Skip to content

Commit

Permalink
Merge branch 'duneanalytics:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
viniabussafi authored Sep 23, 2024
2 parents f0a69e2 + 3b75fac commit 5c8db83
Show file tree
Hide file tree
Showing 150 changed files with 4,144 additions and 1,296 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ dbt_macros/dune/create_views_of_dependencies.sql
dbt_macros/dune/alter_table_locations.sql
scripts/integration_test/test_diffs_tokens/*
.vs
dbt_subprojects/manifests/*


# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down Expand Up @@ -146,3 +148,4 @@ logs/
!target/manifest.json
!target/run_results.json
!target/sources.json

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ filtered_daily_agg_balances as (
END as balance,
erc20_tokens.symbol as token_symbol,
token_id
from {{ref('tokens_'~blockchain~'_balances_daily_agg_base')}} b
from {{source('tokens_'~blockchain,'balances_daily_agg_base')}} b
{% if address_list is not none %}
inner join (select distinct address from {{address_list}}) f1
on f1.address = b.address
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ logs as (
, block_number
, block_time
, tx_hash
, tx_from
, tx_to
, index
, contract_address
, topic0
Expand Down Expand Up @@ -250,6 +252,8 @@ select
, block_number
, block_time
, tx_hash
, tx_from
, tx_to
, tx_success
, call_from
, call_to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ select
block_number
, block_time
, tx_hash
, tx_from
, tx_to
, index
, contract_address
, topic0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,13 @@ models:
description: "The amount of tokens involved in the transaction"
- name: price_usd
description: "The USD price of the fungibles used in the transaction"
- name: heroes_revenue
description: "The revenue generated for heroes"
- name: heroes_revenue_usd
description: "The revenue generated for heroes in USD"
- name: to_fantasy_treasury
description: "The amount going to fantasy's treasury excluding direct hero rewards"
- name: to_fantasy_treasury_usd
description: "The amount in USD going to fantasy's treasury excluding direct hero rewards"
- name: tactics_bought
description: "The amount of tactics tickets bought"
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ SELECT m.evt_block_time AS block_time
, 0x4300000000000000000000000000000000000004 AS token_address
, m.price/POWER(10, 18) AS token_amount
, m.price/POWER(10, 18)*pu.price AS price_usd
, 0.1*m.price/POWER(10, 18) AS heroes_revenue
, 0.1*m.price/POWER(10, 18)*pu.price AS heroes_revenue_usd
, 0.9*m.price/POWER(10, 18) AS to_fantasy_treasury
, 0.9*m.price/POWER(10, 18)*pu.price AS to_fantasy_treasury_usd
, 0 AS tactics_bought
FROM {{ source('fantasy_blast', 'Minter_evt_Mint')}} m
INNER JOIN fantasy_configs c ON m.mintConfigId=c.config_id
Expand Down Expand Up @@ -100,6 +104,10 @@ SELECT evt_block_time AS block_time
, CAST(NULL AS varbinary) AS token_address
, 0 AS token_amount
, 0 AS price_usd
, 0 AS heroes_revenue
, 0 AS heroes_revenue_usd
, 0 AS to_fantasy_treasury
, 0 AS to_fantasy_treasury_usd
, 0 AS tactics_bought
FROM {{ source('fantasy_blast', 'Minter_evt_LevelUp')}}

Expand Down Expand Up @@ -128,6 +136,10 @@ SELECT evt_block_time AS block_time
, CAST(NULL AS varbinary) AS token_address
, 0 AS token_amount
, 0 AS price_usd
, 0 AS heroes_revenue
, 0 AS heroes_revenue_usd
, 0 AS to_fantasy_treasury
, 0 AS to_fantasy_treasury_usd
, 0 AS tactics_bought
FROM {{ source('fantasy_blast', 'Minter_evt_BurnToDraw')}}

Expand Down Expand Up @@ -156,6 +168,10 @@ SELECT nftt.block_time
, nftt.currency_contract AS token_address
, nftt.amount_original AS token_amount
, nftt.amount_usd AS price_usd
, royalty_fee_amount AS heroes_revenue
, royalty_fee_amount_usd AS heroes_revenue_usd
, platform_fee_amount AS to_fantasy_treasury
, platform_fee_amount_usd AS to_fantasy_treasury_usd
, 0 AS tactics_bought
FROM {{ source('nft', 'trades') }} nftt
INNER JOIN {{ source('blast', 'transactions') }} txs ON txs.block_number=nftt.block_number
Expand Down Expand Up @@ -191,6 +207,10 @@ SELECT block_time
, contract_address AS token_address
, amount AS token_amount
, amount_usd AS price_usd
, 0.015*amount AS heroes_revenue
, 0.015*amount_usd AS heroes_revenue_usd
, 0.06*amount AS to_fantasy_treasury
, 0.06*amount_usd AS to_fantasy_treasury_usd
, ROUND(amount_usd/19.99) AS tactics_bought
FROM {{ source('tokens_blast', 'transfers') }} tt
WHERE block_number >= 4917909
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
}}

{% set dex_pool_metrics_models = [
source('balancer','pools_metrics_daily')
source('balancer','pools_metrics_daily'),
source('beethoven_x_fantom','pools_metrics_daily'),
source('jelly_swap_sei','pools_metrics_daily')
] %}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,5 +410,178 @@ FROM (VALUES
, (0x5ddf30555ee9545c8982626b7e3b6f70e5c2635f) -- Etherscan
, (0x01bd2da640345f1c29831b7cef9a434298408172) -- Etherscan
, (0x42183725df3be80bcefb3d12528417698c0c8a8c) -- Etherscan
, (0xca980f000771f70b15647069e9e541ef73f71f2f) -- Etherscan
, (0xDa7d7A4640Dfd472D243dceaDF40d0E1DB891Afb) -- Etherscan
, (0xC8d8141643FCfee443f6a7493C76c913Df772333) -- Etherscan
, (0xA42935DC1f5bCa7FF523Dd92c16b2Da268566D70) -- Etherscan
, (0x1f2F10D1C40777AE1Da742455c65828FF36Df387) -- Etherscan
, (0xFB745fa1824bb085362a7f0933017AB41d24e05C) -- Etherscan
, (0x90D61b727f7fB21B93A55CeDF9DF9d2F4fE7D6F4) -- Etherscan
, (0x5e51328C0583094b76f28Cfd532AbC3d454fCfEA) -- Etherscan
, (0x7b4aa82a26f6d864489b1DD905cb591ED4F9C715) -- Etherscan
, (0xF45F62bbb1a3e3eF7376790CD09e190DF6808bB5) -- Etherscan
, (0xBf3033C6dd79d8C773d1E58051E12D5B9B4f9418) -- Etherscan
, (0x7694C1475bE4B0f7E559d17284f03111991cf878) -- Etherscan
, (0x6f1cdbbb4d53d226cf4b917bf768b94acbab6168) -- Etherscan
, (0x2bea56Da3Fd9387A0556d158451538C05E08654a) -- Etherscan
, (0x5F80997936bf86F7F10648897dc40d3b8b04c821) -- Etherscan
, (0x262D2Fa34C66B462604Eda521E5EDE976D5C779C) -- Etherscan
, (0x76b5A83C8c8097E7723Eda897537B6345789B229) -- Etherscan
, (0x50347Cae376b0e3fe90b97858E2fdbeA6FEDFF40) -- Etherscan
, (0xB1ce3eA155A6Eda0B34d958081489F54BdF3Da5F) -- Etherscan
, (0x30Ea35bf5dbe2B80FC2438418848a53A0b194E3B) -- Etherscan
, (0x16B5332DC3439574b2f580f6692B24fEf649DB42) -- Etherscan
, (0xCA980F000771f70B15647069E9E541ef73F71f2f) -- Etherscan
, (0xaaCef30F703A86B259c807812E4feD295Ccb07AE) -- Etherscan
, (0x0bc8332840eEc6f16F1fA846214E628B03558cAf) -- Etherscan
, (0x7A6d324756605B200b7ADAa2795Ae0F930F77dcD) -- Etherscan
, (0x0000000000304a767881fDcCB30FCEB51f6221e2) -- Etherscan
, (0x5aD7c57A50cFB4620aDa929C53f08341Bf11Eb7c) -- Etherscan
, (0xe72889F88f279043206698c50B752FC6eb47b63f) -- Etherscan
, (0x0aeC284D53A2B29747e88d1F29c10fEda7dbfC48) -- Etherscan
, (0x37eb12c7592Fd3A8C1A2F9474D75B5cFC47a6980) -- Etherscan
, (0x29C67dd723F459300363F5C5FbA5FcE8FCe323BD) -- Etherscan
, (0x31A240648e2baf4f9F17225987f6f53fceB1699A) -- Etherscan
, (0xd129D8C12f0e7aA51157D9e6cc3F7Ece2dc84ecD) -- Etherscan
, (0x952E24a9F49a15caC92cF1F6d01B9536959948f4) -- Etherscan
, (0x23b530268c4a1f0BB11fBb0AA2F3ddf0d41cAf22) -- Etherscan
, (0xdcD4c1343b22DBBa8E763417456713A7b6946B93) -- Etherscan
, (0xDD3A6ab30c06ff3d7E5D89EF5f6AE2AeeCeF1A31) -- Etherscan
, (0xDC00E700B1709a9B7a0032f3c84373C2DE00e620) -- Etherscan
, (0xE20Cd9377C204A27952F8B41075F0b8bD1ceEC3d) -- Etherscan
, (0xEF17998601dd5785b909AdD7B2F376299d308ed4) -- Etherscan
, (0x4eb7Fc78CFa4887587E84783e2498c917cAb9fc9) -- Etherscan
, (0xca122E50566cC5a5F0B744c6aF7831C5174f40Fa) -- Etherscan
, (0x5079FC00f00F30000E0c8C083801cFdE000008b6) -- Etherscan
, (0xF1A0b1Dcda71826f507Fb22a5419A9D97EF9E238) -- Etherscan
, (0x32801aB1957Aaad1c65289B51603373802B4e8BB) -- Etherscan
, (0x1B72d900eE50CA200097003100001F30aE00495b) -- Etherscan
, (0x6aF422F2f375F3A43182A1b743E72E608fe0b1d4) -- Etherscan
, (0x400900032E970DE2Dcf81F7E430569099d36ADAd) -- Etherscan
, (0x9f51040aEc194a89cb6a7e852E79Ea07Cc0bF648) -- Etherscan
, (0xCdBAB0eB5325aC82bb684a185bA84dbdc8d5e4D3) -- Etherscan
, (0x7a6955333D76D702E17e0B5593D6B553D9eE813c) -- Etherscan
, (0x2F17d3ceB71Ad380441A90f8Cb1882D91819E0F1) -- Etherscan
, (0x34E6Fd53C6C10141774a28de9520e21af6274d4B) -- Etherscan
, (0xcAC964bF34F0643F8BbBa2e6a0e2750f8b436f65) -- Etherscan
, (0x3f242a8F14A5A4C7346658f501fa94DBEec1e5FF) -- Etherscan
, (0x9878644ad744a970D3598594f1cdbb1389c17826) -- Etherscan
, (0x2C2C82e7CAf5F14e4995c366D9DB8CdFdf7677E3) -- Etherscan
, (0x6BbE6b6F726C08a8E447CbBc7573c880339C4e2A) -- Etherscan
, (0xA4a343f900B1f0aFc140AF985F307B53629B1bCa) -- Etherscan
, (0xCF8b0F9422084695ef702bFce33976982FF3304b) -- Etherscan
, (0x605e35E88b2EBA3fF084045D8EB8ae881c7E9dcB) -- Etherscan
, (0xAf8887864653A612c928256943f073221E9FC1BF) -- Etherscan
, (0x380Bf264BD8eE2e52d58d23834Ad36C30f1A1778) -- Etherscan
, (0xe76014c179F19dA26Bb30A0f085FF0A466B92829) -- Etherscan
, (0x00000000009E50a7dDb7a7B0e2ee6604fd120E49) -- Etherscan
, (0x73a8a6F5d9762EA5f1de193eC19CdF476C7e86b1) -- Etherscan
, (0x77d5f03822f94B39ad6117F6a46761EC5879031b) -- Etherscan
, (0x4736B02DB015DCD1A57a69c889D073b100000000) -- Etherscan
, (0x18AbedEbf76e1E6FdEb3aE0A5Dd06DAa28112aBF) -- Etherscan
, (0x64545160d28Fd0E309277C02D6d73b3923Cc4bFA) -- Etherscan
, (0xF03f1A572792339f625e44A1c304eC826659c259) -- Etherscan
, (0xb13c95E00312e301085d29ebB84c21fCA663dAae) -- Etherscan
, (0x826A4f4DA02588737d3c27325B14F39b5151CA3C) -- Etherscan
, (0x2b8Bc3f432f5a95Aadd0593D39e8bf8A0174B7a4) -- Etherscan
, (0x2C10f2e3c2Eaa722b78dbD9f7661Ee22520554e6) -- Etherscan
, (0x97C1A26482099363cb055f0F3Ca1D6057Fe55447) -- Etherscan
, (0x74b667caba0583695817F05c4cD684fB561B3f1D) -- Etherscan
, (0xaAFb85ad4a412dd8adC49611496a7695A22f4aeb) -- Etherscan
, (0x8Ce45e650aB17B6CA0dD6071f7c2B5c69B5b42b2) -- Etherscan
, (0x6a5eF39f58C80e42642b9210Bf74f20666A2E6b6) -- Etherscan
, (0xA8E1aeD437f83898784fDc5c0256412F10bE33AE) -- Etherscan
, (0xD4674001A9a66b31F3c09E3b1Fec465404c83d35) -- Etherscan
, (0xea907797Dd7243DE1ae030d97279eDde936AE779) -- Etherscan
, (0x83eF3D446Bd1220C8261251f83AC5cc51311d600) -- Etherscan
, (0x187e8e5c70457C756A5779AEB2227eF098bCA776) -- Etherscan
, (0xbaDC0de76438f9524D42C219b390636196bfbdFc) -- Etherscan
, (0x67981A396852EA0Cba2A687b427FA71F7739d1cF) -- Etherscan
, (0xd58Db780bC6A23aC39da7A7b85e7B4B64610bf20) -- Etherscan
, (0x04c613CE5Be6A8fda3A441163975a62909b337d7) -- Etherscan
, (0x2EcD8f51Fa432415fe8F385b8b369f13EFF16FcB) -- Etherscan
, (0x0d531E9bFcc88C42A4A707162b853d233eb586Fc) -- Etherscan
, (0x4Ab12E7CE31857Ee022f273e8580F73335a73c0B) -- Etherscan
, (0x2Cf73796Be4613151a05A90bD4625225C8198c9C) -- Etherscan
, (0xB93D5724e4dd2895f38e27D5D84208018818bEA1) -- Etherscan
, (0x00000000000Ba9Cd9F5175108141A82B6c24d727) -- Etherscan
, (0x738e79fBC9010521763944ddF13aAD7f61502221) -- Etherscan
, (0x1810A6F790f2A007D66548D78B52b7123054F325) -- Etherscan
, (0x525145f821D8D2ABb494c454E9445E14c817F7cb) -- Etherscan
, (0xBdB241F7fd4eD7f0F40fC6C26B7C1F8Dd21b6C49) -- Etherscan
, (0x8D7f71C25FB581b7ba2EFbB10345d262d1852Ff5) -- Etherscan
, (0x1Ae235406e5dF15E7c8E55dF6C16e643Eea44d17) -- Etherscan
, (0x5e638aC1700e5aD5F937df30Cb5BBC51A5A4C1EC) -- Etherscan
, (0xd7a00569aFc56eAF88485845c5e3fE8507912eCa) -- Etherscan
, (0xcB83cA9633Ad057Bd88A48a5B6e8108D97Ad4472) -- Etherscan
, (0xe5bba2Bde7D4192D4b986E9e87A39f0C0dadEB38) -- Etherscan
, (0x5f9Ecf757137d5Ef4330aB72d18163c2f221befD) -- Etherscan
, (0x70E86223507724BF2C51Fe3AC2CC78C67BFAD366) -- Etherscan
, (0xbEb5fD030ffB0FBc95d68113c1C796Eff65526d7) -- Etherscan
, (0xD198fBE60C49D4789525fC54567447518C7D2a11) -- Etherscan
, (0xBC54CB8F702f6F404Aa83D986Ee793dB5C4e5359) -- Etherscan
, (0x53FacEe52e897740B140F5304E9Cd9DC6238d735) -- Etherscan
, (0x8d27C03FA77f30AF3Dce552ddE5bAbF65d14861f) -- Etherscan
, (0xdEA6fdEA0471ce1545331B7b93Fdbd43786fa4c2) -- Etherscan
, (0x0000000000450702bC4f750fD1E7Ecad7054c4f1) -- Etherscan
, (0x7D23E5c85C9525b777ba9B317f4aA271d33B69A5) -- Etherscan
, (0x430A350E685fA0D49eb2FBd83aBDE6d2b796aDB0) -- Etherscan
, (0xa52A64501E816016030511aea0445F1A97EE6694) -- Etherscan
, (0x73b2416e1CBAFBf6112aBfdCF10991Bd0705F715) -- Etherscan
, (0xA515d8b58233fd37B00C087028121DeB1A4F3bB0) -- Etherscan
, (0xECB03B9a0E7F7B5E261d3Ef752865af6621a54Fe) -- Etherscan
, (0x073197fa2656bdAf1ca018b7b333379683B1D8aD) -- Etherscan
, (0x7701Aaa4dFDB9107815DD3e36e0Bf134417c02b0) -- Etherscan
, (0xF1b0475ab021F37b971013B4222E510A8679BEdF) -- Etherscan
, (0x760762B30991A01F492E9ff067583a0C85d5768F) -- Etherscan
, (0xD460F9384f5328cf93dF6970cDBFe392BE03D006) -- Etherscan
, (0xf411fcA55E1a892C9Ba6D04AbE5Ca26eC1764D2B) -- Etherscan
, (0x5B1315BBEa9216ebB840816040E2C19AfCCE59A8) -- Etherscan
, (0x9ba88D864B204845eB95f202C6649B126bE8892A) -- Etherscan
, (0xF67d5Fe8b3B6DDD964448C0F6dA09bdEA6d58BC4) -- Etherscan
, (0x8793C6aA63CC96c955DA4906f628DC09cd595dC8) -- Etherscan
, (0x874DaCa3729fE54d930D810A71Cbaa1A47Af08e5) -- Etherscan
, (0xba13ca85129bA6bC80934A828fce04331268E953) -- Etherscan
, (0x059324620f5324c87ddeb4204Aa1Fbc59AC2779a) -- Etherscan
, (0x7B9AB5cdc4B1ff7d541F4de11E210f6e57f8c6Fc) -- Etherscan
, (0x25e849E019000018D8E400bf0007000888e66000) -- Etherscan
, (0x000000000000feA5F4B241F9E77B4D43B76798a9) -- Etherscan
, (0x5ED5dD65aB0dC1bCCC44eedAa40680C231FAaa9F) -- Etherscan
, (0xfbEedCFe378866DaB6abbaFd8B2986F5C1768737) -- Etherscan
, (0x63756A3C3BF677BAAB9D9e06457402ED05BE8570) -- Etherscan
, (0x4E69A51f24F5A46919113cc78Ab262Da74A4611D) -- Etherscan
, (0xc6feCDF760Af24095cDEd954dE7d81aB49f8Bae1) -- Etherscan
, (0x000000E1fDDF4fE15DB5f23aE3eE83C6A11E8Dd1) -- Etherscan
, (0x797A05dd6a8bfC1E1eaAa62E744D3Aff197C46b1) -- Etherscan
, (0x136F79961B7AB2A91104eC892c288E225E100214) -- Etherscan
, (0xe6AE75bE7c9317AF842B8F2c2Cd6DC7F49F17184) -- Etherscan
, (0xcC2687c14915Fd68226cCF388842515739A739BD) -- Etherscan
, (0x4B8c0A0df725750aeb948816B4dffeCD32ee9008) -- Etherscan
, (0x356cfd6e6D0000400000003900b415f80669009e) -- Etherscan
, (0x030f11Dcba56b8038c3c94F056ea68dC7668630E) -- Etherscan
, (0x64E6D37c95C066C4F2401e28C2E3bdEec06e2ED8) -- Etherscan
, (0x6980a47beE930a4584B09Ee79eBe46484FbDBDD0) -- Etherscan
, (0x8db64ee50717a0418adf9Ad99D8685318d4D4579) -- Etherscan
, (0x000000000055217587F821917562867172942189) -- Etherscan
, (0x7d32C90762E22379235FC311fDB16fAB399Ed40A) -- Etherscan
, (0xAc682Edd8729d679d6c044cf44e975d5B8FCF90f) -- Etherscan
, (0xB78DfC0C14016Ebb4678D7949Ad6e4b8ba14e634) -- Etherscan
, (0x00000000000006b2AB6deCBC6FC7Ec6bD2Fbc720) -- Etherscan
, (0x2deaE6ce94D65aC1DE19a1FC4Bb160C4E02C92EF) -- Etherscan
, (0x3C005bA2000F0000ba000d69000AC8Ec003800BC) -- Etherscan
, (0x615c8c3675E6f683E201553939508E6ADE823634) -- Etherscan
, (0x4b06DCA23845adC723bD059a7D73333195894bF6) -- Etherscan
, (0x4f7A67464B5976d7547c860109e4432d50AfB38e) -- Etherscan
, (0x00000000000086dEcebE6f366c172Cb10d69eB3A) -- Etherscan
, (0x34B689c61aF149C3Bb904B8407abc0bfB6A622F6) -- Etherscan
, (0xB59A226a2b8A2F2b0512bAA35CC348b6b213b671) -- Etherscan
, (0xCE966eC69B1416359C1f88b1683Ab239BA8620ed) -- Etherscan
, (0xc608c92cC34781F5bA300A7e69e4917FAA7cA87e) -- Etherscan
, (0x6EA7fb8e16c1f03fba90f891567b520Bf4CA6F6a) -- Etherscan
, (0x8011D6C888214b3aEA276A6D9d893578D8B25B03) -- Etherscan
, (0x0000009072063E8accCD96346df848dE0D2E57f4) -- Etherscan
, (0xa3274568F95C628D2A2383Fac9De1FAC220fAd48) -- Etherscan
, (0x24587E3C20AE309943589782Dfa25478Fa6e0e11) -- Etherscan
, (0x8c959215f998eA8D02400fD299832576E6720ecb) -- Etherscan
, (0xF9C977B4dCc279360390fC3BB11D0a935709Fa88) -- Etherscan

) AS x (address)
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{{ config(
schema = 'beethoven_x_fantom',
alias = 'pools_metrics_daily',
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'blockchain', 'project', 'version', 'project_contract_address'],
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_date')],
post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\',
spell_type = "project",
spell_name = "beethoven_x_fantom",
contributors = \'["viniabussafi", "metacrypto"]\') }}'
)
}}


WITH
trades AS(
SELECT
block_date,
version,
blockchain,
project_contract_address,
sum(amount_usd) AS swap_amount_usd
FROM {{ source('beethoven_x', 'trades') }}
{% if is_incremental() %}
WHERE {{incremental_predicate('block_date')}}
{% endif %}
GROUP BY 1, 2, 3, 4
),

liquidity AS(
SELECT
day AS block_date,
blockchain,
version,
pool_address AS project_contract_address,
pool_type,
pool_symbol,
sum(pool_liquidity_usd) AS tvl_usd,
sum(pool_liquidity_eth) AS tvl_eth
FROM {{ ref('beethoven_x_fantom_liquidity') }}
{% if is_incremental() %}
WHERE {{incremental_predicate('day')}}
{% endif %}
GROUP BY 1, 2, 3, 4, 5, 6
),

fees AS(
SELECT
day,
version,
blockchain,
pool_address,
sum(protocol_fee_collected_usd) AS fee_amount_usd
FROM {{ ref('beethoven_x_fantom_protocol_fee') }}
{% if is_incremental() %}
WHERE {{incremental_predicate('day')}}
{% endif %}
GROUP BY 1, 2, 3, 4
)

SELECT
l.blockchain,
'beethoven_x_fantom' AS project,
l.version,
l.block_date,
l.project_contract_address,
l.pool_symbol,
l.pool_type,
t.swap_amount_usd,
l.tvl_usd,
l.tvl_eth,
f.fee_amount_usd
FROM liquidity l
LEFT JOIN trades t ON l.block_date = t.block_date
AND l.project_contract_address = t.project_contract_address
AND l.blockchain = t.blockchain
LEFT JOIN fees f ON l.block_date = f.day
AND l.project_contract_address = f.pool_address
AND l.blockchain = f.blockchain
ORDER BY 1 DESC, 7 DESC
Loading

0 comments on commit 5c8db83

Please sign in to comment.