From 42c9e1d5bc0f82bb38a79829a590e50f42042b67 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:15:36 -0300 Subject: [PATCH 001/127] add missing tokens to tokens.erc20 (#6719) --- .../tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql | 2 ++ dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql index 4c7e7a1e8d1..129b66ba938 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql @@ -98,4 +98,6 @@ FROM (VALUES , (0xbC404429558292eE2D769E57d57D6E74bbd2792d, 'sUSX', 18) , (0xa1b91fe9fd52141ff8cac388ce3f10bfdc1de79d, '$WIF', 6) , (0x90364aa61234b85251ad943681433904c35fa5ce, 'METIS', 18) + , (0x4026affabd9032bcc87fa05c02f088905f3dc09b, 'SWISE', 18) + , (0xf6d22e29496313d89ad6261fbae8d118181561de, 'GT', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql index 27212fb28f3..b90ccc6add7 100644 --- a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql @@ -253,4 +253,5 @@ FROM (VALUES , (0x190b2aA820495c0e92840E8FA699741976cd6439, 'rETH', 18) , (0x85e90a5430af45776548adb82ee4cd9e33b08077, 'DINO', 18) , (0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2, 'BAL', 18) + , (0xa1e4240C9E9B8db3ba9e7625A9571c3B0FF71988, 'PJ', 18) ) AS temp_table (contract_address, symbol, decimals) From a64b70d4e124f21bcc586b6d9e7475386031631a Mon Sep 17 00:00:00 2001 From: Lydia Puspita <113081740+lydiapuspita@users.noreply.github.com> Date: Mon, 16 Sep 2024 21:15:54 +0700 Subject: [PATCH 002/127] Update prices_ethereum_tokens.sql (#6718) Add FTW token price --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 2292ea46d17..76429822bcd 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1826,7 +1826,8 @@ FROM ('usdy-ondo-us-dollar-yield', 'ethereum', 'USDY', 0x96f6ef951840721adbf46ac996b59e0235cb985c, 18), ('pzeth-renzo-restaked-lst', 'ethereum', 'pzETH', 0x8c9532a60E0E7C6BbD2B2c1303F63aCE1c3E9811, 18), ('sx-sx-network', 'ethereum', 'SX', 0xbe9f61555f50dd6167f2772e9cf7519790d96624, 18), - ('rch-rch-token', 'ethereum', 'RCH', 0x57B96D4aF698605563A4653D882635da59Bf11AF, 18) + ('rch-rch-token', 'ethereum', 'RCH', 0x57B96D4aF698605563A4653D882635da59Bf11AF, 18), + ('ftw-black-agnus', 'ethereum', 'FTW', 0x306fD3e7b169Aa4ee19412323e1a5995B8c1a1f4, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( -- bad price feeds From f95328c4ee0969353b0f238ab1a08d76dee836e7 Mon Sep 17 00:00:00 2001 From: notnotsez <32350669+sereenaa@users.noreply.github.com> Date: Tue, 17 Sep 2024 00:16:05 +1000 Subject: [PATCH 003/127] Update prices_zksync_tokens.sql (#6715) * Update prices_zksync_tokens.sql * update prices_zksync_tokens.sql * Update prices_zksync_tokens.sql --- .../tokens/models/prices/zksync/prices_zksync_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql b/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql index 94a724e056e..d8b270cf6f0 100644 --- a/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql @@ -56,6 +56,7 @@ FROM ('zat-zkapes-token', 'zksync', 'ZAT', 0x47EF4A5641992A72CFd57b9406c9D9cefEE8e0C4, 18), ('kat-karat', 'zksync', 'KAT', 0xCDb7D260c107499C80B4b748e8331c64595972a1, 18), ('zkid-zksync-id', 'zksync', 'ZKID', 0x2141d7fe06A1d69c016fC638bA75b6Ef92Fa1435, 18), - ('zk-zksync', 'zksync', 'ZK', 0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E, 18) + ('zk-zksync', 'zksync', 'ZK', 0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E, 18), + ('weeth-wrapped-eeth', 'zksync', 'weETH', 0xc1fa6e2e8667d9be0ca938a54c7e0285e9df924a, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 8839dacb779379d8ac9c57161326b0ae57e89151 Mon Sep 17 00:00:00 2001 From: Raho <87493564+raho1@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:16:19 -0500 Subject: [PATCH 004/127] Update prices_scroll_tokens.sql (#6714) * Update prices_scroll_tokens.sql * Update prices_scroll_tokens.sql Add pufETH, sUSDe, and USDe prices to Scroll token prices --- .../tokens/models/prices/scroll/prices_scroll_tokens.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/scroll/prices_scroll_tokens.sql b/dbt_subprojects/tokens/models/prices/scroll/prices_scroll_tokens.sql index 7a789506aa0..b750d136d72 100644 --- a/dbt_subprojects/tokens/models/prices/scroll/prices_scroll_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/scroll/prices_scroll_tokens.sql @@ -31,5 +31,8 @@ FROM ('pxeth-pirex-ether', 'scroll', 'pxETH ', 0x9e0d7d79735e1c63333128149c7b616a0dc0bbdb, 18), ('frxeth-frax-ether', 'scroll', 'frxETH ', 0xecc68d0451e20292406967fe7c04280e5238ac7d, 18), ('weeth-wrapped-eeth', 'scroll', 'weETH ', 0x01f0a31698C4d065659b9bdC21B3610292a1c506, 18), - ('solvbtc-solv-protocol-solvbtc', 'scroll', 'SolvBTC ', 0x3ba89d490ab1c0c9cc2313385b30710e838370a4, 18) + ('solvbtc-solv-protocol-solvbtc', 'scroll', 'SolvBTC ', 0x3ba89d490ab1c0c9cc2313385b30710e838370a4, 18), + ('pufeth-pufeth', 'scroll', 'pufETH ', 0xc4d46E8402F476F269c379677C99F18E22Ea030e, 18), + ('usde-ethena-usde', 'scroll', 'USDe', 0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34, 18), + ('susde-ethena-staked-usde', 'scroll', 'sUSDe', 0x211Cc4DD073734dA055fbF44a2b4667d5E5fE5d2, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 9831eb2582c9ec37c9de801105502edeee50e22b Mon Sep 17 00:00:00 2001 From: Rantum Date: Mon, 16 Sep 2024 07:17:20 -0700 Subject: [PATCH 005/127] add tokens (#6694) * add tokens * remove pvc * remove dup --------- Co-authored-by: Huang Geyang Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../tokens/models/prices/base/prices_base_tokens.sql | 10 +++++++++- .../tokens/models/prices/bnb/prices_bnb_tokens.sql | 8 +++++++- .../models/prices/ethereum/prices_ethereum_tokens.sql | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql index 9bcb22954d8..0ff677af4e8 100644 --- a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql @@ -157,5 +157,13 @@ FROM ('aerobud-aerobud','base','AEROBUD',0xfad8cb754230dbfd249db0e8eccb5142dd675a0d, 18), --('normie1-normie','base','NORMIE',0x7f12d13b34f5f4f0a9449c16bcd42f0da47af200, 9), --token inactive ('ethb-ethereum-on-base','base','ETHB',0x8d285df5be4570097e84241090fca8034ab18547, 18), - ('pepe-pepe-on-base','base','PEPE',0x80f45eacf6537498ecc660e4e4a2d2f99e195cf4, 18) + ('pepe-pepe-on-base','base','PEPE',0x80f45eacf6537498ecc660e4e4a2d2f99e195cf4, 18), + ('bum-willybumbum','base','BUM',0x4b8ec286fd218adb992e3df1a8d9fcf6de38d583, 18), + ('nippy-cat-on-catnip','base','NIPPY',0x7a31512fb17be839b24276c211e941932c9d20e1, 18), + ('roxy-roxy-frog','base','ROXY',0x10a7a84c91988138f8dbbc82a23b02c8639e2552, 18), + ('pov-degen-pov','base','POV',0x4c96a67b0577358894407af7bc3158fc1dffbeb5, 18), + ('chomp-chompcoin','base','CHOMP',0xebff2db643cf955247339c8c6bcd8406308ca437, 18), + ('birddog-bird-dog-on-base','base','BIRDDOG',0x92af6f53febd6b4c6f5293840b6076a1b82c4bc2, 18), + ('albert-albert-the-alien','base','ALBERT',0x0c067fc190cde145b0c537765a78d4e19873a5cc, 18), + ('tn100x-tn100x','base','TN100X',0x5b5dee44552546ecea05edea01dcd7be7aa6144a, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql index 5ed8c85bd96..6269bff3876 100644 --- a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql @@ -270,7 +270,13 @@ FROM ('wsm-wall-street-memes', 'bnb', 'WSM', 0xb62e45c3df611dce236a6ddc7a493d79f9dfadef, 18), ('the-thena', 'bnb', 'THE', 0xf4c8e32eadec4bfe97e0f595add0f4450a863a11, 18), ('lista-lista-dao', 'bnb', 'LISTA', 0xfceb31a79f71ac9cbdcf853519c1b12d379edc46, 18), - ('opul-opuloustoken-via-chainportio', 'bnb', 'OPUL', 0x686318000d982bc8dcc1cdcf8ffd22322f0960ed, 18) + ('opul-opuloustoken-via-chainportio', 'bnb', 'OPUL', 0x686318000d982bc8dcc1cdcf8ffd22322f0960ed, 18), + ('pepe-pepecoin-bsc', 'bnb', 'PEPE', 0xb46584e0efde3092e04010a13f2eae62adb3b9f0, 18), + ('babydoge-baby-doge-coin', 'bnb', 'BABYDOGE', 0xc748673057861a797275cd8a068abb95a902e8de, 9), + ('bwjup-bsc-wrapped-jupiter', 'bnb', 'bwJUP', 0x0231f91e02debd20345ae8ab7d71a41f8e140ce7, 18), + ('lovely-lovely-inu-finance', 'bnb', 'LOVELY', 0x9e24415d1e549ebc626a13a482bb117a2b43e9cf, 8), + --('pvc-pvc-meta','bnb','PVC',0x75ca521892de7f2ecfb070cab545c250d0ceb7e3, 9), --token_id not found + ('bvsd-bvsd','bnb','BVSD',0x7f9ad7a5854658d984924e868187b2135514fb88, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( 0x2ab0e9e4ee70fff1fb9d67031e44f6410170d00e -- bXEN has bad price feed. diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 76429822bcd..0b440a8e7ce 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1827,6 +1827,11 @@ FROM ('pzeth-renzo-restaked-lst', 'ethereum', 'pzETH', 0x8c9532a60E0E7C6BbD2B2c1303F63aCE1c3E9811, 18), ('sx-sx-network', 'ethereum', 'SX', 0xbe9f61555f50dd6167f2772e9cf7519790d96624, 18), ('rch-rch-token', 'ethereum', 'RCH', 0x57B96D4aF698605563A4653D882635da59Bf11AF, 18), + ('neiro3-neiro', 'ethereum', 'NEIRO', 0xee2a03aa6dacf51c18679c516ad5283d8e7c2637, 9), + ('neiro-first-neiro-on-ethereum', 'ethereum', 'NEIRO', 0x812ba41e071c7b7fa4ebcfb62df5f45f6fa853ee, 9), + ('fuku-fuku-kun', 'ethereum', 'FUKU', 0x1001271083c249bd771e1bb76c22d935809a61ee, 9), + ('elon-elon-memelord', 'ethereum', 'ELON', 0x69420e3a3aa9e17dea102bb3a9b3b73dcddb9528, 9), + ('bar-gold-standard', 'ethereum', 'BAR', 0x777be1c6075c20184c4fd76344b7b0b7c858fe6b, 18), ('ftw-black-agnus', 'ethereum', 'FTW', 0x306fD3e7b169Aa4ee19412323e1a5995B8c1a1f4, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( From 031d9eacf0f22173c27dda2dac9da38617e0da29 Mon Sep 17 00:00:00 2001 From: tomfutago <35136350+tomfutago@users.noreply.github.com> Date: Mon, 16 Sep 2024 15:17:58 +0100 Subject: [PATCH 006/127] add new weeth aggregator (#6716) --- .../ethereum/chainlink_ethereum_price_feeds_oracle_addresses.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_subprojects/daily_spellbook/models/chainlink/ethereum/chainlink_ethereum_price_feeds_oracle_addresses.sql b/dbt_subprojects/daily_spellbook/models/chainlink/ethereum/chainlink_ethereum_price_feeds_oracle_addresses.sql index 6b586f3125e..16f69225c79 100644 --- a/dbt_subprojects/daily_spellbook/models/chainlink/ethereum/chainlink_ethereum_price_feeds_oracle_addresses.sql +++ b/dbt_subprojects/daily_spellbook/models/chainlink/ethereum/chainlink_ethereum_price_feeds_oracle_addresses.sql @@ -366,6 +366,7 @@ FROM (values ('{{ust_usd}}', 8, 0x8b6d9085f310396C6E4f0012783E9f850eaa8a82, 0x01b87e7fF78022A70394d3C6Dd127D0c709e3beA), ('{{ust_usd}}', 8, 0x8b6d9085f310396C6E4f0012783E9f850eaa8a82, 0x5EDd5F803b831b47715aD3e11a90dD244F0cD0a9), ('{{veefriends_floor_price}}', 18, 0x35bf6767577091E7f04707c0290b3f889e968307, 0xe0552DC960366F67Da00CB3d9DF441F24B5C2AC1), + ('{{weeth_eth}}', 18, 0x5c9C449BbC9a6075A2c061dF312a35fd1E05fF22, 0x0F316F6b0c2e2eBE3C3a8b23F6c61009238D51fD), ('{{weeth_eth}}', 18, 0x5c9C449BbC9a6075A2c061dF312a35fd1E05fF22, 0x4dF36F726d8059d881294166dB52c1D13e976FE7), ('{{wbtc_btc}}', 8, 0xfdFD9C85aD200c506Cf9e21F1FD8dd01932FBB23, 0xD7623f1d24b35c392862fB67C9716564A117C9DE), ('{{wbtc_por}}', 8, 0xa81FE04086865e63E12dD3776978E49DEEa2ea4e, 0xB622b7D6d9131cF6A1230EBa91E5da58dbea6F59), From 7dd1750bd285cbfc19d2324272aee03e016c58c7 Mon Sep 17 00:00:00 2001 From: whale_hunter <143016036+whalehunting@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:18:12 +0200 Subject: [PATCH 007/127] feat: add chainswap spellbook (#6688) * add files from PR #6332 * chore: add new deployer addresses * fix: add incremental filters to arbitrum query * Add columns in schema --------- Co-authored-by: Huang Geyang --- .../arbitrum/chain_swap_arbitrum_trades.sql | 149 +++++++ .../chain_swap_avalanche_c_trades.sql | 150 +++++++ .../chainswap/base/chain_swap_base_trades.sql | 154 +++++++ .../chainswap/bnb/chain_swap_bnb_trades.sql | 149 +++++++ .../models/chainswap/chain_swap_schema.yml | 380 ++++++++++++++++++ .../models/chainswap/chain_swap_trades.sql | 59 +++ .../ethereum/chain_swap_ethereum_trades.sql | 152 +++++++ .../optimism/chain_swap_optimism_trades.sql | 156 +++++++ .../polygon/chain_swap_polygon_trades.sql | 156 +++++++ 9 files changed, 1505 insertions(+) create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/arbitrum/chain_swap_arbitrum_trades.sql create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/avalanche_c/chain_swap_avalanche_c_trades.sql create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/base/chain_swap_base_trades.sql create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/bnb/chain_swap_bnb_trades.sql create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_schema.yml create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_trades.sql create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/ethereum/chain_swap_ethereum_trades.sql create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/optimism/chain_swap_optimism_trades.sql create mode 100644 dbt_subprojects/daily_spellbook/models/chainswap/polygon/chain_swap_polygon_trades.sql diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/arbitrum/chain_swap_arbitrum_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/arbitrum/chain_swap_arbitrum_trades.sql new file mode 100644 index 00000000000..c83e6121cf0 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/arbitrum/chain_swap_arbitrum_trades.sql @@ -0,0 +1,149 @@ +{{ + config( + alias='trades', + schema='chain_swap_arbitrum', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_start_date = '2024-03-19' %} +{% set blockchain = 'arbitrum' %} +{% set deployer_1 = '0x9eC1ACAe39d07E1e8D8B3cEbe7022790D87D744A' %} +{% set deployer_2 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set deployer_3 = '0xc1cc1a300Dcfe5359eBe37f2007A77d1F91533ba' %} +{% set deployer_4 = '0x3A510C5a32bCb381c53704AED9c02b0c70041F7A' %} +{% set deployer_5 = '0xb7b953e81612c57256ff0aebd62b6a2f0546f7da' %} +{% set deployer_6 = '0xb252f0ab7bdf1be4d5bbf607eb5c220b2d902a2c' %} +{% set deployer_7 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set weth_contract_address = '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1' %} +{% set usdc_contract_address = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831' %} +{% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set fee_recipient_2 = '0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad' %} + +with + bot_contracts as ( + select address + from {{ source('arbitrum', 'creation_traces') }} + where + ( + "from" = {{ deployer_1 }} + or "from" = {{ deployer_2 }} + or "from" = {{ deployer_3 }} + or "from" = {{ deployer_4 }} + or "from" = {{ deployer_5 }} + or "from" = {{ deployer_6 }} + or "from" = {{ deployer_7 }} + ) + and block_time >= timestamp '{{project_start_date}}' + ), + bot_trades as ( + select + trades.block_time, + amount_usd, + if(token_sold_address = {{ weth_contract_address }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join bot_contracts on trades.tx_to = bot_contracts.address + where + trades.blockchain = '{{blockchain}}' + and (tx_from != {{ fee_recipient_1 }} and tx_from != {{ fee_recipient_2 }}) + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} + and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ), + fee_deposits as ( + select + evt_tx_hash, + value as fee_token_amount, + contract_address as fee_token_address + from {{ source('erc20_arbitrum', 'evt_transfer') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and evt_block_time >= timestamp '{{project_start_date}}' + and value > 0 + and ( + contract_address = {{ weth_contract_address }} + or contract_address = {{ usdc_contract_address }} + ) + union all + select + tx_hash, + value as fee_token_amount, + {{ weth_contract_address }} as fee_token_address + from {{ source('arbitrum', 'traces') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and block_time >= timestamp '{{project_start_date}}' + and value > 0 + + ) +select distinct + block_time, + date_trunc('day', block_time) as block_date, + date_trunc('month', block_time) as block_month, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + cast(token_bought_address as varchar) as token_bought_address, + token_sold_amount, + token_sold_symbol, + cast(token_sold_address as varchar) as token_sold_address, + -- Fees + fee_token_amount / power(10, decimals) * price as fee_usd, + fee_token_amount / power(10, decimals) as fee_token_amount, + symbol as fee_token_symbol, + cast(fee_token_address as varchar) as fee_token_address, + -- Dex + project, + version, + token_pair, + cast(project_contract_address as varchar) as project_contract_address, + -- User + cast(user as varchar) as user, + cast(bot_trades.tx_hash as varchar) as tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +/* Left Outer Join to support 0 fee trades */ +left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = fee_token_address + and minute = date_trunc('minute', block_time) + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/avalanche_c/chain_swap_avalanche_c_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/avalanche_c/chain_swap_avalanche_c_trades.sql new file mode 100644 index 00000000000..d66064471be --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/avalanche_c/chain_swap_avalanche_c_trades.sql @@ -0,0 +1,150 @@ +{{ + config( + alias='trades', + schema='chain_swap_avalanche_c', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_start_date = '2024-03-28' %} +{% set blockchain = 'avalanche_c' %} +{% set deployer_1 = '0x9eC1ACAe39d07E1e8D8B3cEbe7022790D87D744A' %} +{% set deployer_2 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set deployer_3 = '0xc1cc1a300Dcfe5359eBe37f2007A77d1F91533ba' %} +{% set deployer_4 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set wavax_contract_address = '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7' %} +{% set usdc_contract_address = '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E' %} +{% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set fee_recipient_2 = '0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad' %} + +with + bot_contracts as ( + select address + from {{ source('avalanche_c', 'creation_traces') }} + where + ( + "from" = {{ deployer_1 }} + or "from" = {{ deployer_2 }} + or "from" = {{ deployer_3 }} + or "from" = {{ deployer_4 }} + ) + and block_time >= timestamp '{{project_start_date}}' + ), + bot_trades as ( + select + trades.block_time, + amount_usd, + if(token_sold_address = {{ wavax_contract_address }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join bot_contracts on trades.tx_to = bot_contracts.address + where + trades.blockchain = '{{blockchain}}' + and (tx_from != {{ fee_recipient_1 }} and tx_from != {{ fee_recipient_2 }}) + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} + and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ), + fee_deposits as ( + select + evt_tx_hash, + value as fee_token_amount, + contract_address as fee_token_address + from {{ source('erc20_avalanche_c', 'evt_transfer') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + and ( + contract_address = {{ wavax_contract_address }} + or contract_address = {{ usdc_contract_address }} + ) + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} + and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + union all + select + tx_hash, + value as fee_token_amount, + {{ wavax_contract_address }} as fee_token_address + from {{ source('avalanche_c', 'traces') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} + and block_time >= timestamp '{{project_start_date}}' + {% endif %} + ) +select distinct + block_time, + date_trunc('day', block_time) as block_date, + date_trunc('month', block_time) as block_month, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + cast(token_bought_address as varchar) as token_bought_address, + token_sold_amount, + token_sold_symbol, + cast(token_sold_address as varchar) as token_sold_address, + -- Fees + fee_token_amount / power(10, decimals) * price as fee_usd, + fee_token_amount / power(10, decimals) as fee_token_amount, + symbol as fee_token_symbol, + cast(fee_token_address as varchar) as fee_token_address, + -- Dex + project, + version, + token_pair, + cast(project_contract_address as varchar) as project_contract_address, + -- User + cast(user as varchar) as user, + cast(bot_trades.tx_hash as varchar) as tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +/* Left Outer Join to support 0 fee trades */ +left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = fee_token_address + and minute = date_trunc('minute', block_time) + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/base/chain_swap_base_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/base/chain_swap_base_trades.sql new file mode 100644 index 00000000000..32ba14c0fb4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/base/chain_swap_base_trades.sql @@ -0,0 +1,154 @@ +{{ + config( + alias='trades', + schema='chain_swap_base', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_start_date = '2024-03-21' %} +{% set blockchain = 'base' %} +{% set deployer_1 = '0x9eC1ACAe39d07E1e8D8B3cEbe7022790D87D744A' %} +{% set deployer_2 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set deployer_3 = '0xc1cc1a300Dcfe5359eBe37f2007A77d1F91533ba' %} +{% set deployer_4 = '0x3A510C5a32bCb381c53704AED9c02b0c70041F7A' %} +{% set deployer_5 = '0xb252f0ab7bdf1be4d5bbf607eb5c220b2d902a2c' %} +{% set deployer_6 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set weth_contract_address = '0x4200000000000000000000000000000000000006' %} +{% set usdc_contract_address = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' %} +{% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set fee_recipient_2 = '0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad' %} + +with + bot_contracts as ( + select address + from {{ source('base', 'creation_traces') }} + where + ( + "from" = {{ deployer_1 }} + or "from" = {{ deployer_2 }} + or "from" = {{ deployer_3 }} + or "from" = {{ deployer_4 }} + or "from" = {{ deployer_5 }} + or "from" = {{ deployer_6 }} + ) + and block_time >= timestamp '{{project_start_date}}' + ), + bot_trades as ( + select + trades.block_time, + amount_usd, + if(token_sold_address = {{ weth_contract_address }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join bot_contracts on trades.tx_to = bot_contracts.address + where + trades.blockchain = '{{blockchain}}' + and (tx_from != {{ fee_recipient_1 }} and tx_from != {{ fee_recipient_2 }}) + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} + and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ), + fee_deposits as ( + select + evt_tx_hash, + value as fee_token_amount, + contract_address as fee_token_address + from {{ source('erc20_base', 'evt_transfer') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + and ( + contract_address = {{ weth_contract_address }} + or contract_address = {{ usdc_contract_address }} + ) + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} + and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + union all + select + tx_hash, + value as fee_token_amount, + {{ weth_contract_address }} as fee_token_address + from {{ source('base', 'traces') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} + and block_time >= timestamp '{{project_start_date}}' + {% endif %} + ) +select distinct + block_time, + date_trunc('day', block_time) as block_date, + date_trunc('month', block_time) as block_month, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + cast(token_bought_address as varchar) as token_bought_address, + token_sold_amount, + token_sold_symbol, + cast(token_sold_address as varchar) as token_sold_address, + -- Fees + fee_token_amount / power(10, decimals) * price as fee_usd, + fee_token_amount / power(10, decimals) as fee_token_amount, + symbol as fee_token_symbol, + cast(fee_token_address as varchar) as fee_token_address, + -- Dex + project, + version, + token_pair, + cast(project_contract_address as varchar) as project_contract_address, + -- User + cast(user as varchar) as user, + cast(bot_trades.tx_hash as varchar) as tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +/* Left Outer Join to support 0 fee trades */ +left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = fee_token_address + and minute = date_trunc('minute', block_time) + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/bnb/chain_swap_bnb_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/bnb/chain_swap_bnb_trades.sql new file mode 100644 index 00000000000..ab069893eaf --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/bnb/chain_swap_bnb_trades.sql @@ -0,0 +1,149 @@ +{{ + config( + alias='trades', + schema='chain_swap_bnb', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_start_date = '2024-06-17' %} +{% set blockchain = 'bnb' %} +{% set deployer_1 = '0x1d32cFeFd97de9D740714A31b2E8C7bc34825442' %} +{% set deployer_2 = '0x3A510C5a32bCb381c53704AED9c02b0c70041F7A' %} +{% set deployer_3 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set wbnb_contract_address = '0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c' %} +{% set usdc_contract_address = '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d' %} +{% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set fee_recipient_2 = '0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad' %} + +with + bot_contracts as ( + select address + from {{ source('bnb', 'creation_traces') }} + where + ( + "from" = {{ deployer_1 }} + or "from" = {{ deployer_2 }} + or "from" = {{ deployer_3 }} + + ) + and block_time >= timestamp '{{project_start_date}}' + ), + bot_trades as ( + select + trades.block_time, + amount_usd, + if(token_sold_address = {{ wbnb_contract_address }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join bot_contracts on trades.tx_to = bot_contracts.address + where + trades.blockchain = '{{blockchain}}' + and (tx_from != {{ fee_recipient_1 }} and tx_from != {{ fee_recipient_2 }}) + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} + and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ), + fee_deposits as ( + select + evt_tx_hash, + value as fee_token_amount, + contract_address as fee_token_address + from {{ source('erc20_bnb', 'evt_transfer') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + and ( + contract_address = {{ wbnb_contract_address }} + or contract_address = {{ usdc_contract_address }} + ) + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} + and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + union all + select + tx_hash, + value as fee_token_amount, + {{ wbnb_contract_address }} as fee_token_address + from {{ source('bnb', 'traces') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} + and block_time >= timestamp '{{project_start_date}}' + {% endif %} + ) +select distinct + block_time, + date_trunc('day', block_time) as block_date, + date_trunc('month', block_time) as block_month, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + cast(token_bought_address as varchar) as token_bought_address, + token_sold_amount, + token_sold_symbol, + cast(token_sold_address as varchar) as token_sold_address, + -- Fees + fee_token_amount / power(10, decimals) * price as fee_usd, + fee_token_amount / power(10, decimals) as fee_token_amount, + symbol as fee_token_symbol, + cast(fee_token_address as varchar) as fee_token_address, + -- Dex + project, + version, + token_pair, + cast(project_contract_address as varchar) as project_contract_address, + -- User + cast(user as varchar) as user, + cast(bot_trades.tx_hash as varchar) as tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +/* Left Outer Join to support 0 fee trades */ +left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = fee_token_address + and minute = date_trunc('minute', block_time) + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_schema.yml b/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_schema.yml new file mode 100644 index 00000000000..caeec0006ce --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_schema.yml @@ -0,0 +1,380 @@ +version: 2 + +models: + - name: chain_swap_trades + meta: + blockchain: ethereum + sector: project + contributors: ["whale_hunter", "clizzard"] + config: + tags: ["ethereum", "dex", "bot", "trades"] + description: > + Trades by trading bots on Ethereum + columns: + - &blockchain + name: blockchain + description: "Blockchain which the DEX is deployed" + - &block_time + name: block_time + description: "UTC event block time of each DEX trade" + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &type + name: type + description: "Wether the trade is a buy or sell" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &fee_usd + name: fee_usd + description: "USD value of the fee at time of execution" + - &fee_token_amount + name: fee_token_amount + description: "Value of the fee paid at time of execution in the original currency" + - &fee_token_symbol + name: fee_token_symbol + description: "Token symbol for fee token" + - &fee_token_address + name: fee_token_address + description: "Contract address of the fee token" + - &project + name: project + description: "Project name of the DEX" + - &version + name: version + description: "Version of the contract built and deployed by the DEX project" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &project_contract_address + name: project_contract_address + description: "Project contract address which executed the trade on the blockchain" + - &user + name: user + description: "Address which initiated the trade" + - &tx_hash + name: tx_hash + description: "Unique transaction hash value tied to each transaction on the DEX" + - &evt_index + name: evt_index + description: "Index of the corresponding trade event" + - &is_last_trade_in_transaction + name: is_last_trade_in_transaction + description: "Wether the trade is the last hop of the trade transaction, in case of a multi-hop trade" + + - name: chain_swap_ethereum_trades + meta: + blockchain: ethereum + sector: project + project: chain_swap + contributors: whale_hunter + config: + tags: ["ethereum", "dex", "chain_swap", "trades"] + description: > + ChainSwap trades on Ethereum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - *blockchain + - *block_time + - *block_date + - *block_month + - *amount_usd + - *type + - *token_bought_amount + - *token_bought_symbol + - *token_bought_address + - *token_sold_amount + - *token_sold_symbol + - *token_sold_address + - *fee_usd + - *fee_token_amount + - *fee_token_symbol + - *fee_token_address + - *project + - *version + - *token_pair + - *project_contract_address + - *user + - *tx_hash + - *evt_index + - *is_last_trade_in_transaction + + - name: chain_swap_arbitrum_trades + meta: + blockchain: arbitrum + sector: project + project: chain_swap + contributors: whale_hunter + config: + tags: ["arbitrum", "dex", "chain_swap", "trades"] + description: > + ChainSwap trades on Arbitrum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - *blockchain + - *block_time + - *block_date + - *block_month + - *amount_usd + - *type + - *token_bought_amount + - *token_bought_symbol + - *token_bought_address + - *token_sold_amount + - *token_sold_symbol + - *token_sold_address + - *fee_usd + - *fee_token_amount + - *fee_token_symbol + - *fee_token_address + - *project + - *version + - *token_pair + - *project_contract_address + - *user + - *tx_hash + - *evt_index + - *is_last_trade_in_transaction + + - name: chain_swap_base_trades + meta: + blockchain: base + sector: project + project: chain_swap + contributors: whale_hunter + config: + tags: ["base", "dex", "chain_swap", "trades"] + description: > + ChainSwap trades on Base + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - *blockchain + - *block_time + - *block_date + - *block_month + - *amount_usd + - *type + - *token_bought_amount + - *token_bought_symbol + - *token_bought_address + - *token_sold_amount + - *token_sold_symbol + - *token_sold_address + - *fee_usd + - *fee_token_amount + - *fee_token_symbol + - *fee_token_address + - *project + - *version + - *token_pair + - *project_contract_address + - *user + - *tx_hash + - *evt_index + - *is_last_trade_in_transaction + + - name: chain_swap_optimism_trades + meta: + blockchain: optimism + sector: project + project: chain_swap + contributors: whale_hunter + config: + tags: ["optimism", "dex", "chain_swap", "trades"] + description: > + ChainSwap trades on Optimism + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - *blockchain + - *block_time + - *block_date + - *block_month + - *amount_usd + - *type + - *token_bought_amount + - *token_bought_symbol + - *token_bought_address + - *token_sold_amount + - *token_sold_symbol + - *token_sold_address + - *fee_usd + - *fee_token_amount + - *fee_token_symbol + - *fee_token_address + - *project + - *version + - *token_pair + - *project_contract_address + - *user + - *tx_hash + - *evt_index + - *is_last_trade_in_transaction + + - name: chain_swap_bnb_trades + meta: + blockchain: bnb + sector: project + project: chain_swap + contributors: whale_hunter + config: + tags: ["bnb", "dex", "chain_swap", "trades"] + description: > + ChainSwap trades on Bnb + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - *blockchain + - *block_time + - *block_date + - *block_month + - *amount_usd + - *type + - *token_bought_amount + - *token_bought_symbol + - *token_bought_address + - *token_sold_amount + - *token_sold_symbol + - *token_sold_address + - *fee_usd + - *fee_token_amount + - *fee_token_symbol + - *fee_token_address + - *project + - *version + - *token_pair + - *project_contract_address + - *user + - *tx_hash + - *evt_index + - *is_last_trade_in_transaction + + - name: chain_swap_polygon_trades + meta: + blockchain: polygon + sector: project + project: chain_swap + contributors: whale_hunter + config: + tags: ["polygon", "dex", "chain_swap", "trades"] + description: > + ChainSwap trades on Polygon + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + columns: + - *blockchain + - *block_time + - *block_date + - *block_month + - *amount_usd + - *type + - *token_bought_amount + - *token_bought_symbol + - *token_bought_address + - *token_sold_amount + - *token_sold_symbol + - *token_sold_address + - *fee_usd + - *fee_token_amount + - *fee_token_symbol + - *fee_token_address + - *project + - *version + - *token_pair + - *project_contract_address + - *user + - *tx_hash + - *evt_index + - *is_last_trade_in_transaction + + - name: chain_swap_avalanche_c_trades + meta: + blockchain: avalanche_c + sector: project + project: chain_swap + contributors: whale_hunter + config: + tags: ["avalanche_c", "dex", "chain_swap", "trades"] + description: > + ChainSwap trades on Avalanche_c + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_hash + - evt_index + + columns: + - *blockchain + - *block_time + - *block_date + - *block_month + - *amount_usd + - *type + - *token_bought_amount + - *token_bought_symbol + - *token_bought_address + - *token_sold_amount + - *token_sold_symbol + - *token_sold_address + - *fee_usd + - *fee_token_amount + - *fee_token_symbol + - *fee_token_address + - *project + - *version + - *token_pair + - *project_contract_address + - *user + - *tx_hash + - *evt_index + - *is_last_trade_in_transaction \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_trades.sql new file mode 100644 index 00000000000..302e5d869be --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/chain_swap_trades.sql @@ -0,0 +1,59 @@ +{{ + config( + schema = 'trades', + alias = 'chain_swap', + materialized = 'view', + post_hook = '{{ expose_spells( + blockchains = \'["ethereum", "base", "avalanche_c", "optimism","polygon", "bnb", "arbitrum"]\', + spell_type = "project", + spell_name = "chain_swap", + contributors = \'["whale_hunter","clizzard"]\') }}' + ) +}} + + + +{% set blockchains = [ + ref('chain_swap_ethereum_trades') + , ref('chain_swap_base_trades') + , ref('chain_swap_arbitrum_trades') + , ref('chain_swap_optimism_trades') + , ref('chain_swap_polygon_trades') + , ref('chain_swap_bnb_trades') + , ref('chain_swap_avalanche_c_trades') +] %} + +{% for blockchain in blockchains %} +SELECT block_time, + block_date, + block_month, + blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + -- Fees + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + -- Dex + project, + version, + token_pair, + project_contract_address, + -- User + user, + tx_hash, + evt_index, + is_last_trade_in_transaction +FROM {{ blockchain }} +{% if not loop.last %} +UNION ALL +{% endif %} +{% endfor %} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/ethereum/chain_swap_ethereum_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/ethereum/chain_swap_ethereum_trades.sql new file mode 100644 index 00000000000..073195a8c12 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/ethereum/chain_swap_ethereum_trades.sql @@ -0,0 +1,152 @@ +{{ + config( + alias="trades", + schema="chain_swap_ethereum", + partition_by=["block_month"], + materialized="incremental", + file_format="delta", + incremental_strategy="merge", + incremental_predicates=[ + incremental_predicate("DBT_INTERNAL_DEST.block_time") + ], + unique_key=["blockchain", "tx_hash", "evt_index"], + ) +}} + +{% set project_start_date = "2024-03-28" %} +{% set blockchain = "ethereum" %} +{% set deployer_1 = "0x9eC1ACAe39d07E1e8D8B3cEbe7022790D87D744A" %} +{% set deployer_2 = "0x415EEc63c95e944D544b3088bc682B759edB8548" %} +{% set deployer_3 = "0xc1cc1a300Dcfe5359eBe37f2007A77d1F91533ba" %} +{% set deployer_4 = "0x3A510C5a32bCb381c53704AED9c02b0c70041F7A" %} +{% set deployer_5 = "0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94" %} +{% set weth_contract_address = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2" %} +{% set usdc_contract_address = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" %} +{% set fee_recipient_1 = "0x415EEc63c95e944D544b3088bc682B759edB8548" %} +{% set fee_recipient_2 = "0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad" %} + +with + bot_contracts as ( + select address + from {{ source("ethereum", "creation_traces") }} + where + ( + "from" = {{ deployer_1 }} + or "from" = {{ deployer_2 }} + or "from" = {{ deployer_3 }} + or "from" = {{ deployer_4 }} + or "from" = {{ deployer_5 }} + ) + and block_time >= timestamp '{{project_start_date}}' + ), + bot_trades as ( + select + trades.block_time, + amount_usd, + if(token_sold_address = {{ weth_contract_address }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source("dex", "trades") }} as trades + join bot_contracts on trades.tx_to = bot_contracts.address + where + trades.blockchain = '{{blockchain}}' + and (tx_from != {{ fee_recipient_1 }} and tx_from != {{ fee_recipient_2 }}) + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} + and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ), + fee_deposits as ( + select + evt_tx_hash, + value as fee_token_amount, + contract_address as fee_token_address + from {{ source("erc20_ethereum", "evt_transfer") }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + and ( + contract_address = {{ weth_contract_address }} + or contract_address = {{ usdc_contract_address }} + ) + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} + and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + union all + select + tx_hash, + value as fee_token_amount, + {{ weth_contract_address }} as fee_token_address + from {{ source("ethereum", "traces") }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} + and block_time >= timestamp '{{project_start_date}}' + {% endif %} + ) +select distinct + block_time, + date_trunc('day', block_time) as block_date, + date_trunc('month', block_time) as block_month, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + cast(token_bought_address as varchar) as token_bought_address, + token_sold_amount, + token_sold_symbol, + cast(token_sold_address as varchar) as token_sold_address, + -- Fees + fee_token_amount / power(10, decimals) * price as fee_usd, + fee_token_amount / power(10, decimals) as fee_token_amount, + symbol as fee_token_symbol, + cast(fee_token_address as varchar) as fee_token_address, + -- Dex + project, + version, + token_pair, + cast(project_contract_address as varchar) as project_contract_address, + -- User + cast(user as varchar) as user, + cast(bot_trades.tx_hash as varchar) as tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +/* Left Outer Join to support 0 fee trades */ +left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join + {{ source("prices", "usd") }} + on ( + blockchain = '{{blockchain}}' + and contract_address = fee_token_address + and minute = date_trunc('minute', block_time) + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/optimism/chain_swap_optimism_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/optimism/chain_swap_optimism_trades.sql new file mode 100644 index 00000000000..db7bb3f0001 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/optimism/chain_swap_optimism_trades.sql @@ -0,0 +1,156 @@ +{{ + config( + alias='trades', + schema='chain_swap_optimism', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_start_date = '2024-03-21' %} +{% set blockchain = 'optimism' %} +{% set deployer_1 = '0xB7B953e81612c57256fF0aebD62B6a2F0546F7dA' %} +{% set deployer_2 = '0xb252f0Ab7BDF1bE4d5BBf607EB5c220B2D902a2C' %} +{% set deployer_3 = '0xc1cc1a300Dcfe5359eBe37f2007A77d1F91533ba' %} +{% set deployer_4 = '0x3A510C5a32bCb381c53704AED9c02b0c70041F7A' %} +{% set deployer_5 = '0x9eC1ACAe39d07E1e8D8B3cEbe7022790D87D744A' %} +{% set deployer_6 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set deployer_7 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set weth_contract_address = '0x4200000000000000000000000000000000000006' %} +{% set usdc_contract_address = '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85' %} +{% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set fee_recipient_2 = '0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad' %} + +with + bot_contracts as ( + select address + from {{ source('optimism', 'creation_traces') }} + where + ( + "from" = {{ deployer_1 }} + or "from" = {{ deployer_2 }} + or "from" = {{ deployer_3 }} + or "from" = {{ deployer_4 }} + or "from" = {{ deployer_5 }} + or "from" = {{ deployer_6 }} + or "from" = {{ deployer_7 }} + ) + and block_time >= timestamp '{{project_start_date}}' + ), + bot_trades as ( + select + trades.block_time, + amount_usd, + if(token_sold_address = {{ weth_contract_address }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join bot_contracts on trades.tx_to = bot_contracts.address + where + trades.blockchain = '{{blockchain}}' + and (tx_from != {{ fee_recipient_1 }} and tx_from != {{ fee_recipient_2 }}) + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} + and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ), + fee_deposits as ( + select + evt_tx_hash, + value as fee_token_amount, + contract_address as fee_token_address + from {{ source('erc20_optimism', 'evt_transfer') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + and ( + contract_address = {{ weth_contract_address }} + or contract_address = {{ usdc_contract_address }} + ) + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} + and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + union all + select + tx_hash, + value as fee_token_amount, + {{ weth_contract_address }} as fee_token_address + from {{ source('optimism', 'traces') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} + and block_time >= timestamp '{{project_start_date}}' + {% endif %} + ) +select distinct + block_time, + date_trunc('day', block_time) as block_date, + date_trunc('month', block_time) as block_month, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + cast(token_bought_address as varchar) as token_bought_address, + token_sold_amount, + token_sold_symbol, + cast(token_sold_address as varchar) as token_sold_address, + -- Fees + fee_token_amount / power(10, decimals) * price as fee_usd, + fee_token_amount / power(10, decimals) as fee_token_amount, + symbol as fee_token_symbol, + cast(fee_token_address as varchar) as fee_token_address, + -- Dex + project, + version, + token_pair, + cast(project_contract_address as varchar) as project_contract_address, + -- User + cast(user as varchar) as user, + cast(bot_trades.tx_hash as varchar) as tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +/* Left Outer Join to support 0 fee trades */ +left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = fee_token_address + and minute = date_trunc('minute', block_time) + ) +order by block_time desc, evt_index desc diff --git a/dbt_subprojects/daily_spellbook/models/chainswap/polygon/chain_swap_polygon_trades.sql b/dbt_subprojects/daily_spellbook/models/chainswap/polygon/chain_swap_polygon_trades.sql new file mode 100644 index 00000000000..01556b7a6bf --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/chainswap/polygon/chain_swap_polygon_trades.sql @@ -0,0 +1,156 @@ +{{ + config( + alias='trades', + schema='chain_swap_polygon', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates=[ + incremental_predicate('DBT_INTERNAL_DEST.block_time') + ], + unique_key=['blockchain', 'tx_hash', 'evt_index'], + ) +}} + +{% set project_start_date = '2024-03-21' %} +{% set blockchain = 'polygon' %} +{% set deployer_1 = '0x9eC1ACAe39d07E1e8D8B3cEbe7022790D87D744A' %} +{% set deployer_2 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set deployer_3 = '0xc1cc1a300Dcfe5359eBe37f2007A77d1F91533ba' %} +{% set deployer_4 = '0x3A510C5a32bCb381c53704AED9c02b0c70041F7A' %} +{% set deployer_5 = '0xB7B953e81612c57256fF0aebD62B6a2F0546F7dA' %} +{% set deployer_6 = '0xa24e8cE77D4A7Ce869DA3730e6560BfB66553F94' %} +{% set wmatic_contract_address = '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270' %} +{% set usdc_contract_address = '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359' %} +{% set fee_recipient_1 = '0x415EEc63c95e944D544b3088bc682B759edB8548' %} +{% set fee_recipient_2 = '0xe1ff5a4c489b11e094bfbb5d23c6d4597a3a79ad' %} + +with + bot_contracts as ( + select address + from {{ source('polygon', 'creation_traces') }} + where + ( + "from" = {{ deployer_1 }} + or "from" = {{ deployer_2 }} + or "from" = {{ deployer_3 }} + or "from" = {{ deployer_4 }} + or "from" = {{ deployer_5 }} + or "from" = {{ deployer_6 }} + ) + and block_time >= timestamp '{{project_start_date}}' + ), + bot_trades as ( + select + trades.block_time, + amount_usd, + if(token_sold_address = {{ wmatic_contract_address }}, 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + project, + version, + token_pair, + project_contract_address, + tx_from as user, + tx_to as bot, + trades.tx_hash, + evt_index + from {{ source('dex', 'trades') }} as trades + join bot_contracts on trades.tx_to = bot_contracts.address + where + trades.blockchain = '{{blockchain}}' + and (tx_from != {{ fee_recipient_1 }} and tx_from != {{ fee_recipient_2 }}) + {% if is_incremental() %} + and {{ incremental_predicate('trades.block_time') }} + {% else %} + and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ), + highest_event_index_for_each_trade as ( + select tx_hash, max(evt_index) as highest_event_index + from bot_trades + group by tx_hash + ), + fee_deposits as ( + select + evt_tx_hash, + value as fee_token_amount, + contract_address as fee_token_address + from {{ source('erc20_polygon', 'evt_transfer') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + and ( + contract_address = {{ wmatic_contract_address }} + or contract_address = {{ usdc_contract_address }} + ) + {% if is_incremental() %} + and {{ incremental_predicate('evt_block_time') }} + {% else %} + and evt_block_time >= timestamp '{{project_start_date}}' + {% endif %} + union all + select + tx_hash, + value as fee_token_amount, + {{ wmatic_contract_address }} as fee_token_address + from {{ source('polygon', 'traces') }} + where + (to = {{ fee_recipient_1 }} or to = {{ fee_recipient_2 }}) + and value > 0 + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% else %} + and block_time >= timestamp '{{project_start_date}}' + {% endif %} + ) + + +select distinct + block_time, + date_trunc('day', block_time) as block_date, + date_trunc('month', block_time) as block_month, + '{{blockchain}}' as blockchain, + -- Trade + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + cast(token_bought_address as varchar) as token_bought_address, + token_sold_amount, + token_sold_symbol, + cast(token_sold_address as varchar) as token_sold_address, + -- Fees + fee_token_amount / power(10, decimals) * price as fee_usd, + fee_token_amount / power(10, decimals) as fee_token_amount, + symbol as fee_token_symbol, + cast(fee_token_address as varchar) as fee_token_address, + -- Dex + project, + version, + token_pair, + cast(project_contract_address as varchar) as project_contract_address, + -- User + cast(user as varchar) as user, + cast(bot_trades.tx_hash as varchar) as tx_hash, + evt_index, + if(evt_index = highest_event_index, true, false) as is_last_trade_in_transaction +from bot_trades +join + highest_event_index_for_each_trade + on bot_trades.tx_hash = highest_event_index_for_each_trade.tx_hash +/* Left Outer Join to support 0 fee trades */ +left join fee_deposits on bot_trades.tx_hash = fee_deposits.evt_tx_hash +left join + {{ source('prices', 'usd') }} + on ( + blockchain = '{{blockchain}}' + and contract_address = fee_token_address + and minute = date_trunc('minute', block_time) + ) +order by block_time desc, evt_index desc From 4bd70499b5c8f25867153ed68cfd9166cb83dc44 Mon Sep 17 00:00:00 2001 From: hildobby Date: Mon, 16 Sep 2024 16:18:31 +0200 Subject: [PATCH 008/127] Tag more blob posters (#6670) * tag 2 more * fix binary --- .../models/_sector/blobs/ethereum/blobs_submitters.sql | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql index 1c8cf86fbd4..d15eb34a8b5 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql @@ -53,14 +53,10 @@ SELECT address , (0xaf1e4f6a47af647f87c0ec814d8032c4a4bff145, 'Zircuit', 'ZircuitL2') , (0xdbbe3d8c2d2b22a2611c5a94a9a12c2fcd49eb29, 'World Chain', 'worldcoin') , (0x8cda8351236199af7532bad53d683ddd9b275d89, 'RACE', 'RACEecosystem') - , (0x7f9d9c1bce1062e1077845ea39a0303429600a06, 'Binary', 'binary_chain') + , (0x7f9d9c1bce1062e1077845ea39a0303429600a06, 'Binary', 'thebinaryhldgs') , (0x4d875acfd836eb3d8a2f25ba03de16c97ec9fc0f, 'PandaSea', 'pandaseaweb3') , (0xf7ca543d652e38692fd12f989eb55b5327ec9a20, 'Shape', 'Shape_L2') , (0xde794bec196832474f2f218135bfd0f7ca7fb038, 'Swan Chain', 'swan_chain') - /* - address: 0x40ea7581ed45bf55f255b465c59ccfd298fc3c89, chain_id: 1110 - address: 0x7720ba0b715f930f61b45bc22d6eb55bf5e3d91a, chain_id: 90000 - address: 0xfbb1bcb6fe16934c2e3d53ed1fe0271f3cfe8726, chain_id: 2800 - address: 0x43ca061ea80fbb4a2b5515f4be4e953b191147af, chain_id: 183 - */ + , (0x67a44ce38627f46f20b1293960559ed85dd194f1, 'Polynomial', 'PolynomialFi') + , (0x060b915ca4904b56ada63565626b9c97f6cad212, 'SNAXchain', 'synthetix_io') ) AS x(address, entity, x_username) \ No newline at end of file From 0c673f2126d58d9759eb95cc6a271a090ca4ebfc Mon Sep 17 00:00:00 2001 From: Peter <157015397+safeintern@users.noreply.github.com> Date: Mon, 16 Sep 2024 22:18:55 +0800 Subject: [PATCH 009/127] Update Ethereum/Optimism/Polygon Safe Balance V2 (#6662) * Update Ethereum Safe Balance Made changes because previous version doesn't properly capture the balances for the safe * Update Polygon Safe Balance v2 * Update safe_optimism_balances.sql * POL symbol Due to MATIC --> POL migration, had changed to POL --------- Co-authored-by: 0xRob <83790096+0xRobin@users.noreply.github.com> --- .../safe/ethereum/safe_ethereum_balances.sql | 63 ++++++++-------- .../safe/optimism/safe_optimism_balances.sql | 66 +++++++++-------- .../safe/polygon/safe_polygon_balances.sql | 71 ++++++++++--------- 3 files changed, 109 insertions(+), 91 deletions(-) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/safe_ethereum_balances.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/safe_ethereum_balances.sql index 4f9e0388fd8..9c8ddd66c5b 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/safe_ethereum_balances.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/ethereum/safe_ethereum_balances.sql @@ -14,29 +14,30 @@ ) }} -with changed_balances as ( +with safes as ( + select + address, + blockchain + from {{ ref('safe_ethereum_safes') }} + where blockchain = 'ethereum' +), +token_balances as ( select a.blockchain, - day, + a.day, a.address, - token_symbol, - token_address, - token_standard, - token_id, - balance, - lead(cast(day as date)) over (partition by token_address, a.address, token_id order by day asc) as next_update_day + a.token_symbol, + a.token_address, + a.token_standard, + a.token_id, + a.balance, + lead(cast(day as timestamp)) over (partition by token_address, a.address, token_id order by day asc) as next_update_day from {{ source('tokens_ethereum', 'balances_daily_agg') }} a - join ( - select - address - , blockchain - from {{ ref('safe_ethereum_safes') }} s - where blockchain = 'ethereum' - ) q on q.address = a.address - where day >= date('2021-07-01') - and token_standard in ('native', 'erc20') + join safes s on a.address = s.address + where a.day >= date('2021-07-01') + and a.token_standard in ('native', 'erc20') {% if is_incremental() %} - and {{ incremental_predicate('day') }} + and {{ incremental_predicate('a.day') }} {% endif %} ), days as ( @@ -47,18 +48,20 @@ days as ( ), forward_fill as ( select - blockchain, + s.blockchain, cast(d.day as date) as day, - address, - token_symbol, - token_address, - token_standard, - token_id, - balance + s.address, + coalesce(b.token_symbol, lag(b.token_symbol) over (partition by s.address, b.token_address order by d.day)) as token_symbol, + coalesce(b.token_address, lag(b.token_address) over (partition by s.address, b.token_address order by d.day)) as token_address, + coalesce(b.token_standard, lag(b.token_standard) over (partition by s.address, b.token_address order by d.day)) as token_standard, + coalesce(b.token_id, lag(b.token_id) over (partition by s.address, b.token_address order by d.day)) as token_id, + coalesce(b.balance, lag(b.balance) over (partition by s.address, b.token_address order by d.day)) as balance from days d - left join changed_balances b - on d.day >= b.day - and (b.next_update_day is null OR d.day < b.next_update_day) + cross join safes s + left join token_balances b + on s.address = b.address + and d.day >= b.day + and (b.next_update_day is null OR d.day < b.next_update_day) where d.day >= cast('2021-07-01' as date) {% if is_incremental() %} and {{ incremental_predicate('d.day') }} @@ -80,13 +83,13 @@ from ( ) b left join {{ ref('prices_usd_daily') }} p on ( - token_standard = 'erc20' + b.token_standard = 'erc20' and b.blockchain = p.blockchain and b.token_address = p.contract_address and b.day = p.day ) or ( - token_standard = 'native' + b.token_standard = 'native' and p.blockchain is null and p.contract_address is null and p.symbol = 'ETH' diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_balances.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_balances.sql index 29f5ff02ba5..47a58b613c4 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_balances.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/optimism/safe_optimism_balances.sql @@ -14,51 +14,58 @@ ) }} -with changed_balances as ( +with safes as ( + -- Capture all safes from a reference table + select + address, + blockchain + from {{ ref('safe_optimism_safes') }} + where blockchain = 'optimism' +), +token_balances as ( + -- Extract token balances with balance changes for safes from the daily aggregation select a.blockchain, - day, + a.day, a.address, - token_symbol, - token_address, - token_standard, - token_id, - balance, + a.token_symbol, + a.token_address, + a.token_standard, + a.token_id, + a.balance, lead(cast(day as timestamp)) over (partition by token_address, a.address, token_id order by day asc) as next_update_day from {{ source('tokens_optimism', 'balances_daily_agg') }} a - join ( - select - address - , blockchain - from {{ ref('safe_optimism_safes') }} s - where blockchain = 'optimism' - ) q on q.address = a.address - where day >= date('2021-07-01') - and token_standard in ('native', 'erc20') + join safes s on a.address = s.address + where a.day >= date('2021-07-01') + and a.token_standard in ('native', 'erc20') {% if is_incremental() %} - and {{ incremental_predicate('day') }} + and {{ incremental_predicate('a.day') }} {% endif %} ), days as ( + -- Generate a sequence of days to ensure forward-filling select * from unnest( sequence(cast('2021-07-01' as date), date(date_trunc('day', now())), interval '1' day) ) as foo(day) ), forward_fill as ( + -- Forward-fill balances across all safes, even if there's no balance change select - blockchain, + s.blockchain, cast(d.day as date) as day, - address, - token_symbol, - token_address, - token_standard, - token_id, - balance + s.address, + coalesce(b.token_symbol, lag(b.token_symbol) over (partition by s.address, b.token_address order by d.day)) as token_symbol, + coalesce(b.token_address, lag(b.token_address) over (partition by s.address, b.token_address order by d.day)) as token_address, + coalesce(b.token_standard, lag(b.token_standard) over (partition by s.address, b.token_address order by d.day)) as token_standard, + coalesce(b.token_id, lag(b.token_id) over (partition by s.address, b.token_address order by d.day)) as token_id, + coalesce(b.balance, lag(b.balance) over (partition by s.address, b.token_address order by d.day)) as balance from days d - left join changed_balances b - on d.day >= b.day - and (b.next_update_day is null OR d.day < b.next_update_day) + cross join safes s + left join token_balances b + on s.address = b.address + and d.day >= b.day + and (b.next_update_day is null OR d.day < b.next_update_day) where d.day >= cast('2021-07-01' as date) {% if is_incremental() %} and {{ incremental_predicate('d.day') }} @@ -75,18 +82,19 @@ select sum(b.balance) as token_balance, sum(b.balance * p.price) as balance_usd from ( + -- Ensure that we only include records with positive balances for final output select * from forward_fill where balance > 0 ) b left join {{ ref('prices_usd_daily') }} p on ( - token_standard = 'erc20' + b.token_standard = 'erc20' and b.blockchain = p.blockchain and b.token_address = p.contract_address and b.day = p.day ) or ( - token_standard = 'native' + b.token_standard = 'native' and p.blockchain is null and p.contract_address is null and p.symbol = 'ETH' diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_balances.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_balances.sql index b8cdf935f15..e826bb9fdb2 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_balances.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/polygon/safe_polygon_balances.sql @@ -16,52 +16,58 @@ {% set project_start_date = '2021-07-01' %} -with changed_balances as ( +with safes as ( + select + address, + blockchain + from {{ ref('safe_polygon_safes') }} + where blockchain = 'polygon' +), +token_balances as ( + select a.blockchain, - day, + a.day, a.address, - token_symbol, - token_address, - token_standard, - token_id, - balance, + a.token_symbol, + a.token_address, + a.token_standard, + a.token_id, + a.balance, lead(cast(day as timestamp)) over (partition by token_address, a.address, token_id order by day asc) as next_update_day from {{ source('tokens_polygon', 'balances_daily_agg') }} a - join ( - select - address - , blockchain - from {{ ref('safe_polygon_safes') }} s - where blockchain = 'polygon' - ) q on q.address = a.address - where day >= date '{{ project_start_date }}' - and token_standard in ('native', 'erc20') + join safes s on a.address = s.address + where a.day >= date('2021-07-01') + and a.token_standard in ('native', 'erc20') {% if is_incremental() %} - and {{ incremental_predicate('day') }} + and {{ incremental_predicate('a.day') }} {% endif %} ), days as ( + -- Generate a sequence of days to ensure forward-filling select * from unnest( - sequence(cast('{{ project_start_date }}' as date), date(date_trunc('day', now())), interval '1' day) + sequence(cast('2021-07-01' as date), date(date_trunc('day', now())), interval '1' day) ) as foo(day) ), forward_fill as ( + -- Forward-fill balances across all safes, even if there's no balance change select - blockchain, + s.blockchain, cast(d.day as date) as day, - address, - token_symbol, - token_address, - token_standard, - token_id, - balance + s.address, + coalesce(b.token_symbol, lag(b.token_symbol) over (partition by s.address, b.token_address order by d.day)) as token_symbol, + coalesce(b.token_address, lag(b.token_address) over (partition by s.address, b.token_address order by d.day)) as token_address, + coalesce(b.token_standard, lag(b.token_standard) over (partition by s.address, b.token_address order by d.day)) as token_standard, + coalesce(b.token_id, lag(b.token_id) over (partition by s.address, b.token_address order by d.day)) as token_id, + coalesce(b.balance, lag(b.balance) over (partition by s.address, b.token_address order by d.day)) as balance from days d - left join changed_balances b - on d.day >= b.day - and (b.next_update_day is null OR d.day < b.next_update_day) - where d.day >= date '{{ project_start_date }}' + cross join safes s + left join token_balances b + on s.address = b.address + and d.day >= b.day + and (b.next_update_day is null OR d.day < b.next_update_day) + where d.day >= cast('2021-07-01' as date) {% if is_incremental() %} and {{ incremental_predicate('d.day') }} {% endif %} @@ -77,21 +83,22 @@ select sum(b.balance) as token_balance, sum(b.balance * p.price) as balance_usd from ( + -- Ensure that we only include records with positive balances for final output select * from forward_fill where balance > 0 ) b left join {{ ref('prices_usd_daily') }} p on ( - token_standard = 'erc20' + b.token_standard = 'erc20' and b.blockchain = p.blockchain and b.token_address = p.contract_address and b.day = p.day ) or ( - token_standard = 'native' + b.token_standard = 'native' and p.blockchain is null and p.contract_address is null - and p.symbol = 'ETH' + and p.symbol = 'POL' and b.day = p.day ) group by 1, 2, 3, 4, 5, 6, 7 From 295adde9b368542fe7d8042395c5ff663e537a05 Mon Sep 17 00:00:00 2001 From: 0xRob <83790096+0xRobin@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:19:12 +0200 Subject: [PATCH 010/127] better formula for used blob bytes (#6709) --- .../models/_sector/blobs/ethereum/ethereum_blobs.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/ethereum_blobs.sql b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/ethereum_blobs.sql index 6893aaaacab..fe150760836 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/ethereum_blobs.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/ethereum_blobs.sql @@ -1,5 +1,4 @@ {{ config( - tags = ['prod_exclude'], schema = 'ethereum', alias = 'blobs', materialized = 'incremental', @@ -22,8 +21,7 @@ SELECT , b.index AS blob_index , b.proposer_index AS beacon_proposer_index , b.kzg_commitment AS blob_kzg_commitment - -- belows expression is very slow - ,ceil(cast(length(regexp_replace(cast(blob as varchar), '0*$', '')) - 2 as double) /2 ) AS used_blob_byte_count -- handle for last byte having a 0 at the end + ,bytearray_length(varbinary_ltrim(varbinary_rtrim(blob))) as used_blob_byte_count ,bytearray_length(blob) AS blob_byte_count ,bytearray_length(blob) AS blob_gas_used -- GPT to the rescue From 3bc14e49b37a22820043e109bad200fbe5b3f1ba Mon Sep 17 00:00:00 2001 From: clizzard <145153355+clizzard7@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:19:30 +0200 Subject: [PATCH 011/127] add spellbook for alpha dex solana trading bot (#6686) * add new spellbook * fix seed * chore: add spellbook to dex_solana_bot_trades * fix: remove obsolete comma --------- Co-authored-by: whale_hunter <143016036+whalehunting@users.noreply.github.com> Co-authored-by: Huang Geyang --- .../_sector/dex/bot_trades/solana/_schema.yml | 37 ++++++ .../solana/dex_solana_bot_trades.sql | 1 + .../platforms/alpha_dex_solana_bot_trades.sql | 124 ++++++++++++++++++ .../platforms/alpha_dex_solana_bot_users.sql | 32 +++++ .../alpha_dex_solana_trades_seed.csv | 21 +++ 5 files changed, 215 insertions(+) create mode 100644 dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/alpha_dex_solana_bot_trades.sql create mode 100644 dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/alpha_dex_solana_bot_users.sql create mode 100644 dbt_subprojects/solana/seeds/alpha_dex/alpha_dex_solana_trades_seed.csv diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml index fd9bb8acfbb..4b551b2365a 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml @@ -476,3 +476,40 @@ models: - check_bot_trades_seed: seed_file: ref('unibot_solana_trades_seed') blockchain: solana + + - name: alpha_dex_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: alpha_dex + contributors: whale_hunter + config: + tags: ["solana", "dex", "alpha_dex", "trades"] + description: > + Alpha Dex trades on Solana + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('alpha_dex_solana_trades_seed') + blockchain: solana + + - name: alpha_dex_solana_bot_users + meta: + blockchain: solana + sector: dex + project: alpha_dex + contributors: whale_hunter + description: > + alpha_dex users on Solana + config: + tags: ["solana", "dex", "bot_trades"] + columns: + - name: user + tests: unique + \ No newline at end of file diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql index e8e93ba394c..bc7a9c3ba54 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql @@ -26,6 +26,7 @@ , ref('sol_gun_solana_bot_trades') , ref('consortium_key_solana_bot_trades') , ref('tirador_solana_bot_trades') + , ref('alpha_dex_solana_bot_trades') ] %} {% for bot in solana_trading_bot %} diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/alpha_dex_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/alpha_dex_solana_bot_trades.sql new file mode 100644 index 00000000000..27a4fc0c138 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/alpha_dex_solana_bot_trades.sql @@ -0,0 +1,124 @@ +{{ + config( + alias='bot_trades', + schema='alpha_dex_solana', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key=[ + 'blockchain', + 'tx_id', + 'tx_index', + 'outer_instruction_index', + 'inner_instruction_index', + ] + ) +}} + +{% set project_start_date = '2024-06-02' %} +{% set fee_receiver = '6qgwjhV2RQxcPffRdtQBTTEezRykQKXqhcDyv1z3r9tq' %} +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +with + all_fee_payments as ( + select * from {{ref('alpha_dex_solana_bot_users')}} + ), + bot_trades as ( + select + trades.block_time, + cast(date_trunc('day', trades.block_time) as date) as block_date, + cast(date_trunc('month', trades.block_time) as date) as block_month, + 'solana' as blockchain, + amount_usd, + if(token_sold_mint_address = '{{wsol_token}}', 'Buy', 'Sell') as type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address as token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address as token_sold_address, + 0 as fee_usd, + 0 AS fee_token_amount, + 'SOL' as fee_token_symbol, + '{{wsol_token}}' as fee_token_address, + project, + version, + token_pair, + project_program_id as project_contract_address, + trader_id as user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + from {{ ref('dex_solana_trades') }} as trades + join all_fee_payments on trades.trader_id = all_fee_payments.user + join + {{ source('solana', 'transactions') }} as transactions + on ( + trades.block_time = transactions.block_time + and trades.tx_id = id + {% if is_incremental() %} + and {{ incremental_predicate('transactions.block_time') }} + and {{ incremental_predicate('trades.block_time') }} + {% else %} + and transactions.block_time >= timestamp '{{project_start_date}}' + and trades.block_time >= timestamp '{{project_start_date}}' + {% endif %} + ) + where + trades.trader_id != '{{fee_receiver}}' -- Exclude trades signed by FeeWallet + and transactions.signer != '{{fee_receiver}}' -- Exclude trades signed by FeeWallet + ), + highest_inner_instruction_index_for_each_trade as ( + select + tx_id, + outer_instruction_index, + max(inner_instruction_index) as highest_inner_instruction_index + from bot_trades + group by tx_id, outer_instruction_index + ) +select + block_time, + block_date, + block_month, + 'Alpha Dex' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + bot_trades.tx_id, + tx_index, + bot_trades.outer_instruction_index, + coalesce(inner_instruction_index, 0) as inner_instruction_index, + if( + inner_instruction_index = highest_inner_instruction_index, true, false + ) as is_last_trade_in_transaction +from bot_trades +join + highest_inner_instruction_index_for_each_trade + on ( + bot_trades.tx_id = highest_inner_instruction_index_for_each_trade.tx_id + and bot_trades.outer_instruction_index + = highest_inner_instruction_index_for_each_trade.outer_instruction_index + ) +order by + block_time desc, + tx_index desc, + outer_instruction_index desc, + inner_instruction_index desc diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/alpha_dex_solana_bot_users.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/alpha_dex_solana_bot_users.sql new file mode 100644 index 00000000000..b21a64e673b --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/alpha_dex_solana_bot_users.sql @@ -0,0 +1,32 @@ +{{ + config( + alias='bot_users', + schema='alpha_dex_solana', + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + unique_key='user' + ) +}} + +{% set project_start_date = '2024-06-02' %} +{% set fee_receiver = '6qgwjhV2RQxcPffRdtQBTTEezRykQKXqhcDyv1z3r9tq' %} + + +select distinct + signer as user +from {{ source('solana', 'account_activity') }} as activity +inner join {{ source("solana", "transactions") }} as transactions + on tx_id = id + and transactions.block_time = activity.block_time + {% if is_incremental() %} + and {{ incremental_predicate('activity.block_time') }} + and {{ incremental_predicate('transactions.block_time') }} + {% else %} + and activity.block_time >= timestamp '{{project_start_date}}' + and transactions.block_time >= timestamp '{{project_start_date}}' + {% endif %} +where + tx_success + and balance_change > 0 + and address = '{{fee_receiver}}' diff --git a/dbt_subprojects/solana/seeds/alpha_dex/alpha_dex_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/alpha_dex/alpha_dex_solana_trades_seed.csv new file mode 100644 index 00000000000..a60bfb9858f --- /dev/null +++ b/dbt_subprojects/solana/seeds/alpha_dex/alpha_dex_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-07-04 15:31:10.000 UTC,2024-07-04,2024-07-01,Alpha Dex,solana,268.36,Buy,65167.086368,BOBBY,48yNDqabAvGNfnkhadsV1MAvtp44fFDdHBRBdFhvpump,2,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BOBBY,6pgNsBb4xJdfouzejx7qDYpibgRnLvopivtNGF6XJyys,5wgWiWxtXbbEaeis6eVjqwuBFJh4QzpWazmQt48m2ckU,4TH8nsLfeCyi4vpZBAKgHCJbiQeiCCX5xcVT8CKTwcZCTiVqrtL8MGrcLscGAKPJejFy1Bgfni75b1z16tCSjjJ7,71,5,0,true +2024-07-13 20:18:22.000 UTC,2024-07-13,2024-07-01,Alpha Dex,solana,70.11,Buy,2531493.950401,PINKY,J7YzdJMF7NxvSBqJi3uWGV3gGv367qbXdgG23qSrpump,0.5,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-PINKY,6n5RN92t4hh4pHs3aPaQNBXNpEcwtwVWPAm33jZK1Jds,KXxHQY8e1QTXf7oK2ZY8qqjpD1MW7j36ykJwq8Sg7PR,4jL7dszLcRMCCY6hPHK28cToYTocNvHAMaPD3hRZKa2D4Fj53EBjPyxqgwn7DHCDQ8Q449F8jgH64ug6G1B2m2dE,1440,5,4,true +2024-07-01 23:22:53.000 UTC,2024-07-01,2024-07-01,Alpha Dex,solana,73.355,Buy,3036223.686595,RAW,Ci5Rtq47wk3FuKLw4pyhJR236jkeFWXivwPcKbe3pump,0.5,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-RAW,BXcndJA2FDacDW2hXvg4dA1vBXHX3frx1gMuyq142pq1,DpbU5BoRvWQqAVJFj5dQfT51D7qitmxM7pUNiaMGi2nK,5FiULyBRobWsxhScRe2di2E5dirXjNZrWqXeker7QpafwWBWMLhw3ocmGhSrkH3r6iiixZ2MpMhdyYxg3NLdMxSU,12,5,0,true +2024-07-31 04:37:27.000 UTC,2024-07-31,2024-07-01,Alpha Dex,solana,269.685,Buy,634170.565465,Knight,LVCQ1YmeK6DECKqcwmscyDRxUYJpiGth9ppGKtopump,1.5,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Knight,HgGd3E2HWsAzb4PpoXbgfZDjwSnBN7MBgQAFouREhcXG,DvNtzjS6umGVuv7uvXtP9GPW8Xdkie1jZ6V9bgf7Hte2,5TkmqSZg526uM2VMbEbB39SwSKEyqrGLn7Vd1NE3F79oZPp7iqNvAgGPZRtrhNazDp8J6wPdE3Rsaxr4PPnVB5Gh,573,7,1,true +2024-07-25 02:50:52.000 UTC,2024-07-25,2024-07-01,Alpha Dex,solana,2021.596454679576,Buy,2020.436724,USDC,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,11.9,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,whirlpool,1,USDC-SOL,FpCMFDFGYotvufJ7HrFHsWEiiQCGbkLCtwHiDnh7o28Q,DvNtzjS6umGVuv7uvXtP9GPW8Xdkie1jZ6V9bgf7Hte2,4ErtKWQAx36hLweQyv2h9VbzJSoLDvBwDybH9rn5sE5xWDSUgpwZMQSqouM2UdWwEi2cNGXXLtBvx7qoLn7YeHRW,110,6,1,true +2024-07-01 03:15:46.000 UTC,2024-07-01,2024-07-01,Alpha Dex,solana,29.532,Buy,35063.62997,JACK,EUZ7aBJu8sQLXhW3AX3K93SGtTF4FCKU3pnZJj5opump,0.2,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-JACK,DxtDW7Vg3kzvGn3X61rDTjoLcPB7xKtqsQv229nGgnBA,F3t7RR4R92jVfR6YUnjUS4kLnB2dUYCHXvKKzFtjWuCs,2GUnfYZ5o3Ftocw8cBCAmmdA5ePJ5dzacpVvtPvgjoSgUUebPFaJK9N5iwa43fBPSGrSFrjncWTzsSw1d9iKzYv6,601,6,0,true +2024-07-30 19:39:57.000 UTC,2024-07-30,2024-07-01,Alpha Dex,solana,17.718,Buy,15217.140662,PUPPERFISH,7fMP2Ez2j1wzvoFnVF9WEQkbpeeFjhvHtzx4fUCcpump,0.1,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PUPPERFISH,6oBCVrc7nkCQcdfsVs545jY2tUAPdKXGRvAb5Ke8K6uj,F8YqrAuW4cN8JVJ1TdTQtdXv9CS3HoAjM8qk87PCRrfF,SFn29ePnTiNn1HjzZyku9vGUQB1A5Ha385iY9nURhpqCJ1hRvsyjAbrn5HLpTBT12a2CVMN4cuprdVhcFz1fFRQ,2419,2,6,true +2024-07-26 11:47:27.000 UTC,2024-07-26,2024-07-01,Alpha Dex,solana,3576.6000000000004,Buy,89044.890098,DOLAN,4YK1njyeCkBuXG6phNtidJWKCbBhB659iwGkUJx98P5Z,20,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-DOLAN,A4XeGGhWRcyYRnZqHwDanEow9nrodSJDRHEwcpCbuk4e,DpbU5BoRvWQqAVJFj5dQfT51D7qitmxM7pUNiaMGi2nK,5jLNdz1X9s4t2DKMZSRBHcCDkPXnDQXSiZL8DwKq6dqrSTiebHN28zyvU13V8h55F6ekbz3jswucb2YhGw6czTUC,1742,5,0,true +2024-07-16 19:23:18.000 UTC,2024-07-16,2024-07-01,Alpha Dex,solana,40.505,Buy,3762153.264029,Pep,6aSC2PwRuEeE1eV6m9Zie1bSbnpje8eDaNy76SUspump,0.25,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Pep,9CcnvqgEpGSw1oiegmzkexYPmoaPXwpY1AbvwTswkc5P,8DSWt2FhamzorVXKgF24o1mTAe4f7ontiW9ADDqyMRUP,2nfSBWexU7eBPC1tXYkoyQRNEccLiAwHBE6dDutjuRH7W54QFQweSwhXSfxTdKdca2mafecCKRLnRcUKX83qsD7t,42,6,0,true +2024-07-24 12:55:00.000 UTC,2024-07-24,2024-07-01,Alpha Dex,solana,1501.4399999999998,Buy,1180215.413387,SHIBY,AEKUy9xPYaUPPbuh2K1koBCLrvyFTjD89xa3M9eRpump,8.5,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SHIBY,7mrHoG7uyhGJPWr7mZ9zP8SMAX3qQz3ehxNCvWXgv6M8,Hh67Q6jwk9CnqigWzUoAEXbnKEMTxHetvDofya5agmDa,2xinDkXQa8qcnNVLCW4HjSssrAjqq8JPj8oov7CH7NXZYh56nPh9cwGa3AKxLEoPpRTvDcCZQosqjmBZzD7V2U5d,445,6,1,true +2024-07-22 15:44:13.000 UTC,2024-07-22,2024-07-01,Alpha Dex,solana,42.227248241906,Sell,42.197246,USDT,Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB,42.206999,USDC,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,0,0,SOL,So11111111111111111111111111111111111111112,whirlpool,1,USDT-USDC,4fuUiYxTQ6QCrdSq9ouBYcTM7bqSwYTSyLueGZLTy4T4,J8kVAqbVhsrr64YAhvzTo57n7H9u9LhjsY47GUpXs8Jp,59PAihrTjkuj4NootdDvE5PLg1htctQcaakQFAGEpGUy6mHH3F7f7v2anp4BcTNmzLg4jCHpny34Zgg6Z2f7xgjB,199,3,11,true +2024-07-22 15:44:13.000 UTC,2024-07-22,2024-07-01,Alpha Dex,solana,42.25313124990701,Buy,42.206999,USDC,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,0.235040232,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,meteora,2,USDC-SOL,GMgh4NtWrGaUf1RR2kcXD7LY1jou1qFAuSsQeKp5ow4a,J8kVAqbVhsrr64YAhvzTo57n7H9u9LhjsY47GUpXs8Jp,59PAihrTjkuj4NootdDvE5PLg1htctQcaakQFAGEpGUy6mHH3F7f7v2anp4BcTNmzLg4jCHpny34Zgg6Z2f7xgjB,199,3,6,false +2024-07-09 01:11:12.000 UTC,2024-07-09,2024-07-01,Alpha Dex,solana,100.2930466258,Sell,0.720289045,SOL,So11111111111111111111111111111111111111112,3590.834054,ZACK,8vCAUbxejdtaxn6jnX5uaQTyTZLmXALg9u1bvFCAjtx7,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,ZACK-SOL,7896DcX977xMJboS6BJvgkK4sB5p2FhctJx81DntbyCX,5wgWiWxtXbbEaeis6eVjqwuBFJh4QzpWazmQt48m2ckU,2gqYV2Z4vWmX1fJDdC5dVTgJZEnvxgpWYaCLgA8teWTQ4sGHKN6mHRA2YUHuUwgrfNvD8hgHPosCy5EDKRALwTcu,981,5,0,true +2024-07-09 01:11:17.000 UTC,2024-07-09,2024-07-01,Alpha Dex,solana,77.62927500184001,Sell,0.557521366,SOL,So11111111111111111111111111111111111111112,266037.792147,ZAZU,n7EksMkvk3WT5FjQ3HBMLm9XYU3EnoXUSJ7PoWpxsoG,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,ZAZU-SOL,GyW6v1xdTRq1LSMp9WHyBwiuupmUwC3qQaXA3BgDiYX9,5wgWiWxtXbbEaeis6eVjqwuBFJh4QzpWazmQt48m2ckU,4da6yRMZPPvUnbw4A6HUSaeCYwpGnsVfQXrg2x9TyG9ipHJZ33zYcXirHrRDDzFJCeBpGRic2ysSCAFnSuYkyhcp,57,5,0,true +2024-07-09 01:11:36.000 UTC,2024-07-09,2024-07-01,Alpha Dex,solana,139.24,Buy,38452.070975,hehe,BreuhVohXX5fv6q41uyb3sojtAuGoGaiAhKBMtcrpump,1,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-hehe,23KJaRate7XthAQ7C5XbJJYK5cyG1sNA2ikCPsiAcbVP,5wgWiWxtXbbEaeis6eVjqwuBFJh4QzpWazmQt48m2ckU,4suif8Wta5oQEVgwrDpzsybHadvnDZ2gfWAZKTugqmYUGeBPARPoqrGrTZ7K7293rUcKx3EDNct2hjNRgYgMcTEM,879,6,0,true +2024-07-12 02:47:42.000 UTC,2024-07-12,2024-07-01,Alpha Dex,solana,68.78,Buy,1360590.640326,JACK,EUZ7aBJu8sQLXhW3AX3K93SGtTF4FCKU3pnZJj5opump,0.5,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-JACK,DxtDW7Vg3kzvGn3X61rDTjoLcPB7xKtqsQv229nGgnBA,EGd2qwpvSc6L7n1z6v3Pwn59rTk8DEYBx1k1Q9JDXgJ1,4LZjgrW1TtsEFYEvnio4wEGhngx9m775piMw8vbxn6RBV1WJLVeEcY6szED9Vag6qawpR5EfaNb8PFVVLuN5wmLx,189,5,0,true +2024-07-12 02:47:51.000 UTC,2024-07-12,2024-07-01,Alpha Dex,solana,68.78,Buy,1346944.923794,JACK,EUZ7aBJu8sQLXhW3AX3K93SGtTF4FCKU3pnZJj5opump,0.5,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-JACK,DxtDW7Vg3kzvGn3X61rDTjoLcPB7xKtqsQv229nGgnBA,EGd2qwpvSc6L7n1z6v3Pwn59rTk8DEYBx1k1Q9JDXgJ1,2YE3AxrJspysfYFYYPjAkMpbsBS63F6LQd9kgZa4Gip8Mhk73yTXt8sVAAt9fVQT5TifvhFov8D1gueSxtEVdsZ6,1899,5,0,true +2024-07-21 04:10:23.000 UTC,2024-07-21,2024-07-01,Alpha Dex,solana,86.685,Buy,3192695.290384,POUND,FiromfyosqaWqzStxD15WRpidHz5rzFK6uwpPQsEJ1iq,0.5,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-POUND,8GHpqhSKmw4y6ZN4x2LkSYFBKL3ke7sRLmWSmRUb2PcG,BrYmV7Q7ubsPsDFHTuKqr5MnVBUU2TQRS9BFgLhDGJJi,sBhapgFxkxFHzASbvSmSpZZcJXzKFG61LvTRLggWSLvM7jZsvJeMYsyBTYwLy6fEujdrX2KtWPfJeNFGJ67fTKa,426,6,0,true +2024-07-02 02:30:17.000 UTC,2024-07-02,2024-07-01,Alpha Dex,solana,25.175300000000004,Buy,142966.19295,ROCCO,D1D3PL5SqEEUp2nL9jrmXLnZgGdfivTwo6jiLQXYpump,0.17,SOL,So11111111111111111111111111111111111111112,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-ROCCO,FTgLHPRhM4YSwzMG3pr9zBtQ39mxziuVqF8SPjYWM1yG,8BQ4Vg1c93mxCEXTEvggD6HaHiViEcNEENqTqo2HjoEw,A5Q84FeFTYL9Mk5SuicE6XmH3795RECwCNBCEm4WFPd2abGzTx4NpfHrHbeU1kTrfdhN89zqRhDc5LVXEwTAUhX,251,5,0,true +2024-07-30 18:49:17.000 UTC,2024-07-30,2024-07-01,Alpha Dex,solana,105.80594424505001,Sell,0.593914927,SOL,So11111111111111111111111111111111111111112,1181574.214978,TROLL,5VdeDCrUMC71RrSYYFetkuq7UX58g9uakDJ548yyivaK,0,0,SOL,So11111111111111111111111111111111111111112,raydium,4,TROLL-SOL,3ugXdBF1JKms4kBjKoLKKseAnU9sc4sPKNEJvQrJgpVF,8ZVcJxHSoJhVGESAt1NSZWteqJyDrNSC5edTiDNvcptY,4sW53CXqRjvmueg2RphJqZbBZkFUzp3G38FBX8TXkpKsDK3CZWkCw4T3EwpGGWWq5SzJ3PPSDJnw5NRWeBGfqBsF,699,3,0,true From 1672d97eadbc31ce5bd189c486f22d92747e8029 Mon Sep 17 00:00:00 2001 From: clizzard <145153355+clizzard7@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:22:00 +0200 Subject: [PATCH 012/127] feat: add mevX solana bot trades spellbook (#6665) * init init mevX * fix: add missing seed file * fix seed file * chore: add spellbook to dex_solana_bot_trades * fix: add correct spellbook name * fix: remove obsolete comma --------- Co-authored-by: whale_hunter <143016036+whalehunting@users.noreply.github.com> Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../_sector/dex/bot_trades/solana/_schema.yml | 24 ++- .../solana/dex_solana_bot_trades.sql | 3 +- .../platforms/mev_x_solana_bot_trades.sql | 160 ++++++++++++++++++ .../seeds/mev_x/mev_x_solana_trades_seed.csv | 21 +++ 4 files changed, 206 insertions(+), 2 deletions(-) create mode 100644 dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/mev_x_solana_bot_trades.sql create mode 100644 dbt_subprojects/solana/seeds/mev_x/mev_x_solana_trades_seed.csv diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml index 4b551b2365a..270652d829a 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml @@ -477,6 +477,28 @@ models: seed_file: ref('unibot_solana_trades_seed') blockchain: solana + - name: mev_x_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: mev_x + contributors: whale_hunter + config: + tags: ["solana", "dex", "mev_x", "trades"] + description: > + MevX trades on Solana + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('mev_x_solana_trades_seed') + blockchain: solana + - name: alpha_dex_solana_bot_trades meta: blockchain: solana @@ -512,4 +534,4 @@ models: columns: - name: user tests: unique - \ No newline at end of file + diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql index bc7a9c3ba54..418cd77f123 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/dex_solana_bot_trades.sql @@ -26,6 +26,7 @@ , ref('sol_gun_solana_bot_trades') , ref('consortium_key_solana_bot_trades') , ref('tirador_solana_bot_trades') + , ref('mev_x_solana_bot_trades') , ref('alpha_dex_solana_bot_trades') ] %} @@ -61,4 +62,4 @@ FROM {{ bot }} {% if not loop.last %} UNION ALL {% endif %} -{% endfor %} \ No newline at end of file +{% endfor %} diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/mev_x_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/mev_x_solana_bot_trades.sql new file mode 100644 index 00000000000..16a9f18b18f --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/mev_x_solana_bot_trades.sql @@ -0,0 +1,160 @@ +{{ config( + alias = 'bot_trades', + schema = 'mev_x', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] + ) +}} + +{% set project_start_date = '2024-07-16' %} +{% set buy_fee_receiver_1 = '3kxSQybWEeQZsMuNWMRJH4TxrhwoDwfv41TNMLRzFP5A' %} +{% set sell_fee_receiver_1 = 'BS3CyJ9rRC4Tp8G7f86r6hGvuu3XdrVGNVpbNM9U5WRZ' %} +{% set sell_fee_receiver_2 = '4Lpvp1q69SHentfYcMBUrkgvppeEx6ovHCSYjg4UYXiq' %} +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + balance_change / 1e9 AS fee_token_amount, + '{{wsol_token}}' AS fee_token_mint_address + FROM + {{ source('solana','account_activity') }} + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND tx_success + AND balance_change > 0 + AND ( + address = '{{buy_fee_receiver_1}}' + OR address = '{{sell_fee_receiver_1}}' + OR address = '{{sell_fee_receiver_2}}' + ) + ), + botTrades AS ( + SELECT + trades.block_time, + CAST(date_trunc('day', trades.block_time) AS date) AS block_date, + CAST(date_trunc('month', trades.block_time) AS date) AS block_month, + 'solana' AS blockchain, + amount_usd, + IF( + token_sold_mint_address = '{{wsol_token}}', + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address AS token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address AS token_sold_address, + fee_token_amount * price AS fee_usd, + fee_token_amount, + IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol, + fee_token_mint_address AS fee_token_address, + project, + version, + token_pair, + project_program_id AS project_contract_address, + trader_id AS user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + FROM + {{ ref('dex_solana_trades') }} AS trades + JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id + LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON ( + feeTokenPrices.blockchain = 'solana' + AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address) + AND date_trunc('minute', block_time) = minute + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + JOIN {{ source('solana','transactions') }} AS transactions ON ( + trades.tx_id = id + {% if is_incremental() %} + AND {{ incremental_predicate('transactions.block_time') }} + {% else %} + AND transactions.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + WHERE + trades.trader_id != '{{buy_fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND trades.trader_id != '{{sell_fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND trades.trader_id != '{{sell_fee_receiver_2}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{buy_fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{sell_fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{sell_fee_receiver_2}}' -- Exclude trades signed by FeeWallet + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestInnerInstructionIndexForEachTrade AS ( + SELECT + tx_id, + outer_instruction_index, + MAX(inner_instruction_index) AS highestInnerInstructionIndex + FROM + botTrades + GROUP BY + tx_id, + outer_instruction_index + ) +SELECT + block_time, + block_date, + block_month, + 'MevX Bot' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + botTrades.tx_id, + tx_index, + botTrades.outer_instruction_index, + COALESCE(inner_instruction_index, 0) AS inner_instruction_index, + IF( + inner_instruction_index = highestInnerInstructionIndex, + true, + false + ) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestInnerInstructionIndexForEachTrade ON ( + botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id + AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index + ) +ORDER BY + block_time DESC, + tx_index DESC, + outer_instruction_index DESC, + inner_instruction_index DESC diff --git a/dbt_subprojects/solana/seeds/mev_x/mev_x_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/mev_x/mev_x_solana_trades_seed.csv new file mode 100644 index 00000000000..13c63409d0c --- /dev/null +++ b/dbt_subprojects/solana/seeds/mev_x/mev_x_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-07-31 16:12:03.000 UTC,2024-07-31,2024-07-01,MevX Bot,solana,1.1213760531299999,Sell,0.006206077,SOL,So11111111111111111111111111111111111111112,25594.412879,MAMA,FoJ5WjecurF547wnowLmNKXvSLJVFRsVkCGSFCRkpump,0.006610543650000001,0.000036585,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-MAMA,5qU4rUsjUQg3PTE5QPfQyXYAFZ88PPxD3MJNQ2CwZGuV,6iXYwVvpr3btWvMeYeZtwPZM9xc5gMRXfYjq4snZekXH,2fJsLrQdaGumzfb2ciG8h793ERbhZFYHfQuHhNxFtUx44dWNaz7g5jShDxeeDLAY5ZUwAbMjkzVgGQmyNNfNY7Lz,2664,5,0,true +2024-07-26 09:15:00.000 UTC,2024-07-26,2024-07-01,MevX Bot,solana,0.17874,Buy,55.015667999,STBOT,2x8o3hA5S5fBxCSE9hzVTf3RohcMWHqkDNKNEPuzprD5,0.001,SOL,So11111111111111111111111111111111111111112,0.0017874000000000002,0.00001,SOL,So11111111111111111111111111111111111111112,raydium,4,STBOT-SOL,BuZAMghNCsoVZcL2xaEYp84LtGh71Xhb7xkod1SaVs7n,919XysJivUF8q3gXbM5sgL9w7BVY9Lth6DhUnTxYGVQk,4wagFS8jcgYWVEijtVA1sAsykRxosT84ovoJkXTk4LZDDqpqm8GgFPo6HiKwZscnkHLwMviFAY1B7FMQjk2mmVvP,765,5,0,true +2024-07-31 22:07:22.000 UTC,2024-07-31,2024-07-01,MevX Bot,solana,17.378,Buy,257153.969313,toby,AULCAENV7ErJSL1TnfvaEWLXTn23XvUdDshXyT3Wpump,0.1,SOL,So11111111111111111111111111111111111111112,0.05213399999999999,0.0003,SOL,So11111111111111111111111111111111111111112,raydium,4,toby-SOL,BUVroMHAmy6USYWYuCgzh8xri2knVHnaXroZh3YrZ7vP,GQGCRDBcVMaNQC3H159nxNGsZQEgcWpCMjFM4m6jw8fD,4PyyEkmvhouyUov6LroQZiYuFQVimAZarNTjtUCLk9Ytfr2ubpMBu8x4oEpSCCV1EvZnRuqckzW2wEhXfF9NfYqA,41,6,0,true +2024-07-30 08:16:35.000 UTC,2024-07-30,2024-07-01,MevX Bot,solana,0.365,Buy,4322.858459,BROG,7Hpdn3ZHZyDrqQ2LPPZjaTwn1wYakcjMzRLeMR7pump,0.002,SOL,So11111111111111111111111111111111111111112,0.0010948174999999998,0.000005999,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BROG,3hjaY6AmmHQ7JtqYxPuAJscZFgNxLhwoVeCmAZJh5qzN,xPLLoKTE7kvTkAYdYq37akbjsZBBrUBZz8TWveJYfuA,4NyAq5qJUP2eCrdoTwVGTBp2DtYkqh4CFy7Z8Bn75CmDaeHHJfEx1AUBDFLEe2hM867xqqBSYd6N9z4AD6pShvrH,1795,5,0,true +2024-07-29 16:50:17.000 UTC,2024-07-29,2024-07-01,MevX Bot,solana,0.46005523726,Buy,27407.321006,ASCENT,Bi7gobmgcXi18DbLsZXH44RkiCsqYb1zr68qRyFBpump,0.002481286,SOL,So11111111111111111111111111111111111111112,0.00111227459,0.000005999,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-ASCENT,A5GqmYJoQB825Lgzx74XbRmthVarQZxVjEvgTmxLp7Yt,xPLLoKTE7kvTkAYdYq37akbjsZBBrUBZz8TWveJYfuA,PrbaGxCcJpZm3NKy71ooczXkpcyoaBhKGHTtnCRsjZHRg39d8ZbC519KskRZJS5hwvVNSqX6DgkhfJ4ch9shFUR,2032,2,4,true +2024-07-30 12:17:53.000 UTC,2024-07-30,2024-07-01,MevX Bot,solana,36.146,Buy,421.340472,SCF,GiG7Hr61RVm4CSUxJmgiCoySFQtdiwxtqf64MsRppump,0.2,SOL,So11111111111111111111111111111111111111112,0.072292,0.0004,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SCF,6USpEBbN94DUYLUi4a2wo3AZDCyozon1PLGYu27jzPkX,GQGCRDBcVMaNQC3H159nxNGsZQEgcWpCMjFM4m6jw8fD,3paJEacLYKC2YupZ72zx2f2rBE3Levijp25bQJTSrps2Fj6G5erEWxBKieDpF8QFo6wGrGkdSBGsoiEo81rpWhyR,2214,6,0,true +2024-07-29 14:36:38.000 UTC,2024-07-29,2024-07-01,MevX Bot,solana,0.43615960752,Buy,27698.695242,Shit,81A6zE2oe5NTv13ss5XX67fZhTRaJznAoh6zWjsGpump,0.002304309,SOL,So11111111111111111111111111111111111111112,0.00113549072,0.000005999,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Shit,6RCeNNmfoPhqzpen8iRLRoDyE4xZo7NjncwMJB1fDxiv,xPLLoKTE7kvTkAYdYq37akbjsZBBrUBZz8TWveJYfuA,4oFQFujVYFdTQaA6h2W6peTXM2NnXuiRniVcKTux94uhNyxwxjwrTzBn9HtYsQwGXKaXA2r3sMKxtFZVBuZx3mqv,2836,2,4,true +2024-07-30 04:24:57.000 UTC,2024-07-30,2024-07-01,MevX Bot,solana,82.43659165362,Sell,0.450620923,SOL,So11111111111111111111111111111111111111112,15006432.803214,METIS,6aZXdTupa4DCLmKFKBAMuRn4bSNzST76u81KqpVvpump,0.16487302854,0.000901241,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-METIS,,xPLLoKTE7kvTkAYdYq37akbjsZBBrUBZz8TWveJYfuA,2vnFZHV5DrUhztFCU2p6Ccmw4g7Bv4g4LXu4ruu1Uf7hSdBzBYjToVZXTVrF6t516A68G98FjMv6o3nkF2CTjryf,1911,2,2,true +2024-07-31 13:35:26.000 UTC,2024-07-31,2024-07-01,MevX Bot,solana,12.24652021746,Sell,0.066972111,SOL,So11111111111111111111111111111111111111112,2014407.797148,MRHAMY,Hz2B7PAgQ1G5CyoUwsCjQTBsnwKkwEDqaho7ejJtpump,0.02449299984,0.000133944,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-MRHAMY,C76zwhjv7aKxKTn8H7gwTe32L8y7AUXrT7QzYq1kXfkH,GQGCRDBcVMaNQC3H159nxNGsZQEgcWpCMjFM4m6jw8fD,57wW3xuN8U5MwJcv7JY1zoppNPNkSfswfDdiBj3zTqZejdjbWiRpgazfBF9hK5nAhzi7tzTdCYdXnKAqUMYP8yyW,852,2,2,true +2024-07-31 04:39:48.000 UTC,2024-07-31,2024-07-01,MevX Bot,solana,0.197769,Buy,67.613422398,STBOT,2x8o3hA5S5fBxCSE9hzVTf3RohcMWHqkDNKNEPuzprD5,0.0011,SOL,So11111111111111111111111111111111111111112,0.000395538,0.0000022,SOL,So11111111111111111111111111111111111111112,raydium,4,STBOT-SOL,BuZAMghNCsoVZcL2xaEYp84LtGh71Xhb7xkod1SaVs7n,D43s9ixnEh7ej8QAJUoLwkgEoXtNnXv7UrGwnA38zzUu,3kPRdaENm7ohGZpj7aZPsecUDWMJc43bFv9cHTidTnVEay6FtghBj1sFRCCXULPTmYfc75BvikyyS3kNuVG5uqxS,3076,5,0,true +2024-07-31 09:46:48.000 UTC,2024-07-31,2024-07-01,MevX Bot,solana,2.0973854483500003,Sell,0.011389549,SOL,So11111111111111111111111111111111111111112,1212.79464,LGBTQ,12B5pSnrTvCvZnkRjL5EHpYP6GSWKKwGC9iXjUhApump,0.004195673600000001,0.000022784,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LGBTQ,8B5hGbQpHrALvcYxAFypyW6cP3B573r7eFaDiMU69ekk,EfmBCaEqav8AxgDHAyMCu3d35svpd6Z9bhZ9FtrGERQW,4CeDZ8djJLjN5yK3GnJ9sjt96Ujo1vtmxC7YVRnU52cHYfDRoConcJG3sWRbkQpY4Rei7iupSUrNiL4sv29hzzHu,780,5,0,true +2024-07-31 04:12:45.000 UTC,2024-07-31,2024-07-01,MevX Bot,solana,17.86427696517,Sell,0.098866993,SOL,So11111111111111111111111111111111111111112,196.026459,SCF,GiG7Hr61RVm4CSUxJmgiCoySFQtdiwxtqf64MsRppump,0.03572855646,0.000197734,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SCF,6USpEBbN94DUYLUi4a2wo3AZDCyozon1PLGYu27jzPkX,HMdDkwZwPFDwyP2rsnbcLy586CV36Q63dG5KEkTgs79g,9iDAJxJaovrfvmDmL8GUALzW1zFPFqVoThatMvmtwNGFUUJXwR7fm35o7oAJw9mpYGZgsiHV518k5VWQAuc42zD,472,5,0,true +2024-07-29 12:06:16.000 UTC,2024-07-29,2024-07-01,MevX Bot,solana,0.40425090816000003,Buy,21975.151728,AOBA,7G2NUoAd2VkrNgRVqaBnYhxbm2ZsYHSuxr3m33GPpump,0.002115168,SOL,So11111111111111111111111111111111111111112,0.00114652888,0.000005999,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-AOBA,7zicz3L5E47xSFtyTSJn5aD61iCJS5f9AWsj9dBGBoyk,xPLLoKTE7kvTkAYdYq37akbjsZBBrUBZz8TWveJYfuA,3esitmfUqeNm75pC23LxsFWXLr9UNgpAKEk8h8AV8HKV2tGsqxuvAJ2pdAHbSTBTZYMG2PxB346g9z64qQJKY2xR,940,2,4,true +2024-07-30 04:57:56.000 UTC,2024-07-30,2024-07-01,MevX Bot,solana,36.542140249999996,Buy,941623.435987,TWUMP,Cw3usfmqdmYAgnCri9gZm6LGpm66bGk5K5epBxA8pump,0.20012125,SOL,So11111111111111111111111111111111111111112,0.07304000000000001,0.0004,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,TWUMP-SOL,Hw53vjanoPkrNEfJvxMK7rneC6aSXaHCPio6f4DuHiDx,GQGCRDBcVMaNQC3H159nxNGsZQEgcWpCMjFM4m6jw8fD,4boYnaod9yNrYbhewuw9qH7kac8zu4rWxTbrCoCd4cTP9xvm21yjmPjvMYxfNZgbr7LvfL5oJAM5m7qwjnznuJNR,492,3,4,true +2024-07-29 11:15:21.000 UTC,2024-07-29,2024-07-01,MevX Bot,solana,99.26279854959999,Sell,0.52111927,SOL,So11111111111111111111111111111111111111112,15647656.280247,MABA,8qCivboDonBbe82GcF4Jj4MQ84eVuqdA5Po2BV3epump,0.19852549424,0.001042238,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-MABA,,xPLLoKTE7kvTkAYdYq37akbjsZBBrUBZz8TWveJYfuA,3E63m4q1eDgCAwMWXLJzcB8AqGRmAFb6zc95iZ53DMkEw6VV1qgZLWTt3xJzsXrCYqxcqFtihGY8F9RMn1FTfkrR,587,2,2,true +2024-07-30 16:19:11.000 UTC,2024-07-30,2024-07-01,MevX Bot,solana,18.122,Buy,262381.408195,brev,AHRousa4gA5ETm6n1SY9nB5YxcN1EaZy2pD7vjCVpump,0.1,SOL,So11111111111111111111111111111111111111112,0.054366,0.0003,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-brev,J3A4FYBdqzVRG3WtSYF2kUV84gnoVbBukRdShkFkzB9c,GQGCRDBcVMaNQC3H159nxNGsZQEgcWpCMjFM4m6jw8fD,3ZVxzTwQuzUFEEWqsnkiJ3bZKjFD9WcHp8P1Rhw3fCf9t68P76zeCywMQ5UbXZvgN2fRHJDWUkUMnonMxcBvBYZB,1767,6,0,true +2024-07-26 16:37:16.000 UTC,2024-07-26,2024-07-01,MevX Bot,solana,3.6148420283599996,Sell,0.019871596,SOL,So11111111111111111111111111111111111111112,4472285338.2823,$TOAD,FViMp5phQH2bX81S7Yyn1yXjj3BRddFBNcMCbTH8FCze,0.007250023049999999,0.000039855,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-$TOAD,GRjpvpES5zEWq1fxSZXjEvbafg56UxKyFvy5Rk1WS615,3gNBGUCM99SA6onvQ89K3uuycg2JDibHDgNCiNBbTPB7,XTbyczuLNaPkPUvdn67re3sfKsihdQMEG6TXMouh3nc4AKEn5kr62ZsUVhHwFqbcC2CFypHqCz7Bt5zwmpCsyw9,271,5,0,true +2024-07-31 05:36:32.000 UTC,2024-07-31,2024-07-01,MevX Bot,solana,1.7985,Buy,615.979071067,STBOT,2x8o3hA5S5fBxCSE9hzVTf3RohcMWHqkDNKNEPuzprD5,0.01,SOL,So11111111111111111111111111111111111111112,0.0035970000000000004,0.00002,SOL,So11111111111111111111111111111111111111112,raydium,4,STBOT-SOL,BuZAMghNCsoVZcL2xaEYp84LtGh71Xhb7xkod1SaVs7n,ChtvYJj12KwF2JNKqtbL9ZJq5mRcbt5hZkaRE2s2t278,61uShHp5hP7JpEaoaDhHGRWv37mzAvKc72qncGPzeL1MPKk84xBLXcyc43Qn3Tf8JkSryX9fnT8bXCk8Bx1UFZDr,138,5,0,true +2024-07-31 15:42:49.000 UTC,2024-07-31,2024-07-01,MevX Bot,solana,24.71007948136,Sell,0.136716164,SOL,So11111111111111111111111111111111111111112,1438433.939583,POOL,FbewxJUqdZH3C6pY9P5viQTeaxu1vEXpiTWHvJyapump,0.051563676079999995,0.000285292,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-POOL,3zx53KCWAqPpdF8NanEbXEEAPizPXfcboYpT3cnEuMUN,E7c1BDxWzVikhphm6vQtHjnvVoHFUPn9wi6FavZQFPYt,2qmh4aypjoCtgsrWDiyMSz12F5BGJjZcwX648wqCjuLVRsr26rTCamzgPeV3JAypEBvLrKTqvsmV1vU64bK3G7GN,1481,5,0,true +2024-07-30 14:47:54.000 UTC,2024-07-30,2024-07-01,MevX Bot,solana,48.9361783302,Sell,0.270007605,SOL,So11111111111111111111111111111111111111112,16437.857253434,STBOT,2x8o3hA5S5fBxCSE9hzVTf3RohcMWHqkDNKNEPuzprD5,0.09787231860000001,0.000540015,SOL,So11111111111111111111111111111111111111112,raydium,4,STBOT-SOL,BuZAMghNCsoVZcL2xaEYp84LtGh71Xhb7xkod1SaVs7n,E7c1BDxWzVikhphm6vQtHjnvVoHFUPn9wi6FavZQFPYt,4fAP8p2iyp2uipEDYXPB7Xist7hBH92cMSAW86a5L1UwDbw337nYZ4gtxL7E2bUQevF5PZ4QwVRdcG93EnVQBJLG,176,5,0,true From ad8c48e2c47af3536938514d1e0818a47f5ff77b Mon Sep 17 00:00:00 2001 From: Phu <33654804+lequangphu@users.noreply.github.com> Date: Mon, 16 Sep 2024 21:22:17 +0700 Subject: [PATCH 013/127] Add Odos on Arbitrum to dex_aggregator (#6680) * Add Odos on Arbitrum to dex_aggregator * Change to WETH address on Arbitrum * Add sources of Odos on Arbitrum * Add odos/arbitrum seeds * Change data type --------- Co-authored-by: Huang Geyang --- .../dex/models/_projects/odos/_schema.yml | 4 +- .../_projects/odos/arbitrum/_schema.yml | 186 ++++++++++++++++++ .../odos/arbitrum/odos_arbitrum_trades.sql | 46 +++++ .../odos/arbitrum/odos_v1_arbitrum_trades.sql | 103 ++++++++++ .../odos/arbitrum/odos_v2_arbitrum_trades.sql | 110 +++++++++++ .../dex/models/_projects/odos/odos_trades.sql | 5 +- .../aggregator_trades/dex_aggregator_seed.csv | 12 +- .../odos/arbitrum/odos_arbitrum_sources.yml | 14 ++ 8 files changed, 475 insertions(+), 5 deletions(-) create mode 100644 dbt_subprojects/dex/models/_projects/odos/arbitrum/_schema.yml create mode 100644 dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_arbitrum_trades.sql create mode 100644 dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_v1_arbitrum_trades.sql create mode 100644 dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_v2_arbitrum_trades.sql create mode 100644 sources/odos/arbitrum/odos_arbitrum_sources.yml diff --git a/dbt_subprojects/dex/models/_projects/odos/_schema.yml b/dbt_subprojects/dex/models/_projects/odos/_schema.yml index 9f38bc596bc..f22da573184 100644 --- a/dbt_subprojects/dex/models/_projects/odos/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/odos/_schema.yml @@ -3,12 +3,12 @@ version: 2 models: - name: odos_trades meta: - blockchain: optimism, ethereum + blockchain: optimism, ethereum, base, arbitrum sector: dex project: odos contributors: Henrystats config: - tags: ['avalanche_c', 'odos','trades', 'dex', 'aggregator'] + tags: ['odos','trades', 'dex', 'aggregator'] description: > odos trades on all chains across all contracts and versions. This table will load odos aggregator trades downstream. columns: diff --git a/dbt_subprojects/dex/models/_projects/odos/arbitrum/_schema.yml b/dbt_subprojects/dex/models/_projects/odos/arbitrum/_schema.yml new file mode 100644 index 00000000000..2f32263178e --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/odos/arbitrum/_schema.yml @@ -0,0 +1,186 @@ +version: 2 + +models: + - name: odos_v1_arbitrum_trades + meta: + blockchain: arbitrum + sector: dex + project: odos + contributors: lequangphu + config: + tags: ['arbitrum','trades', 'odos','dex'] + description: > + A table containing all trades of odos v1 on arbitrum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - trace_address + - check_dex_aggregator_seed: + blockchain: arbitrum + project: odos + version: 1 + columns: + - &blockchain + name: blockchain + description: "Blockchain which the DEX is deployed" + - &project + name: project + description: "Project name of the DEX" + - &version + name: version + description: "Version of the contract built and deployed by the DEX project" + - &block_month + name: block_month + description: "UTC event block month of each DEX trade" + - &block_date + name: block_date + description: "UTC event block date of each DEX trade" + - &block_time + name: block_time + description: "UTC event block time of each DEX trade" + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the transaction" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the transaction" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the transaction" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &maker + name: maker + description: "Address of trader who sold a token" + - &project_contract_address + name: project_contract_address + description: "Project contract address which executed the trade on the blockchain" + - &tx_hash + name: tx_hash + description: "Unique transaction hash value tied to each transaction on the DEX" + - &tx_from + name: tx_from + description: "Address which initiated the transaction" + - &tx_to + name: tx_to + description: "Address which received the transaction" + - &evt_index + name: evt_index + description: "" + - &trace_address + name: trace_address + description: "" + + - name: odos_v2_arbitrum_trades + meta: + blockchain: arbitrum + sector: dex + project: odos + contributors: lequangphu + config: + tags: ['arbitrum','trades', 'odos','dex'] + description: > + A table containing all trades of odos v2 on arbitrum + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - trace_address + - check_dex_aggregator_seed: + blockchain: arbitrum + project: odos + version: 2 + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *tx_hash + - *tx_from + - *tx_to + - *evt_index + - *trace_address + + - name: odos_arbitrum_trades + meta: + blockchain: arbitrum + sector: dex + project: odos + contributors: lequangphu + config: + tags: ['arbitrum','trades', 'odos','dex'] + description: > + A table containing all trades of odos on arbitrum. + columns: + - *blockchain + - *project + - *version + - *block_month + - *block_date + - *block_time + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *amount_usd + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *tx_hash + - *tx_from + - *tx_to + - *evt_index + - *trace_address \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_arbitrum_trades.sql b/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_arbitrum_trades.sql new file mode 100644 index 00000000000..b4d4648a076 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_arbitrum_trades.sql @@ -0,0 +1,46 @@ +{{ config( + schema = 'odos_arbitrum' + , alias = 'trades' + ) +}} + +{% set odos_models = [ +ref('odos_v1_arbitrum_trades') +, ref('odos_v2_arbitrum_trades') +] %} + + +SELECT * +FROM ( + {% for dex_model in odos_models %} + SELECT + blockchain, + project, + version, + block_month, + block_date, + block_time, + token_bought_symbol, + token_sold_symbol, + token_pair, + token_bought_amount, + token_sold_amount, + token_bought_amount_raw, + token_sold_amount_raw, + amount_usd, + token_bought_address, + token_sold_address, + taker, + maker, + project_contract_address, + tx_hash, + tx_from, + tx_to, + evt_index, + trace_address + FROM {{ dex_model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_v1_arbitrum_trades.sql b/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_v1_arbitrum_trades.sql new file mode 100644 index 00000000000..af704cc405e --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_v1_arbitrum_trades.sql @@ -0,0 +1,103 @@ +{{ config( + schema = 'odos_v1_arbitrum' + ,alias = 'trades' + ,materialized = 'incremental' + ,file_format = 'delta' + ,incremental_strategy = 'merge' + ,unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index', 'trace_address'] + ,incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{% set project_start_date = '2022-04-11' %} + +WITH +dexs as ( + SELECT + evt_block_time as block_time, + evt_block_number as block_number, + json_extract_scalar(outputs[1], '$.receiver') AS taker, + CAST(NULL as VARBINARY) as maker, + amountsIn[1] as token_sold_amount_raw, + amountsOut[1] as token_bought_amount_raw, + CAST(NULL as double) as amount_usd, + tokensIn[1] as token_sold_address, + json_extract_scalar(outputs[1], '$.tokenAddress') AS token_bought_address, + contract_address as project_contract_address, + evt_tx_hash as tx_hash, + evt_index, + CAST(ARRAY[-1] as array) as trace_address + FROM + {{ source('odos_v1_arbitrum', 'OdosRouter_evt_Swapped') }} + {% if is_incremental() %} + WHERE {{incremental_predicate('evt_block_time')}} + {% else %} + WHERE evt_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} +) + +SELECT + 'arbitrum' AS blockchain, + 'odos' AS project, + '1' AS version, + TRY_CAST(date_trunc('DAY', dexs.block_time) AS date) AS block_date, + TRY_CAST(date_trunc('MONTH', dexs.block_time) AS date) AS block_month, + dexs.block_time, + erc20a.symbol AS token_bought_symbol, + erc20b.symbol AS token_sold_symbol, + CASE + WHEN lower(erc20a.symbol) > lower(erc20b.symbol) + THEN concat(erc20b.symbol, '-', erc20a.symbol) + ELSE concat(erc20a.symbol, '-', erc20b.symbol) + END AS token_pair, + dexs.token_bought_amount_raw / power(10, erc20a.decimals) AS token_bought_amount, + dexs.token_sold_amount_raw / power(10, erc20b.decimals) AS token_sold_amount, + dexs.token_bought_amount_raw AS token_bought_amount_raw, + dexs.token_sold_amount_raw AS token_sold_amount_raw, + COALESCE( + dexs.amount_usd, + (dexs.token_bought_amount_raw / power(10, erc20a.decimals)) * p_bought.price, + (dexs.token_sold_amount_raw / power(10, erc20b.decimals)) * p_sold.price + ) AS amount_usd, + CAST(dexs.token_bought_address AS varbinary) AS token_bought_address, + dexs.token_sold_address, + CAST(dexs.taker AS varbinary) AS taker, + dexs.maker, + dexs.project_contract_address, + dexs.tx_hash, + tx."from" AS tx_from, + tx.to AS tx_to, + dexs.evt_index, + dexs.trace_address +FROM dexs +INNER JOIN {{ source('arbitrum', 'transactions') }} tx + ON dexs.tx_hash = tx.hash + {% if not is_incremental() %} + AND tx.block_time >= DATE '{{project_start_date}}' + {% else %} + AND {{ incremental_predicate('tx.block_time') }} + {% endif %} +LEFT JOIN {{ source('tokens', 'erc20') }} erc20a + ON CAST(erc20a.contract_address AS varchar) = dexs.token_bought_address + AND erc20a.blockchain = 'arbitrum' +LEFT JOIN {{ source('tokens', 'erc20') }} erc20b + ON erc20b.contract_address = dexs.token_sold_address + AND erc20b.blockchain = 'arbitrum' +LEFT JOIN {{ source('prices', 'usd') }} p_bought + ON p_bought.minute = date_trunc('minute', dexs.block_time) + AND CAST(p_bought.contract_address AS varchar) = dexs.token_bought_address + AND p_bought.blockchain = 'arbitrum' + {% if not is_incremental() %} + AND p_bought.minute >= DATE '{{project_start_date}}' + {% else %} + AND {{ incremental_predicate('p_bought.minute') }} + {% endif %} +LEFT JOIN {{ source('prices', 'usd') }} p_sold + ON p_sold.minute = date_trunc('minute', dexs.block_time) + AND p_sold.contract_address = dexs.token_sold_address + AND p_sold.blockchain = 'arbitrum' + {% if not is_incremental() %} + AND p_sold.minute >= DATE '{{project_start_date}}' + {% else %} + AND {{ incremental_predicate('p_sold.minute') }} + {% endif %} diff --git a/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_v2_arbitrum_trades.sql b/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_v2_arbitrum_trades.sql new file mode 100644 index 00000000000..0c43c2f7dcd --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/odos/arbitrum/odos_v2_arbitrum_trades.sql @@ -0,0 +1,110 @@ +{{ config( + alias = 'trades' + ,schema = 'odos_v2_arbitrum' + ,materialized = 'incremental' + ,file_format = 'delta' + ,incremental_strategy = 'merge' + ,unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index', 'trace_address'] + ,incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{% set project_start_date = '2023-07-15' %} + +with event_data AS ( + SELECT + evt_block_time AS block_time, + evt_block_number AS block_number, + sender AS taker, + contract_address AS maker, + inputAmount AS token_sold_amount_raw, + amountOut AS token_bought_amount_raw, + CAST(NULL as double) as amount_usd, + CASE + WHEN inputToken = 0x0000000000000000000000000000000000000000 + THEN 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 -- WETH + ELSE inputToken + END AS token_sold_address, + CASE + WHEN outputToken = 0x0000000000000000000000000000000000000000 + THEN 0x82aF49447D8a07e3bd95BD0d56f35241523fBab1 -- WETH + ELSE outputToken + END AS token_bought_address, + contract_address AS project_contract_address, + evt_tx_hash AS tx_hash, + evt_index, + CAST(ARRAY[-1] as array) as trace_address + FROM + {{ source('odos_v2_arbitrum', 'OdosRouterV2_evt_Swap') }} + {% if is_incremental() %} + WHERE {{incremental_predicate('evt_block_time')}} + {% else %} + WHERE evt_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} +) + +SELECT + 'arbitrum' AS blockchain, + 'odos' AS project, + '2' AS version, + TRY_CAST(date_trunc('DAY', e.block_time) AS date) AS block_date, + TRY_CAST(date_trunc('MONTH', e.block_time) AS date) AS block_month, + e.block_time, + erc20a.symbol AS token_bought_symbol, + erc20b.symbol AS token_sold_symbol, + CASE + WHEN lower(erc20a.symbol) > lower(erc20b.symbol) + THEN concat(erc20b.symbol, '-', erc20a.symbol) + ELSE concat(erc20a.symbol, '-', erc20b.symbol) + END AS token_pair, + e.token_bought_amount_raw / power(10, erc20a.decimals) AS token_bought_amount, + e.token_sold_amount_raw / power(10, erc20b.decimals) AS token_sold_amount, + e.token_bought_amount_raw AS token_bought_amount_raw, + e.token_sold_amount_raw AS token_sold_amount_raw, + COALESCE( + e.amount_usd, + (e.token_bought_amount_raw / power(10, erc20a.decimals)) * p_bought.price, + (e.token_sold_amount_raw / power(10, erc20b.decimals)) * p_sold.price + ) AS amount_usd, + CAST(e.token_bought_address AS varbinary) AS token_bought_address, + e.token_sold_address, + CAST(e.taker AS varbinary) AS taker, + e.maker, + e.project_contract_address, + e.tx_hash, + tx."from" AS tx_from, + tx.to AS tx_to, + e.evt_index, + e.trace_address +FROM event_data e +INNER JOIN {{ source('arbitrum', 'transactions') }} tx + ON e.tx_hash = tx.hash + {% if not is_incremental() %} + AND tx.block_time >= DATE '{{project_start_date}}' + {% else %} + AND {{ incremental_predicate('tx.block_time') }} + {% endif %} +LEFT JOIN {{ source('tokens', 'erc20') }} erc20a + ON erc20a.contract_address = e.token_bought_address + AND erc20a.blockchain = 'arbitrum' +LEFT JOIN {{ source('tokens', 'erc20') }} erc20b + ON erc20b.contract_address = e.token_sold_address + AND erc20b.blockchain = 'arbitrum' +LEFT JOIN {{ source('prices', 'usd') }} p_bought + ON p_bought.minute = date_trunc('minute', e.block_time) + AND p_bought.contract_address = e.token_bought_address + AND p_bought.blockchain = 'arbitrum' + {% if not is_incremental() %} + AND p_bought.minute >= DATE '{{project_start_date}}' + {% else %} + AND {{ incremental_predicate('p_bought.minute') }} + {% endif %} +LEFT JOIN {{ source('prices', 'usd') }} p_sold + ON p_sold.minute = date_trunc('minute', e.block_time) + AND p_sold.contract_address = e.token_sold_address + AND p_sold.blockchain = 'arbitrum' + {% if not is_incremental() %} + AND p_sold.minute >= DATE '{{project_start_date}}' + {% else %} + AND {{ incremental_predicate('p_sold.minute') }} + {% endif %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/odos/odos_trades.sql b/dbt_subprojects/dex/models/_projects/odos/odos_trades.sql index 43e2ac5e5c8..bfe8bd6ceeb 100644 --- a/dbt_subprojects/dex/models/_projects/odos/odos_trades.sql +++ b/dbt_subprojects/dex/models/_projects/odos/odos_trades.sql @@ -1,16 +1,17 @@ {{ config( schema = 'odos', alias = 'trades', - post_hook='{{ expose_spells(\'["optimism", "ethereum"]\', + post_hook='{{ expose_spells(\'["optimism", "ethereum", "base", "arbitrum"]\', "project", "odos", - \'["Henrystats", "amalashkevich"]\') }}' + \'["Henrystats", "amalashkevich","lequangphu"]\') }}' ) }} {% set odos_models = [ ref('odos_ethereum_trades'), ref('odos_optimism_trades'), + ref('odos_arbitrum_trades'), ref('odos_base_trades') ] %} diff --git a/dbt_subprojects/dex/seeds/aggregator_trades/dex_aggregator_seed.csv b/dbt_subprojects/dex/seeds/aggregator_trades/dex_aggregator_seed.csv index 43e23ce9007..0af36d9f1c4 100644 --- a/dbt_subprojects/dex/seeds/aggregator_trades/dex_aggregator_seed.csv +++ b/dbt_subprojects/dex/seeds/aggregator_trades/dex_aggregator_seed.csv @@ -150,4 +150,14 @@ zksync,bebop,jam,2024-05-27,0x3f1d7f99e108b3f5380d1d7344f4ced18b31b14ab1015b48e7 ethereum,bebop,blend,2024-05-21,0x21677f9f3c67d01ab04e0099e96504eaba4e096048904d395e5cb7d2406fd00f,120,"0,0,0",0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0.42318489471676,0xae7ab96520de3a18e5e111b5eaab095312d7fe84,0.43046091487172494 polygon,bebop,blend,2024-05-31,0x680a55160e096aeee0e01390d5dbeab32263bfca3f842f58c44cdcca5349ad10,102,"0,0,0",0x2791bca1f2de4661ed88a30c99a7a9449aa84174,21.723107,0xc2132d05d31c914a87c6611c10748aeb04b58e8f,21.737614 arbitrum,bebop,blend,2024-05-26,0x04045cbce9de0469c40c2ad17fca876cda06ce6946c7d7a84b80bf6d8c662d6e,7,"0,0,0",0x82af49447d8a07e3bd95bd0d56f35241523fbab1,0.045019157349776975,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,172.591646 -base,bebop,blend,2024-05-21,0x2e3d46d6e847ad3a88f515aca7e556a14c93dc1eba5899da0b0edd6936ec8054,163,"0,0,0",0x833589fcd6edb6e08f4c7c32d4f71b54bda02913,40.623838,0x4200000000000000000000000000000000000006,0.0109 \ No newline at end of file +base,bebop,blend,2024-05-21,0x2e3d46d6e847ad3a88f515aca7e556a14c93dc1eba5899da0b0edd6936ec8054,163,"0,0,0",0x833589fcd6edb6e08f4c7c32d4f71b54bda02913,40.623838,0x4200000000000000000000000000000000000006,0.0109 +arbitrum,odos,2,2024-09-09,0x9866ce94df47c2432e68561eb2eae9e68d0e374db8aa5d2ee3b3fef2a29797ea,17,-1,0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34,289.51583210511194,0x912ce59144191c1204e64559fe8253a0e49e6548,567.903481962462 +arbitrum,odos,2,2024-09-09,0xe674461ffaa39e2a2a7051b1cb65bcba58aeedbbd0f5673d1f02b7459bdf7a32,14,-1,0x2416092f143378750bb29b79ed961ab195cceea5,0.47177957854222957,0x82af49447d8a07e3bd95bd0d56f35241523fbab1,0.48 +arbitrum,odos,2,2024-09-09,0xf8c2e5cb30c07a0f266bf7afcd310baa45682ec180f55aaf89ea50d0e4d11c83,13,-1,0xf97f4df75117a78c1a5a0dbb814af92458539fb4,40.15785490883377,0xaf88d065e77c8cc2239327c5edb3a432268e5831,414.16 +arbitrum,odos,2,2024-09-09,0xa6d37f5f4fa1948c155e254434e0b09ada41238e83467ea35e3dc30ed2262526,18,-1,0xaf88d065e77c8cc2239327c5edb3a432268e5831,14834.628903,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,14834.798178 +arbitrum,odos,2,2024-09-09,0x9b4c22328e69f905121b5c15419dc9fa3f2085976d4954cb61e32150c67af962,16,-1,0xf97f4df75117a78c1a5a0dbb814af92458539fb4,1.8460308909438838,0xaf88d065e77c8cc2239327c5edb3a432268e5831,19.05712 +arbitrum,odos,1,2023-09-13,0xaef151abff4317b09660c749e1faca1b6400d9ab50ae751bc5fe6b5988e03965,18,-1,0x307838326166343934343764386130376533626439356264306435366633353234313532336662616231,0.006570233329582102,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,49.9 +arbitrum,odos,1,2023-09-13,0x20fb5e16c99be306fb4058f207566332c96ed26a7f7575f0f136fda8d1c2285d,24,-1,0x307838326166343934343764386130376533626439356264306435366633353234313532336662616231,5.6455948955647e-05,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,0.1 +arbitrum,odos,1,2023-09-13,0xeb9a5a3675dc2595390ef13b5392e924ad927e2fed616a8f8eacf355cb94643c,18,-1,0x307838326166343934343764386130376533626439356264306435366633353234313532336662616231,0.006570233329582102,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,49.9 +arbitrum,odos,1,2023-09-13,0x5644436fcc4f702f8171473ecff69c39d3f13ef27fad26d8d01e4ba7680c397a,21,-1,0x307838326166343934343764386130376533626439356264306435366633353234313532336662616231,0.006570233329582102,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,50 +arbitrum,odos,1,2023-09-13,0x22c79845d2b5d155c71b53b7ed61165972a69a195406fae644f60f063cf007b0,23,-1,0x307838326166343934343764386130376533626439356264306435366633353234313532336662616231,5.17754278158e-05,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,0.1 \ No newline at end of file diff --git a/sources/odos/arbitrum/odos_arbitrum_sources.yml b/sources/odos/arbitrum/odos_arbitrum_sources.yml new file mode 100644 index 00000000000..ec3f4babed1 --- /dev/null +++ b/sources/odos/arbitrum/odos_arbitrum_sources.yml @@ -0,0 +1,14 @@ +version: 2 + +sources: + - name: odos_v1_arbitrum + description: > + Decoded event table for swaps on odos + tables: + - name: OdosRouter_evt_Swapped + + - name: odos_v2_arbitrum + description: > + Decoded event table for swaps on odos_v2 + tables: + - name: OdosRouterV2_evt_Swap From 9bf7433d0f1a4db8a6173f0d515ef7dcee136595 Mon Sep 17 00:00:00 2001 From: Huang Geyang Date: Mon, 16 Sep 2024 22:23:43 +0800 Subject: [PATCH 014/127] Introduce dex_aggregator_base_trades (#6653) * Introduce dex_aggregator_base_trades * Fix typo * Refactor lifi_trades * Add lifi to base_trades * Fix config blocks * Fix typo * Fix typo * Apply suggestions from code review Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> * Draft enrich_dex_aggregator_trades macro * Remove 5 columns * Remove 5 columns * Recover add_tx_columns --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../models/enrich_dex_aggregator_trades.sql | 99 ++++++++++++++ .../dex/models/_projects/lifi/_schema.yml | 32 ++++- .../models/_projects/lifi/fantom/_schema.yml | 26 +--- ...trades.sql => lifi_fantom_base_trades.sql} | 8 +- .../lifi/fantom/lifi_v2_fantom_trades.sql | 39 ------ .../_projects/lifi/lifi_base_trades.sql | 40 ++++++ .../dex/models/_projects/lifi/lifi_trades.sql | 49 +------ .../_projects/lifi/optimism/_schema.yml | 26 +--- ...ades.sql => lifi_optimism_base_trades.sql} | 8 +- .../lifi/optimism/lifi_v2_optimism_trades.sql | 39 ------ .../dex/models/aggregator_trades/_schema.yml | 45 ++++++- .../dex_aggregator_base_trades.sql | 58 +++++++++ .../dex_aggregator_trades.sql | 123 ++++++++++++------ 13 files changed, 368 insertions(+), 224 deletions(-) create mode 100644 dbt_subprojects/dex/macros/models/enrich_dex_aggregator_trades.sql rename dbt_subprojects/dex/models/_projects/lifi/fantom/{lifi_fantom_trades.sql => lifi_fantom_base_trades.sql} (80%) create mode 100644 dbt_subprojects/dex/models/_projects/lifi/lifi_base_trades.sql rename dbt_subprojects/dex/models/_projects/lifi/optimism/{lifi_optimism_trades.sql => lifi_optimism_base_trades.sql} (80%) create mode 100644 dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_base_trades.sql diff --git a/dbt_subprojects/dex/macros/models/enrich_dex_aggregator_trades.sql b/dbt_subprojects/dex/macros/models/enrich_dex_aggregator_trades.sql new file mode 100644 index 00000000000..fe88afc97dc --- /dev/null +++ b/dbt_subprojects/dex/macros/models/enrich_dex_aggregator_trades.sql @@ -0,0 +1,99 @@ +{% macro enrich_dex_aggregator_trades( + base_trades = null + , filter = null + , tokens_erc20_model = null + ) +%} + +WITH base_trades as ( + SELECT + * + FROM + {{ base_trades }} + WHERE + {{ filter }} + {% if is_incremental() %} + AND + {{ incremental_predicate('block_time') }} + {% endif %} +) + +, enrichments AS ( + SELECT + base_trades.blockchain + , base_trades.project + , base_trades.version + , base_trades.block_month + , base_trades.block_date + , base_trades.block_time +-- , base_trades.block_number -- temporary missing + , erc20_bought.symbol AS token_bought_symbol + , erc20_sold.symbol AS token_sold_symbol + , case + when lower(erc20_bought.symbol) > lower(erc20_sold.symbol) then concat(erc20_sold.symbol, '-', erc20_bought.symbol) + else concat(erc20_bought.symbol, '-', erc20_sold.symbol) + end AS token_pair + , base_trades.token_bought_amount_raw / power(10, erc20_bought.decimals) AS token_bought_amount + , base_trades.token_sold_amount_raw / power(10, erc20_sold.decimals) AS token_sold_amount + , base_trades.token_bought_amount_raw + , base_trades.token_sold_amount_raw + , base_trades.token_bought_address + , base_trades.token_sold_address + , coalesce(base_trades.taker, base_trades.tx_from) AS taker + , base_trades.maker + , base_trades.project_contract_address + , base_trades.tx_hash + , base_trades.tx_from + , base_trades.tx_to + , base_trades.trace_address + , base_trades.evt_index + FROM + base_trades + LEFT JOIN + {{ tokens_erc20_model }} as erc20_bought + ON erc20_bought.contract_address = base_trades.token_bought_address + AND erc20_bought.blockchain = base_trades.blockchain + LEFT JOIN + {{ tokens_erc20_model }} as erc20_sold + ON erc20_sold.contract_address = base_trades.token_sold_address + AND erc20_sold.blockchain = base_trades.blockchain +) + +, enrichments_with_prices AS ( + {{ + add_amount_usd( + trades_cte = 'enrichments' + ) + }} +) + +SELECT + blockchain + , project + , version + , block_month + , block_date + , block_time +-- , block_number + , token_bought_symbol + , token_sold_symbol + , token_pair + , token_bought_amount + , token_sold_amount + , token_bought_amount_raw + , token_sold_amount_raw + , amount_usd + , token_bought_address + , token_sold_address + , taker + , maker + , project_contract_address + , tx_hash + , tx_from + , tx_to + , trace_address + , evt_index +FROM + enrichments_with_prices + +{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/lifi/_schema.yml b/dbt_subprojects/dex/models/_projects/lifi/_schema.yml index c4c22570073..60d070724c5 100644 --- a/dbt_subprojects/dex/models/_projects/lifi/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/lifi/_schema.yml @@ -83,4 +83,34 @@ models: description: "the position of this event log within this transaction" - &block_month name: block_month - description: "UTC event block month of each DEX trade" \ No newline at end of file + description: "UTC event block month of each DEX trade" + + - name: lifi_base_trades + meta: + blockchain: fantom, optimism + sector: dex + project: lifi + contributors: Henrystats, hosuke + config: + tags: [ 'fantom', 'optimism', 'lifi','trades', 'dex', 'aggregator', 'Henrystats','cross-chain' ] + description: > + lifi aggregator base trades on all chains across all contracts and versions. This table will load dex_aggregator trades downstream. + columns: + - *blockchain + - *project + - *version + - *block_date + - *block_time + - *token_bought_amount_raw + - *token_sold_amount_raw + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *tx_hash + - *tx_from + - *tx_to + - *trace_address + - *evt_index + - *block_month diff --git a/dbt_subprojects/dex/models/_projects/lifi/fantom/_schema.yml b/dbt_subprojects/dex/models/_projects/lifi/fantom/_schema.yml index 474dbc07b1f..dca0d119c25 100644 --- a/dbt_subprojects/dex/models/_projects/lifi/fantom/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/lifi/fantom/_schema.yml @@ -41,30 +41,12 @@ models: - &block_time name: block_time description: "UTC event block time of each DEX trade" - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the transaction" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the transaction" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the transaction" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - &token_bought_amount_raw name: token_bought_amount_raw description: "Raw value of the token bought at time of execution in the original currency" - &token_sold_amount_raw name: token_sold_amount_raw description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - &token_bought_address name: token_bought_address description: "Contract address of the token bought" @@ -99,7 +81,7 @@ models: name: block_month description: "UTC event block month of each DEX trade" - - name: lifi_fantom_trades + - name: lifi_fantom_base_trades meta: blockchain: fantom sector: dex @@ -115,14 +97,8 @@ models: - *version - *block_date - *block_time - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - *token_bought_amount_raw - *token_sold_amount_raw - - *amount_usd - *token_bought_address - *token_sold_address - *taker diff --git a/dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_fantom_trades.sql b/dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_fantom_base_trades.sql similarity index 80% rename from dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_fantom_trades.sql rename to dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_fantom_base_trades.sql index 83ab544ad74..b860a1a1403 100644 --- a/dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_fantom_trades.sql +++ b/dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_fantom_base_trades.sql @@ -1,7 +1,7 @@ {{ config( schema = 'lifi_fantom', - alias = 'trades' + alias = 'base_trades' ) }} @@ -20,14 +20,8 @@ FROM ( block_date, block_month, block_time, - token_bought_symbol, - token_sold_symbol, - token_pair, - token_bought_amount, - token_sold_amount, token_bought_amount_raw, token_sold_amount_raw, - amount_usd, token_bought_address, token_sold_address, taker, diff --git a/dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_v2_fantom_trades.sql b/dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_v2_fantom_trades.sql index 2b555de05d5..33940dd5079 100644 --- a/dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_v2_fantom_trades.sql +++ b/dbt_subprojects/dex/models/_projects/lifi/fantom/lifi_v2_fantom_trades.sql @@ -61,21 +61,8 @@ SELECT cast(date_trunc('DAY', dexs.block_time) as date) as block_date, cast(date_trunc('MONTH', dexs.block_time) as date) as block_month, dexs.block_time, - erc20a.symbol as token_bought_symbol, - erc20b.symbol as token_sold_symbol, - case - when lower(erc20a.symbol) > lower(erc20b.symbol) then concat(erc20b.symbol, '-', erc20a.symbol) - else concat(erc20a.symbol, '-', erc20b.symbol) - end as token_pair, - dexs.token_bought_amount_raw / power(10, erc20a.decimals) AS token_bought_amount, - dexs.token_sold_amount_raw / power(10, erc20b.decimals) AS token_sold_amount, dexs.token_bought_amount_raw, dexs.token_sold_amount_raw, - coalesce( - dexs.amount_usd - ,(dexs.token_bought_amount_raw / power(10, p_bought.decimals)) * p_bought.price - ,(dexs.token_sold_amount_raw / power(10, p_sold.decimals)) * p_sold.price - ) AS amount_usd, dexs.token_bought_address, dexs.token_sold_address, tx."from" AS taker, -- no taker in swap event @@ -95,29 +82,3 @@ inner join {{ source('fantom', 'transactions') }} tx {% if is_incremental() %} and tx.block_time >= date_trunc('day', now() - interval '7' Day) {% endif %} -left join {{ source('tokens', 'erc20') }} erc20a - on erc20a.contract_address = dexs.token_bought_address - and erc20a.blockchain = 'fantom' -left join {{ source('tokens', 'erc20') }} erc20b - on erc20b.contract_address = dexs.token_sold_address - and erc20b.blockchain = 'fantom' -left join {{ source('prices', 'usd') }} p_bought - on p_bought.minute = date_trunc('minute', dexs.block_time) - and p_bought.contract_address = dexs.token_bought_address - and p_bought.blockchain = 'fantom' - {% if not is_incremental() %} - and p_bought.minute >= TIMESTAMP '{{project_start_date}}' - {% endif %} - {% if is_incremental() %} - and p_bought.minute >= date_trunc('day', now() - interval '7' Day) - {% endif %} -left join {{ source('prices', 'usd') }} p_sold - on p_sold.minute = date_trunc('minute', dexs.block_time) - and p_sold.contract_address = dexs.token_sold_address - and p_sold.blockchain = 'fantom' - {% if not is_incremental() %} - and p_sold.minute >= TIMESTAMP '{{project_start_date}}' - {% endif %} - {% if is_incremental() %} - and p_sold.minute >= date_trunc('day', now() - interval '7' Day) - {% endif %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/lifi/lifi_base_trades.sql b/dbt_subprojects/dex/models/_projects/lifi/lifi_base_trades.sql new file mode 100644 index 00000000000..493843fab6d --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/lifi/lifi_base_trades.sql @@ -0,0 +1,40 @@ +{{ config( + schema = 'lifi', + alias = 'base_trades' + ) +}} + +{% set lifi_models = [ +ref('lifi_fantom_base_trades') +, ref('lifi_optimism_base_trades') +] %} + + +SELECT * +FROM ( + {% for dex_model in lifi_models %} + SELECT + blockchain, + project, + version, + block_month, + block_date, + block_time, + token_bought_amount_raw, + token_sold_amount_raw, + token_bought_address, + token_sold_address, + taker, + maker, + project_contract_address, + tx_hash, + tx_from, + tx_to, + trace_address, --ensure field is explicitly cast as array in base models + evt_index + FROM {{ dex_model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/lifi/lifi_trades.sql b/dbt_subprojects/dex/models/_projects/lifi/lifi_trades.sql index d91055d86c9..55538339cea 100644 --- a/dbt_subprojects/dex/models/_projects/lifi/lifi_trades.sql +++ b/dbt_subprojects/dex/models/_projects/lifi/lifi_trades.sql @@ -1,50 +1,13 @@ {{ config( schema = 'lifi', alias = 'trades', - post_hook='{{ expose_spells(\'["fantom", "optimism"]\', - "project", - "lifi", - \'["Henrystats"]\') }}' + post_hook='{{ expose_spells(blockchains = \'["fantom", "optimism"]\', + spell_type = "project", + spell_name = "lifi", + contributors = \'["Henrystats", "hosuke"]\') }}' ) }} -{% set lifi_models = [ -ref('lifi_fantom_trades') -,ref('lifi_optimism_trades') -] %} - - SELECT * -FROM ( - {% for dex_model in lifi_models %} - SELECT - blockchain, - project, - version, - block_month, - block_date, - block_time, - token_bought_symbol, - token_sold_symbol, - token_pair, - token_bought_amount, - token_sold_amount, - token_bought_amount_raw, - token_sold_amount_raw, - amount_usd, - token_bought_address, - token_sold_address, - taker, - maker, - project_contract_address, - tx_hash, - tx_from, - tx_to, - trace_address, --ensure field is explicitly cast as array in base models - evt_index - FROM {{ dex_model }} - {% if not loop.last %} - UNION ALL - {% endif %} - {% endfor %} -) \ No newline at end of file +FROM {{ ref('dex_aggregator_trades') }} +WHERE project = 'lifi' \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/lifi/optimism/_schema.yml b/dbt_subprojects/dex/models/_projects/lifi/optimism/_schema.yml index 0fb8ef06ae3..7fd22619823 100644 --- a/dbt_subprojects/dex/models/_projects/lifi/optimism/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/lifi/optimism/_schema.yml @@ -41,30 +41,12 @@ models: - &block_time name: block_time description: "UTC event block time of each DEX trade" - - &token_bought_symbol - name: token_bought_symbol - description: "Token symbol for token bought in the transaction" - - &token_sold_symbol - name: token_sold_symbol - description: "Token symbol for token sold in the transaction" - - &token_pair - name: token_pair - description: "Token symbol pair for each token involved in the transaction" - - &token_bought_amount - name: token_bought_amount - description: "Value of the token bought at time of execution in the original currency" - - &token_sold_amount - name: token_sold_amount - description: "Value of the token sold at time of execution in the original currency" - &token_bought_amount_raw name: token_bought_amount_raw description: "Raw value of the token bought at time of execution in the original currency" - &token_sold_amount_raw name: token_sold_amount_raw description: "Raw value of the token sold at time of execution in the original currency" - - &amount_usd - name: amount_usd - description: "USD value of the trade at time of execution" - &token_bought_address name: token_bought_address description: "Contract address of the token bought" @@ -99,7 +81,7 @@ models: name: block_month description: "UTC event block month of each DEX trade" - - name: lifi_optimism_trades + - name: lifi_optimism_base_trades meta: blockchain: optimism sector: dex @@ -115,14 +97,8 @@ models: - *version - *block_date - *block_time - - *token_bought_symbol - - *token_sold_symbol - - *token_pair - - *token_bought_amount - - *token_sold_amount - *token_bought_amount_raw - *token_sold_amount_raw - - *amount_usd - *token_bought_address - *token_sold_address - *taker diff --git a/dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_optimism_trades.sql b/dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_optimism_base_trades.sql similarity index 80% rename from dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_optimism_trades.sql rename to dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_optimism_base_trades.sql index d373f3f66a2..4423e749258 100644 --- a/dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_optimism_trades.sql +++ b/dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_optimism_base_trades.sql @@ -1,7 +1,7 @@ {{ config( schema = 'lifi_optimism', - alias = 'trades' + alias = 'base_trades' ) }} @@ -20,14 +20,8 @@ FROM ( block_date, block_month, block_time, - token_bought_symbol, - token_sold_symbol, - token_pair, - token_bought_amount, - token_sold_amount, token_bought_amount_raw, token_sold_amount_raw, - amount_usd, token_bought_address, token_sold_address, taker, diff --git a/dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_v2_optimism_trades.sql b/dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_v2_optimism_trades.sql index e05c6eb96fc..b6d26eda580 100644 --- a/dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_v2_optimism_trades.sql +++ b/dbt_subprojects/dex/models/_projects/lifi/optimism/lifi_v2_optimism_trades.sql @@ -61,21 +61,8 @@ SELECT cast(date_trunc('DAY', dexs.block_time) as date) as block_date, cast(date_trunc('MONTH', dexs.block_time) as date) as block_month, dexs.block_time, - erc20a.symbol as token_bought_symbol, - erc20b.symbol as token_sold_symbol, - case - when lower(erc20a.symbol) > lower(erc20b.symbol) then concat(erc20b.symbol, '-', erc20a.symbol) - else concat(erc20a.symbol, '-', erc20b.symbol) - end as token_pair, - dexs.token_bought_amount_raw / power(10, erc20a.decimals) AS token_bought_amount, - dexs.token_sold_amount_raw / power(10, erc20b.decimals) AS token_sold_amount, dexs.token_bought_amount_raw, dexs.token_sold_amount_raw, - coalesce( - dexs.amount_usd - ,(dexs.token_bought_amount_raw / power(10, p_bought.decimals)) * p_bought.price - ,(dexs.token_sold_amount_raw / power(10, p_sold.decimals)) * p_sold.price - ) AS amount_usd, dexs.token_bought_address, dexs.token_sold_address, tx."from" AS taker, -- no taker in swap event @@ -95,29 +82,3 @@ inner join {{ source('optimism', 'transactions') }} tx {% if is_incremental() %} and tx.block_time >= date_trunc('day', now() - interval '7' Day) {% endif %} -left join {{ source('tokens', 'erc20') }} erc20a - on erc20a.contract_address = dexs.token_bought_address - and erc20a.blockchain = 'optimism' -left join {{ source('tokens', 'erc20') }} erc20b - on erc20b.contract_address = dexs.token_sold_address - and erc20b.blockchain = 'optimism' -left join {{ source('prices', 'usd') }} p_bought - on p_bought.minute = date_trunc('minute', dexs.block_time) - and p_bought.contract_address = dexs.token_bought_address - and p_bought.blockchain = 'optimism' - {% if not is_incremental() %} - and p_bought.minute >= TIMESTAMP '{{project_start_date}}' - {% endif %} - {% if is_incremental() %} - and p_bought.minute >= date_trunc('day', now() - interval '7' Day) - {% endif %} -left join {{ source('prices', 'usd') }} p_sold - on p_sold.minute = date_trunc('minute', dexs.block_time) - and p_sold.contract_address = dexs.token_sold_address - and p_sold.blockchain = 'optimism' - {% if not is_incremental() %} - and p_sold.minute >= TIMESTAMP '{{project_start_date}}' - {% endif %} - {% if is_incremental() %} - and p_sold.minute >= date_trunc('day', now() - interval '7' Day) - {% endif %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/aggregator_trades/_schema.yml b/dbt_subprojects/dex/models/aggregator_trades/_schema.yml index 9615ea7bfaa..c2f424433db 100644 --- a/dbt_subprojects/dex/models/aggregator_trades/_schema.yml +++ b/dbt_subprojects/dex/models/aggregator_trades/_schema.yml @@ -92,4 +92,47 @@ models: name: trace_address - &evt_index name: evt_index - description: "Index of the corresponding trade event" \ No newline at end of file + description: "Index of the corresponding trade event" + + - name: dex_aggregator_base_trades + meta: + blockchain: ethereum, gnosis, avalanche_c, fantom, optimism, arbitrum, bnb + sector: dex_aggregator + contributors: hosuke + config: + tags: ['ethereum', 'gnosis', 'avalanche_c', 'fantom', 'aggregator', 'dex', 'trades', 'cross-chain'] + description: > + Base trades data without amount_usd column + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - trace_address + columns: + - *blockchain + - *project + - *version + - *block_date + - *block_time + - *token_bought_symbol + - *token_sold_symbol + - *token_pair + - *token_bought_amount + - *token_sold_amount + - *token_bought_amount_raw + - *token_sold_amount_raw + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *tx_hash + - *tx_from + - *tx_to + - *trace_address + - *evt_index \ No newline at end of file diff --git a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_base_trades.sql b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_base_trades.sql new file mode 100644 index 00000000000..9b7ee783f7e --- /dev/null +++ b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_base_trades.sql @@ -0,0 +1,58 @@ +{{ config( + schema ='dex_aggregator' + , alias = 'base_trades' + , partition_by = ['block_month', 'blockchain', 'project'] + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['blockchain', 'project', 'version', 'tx_hash', 'evt_index', 'trace_address'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{% set base_trade_models = [ + ref('lifi_base_trades') +] %} + +with base_union as ( + SELECT * + FROM + ( + {% for model in base_trade_models %} + SELECT + blockchain + , project + , version + , block_date + , block_month + , block_time + -- , block_number -- missing yet + , cast(token_bought_amount_raw as uint256) as token_bought_amount_raw + , cast(token_sold_amount_raw as uint256) as token_sold_amount_raw + , token_bought_address + , token_sold_address + , taker + , maker + , project_contract_address + , tx_hash + , tx_from + , tx_to + , trace_address + , evt_index + FROM + {{ model }} + WHERE + token_sold_amount_raw >= 0 and token_bought_amount_raw >= 0 + {% if is_incremental() %} + AND {{ incremental_predicate('block_time') }} + {% endif %} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} + ) +) +select + * +from + base_union diff --git a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql index e67cb143484..39a47f57cad 100644 --- a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql +++ b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql @@ -1,4 +1,3 @@ - {{ config( schema ='dex_aggregator', alias = 'trades', @@ -10,14 +9,13 @@ post_hook='{{ expose_spells(\'["ethereum", "gnosis", "avalanche_c", "fantom", "bnb", "optimism", "arbitrum"]\', "sector", "dex_aggregator", - \'["bh2smith", "Henrystats", "jeff-dude", "rantum" ]\') }}' + \'["bh2smith", "Henrystats", "jeff-dude", "rantum", "hosuke"]\') }}' ) }} -{% set dex_aggregator_models = [ +{% set as_is_models = [ ref('cow_protocol_trades') ,ref('paraswap_trades') - ,ref('lifi_trades') ,ref('yield_yak_trades') ,ref('bebop_trades') ,ref('dodo_aggregator_trades') @@ -30,37 +28,88 @@ ,ref('odos_trades') ] %} -{% for aggregator_model in dex_aggregator_models %} -SELECT - blockchain - , project - , version - , block_date - , block_month - , block_time - , token_bought_symbol - , token_sold_symbol - , token_pair - , token_bought_amount - , token_sold_amount - , try_cast(token_bought_amount_raw as uint256) as token_bought_amount_raw - , try_cast(token_sold_amount_raw as uint256) as token_sold_amount_raw - , amount_usd - , token_bought_address - , token_sold_address - , taker - , maker - , project_contract_address - , tx_hash - , tx_from - , tx_to - , trace_address - , evt_index -FROM {{ aggregator_model }} -{% if is_incremental() %} -WHERE block_date >= date_trunc('day', now() - interval '7' day) -{% endif %} -{% if not loop.last %} -UNION ALL -{% endif %} +WITH enriched_aggregator_base_trades AS ( + {{ + enrich_dex_aggregator_trades( + base_trades = ref('dex_aggregator_base_trades') + , filter = "1 = 1" + , tokens_erc20_model = source('tokens', 'erc20') + ) + }} +) + +, as_is_dexs AS ( + {% for model in as_is_models %} + SELECT + blockchain + , project + , version + , block_date + , block_month + , block_time + , token_bought_symbol + , token_sold_symbol + , token_pair + , token_bought_amount + , token_sold_amount + , cast(token_bought_amount_raw as uint256) as token_bought_amount_raw + , cast(token_sold_amount_raw as uint256) as token_sold_amount_raw + , amount_usd + , token_bought_address + , token_sold_address + , taker + , maker + , project_contract_address + , tx_hash + , tx_from + , tx_to + , trace_address + , evt_index + FROM + {{ model }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('block_time') }} + {% endif %} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) +{% set cte_to_union = [ + 'enriched_aggregator_base_trades' + , 'as_is_dexs' + ] +%} + +{% for cte in cte_to_union %} + SELECT + blockchain + , project + , version + , block_date + , block_month + , block_time + , token_bought_symbol + , token_sold_symbol + , token_pair + , token_bought_amount + , token_sold_amount + , token_bought_amount_raw + , token_sold_amount_raw + , amount_usd + , token_bought_address + , token_sold_address + , taker + , maker + , project_contract_address + , tx_hash + , tx_from + , tx_to + , trace_address + , evt_index + FROM + {{ cte }} + {% if not loop.last %} + UNION ALL + {% endif %} {% endfor %} From cc41e14fa102a3b2bcaf25047544e97850c98a68 Mon Sep 17 00:00:00 2001 From: 0xRob <83790096+0xRobin@users.noreply.github.com> Date: Mon, 16 Sep 2024 16:24:02 +0200 Subject: [PATCH 015/127] add erc1155 fillamount (#6675) --- .../nft/macros/platforms/element_v1_base_trades.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/nft/macros/platforms/element_v1_base_trades.sql b/dbt_subprojects/nft/macros/platforms/element_v1_base_trades.sql index ec78b4ab2c1..b6bb7cc4779 100644 --- a/dbt_subprojects/nft/macros/platforms/element_v1_base_trades.sql +++ b/dbt_subprojects/nft/macros/platforms/element_v1_base_trades.sql @@ -88,7 +88,7 @@ SELECT 'secondary' AS trade_type, erc1155Token AS nft_contract_address, cast(erc1155TokenId as uint256) AS nft_token_id, - uint256 '1' AS nft_amount, + cast(erc1155FillAmount as uint256) AS nft_amount, taker AS buyer, maker AS seller, cast(erc20FillAmount AS UINT256) AS price_raw, @@ -123,7 +123,7 @@ SELECT 'secondary' AS trade_type, erc1155Token AS nft_contract_address, cast(erc1155TokenId as uint256) AS nft_token_id, - uint256 '1' AS nft_amount, + cast(erc1155FillAmount as uint256) AS nft_amount, maker AS buyer, taker AS seller, cast(erc20FillAmount AS UINT256) AS price_raw, From cf243c47815e14becc51947793be4e65614d3be7 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:25:37 -0300 Subject: [PATCH 016/127] add RAFT token to prices.usd (#6720) Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 0b440a8e7ce..2481fc0fe91 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1827,6 +1827,7 @@ FROM ('pzeth-renzo-restaked-lst', 'ethereum', 'pzETH', 0x8c9532a60E0E7C6BbD2B2c1303F63aCE1c3E9811, 18), ('sx-sx-network', 'ethereum', 'SX', 0xbe9f61555f50dd6167f2772e9cf7519790d96624, 18), ('rch-rch-token', 'ethereum', 'RCH', 0x57B96D4aF698605563A4653D882635da59Bf11AF, 18), + ('raft-raft', 'ethereum', 'RAFT', 0x4c5cb5d87709387f8821709f7a6664f00dcf0c93, 18), ('neiro3-neiro', 'ethereum', 'NEIRO', 0xee2a03aa6dacf51c18679c516ad5283d8e7c2637, 9), ('neiro-first-neiro-on-ethereum', 'ethereum', 'NEIRO', 0x812ba41e071c7b7fa4ebcfb62df5f45f6fa853ee, 9), ('fuku-fuku-kun', 'ethereum', 'FUKU', 0x1001271083c249bd771e1bb76c22d935809a61ee, 9), From 3d1c577c1a7b2ef7aa84f22bd67a412e0fbf0512 Mon Sep 17 00:00:00 2001 From: Haris Angelidakis <64154020+harisang@users.noreply.github.com> Date: Mon, 16 Sep 2024 18:55:18 +0300 Subject: [PATCH 017/127] update barter staging address (#6710) --- .../cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql index 98c6fb47452..8219af3a851 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/cow_protocol/ethereum/cow_protocol_ethereum_solvers.sql @@ -112,6 +112,7 @@ known_solver_metadata (address, environment, name) as ( (0xc10D4DfDA62227d9EC23Ab0010E2942e48338A60, 'prod', 'Apollo'), (0x008300082C3000009e63680088f8c7f4D3ff2E87, 'prod', 'Copium_Capital'), (0xC7899Ff6A3aC2FF59261bD960A8C880DF06E1041, 'prod', 'Barter'), + (0xA6A871b612bCE899b1CbBad6E545e5e47Da98b87, 'barn', 'Barter'), (0xa08B00576aeE8d8dd960E08298FAc9fD7C756e36, 'barn', 'Apollo'), (0x2c3A1c33d96C9DcA1c34EB234B1e65F79dEaE60e, 'barn', 'Horadrim'), (0xa5559C2E1302c5Ce82582A6b1E4Aec562C2FbCf4, 'barn', 'Project_Blanc'), @@ -186,7 +187,6 @@ known_solver_metadata (address, environment, name) as ( (0x5f7A6aeec3D3E80558278632954DA4b730996F83, 'barn', 'Barter'), (0x3Bf7c0e1728fB64bb0973b1e2A342F1C7eb1bb8e, 'barn', 'PropellerSwap'), (0xEADA531BC5361C9287088D857512e0CA812EAa68, 'barn', 'Enso'), - (0xC7899Ff6A3aC2FF59261bD960A8C880DF06E1041, 'barn', 'Barter'), (0x0798540ee03a8c2e68cef19c56d1faa86271d5cf, 'service', 'Withdraw'), (0xdf30c9502eafea21ecc8410108dda338dd5047c5, 'service', 'Withdraw'), (0x256bb5ad3dbdf61ae08d7cbc0b9223ccb1c60aae, 'service', 'Withdraw'), From 75d2f0b1afc965564cef9b92f982bbc3590c276b Mon Sep 17 00:00:00 2001 From: hildobby Date: Mon, 16 Sep 2024 20:05:37 +0200 Subject: [PATCH 018/127] [Easy] `fantasy.events` updates (#6711) * add revenue numbers * fix * Add tactics revenue * Update _schema.yml * Update fantasy_events.sql --- .../models/_projects/fantasy/_schema.yml | 8 ++++++++ .../_projects/fantasy/fantasy_events.sql | 20 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/fantasy/_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/fantasy/_schema.yml index 21ab57999e6..6baed668877 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/fantasy/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/fantasy/_schema.yml @@ -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" \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/fantasy/fantasy_events.sql b/dbt_subprojects/daily_spellbook/models/_projects/fantasy/fantasy_events.sql index a2e3c1ab1e1..4ee6c7bc4f4 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/fantasy/fantasy_events.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/fantasy/fantasy_events.sql @@ -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 @@ -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')}} @@ -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')}} @@ -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 @@ -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 From 9c723223f28405d3f697bad799dba3d90a74796f Mon Sep 17 00:00:00 2001 From: 0xRob <83790096+0xRobin@users.noreply.github.com> Date: Tue, 17 Sep 2024 18:51:04 +0200 Subject: [PATCH 019/127] move RWA (#6725) --- .../shared}/balances_incremental_subset_daily.sql | 2 +- .../_sector}/rwa/arbitrum/rwa_arbitrum_balances.sql | 0 .../rwa/arbitrum/rwa_arbitrum_dex_balances.sql | 0 .../_sector}/rwa/arbitrum/rwa_arbitrum_dex_pools.sql | 0 .../_sector}/rwa/arbitrum/rwa_arbitrum_schema.yml | 0 .../_sector}/rwa/arbitrum/rwa_arbitrum_tokens.sql | 0 sources/_subprojects_outputs/tokens/balances.yml | 10 +++++++++- 7 files changed, 10 insertions(+), 2 deletions(-) rename {dbt_subprojects/tokens/macros/balances => dbt_macros/shared}/balances_incremental_subset_daily.sql (98%) rename dbt_subprojects/{tokens/models => daily_spellbook/models/_sector}/rwa/arbitrum/rwa_arbitrum_balances.sql (100%) rename dbt_subprojects/{tokens/models => daily_spellbook/models/_sector}/rwa/arbitrum/rwa_arbitrum_dex_balances.sql (100%) rename dbt_subprojects/{tokens/models => daily_spellbook/models/_sector}/rwa/arbitrum/rwa_arbitrum_dex_pools.sql (100%) rename dbt_subprojects/{tokens/models => daily_spellbook/models/_sector}/rwa/arbitrum/rwa_arbitrum_schema.yml (100%) rename dbt_subprojects/{tokens/models => daily_spellbook/models/_sector}/rwa/arbitrum/rwa_arbitrum_tokens.sql (100%) diff --git a/dbt_subprojects/tokens/macros/balances/balances_incremental_subset_daily.sql b/dbt_macros/shared/balances_incremental_subset_daily.sql similarity index 98% rename from dbt_subprojects/tokens/macros/balances/balances_incremental_subset_daily.sql rename to dbt_macros/shared/balances_incremental_subset_daily.sql index 171471073d8..9e330747b25 100644 --- a/dbt_subprojects/tokens/macros/balances/balances_incremental_subset_daily.sql +++ b/dbt_macros/shared/balances_incremental_subset_daily.sql @@ -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 diff --git a/dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_balances.sql b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_balances.sql similarity index 100% rename from dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_balances.sql rename to dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_balances.sql diff --git a/dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_dex_balances.sql b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_dex_balances.sql similarity index 100% rename from dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_dex_balances.sql rename to dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_dex_balances.sql diff --git a/dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_dex_pools.sql b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_dex_pools.sql similarity index 100% rename from dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_dex_pools.sql rename to dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_dex_pools.sql diff --git a/dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_schema.yml b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_schema.yml similarity index 100% rename from dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_schema.yml rename to dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_schema.yml diff --git a/dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_tokens.sql b/dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_tokens.sql similarity index 100% rename from dbt_subprojects/tokens/models/rwa/arbitrum/rwa_arbitrum_tokens.sql rename to dbt_subprojects/daily_spellbook/models/_sector/rwa/arbitrum/rwa_arbitrum_tokens.sql diff --git a/sources/_subprojects_outputs/tokens/balances.yml b/sources/_subprojects_outputs/tokens/balances.yml index 883aac784d7..85a545e876f 100644 --- a/sources/_subprojects_outputs/tokens/balances.yml +++ b/sources/_subprojects_outputs/tokens/balances.yml @@ -3,13 +3,21 @@ sources: - name: tokens_ethereum tables: - name: balances_daily_agg + - name: balances_daily_agg_base - name: tokens_optimism tables: - name: balances_daily_agg + - name: balances_daily_agg_base - name: tokens_polygon tables: - name: balances_daily_agg + - name: balances_daily_agg_base - name: tokens_base tables: - name: balances_daily_agg - + - name: balances_daily_agg_base + - name: tokens_arbitrum + tables: + - name: balances_daily_agg + - name: balances_daily_agg_base + From de92bc9ddd91484803538c46db8c965121c4a275 Mon Sep 17 00:00:00 2001 From: mhmdriyadi <112420584+mhmdriyadi@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:29:01 +0700 Subject: [PATCH 020/127] Update prices_ethereum_tokens.sql (#6745) * Update prices_ethereum_tokens.sql Add babydoge token price * Update prices_ethereum_tokens.sql Add USDZ token price * Update prices_ethereum_tokens.sql Add USDZ token price * Update prices_ethereum_tokens.sql --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 2481fc0fe91..02d68f1cfbd 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1833,7 +1833,9 @@ FROM ('fuku-fuku-kun', 'ethereum', 'FUKU', 0x1001271083c249bd771e1bb76c22d935809a61ee, 9), ('elon-elon-memelord', 'ethereum', 'ELON', 0x69420e3a3aa9e17dea102bb3a9b3b73dcddb9528, 9), ('bar-gold-standard', 'ethereum', 'BAR', 0x777be1c6075c20184c4fd76344b7b0b7c858fe6b, 18), - ('ftw-black-agnus', 'ethereum', 'FTW', 0x306fD3e7b169Aa4ee19412323e1a5995B8c1a1f4, 18) + ('ftw-black-agnus', 'ethereum', 'FTW', 0x306fD3e7b169Aa4ee19412323e1a5995B8c1a1f4, 18), + ('babydoge-baby-doge-coin', 'ethereum', 'BABYDOGE', 0xac57de9c1a09fec648e93eb98875b212db0d460b, 9), + ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( -- bad price feeds From eb45ad80665979e68e77b74d0a6a57883c238e15 Mon Sep 17 00:00:00 2001 From: ShawnEdwards23 <130678374+ShawnEdwards23@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:29:11 +0700 Subject: [PATCH 021/127] Add BAG on Blast to prices.usd (#6743) * Add WBTC and BAG on Blast to prices.usd * Add BAG on Blast to prices.usd --- .../tokens/models/prices/blast/prices_blast_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/blast/prices_blast_tokens.sql b/dbt_subprojects/tokens/models/prices/blast/prices_blast_tokens.sql index ed9be8805d7..2b884b332e7 100644 --- a/dbt_subprojects/tokens/models/prices/blast/prices_blast_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/blast/prices_blast_tokens.sql @@ -19,5 +19,6 @@ FROM ('usdb-usdb','blast','USDB',0x4300000000000000000000000000000000000003,18), ('weth-weth', 'blast', 'bpETH', 0xb772d5c5f4a2eef67dfbc89aa658d2711341b8e5, 18), ('yolo-yolo-games','blast','YOLO',0xf77dd21c5ce38ac08786be35ef1d1dec1a6a15f3,18), - ('blast-blast-token','blast','BLAST',0xb1a5700fa2358173fe465e6ea4ff52e36e88e2ad,18) + ('blast-blast-token','blast','BLAST',0xb1a5700fa2358173fe465e6ea4ff52e36e88e2ad,18), + ('bag-bagwin','blast','BAG',0xb9dfcd4cf589bb8090569cb52fac1b88dbe4981f,18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 34d4ec8876d9862c69c44ce48ec60a6af1c3014d Mon Sep 17 00:00:00 2001 From: sunshinejulia9 <135378933+sunshinejulia9@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:29:21 +0700 Subject: [PATCH 022/127] Update prices_zkevm_tokens.sql (#6741) --- .../tokens/models/prices/zkevm/prices_zkevm_tokens.sql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/zkevm/prices_zkevm_tokens.sql b/dbt_subprojects/tokens/models/prices/zkevm/prices_zkevm_tokens.sql index 98c88734bf3..dd328c8ade9 100644 --- a/dbt_subprojects/tokens/models/prices/zkevm/prices_zkevm_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/zkevm/prices_zkevm_tokens.sql @@ -26,6 +26,9 @@ FROM ('bal-balancer','zkevm','BAL',0x120ef59b80774f02211563834d8e3b72cb1649d6,18), ('usdt-tether','zkevm','USDT',0x1e4a5963abfd975d8c9021ce480b42188849d41d,6), ('gyd-gyro-dollar','zkevm','GYD',0xca5d8f8a8d49439357d3cf46ca2e720702f132b8,18), - ('wsteth-wrapped-liquid-staked-ether-20', 'zkevm', 'wstETH',0x5d8cff95d7a57c0bf50b30b43c7cc0d52825d4a9,18) + ('wsteth-wrapped-liquid-staked-ether-20', 'zkevm', 'wstETH',0x5d8cff95d7a57c0bf50b30b43c7cc0d52825d4a9,18), + ('wbtc-wrapped-bitcoin','zkevm','WBTC',0xea034fb02eb1808c2cc3adbc15f447b93cbe08e1,8), + ('cake-pancakeswap','zkevm','CAKE',0x0d1e753a25ebda689453309112904807625befbe,18), + ('aave-new','zkevm','AAVE',0x68791cfe079814c46e0e25c19bcc5bfc71a744f7,18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 510e13e50627d8c89d5df99666ac5ad96f6a7d2f Mon Sep 17 00:00:00 2001 From: rahmatullah85 <123723531+rahmatullah85@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:29:31 +0700 Subject: [PATCH 023/127] Update prices_solana_tokens.sql (#6739) Add MANEKI token price --- .../tokens/models/prices/solana/prices_solana_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql b/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql index 1213f73e885..23a59fd675b 100644 --- a/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql @@ -699,5 +699,6 @@ FROM ('mother-mother-iggy', 'solana', 'MOTHER', '3S8qX1MsMqRbiwKg2cQyx7nis1oHMgaCuc9c4VfvVdPN', 6), ('mumu1-mumu-the-bull', 'solana', 'MUMU', '5LafQUrVco6o7KMz42eqVEJ9LW31StPyGjeeu5sKoMtA', 6), ('nub-nubcat','solana', 'NUB', 'GtDZKAqvMZMnti46ZewMiXCa4oXF4bZxwQPoKzXPFxZn', 9), - ('bunk-bunkee', 'solana', 'BUNK', '2nhjjqSkA8FYCUdJvQhYjbtZdPjZbNo8VtNKTkJ3hncb', 6) + ('bunk-bunkee', 'solana', 'BUNK', '2nhjjqSkA8FYCUdJvQhYjbtZdPjZbNo8VtNKTkJ3hncb', 6), + ('maneki-maneki', 'solana', 'MANEKI', '25hAyBQfoDhfWx9ay6rarbgvWGwDdNqcHsXS3jQ3mTDJ', 5) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From bfe34776719eb1bafedaf907d88ff0f9484ab2e2 Mon Sep 17 00:00:00 2001 From: Demcruise <115721890+Demcruise@users.noreply.github.com> Date: Wed, 18 Sep 2024 22:29:47 +0700 Subject: [PATCH 024/127] Update prices_base_tokens.sql (#6737) add RDAT price token --- .../tokens/models/prices/base/prices_base_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql index 0ff677af4e8..f031df3066a 100644 --- a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql @@ -165,5 +165,6 @@ FROM ('chomp-chompcoin','base','CHOMP',0xebff2db643cf955247339c8c6bcd8406308ca437, 18), ('birddog-bird-dog-on-base','base','BIRDDOG',0x92af6f53febd6b4c6f5293840b6076a1b82c4bc2, 18), ('albert-albert-the-alien','base','ALBERT',0x0c067fc190cde145b0c537765a78d4e19873a5cc, 18), - ('tn100x-tn100x','base','TN100X',0x5b5dee44552546ecea05edea01dcd7be7aa6144a, 18) + ('tn100x-tn100x','base','TN100X',0x5b5dee44552546ecea05edea01dcd7be7aa6144a, 18), + ('rdat-rdatadao','base','RDAT',0x4498cd8ba045e00673402353f5a4347562707e7d, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From e0946ffdf105d81f93fbfc00e33fc2c0e8c0b609 Mon Sep 17 00:00:00 2001 From: Dedy Prasetyo Hermawan Date: Wed, 18 Sep 2024 22:30:34 +0700 Subject: [PATCH 025/127] Update prices_ethereum_tokens.sql (#6736) Add Synternet (SYNT) token price Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 02d68f1cfbd..aeb1b709510 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1834,6 +1834,7 @@ FROM ('elon-elon-memelord', 'ethereum', 'ELON', 0x69420e3a3aa9e17dea102bb3a9b3b73dcddb9528, 9), ('bar-gold-standard', 'ethereum', 'BAR', 0x777be1c6075c20184c4fd76344b7b0b7c858fe6b, 18), ('ftw-black-agnus', 'ethereum', 'FTW', 0x306fD3e7b169Aa4ee19412323e1a5995B8c1a1f4, 18), + ('synt-synternet','ethereum','SYNT',0xda987c655ebc38c801db64a8608bc1aa56cd9a31, 18), ('babydoge-baby-doge-coin', 'ethereum', 'BABYDOGE', 0xac57de9c1a09fec648e93eb98875b212db0d460b, 9), ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 0e824ea00acea326c75f99b1a0c947ee921b3e0b Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 08:31:40 -0700 Subject: [PATCH 026/127] add base tokens (#6730) * add base tokens * additional tokens --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../models/tokens/base/tokens_base_erc20.sql | 127 ++++++++++++++++++ .../models/tokens/base/tokens_base_schema.yml | 2 +- 2 files changed, 128 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql index b90ccc6add7..f6321bf090b 100644 --- a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20.sql @@ -254,4 +254,131 @@ FROM (VALUES , (0x85e90a5430af45776548adb82ee4cd9e33b08077, 'DINO', 18) , (0x7c6b91D9Be155A6Db01f749217d76fF02A7227F2, 'BAL', 18) , (0xa1e4240C9E9B8db3ba9e7625A9571c3B0FF71988, 'PJ', 18) + , (0x340c070260520ae477b88caa085a33531897145b, '9MM', 18) + , (0x38d513ec43dda20f323f26c7bef74c5cf80b6477, 'CARLO', 18) + , (0x8d3419b9a18651f3926a205ee0b1acea1e7192de, 'LOA', 18) + , (0xed899bfdb28c8ad65307fa40f4acab113ae2e14c, 'ROOST', 18) + , (0x6bd81aad9b25ad1e0b99c47ed01b34eacf4b8be7, 'BODA', 18) + , (0x75570e1189ffc1d63b3417cdf0889f87cd3e9bd1, 'Bunny', 18) + , (0x1c7a460413dd4e964f96d8dfc56e7223ce88cd85, 'SEAM', 18) + , (0x8319767a7b602f88e376368dca1b92d38869b9b4, 'PEACH', 18) + , (0x42069de48741db40aef864f8764432bbccbd0b69, 'BETS', 18) + , (0x1ccb4b14a11e0f2994a7ecbbd4cc69632f4c7c76, 'CCC', 18) + , (0xacd1caef47e4c47bafe8a51b3f4305fc38203b7a, 'LUNE', 18) + , (0xd327d36eb6e1f250d191cd62497d08b4aaa843ce, 'FOMO', 9) + , (0x00e57ec29ef2ba7df07ad10573011647b2366f6d, 'TOSHE', 18) + , (0xf1b4ddf712e108cf43711b1c39f2fddb0d5ce243, 'BASE', 18) + , (0x87c211144b1d9bdaa5a791b8099ea4123dc31d21, 'BCP', 18) + , (0xa5fbc981ebd8f4e791be8bd7a9b7cb144d145bf9, 'MEMEGOD', 18) + , (0x30d19fb77c3ee5cfa97f73d72c6a1e509fa06aef, 'CONDO', 18) + , (0x8b781e0f2967571e96d5d95b3cb61e27785eeaa5, 'BORKIE', 18) + , (0x3159fb5589acd6bf9f82eb0efe8382ed55aed8fd, 'APU', 18) + , (0x029635e83bc26c96006298e05798cdda76a2e7a5, 'SYD', 18) + , (0x314da69de85145fdd5b7580971e9db0388a2cdc4, 'BSW', 18) + , (0x8ad5b9007556749de59e088c88801a3aaa87134b, 'FARTHER', 18) + , (0x64cc19a52f4d631ef5be07947caba14ae00c52eb, 'KIBBLE', 18) + , (0x45096bd2871911ee82a3084d77a01efa3c9c6733, 'BUB', 18) + , (0x44fccd875c8e80b37f38530f434386a6d59141bb, 'DTB', 18) + , (0xfd008f937b4d73eeb00cf74ce90c392be5f07f96, 'MOON', 18) + , (0x160381343365de6d5e7d32172987b3e6bd1cce71, 'Mari', 18) + , (0x546d239032b24eceee0cb05c92fc39090846adc7, 'SEED', 18) + , (0x4c584cbc3a221998dc003349e1c12a4179e97b25, 'BMONEY', 18) + , (0x9721b1ce4ffd8af047bbdfd87e4e20ddc544513a, 'BROS', 18) + , (0xc41ba5737baf6bd0ccd5daf7eee39874e4ad45ff, 'DEGENS', 18) + , (0x10c1b6f768e13c624a4a23337f1a5ba5c9be0e4b, 'WARPIE', 18) + , (0xfd9fa4f785331ce88b5af8994a047ba087c705d8, '$blue', 18) + , (0x420697291f6ce9fbb34e9feddd61868ca2f81f5c, 'MONEYBEE', 18) + , (0x9a589baa21f0492bd4f35a33915986db56d8eecf, 'CATZ', 18) + , (0x2156006a207a793b4069a2b72be58dc2bd759232, 'COIN', 18) + , (0x17931cfc3217261ce0fa21bb066633c463ed8634, 'BASED', 18) + , (0xb9ea61ed1c9942011e5e44f7fae3efddbf277b1e, 'CHIP', 18) + , (0xea6f7e7e0f46a9e0f4e2048eb129d879f609d632, 'PERCY', 18) + , (0x05ad8adc21778f2a2c6800852f05fb949ef507dc, 'HACHI', 18) + , (0x8fe815417913a93ea99049fc0718ee1647a2a07c, 'XSWAP', 18) + , (0x9260409d4719c235c7c199106219f9616d66bde0, 'ArabWif', 18) + , (0x1c22374032e7e5a1bbde3d943f5deb310db060dd, 'onchain', 18) + , (0x57d0ffb02f73aa09dd22d7e81d6c0c81054ab5d9, 'DRAGGY', 18) + , (0xb59c8912c83157a955f9d715e556257f432c35d7, 'TRUF', 18) + , (0x619c4bbbd65f836b78b36cbe781513861d57f39d, 'BWB', 18) + , (0xffcd2489d5492c526126e699b15646b204dd4b2b, 'GCAT', 18) + , (0x1f1aa4d239002bb818536c95e9b762a1fc8484c1, 'RAIN', 18) + , (0x9aaae745cf2830fb8ddc6248b17436dc3a5e701c, 'GOCHU', 18) + , (0x5e1773eb46e74f3a3511fdfe4ba730b3b50411e5, 'BOCAT', 18) + , (0xada3214dc8a4ec6873424e3aba36e8073cf078a5, 'XMRB', 9) + , (0xf086206423f9e9686192bee98c042131d7bc1336, 'DONGUS', 18) + , (0x48164ea5df090e80a0eaee1147e466ea28669221, 'MOB', 18) + , (0x72d1eb99bebadc114c52526f55c9bbad5870dd5c, 'FRENS', 18) + , (0xebe41d50635cddc9a56473fb500f45ac143294bd, 'WAT', 18) + , (0xa617c0c739845b2941bd8edd05c9f993ecc97c18, 'GMR', 18) + , (0x5812fb91b48467dbbe3394d6d3ef7be9707dcddf, 'FISH', 9) + , (0x00000ef506a961089d388276989a967c96c8e314, 'NETA', 18) + , (0x21831890dcefdcbcc5bedce6edb008dd3cdc9c33, 'KICHI', 18) + , (0x1804e3db872eed4141e482ff74c56862f2791103, 'Rocco', 18) + , (0xe652e7448b3beb0e952c9d9493f8899edae058d3, 'CRACK', 18) + , (0x7c101a0e141517009d3138743213e3e835a809de, 'COSMIC', 18) + , (0x980a3662ddbffa895af03c54e7b97cb3bc868ed2, 'ELARA', 9) + , (0x2533b7bed37d1e7366f3d5c9215ceb51b65ac40b, 'LOL', 18) + , (0xecbc993c4b29eb5a192712d689b63a8a665a8f78, 'BaKiK', 18) + , (0x7fdd7419428955dbf36d4176af5a8f09ad29d1f3, 'BOSHI', 18) + , (0xb8e0b7d0df89673e4f6f82a66ef642a1cd46e010, '$REFLECT', 18) + , (0x81f5d76cfb4e49114d9f7a7d04ec108297f4de24, 'BABYCLUB', 18) + , (0x1c1ec1bb5f12f24c97231165b13f3eab9d4ec00e, '2FAI', 9) + , (0xf4509f6c51c780beae92e2740d33607cdc0c42f3, '$CHOO', 18) + , (0x47c6fecd5e41b234f47846760c060934732f2024, 'RALLY', 18) + , (0x528757e34a5617aa3aabe0593225fe33669e921c, 'DRAGON', 9) + , (0x692991ddefadfd6947f8a59a2be4bad14f7ea73f, 'BASED', 18) + , (0xb488fcb23333e7baa28d1dfd7b69a5d3a8bfeb3a, 'terminal', 18) + , (0x8069ef9b21bf292ba05ae527e1960c9676816ee6, 'GME', 11) + , (0xf3c052f2baab885c610a748eb01dfbb643ba835b, 'GULP', 18) + , (0x064e496e3017a07c25754ab3c13e0d8371aded93, 'Billy', 18) + , (0x8619986e425bb1a78b3facfb1f2086aca91b6088, 'DAY1', 18) + , (0xc39f3069d9e58c50582d84c80bd664804e823856, 'SnapCat', 9) + , (0xb5116fe1193ea5ba1d3116e83b637f2d7f315dcc, 'BTC', 18) + , (0xfca95aeb5bf44ae355806a5ad14659c940dc6bf7, 'SHIB', 9) + , (0xdf068fd33f2297dc4c11c99f00fe3565d63398ce, 'Baseman', 18) + , (0x1d8968f4589ee9cbf960cc1ecc9bcf4e24d043cd, 'FOOL', 18) + , (0x8eed3ccb8ab1b178e2dd66d185e08f72d2fc4df9, '$PAPA', 18) + , (0x2816a491dd0b7a88d84cbded842a618e59016888, 'LONG', 18) + , (0x59a32d4b86ffcce0a7f388d6d858c6a0371915ab, 'MAMAI', 18) + , (0xdf3be0ba8450304fa305c9637f6209495ce4f31e, 'BABYNORMUS', 18) + , (0xb6ca1a05315eb64abe842fd37b94b52934792383, 'ETHISM', 18) + , (0x4744767b43b62207dc343c5b540f0aef54e31f94, 'TUTTER', 18) + , (0xb7cfe05915ef0c040c6dde2007c9ddab26259e04, 'MOLLY', 18) + , (0x419423aad02cf951850e336da067db3235baf932, 'BASEWIFHAT', 18) + , (0x96b3478cf54f373c5a3d0ad43d7e5160f3b48dbe, 'NEKO', 18) + , (0x8a7ef77c5cfcaf520c012ada94ac4826814a34aa, 'LOL', 18) + , (0xf0e71975ed873d435837c53554a4373edc72015a, 'YrPi', 9) + , (0xd7ffe0ba4464582706411742899ba467fc833005, 'RD', 18) + , (0x95017e6f16375e63e5cb4d3a5fbf3c40775b08f4, 'CATCH', 18) + , (0x08e4c025819e1f4b5ccc1fa86d7df5bc47a0231d, 'Peplo', 18) + , (0x8dcb20a4cb69c6a4b5f61ff3a62c8fbc4312e25c, 'PANCAKE', 18) + , (0x69ba5ef917ef6ae8ad748717682ca5aae4da1eed, 'SHARKE', 18) + , (0x59a1686faaa2d9d1d9c8d4acd5ab6fd108fdbff3, 'QUEEN', 9) + , (0xa88303cabc6a8797d487988bec3b164f298cfda9, 'BABO', 18) + , (0x35b788b3ae9b1a75aea5893972f5012386a0f920, 'BabyCrash', 18) + , (0x44f8396f60129a30724560ea731122dcf7b8352f, 'RENT', 18) + , (0xee034e475a4be2def50df8a867f2986c4e47211f, 'GN', 9) + , (0x717f9a91b23ca88d1ca735be20e4007c65dc35ef, 'HALO', 18) + , (0x7a43121e70f10a5b7f114e5962158e0aa4c74508, 'RWASS', 18) + , (0xd7eace7eb073dbc73270592efce06cfec2ccec4c, 'FREN', 18) + , (0xe2e50097c2789ae1b52e9a15603eda02517b4628, 'BAPE', 18) + , (0x40be61a8c047e84aa974eac296eaabf09945d3b2, 'BUIDL', 18) + , (0xaf19e4456c0de828496d93c7fd7eaed9b7132eeb, 'SLRS', 18) + , (0x38029c62dfa30d9fd3cadf4c64e9b2ab21dbda17, 'Dubbz', 18) + , (0x089fc731c23d8c7de67b1cd9fc3eb42893cbf3c1, '$SMOG', 18) + , (0x18dd0cbc659347749480f5732683a7df5c44c6cd, 'BWF', 18) + , (0x8b3389fe40aab36cde72d41ba623752b4beb2731, 'SBM', 18) + , (0x26eaf1bae909954ee702c315eb59eba6a2fb6c2a, 'TOP G', 18) + , (0xf95e1c0a67492720ca22842122fe7fa63d5519e5, 'LUNARLENS', 18) + , (0xab8d437481cd68ab5f14ba483e7e81952fd720bd, 'FUN', 18) + , (0xceee43899c4b5ecf1b9b7af6c3012598b3d5295e, 'BCAT', 18) + , (0x471e49de9a1521768d169aec6aa586dc0d0d64cc, 'BOB', 18) + , (0xa7296cefae8477a81e23230ca5d3a3d6f49d3764, 'FIT', 18) + , (0xbd2a89f43c209f23423db5a01a62a9ed107d07d9, 'AIMC', 18) + , (0xa8507c43d1f2029bd3ca3d3e8978ec15b1bc8a7f, 'SHINJA', 18) + , (0xf62fb3d97bdafd50f028ba4d5fb5beda0038cae0, 'BLO', 18) + , (0xdb19b61fc52eb16fbe1e4e9e5441949040512d32, 'NULL', 18) + , (0x37e428349c8e754c8f70b90f4a0c50cee50b174b, 'BRETT420', 18) + , (0x0066cadd8822f2f260db3395dcfa6015bb9c1042, '🍌', 18) + , (0xbb4f69a0fca3f63477b6b3b2a3e8491e5425a356, 'GRASS', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml b/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml index 46487efa49d..c3fd81881fa 100644 --- a/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml @@ -6,7 +6,7 @@ models: blockchain: base sector: tokens project: erc20 - contributors: hildobby + contributors: hildobby, rantum config: tags: ['table', 'erc20', 'base'] description: "All ERC20 Token Addresses on Base - with mapped Symbols and Decimals if known." From 59c279a82d76e1ac45d86c13466e1e6d9532a705 Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 08:32:03 -0700 Subject: [PATCH 027/127] add tokens & symbols (#6728) * add scroll tokens & symbols * add addtiional tokens --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../tokens/arbitrum/tokens_arbitrum_erc20.sql | 11 ++++++ .../arbitrum/tokens_arbitrum_schema.yml | 2 +- .../models/tokens/bnb/tokens_bnb_bep20.sql | 5 +++ .../models/tokens/bnb/tokens_bnb_schema.yml | 2 +- .../tokens/ethereum/tokens_ethereum_erc20.sql | 36 ++++++++++++++++++- .../ethereum/tokens_ethereum_schema.yml | 2 +- .../tokens_optimism_erc20_curated.sql | 3 +- .../optimism/tokens_optimism_schema.yml | 2 +- .../tokens/polygon/tokens_polygon_erc20.sql | 5 +++ .../tokens/scroll/tokens_scroll_erc20.sql | 2 ++ .../tokens/scroll/tokens_scroll_schema.yml | 2 +- 11 files changed, 65 insertions(+), 7 deletions(-) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql index 129b66ba938..fc06a736b80 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql @@ -100,4 +100,15 @@ FROM (VALUES , (0x90364aa61234b85251ad943681433904c35fa5ce, 'METIS', 18) , (0x4026affabd9032bcc87fa05c02f088905f3dc09b, 'SWISE', 18) , (0xf6d22e29496313d89ad6261fbae8d118181561de, 'GT', 18) + , (0xe7076d4bb604dea53adaa424fce0336ee7f975ff, 'auraezETH/wstETH', 18) + , (0xb3cf6721d8f88f7547d90ed8e4119e09945efa9a, 'aurarsETH/wETH', 18) + , (0x2f7242373f4b2c831870c145376c4fc9ac76a35d, 'aurarsETH/rETH/wstETH', 18) + , (0xc99b6fd0486448f100891ca43c015fd6f09c8bd0, 'aurarwstETH-WETH-BPT', 18) + , (0x5043a95c4ae68c32b936513cc144401b06893154, 'aura4POOL-BPT', 18) + , (0x324fe9b8a46973d63a4d8e08bcbe9df6da1f9dff, 'aurarETH/wETH BPT', 18) + , (0xc87b37a581ec3257b734886d9d3a581f5a9d056c, 'ATH', 18) + , (0x93fa0b88c0c78e45980fa74cdd87469311b7b3e4, 'XBG', 18) + , (0x9aee3c99934c88832399d6c6e08ad802112ebeab, 'FU', 18) + , (0xe47ba52f326806559c1dec7ddd997f6957d0317d, 'SHELL', 18) + , (0x79ead7a012d97ed8deece279f9bc39e264d7eef9, 'Bonsai', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml index e875305d821..7b539b9d4a8 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml @@ -6,7 +6,7 @@ models: blockchain: arbitrum sector: tokens project: erc20 - contributors: soispoke, dot2dotseurat, mtitus6, maybeYonas + contributors: soispoke, dot2dotseurat, mtitus6, maybeYonas, rantum config: tags: ['table', 'erc20'] description: "ERC20 Token Addresses, Symbols and Decimals" diff --git a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_bep20.sql b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_bep20.sql index 57508ec8220..21782b7f17d 100644 --- a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_bep20.sql +++ b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_bep20.sql @@ -588,4 +588,9 @@ FROM (VALUES , (0x1cebf8735c8d1365cb4c2117787dc811ea6148e0, 'DUSD', 18) , (0xefc41e176a20ae15c7c20da48d40d83d098845d8, 'SPRT', 18) , (0xd691d9a68C887BDF34DA8c36f63487333ACfD103, 'MAV', 18) + , (0x2b5d9adea07b590b638ffc165792b2c610eda649, 'CKP', 18) + , (0x3b6564b5da73a41d3a66e6558a98fd0e9e1e77ad, 'UTS', 18) + , (0x6985884c4392d348587b19cb9eaaf157f13271cd, 'ZRO', 18) + , (0xfceb31a79f71ac9cbdcf853519c1b12d379edc46, 'LISTA', 18) + , (0x0e7779e698052f8fe56c415c3818fcf89de9ac6d, 'ULTI', 18) ) AS temp_table (contract_address, symbol, decimals) \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml index a92c8032276..a0c42ece067 100644 --- a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml @@ -6,7 +6,7 @@ models: blockchain: bnb sector: tokens project: bep20 - contributors: hildobby + contributors: hildobby, rantum config: tags: ['tokens', 'metadata', 'bep20', 'bnb'] description: "BEP20 Token Addresses, Symbols and Decimals" diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql index dc2f570ddf3..cf35f9e8226 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4590,5 +4590,39 @@ FROM (VALUES , ( 0x20157dbabb84e3bbfe68c349d0d44e48ae7b5ad2, 'dlcBTC', 8) , ( 0xe1B4d34E8754600962Cd944B535180Bd758E6c2e, 'agETH', 18) , ( 0x5C5b196aBE0d54485975D1Ec29617D42D9198326, 'stdeUSD', 18) - , ( 0x09db87a538bd693e9d08544577d5ccfaa6373a48, 'ynETH', 18) + , ( 0x09db87a538bd693e9d08544577d5ccfaa6373a48, 'ynETH', 18) + , ( 0x3b50805453023a91a8bf641e279401a0b23fa6f9, 'REZ', 18) + , ( 0x7777cec341e7434126864195adef9b05dcc3489c, 'ONI', 18) + , ( 0x3ffeea07a27fab7ad1df5297fa75e77a43cb5790, 'PEIPEI', 18) + , ( 0x00f116ac0c304c570daaa68fa6c30a86a04b5c5f, 'INF', 18) + , ( 0x777be1c6075c20184c4fd76344b7b0b7c858fe6b, 'BAR', 18) + , ( 0xaa32f860756f6dcd5a684dc2aadf6c0921257a9a, 'YUNA', 18) + , ( 0xa045fe936e26e1e1e1fb27c1f2ae3643acde0171, 'KAI', 9) + , ( 0x9e566e28c61690f8afe0468f523e137b1ff29f01, 'GNCAT', 9) + , ( 0x7f911119435d8ded9f018194b4b6661331379a3d, 'FWOG', 18) + , ( 0x6985884c4392d348587b19cb9eaaf157f13271cd, 'ZRO', 18) + , ( 0x7b0df1cd724ec34ec9bc4bd19749b01afb490761, 'KOIN', 9) + , ( 0xb60fdf036f2ad584f79525b5da76c5c531283a1b, 'NEMO', 9) + , ( 0x5b342f03d126314d925fa57a45654f92905e6451, 'MNTA', 18) + , ( 0x8149745670881d99700078ede5903a1a7bebe262, 'PEPAY', 18) + , ( 0xb6f4d11d6c274f8f0a55d101b65223a45a3d1128, 'eBAKE', 9) + , ( 0xb35875b40f5ea5483c84ccd6e4ab0afc42a3c355, 'Nerio', 9) + , ( 0xf7554eac0bf20d702e69d08c425e817abb976aea, 'MAHA', 18) + , ( 0x3742f3fcc56b2d46c7b8ca77c23be60cd43ca80a, 'stAVAIL', 18) + , ( 0xd8eb27a94e610a7b859758ed1f2d47ad224bfaaa, 'GOPEPE', 18) + , ( 0xf7760c2c0677078b1d1b6b8463f1de1c6c91a9f8, 'PP', 18) + , ( 0x78128d17a89e5fe51bd0e757cfbc5703c34c7fb6, '$EWT', 18) + , ( 0xf1ff59fa458bee12d6526dbd92290090bf670e29, 'fluffy', 18) + , ( 0xffe9ae172dd1fc9929ba6902873e09fadf81afd7, 'GLOW', 18) + , ( 0xb146823fb8ea064d14ba1a52e3e55cde09afff2d, 'EYE', 18) + , ( 0x88ce174c655b6d11210a069b2c106632dabdb068, 'YAWN', 18) + , ( 0xf6b6235f6725f84457f5d6f0b0aa3c962a079977, 'WBKN', 18) + , ( 0x1039bae6254178ee2f6123cd64cde9e4ca79d779, 'WUKONG', 18) + , ( 0xe1c8d908f0e495cf6d8459547d1d28b72bf04bf2, 'TSAI', 18) + , ( 0x132b96b1152bb6be197501e8220a74d3e63e4682, 'WUKONG', 9) + , ( 0x516d339afa72f6959b8e06a31fbc32da3e49348b, 'CNCT', 18) + , ( 0x60407266586e204792b69b024558aa18228ab12f, 'MBAKER', 18) + , ( 0x048d07bd350ba516b84587e147284881b593eb86, 'SYNK', 18) + , ( 0xbbd91d5cda7085a186b1354e1b0744bb58ad7cf6, 'ZOMBIE', 9) + ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml index f3d409b6995..3b7adcf4133 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml @@ -6,7 +6,7 @@ models: blockchain: ethereum sector: tokens project: erc20 - contributors: soispoke, dot2dotseurat + contributors: soispoke, dot2dotseurat, rantum config: tags: ['table', 'erc20'] description: "ERC20 Token Addresses, Symbols and Decimals" diff --git a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_curated.sql b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_curated.sql index 6635541213c..fbb3b7e3457 100644 --- a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_curated.sql +++ b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_curated.sql @@ -449,7 +449,8 @@ WITH raw_token_list AS ( ,(0x337b4b933d60f40cb57dd19ae834af103f049810, 's_aOptWETH', 18, 'receipt') ,(0xe62dda84e579e6a37296bcfc74c97349d2c59ce3, 'ysWETH', 18, 'receipt') ,(0xd08C3F25862077056cb1b710937576Af899a4959, 'InstETH', 18, 'underlying') - ,(0x57f5e098cad7a3d1eed53991d4d66c45c9af7812, 'wUSDM', 18, 'receipt') + ,(0x57f5e098cad7a3d1eed53991d4d66c45c9af7812, 'wUSDM', 18, 'receipt') + ,(0xbfd5206962267c7b4b4a8b3d76ac2e1b2a5c4d5e, 'OSAK', 18, 'underlying') ) AS temp_table (contract_address, symbol, decimals, token_type) ) SELECT diff --git a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml index 6e8afb8c534..9038606ca81 100644 --- a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml @@ -37,7 +37,7 @@ models: blockchain: optimism sector: tokens project: erc20 - contributors: msilb7 + contributors: msilb7, rantum config: tags: ['table', 'erc20', 'optimism'] description: "Manually identified ERC20 Token Addresses, Symbols and Decimals" diff --git a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20.sql b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20.sql index df983de9138..6e911f2ebfd 100644 --- a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20.sql @@ -46,4 +46,9 @@ FROM (VALUES , (0xc3323b6e71925b25943fb7369ee6769837e9c676, 'PORIGON', 18) , (0x365e13f973bd62024be8a70a225684c58baad03c, 'MPM', 18) , (0xA135f5A2Fb085c15BF56e5703e61167Fb5Ae7E42, 'MIKI', 18) + , (0x3c69d114664d48357d820dbdd121a8071eac99bf, 'GALAXIS', 18) + , (0x683565196c3eab450003c964d4bad1fd3068d4cc, 'VDA', 18) + , (0x94f05506b6a9c564839d8e95b21f9fb4f42ff2aa, 'SFRIED', 18) + , (0x9b8b6a1298d34b3c4bbddce8a7ff0149121592c1, 'AMBO', 18) + , (0xe9d2fa815b95a9d087862a09079549f351dab9bd, 'BONSAI', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_erc20.sql b/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_erc20.sql index 61bdbe0aba7..78c0a6f023e 100644 --- a/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_erc20.sql @@ -25,4 +25,6 @@ FROM (VALUES , (0x608ef9a3bffe206b86c3108218003b3cfbf99c84, 'KNC', 18) , (0x79379c0e09a41d7978f883a56246290ee9a8c4d3, 'AAVE', 18) , (0x5300000000000000000000000000000000000004, 'WETH', 18) + , (0xaaae8378809bb8815c08d3c59eb0c7d1529ad769, 'NURI', 18) + , (0x8731d54e9d02c286767d56ac03e8037c07e01e98, 'STG', 18) ) AS temp_table (contract_address, symbol, decimals) \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_schema.yml b/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_schema.yml index b59b397f529..72eef1c075c 100644 --- a/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_schema.yml @@ -6,7 +6,7 @@ models: blockchain: scroll sector: tokens project: erc20 - contributors: lgingerich + contributors: lgingerich, rantum config: tags: ['table', 'erc20'] description: "ERC20 Token Addresses, Symbols and Decimals" From f13f21f46d9c21d951a218239cb203cae1687f08 Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 08:33:07 -0700 Subject: [PATCH 028/127] add linea tokens (#6722) * add linea tokens * fix ezETH symbol --- .../tokens/models/tokens/_schema.yml | 4 +-- .../tokens/linea/tokens_linea_erc20.sql | 35 +++++++++++++++++++ .../tokens/linea/tokens_linea_schema.yml | 21 +++++++++++ .../tokens/models/tokens/tokens_erc20.sql | 5 +-- 4 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 dbt_subprojects/tokens/models/tokens/linea/tokens_linea_erc20.sql create mode 100644 dbt_subprojects/tokens/models/tokens/linea/tokens_linea_schema.yml diff --git a/dbt_subprojects/tokens/models/tokens/_schema.yml b/dbt_subprojects/tokens/models/tokens/_schema.yml index 24973d74253..449bd4312c7 100644 --- a/dbt_subprojects/tokens/models/tokens/_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/_schema.yml @@ -5,9 +5,9 @@ models: meta: blockchain: arbitrum, avalanche_c, bnb, ethereum, gnosis, mantle, optimism, fantom, polygon, base, blast, sepolia, sei, nova sector: tokens - contributors: hildobby, 0xManny, dot2dotseurat, soispoke, mtitus6, wuligy, angus_1, Henrystats, viniabussafi, jeff-dude + contributors: hildobby, 0xManny, dot2dotseurat, soispoke, mtitus6, wuligy, angus_1, Henrystats, viniabussafi, jeff-dude, rantum config: - tags: ['tokens','erc20', 'arbitrum', 'avalanche_c', 'bnb', 'ethereum', 'gnosis', 'mantle', 'optimism', 'fantom', 'base', 'blast', 'sei', 'nova'] + tags: ['tokens','erc20', 'arbitrum', 'avalanche_c', 'bnb', 'ethereum', 'gnosis', 'mantle', 'optimism', 'fantom', 'base', 'blast', 'sei', 'nova', 'linea'] description: > Crosschain ERC20 tokens tests: diff --git a/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_erc20.sql b/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_erc20.sql new file mode 100644 index 00000000000..f16bc1ff104 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_erc20.sql @@ -0,0 +1,35 @@ +{{ + config( + schema = 'tokens_linea' + ,alias = 'erc20' + ,tags = ['static'] + ,materialized = 'table' + ) +}} + +SELECT + contract_address + , symbol + , decimals +FROM (VALUES + (0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f, 'WETH', 18), + (0xaaaac83751090c6ea42379626435f805ddf54dc8, 'NILE', 18), + (0x78354f8dccb269a615a7e0a24f9b0718fdc3c7a7, 'ZERO', 18), + (0x1bf74c010e6320bab11e2e5a532b5ac15e0b8aa6, 'weETH', 18), + (0xa219439258ca9da29e9cc4ce5596924745e12b93, 'USDT', 6), + (0x5fbdf89403270a1846f5ae7d113a989f850d1566, 'FOXY', 18), + (0xd2671165570f41bbb3b0097893300b6eb6101e6c, 'wrsETH', 18), + (0x43e8809ea748eff3204ee01f08872f063e44065f, 'MENDI', 18), + (0x176211869ca2b568f2a7d4ee941e073a821ee1ff, 'USDC', 6), + (0x63ba74893621d3d12f13cec1e86517ec3d329837, 'LUSD', 18), + (0xacb54d07ca167934f57f829bee2cc665e1a5ebef, 'CROAK', 18), + (0x82cc61354d78b846016b559e3ccd766fa7e793d5, 'LINDA', 18), + (0x2416092f143378750bb29b79ed961ab195cceea5, 'ezETH', 18), + (0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4, 'WBTC', 8), + (0x4af15ec2a0bd43db75dd04e62faa3b8ef36b00d5, 'DAI', 18), + (0x894134a25a5fac1c2c26f1d8fbf05111a3cb9487, 'GRAI', 18), + (0xeb466342c4d449bc9f53a865d5cb90586f405215, 'axlUSDC', 6), + (0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34, 'USDe', 18), + (0x59846bfc18fc21df6bed378748f99ea38f44d50a, 'lzIT', 6), + (0x1a51b19ce03dbe0cb44c1528e34a7edd7771e9af, 'LYNX', 18) +) AS temp_table (contract_address, symbol, decimals) \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_schema.yml b/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_schema.yml new file mode 100644 index 00000000000..d2fb3fd6976 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_schema.yml @@ -0,0 +1,21 @@ +version: 2 + +models: + - name: tokens_linea_erc20 + meta: + blockchain: linea + sector: tokens + project: erc20 + contributors: rantum + config: + tags: ['table', 'erc20'] + description: "ERC20 Token Addresses, Symbols and Decimals" + columns: + - name: contract_address + description: "ERC20 token contract address" + tests: + - unique + - name: symbol + description: "ERC20 token symbol" + - name: decimals + description: "Number of decimals, refers to how divisible an ERC20 token can be" diff --git a/dbt_subprojects/tokens/models/tokens/tokens_erc20.sql b/dbt_subprojects/tokens/models/tokens/tokens_erc20.sql index fa5d8aac7b9..f2ba6348830 100644 --- a/dbt_subprojects/tokens/models/tokens/tokens_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/tokens_erc20.sql @@ -3,10 +3,10 @@ schema = 'tokens' ,alias = 'erc20' ,materialized = 'table' - ,post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","bnb","celo","ethereum","fantom","fuse","gnosis","goerli","mantle","optimism","polygon","scroll","zkevm","zksync","zora","blast","sepolia","sei","nova"]\', + ,post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","bnb","celo","ethereum","fantom","fuse","gnosis","goerli","mantle","optimism","polygon","scroll","zkevm","zksync","zora","blast","sepolia","sei","nova","linea"]\', "sector", "tokens", - \'["bh2smith","0xManny","hildobby","soispoke","dot2dotseurat","mtitus6","wuligy","lgingerich","0xRob","jeff-dude","viniabussafi","IrishLatte19","angus_1","Henrystats"]\') }}' + \'["bh2smith","0xManny","hildobby","soispoke","dot2dotseurat","mtitus6","wuligy","lgingerich","0xRob","jeff-dude","viniabussafi","IrishLatte19","angus_1","Henrystats","rantum"]\') }}' ) }} @@ -37,6 +37,7 @@ ,'tokens_sepolia': {'blockchain': 'sepolia', 'model': ref('tokens_sepolia_erc20')} ,'tokens_sei': {'blockchain': 'sei', 'model': ref('tokens_sei_erc20')} ,'tokens_nova': {'blockchain': 'nova', 'model': ref('tokens_nova_erc20')} + ,'tokens_linea': {'blockchain': 'linea', 'model': ref('tokens_linea_erc20')} } %} with From b80fa50f44e79f46231fac5c4c359d40696557bc Mon Sep 17 00:00:00 2001 From: 0xBoxer <71930326+0xBoxer@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:33:22 +0200 Subject: [PATCH 029/127] Add upload script (#6622) * fix base source replace mishappen * add scripts * add gitignore * wut * add to gitigonore * Revert "add to gitigonore" This reverts commit 115122647cf1d9ba3d86bfb6748393c5ae46e74b. * delete manifest from branch * clean up files * add readme --- .gitignore | 3 + scripts/collect_manifests.py | 42 ++++++ scripts/upload-spell-metadata/readme.md | 56 ++++++++ .../upload-spell-metadata/upload-to-dune.py | 135 ++++++++++++++++++ 4 files changed, 236 insertions(+) create mode 100644 scripts/collect_manifests.py create mode 100644 scripts/upload-spell-metadata/readme.md create mode 100644 scripts/upload-spell-metadata/upload-to-dune.py diff --git a/.gitignore b/.gitignore index 1a1c62c9df8..46f99d09f96 100644 --- a/.gitignore +++ b/.gitignore @@ -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__/ @@ -146,3 +148,4 @@ logs/ !target/manifest.json !target/run_results.json !target/sources.json + diff --git a/scripts/collect_manifests.py b/scripts/collect_manifests.py new file mode 100644 index 00000000000..01e2b497b8e --- /dev/null +++ b/scripts/collect_manifests.py @@ -0,0 +1,42 @@ +import os +import subprocess +import shutil + +# need to make sure dbt deps are installed for all subprojects + +# Define the base directory of the repo, adjusting for script's location +base_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'dbt_subprojects')) + +# Define the list of subprojects to compile +subprojects = ['daily_spellbook', 'dex', 'hourly_spellbook', 'nft', 'solana', 'tokens'] + +# Directory to store the collected manifest.json files +output_dir = os.path.join(base_dir, 'manifests') +os.makedirs(output_dir, exist_ok=True) + +def run_dbt_compile(project_dir): + """Run `dbt compile` in the specified project directory.""" + try: + result = subprocess.run(['dbt', 'compile'], cwd=project_dir, check=True, capture_output=True, text=True) + print(f"Successfully compiled {project_dir}") + except subprocess.CalledProcessError as e: + print(f"Error compiling {project_dir}: {e.stdout}\n{e.stderr}") + +def collect_manifest(project_dir): + """Collect the manifest.json file from the project directory.""" + manifest_path = os.path.join(project_dir, 'target', 'manifest.json') + if os.path.exists(manifest_path): + dest_path = os.path.join(output_dir, f"{os.path.basename(project_dir)}_manifest.json") + shutil.copy(manifest_path, dest_path) + print(f"Collected {manifest_path} to {dest_path}") + else: + print(f"manifest.json not found in {project_dir}") + +def main(): + for subproject in subprojects: + project_dir = os.path.join(base_dir, subproject) + run_dbt_compile(project_dir) + collect_manifest(project_dir) + +if __name__ == "__main__": + main() diff --git a/scripts/upload-spell-metadata/readme.md b/scripts/upload-spell-metadata/readme.md new file mode 100644 index 00000000000..a1ae0ca0194 --- /dev/null +++ b/scripts/upload-spell-metadata/readme.md @@ -0,0 +1,56 @@ +# upload-to-dune.py + +## Overview + +`upload-to-dune.py` collects metadata from models and sources, combines it into a CSV, and uploads it to Dune Analytics. This maintains an up-to-date record of Spellbook models and sources on Dune. + +Before being able to run the script, you need to run the `collect_manifests.py` script first to generate the manifest files. + +## Functionality + +### Manifest Parsing + +Extracts information from multiple JSON manifest files. Sources only get read ones, models all get read. If there is a table that is defined as both source and model, the model's information is used. + +### CSV Creation + +Creates a CSV file with the combined model and source information. + +### Dune Upload + +Uploads the CSV to Dune Analytics via API. + +## Requirements + +- Python 3.x +- Python packages: `json`, `csv`, `os`, `requests`, `dotenv` +- Dune Analytics API key (stored in a `.env` file as `DUNE_API_KEY`) +- Correct project structure with manifest files in `dbt_subprojects/manifests` + +## How to Run + +1. Ensure all requirements are met. +2. Navigate to the script's directory. +3. Run: `python upload-to-dune.py` +4. Check console output for upload status. + +## Output + +- CSV file: `combined_dbt_models_sources.csv` +- Console output showing CSV file size and response from Dune API after upload attempt. + +| Column Name | Description | +| ------------------ | ------------------------------------------------------------------------------- | +| model_name | The name of the dbt model e.g. `dex.trades` | +| schema | The database schema where the model is located e.g. `dex` | +| alias | The alias of the model e.g. `trades` | +| partition_by | The column(s) used for partitioning the model, if applicable. empty for sources | +| column | The name of a specific column in the model | +| column_description | A description of the column's content or purpose defined in spellbook yml files | +| meta_origin | The origin of the metadata for this model. Either `source` or `model` | + +## Troubleshooting + +- Verify Python packages are installed. +- Check Dune API key is correct and set properly. +- Ensure manifest files are in the correct location and format. diff --git a/scripts/upload-spell-metadata/upload-to-dune.py b/scripts/upload-spell-metadata/upload-to-dune.py new file mode 100644 index 00000000000..e3b4854b322 --- /dev/null +++ b/scripts/upload-spell-metadata/upload-to-dune.py @@ -0,0 +1,135 @@ +import json +import csv +import os +import requests +import dotenv +from dotenv import load_dotenv + +# Load environment variables +load_dotenv() + +# Set up paths +script_dir = os.path.dirname(os.path.abspath(__file__)) +project_root = os.path.dirname(os.path.dirname(script_dir)) + +# Get API key from environment variable +api_key = os.getenv("DUNE_API_KEY") + +# Directory containing the manifest files +manifests_dir = os.path.join(project_root, 'dbt_subprojects', 'manifests') + +# CSV file to store combined data +csv_file_path = os.path.join(project_root, 'dbt_subprojects', 'manifests' , 'combined_dbt_models_sources.csv') + +def parse_manifest(file_path): + with open(file_path, 'r') as file: + data = json.load(file) + + info = {} + + # Parse sources + for unique_id, source_details in data['sources'].items(): + schema = source_details.get('schema') + name = source_details.get('name') + full_name = f"{schema}.{name}" + source_columns = source_details.get('columns', {}) + info[full_name] = { + 'schema': schema, + 'name': name, + 'columns': source_columns, + 'partition_by': '', + 'meta_origin': 'source' + } + + # Parse models (merging with source info if exists) + for node_id, node_details in data['nodes'].items(): + if node_details.get('resource_type') == 'model': + schema = node_details.get('schema') + alias = node_details.get('alias') + full_name = f"{schema}.{alias}" + partition_by = node_details.get('config', {}).get('partition_by') + model_columns = node_details.get('columns', {}) + + if full_name in info: + # Merge columns, prioritizing model descriptions + merged_columns = {**info[full_name]['columns'], **model_columns} + else: + merged_columns = model_columns + + info[full_name] = { + 'schema': schema, + 'name': alias, + 'columns': merged_columns, + 'partition_by': partition_by, + 'meta_origin': 'model' + } + + return info + +# Combine all manifests into a single CSV +with open(csv_file_path, 'w', newline='') as csvfile: + csvwriter = csv.writer(csvfile) + csvwriter.writerow(['model_name', 'schema', 'alias', 'partition_by', 'column', 'column_description', 'meta_origin']) + + combined_info = {} + + for filename in os.listdir(manifests_dir): + if filename.endswith('_manifest.json'): + file_path = os.path.join(manifests_dir, filename) + manifest_info = parse_manifest(file_path) + + # Update combined_info, merging column information + for full_name, details in manifest_info.items(): + if full_name not in combined_info: + combined_info[full_name] = details + else: + # Merge columns, keeping all descriptions + combined_info[full_name]['columns'] = { + **combined_info[full_name]['columns'], + **details['columns'] + } + # Update meta_origin to 'model' if it's a model + if details['meta_origin'] == 'model': + combined_info[full_name]['meta_origin'] = 'model' + combined_info[full_name]['partition_by'] = details['partition_by'] + + # Write combined information to CSV + for full_name, details in combined_info.items(): + schema = details['schema'] + name = details['name'] + partition_by = details['partition_by'] + meta_origin = details['meta_origin'] + + if details['columns']: + for column_name, column_details in details['columns'].items(): + column_description = column_details.get('description', 'No description available') + csvwriter.writerow([full_name, schema, name, partition_by, column_name, column_description, meta_origin]) + else: + csvwriter.writerow([full_name, schema, name, partition_by, '', '', meta_origin]) + +# Upload the CSV to Dune +url = 'https://api.dune.com/api/v1/table/upload/csv' + +with open(csv_file_path, 'r') as file: + data = file.read() + # Print the size of the CSV file + file_size = os.path.getsize(csv_file_path) + print('CSV file size:', file_size/1000, 'kilobytes') + + # Set the headers and metadata for the CSV data + headers = {'X-Dune-Api-Key': api_key} + + # Construct the payload for the API + payload = { + "table_name": "spellbook_table_infos", + "description": "Combined Spellbook models and sources metadata", + "data": str(data), + "is_private": False + } + + # Send the POST request to the HTTP endpoint + response = requests.post(url, data=json.dumps(payload), headers=headers) + + # Print the response status code and content + print('Response status code:', response.status_code) + print('Response content:', response.content) \ No newline at end of file From 70c14b6bd20f6953ada187cee9b424e2e15ec48e Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:53:59 -0300 Subject: [PATCH 030/127] add beethoven x and jelly swap to pools_metrics_daily (#6721) * add beetoven x and jelly swap to pools_metrics_daily * fix schemas * again * again * break into 2 PRs --- ...beethoven_x_fantom_pools_metrics_daily.sql | 82 +++++++++++++++++++ .../fantom/beethoven_x_fantom_schema.yml | 39 +++++++++ .../jelly_swap_sei_pools_metrics_daily.sql | 82 +++++++++++++++++++ .../jelly_swap/sei/jelly_swap_sei_schema.yml | 41 +++++++++- sources/_subprojects_outputs/dex/_sources.yml | 6 ++ .../hourly_spellbook/_sources.yml | 8 ++ 6 files changed, 257 insertions(+), 1 deletion(-) create mode 100644 dbt_subprojects/daily_spellbook/models/beethoven_x/fantom/beethoven_x_fantom_pools_metrics_daily.sql create mode 100644 dbt_subprojects/daily_spellbook/models/jelly_swap/sei/jelly_swap_sei_pools_metrics_daily.sql diff --git a/dbt_subprojects/daily_spellbook/models/beethoven_x/fantom/beethoven_x_fantom_pools_metrics_daily.sql b/dbt_subprojects/daily_spellbook/models/beethoven_x/fantom/beethoven_x_fantom_pools_metrics_daily.sql new file mode 100644 index 00000000000..95c7325df71 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/beethoven_x/fantom/beethoven_x_fantom_pools_metrics_daily.sql @@ -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 diff --git a/dbt_subprojects/daily_spellbook/models/beethoven_x/fantom/beethoven_x_fantom_schema.yml b/dbt_subprojects/daily_spellbook/models/beethoven_x/fantom/beethoven_x_fantom_schema.yml index 73a6025c8b7..8145db2d2e1 100644 --- a/dbt_subprojects/daily_spellbook/models/beethoven_x/fantom/beethoven_x_fantom_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/beethoven_x/fantom/beethoven_x_fantom_schema.yml @@ -328,3 +328,42 @@ models: - name: token_address - name: daily_delta description: "Daily total impact on BPT supply" + + - name: beethoven_x_fantom_pools_metrics_daily + meta: + blockchain: fantom + contributors: viniabussafi, metacrypto + config: + tags: ['fantom', 'jelly_swap', 'pool', 'stats', 'volume', 'tvl', 'fee'] + description: > + This spell aggregates data from the trades, liquidity and protocol fees spells, by day and pool, while also displaying some basic information about the pool + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - project_contract_address + columns: + - *blockchain + - name: project + - name: version + - name: block_date + - &project_contract_address + name: project_contract_address + description: "Pool address" + - *pool_symbol + - name: pool_type + - &swap_amount_usd + name: swap_amount_usd + description: "Daily swap volume on a pool, in USD" + - &tvl_usd + name: tvl_usd + description: "Total Value Locked on a pool, in USD" + - &tvl_eth + name: tvl_eth + description: "Total Value Locked on a pool, in eth" + - &fee_amount_usd + name: fee_amount_usd + description: "Daily fees collected on a pool, in USD" \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/jelly_swap/sei/jelly_swap_sei_pools_metrics_daily.sql b/dbt_subprojects/daily_spellbook/models/jelly_swap/sei/jelly_swap_sei_pools_metrics_daily.sql new file mode 100644 index 00000000000..ee53d7c5fd6 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/jelly_swap/sei/jelly_swap_sei_pools_metrics_daily.sql @@ -0,0 +1,82 @@ +{{ config( + schema = 'jelly_swap_sei', + 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 = "jelly_swap_sei", + contributors = \'["viniabussafi", "metacrypto"]\') }}' + ) +}} + + +WITH +trades AS( + SELECT + block_date, + version, + blockchain, + project_contract_address, + sum(amount_usd) AS swap_amount_usd + FROM {{ source('jelly_swap', '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('jelly_swap_sei_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('jelly_swap_sei_protocol_fee') }} + {% if is_incremental() %} + WHERE {{incremental_predicate('day')}} + {% endif %} + GROUP BY 1, 2, 3, 4 +) + +SELECT + l.blockchain, + 'jelly_swap_sei' 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 diff --git a/dbt_subprojects/daily_spellbook/models/jelly_swap/sei/jelly_swap_sei_schema.yml b/dbt_subprojects/daily_spellbook/models/jelly_swap/sei/jelly_swap_sei_schema.yml index 4fdbce28476..fecc0c2a715 100644 --- a/dbt_subprojects/daily_spellbook/models/jelly_swap/sei/jelly_swap_sei_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/jelly_swap/sei/jelly_swap_sei_schema.yml @@ -327,4 +327,43 @@ models: - name: version - name: token_address - name: daily_delta - description: "Daily total impact on BPT supply" \ No newline at end of file + description: "Daily total impact on BPT supply" + + - name: jelly_swap_sei_pools_metrics_daily + meta: + blockchain: sei + contributors: viniabussafi, metacrypto + config: + tags: ['sei', 'jelly_swap', 'pool', 'stats', 'volume', 'tvl', 'fee'] + description: > + This spell aggregates data from the trades, liquidity and protocol fees spells, by day and pool, while also displaying some basic information about the pool + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - project_contract_address + columns: + - *blockchain + - name: project + - name: version + - name: block_date + - &project_contract_address + name: project_contract_address + description: "Pool address" + - *pool_symbol + - name: pool_type + - &swap_amount_usd + name: swap_amount_usd + description: "Daily swap volume on a pool, in USD" + - &tvl_usd + name: tvl_usd + description: "Total Value Locked on a pool, in USD" + - &tvl_eth + name: tvl_eth + description: "Total Value Locked on a pool, in eth" + - &fee_amount_usd + name: fee_amount_usd + description: "Daily fees collected on a pool, in USD" \ No newline at end of file diff --git a/sources/_subprojects_outputs/dex/_sources.yml b/sources/_subprojects_outputs/dex/_sources.yml index 3fe73758d76..88751103645 100644 --- a/sources/_subprojects_outputs/dex/_sources.yml +++ b/sources/_subprojects_outputs/dex/_sources.yml @@ -69,3 +69,9 @@ sources: - name: cow_protocol_arbitrum tables: - name: trades + - name: jelly_swap + tables: + - name: trades + - name: beethoven_x + tables: + - name: trades diff --git a/sources/_subprojects_outputs/hourly_spellbook/_sources.yml b/sources/_subprojects_outputs/hourly_spellbook/_sources.yml index f00aaa31743..fc633083e38 100644 --- a/sources/_subprojects_outputs/hourly_spellbook/_sources.yml +++ b/sources/_subprojects_outputs/hourly_spellbook/_sources.yml @@ -42,3 +42,11 @@ sources: - name: perpetual tables: - name: trades + + - name: beethoven_x_fantom + tables: + - name: pools_metrics_daily + + - name: jelly_swap_sei + tables: + - name: pools_metrics_daily \ No newline at end of file From fd242829fca4bbb0707b3a45a88a007f2388aaaf Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 08:54:09 -0700 Subject: [PATCH 031/127] add new mev addresses (#6706) * add new mev addresses * remove dup --- .../ethereum/addresses_ethereum_mev.sql | 175 +++++++++++++++++- 1 file changed, 174 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/daily_spellbook/models/addresses/ethereum/addresses_ethereum_mev.sql b/dbt_subprojects/daily_spellbook/models/addresses/ethereum/addresses_ethereum_mev.sql index fc2f4ba86e7..a4b2cf3b60e 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses/ethereum/addresses_ethereum_mev.sql +++ b/dbt_subprojects/daily_spellbook/models/addresses/ethereum/addresses_ethereum_mev.sql @@ -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) From c4c99b3fbd7fdec0cd14d45b5a470ee4e9e3bc3d Mon Sep 17 00:00:00 2001 From: tomfutago <35136350+tomfutago@users.noreply.github.com> Date: Wed, 18 Sep 2024 16:55:37 +0100 Subject: [PATCH 032/127] Add ether.fi to lending sector (#6717) * add etherfi to lending sector * update seed samples --------- Co-authored-by: Huang Geyang --- .../lending/borrow/ethereum/_schema.yml | 38 +++++++++++++++++ .../ethereum/lending_ethereum_base_borrow.sql | 1 + .../aave_etherfi_v3_ethereum_base_borrow.sql | 21 ++++++++++ .../lending/flashloans/ethereum/_schema.yml | 33 +++++++++++++++ .../lending_ethereum_base_flashloans.sql | 1 + ...ve_etherfi_v3_ethereum_base_flashloans.sql | 21 ++++++++++ .../lending/supply/ethereum/_schema.yml | 38 +++++++++++++++++ .../ethereum/lending_ethereum_base_supply.sql | 1 + .../aave_etherfi_v3_ethereum_base_supply.sql | 21 ++++++++++ .../seeds/_sector/lending/_schema.yml | 41 +++++++++++++++++++ ...aave_etherfi_ethereum_base_borrow_seed.csv | 3 ++ ..._etherfi_ethereum_base_flashloans_seed.csv | 1 + ...aave_etherfi_ethereum_base_supply_seed.csv | 3 ++ .../lending/borrow/ethereum/_sources.yml | 6 +++ .../lending/flashloans/ethereum/_sources.yml | 4 ++ .../lending/supply/ethereum/_sources.yml | 6 +++ 16 files changed, 239 insertions(+) create mode 100644 dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/platforms/aave_etherfi_v3_ethereum_base_borrow.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/platforms/aave_etherfi_v3_ethereum_base_flashloans.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/platforms/aave_etherfi_v3_ethereum_base_supply.sql create mode 100644 dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_borrow_seed.csv create mode 100644 dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_flashloans_seed.csv create mode 100644 dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_supply_seed.csv diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/_schema.yml index c9a091246dc..c747736bf26 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/_schema.yml @@ -239,6 +239,44 @@ models: - *tx_hash - *evt_index + - name: aave_etherfi_v3_ethereum_base_borrow + meta: + blockchain: ethereum + sector: lending + project: aave_etherfi + contributors: tomfutago + config: + tags: ['lending', 'borrow', 'aave', 'etherfi', 'v3', 'ethereum'] + description: "Aave v3 borrow transactions on Ethereum" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - transaction_type + - token_address + - tx_hash + - evt_index + - check_lending_base_borrow_seed: + seed_file: ref('aave_etherfi_ethereum_base_borrow_seed') + filter: + version: 3 + columns: + - *blockchain + - *project + - *version + - *transaction_type + - *token_address + - *borrower + - *on_behalf_of + - *repayer + - *liquidator + - *amount + - *block_month + - *block_time + - *block_number + - *project_contract_address + - *tx_hash + - *evt_index + - name: compound_v1_ethereum_base_borrow meta: blockchain: ethereum diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/lending_ethereum_base_borrow.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/lending_ethereum_base_borrow.sql index 4ae598e2a2c..c8b1b328b59 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/lending_ethereum_base_borrow.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/lending_ethereum_base_borrow.sql @@ -12,6 +12,7 @@ ref('aave_v2_ethereum_base_borrow'), ref('aave_v3_ethereum_base_borrow'), ref('aave_lido_v3_ethereum_base_borrow'), + ref('aave_etherfi_v3_ethereum_base_borrow'), ref('compound_v1_ethereum_base_borrow'), ref('compound_v2_ethereum_base_borrow'), ref('compound_v3_ethereum_base_borrow'), diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/platforms/aave_etherfi_v3_ethereum_base_borrow.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/platforms/aave_etherfi_v3_ethereum_base_borrow.sql new file mode 100644 index 00000000000..310857d76ad --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/borrow/ethereum/platforms/aave_etherfi_v3_ethereum_base_borrow.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'aave_etherfi_v3_ethereum', + alias = 'base_borrow', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transaction_type', 'token_address', 'tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + lending_aave_v3_compatible_borrow( + blockchain = 'ethereum', + project = 'aave_etherfi', + version = '3', + project_decoded_as = 'aave_v3_etherfi', + decoded_contract_name = 'PoolInstance' + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/_schema.yml index 6834502a7f4..03c9fd84722 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/_schema.yml @@ -205,6 +205,39 @@ models: - *tx_hash - *evt_index + - name: aave_etherfi_v3_ethereum_base_flashloans + meta: + blockchain: ethereum + sector: lending + project: aave_etherfi + contributors: tomfutago + config: + tags: ['lending', 'flashloans', 'aave', 'etherfi', 'ethereum'] + description: "Aave v3 flashloans transactions on Ethereum" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_lending_base_flashloans_seed: + seed_file: ref('aave_etherfi_ethereum_base_flashloans_seed') + filter: + version: 3 + columns: + - *blockchain + - *project + - *version + - *recipient + - *amount + - *fee + - *token_address + - *project_contract_address + - *block_month + - *block_time + - *block_number + - *tx_hash + - *evt_index + - name: radiant_ethereum_base_flashloans meta: blockchain: ethereum diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/lending_ethereum_base_flashloans.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/lending_ethereum_base_flashloans.sql index 56f82efeaad..7f33769ae09 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/lending_ethereum_base_flashloans.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/lending_ethereum_base_flashloans.sql @@ -12,6 +12,7 @@ ref('aave_v2_ethereum_base_flashloans'), ref('aave_v3_ethereum_base_flashloans'), ref('aave_lido_v3_ethereum_base_flashloans'), + ref('aave_etherfi_v3_ethereum_base_flashloans'), ref('radiant_ethereum_base_flashloans'), ref('uwulend_ethereum_base_flashloans'), ref('spark_ethereum_base_flashloans'), diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/platforms/aave_etherfi_v3_ethereum_base_flashloans.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/platforms/aave_etherfi_v3_ethereum_base_flashloans.sql new file mode 100644 index 00000000000..6c0ffae8c67 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/flashloans/ethereum/platforms/aave_etherfi_v3_ethereum_base_flashloans.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'aave_etherfi_v3_ethereum', + alias = 'base_flashloans', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + lending_aave_v3_compatible_flashloans( + blockchain = 'ethereum', + project = 'aave_etherfi', + version = '3', + project_decoded_as = 'aave_v3_etherfi', + decoded_contract_name = 'PoolInstance' + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/_schema.yml index 43581f67717..933ab8dfeb2 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/_schema.yml @@ -239,6 +239,44 @@ models: - *tx_hash - *evt_index + - name: aave_etherfi_v3_ethereum_base_supply + meta: + blockchain: ethereum + sector: lending + project: aave_etherfi + contributors: tomfutago + config: + tags: ['lending', 'supply', 'aave', 'etherfi', 'ethereum'] + description: "Aave v3 supply transactions on Ethereum" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - transaction_type + - token_address + - tx_hash + - evt_index + - check_lending_base_supply_seed: + seed_file: ref('aave_etherfi_ethereum_base_supply_seed') + filter: + version: 3 + columns: + - *blockchain + - *project + - *version + - *transaction_type + - *token_address + - *depositor + - *on_behalf_of + - *withdrawn_to + - *liquidator + - *amount + - *block_month + - *block_time + - *block_number + - *project_contract_address + - *tx_hash + - *evt_index + - name: compound_v2_ethereum_base_supply meta: blockchain: ethereum diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/lending_ethereum_base_supply.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/lending_ethereum_base_supply.sql index fb90b03ccf6..6e4dda2fdbe 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/lending_ethereum_base_supply.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/lending_ethereum_base_supply.sql @@ -12,6 +12,7 @@ ref('aave_v2_ethereum_base_supply'), ref('aave_v3_ethereum_base_supply'), ref('aave_lido_v3_ethereum_base_supply'), + ref('aave_etherfi_v3_ethereum_base_supply'), ref('compound_v2_ethereum_base_supply'), ref('compound_v3_ethereum_base_supply'), ref('radiant_ethereum_base_supply'), diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/platforms/aave_etherfi_v3_ethereum_base_supply.sql b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/platforms/aave_etherfi_v3_ethereum_base_supply.sql new file mode 100644 index 00000000000..a5d6fddeb74 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_sector/lending/supply/ethereum/platforms/aave_etherfi_v3_ethereum_base_supply.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'aave_etherfi_v3_ethereum', + alias = 'base_supply', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transaction_type', 'token_address', 'tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + lending_aave_v3_compatible_supply( + blockchain = 'ethereum', + project = 'aave_etherfi', + version = '3', + project_decoded_as = 'aave_v3_etherfi', + decoded_contract_name = 'PoolInstance' + ) +}} diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/_schema.yml b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/_schema.yml index 51c103b4d09..f434216529b 100644 --- a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/_schema.yml @@ -70,6 +70,20 @@ seeds: token_address: varbinary borrower: varbinary amount: double + - name: aave_etherfi_ethereum_base_borrow_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + block_number: bigint + block_time: timestamp + tx_hash: varbinary + evt_index: bigint + transaction_type: varchar + token_address: varbinary + borrower: varbinary + amount: double - name: aave_fantom_base_borrow_seed config: column_types: @@ -225,6 +239,20 @@ seeds: token_address: varbinary depositor: varbinary amount: double + - name: aave_etherfi_ethereum_base_supply_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + block_number: bigint + block_time: timestamp + tx_hash: varbinary + evt_index: bigint + transaction_type: varchar + token_address: varbinary + depositor: varbinary + amount: double - name: aave_fantom_base_supply_seed config: column_types: @@ -375,6 +403,19 @@ seeds: token_address: varbinary recipient: varbinary amount: double + - name: aave_etherfi_ethereum_base_flashloans_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + block_number: bigint + block_time: timestamp + tx_hash: varbinary + evt_index: bigint + token_address: varbinary + recipient: varbinary + amount: double - name: aave_fantom_base_flashloans_seed config: column_types: diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_borrow_seed.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_borrow_seed.csv new file mode 100644 index 00000000000..964b6ac37ec --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_borrow_seed.csv @@ -0,0 +1,3 @@ +blockchain,project,version,block_number,block_time,tx_hash,evt_index,transaction_type,token_address,borrower,amount +ethereum,aave_etherfi,3,20752989,2024-09-15 02:20:35.000 UTC,0x7098f5b98b041d290f2b28afb22a0334d5274e229d4465e150be7ce4df10826a,242,borrow,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0x9dbc5e35a2f1a6dc214bdb7ed7a8c706d77f0a74,1e+10 +ethereum,aave_etherfi,3,20728281,2024-09-11 15:31:35.000 UTC,0x6180393887262f626d967ba8a32a10ce8bd860a39dd1423ed2fc592d16e63aff,299,repay,0x853d955acef822db058eb8505911ed77f175b99e,0xedf1086b81f979354fc2ea07260eb83f5852eb15,-1.84e+20 diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_flashloans_seed.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_flashloans_seed.csv new file mode 100644 index 00000000000..7a805e33930 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_flashloans_seed.csv @@ -0,0 +1 @@ +blockchain,project,version,block_number,block_time,tx_hash,evt_index,token_address,recipient,amount diff --git a/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_supply_seed.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_supply_seed.csv new file mode 100644 index 00000000000..20e0d45a424 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/lending/aave_etherfi_ethereum_base_supply_seed.csv @@ -0,0 +1,3 @@ +blockchain,project,version,block_number,block_time,tx_hash,evt_index,transaction_type,token_address,depositor,amount +ethereum,aave_etherfi,3,20752986,2024-09-15 02:19:59.000 UTC,0x65e3cb2d48b81de680b62714f663e144e9ee04927f9321c810f40602b329238c,202,deposit,0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee,0x9dbc5e35a2f1a6dc214bdb7ed7a8c706d77f0a74,9.54280867878683e+18 +ethereum,aave_etherfi,3,20740462,2024-09-13 08:20:23.000 UTC,0xab48c34bc87037ef9780b365dcb25d9800a6b3a847f1148d9b3dbd4c5f92b475,152,withdraw,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0x829bfb482331b9dc2becb5483eca79c0578c3a45,-1.63586567e+08 diff --git a/sources/_sector/lending/borrow/ethereum/_sources.yml b/sources/_sector/lending/borrow/ethereum/_sources.yml index 49a6dba0ef4..6eb32dd9418 100644 --- a/sources/_sector/lending/borrow/ethereum/_sources.yml +++ b/sources/_sector/lending/borrow/ethereum/_sources.yml @@ -22,6 +22,12 @@ sources: - name: LidoPool_evt_Repay - name: LidoPool_evt_LiquidationCall + - name: aave_v3_etherfi_ethereum + tables: + - name: PoolInstance_evt_Borrow + - name: PoolInstance_evt_Repay + - name: PoolInstance_evt_LiquidationCall + - name: compound_v1_ethereum tables: - name: MoneyMarket_evt_BorrowTaken diff --git a/sources/_sector/lending/flashloans/ethereum/_sources.yml b/sources/_sector/lending/flashloans/ethereum/_sources.yml index 0eddafb8db7..1b7f38ab725 100644 --- a/sources/_sector/lending/flashloans/ethereum/_sources.yml +++ b/sources/_sector/lending/flashloans/ethereum/_sources.yml @@ -14,6 +14,10 @@ sources: - name: Pool_evt_FlashLoan - name: LidoPool_evt_FlashLoan + - name: aave_v3_etherfi_ethereum + tables: + - name: PoolInstance_evt_FlashLoan + - name: radiant_capital_ethereum tables: - name: LendingPool_evt_FlashLoan diff --git a/sources/_sector/lending/supply/ethereum/_sources.yml b/sources/_sector/lending/supply/ethereum/_sources.yml index 93ca679c0fc..bc4108ff420 100644 --- a/sources/_sector/lending/supply/ethereum/_sources.yml +++ b/sources/_sector/lending/supply/ethereum/_sources.yml @@ -21,6 +21,12 @@ sources: - name: LidoPool_evt_Withdraw - name: LidoPool_evt_ReserveDataUpdated + - name: aave_v3_etherfi_ethereum + tables: + - name: PoolInstance_evt_Supply + - name: PoolInstance_evt_Withdraw + - name: PoolInstance_evt_ReserveDataUpdated + - name: compound_v2_ethereum tables: - name: cErc20_evt_Mint From 7ec6158b4acee9a88c39036b0da3987d24804117 Mon Sep 17 00:00:00 2001 From: hildobby Date: Wed, 18 Sep 2024 17:55:49 +0200 Subject: [PATCH 033/127] add new contracts from kiln and rocket pool (#6615) --- .../ethereum/entities/staking_ethereum_entities_contracts.sql | 1 + .../entities/staking_ethereum_entities_depositor_addresses.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_contracts.sql b/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_contracts.sql index da6fbb31e3d..599094462c9 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_contracts.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_contracts.sql @@ -15,6 +15,7 @@ WITH contracts AS ( (0xdcd51fc5cd918e0461b9b7fb75967fdfd10dae2f, 'Rocket Pool', 'Liquid Staking') , (0x1cc9cf5586522c6f483e84a19c3c2b0b6d027bf0, 'Rocket Pool', 'Liquid Staking') , (0x2fb42ffe2d7df8381853e96304300c6a5e846905, 'Rocket Pool', 'Liquid Staking') + , (0x9304b4ebfbe68932cf9af8de4d21d7e7621f701a, 'Rocket Pool', 'Liquid Staking') --, (0x9b8c989ff27e948f55b53bb19b3cc1947852e394, 'Kiln', 'Staking Pool') -- Kiln doesn't custody or manage any validators, hence the removal --, (0x1e68238ce926dec62b3fbc99ab06eb1d85ce0270, 'Kiln', 'Staking Pool') , (0x2421a0af8badfae12e1c1700e369747d3db47b09, 'SenseiNode', 'Staking Pool') diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_depositor_addresses.sql b/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_depositor_addresses.sql index dc9f6d245ed..4d57d43f058 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_depositor_addresses.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_depositor_addresses.sql @@ -31,6 +31,7 @@ FROM , (0x746d8a8fcab7f829fa500504f60d89c5cc1ea973, 'Kiln', 'Kiln 5', 'Staking Pool') , (0x0816df553a89c4bff7ebfd778a9706a989dd3ce3, 'Kiln', 'Kiln 6', 'Staking Pool') , (0xef650d5dbe75f39e2ec18a4381f75c8a4d4e19c8, 'Kiln', 'Kiln 7', 'Staking Pool') + , (0x576834cb068e677db4aff6ca245c7bde16c3867e, 'Kiln', 'Kiln 8', 'Staking Pool') , (0xbf1556a7d625654e3d64d1f0466a60a697fac178, 'imToken', 'imToken Staking[NodeProviderInfStones]', 'Staking Pool') , (0xbca3b7b87dcb15f0efa66136bc0e4684a3e5da4d, 'SharedStake', 'SharedStake', 'Liquid Staking') , (0xeadcba8bf9aca93f627f31fb05470f5a0686ceca, 'StakeWise', 'StakeWise Solos', 'Staking Pool') From c6ca462630c9872f7b70a4e9b0cd5e8e2b50f7d2 Mon Sep 17 00:00:00 2001 From: catherine-2 <95732099+catherine-2@users.noreply.github.com> Date: Wed, 18 Sep 2024 08:56:04 -0700 Subject: [PATCH 034/127] new drop added (#6702) --- .../metadata/nft_ethereum_metadata_xcopy_collections.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/nft/models/nft_metrics/ethereum/metadata/nft_ethereum_metadata_xcopy_collections.sql b/dbt_subprojects/nft/models/nft_metrics/ethereum/metadata/nft_ethereum_metadata_xcopy_collections.sql index a4d97fa5dd9..185eda4b8f2 100644 --- a/dbt_subprojects/nft/models/nft_metrics/ethereum/metadata/nft_ethereum_metadata_xcopy_collections.sql +++ b/dbt_subprojects/nft/models/nft_metrics/ethereum/metadata/nft_ethereum_metadata_xcopy_collections.sql @@ -18,7 +18,8 @@ from ( select title, art_type, platform, edition_count, blockchain, token_standard, contract_address, min_token_id, max_token_id, category, link, mint_date from (VALUES - ('SH_MASH_MA', 'Edition', 'Manifold', 250, 'Ethereum', 'erc1155', 0x3e34ff1790bf0a13efd7d77e75870cb525687338, 7, 7, 'DAMAGE CONTROL', 'https://opensea.io/assets/ethereum/0x3e34ff1790bf0a13efd7d77e75870cb525687338/7','2024-07-25') + ('BOT_ROT', 'Edition', 'Manifold', 250, 'Ethereum', 'erc1155', 0x3e34ff1790bf0a13efd7d77e75870cb525687338, 8, 8, 'DAMAGE CONTROL', 'https://opensea.io/assets/ethereum/0x3e34ff1790bf0a13efd7d77e75870cb525687338/8','2024-09-11') + , ('SH_MASH_MA', 'Edition', 'Manifold', 250, 'Ethereum', 'erc1155', 0x3e34ff1790bf0a13efd7d77e75870cb525687338, 7, 7, 'DAMAGE CONTROL', 'https://opensea.io/assets/ethereum/0x3e34ff1790bf0a13efd7d77e75870cb525687338/7','2024-07-25') , ('XOMBO', 'Edition', 'Manifold', 500, 'Ethereum', 'erc1155', 0x3e34ff1790bf0a13efd7d77e75870cb525687338, 6, 6, 'DAMAGE CONTROL', 'https://opensea.io/assets/ethereum/0x3e34ff1790bf0a13efd7d77e75870cb525687338/6','2024-07-25') , ('CRAWLER', 'Edition', 'Manifold', 500, 'Ethereum', 'erc1155', 0x3e34ff1790bf0a13efd7d77e75870cb525687338, 5, 5, 'DAMAGE CONTROL', 'https://opensea.io/assets/ethereum/0x3e34ff1790bf0a13efd7d77e75870cb525687338/5','2024-02-11') , ('CHURN', 'Edition', 'Manifold', 250, 'Ethereum', 'erc1155', 0x3e34ff1790bf0a13efd7d77e75870cb525687338, 4, 4, 'DAMAGE CONTROL', 'https://opensea.io/assets/ethereum/0x3e34ff1790bf0a13efd7d77e75870cb525687338/4','2024-01-15') From 14f66b1412b38c3fb7871fab992b5d198bcf9e00 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Wed, 18 Sep 2024 12:57:09 -0300 Subject: [PATCH 035/127] Update labels_balancer_v2_pools_polygon.sql (#6744) --- .../labels/polygon/labels_balancer_v2_pools_polygon.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/polygon/labels_balancer_v2_pools_polygon.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/polygon/labels_balancer_v2_pools_polygon.sql index 11f9af6d31e..3a396d3c880 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/polygon/labels_balancer_v2_pools_polygon.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/polygon/labels_balancer_v2_pools_polygon.sql @@ -246,7 +246,7 @@ WITH pools AS ( 0 AS normalized_weight, cc._name, 'FX' AS pool_type - FROM {{ source('xavefinance_avalanche_c', 'FXPoolFactory_call_newFXPool') }} cc + FROM {{ source('xavefinance_polygon', 'FXPoolFactory_call_newFXPool') }} cc CROSS JOIN UNNEST(_assetsToRegister) AS t (token) WHERE call_success ), From ff9c483098ee81a3b0075418e5bfce1385e9dcbd Mon Sep 17 00:00:00 2001 From: chef-seaweed <121569855+chef-seaweed@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:57:19 +0800 Subject: [PATCH 036/127] Add PancakeSwap Stableswap on Ethereum to Dex Trades (#6738) * Add PCS Stableswap on Ethereum * Update pancakeswap_v2_ethereum_base_trades.sql --- .../pancakeswap_v2_ethereum_base_trades.sql | 76 +++++++++++++++---- .../pancakeswap_ethereum_base_trades_seed.csv | 3 + .../_sector/dex/trades/ethereum/_sources.yml | 2 + 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/dbt_subprojects/dex/models/trades/ethereum/platforms/pancakeswap_v2_ethereum_base_trades.sql b/dbt_subprojects/dex/models/trades/ethereum/platforms/pancakeswap_v2_ethereum_base_trades.sql index dbd16edafe3..7ab786f47ad 100644 --- a/dbt_subprojects/dex/models/trades/ethereum/platforms/pancakeswap_v2_ethereum_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/ethereum/platforms/pancakeswap_v2_ethereum_base_trades.sql @@ -25,7 +25,7 @@ dexs_macro AS ( }} ), -dexs AS ( +dexs_mm AS ( -- PancakeSwap v2 MMPool SELECT 'mmpool' AS version, @@ -46,8 +46,33 @@ dexs AS ( {% if is_incremental() %} WHERE {{ incremental_predicate('t.evt_block_time') }} {% endif %} +), + +dexs_ss AS ( + -- PancakeSwap v2 stableswap + SELECT + 'stableswap' AS version, + t.evt_block_number AS block_number, + t.evt_block_time AS block_time, + t.buyer AS taker, + CAST(NULL AS VARBINARY) AS maker, + tokens_bought AS token_bought_amount_raw, + tokens_sold AS token_sold_amount_raw, + CASE WHEN bought_id = UINT256 '0' THEN f.tokenA ELSE f.tokenB END AS token_bought_address, + CASE WHEN bought_id = UINT256 '0' THEN f.tokenB ELSE f.tokenA END AS token_sold_address, + t.contract_address AS project_contract_address, + t.evt_tx_hash AS tx_hash, + t.evt_index + FROM {{ source('pancakeswap_v2_ethereum', 'PancakeStableSwapTwoPool_evt_TokenExchange') }} t + INNER JOIN {{ source('pancakeswap_v2_ethereum', 'PancakeStableSwapFactory_evt_NewStableSwapPair') }} f + ON t.contract_address = f.swapContract + {% if is_incremental() %} + WHERE {{ incremental_predicate('t.evt_block_time') }} + {% endif %} ) + + SELECT dexs_macro.blockchain, dexs_macro.project, @@ -70,18 +95,37 @@ UNION ALL SELECT 'ethereum' AS blockchain, 'pancakeswap' AS project, - dexs.version, - CAST(date_trunc('month', dexs.block_time) AS date) AS block_month, - CAST(date_trunc('day', dexs.block_time) AS date) AS block_date, - dexs.block_time, - dexs.block_number, - dexs.token_bought_amount_raw, - dexs.token_sold_amount_raw, - dexs.token_bought_address, - dexs.token_sold_address, - dexs.taker, - dexs.maker, - dexs.project_contract_address, - dexs.tx_hash, - dexs.evt_index -FROM dexs + dexs_mm.version, + CAST(date_trunc('month', dexs_mm.block_time) AS date) AS block_month, + CAST(date_trunc('day', dexs_mm.block_time) AS date) AS block_date, + dexs_mm.block_time, + dexs_mm.block_number, + dexs_mm.token_bought_amount_raw, + dexs_mm.token_sold_amount_raw, + dexs_mm.token_bought_address, + dexs_mm.token_sold_address, + dexs_mm.taker, + dexs_mm.maker, + dexs_mm.project_contract_address, + dexs_mm.tx_hash, + dexs_mm.evt_index +FROM dexs_mm +UNION ALL +SELECT + 'ethereum' AS blockchain, + 'pancakeswap' AS project, + dexs_ss.version, + CAST(date_trunc('month', dexs_ss.block_time) AS date) AS block_month, + CAST(date_trunc('day', dexs_ss.block_time) AS date) AS block_date, + dexs_ss.block_time, + dexs_ss.block_number, + dexs_ss.token_bought_amount_raw, + dexs_ss.token_sold_amount_raw, + dexs_ss.token_bought_address, + dexs_ss.token_sold_address, + dexs_ss.taker, + dexs_ss.maker, + dexs_ss.project_contract_address, + dexs_ss.tx_hash, + dexs_ss.evt_index +FROM dexs_ss diff --git a/dbt_subprojects/dex/seeds/trades/pancakeswap_ethereum_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/pancakeswap_ethereum_base_trades_seed.csv index f46618aa238..ecdeabecc12 100644 --- a/dbt_subprojects/dex/seeds/trades/pancakeswap_ethereum_base_trades_seed.csv +++ b/dbt_subprojects/dex/seeds/trades/pancakeswap_ethereum_base_trades_seed.csv @@ -11,3 +11,6 @@ ethereum,pancakeswap,mmpool,2023-03-09,0xe8fceccb966aa76d8b847f0b067f987b2333136 ethereum,pancakeswap,mmpool,2023-03-09,0x06e1b3740c4a4d8fa60f7ddf6defb706f1ec64c563b697f0695647921b2b8c89,288,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,16787094,1535457365,1000000000000000000 ethereum,pancakeswap,3,2023-04-02,0x3a0097fcc23266394c9ec6e5cf1dd667e60717b1f92fbc76a5e5e2aa50a430ba,84,0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2,0xdac17f958d2ee523a2206206994597c13d831ec7,16959182,1637811712507004,3000000 ethereum,pancakeswap,3,2023-04-01,0x942d7e8064aa1925e484ad9e38b25b0eea8620aa2b85a42a47b957bcdc5df18b,175,0xdac17f958d2ee523a2206206994597c13d831ec7,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,16955398,980006,1000000 +ethereum,pancakeswap,stableswap,2024-09-03 00:00:00.000 UTC,0x76706147bb031c1dff5386142d866ec083578420885fb24160124a66800ef418,299,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,20668595,9967437,10000000 +ethereum,pancakeswap,stableswap,2024-09-04 00:00:00.000 UTC,0x6639947fd9c9d5e07425f2500f3f50b13bb7b4bd92316d5392866e759aa7e97c,74,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,20680551,1251896,1177998 +ethereum,pancakeswap,stableswap,2024-09-08 00:00:00.000 UTC,0x7e07e90e2230148bd1a5c49ccaa94a36408dc3df2f39c923c6c49b154d6c7ba4,72,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,20704016,13399197,13511099 diff --git a/sources/_sector/dex/trades/ethereum/_sources.yml b/sources/_sector/dex/trades/ethereum/_sources.yml index b92f4ff7857..f9cad75320b 100644 --- a/sources/_sector/dex/trades/ethereum/_sources.yml +++ b/sources/_sector/dex/trades/ethereum/_sources.yml @@ -28,6 +28,8 @@ sources: - name: PancakePair_evt_Swap - name: PancakeFactory_evt_PairCreated - name: PancakeSwapMMPool_evt_Swap + - name: PancakeStableSwapTwoPool_evt_TokenExchange + - name: PancakeStableSwapFactory_evt_NewStableSwapPair - name: pancakeswap_v3_ethereum tables: - name: PancakeV3Pool_evt_Swap From 82ac2367ff709d824b4e15461a2bd754bfa89ea8 Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 08:57:30 -0700 Subject: [PATCH 037/127] zeroex - add linea [new model] (#6684) * add linea * update token list * add log filter * only last maker row * fix schema filetype * token list * change rn order * remove bad join condition * 0x-API * udpate valid_logs selection/cte --- .../zeroex/linea/zeroex_linea_schema.yml | 111 +++++++ .../linea/zeroex_linea_settler_trades.sql | 286 ++++++++++++++++++ .../seeds/_project/zeroex/linea/_schema.yml | 11 + .../zeroex_linea_settler_trades_sample.csv | 2 + 4 files changed, 410 insertions(+) create mode 100644 dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_schema.yml create mode 100644 dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_settler_trades.sql create mode 100644 dbt_subprojects/dex/seeds/_project/zeroex/linea/_schema.yml create mode 100644 dbt_subprojects/dex/seeds/_project/zeroex/linea/zeroex_linea_settler_trades_sample.csv diff --git a/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_schema.yml b/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_schema.yml new file mode 100644 index 00000000000..5a04d65f2c3 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_schema.yml @@ -0,0 +1,111 @@ +version: 2 + +models: + - name: zeroex_linea_settler_trades + meta: + blockchain: linea + project: zeroex + contributors: rantum + config: + tags: ['linea','0x','dex_aggregator','dex','aggregator'] + description: > + 0x API erc20 trades through 0x Settler contracts. No fills, only deduped transactions. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_month + - block_date + - tx_hash + - evt_index + - check_seed: + seed_file: ref('zeroex_linea_settler_trades_sample') + match_columns: + - tx_hash + check_columns: + - taker + - maker_token + - taker_token + columns: + - &blockchain + name: blockchain + description: "Blockchain which the aggregator project is deployed" + - &block_date + name: block_date + description: "UTC event block date of each trade" + - &block_month + name: block_month + description: "UTC event block month of each trade" + - &block_time + name: block_time + description: "UTC event block time of each trade" + - &taker_symbol + name: taker_symbol + description: "Symbol of the token taker sells" + - &maker_symbol + name: maker_symbol + description: "Symbol of the token taker buys" + - &token_pair + name: token_pair + description: "Token pair traded" + - &taker_token_amount + name: taker_token_amount + description: "The after-decimal amount of the token taker sells" + - &taker_token_amount_raw + name: taker_token_amount_raw + description: "The raw amount of the token taker sells" + - &maker_token_amount + name: maker_token_amount + description: "The after-decimal amount of the token taker buys" + - &maker_token_amount_raw + name: maker_token_amount_raw + description: "The raw amount of the token taker buys" + - &volume_usd + name: volume_usd + description: "Trading volume measured in USD value" + - &taker_token + name: taker_token + description: "Contract address of the token taker sells" + - &maker_token + name: maker_token + description: "Contract address of the token taker buys" + - &maker + name: maker + description: "buyer of the trade" + - &taker + name: taker + description: "seller of the trade" + - &affiliate_address + name: affiliate_address + description: "The recipient address of the affiliate, or the applications that is using 0x API, for receiving affiliate fee" + - &tx_hash + name: tx_hash + description: "Transaction hash of the fill" + - &tx_from + name: tx_from + description: "Address which initiated the trade" + - &tx_to + name: tx_to + description: "Address which received the trade" + - &evt_index + name: evt_index + description: "Index of the corresponding order filled event" + - &type + name: type + description: "The liquidity route the order went thru" + - &swap_flag + name: swap_flag + description: "If the swap was filled/consumed thru 0x API" + - &contract_address + name: contract_address + desctiption: "The address of the contract which fired the fill/swap event" + - &fills_within + name: fills_within + description: "fills in then multihop, if present" + + + + + + + + \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_settler_trades.sql new file mode 100644 index 00000000000..955d3c96787 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_settler_trades.sql @@ -0,0 +1,286 @@ +{{ config( + schema = 'zeroex_linea', + alias = 'settler_trades', + materialized='incremental', + partition_by = ['block_month'], + unique_key = ['block_month', 'block_date', 'tx_hash', 'evt_index'], + on_schema_change='sync_all_columns', + file_format ='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] +)}} + +{% set zeroex_settler_start_date = '2024-07-15' %} + +WITH tbl_addresses AS ( + SELECT + blockchain, + token_id, + to AS settler_address, + block_time AS begin_block_time, + block_number AS begin_block_number + FROM + {{ source('nft', 'transfers') }} + WHERE + contract_address = 0x00000000000004533fe15556b1e086bb1a72ceae + AND blockchain = 'linea' + and block_time > TIMESTAMP '2024-05-23' +), + +tbl_end_times AS ( + SELECT + *, + LEAD(begin_block_time) OVER (PARTITION BY blockchain, token_id ORDER BY begin_block_time) AS end_block_time, + LEAD(begin_block_number) OVER (PARTITION BY blockchain, token_id ORDER BY begin_block_number) AS end_block_number + FROM + tbl_addresses +), + +result_0x_settler_addresses AS ( + SELECT + * + FROM + tbl_end_times + WHERE + settler_address != 0x0000000000000000000000000000000000000000 +), + +settler_txs AS ( + SELECT + tx_hash, + block_time, + block_number, + method_id, + contract_address, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, + CASE + WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) + WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) + END AS tag + FROM ( + SELECT + tr.tx_hash, + block_number, + block_time, + "to" AS contract_address, + varbinary_substring(input,1,4) AS method_id, + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address + FROM + {{ source('linea', 'traces') }} AS tr + JOIN + result_0x_settler_addresses a ON a.settler_address = tr.to AND a.blockchain = 'linea' AND tr.block_time > a.begin_block_time + WHERE + (a.settler_address IS NOT NULL OR tr.to = 0xca11bde05977b3631167028862be2a173976ca11) + AND varbinary_substring(input,1,4) IN (0x1fff991f, 0xfd3ad6d4) + {% if is_incremental() %} + AND {{ incremental_predicate('block_time') }} + {% else %} + AND block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + GROUP BY + 1,2,3,4,5,6 +), +tbl_trades as ( + +with tbl_all_logs AS ( + SELECT + logs.tx_hash, + logs.block_time, + logs.block_number, + index, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, + method_id, + tag, + st.settler_address, + zid, + st.settler_address as contract_address + FROM + {{ source('linea', 'logs') }} AS logs + JOIN + settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + + WHERE + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 + {% if is_incremental() %} + AND {{ incremental_predicate('logs.block_time') }} + {% else %} + AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by index desc) rn + from tbl_all_logs + where maker_token != taker_token + ) + select * from tbl_valid_logs + where rn = 1 +), + + +tokens AS ( + SELECT DISTINCT + te.* + FROM + {{ source('tokens', 'erc20') }} AS te + JOIN + tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token + WHERE + te.blockchain = 'linea' +), + +prices AS ( + SELECT DISTINCT + pu.* + FROM + {{ source('prices', 'usd') }} AS pu + JOIN + tbl_trades ON (pu.contract_address = taker_token OR pu.contract_address = maker_token) AND date_trunc('minute',block_time) = minute + WHERE + pu.blockchain = 'linea' + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= DATE '{{zeroex_settler_start_date}}' + {% endif %} +), + +fills as ( + with signatures as ( + select distinct signature + from {{ source('linea', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SelllineaToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('linea', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + +results AS ( + SELECT + trades.block_time, + trades.block_number, + zid, + trades.contract_address, + method_id, + trades.tx_hash, + "from" AS tx_from, + "to" AS tx_to, + trades.index AS tx_index, + taker , + CAST(NULL AS varbinary) AS maker, + taker_token, + pt.price, + COALESCE(tt.symbol, pt.symbol) AS taker_symbol, + taker_amount AS taker_token_amount_raw, + taker_amount / POW(10,COALESCE(tt.decimals,pt.decimals)) AS taker_token_amount, + taker_amount / POW(10,COALESCE(tt.decimals,pt.decimals)) * pt.price AS taker_amount, + maker_token, + COALESCE(tm.symbol, pm.symbol) AS maker_symbol, + maker_amount AS maker_token_amount_raw, + maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, + maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, + tag, + fills_within + FROM + tbl_trades trades + JOIN + {{ source('linea', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number + LEFT JOIN + tokens tt ON tt.blockchain = 'linea' AND tt.contract_address = taker_token + LEFT JOIN + tokens tm ON tm.blockchain = 'linea' AND tm.contract_address = maker_token + LEFT JOIN + prices pt ON pt.blockchain = 'linea' AND pt.contract_address = taker_token AND pt.minute = DATE_TRUNC('minute', trades.block_time) + LEFT JOIN + prices pm ON pm.blockchain = 'linea' AND pm.contract_address = maker_token AND pm.minute = DATE_TRUNC('minute', trades.block_time) + WHERE + 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('tr.block_time') }} + {% else %} + AND tr.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} +), + +results_usd AS ( + SELECT + 'linea' AS blockchain, + '0x-API' AS project, + 'settler' AS version, + DATE_TRUNC('day', block_time) block_date, + DATE_TRUNC('month', block_time) AS block_month, + block_time, + taker_symbol, + maker_symbol, + CASE WHEN LOWER(taker_symbol) > LOWER(maker_symbol) THEN CONCAT(maker_symbol, '-', taker_symbol) ELSE CONCAT(taker_symbol, '-', maker_symbol) END AS token_pair, + taker_token_amount, + maker_token_amount, + taker_token_amount_raw, + maker_token_amount_raw, + CASE WHEN maker_token IN (0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f, + 0x176211869ca2b568f2a7d4ee941e073a821ee1ff, + 0xa219439258ca9da29e9cc4ce5596924745e12b93, + 0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4 ) AND maker_amount IS NOT NULL + THEN maker_amount + WHEN taker_token IN (0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f, + 0x176211869ca2b568f2a7d4ee941e073a821ee1ff, + 0xa219439258ca9da29e9cc4ce5596924745e12b93, + 0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4 ) AND taker_amount IS NOT NULL + THEN taker_amount + ELSE COALESCE(maker_amount, taker_amount) + END AS volume_usd, + taker_token, + maker_token, + taker, + maker, + tag, + zid, + tx_hash, + tx_from, + tx_to, + tx_index AS evt_index, + (ARRAY[-1]) AS trace_address, + 'settler' AS type, + TRUE AS swap_flag, + fills_within, + contract_address + FROM + results +) + +SELECT DISTINCT + * +FROM + results_usd +ORDER BY + block_time DESC \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/_project/zeroex/linea/_schema.yml b/dbt_subprojects/dex/seeds/_project/zeroex/linea/_schema.yml new file mode 100644 index 00000000000..5d65da08e6b --- /dev/null +++ b/dbt_subprojects/dex/seeds/_project/zeroex/linea/_schema.yml @@ -0,0 +1,11 @@ +version: 2 + +seeds: + - name: zeroex_linea_settler_trades_sample + config: + column_types: + tx_hash: varbinary + taker: varbinary + taker_token: varbinary + maker_token: varbinary + taker_token_amount: double \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/_project/zeroex/linea/zeroex_linea_settler_trades_sample.csv b/dbt_subprojects/dex/seeds/_project/zeroex/linea/zeroex_linea_settler_trades_sample.csv new file mode 100644 index 00000000000..6760f03e395 --- /dev/null +++ b/dbt_subprojects/dex/seeds/_project/zeroex/linea/zeroex_linea_settler_trades_sample.csv @@ -0,0 +1,2 @@ +tx_hash,taker,taker_token,maker_token,taker_token_amount +0xfd32094a40aea663ed1662833709c1c3590989607abf99e70a18f5740c8fd043,0x4ea754349ace5303c82f0d1d491041e042f2ad22,0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f,0xa219439258ca9da29e9cc4ce5596924745e12b93,0.000745504333903425 \ No newline at end of file From 18a46bde215b3c7f69587aec90556f306b296769 Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 08:57:41 -0700 Subject: [PATCH 038/127] zeroex settler - revise model [base] (#6659) * update maker token value selection * add filter * add settler_address * reorder settler field * new model * index * add incremental * new base model * remove bad join condition * remove fills_within cte * only last valid log * udpate vali_logs cte * fix cte * log selection update * maker_token != taker_token * rewrite tokens cte * fix source jinja syntax --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../base/zeroex_base_settler_trades.sql | 202 +++++++++--------- 1 file changed, 101 insertions(+), 101 deletions(-) diff --git a/dbt_subprojects/dex/models/_projects/zeroex/base/zeroex_base_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/base/zeroex_base_settler_trades.sql index 40ec20b612e..14e0c21d9f7 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/base/zeroex_base_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/base/zeroex_base_settler_trades.sql @@ -52,7 +52,8 @@ settler_txs AS ( block_number, method_id, contract_address, - MAX(varbinary_substring(tracker,1,12)) AS zid, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, CASE WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) @@ -64,7 +65,8 @@ settler_txs AS ( block_time, "to" AS contract_address, varbinary_substring(input,1,4) AS method_id, - varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address FROM {{ source('base', 'traces') }} AS tr JOIN @@ -79,88 +81,83 @@ settler_txs AS ( {% endif %} ) GROUP BY - 1,2,3,4,5 + 1,2,3,4,5,6 ), +tbl_trades as ( -tbl_all_logs AS ( +with tbl_all_logs AS ( SELECT logs.tx_hash, logs.block_time, logs.block_number, - ROW_NUMBER() OVER (PARTITION BY logs.tx_hash ORDER BY index) rn_first, - index, - CASE - WHEN varbinary_substring(logs.topic2, 13, 20) = logs.tx_from THEN 1 - WHEN varbinary_substring(logs.topic1, 13, 20) = st.contract_address THEN 0 - WHEN FIRST_VALUE(logs.contract_address) OVER (PARTITION BY logs.tx_hash ORDER BY index) = logs.contract_address THEN 0 - ELSE 1 - END maker_tkn, - bytearray_to_int256(bytearray_substring(DATA, 23,10)) value, - logs.contract_address AS token, - zid, - st.contract_address, + index, + case when ( (varbinary_substring(logs.topic2, 13, 20) = logs.tx_from) OR + (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or + topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) + then 1 end as valid, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, method_id, - tag + tag, + st.settler_address, + zid, + st.settler_address as contract_address FROM {{ source('base', 'logs') }} AS logs JOIN - settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + settler_txs st ON st.tx_hash = logs.tx_hash + AND logs.block_time = st.block_time + AND st.block_number = logs.block_number + AND ( (st.settler_address = bytearray_substring(logs.topic1,13,20)) + or (st.settler_address= bytearray_substring(logs.topic2,13,20)) + or logs.tx_from = bytearray_substring(logs.topic1,13,20) + or logs.tx_from = bytearray_substring(logs.topic2,13,20) + ) WHERE - topic0 IN (0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, - 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c) - and not(tag = 0x000000 and zid = 0xa00000000000000000000000) + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 {% if is_incremental() %} AND {{ incremental_predicate('logs.block_time') }} {% else %} AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' {% endif %} -), - -tbl_maker_token AS ( - SELECT - ROW_NUMBER() OVER (PARTITION BY tx_hash ORDER BY index DESC) rn_last, - token AS maker_token, - tx_hash, - block_time, - block_number, - index - FROM - tbl_all_logs - WHERE - maker_tkn = 1 -), - -tbl_trades AS ( - SELECT - ta.tx_hash, - ta.block_time, - ta.block_number, - zid, - method_id, - tag, - contract_address, - SUM(value) FILTER (WHERE rn_first = 1) AS taker_amount, - MAX(token) FILTER (WHERE rn_first = 1) AS taker_token, - SUM(value) FILTER (WHERE rn_last = 1) AS maker_amount, - MAX(maker_token) FILTER (WHERE rn_last = 1) AS maker_token - FROM - tbl_all_logs ta - LEFT JOIN - tbl_maker_token mkr ON ta.tx_hash = mkr.tx_hash AND ta.block_time = mkr.block_time AND ta.block_number = mkr.block_number AND ta.index = mkr.index AND mkr.rn_last = 1 - GROUP BY - 1,2,3,4,5,6,7 + ), + tbl_valid_logs as ( + select *, + row_number() over (partition by tx_hash order by valid, index) rn + from tbl_all_logs + where taker_token != maker_token + ) + select * from tbl_valid_logs where rn = 1 ), tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'base' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = '{{blockchain}}' ), prices AS ( @@ -178,7 +175,34 @@ prices AS ( AND minute >= DATE '{{zeroex_settler_start_date}}' {% endif %} ), - +/* +fills as ( + with signatures as ( + select distinct signature + from {{ source('base', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SellbaseToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('base', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), +*/ results AS ( SELECT trades.block_time, @@ -189,23 +213,8 @@ results AS ( trades.tx_hash, "from" AS tx_from, "to" AS tx_to, - index AS tx_index, - CASE - WHEN varbinary_substring(data,17,10) != 0x00000000000000000000 AND varbinary_substring(data,17,1) != 0x THEN varbinary_substring(data,17,20) - WHEN varbinary_substring(data,177,10) != 0x00000000000000000000 THEN varbinary_substring(data,177,20) - WHEN varbinary_substring(data,277,10) != 0x00000000000000000000 THEN varbinary_substring(data,277,20) - WHEN varbinary_substring(data,629,10) != 0x00000000000000000000 THEN varbinary_substring(data,629,20) - WHEN varbinary_substring(data,693,10) != 0x00000000000000000000 THEN varbinary_substring(data,693,20) - WHEN varbinary_substring(data,917,10) != 0x00000000000000000000 THEN varbinary_substring(data,917,20) - WHEN varbinary_substring(data,949,10) != 0x00000000000000000000 THEN varbinary_substring(data,949,20) - WHEN varbinary_substring(data,981,10) != 0x00000000000000000000 THEN varbinary_substring(data,981,20) - WHEN varbinary_substring(data,1013,10) != 0x00000000000000000000 THEN varbinary_substring(data,1013,20) - WHEN varbinary_substring(data,1141,10) != 0x00000000000000000000 THEN varbinary_substring(data,1141,20) - WHEN varbinary_substring(data,1273,10) != 0x00000000000000000000 THEN varbinary_substring(data,1273,20) - WHEN varbinary_substring(data,1749,4) != 0x00000000 THEN varbinary_substring(data,1749,20) - WHEN varbinary_substring(data,1049,4) != 0x00000000 THEN varbinary_substring(data,1049,20) - WHEN varbinary_substring(data,17,4) != 0x00000000 THEN varbinary_substring(data,17,20) - END AS taker , + trades.index AS tx_index, + taker , CAST(NULL AS varbinary) AS maker, taker_token, pt.price, @@ -219,16 +228,13 @@ results AS ( maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, tag, - data, - varbinary_substring(data, varbinary_length(data) - CASE - WHEN varbinary_position (data,0xc4103b48be) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xc4103b48be)) - WHEN varbinary_position (data,0xe48d68a156) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe48d68a156)) - WHEN varbinary_position (data,0xe422ce6ede) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe422ce6ede)) - END -3, 37) taker_indicator_string + -1 as fills_within FROM tbl_trades trades JOIN {{ source('base', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number +-- LEFT JOIN +-- fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number LEFT JOIN tokens tt ON tt.blockchain = 'base' AND tt.contract_address = taker_token LEFT JOIN @@ -261,13 +267,13 @@ results_usd AS ( maker_token_amount, taker_token_amount_raw, maker_token_amount_raw, - CASE WHEN maker_token IN (0x4200000000000000000000000000000000000006, + CASE WHEN maker_token IN (0x4200000000000000000000000000000000000006, 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, 0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca, 0x5d0af35b4f6f4715961b56168de93bf0062b173d, 0x50c5725949a6f0c72e6c4a641f24049a917db0cb) AND maker_amount IS NOT NULL THEN maker_amount - WHEN taker_token IN (0x4200000000000000000000000000000000000006, + WHEN taker_token IN (0x4200000000000000000000000000000000000006, 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, 0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca, 0x5d0af35b4f6f4715961b56168de93bf0062b173d, @@ -277,13 +283,7 @@ results_usd AS ( END AS volume_usd, taker_token, maker_token, - CASE WHEN (varbinary_substring(taker,1,4) = 0x00000000) - OR taker IS NULL - OR taker = taker_token - OR taker = contract_address - OR taker = 0xdef1c0ded9bec7f1a1670819833240f027b25eff - OR varbinary_substring(taker_indicator_string, 18,20) != contract_address - THEN varbinary_substring(taker_indicator_string, 18,20) ELSE taker END AS taker, + taker, maker, tag, zid, @@ -294,15 +294,15 @@ results_usd AS ( (ARRAY[-1]) AS trace_address, 'settler' AS type, TRUE AS swap_flag, - -1 AS fills_within, + fills_within, contract_address FROM results ) -SELECT DISTINCT +SELECT * FROM results_usd ORDER BY - block_time DESC \ No newline at end of file + block_time DESC From df9f6450084e9ee8128443bca7b32fb8f8f520fa Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 08:57:52 -0700 Subject: [PATCH 039/127] zeroex - add scroll model (#6682) * add scroll model & seed * fix dup in schema * fix schema file name * fix seed * add to all-chain model * add chain name to configs * correct takers * new settler model * add log filter * upate model for only last maker amount * commma * change rn order * 0x-API * remove bad join condition * correct taker * revise valid logs cte --------- Co-authored-by: Huang Geyang --- .../zeroex/scroll/zeroex_scroll_schema.yml | 111 +++++++ .../scroll/zeroex_scroll_settler_trades.sql | 285 ++++++++++++++++++ .../zeroex/zeroex_api_fills_deduped.sql | 3 +- .../models/_projects/zeroex/zeroex_schema.yml | 4 +- .../seeds/_project/zeroex/scroll/_schema.yml | 11 + .../zeroex_scroll_settler_trades_sample.csv | 2 + .../zeroex/zeroex_api_fills_sample.csv | 8 +- 7 files changed, 417 insertions(+), 7 deletions(-) create mode 100644 dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_schema.yml create mode 100644 dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_settler_trades.sql create mode 100644 dbt_subprojects/dex/seeds/_project/zeroex/scroll/_schema.yml create mode 100644 dbt_subprojects/dex/seeds/_project/zeroex/scroll/zeroex_scroll_settler_trades_sample.csv diff --git a/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_schema.yml b/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_schema.yml new file mode 100644 index 00000000000..c5cec51e487 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_schema.yml @@ -0,0 +1,111 @@ +version: 2 + +models: + - name: zeroex_scroll_settler_trades + meta: + blockchain: scroll + project: zeroex + contributors: rantum + config: + tags: ['scroll','0x','dex_aggregator','dex','aggregator'] + description: > + 0x API erc20 trades through 0x Settler contracts. No fills, only deduped transactions. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_month + - block_date + - tx_hash + - evt_index + - check_seed: + seed_file: ref('zeroex_scroll_settler_trades_sample') + match_columns: + - tx_hash + check_columns: + - taker + - maker_token + - taker_token + columns: + - &blockchain + name: blockchain + description: "Blockchain which the aggregator project is deployed" + - &block_date + name: block_date + description: "UTC event block date of each trade" + - &block_month + name: block_month + description: "UTC event block month of each trade" + - &block_time + name: block_time + description: "UTC event block time of each trade" + - &taker_symbol + name: taker_symbol + description: "Symbol of the token taker sells" + - &maker_symbol + name: maker_symbol + description: "Symbol of the token taker buys" + - &token_pair + name: token_pair + description: "Token pair traded" + - &taker_token_amount + name: taker_token_amount + description: "The after-decimal amount of the token taker sells" + - &taker_token_amount_raw + name: taker_token_amount_raw + description: "The raw amount of the token taker sells" + - &maker_token_amount + name: maker_token_amount + description: "The after-decimal amount of the token taker buys" + - &maker_token_amount_raw + name: maker_token_amount_raw + description: "The raw amount of the token taker buys" + - &volume_usd + name: volume_usd + description: "Trading volume measured in USD value" + - &taker_token + name: taker_token + description: "Contract address of the token taker sells" + - &maker_token + name: maker_token + description: "Contract address of the token taker buys" + - &maker + name: maker + description: "buyer of the trade" + - &taker + name: taker + description: "seller of the trade" + - &affiliate_address + name: affiliate_address + description: "The recipient address of the affiliate, or the applications that is using 0x API, for receiving affiliate fee" + - &tx_hash + name: tx_hash + description: "Transaction hash of the fill" + - &tx_from + name: tx_from + description: "Address which initiated the trade" + - &tx_to + name: tx_to + description: "Address which received the trade" + - &evt_index + name: evt_index + description: "Index of the corresponding order filled event" + - &type + name: type + description: "The liquidity route the order went thru" + - &swap_flag + name: swap_flag + description: "If the swap was filled/consumed thru 0x API" + - &contract_address + name: contract_address + desctiption: "The address of the contract which fired the fill/swap event" + - &fills_within + name: fills_within + description: "fills in then multihop, if present" + + + + + + + + \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_settler_trades.sql new file mode 100644 index 00000000000..38e069d1fcd --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_settler_trades.sql @@ -0,0 +1,285 @@ +{{ config( + schema = 'zeroex_scroll', + alias = 'settler_trades', + materialized='incremental', + partition_by = ['block_month'], + unique_key = ['block_month', 'block_date', 'tx_hash', 'evt_index'], + on_schema_change='sync_all_columns', + file_format ='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] +)}} + +{% set zeroex_settler_start_date = '2024-07-15' %} + +WITH tbl_addresses AS ( + SELECT + blockchain, + token_id, + to AS settler_address, + block_time AS begin_block_time, + block_number AS begin_block_number + FROM + {{ source('nft', 'transfers') }} + WHERE + contract_address = 0x00000000000004533fe15556b1e086bb1a72ceae + AND blockchain = 'scroll' + and block_time > TIMESTAMP '2024-05-23' +), + +tbl_end_times AS ( + SELECT + *, + LEAD(begin_block_time) OVER (PARTITION BY blockchain, token_id ORDER BY begin_block_time) AS end_block_time, + LEAD(begin_block_number) OVER (PARTITION BY blockchain, token_id ORDER BY begin_block_number) AS end_block_number + FROM + tbl_addresses +), + +result_0x_settler_addresses AS ( + SELECT + * + FROM + tbl_end_times + WHERE + settler_address != 0x0000000000000000000000000000000000000000 +), + +settler_txs AS ( + SELECT + tx_hash, + block_time, + block_number, + method_id, + contract_address, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, + CASE + WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) + WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) + END AS tag + FROM ( + SELECT + tr.tx_hash, + block_number, + block_time, + "to" AS contract_address, + varbinary_substring(input,1,4) AS method_id, + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address + FROM + {{ source('scroll', 'traces') }} AS tr + JOIN + result_0x_settler_addresses a ON a.settler_address = tr.to AND a.blockchain = 'scroll' AND tr.block_time > a.begin_block_time + WHERE + (a.settler_address IS NOT NULL OR tr.to = 0xca11bde05977b3631167028862be2a173976ca11) + AND varbinary_substring(input,1,4) IN (0x1fff991f, 0xfd3ad6d4) + {% if is_incremental() %} + AND {{ incremental_predicate('block_time') }} + {% else %} + AND block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + GROUP BY + 1,2,3,4,5,6 +), +tbl_trades as ( + +with tbl_all_logs AS ( + SELECT + logs.tx_hash, + logs.block_time, + logs.block_number, + index, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, + method_id, + tag, + st.settler_address, + zid, + st.settler_address as contract_address + FROM + {{ source('scroll', 'logs') }} AS logs + JOIN + settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + + WHERE + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 + {% if is_incremental() %} + AND {{ incremental_predicate('logs.block_time') }} + {% else %} + AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by index desc) rn + from tbl_all_logs + where taker_token != maker_token + ) + select * from tbl_valid_logs where rn = 1 +), + + +tokens AS ( + SELECT DISTINCT + te.* + FROM + {{ source('tokens', 'erc20') }} AS te + JOIN + tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token + WHERE + te.blockchain = 'scroll' +), + +prices AS ( + SELECT DISTINCT + pu.* + FROM + {{ source('prices', 'usd') }} AS pu + JOIN + tbl_trades ON (pu.contract_address = taker_token OR pu.contract_address = maker_token) AND date_trunc('minute',block_time) = minute + WHERE + pu.blockchain = 'scroll' + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= DATE '{{zeroex_settler_start_date}}' + {% endif %} +), + +fills as ( + with signatures as ( + select distinct signature + from {{ source('scroll', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SellscrollToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('scroll', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + +results AS ( + SELECT + trades.block_time, + trades.block_number, + zid, + trades.contract_address, + method_id, + trades.tx_hash, + "from" AS tx_from, + "to" AS tx_to, + trades.index AS tx_index, + taker , + CAST(NULL AS varbinary) AS maker, + taker_token, + pt.price, + COALESCE(tt.symbol, pt.symbol) AS taker_symbol, + taker_amount AS taker_token_amount_raw, + taker_amount / POW(10,COALESCE(tt.decimals,pt.decimals)) AS taker_token_amount, + taker_amount / POW(10,COALESCE(tt.decimals,pt.decimals)) * pt.price AS taker_amount, + maker_token, + COALESCE(tm.symbol, pm.symbol) AS maker_symbol, + maker_amount AS maker_token_amount_raw, + maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, + maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, + tag, + fills_within + FROM + tbl_trades trades + JOIN + {{ source('scroll', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number + LEFT JOIN + tokens tt ON tt.blockchain = 'scroll' AND tt.contract_address = taker_token + LEFT JOIN + tokens tm ON tm.blockchain = 'scroll' AND tm.contract_address = maker_token + LEFT JOIN + prices pt ON pt.blockchain = 'scroll' AND pt.contract_address = taker_token AND pt.minute = DATE_TRUNC('minute', trades.block_time) + LEFT JOIN + prices pm ON pm.blockchain = 'scroll' AND pm.contract_address = maker_token AND pm.minute = DATE_TRUNC('minute', trades.block_time) + WHERE + 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('tr.block_time') }} + {% else %} + AND tr.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} +), + +results_usd AS ( + SELECT + 'scroll' AS blockchain, + '0x-API' AS project, + 'settler' AS version, + DATE_TRUNC('day', block_time) block_date, + DATE_TRUNC('month', block_time) AS block_month, + block_time, + taker_symbol, + maker_symbol, + CASE WHEN LOWER(taker_symbol) > LOWER(maker_symbol) THEN CONCAT(maker_symbol, '-', taker_symbol) ELSE CONCAT(taker_symbol, '-', maker_symbol) END AS token_pair, + taker_token_amount, + maker_token_amount, + taker_token_amount_raw, + maker_token_amount_raw, + CASE WHEN maker_token IN (0x5300000000000000000000000000000000000004, + 0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4, + 0xf55bec9cafdbe8730f096aa55dad6d22d44099df, + 0xca77eb3fefe3725dc33bccb54edefc3d9f764f97) AND maker_amount IS NOT NULL + THEN maker_amount + WHEN taker_token IN (0x5300000000000000000000000000000000000004, + 0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4, + 0xf55bec9cafdbe8730f096aa55dad6d22d44099df, + 0xca77eb3fefe3725dc33bccb54edefc3d9f764f97) AND taker_amount IS NOT NULL + THEN taker_amount + ELSE COALESCE(maker_amount, taker_amount) + END AS volume_usd, + taker_token, + maker_token, + taker, + maker, + tag, + zid, + tx_hash, + tx_from, + tx_to, + tx_index AS evt_index, + (ARRAY[-1]) AS trace_address, + 'settler' AS type, + TRUE AS swap_flag, + fills_within, + contract_address + FROM + results +) + +SELECT DISTINCT + * +FROM + results_usd +ORDER BY + block_time DESC \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql index aa2858739c6..d52c1be0b8d 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql @@ -1,7 +1,7 @@ {{ config( schema = 'zeroex' , alias = 'api_fills_deduped' - , post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "base", "bnb", "celo", "ethereum", "fantom", "optimism", "polygon"]\', + , post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "base", "bnb", "celo", "ethereum", "fantom", "optimism", "polygon","scroll"]\', "project", "zeroex", \'["rantum","bakabhai993"]\') }}' @@ -29,6 +29,7 @@ ,ref('zeroex_bnb_settler_trades') ,ref('zeroex_avalanche_c_settler_trades') ,ref('zeroex_arbitrum_settler_trades') + ,ref('zeroex_scroll_settler_trades') ] %} diff --git a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml index 13fde7bc2fe..3ae3939eb6d 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml +++ b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml @@ -3,11 +3,11 @@ version: 2 models: - name: zeroex_api_fills meta: - blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb + blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb, scroll project: zeroex contributors: rantum, danning.sui, bakabhai993 config: - tags: ['ethereum','0x','dex_aggregator','dex','aggregator','optimism','polygon','arbitrum','fantom','avalanche','bnb'] + tags: ['ethereum','0x','dex_aggregator','dex','aggregator','optimism','polygon','arbitrum','fantom','avalanche','bnb','scroll'] description: > 0x API erc20 swaps raw fills (including multihops) and also native swaps thru 0x exchange contracts (without using 0x API) on Ethereum tests: diff --git a/dbt_subprojects/dex/seeds/_project/zeroex/scroll/_schema.yml b/dbt_subprojects/dex/seeds/_project/zeroex/scroll/_schema.yml new file mode 100644 index 00000000000..db87da2f1c3 --- /dev/null +++ b/dbt_subprojects/dex/seeds/_project/zeroex/scroll/_schema.yml @@ -0,0 +1,11 @@ +version: 2 + +seeds: + - name: zeroex_scroll_settler_trades_sample + config: + column_types: + tx_hash: varbinary + taker: varbinary + taker_token: varbinary + maker_token: varbinary + taker_token_amount: double \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/_project/zeroex/scroll/zeroex_scroll_settler_trades_sample.csv b/dbt_subprojects/dex/seeds/_project/zeroex/scroll/zeroex_scroll_settler_trades_sample.csv new file mode 100644 index 00000000000..f802430aa67 --- /dev/null +++ b/dbt_subprojects/dex/seeds/_project/zeroex/scroll/zeroex_scroll_settler_trades_sample.csv @@ -0,0 +1,2 @@ +tx_hash,taker,taker_token,maker_token,taker_token_amount +0xa12012ea857c8ae2ce43ee0da243389f6621d72ef1442443f7656ca2ec70aa0d,0x4ea754349ace5303c82f0d1d491041e042f2ad22,0x5300000000000000000000000000000000000004,0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4,0.000826625353833232 \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/_project/zeroex/zeroex_api_fills_sample.csv b/dbt_subprojects/dex/seeds/_project/zeroex/zeroex_api_fills_sample.csv index 50fe18c25dc..4cf5ee3f8b7 100644 --- a/dbt_subprojects/dex/seeds/_project/zeroex/zeroex_api_fills_sample.csv +++ b/dbt_subprojects/dex/seeds/_project/zeroex/zeroex_api_fills_sample.csv @@ -1,11 +1,11 @@ volume_usd,block_date,block_time,blockchain,evt_index,maker,taker,maker_symbol,token_pair,taker_token,taker_token_amount,taker_symbol,trace_address,tx_from,tx_hash,tx_to,maker_token,maker_token_amount,version,maker_token_amount_raw 10446.658948584456,2023-04-04,2023-04-04 20:36:35.000 UTC,ethereum,18,0x00000012556e6973776170563300000000000000,0xc6c7565644ea1893ad29182f7b6961aab7edfed0,DAI,DAI-WETH,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,,WETH,[],0xc6c7565644ea1893ad29182f7b6961aab7edfed0,0x222a3c1bfeb298fe4d70f56d635f8b750fa58395c86b699b08ef871dc8513e76,0xa88800cd213da5ae406ce248380802bd53b47647,0x307836623137353437346538393039346334346461393862393534656564656163343935323731643066,10445.844172738982,,10445844172738981554467 779.9870676321608,2023-04-04,2023-04-04 20:19:47.000 UTC,ethereum,68,0xbaec0e18c770993ffb1175fef493b5113cc6e32d,0xc2c5075f7ab3c7ec9137818321d141591fd64bbe,WETH,ILV-WETH,0x307837363766653965646339653064663938653037343534383437393039623565393539643763613065,13.264759162139244,ILV,[],0xc2c5075f7ab3c7ec9137818321d141591fd64bbe,0xa60ff895b5aaafa93ac7d2af68d0fec2651750a001db6f1d06a98302c9047003,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.41726604234366216,,4.1726604234366214E17 -779.9870676321608,2023-04-04,2023-04-04 20:19:47.000 UTC,ethereum,71,0xe3baa96ad46457d9e6cdd4e32abc11e2c124ec49,0xe66b31678d6c16e9ebf358268a790b763c133750,MATIC,MATIC-WETH,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.41726604234366216,WETH,[],0xc2c5075f7ab3c7ec9137818321d141591fd64bbe,0xa60ff895b5aaafa93ac7d2af68d0fec2651750a001db6f1d06a98302c9047003,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307837643161666137623731386662383933646233306133616263306366633630386161636665626230,,,6.83415110457315E20 -69.29769365372037,2023-04-04,2023-04-04 20:18:59.000 UTC,ethereum,47,0xc0d776e2223c9a2ad13433dab7ec08cb9c5e76ae,0xe66b31678d6c16e9ebf358268a790b763c133750,XEN,WETH-XEN,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.03707186384796305,WETH,[],0x52f64a96f9b9cfdd642148754fa2d37d3a902574,0x9b12676bc92f104a029c42f660e98501e621f4d1df5370ab0ae8847cfbd1ee87,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307830363435306465653766643266623865333930363134333462616263666330353539396136666238,2.028292203781448e+07,,2.028292203781448E25 +779.9870676321608,2023-04-04,2023-04-04 20:19:47.000 UTC,ethereum,71,0xe3baa96ad46457d9e6cdd4e32abc11e2c124ec49,0xc2c5075f7ab3c7ec9137818321d141591fd64bbe,MATIC,MATIC-WETH,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.41726604234366216,WETH,[],0xc2c5075f7ab3c7ec9137818321d141591fd64bbe,0xa60ff895b5aaafa93ac7d2af68d0fec2651750a001db6f1d06a98302c9047003,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307837643161666137623731386662383933646233306133616263306366633630386161636665626230,,,6.83415110457315E20 +69.29769365372037,2023-04-04,2023-04-04 20:18:59.000 UTC,ethereum,47,0xc0d776e2223c9a2ad13433dab7ec08cb9c5e76ae,0x52f64a96f9b9cfdd642148754fa2d37d3a902574,XEN,WETH-XEN,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.03707186384796305,WETH,[],0x52f64a96f9b9cfdd642148754fa2d37d3a902574,0x9b12676bc92f104a029c42f660e98501e621f4d1df5370ab0ae8847cfbd1ee87,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307830363435306465653766643266623865333930363134333462616263666330353539396136666238,2.028292203781448e+07,,2.028292203781448E25 29.62565417333819,2023-04-04,2023-04-04 20:18:46.000 UTC,polygon,319,0x000000024d657368537761700000000000000000,0x21f96887b77f0ef00a33b148965269fcd14f3f62,WMATIC,USDT-WMATIC,0xc2132d05d31c914a87c6611c10748aeb04b58e8f,,USDT,[],0x21f96887b77f0ef00a33b148965269fcd14f3f62,0x6cee7ce88c9d9f441bda4d751832b2e6cf5fbad1cd5e23a56430762b0383fff4,0x1a1ec25dc08e98e5e93f1104b5e5cdd298707d31,0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270,26.054563579943917,,2.6054563579943916E19 504.32666693752896,2023-04-04,2023-04-04 20:18:35.000 UTC,ethereum,70,0x1b425529c9d7472603e2dcf125fd195f71dfb412,0x980a76779950f2c7cc06478f3933754839eb0577,WETH,RINIA-WETH,0x307838663832386130363434663132666133353238383865363435613930333333643330663666643764,,RINIA,[],0x980a76779950f2c7cc06478f3933754839eb0577,0x9e77263bc7c05219af3393e3fed53e4affbdcadb168fb0272f1f66a404c2a7f5,0xdef1c0ded9bec7f1a1670819833240f027b25eff,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.2697972839475782,,2.697972839475782E17 -1187.960462635206,2023-04-04,2023-04-04 20:18:23.000 UTC,ethereum,67,0xe3baa96ad46457d9e6cdd4e32abc11e2c124ec49,0xe66b31678d6c16e9ebf358268a790b763c133750,MATIC,MATIC-WETH,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.6355176659650807,WETH,[],0xc2c5075f7ab3c7ec9137818321d141591fd64bbe,0xdc8f6fc4096ed10ef8de4dd8fd8d417f3d0e813803106a2f404191a59f2a3af6,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307837643161666137623731386662383933646233306133616263306366633630386161636665626230,,,1.0412282002731007E21 -49.49835260980026,2023-04-04,2023-04-04 20:17:59.000 UTC,ethereum,48,0x945bcf562085de2d5875b9e2012ed5fd5cfab927,0xe66b31678d6c16e9ebf358268a790b763c133750,MATIC,MATIC-WETH,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.02647990274854503,WETH,[],0x59d68b8c82079568c9907903f554d2e7e25ebf55,0xd73d99416671b47e2f821bdf332a4283a31d002c8ff02918c5c2fcfbe2625d58,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307837643161666137623731386662383933646233306133616263306366633630386161636665626230,,,43273671441228360000 +1187.960462635206,2023-04-04,2023-04-04 20:18:23.000 UTC,ethereum,67,0xe3baa96ad46457d9e6cdd4e32abc11e2c124ec49,0xc2c5075f7ab3c7ec9137818321d141591fd64bbe,MATIC,MATIC-WETH,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.6355176659650807,WETH,[],0xc2c5075f7ab3c7ec9137818321d141591fd64bbe,0xdc8f6fc4096ed10ef8de4dd8fd8d417f3d0e813803106a2f404191a59f2a3af6,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307837643161666137623731386662383933646233306133616263306366633630386161636665626230,,,1.0412282002731007E21 +49.49835260980026,2023-04-04,2023-04-04 20:17:59.000 UTC,ethereum,48,0x945bcf562085de2d5875b9e2012ed5fd5cfab927,0x59d68b8c82079568c9907903f554d2e7e25ebf55,MATIC,MATIC-WETH,0x307863303261616133396232323366653864306130653563346632376561643930383363373536636332,0.02647990274854503,WETH,[],0x59d68b8c82079568c9907903f554d2e7e25ebf55,0xd73d99416671b47e2f821bdf332a4283a31d002c8ff02918c5c2fcfbe2625d58,0xe66b31678d6c16e9ebf358268a790b763c133750,0x307837643161666137623731386662383933646233306133616263306366633630386161636665626230,,,43273671441228360000 1051.1007943624827,2023-04-04,2023-04-04 20:17:51.000 UTC,optimism,30,0x0000001d56656c6f64726f6d6500000000000000,0x6cf233cb7a0a1878ef2d315f77e6c8b925f12cec,WETH,USDC-WETH,0x7f5c764cbc14f9669b88837ca1490cca17c31607,,USDC,[],0x6cf233cb7a0a1878ef2d315f77e6c8b925f12cec,0xd95e7f7008d83757d379ae63f102fe1b4e3a8cd90f561b608b909eab75e38ed6,0xdef1abe32c034e558cdd535791643c58a13acc10,0x4200000000000000000000000000000000000006,0.56230248778272,,5.6230248778271994E17 1051.061195219627,2023-04-04,2023-04-04 20:17:51.000 UTC,optimism,14,0x00000012556e6973776170563300000000000000,0x6cf233cb7a0a1878ef2d315f77e6c8b925f12cec,WETH,USDC-WETH,0x7f5c764cbc14f9669b88837ca1490cca17c31607,,USDC,[],0x6cf233cb7a0a1878ef2d315f77e6c8b925f12cec,0xd95e7f7008d83757d379ae63f102fe1b4e3a8cd90f561b608b909eab75e38ed6,0xdef1abe32c034e558cdd535791643c58a13acc10,0x4200000000000000000000000000000000000006,0.5622813036140263,,5.622813036140263E17 From efa97d49e8e6b18573765e6407d85b3cf70d6ae5 Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 08:58:03 -0700 Subject: [PATCH 040/127] zeroex settler - new model (#6679) * new model arb * add incremental * incremental fix * incremental fix, add arb, avax * add op, poly, eth chains * revert bnb, avax changes * add avax * add bnb * add log filters * update model on all chains * revise valid logs cte * logs selection update --- .../zeroex_arbitrum_settler_trades.sql | 172 ++++++++--------- .../zeroex_avalanche_c_settler_trades.sql | 173 ++++++++--------- .../zeroex/bnb/zeroex_bnb_settler_trades.sql | 175 ++++++++---------- .../zeroex_ethereum_settler_trades.sql | 173 ++++++++--------- .../zeroex_optimism_settler_trades.sql | 173 ++++++++--------- .../polygon/zeroex_polygon_settler_trades.sql | 175 ++++++++---------- 6 files changed, 487 insertions(+), 554 deletions(-) diff --git a/dbt_subprojects/dex/models/_projects/zeroex/arbitrum/zeroex_arbitrum_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/arbitrum/zeroex_arbitrum_settler_trades.sql index 77ed47a27ff..e44c7082f6d 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/arbitrum/zeroex_arbitrum_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/arbitrum/zeroex_arbitrum_settler_trades.sql @@ -25,7 +25,6 @@ WITH tbl_addresses AS ( contract_address = 0x00000000000004533fe15556b1e086bb1a72ceae AND blockchain = 'arbitrum' and block_time > TIMESTAMP '2024-05-23' - ), tbl_end_times AS ( @@ -53,7 +52,8 @@ settler_txs AS ( block_number, method_id, contract_address, - MAX(varbinary_substring(tracker,1,12)) AS zid, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, CASE WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) @@ -65,7 +65,8 @@ settler_txs AS ( block_time, "to" AS contract_address, varbinary_substring(input,1,4) AS method_id, - varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address FROM {{ source('arbitrum', 'traces') }} AS tr JOIN @@ -80,78 +81,62 @@ settler_txs AS ( {% endif %} ) GROUP BY - 1,2,3,4,5 + 1,2,3,4,5,6 ), +tbl_trades as ( -tbl_all_logs AS ( +with tbl_all_logs AS ( SELECT logs.tx_hash, logs.block_time, logs.block_number, - ROW_NUMBER() OVER (PARTITION BY logs.tx_hash ORDER BY index) rn_first, - index, - CASE - WHEN varbinary_substring(logs.topic2, 13, 20) = logs.tx_from THEN 1 - WHEN varbinary_substring(logs.topic1, 13, 20) = st.contract_address THEN 0 - WHEN FIRST_VALUE(logs.contract_address) OVER (PARTITION BY logs.tx_hash ORDER BY index) = logs.contract_address THEN 0 - ELSE 1 - END maker_tkn, - bytearray_to_int256(bytearray_substring(DATA, 22,11)) value, - logs.contract_address AS token, - zid, - st.contract_address, + index, + case when ( (varbinary_substring(logs.topic2, 13, 20) = logs.tx_from) OR + (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or + topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) + then 1 end as valid, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, method_id, - tag + tag, + st.settler_address, + zid, + st.settler_address as contract_address FROM {{ source('arbitrum', 'logs') }} AS logs JOIN - settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + settler_txs st ON st.tx_hash = logs.tx_hash + AND logs.block_time = st.block_time + AND st.block_number = logs.block_number + AND ( (st.settler_address = bytearray_substring(logs.topic1,13,20)) + or (st.settler_address= bytearray_substring(logs.topic2,13,20)) + or logs.tx_from = bytearray_substring(logs.topic1,13,20) + or logs.tx_from = bytearray_substring(logs.topic2,13,20) + ) WHERE - topic0 IN (0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, - 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c) - and not(tag = 0x000000 and zid = 0xa00000000000000000000000) + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 {% if is_incremental() %} AND {{ incremental_predicate('logs.block_time') }} {% else %} AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by index desc) rn + from tbl_all_logs + where taker_token != maker_token + ) + select * from tbl_valid_logs where rn = 1 ), -tbl_maker_token AS ( - SELECT - ROW_NUMBER() OVER (PARTITION BY tx_hash ORDER BY index DESC) rn_last, - token AS maker_token, - tx_hash, - block_time, - block_number, - index - FROM - tbl_all_logs - WHERE - maker_tkn = 1 -), - -tbl_trades AS ( - SELECT - ta.tx_hash, - ta.block_time, - ta.block_number, - zid, - method_id, - tag, - contract_address, - SUM(value) FILTER (WHERE rn_first = 1) AS taker_amount, - MAX(token) FILTER (WHERE rn_first = 1) AS taker_token, - SUM(value) FILTER (WHERE rn_last = 1) AS maker_amount, - MAX(maker_token) FILTER (WHERE rn_last = 1) AS maker_token - FROM - tbl_all_logs ta - LEFT JOIN - tbl_maker_token mkr ON ta.tx_hash = mkr.tx_hash AND ta.block_time = mkr.block_time AND ta.block_number = mkr.block_number AND ta.index = mkr.index AND mkr.rn_last = 1 - GROUP BY - 1,2,3,4,5,6,7 -), tokens AS ( SELECT DISTINCT @@ -180,6 +165,33 @@ prices AS ( {% endif %} ), +fills as ( + with signatures as ( + select distinct signature + from {{ source('arbitrum', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SellarbitrumToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('arbitrum', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + results AS ( SELECT trades.block_time, @@ -190,23 +202,8 @@ results AS ( trades.tx_hash, "from" AS tx_from, "to" AS tx_to, - index AS tx_index, - CASE - WHEN varbinary_substring(data,17,10) != 0x00000000000000000000 AND varbinary_substring(data,17,1) != 0x THEN varbinary_substring(data,17,20) - WHEN varbinary_substring(data,177,10) != 0x00000000000000000000 THEN varbinary_substring(data,177,20) - WHEN varbinary_substring(data,277,10) != 0x00000000000000000000 THEN varbinary_substring(data,277,20) - WHEN varbinary_substring(data,629,10) != 0x00000000000000000000 THEN varbinary_substring(data,629,20) - WHEN varbinary_substring(data,693,10) != 0x00000000000000000000 THEN varbinary_substring(data,693,20) - WHEN varbinary_substring(data,917,10) != 0x00000000000000000000 THEN varbinary_substring(data,917,20) - WHEN varbinary_substring(data,949,10) != 0x00000000000000000000 THEN varbinary_substring(data,949,20) - WHEN varbinary_substring(data,981,10) != 0x00000000000000000000 THEN varbinary_substring(data,981,20) - WHEN varbinary_substring(data,1013,10) != 0x00000000000000000000 THEN varbinary_substring(data,1013,20) - WHEN varbinary_substring(data,1141,10) != 0x00000000000000000000 THEN varbinary_substring(data,1141,20) - WHEN varbinary_substring(data,1273,10) != 0x00000000000000000000 THEN varbinary_substring(data,1273,20) - WHEN varbinary_substring(data,1749,4) != 0x00000000 THEN varbinary_substring(data,1749,20) - WHEN varbinary_substring(data,1049,4) != 0x00000000 THEN varbinary_substring(data,1049,20) - WHEN varbinary_substring(data,17,4) != 0x00000000 THEN varbinary_substring(data,17,20) - END AS taker , + trades.index AS tx_index, + taker , CAST(NULL AS varbinary) AS maker, taker_token, pt.price, @@ -220,16 +217,13 @@ results AS ( maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, tag, - data, - varbinary_substring(data, varbinary_length(data) - CASE - WHEN varbinary_position (data,0xc4103b48be) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xc4103b48be)) - WHEN varbinary_position (data,0xe48d68a156) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe48d68a156)) - WHEN varbinary_position (data,0xe422ce6ede) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe422ce6ede)) - END -3, 37) taker_indicator_string + fills_within FROM tbl_trades trades JOIN {{ source('arbitrum', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number LEFT JOIN tokens tt ON tt.blockchain = 'arbitrum' AND tt.contract_address = taker_token LEFT JOIN @@ -250,7 +244,7 @@ results AS ( results_usd AS ( SELECT 'arbitrum' AS blockchain, - '0x API' AS project, + '0x-API' AS project, 'settler' AS version, DATE_TRUNC('day', block_time) block_date, DATE_TRUNC('month', block_time) AS block_month, @@ -262,13 +256,13 @@ results_usd AS ( maker_token_amount, taker_token_amount_raw, maker_token_amount_raw, - CASE WHEN maker_token IN (0x82af49447d8a07e3bd95bd0d56f35241523fbab1, + CASE WHEN maker_token IN (0x82af49447d8a07e3bd95bd0d56f35241523fbab1, 0xaf88d065e77c8cc2239327c5edb3a432268e5831, 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8, 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9, 0x912ce59144191c1204e64559fe8253a0e49e6548) AND maker_amount IS NOT NULL THEN maker_amount - WHEN taker_token IN (0x82af49447d8a07e3bd95bd0d56f35241523fbab1, + WHEN taker_token IN (0x82af49447d8a07e3bd95bd0d56f35241523fbab1, 0xaf88d065e77c8cc2239327c5edb3a432268e5831, 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8, 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9, @@ -278,13 +272,7 @@ results_usd AS ( END AS volume_usd, taker_token, maker_token, - CASE WHEN (varbinary_substring(taker,1,4) = 0x00000000) - OR taker IS NULL - OR taker = taker_token - OR taker = contract_address - OR taker = 0xdef1c0ded9bec7f1a1670819833240f027b25eff - OR varbinary_substring(taker_indicator_string, 18,20) != contract_address - THEN varbinary_substring(taker_indicator_string, 18,20) ELSE taker END AS taker, + taker, maker, tag, zid, @@ -295,12 +283,12 @@ results_usd AS ( (ARRAY[-1]) AS trace_address, 'settler' AS type, TRUE AS swap_flag, - -1 AS fills_within, + fills_within, contract_address FROM results ) - + SELECT DISTINCT * FROM diff --git a/dbt_subprojects/dex/models/_projects/zeroex/avalanche_c/zeroex_avalanche_c_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/avalanche_c/zeroex_avalanche_c_settler_trades.sql index bae7ceadbbc..8718c12d682 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/avalanche_c/zeroex_avalanche_c_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/avalanche_c/zeroex_avalanche_c_settler_trades.sql @@ -52,7 +52,8 @@ settler_txs AS ( block_number, method_id, contract_address, - MAX(varbinary_substring(tracker,1,12)) AS zid, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, CASE WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) @@ -64,7 +65,8 @@ settler_txs AS ( block_time, "to" AS contract_address, varbinary_substring(input,1,4) AS method_id, - varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address FROM {{ source('avalanche_c', 'traces') }} AS tr JOIN @@ -79,78 +81,62 @@ settler_txs AS ( {% endif %} ) GROUP BY - 1,2,3,4,5 + 1,2,3,4,5,6 ), +tbl_trades as ( -tbl_all_logs AS ( +with tbl_all_logs AS ( SELECT logs.tx_hash, logs.block_time, logs.block_number, - ROW_NUMBER() OVER (PARTITION BY logs.tx_hash ORDER BY index) rn_first, - index, - CASE - WHEN varbinary_substring(logs.topic2, 13, 20) = logs.tx_from THEN 1 - WHEN varbinary_substring(logs.topic1, 13, 20) = st.contract_address THEN 0 - WHEN FIRST_VALUE(logs.contract_address) OVER (PARTITION BY logs.tx_hash ORDER BY index) = logs.contract_address THEN 0 - ELSE 1 - END maker_tkn, - bytearray_to_int256(bytearray_substring(DATA, 22,11)) value, - logs.contract_address AS token, - zid, - st.contract_address, + index, + case when ( (varbinary_substring(logs.topic2, 13, 20) = logs.tx_from) OR + (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or + topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) + then 1 end as valid, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, method_id, - tag + tag, + st.settler_address, + zid, + st.settler_address as contract_address FROM {{ source('avalanche_c', 'logs') }} AS logs JOIN - settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + settler_txs st ON st.tx_hash = logs.tx_hash + AND logs.block_time = st.block_time + AND st.block_number = logs.block_number + AND ( (st.settler_address = bytearray_substring(logs.topic1,13,20)) + or (st.settler_address= bytearray_substring(logs.topic2,13,20)) + or logs.tx_from = bytearray_substring(logs.topic1,13,20) + or logs.tx_from = bytearray_substring(logs.topic2,13,20) + ) WHERE - topic0 IN (0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, - 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c) - and not(tag = 0x000000 and zid = 0xa00000000000000000000000) + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 {% if is_incremental() %} AND {{ incremental_predicate('logs.block_time') }} {% else %} AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by valid, index desc) rn + from tbl_all_logs + where taker_token != maker_token + ) + select * from tbl_valid_logs where rn = 1 ), -tbl_maker_token AS ( - SELECT - ROW_NUMBER() OVER (PARTITION BY tx_hash ORDER BY index DESC) rn_last, - token AS maker_token, - tx_hash, - block_time, - block_number, - index - FROM - tbl_all_logs - WHERE - maker_tkn = 1 -), - -tbl_trades AS ( - SELECT - ta.tx_hash, - ta.block_time, - ta.block_number, - zid, - method_id, - tag, - contract_address, - SUM(value) FILTER (WHERE rn_first = 1) AS taker_amount, - MAX(token) FILTER (WHERE rn_first = 1) AS taker_token, - SUM(value) FILTER (WHERE rn_last = 1) AS maker_amount, - MAX(maker_token) FILTER (WHERE rn_last = 1) AS maker_token - FROM - tbl_all_logs ta - LEFT JOIN - tbl_maker_token mkr ON ta.tx_hash = mkr.tx_hash AND ta.block_time = mkr.block_time AND ta.block_number = mkr.block_number AND ta.index = mkr.index AND mkr.rn_last = 1 - GROUP BY - 1,2,3,4,5,6,7 -), tokens AS ( SELECT DISTINCT @@ -179,6 +165,33 @@ prices AS ( {% endif %} ), +fills as ( + with signatures as ( + select distinct signature + from {{ source('avalanche_c', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'Sellavalanche_cToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('avalanche_c', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + results AS ( SELECT trades.block_time, @@ -189,23 +202,8 @@ results AS ( trades.tx_hash, "from" AS tx_from, "to" AS tx_to, - index AS tx_index, - CASE - WHEN varbinary_substring(data,17,10) != 0x00000000000000000000 AND varbinary_substring(data,17,1) != 0x THEN varbinary_substring(data,17,20) - WHEN varbinary_substring(data,177,10) != 0x00000000000000000000 THEN varbinary_substring(data,177,20) - WHEN varbinary_substring(data,277,10) != 0x00000000000000000000 THEN varbinary_substring(data,277,20) - WHEN varbinary_substring(data,629,10) != 0x00000000000000000000 THEN varbinary_substring(data,629,20) - WHEN varbinary_substring(data,693,10) != 0x00000000000000000000 THEN varbinary_substring(data,693,20) - WHEN varbinary_substring(data,917,10) != 0x00000000000000000000 THEN varbinary_substring(data,917,20) - WHEN varbinary_substring(data,949,10) != 0x00000000000000000000 THEN varbinary_substring(data,949,20) - WHEN varbinary_substring(data,981,10) != 0x00000000000000000000 THEN varbinary_substring(data,981,20) - WHEN varbinary_substring(data,1013,10) != 0x00000000000000000000 THEN varbinary_substring(data,1013,20) - WHEN varbinary_substring(data,1141,10) != 0x00000000000000000000 THEN varbinary_substring(data,1141,20) - WHEN varbinary_substring(data,1273,10) != 0x00000000000000000000 THEN varbinary_substring(data,1273,20) - WHEN varbinary_substring(data,1749,4) != 0x00000000 THEN varbinary_substring(data,1749,20) - WHEN varbinary_substring(data,1049,4) != 0x00000000 THEN varbinary_substring(data,1049,20) - WHEN varbinary_substring(data,17,4) != 0x00000000 THEN varbinary_substring(data,17,20) - END AS taker , + trades.index AS tx_index, + taker , CAST(NULL AS varbinary) AS maker, taker_token, pt.price, @@ -219,16 +217,13 @@ results AS ( maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, tag, - data, - varbinary_substring(data, varbinary_length(data) - CASE - WHEN varbinary_position (data,0xc4103b48be) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xc4103b48be)) - WHEN varbinary_position (data,0xe48d68a156) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe48d68a156)) - WHEN varbinary_position (data,0xe422ce6ede) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe422ce6ede)) - END -3, 37) taker_indicator_string + fills_within FROM tbl_trades trades JOIN {{ source('avalanche_c', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number LEFT JOIN tokens tt ON tt.blockchain = 'avalanche_c' AND tt.contract_address = taker_token LEFT JOIN @@ -249,7 +244,7 @@ results AS ( results_usd AS ( SELECT 'avalanche_c' AS blockchain, - '0x API' AS project, + '0x-API' AS project, 'settler' AS version, DATE_TRUNC('day', block_time) block_date, DATE_TRUNC('month', block_time) AS block_month, @@ -261,29 +256,23 @@ results_usd AS ( maker_token_amount, taker_token_amount_raw, maker_token_amount_raw, - CASE WHEN maker_token IN (0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7, + CASE WHEN maker_token IN (0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7, 0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e, 0x152b9d0fdc40c096757f570a51e494bd4b943e50, 0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab, - 0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7) AND maker_amount IS NOT NULL + 0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7) AND maker_amount IS NOT NULL THEN maker_amount - WHEN taker_token IN (0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7, + WHEN taker_token IN (0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7, 0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e, 0x152b9d0fdc40c096757f570a51e494bd4b943e50, 0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab, - 0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7) AND taker_amount IS NOT NULL + 0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7) AND taker_amount IS NOT NULL THEN taker_amount ELSE COALESCE(maker_amount, taker_amount) END AS volume_usd, taker_token, maker_token, - CASE WHEN (varbinary_substring(taker,1,4) = 0x00000000) - OR taker IS NULL - OR taker = taker_token - OR taker = contract_address - OR taker = 0xdef1c0ded9bec7f1a1670819833240f027b25eff - OR varbinary_substring(taker_indicator_string, 18,20) != contract_address - THEN varbinary_substring(taker_indicator_string, 18,20) ELSE taker END AS taker, + taker, maker, tag, zid, @@ -294,7 +283,7 @@ results_usd AS ( (ARRAY[-1]) AS trace_address, 'settler' AS type, TRUE AS swap_flag, - -1 AS fills_within, + fills_within, contract_address FROM results diff --git a/dbt_subprojects/dex/models/_projects/zeroex/bnb/zeroex_bnb_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/bnb/zeroex_bnb_settler_trades.sql index 22f5b5dac08..29cfd2ee6d0 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/bnb/zeroex_bnb_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/bnb/zeroex_bnb_settler_trades.sql @@ -24,7 +24,7 @@ WITH tbl_addresses AS ( WHERE contract_address = 0x00000000000004533fe15556b1e086bb1a72ceae AND blockchain = 'bnb' - and block_time > TIMESTAMP '2024-05-23' + and block_time > TIMESTAMP '2024-05-23' ), tbl_end_times AS ( @@ -52,7 +52,8 @@ settler_txs AS ( block_number, method_id, contract_address, - MAX(varbinary_substring(tracker,1,12)) AS zid, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, CASE WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) @@ -64,7 +65,8 @@ settler_txs AS ( block_time, "to" AS contract_address, varbinary_substring(input,1,4) AS method_id, - varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address FROM {{ source('bnb', 'traces') }} AS tr JOIN @@ -79,78 +81,62 @@ settler_txs AS ( {% endif %} ) GROUP BY - 1,2,3,4,5 + 1,2,3,4,5,6 ), +tbl_trades as ( -tbl_all_logs AS ( +with tbl_all_logs AS ( SELECT logs.tx_hash, logs.block_time, logs.block_number, - ROW_NUMBER() OVER (PARTITION BY logs.tx_hash ORDER BY index) rn_first, - index, - CASE - WHEN varbinary_substring(logs.topic2, 13, 20) = logs.tx_from THEN 1 - WHEN varbinary_substring(logs.topic1, 13, 20) = st.contract_address THEN 0 - WHEN FIRST_VALUE(logs.contract_address) OVER (PARTITION BY logs.tx_hash ORDER BY index) = logs.contract_address THEN 0 - ELSE 1 - END maker_tkn, - bytearray_to_int256(bytearray_substring(DATA, 22,11)) value, - logs.contract_address AS token, - zid, - st.contract_address, + index, + case when ( (varbinary_substring(logs.topic2, 13, 20) = logs.tx_from) OR + (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or + topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) + then 1 end as valid, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, method_id, - tag + tag, + st.settler_address, + zid, + st.settler_address as contract_address FROM {{ source('bnb', 'logs') }} AS logs JOIN - settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + settler_txs st ON st.tx_hash = logs.tx_hash + AND logs.block_time = st.block_time + AND st.block_number = logs.block_number + AND ( (st.settler_address = bytearray_substring(logs.topic1,13,20)) + or (st.settler_address= bytearray_substring(logs.topic2,13,20)) + or logs.tx_from = bytearray_substring(logs.topic1,13,20) + or logs.tx_from = bytearray_substring(logs.topic2,13,20) + ) WHERE - topic0 IN (0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, - 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c) - and not(tag = 0x000000 and zid = 0xa00000000000000000000000) + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 {% if is_incremental() %} AND {{ incremental_predicate('logs.block_time') }} {% else %} AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by valid, index desc) rn + from tbl_all_logs + where taker_token != maker_token + ) + select * from tbl_valid_logs where rn = 1 ), -tbl_maker_token AS ( - SELECT - ROW_NUMBER() OVER (PARTITION BY tx_hash ORDER BY index DESC) rn_last, - token AS maker_token, - tx_hash, - block_time, - block_number, - index - FROM - tbl_all_logs - WHERE - maker_tkn = 1 -), - -tbl_trades AS ( - SELECT - ta.tx_hash, - ta.block_time, - ta.block_number, - zid, - method_id, - tag, - contract_address, - SUM(value) FILTER (WHERE rn_first = 1) AS taker_amount, - MAX(token) FILTER (WHERE rn_first = 1) AS taker_token, - SUM(value) FILTER (WHERE rn_last = 1) AS maker_amount, - MAX(maker_token) FILTER (WHERE rn_last = 1) AS maker_token - FROM - tbl_all_logs ta - LEFT JOIN - tbl_maker_token mkr ON ta.tx_hash = mkr.tx_hash AND ta.block_time = mkr.block_time AND ta.block_number = mkr.block_number AND ta.index = mkr.index AND mkr.rn_last = 1 - GROUP BY - 1,2,3,4,5,6,7 -), tokens AS ( SELECT DISTINCT @@ -179,6 +165,33 @@ prices AS ( {% endif %} ), +fills as ( + with signatures as ( + select distinct signature + from {{ source('bnb', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SellbnbToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('bnb', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + results AS ( SELECT trades.block_time, @@ -189,23 +202,8 @@ results AS ( trades.tx_hash, "from" AS tx_from, "to" AS tx_to, - index AS tx_index, - CASE - WHEN varbinary_substring(data,17,10) != 0x00000000000000000000 AND varbinary_substring(data,17,1) != 0x THEN varbinary_substring(data,17,20) - WHEN varbinary_substring(data,177,10) != 0x00000000000000000000 THEN varbinary_substring(data,177,20) - WHEN varbinary_substring(data,277,10) != 0x00000000000000000000 THEN varbinary_substring(data,277,20) - WHEN varbinary_substring(data,629,10) != 0x00000000000000000000 THEN varbinary_substring(data,629,20) - WHEN varbinary_substring(data,693,10) != 0x00000000000000000000 THEN varbinary_substring(data,693,20) - WHEN varbinary_substring(data,917,10) != 0x00000000000000000000 THEN varbinary_substring(data,917,20) - WHEN varbinary_substring(data,949,10) != 0x00000000000000000000 THEN varbinary_substring(data,949,20) - WHEN varbinary_substring(data,981,10) != 0x00000000000000000000 THEN varbinary_substring(data,981,20) - WHEN varbinary_substring(data,1013,10) != 0x00000000000000000000 THEN varbinary_substring(data,1013,20) - WHEN varbinary_substring(data,1141,10) != 0x00000000000000000000 THEN varbinary_substring(data,1141,20) - WHEN varbinary_substring(data,1273,10) != 0x00000000000000000000 THEN varbinary_substring(data,1273,20) - WHEN varbinary_substring(data,1749,4) != 0x00000000 THEN varbinary_substring(data,1749,20) - WHEN varbinary_substring(data,1049,4) != 0x00000000 THEN varbinary_substring(data,1049,20) - WHEN varbinary_substring(data,17,4) != 0x00000000 THEN varbinary_substring(data,17,20) - END AS taker , + trades.index AS tx_index, + taker , CAST(NULL AS varbinary) AS maker, taker_token, pt.price, @@ -219,16 +217,13 @@ results AS ( maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, tag, - data, - varbinary_substring(data, varbinary_length(data) - CASE - WHEN varbinary_position (data,0xc4103b48be) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xc4103b48be)) - WHEN varbinary_position (data,0xe48d68a156) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe48d68a156)) - WHEN varbinary_position (data,0xe422ce6ede) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe422ce6ede)) - END -3, 37) taker_indicator_string + fills_within FROM tbl_trades trades JOIN {{ source('bnb', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number LEFT JOIN tokens tt ON tt.blockchain = 'bnb' AND tt.contract_address = taker_token LEFT JOIN @@ -249,7 +244,7 @@ results AS ( results_usd AS ( SELECT 'bnb' AS blockchain, - '0x API' AS project, + '0x-API' AS project, 'settler' AS version, DATE_TRUNC('day', block_time) block_date, DATE_TRUNC('month', block_time) AS block_month, @@ -261,31 +256,25 @@ results_usd AS ( maker_token_amount, taker_token_amount_raw, maker_token_amount_raw, - CASE WHEN maker_token IN (0x55d398326f99059ff775485246999027b3197955, + CASE WHEN maker_token IN (0x55d398326f99059ff775485246999027b3197955, 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c, 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d, 0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c, 0x2170ed0880ac9a755fd29b2688956bd959f933f8, - 0xe9e7cea3dedca5984780bafc599bd69add087d56) AND maker_amount IS NOT NULL + 0xe9e7cea3dedca5984780bafc599bd69add087d56) AND maker_amount IS NOT NULL THEN maker_amount - WHEN taker_token IN (0x55d398326f99059ff775485246999027b3197955, + WHEN taker_token IN (0x55d398326f99059ff775485246999027b3197955, 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c, 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d, 0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c, 0x2170ed0880ac9a755fd29b2688956bd959f933f8, - 0xe9e7cea3dedca5984780bafc599bd69add087d56) AND taker_amount IS NOT NULL + 0xe9e7cea3dedca5984780bafc599bd69add087d56) AND taker_amount IS NOT NULL THEN taker_amount ELSE COALESCE(maker_amount, taker_amount) END AS volume_usd, taker_token, maker_token, - CASE WHEN (varbinary_substring(taker,1,4) = 0x00000000) - OR taker IS NULL - OR taker = taker_token - OR taker = contract_address - OR taker = 0xdef1c0ded9bec7f1a1670819833240f027b25eff - OR varbinary_substring(taker_indicator_string, 18,20) != contract_address - THEN varbinary_substring(taker_indicator_string, 18,20) ELSE taker END AS taker, + taker, maker, tag, zid, @@ -296,7 +285,7 @@ results_usd AS ( (ARRAY[-1]) AS trace_address, 'settler' AS type, TRUE AS swap_flag, - -1 AS fills_within, + fills_within, contract_address FROM results diff --git a/dbt_subprojects/dex/models/_projects/zeroex/ethereum/zeroex_ethereum_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/ethereum/zeroex_ethereum_settler_trades.sql index 8d46748a259..f1cbd6b58a9 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/ethereum/zeroex_ethereum_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/ethereum/zeroex_ethereum_settler_trades.sql @@ -24,7 +24,7 @@ WITH tbl_addresses AS ( WHERE contract_address = 0x00000000000004533fe15556b1e086bb1a72ceae AND blockchain = 'ethereum' - and block_time > TIMESTAMP '2024-05-23' + and block_time > TIMESTAMP '2024-05-23' ), tbl_end_times AS ( @@ -52,7 +52,8 @@ settler_txs AS ( block_number, method_id, contract_address, - MAX(varbinary_substring(tracker,1,12)) AS zid, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, CASE WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) @@ -64,7 +65,8 @@ settler_txs AS ( block_time, "to" AS contract_address, varbinary_substring(input,1,4) AS method_id, - varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address FROM {{ source('ethereum', 'traces') }} AS tr JOIN @@ -79,78 +81,62 @@ settler_txs AS ( {% endif %} ) GROUP BY - 1,2,3,4,5 + 1,2,3,4,5,6 ), +tbl_trades as ( -tbl_all_logs AS ( +with tbl_all_logs AS ( SELECT logs.tx_hash, logs.block_time, logs.block_number, - ROW_NUMBER() OVER (PARTITION BY logs.tx_hash ORDER BY index) rn_first, - index, - CASE - WHEN varbinary_substring(logs.topic2, 13, 20) = logs.tx_from THEN 1 - WHEN varbinary_substring(logs.topic1, 13, 20) = st.contract_address THEN 0 - WHEN FIRST_VALUE(logs.contract_address) OVER (PARTITION BY logs.tx_hash ORDER BY index) = logs.contract_address THEN 0 - ELSE 1 - END maker_tkn, - bytearray_to_int256(bytearray_substring(DATA, 22,11)) value, - logs.contract_address AS token, - zid, - st.contract_address, + index, + case when ( (varbinary_substring(logs.topic2, 13, 20) = logs.tx_from) OR + (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or + topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) + then 1 end as valid, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, method_id, - tag + tag, + st.settler_address, + zid, + st.settler_address as contract_address FROM {{ source('ethereum', 'logs') }} AS logs JOIN - settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + settler_txs st ON st.tx_hash = logs.tx_hash + AND logs.block_time = st.block_time + AND st.block_number = logs.block_number + AND ( (st.settler_address = bytearray_substring(logs.topic1,13,20)) + or (st.settler_address= bytearray_substring(logs.topic2,13,20)) + or logs.tx_from = bytearray_substring(logs.topic1,13,20) + or logs.tx_from = bytearray_substring(logs.topic2,13,20) + ) WHERE - topic0 IN (0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, - 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c) + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 {% if is_incremental() %} - and not(tag = 0x000000 and zid = 0xa00000000000000000000000) AND {{ incremental_predicate('logs.block_time') }} {% else %} AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by valid, index desc) rn + from tbl_all_logs + where taker_token != maker_token + ) + select * from tbl_valid_logs where rn = 1 ), -tbl_maker_token AS ( - SELECT - ROW_NUMBER() OVER (PARTITION BY tx_hash ORDER BY index DESC) rn_last, - token AS maker_token, - tx_hash, - block_time, - block_number, - index - FROM - tbl_all_logs - WHERE - maker_tkn = 1 -), - -tbl_trades AS ( - SELECT - ta.tx_hash, - ta.block_time, - ta.block_number, - zid, - method_id, - tag, - contract_address, - SUM(value) FILTER (WHERE rn_first = 1) AS taker_amount, - MAX(token) FILTER (WHERE rn_first = 1) AS taker_token, - SUM(value) FILTER (WHERE rn_last = 1) AS maker_amount, - MAX(maker_token) FILTER (WHERE rn_last = 1) AS maker_token - FROM - tbl_all_logs ta - LEFT JOIN - tbl_maker_token mkr ON ta.tx_hash = mkr.tx_hash AND ta.block_time = mkr.block_time AND ta.block_number = mkr.block_number AND ta.index = mkr.index AND mkr.rn_last = 1 - GROUP BY - 1,2,3,4,5,6,7 -), tokens AS ( SELECT DISTINCT @@ -179,6 +165,33 @@ prices AS ( {% endif %} ), +fills as ( + with signatures as ( + select distinct signature + from {{ source('ethereum', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SellethereumToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('ethereum', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + results AS ( SELECT trades.block_time, @@ -189,23 +202,8 @@ results AS ( trades.tx_hash, "from" AS tx_from, "to" AS tx_to, - index AS tx_index, - CASE - WHEN varbinary_substring(data,17,10) != 0x00000000000000000000 AND varbinary_substring(data,17,1) != 0x THEN varbinary_substring(data,17,20) - WHEN varbinary_substring(data,177,10) != 0x00000000000000000000 THEN varbinary_substring(data,177,20) - WHEN varbinary_substring(data,277,10) != 0x00000000000000000000 THEN varbinary_substring(data,277,20) - WHEN varbinary_substring(data,629,10) != 0x00000000000000000000 THEN varbinary_substring(data,629,20) - WHEN varbinary_substring(data,693,10) != 0x00000000000000000000 THEN varbinary_substring(data,693,20) - WHEN varbinary_substring(data,917,10) != 0x00000000000000000000 THEN varbinary_substring(data,917,20) - WHEN varbinary_substring(data,949,10) != 0x00000000000000000000 THEN varbinary_substring(data,949,20) - WHEN varbinary_substring(data,981,10) != 0x00000000000000000000 THEN varbinary_substring(data,981,20) - WHEN varbinary_substring(data,1013,10) != 0x00000000000000000000 THEN varbinary_substring(data,1013,20) - WHEN varbinary_substring(data,1141,10) != 0x00000000000000000000 THEN varbinary_substring(data,1141,20) - WHEN varbinary_substring(data,1273,10) != 0x00000000000000000000 THEN varbinary_substring(data,1273,20) - WHEN varbinary_substring(data,1749,4) != 0x00000000 THEN varbinary_substring(data,1749,20) - WHEN varbinary_substring(data,1049,4) != 0x00000000 THEN varbinary_substring(data,1049,20) - WHEN varbinary_substring(data,17,4) != 0x00000000 THEN varbinary_substring(data,17,20) - END AS taker , + trades.index AS tx_index, + taker , CAST(NULL AS varbinary) AS maker, taker_token, pt.price, @@ -219,16 +217,13 @@ results AS ( maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, tag, - data, - varbinary_substring(data, varbinary_length(data) - CASE - WHEN varbinary_position (data,0xc4103b48be) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xc4103b48be)) - WHEN varbinary_position (data,0xe48d68a156) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe48d68a156)) - WHEN varbinary_position (data,0xe422ce6ede) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe422ce6ede)) - END -3, 37) taker_indicator_string + fills_within FROM tbl_trades trades JOIN {{ source('ethereum', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number LEFT JOIN tokens tt ON tt.blockchain = 'ethereum' AND tt.contract_address = taker_token LEFT JOIN @@ -249,7 +244,7 @@ results AS ( results_usd AS ( SELECT 'ethereum' AS blockchain, - '0x API' AS project, + '0x-API' AS project, 'settler' AS version, DATE_TRUNC('day', block_time) block_date, DATE_TRUNC('month', block_time) AS block_month, @@ -261,31 +256,25 @@ results_usd AS ( maker_token_amount, taker_token_amount_raw, maker_token_amount_raw, - CASE WHEN maker_token IN (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, + CASE WHEN maker_token IN (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0xdac17f958d2ee523a2206206994597c13d831ec7, 0x4fabb145d64652a948d72533023f6e7a623c7c53, 0x6b175474e89094c44da98b954eedeac495271d0f, 0xae7ab96520de3a18e5e111b5eaab095312d7fe84) AND maker_amount IS NOT NULL THEN maker_amount - WHEN taker_token IN (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, + WHEN taker_token IN (0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2, 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0xdac17f958d2ee523a2206206994597c13d831ec7, 0x4fabb145d64652a948d72533023f6e7a623c7c53, 0x6b175474e89094c44da98b954eedeac495271d0f, - 0xae7ab96520de3a18e5e111b5eaab095312d7fe84) AND maker_amount IS NOT NULL AND taker_amount IS NOT NULL + 0xae7ab96520de3a18e5e111b5eaab095312d7fe84) AND taker_amount IS NOT NULL THEN taker_amount ELSE COALESCE(maker_amount, taker_amount) END AS volume_usd, taker_token, maker_token, - CASE WHEN (varbinary_substring(taker,1,4) = 0x00000000) - OR taker IS NULL - OR taker = taker_token - OR taker = contract_address - OR taker = 0xdef1c0ded9bec7f1a1670819833240f027b25eff - OR varbinary_substring(taker_indicator_string, 18,20) != contract_address - THEN varbinary_substring(taker_indicator_string, 18,20) ELSE taker END AS taker, + taker, maker, tag, zid, @@ -296,7 +285,7 @@ results_usd AS ( (ARRAY[-1]) AS trace_address, 'settler' AS type, TRUE AS swap_flag, - -1 AS fills_within, + fills_within, contract_address FROM results diff --git a/dbt_subprojects/dex/models/_projects/zeroex/optimism/zeroex_optimism_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/optimism/zeroex_optimism_settler_trades.sql index 0dfa8e46f4e..f76da55d3fc 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/optimism/zeroex_optimism_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/optimism/zeroex_optimism_settler_trades.sql @@ -52,7 +52,8 @@ settler_txs AS ( block_number, method_id, contract_address, - MAX(varbinary_substring(tracker,1,12)) AS zid, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, CASE WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) @@ -64,7 +65,8 @@ settler_txs AS ( block_time, "to" AS contract_address, varbinary_substring(input,1,4) AS method_id, - varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address FROM {{ source('optimism', 'traces') }} AS tr JOIN @@ -79,78 +81,62 @@ settler_txs AS ( {% endif %} ) GROUP BY - 1,2,3,4,5 + 1,2,3,4,5,6 ), +tbl_trades as ( -tbl_all_logs AS ( +with tbl_all_logs AS ( SELECT logs.tx_hash, logs.block_time, logs.block_number, - ROW_NUMBER() OVER (PARTITION BY logs.tx_hash ORDER BY index) rn_first, - index, - CASE - WHEN varbinary_substring(logs.topic2, 13, 20) = logs.tx_from THEN 1 - WHEN varbinary_substring(logs.topic1, 13, 20) = st.contract_address THEN 0 - WHEN FIRST_VALUE(logs.contract_address) OVER (PARTITION BY logs.tx_hash ORDER BY index) = logs.contract_address THEN 0 - ELSE 1 - END maker_tkn, - bytearray_to_int256(bytearray_substring(DATA, 22,11)) value, - logs.contract_address AS token, - zid, - st.contract_address, + index, + case when ( (varbinary_substring(logs.topic2, 13, 20) = logs.tx_from) OR + (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or + topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) + then 1 end as valid, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, method_id, - tag + tag, + st.settler_address, + zid, + st.settler_address as contract_address FROM {{ source('optimism', 'logs') }} AS logs JOIN - settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + settler_txs st ON st.tx_hash = logs.tx_hash + AND logs.block_time = st.block_time + AND st.block_number = logs.block_number + AND ( (st.settler_address = bytearray_substring(logs.topic1,13,20)) + or (st.settler_address= bytearray_substring(logs.topic2,13,20)) + or logs.tx_from = bytearray_substring(logs.topic1,13,20) + or logs.tx_from = bytearray_substring(logs.topic2,13,20) + ) WHERE - topic0 IN (0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, - 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c) - and not(tag = 0x000000 and zid = 0xa00000000000000000000000) + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 {% if is_incremental() %} AND {{ incremental_predicate('logs.block_time') }} {% else %} AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by valid, index desc) rn + from tbl_all_logs + where taker_token != maker_token + ) + select * from tbl_valid_logs where rn = 1 ), -tbl_maker_token AS ( - SELECT - ROW_NUMBER() OVER (PARTITION BY tx_hash ORDER BY index DESC) rn_last, - token AS maker_token, - tx_hash, - block_time, - block_number, - index - FROM - tbl_all_logs - WHERE - maker_tkn = 1 -), - -tbl_trades AS ( - SELECT - ta.tx_hash, - ta.block_time, - ta.block_number, - zid, - method_id, - tag, - contract_address, - SUM(value) FILTER (WHERE rn_first = 1) AS taker_amount, - MAX(token) FILTER (WHERE rn_first = 1) AS taker_token, - SUM(value) FILTER (WHERE rn_last = 1) AS maker_amount, - MAX(maker_token) FILTER (WHERE rn_last = 1) AS maker_token - FROM - tbl_all_logs ta - LEFT JOIN - tbl_maker_token mkr ON ta.tx_hash = mkr.tx_hash AND ta.block_time = mkr.block_time AND ta.block_number = mkr.block_number AND ta.index = mkr.index AND mkr.rn_last = 1 - GROUP BY - 1,2,3,4,5,6,7 -), tokens AS ( SELECT DISTINCT @@ -179,6 +165,33 @@ prices AS ( {% endif %} ), +fills as ( + with signatures as ( + select distinct signature + from {{ source('optimism', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SelloptimismToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('optimism', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + results AS ( SELECT trades.block_time, @@ -189,23 +202,8 @@ results AS ( trades.tx_hash, "from" AS tx_from, "to" AS tx_to, - index AS tx_index, - CASE - WHEN varbinary_substring(data,17,10) != 0x00000000000000000000 AND varbinary_substring(data,17,1) != 0x THEN varbinary_substring(data,17,20) - WHEN varbinary_substring(data,177,10) != 0x00000000000000000000 THEN varbinary_substring(data,177,20) - WHEN varbinary_substring(data,277,10) != 0x00000000000000000000 THEN varbinary_substring(data,277,20) - WHEN varbinary_substring(data,629,10) != 0x00000000000000000000 THEN varbinary_substring(data,629,20) - WHEN varbinary_substring(data,693,10) != 0x00000000000000000000 THEN varbinary_substring(data,693,20) - WHEN varbinary_substring(data,917,10) != 0x00000000000000000000 THEN varbinary_substring(data,917,20) - WHEN varbinary_substring(data,949,10) != 0x00000000000000000000 THEN varbinary_substring(data,949,20) - WHEN varbinary_substring(data,981,10) != 0x00000000000000000000 THEN varbinary_substring(data,981,20) - WHEN varbinary_substring(data,1013,10) != 0x00000000000000000000 THEN varbinary_substring(data,1013,20) - WHEN varbinary_substring(data,1141,10) != 0x00000000000000000000 THEN varbinary_substring(data,1141,20) - WHEN varbinary_substring(data,1273,10) != 0x00000000000000000000 THEN varbinary_substring(data,1273,20) - WHEN varbinary_substring(data,1749,4) != 0x00000000 THEN varbinary_substring(data,1749,20) - WHEN varbinary_substring(data,1049,4) != 0x00000000 THEN varbinary_substring(data,1049,20) - WHEN varbinary_substring(data,17,4) != 0x00000000 THEN varbinary_substring(data,17,20) - END AS taker , + trades.index AS tx_index, + taker , CAST(NULL AS varbinary) AS maker, taker_token, pt.price, @@ -219,16 +217,13 @@ results AS ( maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, tag, - data, - varbinary_substring(data, varbinary_length(data) - CASE - WHEN varbinary_position (data,0xc4103b48be) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xc4103b48be)) - WHEN varbinary_position (data,0xe48d68a156) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe48d68a156)) - WHEN varbinary_position (data,0xe422ce6ede) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe422ce6ede)) - END -3, 37) taker_indicator_string + fills_within FROM tbl_trades trades JOIN {{ source('optimism', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number LEFT JOIN tokens tt ON tt.blockchain = 'optimism' AND tt.contract_address = taker_token LEFT JOIN @@ -249,7 +244,7 @@ results AS ( results_usd AS ( SELECT 'optimism' AS blockchain, - '0x API' AS project, + '0x-API' AS project, 'settler' AS version, DATE_TRUNC('day', block_time) block_date, DATE_TRUNC('month', block_time) AS block_month, @@ -261,31 +256,25 @@ results_usd AS ( maker_token_amount, taker_token_amount_raw, maker_token_amount_raw, - CASE WHEN maker_token IN (0x4200000000000000000000000000000000000006, + CASE WHEN maker_token IN (0x4200000000000000000000000000000000000006, 0x7f5c764cbc14f9669b88837ca1490cca17c31607, 0x4200000000000000000000000000000000000042, 0x0b2c639c533813f4aa9d7837caf62653d097ff85, 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58, - 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1) AND maker_amount IS NOT NULL + 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1) AND maker_amount IS NOT NULL THEN maker_amount - WHEN taker_token IN (0x4200000000000000000000000000000000000006, + WHEN taker_token IN (0x4200000000000000000000000000000000000006, 0x7f5c764cbc14f9669b88837ca1490cca17c31607, 0x4200000000000000000000000000000000000042, 0x0b2c639c533813f4aa9d7837caf62653d097ff85, 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58, - 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1) AND taker_amount IS NOT NULL + 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1) AND taker_amount IS NOT NULL THEN taker_amount ELSE COALESCE(maker_amount, taker_amount) END AS volume_usd, taker_token, maker_token, - CASE WHEN (varbinary_substring(taker,1,4) = 0x00000000) - OR taker IS NULL - OR taker = taker_token - OR taker = contract_address - OR taker = 0xdef1c0ded9bec7f1a1670819833240f027b25eff - OR varbinary_substring(taker_indicator_string, 18,20) != contract_address - THEN varbinary_substring(taker_indicator_string, 18,20) ELSE taker END AS taker, + taker, maker, tag, zid, @@ -296,7 +285,7 @@ results_usd AS ( (ARRAY[-1]) AS trace_address, 'settler' AS type, TRUE AS swap_flag, - -1 AS fills_within, + fills_within, contract_address FROM results diff --git a/dbt_subprojects/dex/models/_projects/zeroex/polygon/zeroex_polygon_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/polygon/zeroex_polygon_settler_trades.sql index c9b356c6953..baa3b8d9a07 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/polygon/zeroex_polygon_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/polygon/zeroex_polygon_settler_trades.sql @@ -24,7 +24,7 @@ WITH tbl_addresses AS ( WHERE contract_address = 0x00000000000004533fe15556b1e086bb1a72ceae AND blockchain = 'polygon' - and block_time > TIMESTAMP '2024-05-23' + and block_time > TIMESTAMP '2024-05-23' ), tbl_end_times AS ( @@ -52,7 +52,8 @@ settler_txs AS ( block_number, method_id, contract_address, - MAX(varbinary_substring(tracker,1,12)) AS zid, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, CASE WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) @@ -64,7 +65,8 @@ settler_txs AS ( block_time, "to" AS contract_address, varbinary_substring(input,1,4) AS method_id, - varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address FROM {{ source('polygon', 'traces') }} AS tr JOIN @@ -79,78 +81,62 @@ settler_txs AS ( {% endif %} ) GROUP BY - 1,2,3,4,5 + 1,2,3,4,5,6 ), +tbl_trades as ( -tbl_all_logs AS ( +with tbl_all_logs AS ( SELECT logs.tx_hash, logs.block_time, logs.block_number, - ROW_NUMBER() OVER (PARTITION BY logs.tx_hash ORDER BY index) rn_first, - index, - CASE - WHEN varbinary_substring(logs.topic2, 13, 20) = logs.tx_from THEN 1 - WHEN varbinary_substring(logs.topic1, 13, 20) = st.contract_address THEN 0 - WHEN FIRST_VALUE(logs.contract_address) OVER (PARTITION BY logs.tx_hash ORDER BY index) = logs.contract_address THEN 0 - ELSE 1 - END maker_tkn, - bytearray_to_int256(bytearray_substring(DATA, 22,11)) value, - logs.contract_address AS token, - zid, - st.contract_address, + index, + case when ( (varbinary_substring(logs.topic2, 13, 20) = logs.tx_from) OR + (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or + topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) + then 1 end as valid, + bytearray_substring(logs.topic2,13,20) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, method_id, - tag + tag, + st.settler_address, + zid, + st.settler_address as contract_address FROM {{ source('polygon', 'logs') }} AS logs JOIN - settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + settler_txs st ON st.tx_hash = logs.tx_hash + AND logs.block_time = st.block_time + AND st.block_number = logs.block_number + AND ( (st.settler_address = bytearray_substring(logs.topic1,13,20)) + or (st.settler_address= bytearray_substring(logs.topic2,13,20)) + or logs.tx_from = bytearray_substring(logs.topic1,13,20) + or logs.tx_from = bytearray_substring(logs.topic2,13,20) + ) WHERE - topic0 IN (0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, - 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, - 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c) - and not(tag = 0x000000 and zid = 0xa00000000000000000000000) + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 {% if is_incremental() %} AND {{ incremental_predicate('logs.block_time') }} {% else %} AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by valid, index desc) rn + from tbl_all_logs + where taker_token != maker_token + ) + select * from tbl_valid_logs where rn = 1 ), -tbl_maker_token AS ( - SELECT - ROW_NUMBER() OVER (PARTITION BY tx_hash ORDER BY index DESC) rn_last, - token AS maker_token, - tx_hash, - block_time, - block_number, - index - FROM - tbl_all_logs - WHERE - maker_tkn = 1 -), - -tbl_trades AS ( - SELECT - ta.tx_hash, - ta.block_time, - ta.block_number, - zid, - method_id, - tag, - contract_address, - SUM(value) FILTER (WHERE rn_first = 1) AS taker_amount, - MAX(token) FILTER (WHERE rn_first = 1) AS taker_token, - SUM(value) FILTER (WHERE rn_last = 1) AS maker_amount, - MAX(maker_token) FILTER (WHERE rn_last = 1) AS maker_token - FROM - tbl_all_logs ta - LEFT JOIN - tbl_maker_token mkr ON ta.tx_hash = mkr.tx_hash AND ta.block_time = mkr.block_time AND ta.block_number = mkr.block_number AND ta.index = mkr.index AND mkr.rn_last = 1 - GROUP BY - 1,2,3,4,5,6,7 -), tokens AS ( SELECT DISTINCT @@ -179,6 +165,33 @@ prices AS ( {% endif %} ), +fills as ( + with signatures as ( + select distinct signature + from {{ source('polygon', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SellpolygonToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('polygon', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + results AS ( SELECT trades.block_time, @@ -189,23 +202,8 @@ results AS ( trades.tx_hash, "from" AS tx_from, "to" AS tx_to, - index AS tx_index, - CASE - WHEN varbinary_substring(data,17,10) != 0x00000000000000000000 AND varbinary_substring(data,17,1) != 0x THEN varbinary_substring(data,17,20) - WHEN varbinary_substring(data,177,10) != 0x00000000000000000000 THEN varbinary_substring(data,177,20) - WHEN varbinary_substring(data,277,10) != 0x00000000000000000000 THEN varbinary_substring(data,277,20) - WHEN varbinary_substring(data,629,10) != 0x00000000000000000000 THEN varbinary_substring(data,629,20) - WHEN varbinary_substring(data,693,10) != 0x00000000000000000000 THEN varbinary_substring(data,693,20) - WHEN varbinary_substring(data,917,10) != 0x00000000000000000000 THEN varbinary_substring(data,917,20) - WHEN varbinary_substring(data,949,10) != 0x00000000000000000000 THEN varbinary_substring(data,949,20) - WHEN varbinary_substring(data,981,10) != 0x00000000000000000000 THEN varbinary_substring(data,981,20) - WHEN varbinary_substring(data,1013,10) != 0x00000000000000000000 THEN varbinary_substring(data,1013,20) - WHEN varbinary_substring(data,1141,10) != 0x00000000000000000000 THEN varbinary_substring(data,1141,20) - WHEN varbinary_substring(data,1273,10) != 0x00000000000000000000 THEN varbinary_substring(data,1273,20) - WHEN varbinary_substring(data,1749,4) != 0x00000000 THEN varbinary_substring(data,1749,20) - WHEN varbinary_substring(data,1049,4) != 0x00000000 THEN varbinary_substring(data,1049,20) - WHEN varbinary_substring(data,17,4) != 0x00000000 THEN varbinary_substring(data,17,20) - END AS taker , + trades.index AS tx_index, + taker , CAST(NULL AS varbinary) AS maker, taker_token, pt.price, @@ -219,16 +217,13 @@ results AS ( maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, tag, - data, - varbinary_substring(data, varbinary_length(data) - CASE - WHEN varbinary_position (data,0xc4103b48be) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xc4103b48be)) - WHEN varbinary_position (data,0xe48d68a156) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe48d68a156)) - WHEN varbinary_position (data,0xe422ce6ede) <> 0 THEN varbinary_position(REVERSE(data), REVERSE(0xe422ce6ede)) - END -3, 37) taker_indicator_string + fills_within FROM tbl_trades trades JOIN {{ source('polygon', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number LEFT JOIN tokens tt ON tt.blockchain = 'polygon' AND tt.contract_address = taker_token LEFT JOIN @@ -249,7 +244,7 @@ results AS ( results_usd AS ( SELECT 'polygon' AS blockchain, - '0x API' AS project, + '0x-API' AS project, 'settler' AS version, DATE_TRUNC('day', block_time) block_date, DATE_TRUNC('month', block_time) AS block_month, @@ -261,31 +256,25 @@ results_usd AS ( maker_token_amount, taker_token_amount_raw, maker_token_amount_raw, - CASE WHEN maker_token IN (0x2791bca1f2de4661ed88a30c99a7a9449aa84174, + CASE WHEN maker_token IN (0x2791bca1f2de4661ed88a30c99a7a9449aa84174, 0x7ceb23fd6bc0add59e62ac25578270cff1b9f619, 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270, 0xc2132d05d31c914a87c6611c10748aeb04b58e8f, 0x3c499c542cef5e3811e1192ce70d8cc03d5c3359, - 0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6) AND maker_amount IS NOT NULL + 0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6) AND maker_amount IS NOT NULL THEN maker_amount - WHEN taker_token IN (0x2791bca1f2de4661ed88a30c99a7a9449aa84174, + WHEN taker_token IN (0x2791bca1f2de4661ed88a30c99a7a9449aa84174, 0x7ceb23fd6bc0add59e62ac25578270cff1b9f619, 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270, 0xc2132d05d31c914a87c6611c10748aeb04b58e8f, 0x3c499c542cef5e3811e1192ce70d8cc03d5c3359, - 0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6) AND taker_amount IS NOT NULL + 0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6) AND taker_amount IS NOT NULL THEN taker_amount ELSE COALESCE(maker_amount, taker_amount) END AS volume_usd, taker_token, maker_token, - CASE WHEN (varbinary_substring(taker,1,4) = 0x00000000) - OR taker IS NULL - OR taker = taker_token - OR taker = contract_address - OR taker = 0xdef1c0ded9bec7f1a1670819833240f027b25eff - OR varbinary_substring(taker_indicator_string, 18,20) != contract_address - THEN varbinary_substring(taker_indicator_string, 18,20) ELSE taker END AS taker, + taker, maker, tag, zid, @@ -296,7 +285,7 @@ results_usd AS ( (ARRAY[-1]) AS trace_address, 'settler' AS type, TRUE AS swap_flag, - -1 AS fills_within, + fills_within, contract_address FROM results From c3d29f8cb0183d563f4a4bcdcab1ccd2c31b2f6f Mon Sep 17 00:00:00 2001 From: hildobby Date: Wed, 18 Sep 2024 18:07:18 +0200 Subject: [PATCH 041/127] tag new blobbers (#6746) --- .../models/_sector/blobs/ethereum/blobs_submitters.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql index d15eb34a8b5..b9dea9a8c9b 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/blobs/ethereum/blobs_submitters.sql @@ -30,6 +30,7 @@ SELECT address , (0xe1b64045351b0b6e9821f19b39f81bc4711d2230, 'Boba Network', 'bobanetwork') , (0x08f9f14ff43e112b18c96f0986f28cb1878f1d11, 'Camp Network', 'Camp_L2') , (0x5ead389b57d533a94a0eacd570dc1cc59c25f2d4, 'Parallel', 'ParallelFi') + , (0x40acdc94a00b33151b40763b3fed7c46ff639df4, 'Parallel', 'ParallelFi') , (0xcf2898225ed05be911d3709d9417e86e0b4cfc8f, 'Scroll', 'Scroll_ZKP') , (0xa6ea2f3299b63c53143c993d2d5e60a69cd6fe24, 'Lisk', 'LiskHQ') , (0x3d0bf26e60a689a7da5ea3ddad7371f27f7671a5, 'Optopia', 'Optopia_AI') @@ -59,4 +60,7 @@ SELECT address , (0xde794bec196832474f2f218135bfd0f7ca7fb038, 'Swan Chain', 'swan_chain') , (0x67a44ce38627f46f20b1293960559ed85dd194f1, 'Polynomial', 'PolynomialFi') , (0x060b915ca4904b56ada63565626b9c97f6cad212, 'SNAXchain', 'synthetix_io') + , (0x65115c6d23274e0a29a63b69130efe901aa52e7a, 'Hemi Network', 'hemi_xyz') + , (0x43ca061ea80fbb4a2b5515f4be4e953b191147af, 'Ethernity', 'EthernityChain') + , (0xee12c640b0793cf514e42ea1c428bd5399545d4d, 'MetaMail', 'MetaMailInk') ) AS x(address, entity, x_username) \ No newline at end of file From d009f88c737305f45a441ac7bbfe398450443b56 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Wed, 18 Sep 2024 13:08:37 -0300 Subject: [PATCH 042/127] add beethoven x and jelly swap to pools_metrics_daily pt. 2 (#6729) * Update labels_balancer_v2_pools_polygon.sql * rerun * fix typo --- .../models/_sector/dex/pools/dex_pools_metrics_daily.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/daily_spellbook/models/_sector/dex/pools/dex_pools_metrics_daily.sql b/dbt_subprojects/daily_spellbook/models/_sector/dex/pools/dex_pools_metrics_daily.sql index 94423f60d12..8a893d7096d 100644 --- a/dbt_subprojects/daily_spellbook/models/_sector/dex/pools/dex_pools_metrics_daily.sql +++ b/dbt_subprojects/daily_spellbook/models/_sector/dex/pools/dex_pools_metrics_daily.sql @@ -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') ] %} From ff5622a8b8f371a8459b11add84fb98eca526d0e Mon Sep 17 00:00:00 2001 From: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:35:12 +0200 Subject: [PATCH 043/127] `dex.trades`: add HOT-AMM support (#6726) * dex.trades: add hot-amm support * arbitrum * arbitrum sources * arbitrum sources * fix: no duplicates * remove erc20 dependency * add dex info for valantis * style: naming convention --- .../_project/valantis_compatible_trades.sql | 52 ++++++++ dbt_subprojects/dex/models/dex_info.sql | 3 +- .../dex/models/trades/arbitrum/_schema.yml | 117 +++++++++--------- .../arbitrum/dex_arbitrum_base_trades.sql | 1 + .../valantis_hot_arbitrum_base_trades.sql | 21 ++++ .../dex/models/trades/ethereum/_schema.yml | 86 +++++++------ .../ethereum/dex_ethereum_base_trades.sql | 1 + .../valantis_hot_ethereum_base_trades.sql | 21 ++++ dbt_subprojects/dex/package-lock.yml | 2 +- models/README.md | 2 +- .../_sector/dex/trades/arbitrum/_sources.yml | 5 + .../_sector/dex/trades/ethereum/_sources.yml | 5 + 12 files changed, 213 insertions(+), 103 deletions(-) create mode 100644 dbt_subprojects/dex/macros/models/_project/valantis_compatible_trades.sql create mode 100644 dbt_subprojects/dex/models/trades/arbitrum/platforms/valantis_hot_arbitrum_base_trades.sql create mode 100644 dbt_subprojects/dex/models/trades/ethereum/platforms/valantis_hot_ethereum_base_trades.sql diff --git a/dbt_subprojects/dex/macros/models/_project/valantis_compatible_trades.sql b/dbt_subprojects/dex/macros/models/_project/valantis_compatible_trades.sql new file mode 100644 index 00000000000..a447ff4dbaa --- /dev/null +++ b/dbt_subprojects/dex/macros/models/_project/valantis_compatible_trades.sql @@ -0,0 +1,52 @@ +{% macro valantis_compatible_hot_trades( + blockchain = null + , project = null + , version = null + , HOT_evt_Swap = null + , Pair_evt_Swap = null + , Factory_evt_PoolCreated = null + ) +%} +WITH dexs AS +( + SELECT distinct t.evt_block_number AS block_number + , t.evt_block_time AS block_time + , t.amountOut AS token_bought_amount_raw + , t.amountIn AS token_sold_amount_raw + , CASE WHEN t.isZeroToOne THEN f.token1 ELSE f.token0 END AS token_bought_address + , CASE WHEN t.isZeroToOne THEN f.token0 ELSE f.token1 END AS token_sold_address + , t.sender AS taker + , coalesce(h.contract_address, t.contract_address) AS maker -- HOT for HOTSwaps (solver orders), SovereignPool for AMM swaps (permissionless) + , t.contract_address AS project_contract_address + , t.evt_tx_hash AS tx_hash + , t.evt_index AS evt_index + FROM {{ Pair_evt_Swap }} AS t + INNER JOIN {{ Factory_evt_PoolCreated }} AS f + ON t.contract_address = f.pool + LEFT JOIN {{ HOT_evt_Swap }} AS h + ON t.evt_block_number = h.evt_block_number AND t.evt_tx_hash = h.evt_tx_hash AND t.evt_index = h.evt_index + 3 + {% if is_incremental() %} + WHERE + {{ incremental_predicate('t.evt_block_time') }} + {% endif %} +) + +SELECT '{{ blockchain }}' AS blockchain + , '{{ project }}' AS project + , '{{ version }}' AS version + , CAST(date_trunc('month', dexs.block_time) AS date) AS block_month + , CAST(date_trunc('day', dexs.block_time) AS date) AS block_date + , dexs.block_time + , dexs.block_number + , dexs.token_bought_amount_raw + , dexs.token_sold_amount_raw + , dexs.token_bought_address + , dexs.token_sold_address + , dexs.taker + , dexs.maker + , dexs.project_contract_address + , dexs.tx_hash + , dexs.evt_index +FROM + dexs +{% endmacro %} diff --git a/dbt_subprojects/dex/models/dex_info.sql b/dbt_subprojects/dex/models/dex_info.sql index de7794146ad..a1285e50814 100644 --- a/dbt_subprojects/dex/models/dex_info.sql +++ b/dbt_subprojects/dex/models/dex_info.sql @@ -134,7 +134,7 @@ FROM (VALUES , ('scrollswap', 'ScrollSwap', 'Direct', 'scrollswap') , ('auragi', 'Auragi', 'Direct', 'AuragiFinance') , ('soswap','Soswap','Direct','RaiFinance') - , ('elk_finance', 'Elk Finance', 'Direct', 'Elk Finance') + , ('elk_finance', 'Elk Finance', 'Direct', 'Elk Finance') , ('leetswap', 'Leetswap', 'Direct', 'LeetSwap') , ('rocketswap', 'RocketSwap', 'Direct', 'RocketSwap_Labs') , ('alienbase', 'AlienBase', 'Direct', 'alienbasedex') @@ -171,4 +171,5 @@ FROM (VALUES , ('fusionx', 'FusionX Finance', 'Direct', 'FusionX_Finance') , ('agni', 'AGNI Finance', 'Direct', 'Agnidex') , ('rcpswap', 'RCPswap', 'Direct', 'RCPswap') + , ('valantis', 'Valantis', 'Direct', 'ValantisLabs') ) AS temp_table (project, name, marketplace_type, x_username) diff --git a/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml b/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml index c0a633227c5..f9512d958fa 100644 --- a/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml +++ b/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml @@ -12,7 +12,7 @@ models: project: uniswap contributors: jeff-dude, masquot, soispoke, mtitus6 config: - tags: [ 'arbitrum', 'dex', 'trades', 'uniswap', 'v3' ] + tags: ["arbitrum", "dex", "trades", "uniswap", "v3"] description: "uniswap arbitrum v3 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -31,7 +31,7 @@ models: project: uniswap contributors: Henrystats config: - tags: [ 'arbitrum', 'dex', 'trades', 'uniswap', 'v2' ] + tags: ["arbitrum", "dex", "trades", "uniswap", "v2"] description: "uniswap arbitrum v2 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -50,7 +50,7 @@ models: project: sushiswap contributors: Henrystats, tomfutago config: - tags: ['arbitrum', 'dex', 'trades', 'sushiswap', 'v1'] + tags: ["arbitrum", "dex", "trades", "sushiswap", "v1"] description: "Sushiswap arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -62,7 +62,6 @@ models: filter: version: 1 - - name: sushiswap_v2_arbitrum_base_trades meta: blockchain: arbitrum @@ -70,7 +69,7 @@ models: project: sushiswap contributors: tomfutago config: - tags: ['arbitrum', 'dex', 'trades', 'sushiswap', 'v2'] + tags: ["arbitrum", "dex", "trades", "sushiswap", "v2"] description: "Sushiswap arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -82,7 +81,6 @@ models: filter: version: 2 - - name: airswap_arbitrum_base_trades meta: blockchain: arbitrum @@ -90,7 +88,7 @@ models: project: airswap contributors: tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'airswap' ] + tags: ["arbitrum", "dex", "trades", "airswap"] description: "Airswap arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -100,7 +98,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('airswap_arbitrum_base_trades_seed') - - name: camelot_v2_arbitrum_base_trades meta: blockchain: arbitrum @@ -108,7 +105,7 @@ models: project: camelot contributors: ytoast, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'camelot', 'uniswap', 'v2' ] + tags: ["arbitrum", "dex", "trades", "camelot", "uniswap", "v2"] description: "Camelot Arbitrum v2 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -120,7 +117,6 @@ models: filter: version: 2 - - name: camelot_v3_arbitrum_base_trades meta: blockchain: arbitrum @@ -128,7 +124,7 @@ models: project: camelot contributors: whale_hunter, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'camelot', 'uniswap', 'v3' ] + tags: ["arbitrum", "dex", "trades", "camelot", "uniswap", "v3"] description: "Camelot Arbitrum v2 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -140,7 +136,6 @@ models: filter: version: 3 - - name: arbswap_arbitrum_base_trades meta: blockchain: arbitrum @@ -148,7 +143,7 @@ models: project: arbswap contributors: chrispearcx, hosuke, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'arbswap' ] + tags: ["arbitrum", "dex", "trades", "arbswap"] description: "Arbswap arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -158,7 +153,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('arbswap_arbitrum_base_trades_seed') - - name: trader_joe_v2_arbitrum_base_trades meta: blockchain: arbitrum @@ -166,7 +160,7 @@ models: project: trader_joe contributors: hsrvc, pecio222, hosuke config: - tags: [ 'arbitrum', 'dex', 'trades', 'trader_joe', 'v2' ] + tags: ["arbitrum", "dex", "trades", "trader_joe", "v2"] description: "Trader Joe arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -178,7 +172,6 @@ models: filter: version: 2 - - name: trader_joe_v2_1_arbitrum_base_trades meta: blockchain: arbitrum @@ -186,7 +179,7 @@ models: project: trader_joe contributors: chef_seaweed config: - tags: [ 'arbitrum', 'dex', 'trades', 'trader_joe', 'v2.1' ] + tags: ["arbitrum", "dex", "trades", "trader_joe", "v2.1"] description: "Trader Joe arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -205,7 +198,7 @@ models: project: trader_joe contributors: chef_seaweed config: - tags: [ 'arbitrum', 'dex', 'trades', 'trader_joe', 'v2.2' ] + tags: ["arbitrum", "dex", "trades", "trader_joe", "v2.2"] description: "Trader Joe arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -217,7 +210,6 @@ models: filter: version: 2.2 - - name: pancakeswap_v2_arbitrum_base_trades meta: blockchain: arbitrum @@ -225,7 +217,7 @@ models: project: pancakeswap contributors: chef_seaweed, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'pancakeswap', 'uniswap', 'v2' ] + tags: ["arbitrum", "dex", "trades", "pancakeswap", "uniswap", "v2"] description: "Pancakeswap Arbitrum v2 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -239,7 +231,6 @@ models: - 2 - stableswap - - name: balancer_v2_arbitrum_base_trades meta: blockchain: arbitrum @@ -247,7 +238,7 @@ models: project: balancer contributors: bizzyvinci, thetroyharris, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'balancer' ] + tags: ["arbitrum", "dex", "trades", "balancer"] description: "Balancer v2 arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -259,7 +250,6 @@ models: filter: version: 2 - - name: pancakeswap_v3_arbitrum_base_trades meta: blockchain: arbitrum @@ -267,7 +257,7 @@ models: project: pancakeswap contributors: chef_seaweed, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'pancakeswap', 'uniswap', 'v3' ] + tags: ["arbitrum", "dex", "trades", "pancakeswap", "uniswap", "v3"] description: "Pancakeswap Arbitrum v3 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -279,7 +269,6 @@ models: filter: version: 3 - - name: dodo_arbitrum_base_trades meta: blockchain: arbitrum @@ -287,7 +276,7 @@ models: project: dodo contributors: owen05, scoffie, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'dodo' ] + tags: ["arbitrum", "dex", "trades", "dodo"] description: "Dodo Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -303,7 +292,6 @@ models: - 2_dpp - 2_dsp - - name: gmx_arbitrum_base_trades meta: blockchain: arbitrum @@ -311,7 +299,7 @@ models: project: gmx contributors: chef_seaweed, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'gmx' ] + tags: ["arbitrum", "dex", "trades", "gmx"] description: "GMX Arbitrum v3 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -321,7 +309,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('gmx_arbitrum_base_trades_seed') - - name: integral_arbitrum_base_trades meta: blockchain: arbitrum @@ -329,7 +316,7 @@ models: project: integral contributors: integralhq, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'integral', 'uniswap', 'v2' ] + tags: ["arbitrum", "dex", "trades", "integral", "uniswap", "v2"] description: "Integral Arbitrum v3 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -339,7 +326,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('integral_arbitrum_base_trades_seed') - - name: clipper_arbitrum_base_trades meta: blockchain: arbitrum @@ -347,7 +333,7 @@ models: project: clipper contributors: 0xRob, amalashkevich, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'clipper' ] + tags: ["arbitrum", "dex", "trades", "clipper"] description: "clipper Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -363,7 +349,6 @@ models: - 1 - 2 - - name: kyberswap_arbitrum_base_trades meta: blockchain: arbitrum @@ -371,7 +356,7 @@ models: project: kyberswap contributors: ppclunghe, gregshestakovlido, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'kyberswap', 'uniswap', 'v2' ] + tags: ["arbitrum", "dex", "trades", "kyberswap", "uniswap", "v2"] description: "kyberswap Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -386,7 +371,6 @@ models: - elastic - elastic_2 - - name: xchange_arbitrum_base_trades meta: blockchain: arbitrum @@ -394,7 +378,7 @@ models: project: xchange contributors: mike-x7f, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'xchange', 'uniswap', 'v2' ] + tags: ["arbitrum", "dex", "trades", "xchange", "uniswap", "v2"] description: "xchange Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -404,7 +388,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('xchange_arbitrum_base_trades_seed') - - name: ramses_arbitrum_base_trades meta: blockchain: arbitrum @@ -412,7 +395,7 @@ models: project: ramses contributors: echovl, discochuck config: - tags: [ 'arbitrum', 'dex', 'trades', 'ramses', 'uniswap', 'v2' ] + tags: ["arbitrum", "dex", "trades", "ramses", "uniswap", "v2"] description: "Ramses Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -433,7 +416,7 @@ models: project: fraxswap contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'fraxswap' ] + tags: ["arbitrum", "dex", "trades", "fraxswap"] description: "Fraxswap arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -450,7 +433,7 @@ models: project: chronos contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'chronos'] + tags: ["arbitrum", "dex", "trades", "chronos"] description: "Chronos arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -467,7 +450,7 @@ models: project: zyberswap contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'zyberswap'] + tags: ["arbitrum", "dex", "trades", "zyberswap"] description: "Zyberswap arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -484,7 +467,7 @@ models: project: solidlizard contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'solidlizard'] + tags: ["arbitrum", "dex", "trades", "solidlizard"] description: "Solidlizard arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -494,7 +477,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('solidlizard_arbitrum_base_trades_seed') - - name: rubicon_arbitrum_base_trades meta: blockchain: arbitrum @@ -502,7 +484,7 @@ models: project: rubicon contributors: denver, tomfutago config: - tags: [ 'arbitrum', 'dex', 'trades', 'rubicon' ] + tags: ["arbitrum", "dex", "trades", "rubicon"] description: "rubicon Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -519,7 +501,7 @@ models: project: woofi contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'woofi'] + tags: ["arbitrum", "dex", "trades", "woofi"] description: "woofi Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -536,7 +518,7 @@ models: project: smardex contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'smardex'] + tags: ["arbitrum", "dex", "trades", "smardex"] description: "smardex Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -553,7 +535,7 @@ models: project: oasisswap contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'oasisswap'] + tags: ["arbitrum", "dex", "trades", "oasisswap"] description: "oasisswap Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -570,7 +552,7 @@ models: project: swaap contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'swaap', 'v2'] + tags: ["arbitrum", "dex", "trades", "swaap", "v2"] description: "swaap v2 arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -589,7 +571,7 @@ models: project: apeswap contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'apeswap'] + tags: ["arbitrum", "dex", "trades", "apeswap"] description: "apeswap Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -606,9 +588,9 @@ models: pproject: zigzag contributors: jeff-dude, masquot, soispoke, mtitus6, hosuke config: - tags: [ 'arbitrum','trades', 'zigzag','dex' ] + tags: ["arbitrum", "trades", "zigzag", "dex"] description: > - Zigzag V1 contract trades on Arbitrum + Zigzag V1 contract trades on Arbitrum tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: @@ -624,7 +606,7 @@ models: project: gridex contributors: LLDAO config: - tags: [ 'arbitrum', 'dex', 'trades', 'gridex'] + tags: ["arbitrum", "dex", "trades", "gridex"] description: "gridex Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -641,7 +623,7 @@ models: project: sterling_finance contributors: ARDev097 config: - tags: [ 'arbitrum', 'dex', 'trades', 'sterling_finance'] + tags: ["arbitrum", "dex", "trades", "sterling_finance"] description: "sterling_finance Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -658,7 +640,7 @@ models: project: sharkyswap contributors: ARDev097 config: - tags: [ 'arbitrum', 'dex', 'trades', 'sharkyswap'] + tags: ["arbitrum", "dex", "trades", "sharkyswap"] description: "sharkyswap Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -675,7 +657,7 @@ models: project: auragi contributors: archie config: - tags: [ 'arbitrum', 'dex', 'trades', 'auragi'] + tags: ["arbitrum", "dex", "trades", "auragi"] description: "auragi Arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -692,7 +674,7 @@ models: project: wombatexchange contributors: config: - tags: [ 'arbitrum', 'dex', 'trades', 'wombat_exchange' ] + tags: ["arbitrum", "dex", "trades", "wombat_exchange"] description: "wombatexchange arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -709,7 +691,7 @@ models: project: solidly contributors: SolidlyLabs config: - tags: [ 'arbitrum', 'dex', 'trades', 'solidly' ] + tags: ["arbitrum", "dex", "trades", "solidly"] description: "solidly v3 arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -726,7 +708,7 @@ models: project: dackieswap contributors: blanchemaria6 config: - tags: [ 'arbitrum', 'dex', 'trades', 'dackieswap' ] + tags: ["arbitrum", "dex", "trades", "dackieswap"] description: "dackieswap v3 arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -745,7 +727,7 @@ models: project: dackieswap contributors: blanchemaria6 config: - tags: [ 'arbitrum', 'dex', 'trades', 'dackieswap' ] + tags: ["arbitrum", "dex", "trades", "dackieswap"] description: "dackieswap v2 arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -764,7 +746,7 @@ models: project: maverick contributors: get620v config: - tags: [ 'arbitrum', 'dex', 'trades', 'maverick' ] + tags: ["arbitrum", "dex", "trades", "maverick"] description: "Maverick arbitrum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -775,3 +757,18 @@ models: seed_file: ref('maverick_arbitrum_base_trades_seed') filter: version: 2 + + - name: valantis_hot_arbitrum_base_trades + meta: + blockchain: arbitrum + sector: dex + project: valantis + contributors: 0xrusowsky + config: + tags: ["arbitrum", "dex", "trades", "valantis", "arrakis", "hot"] + description: "hot-amm arbitrum base trades" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index diff --git a/dbt_subprojects/dex/models/trades/arbitrum/dex_arbitrum_base_trades.sql b/dbt_subprojects/dex/models/trades/arbitrum/dex_arbitrum_base_trades.sql index 9416f1cd8bd..2c37cfcd91f 100644 --- a/dbt_subprojects/dex/models/trades/arbitrum/dex_arbitrum_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/arbitrum/dex_arbitrum_base_trades.sql @@ -47,6 +47,7 @@ , ref('dackieswap_v3_arbitrum_base_trades') , ref('dackieswap_v2_arbitrum_base_trades') , ref('maverick_v2_arbitrum_base_trades') + , ref('valantis_hot_arbitrum_base_trades') ] %} WITH base_union AS ( diff --git a/dbt_subprojects/dex/models/trades/arbitrum/platforms/valantis_hot_arbitrum_base_trades.sql b/dbt_subprojects/dex/models/trades/arbitrum/platforms/valantis_hot_arbitrum_base_trades.sql new file mode 100644 index 00000000000..975dad4172c --- /dev/null +++ b/dbt_subprojects/dex/models/trades/arbitrum/platforms/valantis_hot_arbitrum_base_trades.sql @@ -0,0 +1,21 @@ +{{ config( + schema = 'valantis_hot_arbitrum' + , alias = 'base_trades' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['tx_hash', 'evt_index'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + valantis_compatible_hot_trades( + blockchain = 'arbitrum', + project = 'valantis', + version = 'hot', + HOT_evt_Swap = source('valantis_arbitrum', 'HOT_evt_HotSwap'), + Pair_evt_Swap = source('valantis_arbitrum', 'SovereignPool_evt_Swap'), + Factory_evt_PoolCreated = source('valantis_arbitrum', 'ProtocolFactory_evt_SovereignPoolDeployed') + ) +}} diff --git a/dbt_subprojects/dex/models/trades/ethereum/_schema.yml b/dbt_subprojects/dex/models/trades/ethereum/_schema.yml index fba051b0a13..3acacaca364 100644 --- a/dbt_subprojects/dex/models/trades/ethereum/_schema.yml +++ b/dbt_subprojects/dex/models/trades/ethereum/_schema.yml @@ -12,7 +12,7 @@ models: project: uniswap contributors: jeff-dude, masquot, soispoke, hosuke config: - tags: [ 'ethereum', 'dex', 'trades', 'uniswap', 'v1'] + tags: ["ethereum", "dex", "trades", "uniswap", "v1"] description: "uniswap ethereum v1 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -31,7 +31,7 @@ models: project: uniswap contributors: jeff-dude, masquot, soispoke, hosuke config: - tags: [ 'ethereum', 'dex', 'trades', 'uniswap', 'v2' ] + tags: ["ethereum", "dex", "trades", "uniswap", "v2"] description: "uniswap ethereum v2 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -50,7 +50,7 @@ models: project: uniswap contributors: jeff-dude, masquot, soispoke, hosuke config: - tags: [ 'ethereum', 'dex', 'trades', 'uniswap', 'v3' ] + tags: ["ethereum", "dex", "trades", "uniswap", "v3"] description: "uniswap ethereum v3 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -62,7 +62,6 @@ models: filter: version: 3 - - name: defiswap_ethereum_base_trades meta: blockchain: ethereum @@ -70,7 +69,7 @@ models: project: defiswap contributors: pandajackson42, 0xRob, hosuke config: - tags: [ 'ethereum', 'dex', 'trades', 'defiswap' ] + tags: ["ethereum", "dex", "trades", "defiswap"] description: "Defiswap ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -80,7 +79,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('defiswap_ethereum_base_trades_seed') - - name: airswap_ethereum_base_trades meta: blockchain: ethereum @@ -88,7 +86,7 @@ models: project: airswap contributors: hosuke, jeff-dude, ivigamberdiev, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'airswap' ] + tags: ["ethereum", "dex", "trades", "airswap"] description: "Defiswap ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -98,7 +96,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('airswap_ethereum_base_trades_seed') - - name: sushiswap_v1_ethereum_base_trades meta: blockchain: ethereum @@ -106,7 +103,7 @@ models: project: sushiswap contributors: pandajackson42, 0xRob, hosuke, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'sushiswap', 'v1' ] + tags: ["ethereum", "dex", "trades", "sushiswap", "v1"] description: "sushiswap ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -118,7 +115,6 @@ models: filter: version: 1 - - name: sushiswap_v2_ethereum_base_trades meta: blockchain: ethereum @@ -126,7 +122,7 @@ models: project: sushiswap contributors: pandajackson42, 0xRob, hosuke, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'sushiswap', 'v2' ] + tags: ["ethereum", "dex", "trades", "sushiswap", "v2"] description: "sushiswap ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -138,7 +134,6 @@ models: filter: version: 2 - - name: carbon_defi_ethereum_base_trades meta: blockchain: ethereum @@ -146,7 +141,7 @@ models: project: carbon_defi contributors: tiagofilipenunes, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'carbon_defi' ] + tags: ["ethereum", "dex", "trades", "carbon_defi"] description: "Carbon_defi ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -156,7 +151,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('carbon_defi_ethereum_base_trades_seed') - - name: apeswap_ethereum_base_trades meta: blockchain: ethereum @@ -164,7 +158,7 @@ models: project: apeswap contributors: hosuke config: - tags: [ 'ethereum', 'dex', 'trades', 'apeswap' ] + tags: ["ethereum", "dex", "trades", "apeswap"] description: apeswap base trades tests: - dbt_utils.unique_combination_of_columns: @@ -181,7 +175,7 @@ models: project: pancakeswap contributors: chef_seaweed, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'pancakeswap', 'uniswap', 'v2' ] + tags: ["ethereum", "dex", "trades", "pancakeswap", "uniswap", "v2"] description: "Pancakeswap Ethereum v2 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -202,7 +196,7 @@ models: project: shibaswap contributors: 0xRob, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'shibaswap', 'uniswap', 'v2' ] + tags: ["ethereum", "dex", "trades", "shibaswap", "uniswap", "v2"] description: "sushiswap ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -221,7 +215,7 @@ models: project: pancakeswap contributors: chef_seaweed, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'pancakeswap', 'uniswap', 'v3' ] + tags: ["ethereum", "dex", "trades", "pancakeswap", "uniswap", "v3"] description: "Pancakeswap Ethereum v3 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -240,7 +234,7 @@ models: project: balancer contributors: bizzyvinci, thetroyharris, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'balancer' ] + tags: ["ethereum", "dex", "trades", "balancer"] description: "Balancer v1 ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -259,7 +253,7 @@ models: project: balancer contributors: bizzyvinci, thetroyharris, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'balancer' ] + tags: ["ethereum", "dex", "trades", "balancer"] description: "Balancer v2 ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -278,7 +272,7 @@ models: project: fraxswap contributors: kndlexi, tomfutago config: - tags: ['ethereum', 'dex', 'trades', 'fraxswap', 'uniswap', 'v2'] + tags: ["ethereum", "dex", "trades", "fraxswap", "uniswap", "v2"] description: "Fraxswap ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -297,7 +291,7 @@ models: project: bancor contributors: tian7, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'bancor' ] + tags: ["ethereum", "dex", "trades", "bancor"] description: "Bancor ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -314,7 +308,7 @@ models: project: verse_dex contributors: Henrystats, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'verse_dex' ] + tags: ["ethereum", "dex", "trades", "verse_dex"] description: "Verse ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -331,7 +325,7 @@ models: project: swapr contributors: cryptoleishen, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'swapr', 'uniswap', 'v2' ] + tags: ["ethereum", "dex", "trades", "swapr", "uniswap", "v2"] description: "Verse ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -348,7 +342,7 @@ models: project: mauve contributors: jeff-dude, masquot, soispoke, raphaelr, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'mauve' ] + tags: ["ethereum", "dex", "trades", "mauve"] description: "Mauve ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -365,7 +359,7 @@ models: project: dfx contributors: Henrystats, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'dfx' ] + tags: ["ethereum", "dex", "trades", "dfx"] description: "DFX ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -382,7 +376,7 @@ models: project: dodo contributors: owen05, scoffie, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'dodo' ] + tags: ["ethereum", "dex", "trades", "dodo"] description: "Dodo ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -398,7 +392,6 @@ models: - 2_dpp - 2_dsp - - name: integral_ethereum_base_trades meta: blockchain: ethereum @@ -406,7 +399,7 @@ models: project: integral contributors: integralhq, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'integral', 'uniswap', 'v2' ] + tags: ["ethereum", "dex", "trades", "integral", "uniswap", "v2"] description: "Integral ethereum v3 base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -416,7 +409,6 @@ models: - check_dex_base_trades_seed: seed_file: ref('integral_ethereum_base_trades_seed') - - name: maverick_ethereum_base_trades meta: blockchain: ethereum @@ -424,7 +416,7 @@ models: project: maverick contributors: get620v, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'maverick' ] + tags: ["ethereum", "dex", "trades", "maverick"] description: "Maverick ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -443,7 +435,7 @@ models: project: maverick contributors: get620v config: - tags: [ 'ethereum', 'dex', 'trades', 'maverick' ] + tags: ["ethereum", "dex", "trades", "maverick"] description: "Maverick ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -462,7 +454,7 @@ models: project: clipper contributors: 0xRob, amalashkevich, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'clipper' ] + tags: ["ethereum", "dex", "trades", "clipper"] description: "clipper ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -478,7 +470,6 @@ models: - 3 - 4 - - name: mstable_ethereum_base_trades meta: blockchain: ethereum @@ -486,7 +477,7 @@ models: project: mstable contributors: ripple3, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'mstable' ] + tags: ["ethereum", "dex", "trades", "mstable"] description: "mstable ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -507,7 +498,7 @@ models: project: kyberswap contributors: ppclunghe, gregshestakovlido, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'kyberswap', 'uniswap', 'v2' ] + tags: ["ethereum", "dex", "trades", "kyberswap", "uniswap", "v2"] description: "kyberswap ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -529,7 +520,7 @@ models: project: xchange contributors: mike-x7f, tomfutago config: - tags: [ 'ethereum', 'dex', 'trades', 'xchange', 'uniswap', 'v2' ] + tags: ["ethereum", "dex", "trades", "xchange", "uniswap", "v2"] description: "xchange ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -546,7 +537,7 @@ models: project: curve contributors: dsalv, yulesa, ilemi, jeff-dude, tomfutago config: - tags: ['ethereum', 'dex', 'trades', 'curve'] + tags: ["ethereum", "dex", "trades", "curve"] description: "Curve ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -571,7 +562,7 @@ models: project: solidly contributors: SolidlyLabs config: - tags: [ 'ethereum', 'dex', 'trades', 'solidly' ] + tags: ["ethereum", "dex", "trades", "solidly"] description: "solidly v3 ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -588,7 +579,7 @@ models: project: swaap contributors: borelien config: - tags: [ 'ethereum', 'dex', 'trades', 'swaap', 'v2'] + tags: ["ethereum", "dex", "trades", "swaap", "v2"] description: "swaap v2 ethereum base trades" tests: - dbt_utils.unique_combination_of_columns: @@ -599,3 +590,18 @@ models: seed_file: ref('swaap_ethereum_base_trades_seed') filter: version: 2 + + - name: valantis_hot_ethereum_base_trades + meta: + blockchain: ethereum + sector: dex + project: valantis + contributors: 0xrusowsky + config: + tags: ["ethereum", "dex", "trades", "valantis", "arrakis", "hot"] + description: "hot-amm ethereum base trades" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index diff --git a/dbt_subprojects/dex/models/trades/ethereum/dex_ethereum_base_trades.sql b/dbt_subprojects/dex/models/trades/ethereum/dex_ethereum_base_trades.sql index 24a983063ef..ef761a7d922 100644 --- a/dbt_subprojects/dex/models/trades/ethereum/dex_ethereum_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/ethereum/dex_ethereum_base_trades.sql @@ -37,6 +37,7 @@ , ref('curve_ethereum_base_trades') , ref('solidly_v3_ethereum_base_trades') , ref('swaap_v2_ethereum_base_trades') + , ref('valantis_hot_ethereum_base_trades') ] %} WITH base_union AS ( diff --git a/dbt_subprojects/dex/models/trades/ethereum/platforms/valantis_hot_ethereum_base_trades.sql b/dbt_subprojects/dex/models/trades/ethereum/platforms/valantis_hot_ethereum_base_trades.sql new file mode 100644 index 00000000000..ce491f4d00f --- /dev/null +++ b/dbt_subprojects/dex/models/trades/ethereum/platforms/valantis_hot_ethereum_base_trades.sql @@ -0,0 +1,21 @@ +{{ config( + schema = 'valantis_hot_ethereum' + , alias = 'base_trades' + , materialized = 'incremental' + , file_format = 'delta' + , incremental_strategy = 'merge' + , unique_key = ['tx_hash', 'evt_index'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +{{ + valantis_compatible_hot_trades( + blockchain = 'ethereum', + project = 'valantis', + version = 'hot', + HOT_evt_Swap = source('valantis_ethereum', 'HOT_evt_HotSwap'), + Pair_evt_Swap = source('valantis_ethereum', 'SovereignPool_evt_Swap'), + Factory_evt_PoolCreated = source('valantis_ethereum', 'ProtocolFactory_evt_SovereignPoolDeployed') + ) +}} diff --git a/dbt_subprojects/dex/package-lock.yml b/dbt_subprojects/dex/package-lock.yml index 9159e5ec7e2..52ef96dcd2e 100644 --- a/dbt_subprojects/dex/package-lock.yml +++ b/dbt_subprojects/dex/package-lock.yml @@ -1,4 +1,4 @@ packages: - package: dbt-labs/dbt_utils version: 1.3.0 -sha1_hash: e60f3271d7a9f853b7ff6316d14feb1341ef78ea +sha1_hash: 226ae69cdfbc9367e2aa2c472b01f99dbce11de0 diff --git a/models/README.md b/models/README.md index 2e6b8e0d193..bbfef11ed76 100644 --- a/models/README.md +++ b/models/README.md @@ -1 +1 @@ -All models live in [dbt_subprojects](../dbt_subprojects/), please continuing building in the proper subproject and refer to main [readme](../README.md) for more information. \ No newline at end of file +All models live in [dbt_subprojects](../dbt_subprojects/), please continuing building in the proper subproject and refer to main [readme](../README.md) for more information. diff --git a/sources/_sector/dex/trades/arbitrum/_sources.yml b/sources/_sector/dex/trades/arbitrum/_sources.yml index 05bf5e4e223..70ac7417282 100644 --- a/sources/_sector/dex/trades/arbitrum/_sources.yml +++ b/sources/_sector/dex/trades/arbitrum/_sources.yml @@ -157,3 +157,8 @@ sources: tables: - name: V2Pool_evt_PoolSwap - name: V2Factory_evt_PoolCreated + - name: valantis_arbitrum + tables: + - name: SovereignPool_evt_Swap + - name: ProtocolFactory_evt_SovereignPoolDeployed + - name: HOT_evt_HotSwap diff --git a/sources/_sector/dex/trades/ethereum/_sources.yml b/sources/_sector/dex/trades/ethereum/_sources.yml index f9cad75320b..c5811187634 100644 --- a/sources/_sector/dex/trades/ethereum/_sources.yml +++ b/sources/_sector/dex/trades/ethereum/_sources.yml @@ -120,3 +120,8 @@ sources: - name: swaap_v2_ethereum tables: - name: Vault_evt_Swap + - name: valantis_ethereum + tables: + - name: SovereignPool_evt_Swap + - name: ProtocolFactory_evt_SovereignPoolDeployed + - name: HOT_evt_HotSwap From da540b98e252e0c2b2963057d52c4f157271b651 Mon Sep 17 00:00:00 2001 From: mhmdriyadi <112420584+mhmdriyadi@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:40:18 +0700 Subject: [PATCH 044/127] Update prices_arbitrum_tokens.sql (#6747) --- .../tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql b/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql index fae0001a99b..b5715edd066 100644 --- a/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql @@ -226,5 +226,6 @@ FROM ('catch-spacecatch', 'arbitrum', 'CATCH', 0xf0a479c9c3378638ec603b8b6b0d75903902550b, 18), ('tap-taptoken', 'arbitrum', 'TAP', 0x2c650dab03a59332e2e0c0c4a7f726913e5028c1, 18), ('shibai-aishiba', 'arbitrum', 'SHIBAI', 0xfa296fca3c7dba4a92a42ec0b5e2138da3b29050, 6), - ('usdm-mountain-protocol-usd', 'arbitrum', 'USDM', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 18) + ('usdm-mountain-protocol-usd', 'arbitrum', 'USDM', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 18), + ('usdz-anzen-usdz', 'arbitrum', 'USDZ', 0x5018609ab477cc502e170a5accf5312b86a4b94f, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 9c7fc20ca1f59d672f39b3a6d657d2831700bd49 Mon Sep 17 00:00:00 2001 From: mhmdriyadi <112420584+mhmdriyadi@users.noreply.github.com> Date: Wed, 18 Sep 2024 23:55:32 +0700 Subject: [PATCH 045/127] Update prices_base_tokens.sql (#6748) Add USDZ token price --- .../tokens/models/prices/base/prices_base_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql index f031df3066a..b41a16f864f 100644 --- a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql @@ -166,5 +166,6 @@ FROM ('birddog-bird-dog-on-base','base','BIRDDOG',0x92af6f53febd6b4c6f5293840b6076a1b82c4bc2, 18), ('albert-albert-the-alien','base','ALBERT',0x0c067fc190cde145b0c537765a78d4e19873a5cc, 18), ('tn100x-tn100x','base','TN100X',0x5b5dee44552546ecea05edea01dcd7be7aa6144a, 18), - ('rdat-rdatadao','base','RDAT',0x4498cd8ba045e00673402353f5a4347562707e7d, 18) + ('rdat-rdatadao','base','RDAT',0x4498cd8ba045e00673402353f5a4347562707e7d, 18), + ('usdz-anzen-usdz', 'base', 'USDZ',0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 35336b2f18dae140185fd99a45d818a97d3fbc72 Mon Sep 17 00:00:00 2001 From: annieruth675 <128200894+annieruth675@users.noreply.github.com> Date: Thu, 19 Sep 2024 00:09:05 +0700 Subject: [PATCH 046/127] Update prices.usd to include USDz and bPEPE (#6750) --- .../tokens/models/prices/blast/prices_blast_tokens.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/blast/prices_blast_tokens.sql b/dbt_subprojects/tokens/models/prices/blast/prices_blast_tokens.sql index 2b884b332e7..e0f88963654 100644 --- a/dbt_subprojects/tokens/models/prices/blast/prices_blast_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/blast/prices_blast_tokens.sql @@ -20,5 +20,7 @@ FROM ('weth-weth', 'blast', 'bpETH', 0xb772d5c5f4a2eef67dfbc89aa658d2711341b8e5, 18), ('yolo-yolo-games','blast','YOLO',0xf77dd21c5ce38ac08786be35ef1d1dec1a6a15f3,18), ('blast-blast-token','blast','BLAST',0xb1a5700fa2358173fe465e6ea4ff52e36e88e2ad,18), - ('bag-bagwin','blast','BAG',0xb9dfcd4cf589bb8090569cb52fac1b88dbe4981f,18) + ('bag-bagwin','blast','BAG',0xb9dfcd4cf589bb8090569cb52fac1b88dbe4981f,18), + ('usdz-anzen-usdz','blast','USDz',0x52056ed29fe015f4ba2e3b079d10c0b87f46e8c6,18), + ('bpepe-blastin-pepes','blast','bPEPE',0xb6e0d8a730c6e5c85c637b1cf7ad6fd07927b965,18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 7ea3c49b9c351df738f17f39bd76d9f227d7e82f Mon Sep 17 00:00:00 2001 From: eileenapril Date: Thu, 19 Sep 2024 00:18:12 +0700 Subject: [PATCH 047/127] Add WLD and PENDLE to prices.usd (OP) (#6752) --- .../models/prices/optimism/prices_optimism_tokens_curated.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql b/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql index 94498778cbf..6187769ada5 100644 --- a/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql +++ b/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql @@ -131,5 +131,7 @@ FROM ('usdv-verified-usd', 'USDV', 0x323665443cef804a3b5206103304bd4872ea4253, 6), ('zro-layerzero', 'ZRO', 0x6985884c4392d348587b19cb9eaaf157f13271cd, 18), ('rseth-rseth', 'rsETH', 0x4186bfc76e2e237523cbc30fd220fe055156b41f, 18), - ('dola-dola', 'DOLA',0x8ae125e8653821e851f12a49f7765db9a9ce7384, 18) + ('dola-dola', 'DOLA',0x8ae125e8653821e851f12a49f7765db9a9ce7384, 18), + ('wld-worldcoin', 'WLD',0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1, 18), + ('pendle-pendle', 'PENDLE',0xbc7b1ff1c6989f006a1185318ed4e7b5796e66e1, 18) ) as temp (token_id, symbol, contract_address, decimals) From 415c0a7b0b34d155b760bdf2b0b2581b12f59a0e Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 10:30:45 -0700 Subject: [PATCH 048/127] add zeroex linea trades to downstream spells (#6749) * add linea trades to multichain spell * add missing chain names --- .../models/_projects/zeroex/zeroex_api_fills_deduped.sql | 3 ++- .../dex/models/_projects/zeroex/zeroex_schema.yml | 6 +++--- .../dex/models/_projects/zeroex/zeroex_trades.sql | 2 +- dbt_subprojects/dex/models/aggregator_trades/_schema.yml | 2 +- .../dex/models/aggregator_trades/dex_aggregator_trades.sql | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql index d52c1be0b8d..8bfdd619be5 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql @@ -1,7 +1,7 @@ {{ config( schema = 'zeroex' , alias = 'api_fills_deduped' - , post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "base", "bnb", "celo", "ethereum", "fantom", "optimism", "polygon","scroll"]\', + , post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "base", "bnb", "celo", "ethereum", "fantom", "optimism", "polygon","scroll", "linea"]\', "project", "zeroex", \'["rantum","bakabhai993"]\') }}' @@ -30,6 +30,7 @@ ,ref('zeroex_avalanche_c_settler_trades') ,ref('zeroex_arbitrum_settler_trades') ,ref('zeroex_scroll_settler_trades') + ,ref('zeroex_linea_settler_trades') ] %} diff --git a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml index 3ae3939eb6d..e93f4f91ef8 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml +++ b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml @@ -7,7 +7,7 @@ models: project: zeroex contributors: rantum, danning.sui, bakabhai993 config: - tags: ['ethereum','0x','dex_aggregator','dex','aggregator','optimism','polygon','arbitrum','fantom','avalanche','bnb','scroll'] + tags: ['ethereum','0x','dex_aggregator','dex','aggregator','optimism','polygon','arbitrum','fantom','avalanche','bnb'] description: > 0x API erc20 swaps raw fills (including multihops) and also native swaps thru 0x exchange contracts (without using 0x API) on Ethereum tests: @@ -105,7 +105,7 @@ models: - name: zeroex_api_fills_deduped meta: - blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb + blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb, base, scroll, linea sector: dex project: zeroex contributors: rantum, bakabhai993 @@ -158,7 +158,7 @@ models: - name: zeroex_trades meta: - blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb + blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb, base, linea, scroll project: zeroex contributors: rantum, danning.sui, bakabhai993 config: diff --git a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_trades.sql index dc147629864..25602b791ac 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_trades.sql @@ -1,7 +1,7 @@ {{ config( schema = 'zeroex' ,alias = 'trades' - ,post_hook='{{ expose_spells(\'["ethereum","arbitrum", "optimism", "polygon","fantom","avalanche_c","bnb"]\', + ,post_hook='{{ expose_spells(\'["ethereum","arbitrum", "optimism", "polygon","fantom","avalanche_c","bnb","base","scroll","linea"]\', "project", "zeroex", \'["rantum","bakabhai993"]\') }}' diff --git a/dbt_subprojects/dex/models/aggregator_trades/_schema.yml b/dbt_subprojects/dex/models/aggregator_trades/_schema.yml index c2f424433db..51067685c68 100644 --- a/dbt_subprojects/dex/models/aggregator_trades/_schema.yml +++ b/dbt_subprojects/dex/models/aggregator_trades/_schema.yml @@ -3,7 +3,7 @@ version: 2 models: - name: dex_aggregator_trades meta: - blockchain: ethereum, gnosis, avalanche_c, fantom, optimism, arbitrum, bnb + blockchain: ethereum, gnosis, avalanche_c, fantom, optimism, arbitrum, bnb, base, scroll, linea, polygon sector: dex_aggregator contributors: bh2smith, Henrystats, jeff-dude, rantum docs_slug: /curated/trading/DEX/dex-aggregator-trades diff --git a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql index 39a47f57cad..ff4aefc4cb0 100644 --- a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql +++ b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql @@ -6,7 +6,7 @@ incremental_strategy = 'merge', unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index', 'trace_address'], incremental_predicates = ['DBT_INTERNAL_DEST.block_date >= date_trunc(\'day\', now() - interval \'7\' day)'], - post_hook='{{ expose_spells(\'["ethereum", "gnosis", "avalanche_c", "fantom", "bnb", "optimism", "arbitrum"]\', + post_hook='{{ expose_spells(\'["ethereum", "gnosis", "avalanche_c", "fantom", "bnb", "optimism", "arbitrum", "base", "linea", "scroll", "polygon"]\', "sector", "dex_aggregator", \'["bh2smith", "Henrystats", "jeff-dude", "rantum", "hosuke"]\') }}' From f57a7b25c5eeaab03959f0a1c691ce974c9e761b Mon Sep 17 00:00:00 2001 From: mhmdriyadi <112420584+mhmdriyadi@users.noreply.github.com> Date: Thu, 19 Sep 2024 00:37:12 +0700 Subject: [PATCH 049/127] Update prices_ethereum_tokens.sql (#6753) Add Lombard staked btc price --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index aeb1b709510..b3e19dbe1f6 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1836,7 +1836,8 @@ FROM ('ftw-black-agnus', 'ethereum', 'FTW', 0x306fD3e7b169Aa4ee19412323e1a5995B8c1a1f4, 18), ('synt-synternet','ethereum','SYNT',0xda987c655ebc38c801db64a8608bc1aa56cd9a31, 18), ('babydoge-baby-doge-coin', 'ethereum', 'BABYDOGE', 0xac57de9c1a09fec648e93eb98875b212db0d460b, 9), - ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18) + ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18), + ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( -- bad price feeds From 29296b5a085ddaa2843e3cd99818b53969d1c59d Mon Sep 17 00:00:00 2001 From: Alex Courouble <56831527+couralex6@users.noreply.github.com> Date: Wed, 18 Sep 2024 11:49:55 -0700 Subject: [PATCH 050/127] Filter out trusted tokens from prices (#6712) * Filter out trusted tokens from prices * update logic to filter out trusted tokens --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Co-authored-by: jeff-dude --- dbt_subprojects/dex/models/prices/dex_prices_beta.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql index 2a01ca14341..477e7b3b862 100644 --- a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql +++ b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql @@ -43,11 +43,16 @@ dex_bought as ( inner join {{ source('tokens', 'erc20') }} as t on d.blockchain = t.blockchain and d.token_bought_address = t.contract_address + left join {{ source('prices', 'trusted_tokens') }} as ptt + on d.blockchain = ptt.blockchain + and d.token_bought_address = ptt.contract_address where 1 = 1 and d.token_bought_amount > 0 and d.token_bought_amount_raw > UINT256 '0' and t.symbol is not null + -- filter out tokens that are already in the trusted_tokens table + and ptt.contract_address is null ), dex_sold as ( select @@ -64,11 +69,16 @@ dex_sold as ( inner join {{ source('tokens', 'erc20') }} as t on d.blockchain = t.blockchain and d.token_sold_address = t.contract_address + left join {{ source('prices', 'trusted_tokens') }} as ptt + on d.blockchain = ptt.blockchain + and d.token_sold_address = ptt.contract_address where 1 = 1 and d.token_sold_amount > 0 and d.token_sold_amount_raw > UINT256 '0' and t.symbol is not null + -- filter out tokens that are already in the trusted_tokens table + and ptt.contract_address is null ), dex_prices as ( select From 1b0dcc39f7f87349440e76dd6654ecdae59576bd Mon Sep 17 00:00:00 2001 From: jamesanalyst <121871291+jamesanalyst@users.noreply.github.com> Date: Thu, 19 Sep 2024 01:51:28 +0700 Subject: [PATCH 051/127] Update prices_mantle_tokens.sql (#6754) * Update prices_mantle_tokens.sql * update --- .../tokens/models/prices/mantle/prices_mantle_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/mantle/prices_mantle_tokens.sql b/dbt_subprojects/tokens/models/prices/mantle/prices_mantle_tokens.sql index bb695b42c7e..2e539e012b6 100644 --- a/dbt_subprojects/tokens/models/prices/mantle/prices_mantle_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/mantle/prices_mantle_tokens.sql @@ -30,5 +30,6 @@ FROM ('usde-ethena-usde', 'mantle', 'USDe', 0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34, 18), ('puff-puff-token', 'mantle', 'PUFF', 0x26a6b0dcdcfb981362afa56d581e4a7dba3be140, 18), ('moe-merchant-moe', 'mantle', 'MOE', 0x4515A45337F461A11Ff0FE8aBF3c606AE5dC00c9, 18), - ('usdy-ondo-us-dollar-yield', 'mantle', 'USDY', 0x5bE26527e817998A7206475496fDE1E68957c5A6, 18) + ('usdy-ondo-us-dollar-yield', 'mantle', 'USDY', 0x5bE26527e817998A7206475496fDE1E68957c5A6, 18), + ('svl-slash-vision-labs', 'mantle', 'SVL', 0xabbeed1d173541e0546b38b1c0394975be200000, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 982fd8d6815d79fc5ade72c4ad50a260c9111009 Mon Sep 17 00:00:00 2001 From: mhmdriyadi <112420584+mhmdriyadi@users.noreply.github.com> Date: Thu, 19 Sep 2024 01:52:47 +0700 Subject: [PATCH 052/127] Update prices_bnb_tokens.sql (#6755) Add COCO token price --- dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql index 6269bff3876..ad1a2b53fab 100644 --- a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql @@ -276,7 +276,8 @@ FROM ('bwjup-bsc-wrapped-jupiter', 'bnb', 'bwJUP', 0x0231f91e02debd20345ae8ab7d71a41f8e140ce7, 18), ('lovely-lovely-inu-finance', 'bnb', 'LOVELY', 0x9e24415d1e549ebc626a13a482bb117a2b43e9cf, 8), --('pvc-pvc-meta','bnb','PVC',0x75ca521892de7f2ecfb070cab545c250d0ceb7e3, 9), --token_id not found - ('bvsd-bvsd','bnb','BVSD',0x7f9ad7a5854658d984924e868187b2135514fb88, 18) + ('bvsd-bvsd','bnb','BVSD',0x7f9ad7a5854658d984924e868187b2135514fb88, 18), + ('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( 0x2ab0e9e4ee70fff1fb9d67031e44f6410170d00e -- bXEN has bad price feed. From 77f5ed5c021df04b0372d234e8ad8fde4511f8bf Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 18 Sep 2024 11:53:53 -0700 Subject: [PATCH 053/127] zeroex - add taker logic (#6756) * add linea trades to multichain spell * add missing chain names * add missing taker logic, udpate tokens cte --- .../zeroex_arbitrum_settler_trades.sql | 32 +++++++++++++------ .../zeroex_avalanche_c_settler_trades.sql | 32 +++++++++++++------ .../base/zeroex_base_settler_trades.sql | 14 ++++---- .../zeroex/bnb/zeroex_bnb_settler_trades.sql | 32 +++++++++++++------ .../zeroex_ethereum_settler_trades.sql | 32 +++++++++++++------ .../linea/zeroex_linea_settler_trades.sql | 32 +++++++++++++------ .../zeroex_optimism_settler_trades.sql | 32 +++++++++++++------ .../polygon/zeroex_polygon_settler_trades.sql | 32 +++++++++++++------ .../scroll/zeroex_scroll_settler_trades.sql | 32 +++++++++++++------ 9 files changed, 183 insertions(+), 87 deletions(-) diff --git a/dbt_subprojects/dex/models/_projects/zeroex/arbitrum/zeroex_arbitrum_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/arbitrum/zeroex_arbitrum_settler_trades.sql index e44c7082f6d..66ed038fc80 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/arbitrum/zeroex_arbitrum_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/arbitrum/zeroex_arbitrum_settler_trades.sql @@ -95,7 +95,7 @@ with tbl_all_logs AS ( (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) then 1 end as valid, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -139,14 +139,26 @@ with tbl_all_logs AS ( tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'arbitrum' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'arbitrum' ), prices AS ( @@ -203,7 +215,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, diff --git a/dbt_subprojects/dex/models/_projects/zeroex/avalanche_c/zeroex_avalanche_c_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/avalanche_c/zeroex_avalanche_c_settler_trades.sql index 8718c12d682..0628eff4a36 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/avalanche_c/zeroex_avalanche_c_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/avalanche_c/zeroex_avalanche_c_settler_trades.sql @@ -95,7 +95,7 @@ with tbl_all_logs AS ( (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) then 1 end as valid, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -139,14 +139,26 @@ with tbl_all_logs AS ( tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'avalanche_c' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'avalanche_c' ), prices AS ( @@ -203,7 +215,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, diff --git a/dbt_subprojects/dex/models/_projects/zeroex/base/zeroex_base_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/base/zeroex_base_settler_trades.sql index 14e0c21d9f7..bcf834f6bbd 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/base/zeroex_base_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/base/zeroex_base_settler_trades.sql @@ -95,7 +95,7 @@ with tbl_all_logs AS ( (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) then 1 end as valid, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -157,7 +157,7 @@ tokens AS ( join {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token WHERE - te.blockchain = '{{blockchain}}' + te.blockchain = 'base' ), prices AS ( @@ -175,7 +175,7 @@ prices AS ( AND minute >= DATE '{{zeroex_settler_start_date}}' {% endif %} ), -/* + fills as ( with signatures as ( select distinct signature @@ -202,7 +202,7 @@ fills as ( {% endif %} group by 1,2,3 ), -*/ + results AS ( SELECT trades.block_time, @@ -214,7 +214,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, @@ -233,8 +233,8 @@ results AS ( tbl_trades trades JOIN {{ source('base', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number --- LEFT JOIN --- fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number LEFT JOIN tokens tt ON tt.blockchain = 'base' AND tt.contract_address = taker_token LEFT JOIN diff --git a/dbt_subprojects/dex/models/_projects/zeroex/bnb/zeroex_bnb_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/bnb/zeroex_bnb_settler_trades.sql index 29cfd2ee6d0..7d53b722cf4 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/bnb/zeroex_bnb_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/bnb/zeroex_bnb_settler_trades.sql @@ -95,7 +95,7 @@ with tbl_all_logs AS ( (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) then 1 end as valid, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -139,14 +139,26 @@ with tbl_all_logs AS ( tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'bnb' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'bnb' ), prices AS ( @@ -203,7 +215,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, diff --git a/dbt_subprojects/dex/models/_projects/zeroex/ethereum/zeroex_ethereum_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/ethereum/zeroex_ethereum_settler_trades.sql index f1cbd6b58a9..d94154c7a98 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/ethereum/zeroex_ethereum_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/ethereum/zeroex_ethereum_settler_trades.sql @@ -95,7 +95,7 @@ with tbl_all_logs AS ( (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) then 1 end as valid, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -139,14 +139,26 @@ with tbl_all_logs AS ( tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'ethereum' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'ethereum' ), prices AS ( @@ -203,7 +215,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, diff --git a/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_settler_trades.sql index 955d3c96787..641ec0626b5 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/linea/zeroex_linea_settler_trades.sql @@ -91,7 +91,7 @@ with tbl_all_logs AS ( logs.block_time, logs.block_number, index, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -130,14 +130,26 @@ with tbl_all_logs AS ( tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'linea' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'linea' ), prices AS ( @@ -194,7 +206,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, diff --git a/dbt_subprojects/dex/models/_projects/zeroex/optimism/zeroex_optimism_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/optimism/zeroex_optimism_settler_trades.sql index f76da55d3fc..38875310058 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/optimism/zeroex_optimism_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/optimism/zeroex_optimism_settler_trades.sql @@ -95,7 +95,7 @@ with tbl_all_logs AS ( (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) then 1 end as valid, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -139,14 +139,26 @@ with tbl_all_logs AS ( tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'optimism' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'optimism' ), prices AS ( @@ -203,7 +215,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, diff --git a/dbt_subprojects/dex/models/_projects/zeroex/polygon/zeroex_polygon_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/polygon/zeroex_polygon_settler_trades.sql index baa3b8d9a07..12f42985150 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/polygon/zeroex_polygon_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/polygon/zeroex_polygon_settler_trades.sql @@ -95,7 +95,7 @@ with tbl_all_logs AS ( (varbinary_substring(logs.topic2, 13, 20) = first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) or topic0 = 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65) then 1 end as valid, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -139,14 +139,26 @@ with tbl_all_logs AS ( tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'polygon' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'polygon' ), prices AS ( @@ -203,7 +215,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, diff --git a/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_settler_trades.sql index 38e069d1fcd..c2086b6c73b 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_settler_trades.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/scroll/zeroex_scroll_settler_trades.sql @@ -91,7 +91,7 @@ with tbl_all_logs AS ( logs.block_time, logs.block_number, index, - bytearray_substring(logs.topic2,13,20) as taker, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, logs.contract_address as maker_token, first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, @@ -129,14 +129,26 @@ with tbl_all_logs AS ( tokens AS ( - SELECT DISTINCT - te.* - FROM - {{ source('tokens', 'erc20') }} AS te - JOIN - tbl_trades ON te.contract_address = taker_token OR te.contract_address = maker_token - WHERE - te.blockchain = 'scroll' + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'scroll' ), prices AS ( @@ -193,7 +205,7 @@ results AS ( "from" AS tx_from, "to" AS tx_to, trades.index AS tx_index, - taker , + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, CAST(NULL AS varbinary) AS maker, taker_token, pt.price, From fdd0124a19899970263ee1f923a20cdc2bb50940 Mon Sep 17 00:00:00 2001 From: synthquest <112836792+Synthquest@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:56:08 -0400 Subject: [PATCH 054/127] Static EVM Stablecoins (#6723) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Main ## Thank you for contributing to Spellbook 🪄 ### Update! Please build spells in the proper [subproject](../dbt_subprojects/) directory. For more information, please see the main [readme](../README.md), which also links to a GH discussion with the option to ask questions. ### Contribution type Please check the type of contribution this pull request is for: - [ x] New spell(s) - [ ] Adding to existing spell lineage - [ ] Bug fix **Note:** You can safely discard any section below which doesn't apply based on selection above --- ### For new spell(s) If you are building new spell(s), please provide the following information: - **Spell name(s):** *tokens.tokens_erc20_stablecoins* - **Description:** contract, description, and decimal definitions for L1 & L2 evm stablecoins - **Who are the new spell(s) for?** general community + internal work - **How will the new spell(s) be used downstream?** General - quick views of stablecoins on l2's. Internal - filter for token transfers - **Implementation details:** static - **Test instructions:** unique contract address + blockchain - **Related issue(s):** N/A --- ### For adding to existing spell lineage If you are adding to an existing spell lineage, please provide the following information: - **Description:** [Description of the changes made] --- ### For bug fixes If you are fixing a bug, please provide the following information: - **Description:** [Description of the bug fix] - **Steps to reproduce:** [How to reproduce the bug] - **Implementation details:** [Information on how the bug was fixed] - **Test instructions:** [How to test the fix] - **Related issue(s):** [Link to related issues, if any] --- ### Additional information Please provide any additional information that might help us review your pull request: - [Any additional information] --- Thank you for your contribution! * revert profile & add test to schema * update dai * Add stablecoin definitions for evm chains * add combined evm stablecoins table * update table naming * Update optimism & add arbitrum daily balances * update balance schema * fix join * remove stablecoin balances tabels * add schema property --- .../tokens/models/tokens/_schema.yml | 28 ++++++ .../tokens_arbitrum_erc20_stablecoins.sql | 34 +++++++ .../arbitrum/tokens_arbitrum_schema.yml | 23 +++++ .../tokens_avalanche_c_erc20_stablecoins.sql | 32 ++++++ .../avalanche_c/tokens_avalanche_c_schema.yml | 23 +++++ .../base/tokens_base_erc20_stablecoins.sql | 26 +++++ .../models/tokens/base/tokens_base_schema.yml | 23 +++++ .../bnb/tokens_bnb_erc20_stablecoins.sql | 43 ++++++++ .../models/tokens/bnb/tokens_bnb_schema.yml | 23 +++++ .../tokens_ethereum_erc20_stablecoins.sql | 87 +++++++++++------ .../ethereum/tokens_ethereum_schema.yml | 26 ++--- .../tokens_fantom_erc20_stablecoins.sql | 46 +++++---- .../tokens/fantom/tokens_fantom_schema.yml | 26 ++--- .../tokens_gnosis_erc20_stablecoins.sql | 21 ++++ .../tokens/gnosis/tokens_gnosis_schema.yml | 23 +++++ .../tokens_optimism_erc20_stablecoins.sql | 97 ++++++++----------- .../optimism/tokens_optimism_schema.yml | 35 +++---- .../tokens_polygon_erc20_stablecoins.sql | 37 +++++++ .../tokens/polygon/tokens_polygon_schema.yml | 23 +++++ .../tokens/tokens_erc20_stablecoins.sql | 42 ++++++++ 20 files changed, 569 insertions(+), 149 deletions(-) create mode 100644 dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/tokens_erc20_stablecoins.sql diff --git a/dbt_subprojects/tokens/models/tokens/_schema.yml b/dbt_subprojects/tokens/models/tokens/_schema.yml index 449bd4312c7..6de4d57b157 100644 --- a/dbt_subprojects/tokens/models/tokens/_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/_schema.yml @@ -63,3 +63,31 @@ models: description: "NFT collection symbol" - name: standard description: "NFT collection standard" + + - name: tokens_erc20_stablecoins + meta: + blockchain: arbitrum, avalanche_c, bnb, ethereum, fantom, gnosis, optimism, polygon, base + sector: tokens + contributors: hildobby, synthquest + config: + tags: ['tokens','stablecoin', 'arbitrum','avalanche_c','bnb','ethereum','fantom','gnosis','optimism','polygon','base'] + description: > + Stablecoin (ERC20) tokens + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - contract_address + columns: + - name: blockchain + description: blockchain name + - name: contract_address + description: token contract address + - name: name + description: token backing + - name: symbol + description: token symbol + - name: decimal + description: token decimals + - name: backing + description: token backing diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20_stablecoins.sql new file mode 100644 index 00000000000..335216bcd6b --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20_stablecoins.sql @@ -0,0 +1,34 @@ +{{ config( + schema = 'tokens_arbitrum' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["arbitrum"]\', + "sector", + "tokens_arbitrum", + \'["synthquest"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + + ('arbitrum', 0x641441c631e2f909700d2f41fd87f0aa6a6b4edb, 'Crypto-backed stablecoin', 'USX', 18, ''), + ('arbitrum', 0x680447595e8b7b3aa1b43beb9f6098c79ac2ab3f, 'Algorithmic stablecoin', 'USDD', 18, ''), + ('arbitrum', 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9, 'Fiat-backed stablecoin', 'USDT', 6, ''), + ('arbitrum', 0xaf88d065e77c8cc2239327c5edb3a432268e5831, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('arbitrum', 0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a, 'Crypto-backed stablecoin', 'MIM', 18, ''), + ('arbitrum', 0xa970af1a584579b618be4d69ad6f73459d112f95, 'Crypto-backed stablecoin', 'sUSD', 18, ''), + ('arbitrum', 0xddc0385169797937066bbd8ef409b5b3c0dfeb52, 'RWA-backed stablecoin', 'wUSDR', 9, ''), + ('arbitrum', 0xe80772eaf6e2e18b651f160bc9158b2a5cafca65, 'Crypto-backed stablecoin', 'USD+', 6, ''), + ('arbitrum', 0x17fc002b466eec40dae837fc4be5c67993ddbd6f, 'Hybrid stablecoin', 'FRAX', 18, ''), + ('arbitrum', 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1, 'Hybrid stablecoin', 'DAI', 18, ''), + ('arbitrum', 0x64343594ab9b56e99087bfa6f2335db24c2d1f17, 'Crypto-backed stablecoin', 'VST', 18, ''), + ('arbitrum', 0xd74f5255d557944cf7dd0e45ff521520002d5748, 'Crypto-backed stablecoin', 'USDs', 18, ''), + ('arbitrum', 0x3f56e0c36d275367b8c502090edf38289b3dea0d, 'Crypto-backed stablecoin', 'MAI', 18, ''), + ('arbitrum', 0xb1084db8d3c05cebd5fa9335df95ee4b8a0edc30, 'Crypto-backed stablecoin', 'USDT+', 6, ''), + ('arbitrum', 0x3509f19581afedeff07c53592bc0ca84e4855475, 'Crypto-backed stablecoin', 'xUSD', 18, ''), + ('arbitrum', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 'Fiat-backed stablecoin', 'USDM', 18, ''), + ('arbitrum', 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('arbitrum', 0x4d15a3a2286d883af0aa1b3f21367843fac63e07, 'Fiat-backed stablecoin', 'TUSD', 18, '') + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml index 7b539b9d4a8..0d566872dc6 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml @@ -81,3 +81,26 @@ models: - unique - name: standard description: "The NFT standard erc721/erc1155/..." + + - name: tokens_arbitrum_erc20_stablecoins + meta: + blockchain: arbitrum + sector: stablecoins + contributors: synthquest + config: + tags: ['tokens', 'arbitrum', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" diff --git a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20_stablecoins.sql new file mode 100644 index 00000000000..c6d569bd584 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20_stablecoins.sql @@ -0,0 +1,32 @@ +{{ config( + schema = 'tokens_avalanche_c' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["avalanche_c"]\', + "sector", + "tokens_avalanche_c", + \'["synthquest"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + + ('avalanche_c', 0x111111111111ed1d73f860f57b2798b683f2d325, 'Crypto-backed stablecoin', 'YUSD', 18, ''), + ('avalanche_c', 0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7, 'Fiat-backed stablecoin', 'USDt', 6, ''), + ('avalanche_c', 0xab05b04743e0aeaf9d2ca81e5d3b8385e4bf961e, 'Hybrid stablecoin', 'USDS', 18, ''), + ('avalanche_c', 0x00000000efe302beaa2b3e6e1b18d08d69a9012a, 'Fiat-backed stablecoin', 'AUSD', 6, ''), + ('avalanche_c', 0x130966628846bfd36ff31a822705796e8cb8c18d, 'Crypto-backed stablecoin', 'MIM', 18, ''), + ('avalanche_c', 0xd24c2ad096400b6fbcd2ad8b24e7acbc21a1da64, 'Hybrid stablecoin', 'FRAX', 18, ''), + ('avalanche_c', 0xd586e7f844cea2f87f50152665bcbc2c279d8d70, 'Crypto-backed stablecoin', 'DAI.e', 18, ''), + ('avalanche_c', 0x3b55e45fd6bd7d4724f5c47e0d1bcaedd059263e, 'Crypto-backed stablecoin', 'miMatic', 18, ''), + ('avalanche_c', 0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('avalanche_c', 0x9c9e5fd8bbc25984b178fdce6117defa39d2db39, 'Fiat-backed stablecoin', 'BUSD', 18, ''), + ('avalanche_c', 0xf14f4ce569cb3679e99d5059909e23b07bd2f387, 'Crypto-backed stablecoin', 'NXUSD', 18, ''), + ('avalanche_c', 0x1c20e891bab6b1727d14da358fae2984ed9b59eb, 'Fiat-backed stablecoin', 'TUSD', 18, ''), + ('avalanche_c', 0xdacde03d7ab4d81feddc3a20faa89abac9072ce2, 'Crypto-backed stablecoin', 'USP', 18, ''), + ('avalanche_c', 0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664, 'Crypto-backed stablecoin', 'USDC.e', 6, ''), + ('avalanche_c', 0x8861f5c40a0961579689fdf6cdea2be494f9b25a, 'Hybrid stablecoin', 'iUSDS', 18, '') + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_schema.yml b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_schema.yml index 33c7d6a409a..22c9c8c7cec 100644 --- a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_schema.yml @@ -85,3 +85,26 @@ models: tests: - accepted_values: values: [ 'erc721', 'erc1155'] + + - name: tokens_avalanche_c_erc20_stablecoins + meta: + blockchain: avalanche_c + sector: stablecoins + contributors: synthquest + config: + tags: ['tokens', 'avalanche_c', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20_stablecoins.sql new file mode 100644 index 00000000000..8cbcbdcb911 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20_stablecoins.sql @@ -0,0 +1,26 @@ +{{ config( + schema = 'tokens_base' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["base"]\', + "sector", + "tokens_base", + \'["synthquest"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + + ('base', 0x60a3e35cc302bfa44cb288bc5a4f316fdb1adb42, 'Fiat-backed stablecoin', 'EURC', 6, ''), + ('base', 0xb79dd08ea68a908a97220c76d19a6aa9cbde4376, 'Crypto-backed stablecoin', 'USD+', 6, ''), + ('base', 0xcc7ff230365bd730ee4b352cc2492cedac49383e, 'Algorithmic stablecoin', 'hyUSD', 18, ''), + ('base', 0xcfa3ef56d303ae4faaba0592388f19d7c3399fb4, 'Crypto-backed stablecoin', 'eUSD', 18, ''), + ('base', 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('base', 0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 'Fiat-backed stablecoin', 'USDz', 18, ''), + ('base', 0x4621b7a9c75199271f773ebd9a499dbd165c3191, 'Crypto-backed stablecoin', 'DOLA', 18, ''), + ('base', 0xca72827a3d211cfd8f6b00ac98824872b72cab49, 'Fiat-backed stablecoin', 'cgUSD', 6, '') + + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml b/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml index c3fd81881fa..3cd3f9fe144 100644 --- a/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml @@ -81,3 +81,26 @@ models: tests: - accepted_values: values: [ 'erc721', 'erc1155' ] + + - name: tokens_base_erc20_stablecoins + meta: + blockchain: base + sector: stablecoins + contributors: synthquest + config: + tags: ['tokens', 'base', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_erc20_stablecoins.sql new file mode 100644 index 00000000000..2d1457e851f --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_erc20_stablecoins.sql @@ -0,0 +1,43 @@ +{{ config( + schema = 'tokens_bnb' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["bnb"]\', + "sector", + "tokens_bnb", + \'["synthquest"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + + ('bnb', 0x14016e85a25aeb13065688cafb43044c2ef86784, 'Fiat-backed stablecoin', 'TUSD', 18, ''), + ('bnb', 0x23396cf899ca06c4472205fc903bdb4de249d6fc, 'Algorithmic stablecoin', 'UST', 18, ''), + ('bnb', 0x0782b6d8c4551b9760e74c0545a9bcd90bdc41e5, 'Crypto-backed stablecoin', 'HAY', 18, ''), + ('bnb', 0x90c97f71e18723b0cf0dfa30ee176ab653e89f40, 'Hybrid stablecoin', 'FRAX', 18, ''), + ('bnb', 0x6bf2be9468314281cd28a94c35f967cafd388325, 'Hybrid stablecoin', 'oUSD', 18, ''), + ('bnb', 0x55d398326f99059ff775485246999027b3197955, 'Fiat-backed stablecoin', 'USDT', 18, ''), + ('bnb', 0xde7d1ce109236b12809c45b23d22f30dba0ef424, 'Hybrid stablecoin', 'USDS', 18, ''), + ('bnb', 0xfa4ba88cf97e282c505bea095297786c16070129, 'Fiat-backed stablecoin', 'CUSD', 18, ''), + ('bnb', 0xc5f0f7b66764f6ec8c8dff7ba683102295e16409, 'Fiat-backed stablecoin', 'FDUSD', 18, ''), + ('bnb', 0x2952beb1326accbb5243725bd4da2fc937bca087, 'RWA-backed stablecoin', 'wUSDR', 9, ''), + ('bnb', 0x1d6cbdc6b29c6afbae65444a1f65ba9252b8ca83, 'Crypto-backed stablecoin', 'TOR', 18, ''), + ('bnb', 0xb0b195aefa3650a6908f15cdac7d92f8a5791b0b, 'Crypto-backed stablecoin', 'BOB', 18, ''), + ('bnb', 0x6458df5d764284346c19d88a104fd3d692471499, 'Hybrid stablecoin', 'iUSDS', 18, ''), + ('bnb', 0x2f29bc0ffaf9bff337b31cbe6cb5fb3bf12e5840, 'Crypto-backed stablecoin', 'DOLA', 18, ''), + ('bnb', 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d, 'Fiat-backed stablecoin', 'USDC', 18, ''), + ('bnb', 0x3f56e0c36d275367b8c502090edf38289b3dea0d, 'Crypto-backed stablecoin', 'MAI', 18, ''), + ('bnb', 0x4bd17003473389a42daf6a0a729f6fdb328bbbd7, 'Crypto-backed stablecoin', 'VAI', 18, ''), + ('bnb', 0xf0186490b18cb74619816cfc7feb51cdbe4ae7b9, 'RWA-backed stablecoin', 'zUSD', 18, ''), + ('bnb', 0xfe19f0b51438fd612f6fd59c1dbb3ea319f433ba, 'Crypto-backed stablecoin', 'MIM', 18, ''), + ('bnb', 0xe9e7cea3dedca5984780bafc599bd69add087d56, 'Fiat-backed stablecoin', 'BUSD', 18, ''), + ('bnb', 0xb5102cee1528ce2c760893034a4603663495fd72, 'Crypto-backed stablecoin', 'USX', 18, ''), + ('bnb', 0xb7f8cd00c5a06c0537e2abff0b58033d02e5e094, 'Crypto-backed stablecoin', 'PAX', 18, ''), + ('bnb', 0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3, 'Hybrid stablecoin', 'DAI', 18, ''), + ('bnb', 0xd17479997f34dd9156deef8f95a52d81d265be9c, 'Algorithmic stablecoin', 'USDD', 18, '') + + + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml index a0c42ece067..5ebe3c50929 100644 --- a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml @@ -81,3 +81,26 @@ models: tests: - accepted_values: values: [ 'bep721', 'bep1155' ] + + - name: tokens_bnb_erc20_stablecoins + meta: + blockchain: bnb + sector: stablecoins + contributors: synthquest + config: + tags: ['tokens', 'bnb', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql index c5e0def8a80..8072f092389 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql @@ -1,39 +1,66 @@ {{ config( - alias = 'stablecoins' + schema = 'tokens_ethereum' + , alias = 'erc20_stablecoins' , tags=['static'] , post_hook='{{ expose_spells(\'["ethereum"]\', "sector", "tokens_ethereum", - \'["gentrexha", "dot2dotseurat"]\') }}' + \'["Henrystats", "synthquest"]\') }}' + , unique_key = ['contract_address'] ) }} -SELECT contract_address, symbol, decimals, name +SELECT blockchain, contract_address, backing, symbol, decimals, name FROM (VALUES - (0xbc6da0fe9ad5f3b0d58160288917aa56653660e9, 'alUSD', 18, 'Alchemix USD'), - (0xd46ba6d942050d489dbd938a2c909a5d5039a161, 'AMPL', 9, 'Ampleforth'), - (0x4fabb145d64652a948d72533023f6e7a623c7c53, 'BUSD', 18, 'Binance USD'), - (0x6b175474e89094c44da98b954eedeac495271d0f, 'DAI', 18, 'Dai'), - (0xdb25f211ab05b1c97d595516f45794528a807ad8, 'EURS', 18, 'STASIS EURS'), - (0x956f47f50a910163d8bf957cf5846d573e7f87ca, 'FEI', 18, 'Fei USD'), - (0x853d955acef822db058eb8505911ed77f175b99e, 'FRAX', 18, 'Frax'), - (0x056fd409e1d7a124bd7017459dfea2f387b6d5cd, 'GUSD', 2, 'Gemini Dollar'), - (0xdf574c24545e5ffecb9a659c229253d4111d87e1, 'HUSD', 8, 'HUSD'), - (0x5f98805A4E8be255a32880FDeC7F6728C6568bA0, 'LUSD', 18, 'Liquity USD'), - (0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3, 'MIM', 18, 'Magic Internet Money'), - (0xe2f2a5c287993345a840db3b0845fbc70f5935a5, 'MUSD', 18, 'mStable USD'), - (0x8e870d67f660d95d5be530380d0ec0bd388289e1, 'PAX', 18, 'Paxos Standard'), - (0x03ab458634910aad20ef5f1c8ee96f1d6ac54919, 'RAI', 18, 'Rai Reflex Index'), - (0x57Ab1ec28D129707052df4dF418D58a2D46d5f51, 'sUSD', 18, 'Synthetix sUSD'), - (0x57Ab1E02fEE23774580C119740129eAC7081e9D3, 'sUSD', 18, 'Synthetix sUSD'), - (0x0000000000085d4780b73119b644ae5ecd22b376, 'TUSD', 18, 'TrueUSD'), - (0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 'USDC', 6, 'USD Coin'), - (0x674c6ad92fd080e4004b2312b45f796a192d27a0, 'USDN', 18, 'Neutrino USD'), - (0x1456688345527bE1f37E9e627DA0837D6f08C925, 'USDP', 18, 'Pax Dollar'), - (0xdac17f958d2ee523a2206206994597c13d831ec7, 'USDT', 6, 'Tether'), - (0xa47c8bf37f92abed4a126bda807a7b7498661acd, 'UST', 18, 'Wrapped UST Token'), - (0xa693b19d2931d498c5b318df961919bb4aee87a5, 'UST', 6, 'UST (Wormhole)'), - (0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A, 'GYD', 18, 'Gyro Dollar'), - (0x73a15fed60bf67631dc6cd7bc5b6e8da8190acf5, 'USD0', 18, 'Usual USD'), - (0x866a2bf4e572cbcf37d5071a7a58503bfb36be1b, 'M', 6, 'M by M^0') - ) AS temp_table (contract_address, symbol, decimals, name) + + ('ethereum', 0x6b175474e89094c44da98b954eedeac495271d0f, 'Hybrid stablecoin', 'DAI', 18, 'Dai'), + ('ethereum', 0x96f6ef951840721adbf46ac996b59e0235cb985c, 'Fiat-backed stablecoin', 'USDY', 18, ''), + ('ethereum', 0xc5f0f7b66764f6ec8c8dff7ba683102295e16409, 'Fiat-backed stablecoin', 'FDUSD', 18, ''), + ('ethereum', 0x8d6cebd76f18e1558d4db88138e2defb3909fad6, 'Crypto-backed stablecoin', 'MAI', 18, ''), + ('ethereum', 0x5f98805a4e8be255a32880fdec7f6728c6568ba0, 'Crypto-backed stablecoin', 'LUSD', 18, 'Liquity USD'), + ('ethereum', 0xf9c2b386ff5df088ac717ab0010587bad3bc1ab1, 'Hybrid stablecoin', 'iUSDS', 18, ''), + ('ethereum', 0x45fdb1b92a649fb6a64ef1511d3ba5bf60044838, 'Hybrid stablecoin', 'USDS', 18, ''), + ('ethereum', 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 'Fiat-backed stablecoin', 'USDC', 6, 'USD Coin'), + ('ethereum', 0xdac17f958d2ee523a2206206994597c13d831ec7, 'Fiat-backed stablecoin', 'USDT', 6, 'Tether'), + ('ethereum', 0xbea0000029ad1c77d3d5d23ba2d8893db9d1efab, 'Algorithmic stablecoin', 'BEAN', 6, ''), + ('ethereum', 0xe2f2a5c287993345a840db3b0845fbc70f5935a5, 'Crypto-backed stablecoin', 'mUSD', 18, 'mStable USD'), + ('ethereum', 0x7712c34205737192402172409a8f7ccef8aa2aec, 'Fiat-backed stablecoin', 'BUIDL', 6, ''), + ('ethereum', 0x4fabb145d64652a948d72533023f6e7a623c7c53, 'Fiat-backed stablecoin', 'BUSD', 18, 'Binance USD'), + ('ethereum', 0x1456688345527be1f37e9e627da0837d6f08c925, 'Crypto-backed stablecoin', 'USDP', 18, 'Pax Dollar'), + ('ethereum', 0x2a8e1e676ec238d8a992307b495b45b3feaa5e86, 'Crypto-backed stablecoin', 'OUSD', 18, ''), + ('ethereum', 0x0c10bf8fcb7bf5412187a595ab97a3609160b5c6, 'Algorithmic stablecoin', 'USDD', 18, ''), + ('ethereum', 0x8e870d67f660d95d5be530380d0ec0bd388289e1, 'Fiat-backed stablecoin', 'USDP', 18, 'Paxos Standard'), + ('ethereum', 0x853d955acef822db058eb8505911ed77f175b99e, 'Hybrid stablecoin', 'FRAX', 18, 'Frax'), + ('ethereum', 0x6c3ea9036406852006290770bedfcaba0e23a0e8, 'Fiat-backed stablecoin', 'PYUSD', 6, ''), + ('ethereum', 0xdf574c24545e5ffecb9a659c229253d4111d87e1, 'Fiat-backed stablecoin', 'HUSD', 8, 'HUSD'), + ('ethereum', 0xc285b7e09a4584d027e5bc36571785b515898246, 'Fiat-backed stablecoin', 'CUSD', 18, ''), + ('ethereum', 0xdc59ac4fefa32293a95889dc396682858d52e5db, 'Algorithmic stablecoin', 'BEAN', 6, ''), + ('ethereum', 0xa774ffb4af6b0a91331c084e1aebae6ad535e6f3, 'Crypto-backed stablecoin', 'FLEXUSD', 18, ''), + ('ethereum', 0xa47c8bf37f92abed4a126bda807a7b7498661acd, 'Algorithmic stablecoin', 'UST', 18, 'Wrapped UST Token'), + ('ethereum', 0x0000000000085d4780b73119b644ae5ecd22b376, 'Fiat-backed stablecoin', 'TUSD', 18, 'TrueUSD'), + ('ethereum', 0x4c9edd5852cd905f086c759e8383e09bff1e68b3, 'Crypto-backed stablecoin', 'USDe', 18, ''), + ('ethereum', 0xc56c2b7e71b54d38aab6d52e94a04cbfa8f604fa, 'Fiat-backed stablecoin', 'ZUSD', 6, ''), + ('ethereum', 0x0a5e677a6a24b2f1a2bf4f3bffc443231d2fdec8, 'Crypto-backed stablecoin', 'USX', 18, ''), + ('ethereum', 0x196f4727526ea7fb1e17b2071b3d8eaa38486988, 'Crypto-backed stablecoin', 'RSV', 18, ''), + ('ethereum', 0xbc6da0fe9ad5f3b0d58160288917aa56653660e9, 'Crypto-backed stablecoin', 'alUSD', 18, 'Alchemix USD'), + ('ethereum', 0x73a15fed60bf67631dc6cd7bc5b6e8da8190acf5, 'Fiat-backed stablecoin', 'USD0', 18, 'Usual USD'), + ('ethereum', 0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3, 'Crypto-backed stablecoin', 'MIM', 18, 'Magic Internet Money'), + ('ethereum', 0xd5a14081a34d256711b02bbef17e567da48e80b5, 'RWA-backed stablecoin', 'wUSDR', 9, ''), + ('ethereum', 0x57ab1ec28d129707052df4df418d58a2d46d5f51, 'Crypto-backed stablecoin', 'sUSD', 18, 'Synthetix sUSD'), + ('ethereum', 0x056fd409e1d7a124bd7017459dfea2f387b6d5cd, 'Fiat-backed stablecoin', 'GUSD', 2, 'Gemini Dollar'), + ('ethereum', 0x1c48f86ae57291f7686349f12601910bd8d470bb, 'Fiat-backed stablecoin', 'USDK', 18, ''), + ('ethereum', 0x865377367054516e17014ccded1e7d814edc9ce4, 'Crypto-backed stablecoin', 'DOLA', 18, ''), + ('ethereum', 0xb0b195aefa3650a6908f15cdac7d92f8a5791b0b, 'Crypto-backed stablecoin', 'BOB', 18, ''), + ('ethereum', 0x956f47f50a910163d8bf957cf5846d573e7f87ca, 'Algorithmic stablecoin', 'FEI', 18, 'Fei USD'), + ('ethereum', 0x9a1997c130f4b2997166975d9aff92797d5134c2, 'RWA-backed stablecoin', 'USDap', 18, ''), + ('ethereum', 0xd46ba6d942050d489dbd938a2c909a5d5039a161, 'Crypto-backed stablecoin', 'AMPL', 9, 'Ampleforth'), + ('ethereum', 0x03ab458634910aad20ef5f1c8ee96f1d6ac54919, 'Crypto-backed stablecoin', 'RAI', 18, 'Rai Reflex Index'), + ('ethereum', 0x674c6ad92fd080e4004b2312b45f796a192d27a0, 'Algorithmic stablecoin', 'USDN', 18, 'Neutrino USD'), + ('ethereum', 0x866a2bf4e572cbcf37d5071a7a58503bfb36be1b, 'Fiat-backed stablecoin', 'M', 6, 'M by M^0'), + ('ethereum', 0x57Ab1E02fEE23774580C119740129eAC7081e9D3, 'Crypto-backed stablecoin', 'sUSD', 18, 'Synthetix sUSD'), + ('ethereum', 0xa693b19d2931d498c5b318df961919bb4aee87a5, 'Crypto-backed stablecoin', 'UST', 6, 'UST (Wormhole)'), + ('ethereum', 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A, 'Crypto-backed stablecoin', 'GYD', 18, 'Gyro Dollar'), + ('ethereum', 0xdb25f211ab05b1c97d595516f45794528a807ad8, 'Fiat-backed stablecoin', 'EURS', 18, 'STASIS EURS') + + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml index 3b7adcf4133..2577f0e571e 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml @@ -88,23 +88,25 @@ models: - name: tokens_ethereum_erc20_stablecoins meta: blockchain: ethereum - sector: tokens - project: erc20 - contributors: gentrexha + sector: stablecoins + contributors: synthquest config: - tags: [ 'table', 'erc20', 'stablecoins' ] - description: "ERC20 Stablecoin Token Addresses, Symbols and Decimals" + tags: ['tokens', 'ethereum', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. columns: + - name: blockchain + description: "Blockchain name" - name: contract_address - description: "ERC20 stablecoin token contract address" - tests: - - unique + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" - name: symbol - description: "ERC20 stablecoin token symbol" - - name: decimals - description: "Number of decimals, refers to how divisible an ERC20 stablecoin token can be" + description: "Stablecoin symbol" - name: name - description: "ERC20 stablecoin token name" + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" - name: tokens_ethereum_nft_standards meta: diff --git a/dbt_subprojects/tokens/models/tokens/fantom/tokens_fantom_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/fantom/tokens_fantom_erc20_stablecoins.sql index 5b58d18f6ff..0fe2a86254d 100644 --- a/dbt_subprojects/tokens/models/tokens/fantom/tokens_fantom_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/fantom/tokens_fantom_erc20_stablecoins.sql @@ -1,26 +1,38 @@ {{ config( - alias = 'stablecoins' + schema = 'tokens_fantom' + , alias = 'erc20_stablecoins' , tags=['static'] , post_hook='{{ expose_spells(\'["fantom"]\', "sector", "tokens_fantom", - \'["Henrystats"]\') }}' + \'["Henrystats", "synthquest"]\') }}' + , unique_key = ['contract_address'] ) }} -SELECT contract_address, symbol, decimals, name +SELECT blockchain, contract_address, backing, symbol, decimals, name FROM (VALUES - (0xc54A1684fD1bef1f077a336E6be4Bd9a3096a6Ca, '2SHARES', 18, '2SHARE'), - (0x04068DA6C83AFCFA0e13ba15A6696662335D5B75, 'USDC', 6, 'USD Coin'), - (0x049d68029688eAbF473097a2fC38ef61633A3C7A, 'fUSDT', 6, 'Frapped USDT'), - (0x8D11eC38a3EB5E956B052f67Da8Bdc9bef8Abf3E, 'DAI', 18, 'Dai Stablecoin'), - (0xdc301622e621166BD8E82f2cA0A26c13Ad0BE355, 'FRAX', 18, 'Frax'), - (0xAd84341756Bf337f5a0164515b1f6F993D194E1f, 'FUSD', 18, 'Fantom Foundation USD'), - (0x7a6e4E3CC2ac9924605DCa4bA31d1831c84b44aE, '2OMB', 18, '2omb Token'), - (0x846e4D51d7E2043C1a87E0Ab7490B93FB940357b, 'UST', 6, 'UST (Wormhole)'), - (0x87a5C9B60A3aaf1064006FE64285018e50e0d020, 'MAGIK', 18, 'Magik'), - (0x9879aBDea01a879644185341F7aF7d8343556B7a, 'TUSD', 18, 'TrueUSD'), - (0x1D3918043d22de2D799a4d80f72Efd50Db90B5Af, 'sPDO', 18, 'pDollar Share'), - (0x5f0456F728E2D59028b4f5B8Ad8C604100724C6A, 'L3USD', 18, 'L3USD'), - (0xb9D62c829fbF7eAff1EbA4E50F3D0480b66c1748, 'PDO', 18, 'pDollar') - ) AS temp_table (contract_address, symbol, decimals, name) \ No newline at end of file + ('fantom', 0x5f0456f728e2d59028b4f5b8ad8c604100724c6a, 'Hybrid stablecoin', 'L3USD', 18, 'L3USD'), + ('fantom', 0x3129662808bec728a27ab6a6b9afd3cbaca8a43c, 'Crypto-backed stablecoin', 'DOLA', 18, ''), + ('fantom', 0x9879abdea01a879644185341f7af7d8343556b7a, 'Fiat-backed stablecoin', 'TUSD', 18, 'TrueUSD'), + ('fantom', 0x0def844ed26409c5c46dda124ec28fb064d90d27, 'Hybrid stablecoin', 'CoUSD', 18, ''), + ('fantom', 0xb9d62c829fbf7eaff1eba4e50f3d0480b66c1748, 'Hybrid stablecoin', 'PDO', 18, 'pDollar'), + ('fantom', 0x7a6e4e3cc2ac9924605dca4ba31d1831c84b44ae, 'Hybrid stablecoin', '2OMB', 18, '2omb Token'), + ('fantom', 0x87a5c9b60a3aaf1064006fe64285018e50e0d020, 'Hybrid stablecoin', 'MAGIK', 18, 'Magik'), + ('fantom', 0x74e23df9110aa9ea0b6ff2faee01e740ca1c642e, 'Crypto-backed stablecoin', 'TOR', 18, ''), + ('fantom', 0xfb98b335551a418cd0737375a2ea0ded62ea213b, 'Crypto-backed stablecoin', 'miMATIC', 18, ''), + ('fantom', 0x04068da6c83afcfa0e13ba15a6696662335d5b75, 'Fiat-backed stablecoin', 'USDC', 6, 'USD Coin'), + ('fantom', 0x82f0b8b456c1a451378467398982d4834b6829c1, 'Crypto-backed stablecoin', 'MIM', 18, ''), + ('fantom', 0xdc301622e621166bd8e82f2ca0a26c13ad0be355, 'Hybrid stablecoin', 'FRAX', 18, 'Frax'), + ('fantom', 0xb67fa6defce4042070eb1ae1511dcd6dcc6a532e, 'Crypto-backed stablecoin', 'alUSD', 18, ''), + ('fantom', 0x846e4d51d7e2043c1a87e0ab7490b93fb940357b, 'Hybrid stablecoin', 'UST', 6, 'UST (Wormhole)'), + ('fantom', 0xad84341756bf337f5a0164515b1f6f993d194e1f, 'Hybrid stablecoin', 'FUSD', 18, 'Fantom Foundation USD'), + ('fantom', 0x049d68029688eabf473097a2fc38ef61633a3c7a, 'Fiat-backed stablecoin', 'fUSDT', 6, 'Frapped USDT'), + ('fantom', 0xe2d27f06f63d98b8e11b38b5b08a75d0c8dd62b9, 'Algorithmic stablecoin', 'UST', 6, ''), + ('fantom', 0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e, 'Crypto-backed stablecoin', 'DAI', 18, 'Dai Stablecoin'), + ('fantom', 0x6fc9383486c163fa48becdec79d6058f984f62ca, 'Hybrid stablecoin', 'USDB', 18, ''), + ('fantom', 0xc54a1684fd1bef1f077a336e6be4bd9a3096a6ca, 'Hybrid stablecoin', '2SHARES', 18, '2SHARE'), + ('fantom', 0x1d3918043d22de2d799a4d80f72efd50db90b5af, 'Hybrid stablecoin', 'sPDO', 18, 'pDollar Share') + + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/fantom/tokens_fantom_schema.yml b/dbt_subprojects/tokens/models/tokens/fantom/tokens_fantom_schema.yml index 4d6b5f3eb00..8ddf73fab1c 100644 --- a/dbt_subprojects/tokens/models/tokens/fantom/tokens_fantom_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/fantom/tokens_fantom_schema.yml @@ -89,23 +89,25 @@ models: - name: tokens_fantom_erc20_stablecoins meta: blockchain: fantom - sector: tokens - project: erc20 - contributors: Henrystats + sector: stablecoins + contributors: synthquest config: - tags: [ 'table', 'erc20', 'stablecoins' ] - description: "ERC20 Stablecoin Token Addresses, Symbols and Decimals" + tags: ['tokens', 'fantom', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. columns: + - name: blockchain + description: "Blockchain name" - name: contract_address - description: "ERC20 stablecoin token contract address" - tests: - - unique + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" - name: symbol - description: "ERC20 stablecoin token symbol" - - name: decimals - description: "Number of decimals, refers to how divisible an ERC20 stablecoin token can be" + description: "Stablecoin symbol" - name: name - description: "ERC20 stablecoin token name" + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" - name: tokens_fantom_nft_standards meta: diff --git a/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20_stablecoins.sql new file mode 100644 index 00000000000..e2e816c9eb3 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20_stablecoins.sql @@ -0,0 +1,21 @@ +{{ config( + schema = 'tokens_gnosis' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["gnosis"]\', + "sector", + "tokens_gnosis", + \'["synthquest"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + ('gnosis', 0xdd96b45877d0e8361a4ddb732da741e97f3191ff, 'Fiat-backed stablecoin', 'BUSD', 18, ''), + ('gnosis', 0x4ecaba5870353805a9f068101a40e0f32ed605c6, 'Fiat-backed stablecoin', 'USDT', 6, ''), + ('gnosis', 0x3f56e0c36d275367b8c502090edf38289b3dea0d, 'Crypto-backed stablecoin', 'MAI', 18, ''), + ('gnosis', 0x44fa8e6f47987339850636f88629646662444217, 'Hybrid stablecoin', 'DAI', 18, ''), + ('gnosis', 0xddafbb505ad214d7b80b1f830fccc89b60fb7a83, 'Fiat-backed stablecoin', 'USDC', 6, '') + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_schema.yml b/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_schema.yml index 30caa673f35..d53675e86d6 100644 --- a/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_schema.yml @@ -86,3 +86,26 @@ models: tests: - accepted_values: values: [ 'erc721', 'erc1155'] + + - name: tokens_gnosis_erc20_stablecoins + meta: + blockchain: gnosis + sector: stablecoins + contributors: synthquest + config: + tags: ['tokens', 'gnosis', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_stablecoins.sql index 36b166d1761..42837c64d4d 100644 --- a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_stablecoins.sql @@ -1,66 +1,49 @@ {{ config( - alias='stablecoins' + schema = 'tokens_optimism' + , alias = 'erc20_stablecoins' , tags=['static'] , post_hook='{{ expose_spells(\'["optimism"]\', "sector", "tokens_optimism", - \'["msilb7"]\') }}' + \'["msilb7", "synthquest"]\') }}' + , unique_key = ['contract_address'] ) }} --- In this table we include underlying stablecoin tokens on Optimism. --- LP Tokens (i.e. 3crv) should not be included since these are made up of udnerlying stables. --- This is a lookup tables that's helpful for any analysis that focuses on stablecoins. - -SELECT - tbl.contract_address - , et.symbol,et. decimals - , tbl.name, tbl.currency_peg, tbl.reserve_type - +SELECT blockchain, contract_address, backing, symbol, decimals, name FROM (VALUES - --Type sourced from Defillama's mappings when relevant: https://defillama.com/stablecoins - (0xda10009cbd5d07dd0cecc66161fc93d7c9000da1, 'Dai Stablecoin', 'USD', 'Crypto-Backed') - ,(0x94b008aa00579c1307b0ef2c499ad98a8ce58e58, 'Tether USD', 'USD', 'Fiat-Backed') - ,(0x7f5c764cbc14f9669b88837ca1490cca17c31607, 'USD Coin', 'USD', 'Fiat-Backed') - ,(0xc40f949f8a4e094d1b49a23ea9241d289b7b2819, 'LUSD Stablecoin', 'USD', 'Crypto-Backed') - ,(0xbfd291da8a403daaf7e5e9dc1ec0aceacd4848b9, 'dForce USD', 'USD', 'Crypto-Backed') - ,(0x2e3d870790dc77a83dd1d18184acc7439a53f475, 'FRAX', 'USD', 'Algorithmic') - ,(0xba28feb4b6a6b81e3f26f08b83a19e715c4294fd, 'UST (Wormhole)', 'USD', 'Algorithmic') - ,(0xfb21b70922b9f6e3c6274bcd6cb1aa8a0fe20b80, 'Terra USD', 'USD', 'Algorithmic') - ,(0x7113370218f31764c1b6353bdf6004d86ff6b9cc, 'Decentralized USD','USD','Algorithmic') - ,(0xcb59a0a753fdb7491d5f3d794316f1ade197b21e, 'TrueUSD','USD','Fiat-Backed') - ,(0xcb8fa9a76b8e203d8c3797bf438d8fb81ea3326a, 'Alchemix USD','USD','Algorithmic') - ,(0xb0b195aefa3650a6908f15cdac7d92f8a5791b0b, 'BOB','USD','Crypto-Backed') - ,(0xdfa46478f9e5ea86d57387849598dbfb2e964b02, 'Mai Stablecoin','USD','Crypto-Backed') - ,(0x7fb688ccf682d58f86d7e38e03f9d22e7705448b, 'Rai Reflex Index','None','Crypto-Backed') - ,(0x340fe1d898eccaad394e2ba0fc1f93d27c7b717a, 'Wrapped USDR','USD','Algorithmic') - ,(0x9c9e5fd8bbc25984b178fdce6117defa39d2db39, 'Binance-Peg BUSD Token','USD','Fiat-Backed') - ,(0xb153fb3d196a8eb25522705560ac152eeec57901, 'Magic Internet Money','USD','Crypto-Backed') - ,(0x8ae125e8653821e851f12a49f7765db9a9ce7384, 'Dola USD Stablecoin','USD','Crypto-Backed') - ,(0x73cb180bf0521828d8849bc8CF2B920918e23032, 'USD+', 'USD','Crypto-Backed') - ,(0x9485aca5bbbe1667ad97c7fe7c4531a624c8b1ed, 'agEUR', 'EUR', 'Crypto-Backed') - ,(0x79af5dd14e855823fa3e9ecacdf001d99647d043, 'Jarvis Synthetic Euro','EUR','Crypto-Backed') - ,(0x970d50d09f3a656b43e11b0d45241a84e3a6e011, 'DAI+', 'USD','Crypto-Backed') - - -- --Synthetix Tokens - ,(0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9, 'Synth sUSD', 'USD', 'Crypto-Backed') - ,(0xfbc4198702e81ae77c06d58f81b629bdf36f0a71, 'Synth sEUR', 'EUR', 'Crypto-Backed') - ,(0xa3a538ea5d5838dc32dde15946ccd74bdd5652ff, 'Synth sINR', 'INR', 'Crypto-Backed') - - - -- --Transfer Tokens (Common Among Bridges) - ,(0x25d8039bb044dc227f741a9e381ca4ceae2e6ae8, 'USD Coin Hop Token', 'USD', 'Bridge-Backed') - ,(0x3666f603cc164936c1b87e207f36beba4ac5f18a, 'USD Coin Hop Token', 'USD', 'Bridge-Backed') - ,(0x2057c8ecb70afd7bee667d76b4cd373a325b1a20, 'Tether USD Hop Token', 'USD', 'Bridge-Backed') - ,(0x56900d66d74cb14e3c86895789901c9135c95b16, 'DAI Hop Token', 'USD', 'Bridge-Backed') - ,(0x67c10c397dd0ba417329543c1a40eb48aaa7cd00, 'Synapse USD', 'USD', 'Bridge-Backed') - - ) AS tbl (contract_address, name, currency_peg, reserve_type) - --- JOIN FOR DATA QUALITY --- -- Enforce that the token is listen in "tokens_optimism_erc20.sql" --- -- Pull symbol and decimals from root table - -INNER JOIN {{source('tokens_optimism', 'erc20')}} et - ON et.contract_address = tbl.contract_address - AND et.is_counted_in_tvl = 1 -- Make sure we don't include any receipt or placeholder tokens + ('optimism', 0xfb21b70922b9f6e3c6274bcd6cb1aa8a0fe20b80, 'Algorithmic stablecoin', 'UST', 6, 'Terra USD'), + ('optimism', 0x970d50d09f3a656b43e11b0d45241a84e3a6e011, 'Crypto-backed stablecoin', 'DAI+', 18, 'DAI+'), + ('optimism', 0xdfa46478f9e5ea86d57387849598dbfb2e964b02, 'Crypto-backed stablecoin', 'MAI', 18, 'Mai Stablecoin'), + ('optimism', 0x3666f603cc164936c1b87e207f36beba4ac5f18a, 'Bridge-backed stablecoin', 'hUSD', 6, 'USD Coin Hop Token'), + ('optimism', 0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9, 'Crypto-backed stablecoin', 'sUSD', 18, 'Synth sUSD'), + ('optimism', 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1, 'Crypto-backed stablecoin', 'DAI', 18, 'Dai Stablecoin'), + ('optimism', 0xc40f949f8a4e094d1b49a23ea9241d289b7b2819, 'Crypto-backed stablecoin', 'LUSD', 18, 'LUSD Stablecoin'), + ('optimism', 0x25d8039bb044dc227f741a9e381ca4ceae2e6ae8, 'Bridge-backed stablecoin', 'hUSDC', 6, 'USD Coin Hop Token'), + ('optimism', 0x79af5dd14e855823fa3e9ecacdf001d99647d043, 'Crypto-backed stablecoin', 'EUR', 18, 'Jarvis Synthetic Euro'), + ('optimism', 0xfbc4198702e81ae77c06d58f81b629bdf36f0a71, 'Crypto-backed stablecoin', 'sEUR', 18, 'Synth sEUR'), + ('optimism', 0xcb59a0a753fdb7491d5f3d794316f1ade197b21e, 'Fiat-backed stablecoin', 'TUSD', 18, 'TrueUSD'), + ('optimism', 0x7fb688ccf682d58f86d7e38e03f9d22e7705448b, 'Crypto-backed stablecoin', 'RAI', 18, 'Rai Reflex Index'), + ('optimism', 0xcb8fa9a76b8e203d8c3797bf438d8fb81ea3326a, 'Algorithmic stablecoin', 'alUSD', 18, 'Alchemix USD'), + ('optimism', 0x340fe1d898eccaad394e2ba0fc1f93d27c7b717a, 'Algorithmic stablecoin', 'wUSDR', 9, 'Wrapped USDR'), + ('optimism', 0x2e3d870790dc77a83dd1d18184acc7439a53f475, 'Hybrid stablecoin', 'FRAX', 18, 'FRAX'), + ('optimism', 0xb0b195aefa3650a6908f15cdac7d92f8a5791b0b, 'Crypto-backed stablecoin', 'BOB', 18, 'BOB'), + ('optimism', 0x8ae125e8653821e851f12a49f7765db9a9ce7384, 'Crypto-backed stablecoin', 'DOLA', 18, 'Dola USD Stablecoin'), + ('optimism', 0x0b2c639c533813f4aa9d7837caf62653d097ff85, 'Fiat-backed stablecoin', 'USDC', 6, 'Circle USDC'), + ('optimism', 0x67c10c397dd0ba417329543c1a40eb48aaa7cd00, 'Bridge-backed stablecoin', 'nUSD', 18, 'Synapse USD'), + ('optimism', 0x56900d66d74cb14e3c86895789901c9135c95b16, 'Bridge-backed stablecoin', 'hDAI', 18, 'DAI Hop Token'), + ('optimism', 0x73cb180bf0521828d8849bc8cf2b920918e23032, 'Crypto-backed stablecoin', 'USD+', 6, 'USD+'), + ('optimism', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 'Fiat-backed stablecoin', 'USDM', 18, ''), + ('optimism', 0xb153fb3d196a8eb25522705560ac152eeec57901, 'Crypto-backed stablecoin', 'MIM', 18, 'Magic Internet Money'), + ('optimism', 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58, 'Fiat-backed stablecoin', 'USDT', 6, 'Tether USD'), + ('optimism', 0x7f5c764cbc14f9669b88837ca1490cca17c31607, 'Fiat-backed stablecoin', 'USDC.e', 6, 'USD Coin'), + ('optimism', 0xa3a538ea5d5838dc32dde15946ccd74bdd5652ff, 'Crypto-backed stablecoin', 'sINR', 18, 'Synth sINR'), + ('optimism', 0x9c9e5fd8bbc25984b178fdce6117defa39d2db39, 'Fiat-backed stablecoin', 'BUSD', 18, 'Binance-Peg BUSD Token'), + ('optimism', 0x7113370218f31764c1b6353bdf6004d86ff6b9cc, 'Algorithmic stablecoin', 'USDD', 18, 'Decentralized USD'), + ('optimism', 0x2057c8ecb70afd7bee667d76b4cd373a325b1a20, 'Bridge-backed stablecoin', 'hUSDT', 6, 'Tether USD Hop Token'), + ('optimism', 0x9485aca5bbbe1667ad97c7fe7c4531a624c8b1ed, 'Crypto-backed stablecoin', 'agEUR', 18, 'agEUR'), + ('optimism', 0xbfd291da8a403daaf7e5e9dc1ec0aceacd4848b9, 'Crypto-backed stablecoin', 'USX', 18, 'dForce USD'), + ('optimism', 0xba28feb4b6a6b81e3f26f08b83a19e715c4294fd, 'Algorithmic stablecoin', 'UST', 6, 'UST (Wormhole)') + + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml index 9038606ca81..b3bb4c83c68 100644 --- a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml @@ -172,32 +172,25 @@ models: - name: tokens_optimism_erc20_stablecoins meta: blockchain: optimism - sector: tokens - project: erc20 - contributors: msilb7 + sector: stablecoins + contributors: synthquest config: - tags: [ 'table', 'erc20', 'stablecoins' ] - description: "Optimism ERC20 Stablecoin Token Addresses, Symbols, Decimals, and Information" + tags: ['tokens', 'optimism', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. columns: + - name: blockchain + description: "Blockchain name" - name: contract_address - description: "ERC20 stablecoin token contract address" - tests: - - unique - - not_null + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" - name: symbol - description: "ERC20 stablecoin token symbol" - - name: decimals - description: "Number of decimals, refers to how divisible an ERC20 stablecoin token can be" + description: "Stablecoin symbol" - name: name - description: "ERC20 stablecoin token name" - - name: currency_peg - description: "What currency is the stablecoin pegged to" - - &reserve_type - name: reserve_type - description: "What is the type of backing for the stablecoin" - tests: - - accepted_values: - values: ['Crypto-Backed','Fiat-Backed','Algorithmic','Bridge-Backed'] + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" - name: tokens_optimism_nft_standards meta: diff --git a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20_stablecoins.sql new file mode 100644 index 00000000000..3e705292284 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20_stablecoins.sql @@ -0,0 +1,37 @@ +{{ config( + schema = 'tokens_polygon' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["polygon"]\', + "sector", + "tokens_polygon", + \'["synthquest"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + ('polygon', 0x2791bca1f2de4661ed88a30c99a7a9449aa84174, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('polygon', 0x3c499c542cef5e3811e1192ce70d8cc03d5c3359, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('polygon', 0x692597b009d13c4049a947cab2239b7d6517875f, 'Algorithmic stablecoin', 'UST', 18, ''), + ('polygon', 0xcf66eb3d546f0415b368d98a95eaf56ded7aa752, 'Crypto-backed stablecoin', 'USX', 18, ''), + ('polygon', 0x8f3cf7ad23cd3cadbd9735aff958023239c6a063, 'Hybrid stablecoin', 'DAI', 18, ''), + ('polygon', 0x2e1ad108ff1d8c782fcbbb89aad783ac49586756, 'Fiat-backed stablecoin', 'TUSD', 18, ''), + ('polygon', 0xd86b5923f3ad7b585ed81b448170ae026c65ae9a, 'Hybrid stablecoin', 'IRON', 18, ''), + ('polygon', 0xffa4d863c96e743a2e1513824ea006b8d0353c57, 'Algorithmic stablecoin', 'USDD', 18, ''), + ('polygon', 0x9c9e5fd8bbc25984b178fdce6117defa39d2db39, 'Fiat-backed stablecoin', 'BUSD', 18, ''), + ('polygon', 0x49a0400587a7f65072c87c4910449fdcc5c47242, 'Crypto-backed stablecoin', 'MIM', 18, ''), + ('polygon', 0x2f1b1662a895c6ba01a99dcaf56778e7d77e5609, 'Hybrid stablecoin', 'USDS', 18, ''), + ('polygon', 0xaf0d9d65fc54de245cda37af3d18cbec860a4d4b, 'RWA-backed stablecoin', 'wUSDR', 9, ''), + ('polygon', 0x45c32fa6df82ead1e2ef74d17b76547eddfaff89, 'Hybrid stablecoin', 'FRAX', 18, ''), + ('polygon', 0x66f31345cb9477b427a1036d43f923a557c432a4, 'Hybrid stablecoin', 'iUSDS', 18, ''), + ('polygon', 0xb0b195aefa3650a6908f15cdac7d92f8a5791b0b, 'Crypto-backed stablecoin', 'BOB', 18, ''), + ('polygon', 0xc2132d05d31c914a87c6611c10748aeb04b58e8f, 'Fiat-backed stablecoin', 'USDT', 6, ''), + ('polygon', 0xa3fa99a148fa48d14ed51d610c367c61876997f1, 'Crypto-backed stablecoin', 'miMATIC', 18, ''), + ('polygon', 0xdab529f40e671a1d4bf91361c21bf9f0c9712ab7, 'Fiat-backed stablecoin', 'BUSD', 18, ''), + ('polygon', 0x3a3e7650f8b9f667da98f236010fbf44ee4b2975, 'Crypto-backed stablecoin', 'xUSD', 18, ''), + ('polygon', 0x23001f892c0c82b79303edc9b9033cd190bb21c7, 'Crypto-backed stablecoin', 'LUSD', 18, '') + + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_schema.yml b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_schema.yml index 5056c5f769e..69aa6724c74 100644 --- a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_schema.yml @@ -81,3 +81,26 @@ models: tests: - accepted_values: values: [ 'erc721', 'erc1155' ] + + - name: tokens_polygon_erc20_stablecoins + meta: + blockchain: polygon + sector: stablecoins + contributors: synthquest + config: + tags: ['tokens', 'polygon', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/tokens_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/tokens_erc20_stablecoins.sql new file mode 100644 index 00000000000..a51741e0877 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/tokens_erc20_stablecoins.sql @@ -0,0 +1,42 @@ +{{ config( + schema='tokens', + alias = 'erc20_stablecoins', + materialized='table', + tags = ['static'], + post_hook = '{{ expose_spells(\'["ethereum", "arbitrum", "gnosis", "optimism", "bnb", "avalanche_c", "polygon", "fantom", "base"]\', + "sector", + "stablecoins", + \'["synthquest"]\') }}' + ) +}} + +{% set stables_models = [ + ref('tokens_arbitrum_erc20_stablecoins') +, ref('tokens_avalanche_c_erc20_stablecoins') +, ref('tokens_bnb_erc20_stablecoins') +, ref('tokens_ethereum_erc20_stablecoins') +, ref('tokens_fantom_erc20_stablecoins') +, ref('tokens_gnosis_erc20_stablecoins') +, ref('tokens_optimism_erc20_stablecoins') +, ref('tokens_polygon_erc20_stablecoins') +, ref('tokens_base_erc20_stablecoins') +] %} + + +SELECT * +FROM +( + {% for model in stables_models %} + SELECT + blockchain + , contract_address + , backing + , symbol + , decimals + , name + FROM {{ model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} +) From 13078ca92aea8622df5db6fd7ab6b062412f776c Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:26:49 -0400 Subject: [PATCH 055/127] `prices_trusted_tokens` add decimals, cleanup model design (#6758) * add decimals, cleanup model design * update to handle non evm * add to select --- .../tokens/models/prices/_schema.yml | 12 +- .../models/prices/prices_trusted_tokens.sql | 282 ++++++++++-------- 2 files changed, 164 insertions(+), 130 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/_schema.yml b/dbt_subprojects/tokens/models/prices/_schema.yml index 4c52e2e0c21..4b2c89003aa 100644 --- a/dbt_subprojects/tokens/models/prices/_schema.yml +++ b/dbt_subprojects/tokens/models/prices/_schema.yml @@ -52,7 +52,7 @@ models: - name: prices_trusted_tokens meta: sector: prices - contributors: hosuke + contributors: hosuke, jeff-dude config: tags: [ 'prices', 'stability' ] description: "List of trusted tokens across blockchains" @@ -62,9 +62,7 @@ models: - blockchain - contract_address columns: - - name: blockchain - description: "Native blockchain of the token" - - name: symbol - description: "Token symbol" - - name: contract_address - description: "Contract address of the token" + - *blockchain + - *contract_address + - *symbol + - *decimals \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql index 6c01f1c23b8..c80d07f4d7a 100644 --- a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql @@ -7,126 +7,162 @@ ) }} - --- Generated from https://dune.com/queries/3355223 -SELECT blockchain AS blockchain - , symbol AS symbol - , contract_address AS contract_address -FROM (VALUES ('arbitrum', 'USDC.e', 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8), - ('arbitrum', 'WETH', 0x82af49447d8a07e3bd95bd0d56f35241523fbab1), - ('arbitrum', 'USDC', 0xaf88d065e77c8cc2239327c5edb3a432268e5831), - ('arbitrum', 'USDT', 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9), - ('arbitrum', 'ARB', 0x912ce59144191c1204e64559fe8253a0e49e6548), - ('arbitrum', 'WBTC', 0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f), - ('arbitrum', 'DAI', 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1), - ('avalanche_c', 'WAVAX', 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7), - ('avalanche_c', 'USDC', 0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e), - ('avalanche_c', 'USDt', 0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7), - ('avalanche_c', 'USDT.e', 0xc7198437980c041c805a1edcba50c1ce5db95118), - ('avalanche_c', 'BTC.b', 0x152b9d0fdc40c096757f570a51e494bd4b943e50), - ('avalanche_c', 'WETH.e', 0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab), - ('avalanche_c', 'DAI.e', 0xd586e7f844cea2f87f50152665bcbc2c279d8d70), - ('base', 'USDbC', 0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca), - ('base', 'USDC', 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913), - ('base', 'WETH', 0x4200000000000000000000000000000000000006), - ('base', 'DAI', 0x50c5725949a6f0c72e6c4a641f24049a917db0cb), - ('base', 'axlUSDC', 0xeb466342c4d449bc9f53a865d5cb90586f405215), - ('base', 'cbETH', 0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22), - ('base', 'wstETH', 0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452), - ('bnb', 'USDT', 0x55d398326f99059ff775485246999027b3197955), - ('bnb', 'WBNB', 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c), - ('bnb', 'BUSD', 0xe9e7cea3dedca5984780bafc599bd69add087d56), - ('bnb', 'USDC', 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d), - ('bnb', 'ETH', 0x2170ed0880ac9a755fd29b2688956bd959f933f8), - ('bnb', 'BTCB', 0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c), - ('bnb', 'DAI', 0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3), - ('celo', 'cUSD', 0x765de816845861e75a25fca122bb6898b8b1282a), - ('celo', 'CELO', 0x471ece3750da237f93b8e339c536989b8978a438), - ('celo', 'USDC', 0xceba9300f2b948710d2653dd7b07f33a8b32118c), - ('celo', 'cEUR', 0xd8763cba276a3738e6de85b4b3bf5fded6d6ca73), - ('celo', 'BTC', 0xd629eb00deced2a080b7ec630ef6ac117e614f1b), - ('celo', 'BIFI', 0x639a647fbe20b6c8ac19e48e2de44ea792c62c5c), - ('celo', 'USDâ‚®', 0x48065fbbe25f71c9282ddf5e1cd6d6a887483d5e), - ('ethereum', 'WETH', 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2), - ('ethereum', 'USDT', 0xdac17f958d2ee523a2206206994597c13d831ec7), - ('ethereum', 'USDC', 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48), - ('ethereum', 'DAI', 0x6b175474e89094c44da98b954eedeac495271d0f), - ('ethereum', 'WBTC', 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599), - ('ethereum', 'crvUSD', 0xf939e0a03fb07f59a73314e73794be0e57ac1b4e), - ('fantom', 'WFTM', 0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83), - ('fantom', 'USDC', 0x04068da6c83afcfa0e13ba15a6696662335d5b75), - ('fantom', 'WETH', 0x74b23882a30290451a17c44f4f05243b6b58c76d), - ('fantom', 'DAI', 0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e), - ('fantom', 'WBTC', 0x321162cd933e2be498cd2267a90534a804051b11), - ('fantom', 'axlUSDC', 0x1b6382dbdea11d97f24495c9a90b7c88469134a4), - ('fantom', 'USDC', 0x28a92dde19d9989f39a49905d7c9c2fac7799bdf), - ('gnosis', 'WXDAI', 0xe91d153e0b41518a2ce8dd3d7944fa863463a97d), - ('gnosis', 'WETH', 0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1), - ('gnosis', 'USDC', 0xddafbb505ad214d7b80b1f830fccc89b60fb7a83), - ('gnosis', 'wstETH', 0x6c76971f98945ae98dd7d4dfca8711ebea946ea6), - ('gnosis', 'GNO', 0x9c58bacc331c9aa871afd802db6379a98e80cedb), - ('gnosis', 'USDT', 0x4ecaba5870353805a9f068101a40e0f32ed605c6), - ('gnosis', 'WBTC', 0x8e5bbbb09ed1ebde8674cda39a0c169401db4252), - ('gnosis', 'DAI', 0x44fa8e6f47987339850636f88629646662444217), - ('gnosis', 'BUSD', 0xdd96b45877d0e8361a4ddb732da741e97f3191ff), - ('linea', 'WETH', 0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f), - ('linea', 'USDC', 0x176211869ca2b568f2a7d4ee941e073a821ee1ff), - ('linea', 'USDT', 0xa219439258ca9da29e9cc4ce5596924745e12b93), - ('linea', 'WBTC', 0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4), - ('linea', 'wstETH', 0xb5bedd42000b71fdde22d3ee8a79bd49a568fc8f), - ('mantle', 'USDT', 0x201eba5cc46d216ce6dc03f6a759e8e766e956ae), - ('mantle', 'WETH', 0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111), - ('mantle', 'USDC', 0x09bc4e0d864854c6afb6eb9a9cdf58ac190d0df9), - ('mantle', 'mETH', 0xcda86a272531e8640cd7f1a92c01839911b90bb0), - ('mantle', 'MNT', 0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000), - ('mantle', 'JOE', 0x371c7ec6d8039ff7933a2aa28eb827ffe1f52f07), - ('mantle', 'WMNT', 0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8), - ('mantle', 'axlUSDC', 0xeb466342c4d449bc9f53a865d5cb90586f405215), - ('optimism', 'USDC.e', 0x7f5c764cbc14f9669b88837ca1490cca17c31607), - ('optimism', 'WETH', 0x4200000000000000000000000000000000000006), - ('optimism', 'USDT', 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58), - ('optimism', 'USDC', 0x0b2c639c533813f4aa9d7837caf62653d097ff85), - ('optimism', 'DAI', 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1), - ('optimism', 'OP', 0x4200000000000000000000000000000000000042), - ('optimism', 'WBTC', 0x68f180fcce6836688e9084f035309e29bf0a2095), - ('optimism', 'sUSD', 0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9), - ('optimism', 'wstETH', 0x1f32b1c2345538c0c6f582fcb022739c4a194ebb), - ('optimism', 'WLD', 0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1), - ('polygon', 'USDC.e', 0x2791bca1f2de4661ed88a30c99a7a9449aa84174), - ('polygon', 'USDT', 0xc2132d05d31c914a87c6611c10748aeb04b58e8f), - ('polygon', 'WMATIC', 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270), - ('polygon', 'WETH', 0x7ceb23fd6bc0add59e62ac25578270cff1b9f619), - ('polygon', 'DAI', 0x8f3cf7ad23cd3cadbd9735aff958023239c6a063), - ('polygon', 'WBTC', 0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6), - ('polygon', 'USDC', 0x3c499c542cef5e3811e1192ce70d8cc03d5c3359), - ('scroll', 'USDC', 0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4), - ('scroll', 'WETH', 0x5300000000000000000000000000000000000004), - ('scroll', 'USDT', 0xf55bec9cafdbe8730f096aa55dad6d22d44099df), - ('scroll', 'WBTC', 0x3c1bca5a656e69edcd0d4e36bebb3fcdaca60cf1), - ('scroll', 'wstETH', 0xf610a9dfb7c89644979b4a0f27063e9e7d7cda32), - ('solana', 'SOL', from_base58('So11111111111111111111111111111111111111112')), - ('solana', 'mSOL', from_base58('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So')), - ('solana', 'USDT', from_base58('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')), - ('solana', 'USDC', from_base58('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')), - ('zkevm', 'WETH', 0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9), - ('zkevm', 'USDT', 0x1e4a5963abfd975d8c9021ce480b42188849d41d), - ('zkevm', 'USDC', 0x37eaa0ef3549a5bb7d431be78a3d99bd360d19e5), - ('zkevm', 'MATIC', 0xa2036f0538221a77a3937f1379699f44945018d0), - ('zkevm', 'rETH', 0xb23c20efce6e24acca0cef9b7b7aa196b84ec942), - ('zksync', 'USDC.e', 0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4), - ('zksync', 'BUSD', 0x2039bb4116b4efc145ec4f0e2ea75012d6c0f181), - ('zksync', 'WETH', 0x5aea5775959fbc2557cc8789bc1bf90a239d9a91), - ('zksync', 'USDT.e', 0x493257fd37edb34451f62edf8d2a0c418852ba4c), - ('zksync', 'ETH', 0x000000000000000000000000000000000000800a), - ('zksync', 'WBTC', 0xbbeb516fb02a01611cbbe0453fe3c580d7281011), - ('zora', 'WETH', 0x4200000000000000000000000000000000000006), - ('sei', 'WSEI', 0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7), - ('sei', 'USDC', 0x3894085Ef7Ff0f0aeDf52E2A2704928d1Ec074F1), - ('sei', 'USDT', 0xB75D0B03c06A926e488e2659DF1A861F860bD3d1), - ('sei', 'WETH', 0x160345fC359604fC6e70E3c5fAcbdE5F7A9342d8), - ('nova', 'USDC', 0x750ba8b76187092B0D1E87E28daaf484d1b5273b), - ('nova', 'WBTC', 0x1d05e4e72cD994cdF976181CfB0707345763564d), - ('nova', 'DAI', 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1), - ('nova', 'WETH', 0x722E8BdD2ce80A4422E880164f2079488e115365), - ('nova', 'ARB', 0xf823C3cD3CeBE0a1fA952ba88Dc9EEf8e0Bf46AD) -) AS t (blockchain, symbol, contract_address) +WITH evm_trusted_tokens AS ( + -- Originally generated from https://dune.com/queries/3355223 + -- Maintained manually moving forward + SELECT + blockchain + , contract_address + FROM ( + VALUES + ('arbitrum', 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8) + , ('arbitrum', 0x82af49447d8a07e3bd95bd0d56f35241523fbab1) + , ('arbitrum', 0xaf88d065e77c8cc2239327c5edb3a432268e5831) + , ('arbitrum', 0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9) + , ('arbitrum', 0x912ce59144191c1204e64559fe8253a0e49e6548) + , ('arbitrum', 0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f) + , ('arbitrum', 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1) + , ('avalanche_c', 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7) + , ('avalanche_c', 0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e) + , ('avalanche_c', 0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7) + , ('avalanche_c', 0xc7198437980c041c805a1edcba50c1ce5db95118) + , ('avalanche_c', 0x152b9d0fdc40c096757f570a51e494bd4b943e50) + , ('avalanche_c', 0x49d5c2bdffac6ce2bfdb6640f4f80f226bc10bab) + , ('avalanche_c', 0xd586e7f844cea2f87f50152665bcbc2c279d8d70) + , ('base', 0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca) + , ('base', 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913) + , ('base', 0x4200000000000000000000000000000000000006) + , ('base', 0x50c5725949a6f0c72e6c4a641f24049a917db0cb) + , ('base', 0xeb466342c4d449bc9f53a865d5cb90586f405215) + , ('base', 0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22) + , ('base', 0xc1cba3fcea344f92d9239c08c0568f6f2f0ee452) + , ('blast', 0x4300000000000000000000000000000000000004) + , ('blast', 0x4300000000000000000000000000000000000003) + , ('blast', 0xb1a5700fa2358173fe465e6ea4ff52e36e88e2ad) + , ('blast', 0xf77dd21c5ce38ac08786be35ef1d1dec1a6a15f3) + , ('bnb', 0x55d398326f99059ff775485246999027b3197955) + , ('bnb', 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c) + , ('bnb', 0xe9e7cea3dedca5984780bafc599bd69add087d56) + , ('bnb', 0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d) + , ('bnb', 0x2170ed0880ac9a755fd29b2688956bd959f933f8) + , ('bnb', 0x7130d2a12b9bcbfae4f2634d864a1ee1ce3ead9c) + , ('bnb', 0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3) + , ('celo', 0x765de816845861e75a25fca122bb6898b8b1282a) + , ('celo', 0x471ece3750da237f93b8e339c536989b8978a438) + , ('celo', 0xceba9300f2b948710d2653dd7b07f33a8b32118c) + , ('celo', 0xd8763cba276a3738e6de85b4b3bf5fded6d6ca73) + , ('celo', 0xd629eb00deced2a080b7ec630ef6ac117e614f1b) + , ('celo', 0x639a647fbe20b6c8ac19e48e2de44ea792c62c5c) + , ('celo', 0x48065fbbe25f71c9282ddf5e1cd6d6a887483d5e) + , ('ethereum', 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2) + , ('ethereum', 0xdac17f958d2ee523a2206206994597c13d831ec7) + , ('ethereum', 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48) + , ('ethereum', 0x6b175474e89094c44da98b954eedeac495271d0f) + , ('ethereum', 0x2260fac5e5542a773aa44fbcfedf7c193bc2c599) + , ('ethereum', 0xf939e0a03fb07f59a73314e73794be0e57ac1b4e) + , ('fantom', 0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83) + , ('fantom', 0x04068da6c83afcfa0e13ba15a6696662335d5b75) + , ('fantom', 0x74b23882a30290451a17c44f4f05243b6b58c76d) + , ('fantom', 0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e) + , ('fantom', 0x321162cd933e2be498cd2267a90534a804051b11) + , ('fantom', 0x1b6382dbdea11d97f24495c9a90b7c88469134a4) + , ('fantom', 0x28a92dde19d9989f39a49905d7c9c2fac7799bdf) + , ('gnosis', 0xe91d153e0b41518a2ce8dd3d7944fa863463a97d) + , ('gnosis', 0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1) + , ('gnosis', 0xddafbb505ad214d7b80b1f830fccc89b60fb7a83) + , ('gnosis', 0x6c76971f98945ae98dd7d4dfca8711ebea946ea6) + , ('gnosis', 0x9c58bacc331c9aa871afd802db6379a98e80cedb) + , ('gnosis', 0x4ecaba5870353805a9f068101a40e0f32ed605c6) + , ('gnosis', 0x8e5bbbb09ed1ebde8674cda39a0c169401db4252) + , ('gnosis', 0x44fa8e6f47987339850636f88629646662444217) + , ('gnosis', 0xdd96b45877d0e8361a4ddb732da741e97f3191ff) + , ('linea', 0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f) + , ('linea', 0x176211869ca2b568f2a7d4ee941e073a821ee1ff) + , ('linea', 0xa219439258ca9da29e9cc4ce5596924745e12b93) + , ('linea', 0x3aab2285ddcddad8edf438c1bab47e1a9d05a9b4) + , ('linea', 0xb5bedd42000b71fdde22d3ee8a79bd49a568fc8f) + , ('mantle', 0x201eba5cc46d216ce6dc03f6a759e8e766e956ae) + , ('mantle', 0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111) + , ('mantle', 0x09bc4e0d864854c6afb6eb9a9cdf58ac190d0df9) + , ('mantle', 0xcda86a272531e8640cd7f1a92c01839911b90bb0) + , ('mantle', 0xdeaddeaddeaddeaddeaddeaddeaddeaddead0000) + , ('mantle', 0x371c7ec6d8039ff7933a2aa28eb827ffe1f52f07) + , ('mantle', 0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8) + , ('mantle', 0xeb466342c4d449bc9f53a865d5cb90586f405215) + , ('nova', 0x750ba8b76187092B0D1E87E28daaf484d1b5273b) + , ('nova', 0x1d05e4e72cD994cdF976181CfB0707345763564d) + , ('nova', 0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1) + , ('nova', 0x722E8BdD2ce80A4422E880164f2079488e115365) + , ('nova', 0xf823C3cD3CeBE0a1fA952ba88Dc9EEf8e0Bf46AD) + , ('optimism', 0x7f5c764cbc14f9669b88837ca1490cca17c31607) + , ('optimism', 0x4200000000000000000000000000000000000006) + , ('optimism', 0x94b008aa00579c1307b0ef2c499ad98a8ce58e58) + , ('optimism', 0x0b2c639c533813f4aa9d7837caf62653d097ff85) + , ('optimism', 0xda10009cbd5d07dd0cecc66161fc93d7c9000da1) + , ('optimism', 0x4200000000000000000000000000000000000042) + , ('optimism', 0x68f180fcce6836688e9084f035309e29bf0a2095) + , ('optimism', 0x8c6f28f2f1a3c87f0f938b96d27520d9751ec8d9) + , ('optimism', 0x1f32b1c2345538c0c6f582fcb022739c4a194ebb) + , ('optimism', 0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1) + , ('polygon', 0x2791bca1f2de4661ed88a30c99a7a9449aa84174) + , ('polygon', 0xc2132d05d31c914a87c6611c10748aeb04b58e8f) + , ('polygon', 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270) + , ('polygon', 0x7ceb23fd6bc0add59e62ac25578270cff1b9f619) + , ('polygon', 0x8f3cf7ad23cd3cadbd9735aff958023239c6a063) + , ('polygon', 0x1bfd67037b42cf73acf2047067bd4f2c47d9bfd6) + , ('polygon', 0x3c499c542cef5e3811e1192ce70d8cc03d5c3359) + , ('scroll', 0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4) + , ('scroll', 0x5300000000000000000000000000000000000004) + , ('scroll', 0xf55bec9cafdbe8730f096aa55dad6d22d44099df) + , ('scroll', 0x3c1bca5a656e69edcd0d4e36bebb3fcdaca60cf1) + , ('scroll', 0xf610a9dfb7c89644979b4a0f27063e9e7d7cda32) + , ('sei', 0xE30feDd158A2e3b13e9badaeABaFc5516e95e8C7) + , ('sei', 0x3894085Ef7Ff0f0aeDf52E2A2704928d1Ec074F1) + , ('sei', 0xB75D0B03c06A926e488e2659DF1A861F860bD3d1) + , ('sei', 0x160345fC359604fC6e70E3c5fAcbdE5F7A9342d8) + , ('zkevm', 0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9) + , ('zkevm', 0x1e4a5963abfd975d8c9021ce480b42188849d41d) + , ('zkevm', 0x37eaa0ef3549a5bb7d431be78a3d99bd360d19e5) + , ('zkevm', 0xa2036f0538221a77a3937f1379699f44945018d0) + , ('zkevm', 0xb23c20efce6e24acca0cef9b7b7aa196b84ec942) + , ('zksync', 0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4) + , ('zksync', 0x2039bb4116b4efc145ec4f0e2ea75012d6c0f181) + , ('zksync', 0x5aea5775959fbc2557cc8789bc1bf90a239d9a91) + , ('zksync', 0x493257fd37edb34451f62edf8d2a0c418852ba4c) + , ('zksync', 0x000000000000000000000000000000000000800a) + , ('zksync', 0xbbeb516fb02a01611cbbe0453fe3c580d7281011) + , ('zora', 0x4200000000000000000000000000000000000006) + ) AS t (blockchain, contract_address) +), non_evm_trusted_tokens AS ( + SELECT + blockchain + , contract_address + , symbol + , decimals + FROM ( + VALUES + ('solana', from_base58('So11111111111111111111111111111111111111112'), 'SOL', 9) + , ('solana', from_base58('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'), 'mSOL', 9) + , ('solana', from_base58('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'), 'USDT', 6) + , ('solana', from_base58('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'), 'USDC', 6) + ) AS t (blockchain, contract_address, symbol, decimals) +) +SELECT + tt.blockchain + , tt.contract_address + , erc20.symbol + , erc20.decimals +FROM + evm_trusted_tokens AS tt +INNER JOIN + {{ ref('tokens_erc20') }} AS erc20 + ON tt.blockchain = erc20.blockchain + AND tt.contract_address = erc20.contract_address +UNION ALL +SELECT + blockchain + , contract_address + , symbol + , decimals +FROM + non_evm_trusted_tokens \ No newline at end of file From 7e1a69c15f6088e93a26d0903e33ecf08ad9e44d Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Wed, 18 Sep 2024 18:51:35 -0400 Subject: [PATCH 056/127] update `prices_trusted_tokens` round two (#6759) * add decimals, cleanup model design * update to handle non evm * add to select * change to join to prices tokens, grab token id --- .../models/prices/prices_trusted_tokens.sql | 44 ++++++------------- 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql index c80d07f4d7a..bbca149afe6 100644 --- a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql @@ -7,7 +7,7 @@ ) }} -WITH evm_trusted_tokens AS ( +WITH trusted_tokens AS ( -- Originally generated from https://dune.com/queries/3355223 -- Maintained manually moving forward SELECT @@ -120,6 +120,10 @@ WITH evm_trusted_tokens AS ( , ('sei', 0x3894085Ef7Ff0f0aeDf52E2A2704928d1Ec074F1) , ('sei', 0xB75D0B03c06A926e488e2659DF1A861F860bD3d1) , ('sei', 0x160345fC359604fC6e70E3c5fAcbdE5F7A9342d8) + , ('solana', from_base58('So11111111111111111111111111111111111111112')) + , ('solana', from_base58('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So')) + , ('solana', from_base58('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB')) + , ('solana', from_base58('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')) , ('zkevm', 0x4f9a0e7fd2bf6067db6994cf12e4495df938e6e9) , ('zkevm', 0x1e4a5963abfd975d8c9021ce480b42188849d41d) , ('zkevm', 0x37eaa0ef3549a5bb7d431be78a3d99bd360d19e5) @@ -133,36 +137,16 @@ WITH evm_trusted_tokens AS ( , ('zksync', 0xbbeb516fb02a01611cbbe0453fe3c580d7281011) , ('zora', 0x4200000000000000000000000000000000000006) ) AS t (blockchain, contract_address) -), non_evm_trusted_tokens AS ( - SELECT - blockchain - , contract_address - , symbol - , decimals - FROM ( - VALUES - ('solana', from_base58('So11111111111111111111111111111111111111112'), 'SOL', 9) - , ('solana', from_base58('mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'), 'mSOL', 9) - , ('solana', from_base58('Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB'), 'USDT', 6) - , ('solana', from_base58('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'), 'USDC', 6) - ) AS t (blockchain, contract_address, symbol, decimals) ) SELECT - tt.blockchain - , tt.contract_address - , erc20.symbol - , erc20.decimals + p.token_id + , p.blockchain + , p.contract_address + , p.symbol + , p.decimals FROM - evm_trusted_tokens AS tt + {{ ref('prices_tokens') }} AS p INNER JOIN - {{ ref('tokens_erc20') }} AS erc20 - ON tt.blockchain = erc20.blockchain - AND tt.contract_address = erc20.contract_address -UNION ALL -SELECT - blockchain - , contract_address - , symbol - , decimals -FROM - non_evm_trusted_tokens \ No newline at end of file + trusted_tokens AS tt + ON p.blockchain = tt.blockchain + AND p.contract_address = tt.contract_address From 85571a14c83015bd08f935c03cc953095c9ccd3f Mon Sep 17 00:00:00 2001 From: max-morrow Date: Thu, 19 Sep 2024 18:19:58 +0300 Subject: [PATCH 057/127] 1inch-U40: fixes for cross-chain lineage (#6733) * fixes * redesigned to submitted contracts - created escrow config factories macro - transferred lop_macro to submitted contracts - transferred escrow_dst_creations to submitted contracts - added necessary sources * Revert "redesigned to submitted contracts" This reverts commit 121a9ab2a05e0a85e8fb9cb09aaa50820a70a3bf. * revert easy dates & fix error with join using null hashlocks - revert easy dates - fix error with join using null hashlocks in call_transfers_macro * rm pre hook * easy date * Revert "easy date" This reverts commit 7f8f5cb6a799b6e42584b5438aeddb77dab5497a. * easy date * Revert "easy date" This reverts commit 87e49375ed49b8ead61412cca0b2fcd06659cac7. * migrate to decimals in swaps * Reapply "easy date" This reverts commit 9c718e2932a6128c4ef3d33755d0e31e51066d7b. * Revert "Reapply "easy date"" This reverts commit 2aa660386541521592c062ef4bcec3570959752e. --------- Co-authored-by: grkhr Co-authored-by: Eduard Gorkh <40689054+grkhr@users.noreply.github.com> --- .../oneinch/CC/oneinch_escrow_dst_creations_macro.sql | 2 +- .../_project/oneinch/oneinch_call_transfers_macro.sql | 5 ++--- .../arbitrum/oneinch_arbitrum_call_transfers.sql | 1 - .../avalanche_c/oneinch_avalanche_c_call_transfers.sql | 1 - .../oneinch/base/oneinch_base_call_transfers.sql | 1 - .../oneinch/bnb/oneinch_bnb_call_transfers.sql | 1 - .../ethereum/oneinch_ethereum_call_transfers.sql | 1 - .../oneinch/fantom/oneinch_fantom_call_transfers.sql | 1 - .../oneinch/gnosis/oneinch_gnosis_call_transfers.sql | 1 - .../dex/models/_projects/oneinch/oneinch_swaps.sql | 10 +++++++++- .../optimism/oneinch_optimism_call_transfers.sql | 1 - .../oneinch/polygon/oneinch_polygon_call_transfers.sql | 1 - .../oneinch/zksync/oneinch_zksync_call_transfers.sql | 1 - 13 files changed, 12 insertions(+), 15 deletions(-) diff --git a/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_dst_creations_macro.sql b/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_dst_creations_macro.sql index 33776bffcf8..bc7fa58b1f3 100644 --- a/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_dst_creations_macro.sql +++ b/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_dst_creations_macro.sql @@ -48,7 +48,7 @@ factories as ( , substr(input, 4 + 32*4 + 12 + 1, 20) as token , bytearray_to_uint256(substr(input, 4 + 32*5 + 1, 32)) as amount , bytearray_to_uint256(substr(input, 4 + 32*6 + 1, 32)) as safety_deposit - , substr(input, 4 + 32*7 + 12 + 1, 32) as timelocks + , substr(input, 4 + 32*7 + 1, 32) as timelocks , success as call_success from {{ source(blockchain, 'traces') }} where diff --git a/dbt_subprojects/dex/macros/models/_project/oneinch/oneinch_call_transfers_macro.sql b/dbt_subprojects/dex/macros/models/_project/oneinch/oneinch_call_transfers_macro.sql index 0a48c20411c..79e849b720f 100644 --- a/dbt_subprojects/dex/macros/models/_project/oneinch/oneinch_call_transfers_macro.sql +++ b/dbt_subprojects/dex/macros/models/_project/oneinch/oneinch_call_transfers_macro.sql @@ -13,6 +13,7 @@ 'tx_hash', 'call_trace_address', 'dst_blockchain', + 'hashlock', ] %} @@ -52,7 +53,6 @@ meta as ( , block_time as result_block_time , tx_hash as result_tx_hash , call_trace_address as result_trace_address - , cast(null as varbinary) as hashlock , cast(null as varbinary) as result_escrow , null as result_method , null as result_amount @@ -71,11 +71,10 @@ meta as ( , result_block_time , result_tx_hash , result_trace_address - , hashlock , result_escrow , result_method , result_amount - from ({{ oneinch_calls_macro(blockchain) }}) + from (select * from ({{ oneinch_calls_macro(blockchain) }}) where hashlock is not null) join results using(hashlock) -- escrow results only where tx_success diff --git a/dbt_subprojects/dex/models/_projects/oneinch/arbitrum/oneinch_arbitrum_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/arbitrum/oneinch_arbitrum_call_transfers.sql index 3e2fac78cd0..aaabac176fe 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/arbitrum/oneinch_arbitrum_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/arbitrum/oneinch_arbitrum_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/avalanche_c/oneinch_avalanche_c_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/avalanche_c/oneinch_avalanche_c_call_transfers.sql index 4ba9b0e133e..db3d3fad805 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/avalanche_c/oneinch_avalanche_c_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/avalanche_c/oneinch_avalanche_c_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/base/oneinch_base_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/base/oneinch_base_call_transfers.sql index 7e6a6b2dc89..62bb59ea6ee 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/base/oneinch_base_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/base/oneinch_base_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/bnb/oneinch_bnb_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/bnb/oneinch_bnb_call_transfers.sql index 70be1e5821f..b65cbd24b45 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/bnb/oneinch_bnb_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/bnb/oneinch_bnb_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/ethereum/oneinch_ethereum_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/ethereum/oneinch_ethereum_call_transfers.sql index 253054e2d6c..508bd7ebbd8 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/ethereum/oneinch_ethereum_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/ethereum/oneinch_ethereum_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/fantom/oneinch_fantom_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/fantom/oneinch_fantom_call_transfers.sql index edcf2b8c183..37780198277 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/fantom/oneinch_fantom_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/fantom/oneinch_fantom_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/gnosis/oneinch_gnosis_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/gnosis/oneinch_gnosis_call_transfers.sql index a901aa578a1..af1ecae3dc6 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/gnosis/oneinch_gnosis_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/gnosis/oneinch_gnosis_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql b/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql index 85144000ed4..8fc1e2cad53 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql @@ -77,7 +77,6 @@ tokens as ( , contract_address , minute , price - , decimals , symbol from {{ source('prices', 'usd') }} {% if is_incremental() %} @@ -85,6 +84,14 @@ tokens as ( {% endif %} ) +, decimals_cte as ( + select + blockchain as transfer_blockchain + , contract_address + , decimals + from {{ source('tokens', 'erc20') }} +) + , calls as ( select * @@ -206,6 +213,7 @@ tokens as ( {% endif %} ) using(blockchain, block_number, tx_hash, call_trace_address) -- block_number is needed for performance left join prices using(transfer_blockchain, contract_address, minute) + left join decimals_cte using(transfer_blockchain, contract_address) left join tokens using(transfer_blockchain, contract_address) group by 1, 2, 3, 4, 5 ) diff --git a/dbt_subprojects/dex/models/_projects/oneinch/optimism/oneinch_optimism_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/optimism/oneinch_optimism_call_transfers.sql index 70ab9ca2e6d..125c2c6f913 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/optimism/oneinch_optimism_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/optimism/oneinch_optimism_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/polygon/oneinch_polygon_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/polygon/oneinch_polygon_call_transfers.sql index 3c90f675d95..27d0cb33909 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/polygon/oneinch_polygon_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/polygon/oneinch_polygon_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/zksync/oneinch_zksync_call_transfers.sql b/dbt_subprojects/dex/models/_projects/oneinch/zksync/oneinch_zksync_call_transfers.sql index fbeda2ecc9f..086a38fc459 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/zksync/oneinch_zksync_call_transfers.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/zksync/oneinch_zksync_call_transfers.sql @@ -12,7 +12,6 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'], - pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' ) }} From 7e482d392124f04b62fb0086020571279f1981c7 Mon Sep 17 00:00:00 2001 From: DecentralizedProtocol <105208848+DecentralizedProtocol@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:27:12 +0700 Subject: [PATCH 058/127] Update prices_ethereum_tokens.sql (#6760) * Update prices_ethereum_tokens.sql Add EURI token price * Fix * Update prices_bnb_tokens.sql Add EURI token price --------- Co-authored-by: Huang Geyang --- dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql | 3 ++- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql index ad1a2b53fab..223f66d6709 100644 --- a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql @@ -277,7 +277,8 @@ FROM ('lovely-lovely-inu-finance', 'bnb', 'LOVELY', 0x9e24415d1e549ebc626a13a482bb117a2b43e9cf, 8), --('pvc-pvc-meta','bnb','PVC',0x75ca521892de7f2ecfb070cab545c250d0ceb7e3, 9), --token_id not found ('bvsd-bvsd','bnb','BVSD',0x7f9ad7a5854658d984924e868187b2135514fb88, 18), - ('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18) + ('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18), + ('euri-eurite', 'bnb', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( 0x2ab0e9e4ee70fff1fb9d67031e44f6410170d00e -- bXEN has bad price feed. diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index b3e19dbe1f6..89d4cb5a5cd 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1837,7 +1837,8 @@ FROM ('synt-synternet','ethereum','SYNT',0xda987c655ebc38c801db64a8608bc1aa56cd9a31, 18), ('babydoge-baby-doge-coin', 'ethereum', 'BABYDOGE', 0xac57de9c1a09fec648e93eb98875b212db0d460b, 9), ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18), - ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8) + ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8), + ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( -- bad price feeds From 40bc5dae940e0ad84097748adfcaa8492313f2b1 Mon Sep 17 00:00:00 2001 From: cindieKim99 <130626254+cindieKim99@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:30:26 +0700 Subject: [PATCH 059/127] Update prices.usd for ZKSync (#6763) --- .../tokens/models/prices/zksync/prices_zksync_tokens.sql | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql b/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql index d8b270cf6f0..119c07a66dd 100644 --- a/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql @@ -57,6 +57,7 @@ FROM ('kat-karat', 'zksync', 'KAT', 0xCDb7D260c107499C80B4b748e8331c64595972a1, 18), ('zkid-zksync-id', 'zksync', 'ZKID', 0x2141d7fe06A1d69c016fC638bA75b6Ef92Fa1435, 18), ('zk-zksync', 'zksync', 'ZK', 0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E, 18), - ('weeth-wrapped-eeth', 'zksync', 'weETH', 0xc1fa6e2e8667d9be0ca938a54c7e0285e9df924a, 18) - + ('weeth-wrapped-eeth', 'zksync', 'weETH', 0xc1fa6e2e8667d9be0ca938a54c7e0285e9df924a, 18), + ('mvx-metavault-trade', 'zksync', 'MVX', 0xc8ac6191cdc9c7bf846ad6b52aaaa7a0757ee305, 18), + ('zf-zkswap-finance', 'zksync', 'ZF', 0x31c2c031fdc9d33e974f327ab0d9883eae06ca4a, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From f07027462a6f7c135039a0238296e7314313f95e Mon Sep 17 00:00:00 2001 From: bertastr <146262345+bertastr@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:30:35 +0700 Subject: [PATCH 060/127] Add ZETA to prices.usd (#6762) * Add ZETA to prices.usd * update * fix --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql | 1 + .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql index 223f66d6709..95a08b04129 100644 --- a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql @@ -278,6 +278,7 @@ FROM --('pvc-pvc-meta','bnb','PVC',0x75ca521892de7f2ecfb070cab545c250d0ceb7e3, 9), --token_id not found ('bvsd-bvsd','bnb','BVSD',0x7f9ad7a5854658d984924e868187b2135514fb88, 18), ('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18), + ('zeta-zetachain', 'bnb', 'ZETA', 0x0000028a2eb8346cd5c0267856ab7594b7a55308, 18), ('euri-eurite', 'bnb', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 89d4cb5a5cd..654f2f49384 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1838,6 +1838,7 @@ FROM ('babydoge-baby-doge-coin', 'ethereum', 'BABYDOGE', 0xac57de9c1a09fec648e93eb98875b212db0d460b, 9), ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18), ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8), + ('zeta-zetachain', 'ethereum', 'ZETA', 0xf091867ec603a6628ed83d274e835539d82e9cc8, 18), ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( From 47a169ac0f84043e562e72b1325f5d8b97adb314 Mon Sep 17 00:00:00 2001 From: 0xyadday <112420584+mhmdriyadi@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:32:30 +0700 Subject: [PATCH 061/127] Update prices_solana_tokens.sql (#6765) Add SCAT token prices --- .../tokens/models/prices/solana/prices_solana_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql b/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql index 23a59fd675b..8cbecdcc8d0 100644 --- a/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/solana/prices_solana_tokens.sql @@ -700,5 +700,6 @@ FROM ('mumu1-mumu-the-bull', 'solana', 'MUMU', '5LafQUrVco6o7KMz42eqVEJ9LW31StPyGjeeu5sKoMtA', 6), ('nub-nubcat','solana', 'NUB', 'GtDZKAqvMZMnti46ZewMiXCa4oXF4bZxwQPoKzXPFxZn', 9), ('bunk-bunkee', 'solana', 'BUNK', '2nhjjqSkA8FYCUdJvQhYjbtZdPjZbNo8VtNKTkJ3hncb', 6), - ('maneki-maneki', 'solana', 'MANEKI', '25hAyBQfoDhfWx9ay6rarbgvWGwDdNqcHsXS3jQ3mTDJ', 5) + ('maneki-maneki', 'solana', 'MANEKI', '25hAyBQfoDhfWx9ay6rarbgvWGwDdNqcHsXS3jQ3mTDJ', 5), + ('scat-simon39s-baby-cat', 'solana', 'SCAT', '2NNkCSrbQtrc9tgEJHt4MQUH3ySaxTRAAXt9cUgCkycB', 9) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 96fe659c0fa39f18eb2f313e1bf7205644135a37 Mon Sep 17 00:00:00 2001 From: Rudi Afandi <53332703+rudiafandi16@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:34:12 +0700 Subject: [PATCH 062/127] Update prices_base_tokens.sql (#6767) add MOXIE token price --- .../tokens/models/prices/base/prices_base_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql index b41a16f864f..39240512a7c 100644 --- a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql @@ -167,5 +167,6 @@ FROM ('albert-albert-the-alien','base','ALBERT',0x0c067fc190cde145b0c537765a78d4e19873a5cc, 18), ('tn100x-tn100x','base','TN100X',0x5b5dee44552546ecea05edea01dcd7be7aa6144a, 18), ('rdat-rdatadao','base','RDAT',0x4498cd8ba045e00673402353f5a4347562707e7d, 18), - ('usdz-anzen-usdz', 'base', 'USDZ',0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 18) + ('usdz-anzen-usdz', 'base', 'USDZ',0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 18), + ('moxie-moxie', 'base', 'MOXIE',0x8C9037D1Ef5c6D1f6816278C7AAF5491d24CD527, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From b55970209a67776621a67b80f5c98cff9b1b51aa Mon Sep 17 00:00:00 2001 From: Demcruise <115721890+Demcruise@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:35:15 +0700 Subject: [PATCH 063/127] Update prices_ethereum_tokens.sql (#6764) * Update prices_ethereum_tokens.sql add BUBBLE token price * Update prices_ethereum_tokens.sql --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 654f2f49384..239dceb9139 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1838,6 +1838,7 @@ FROM ('babydoge-baby-doge-coin', 'ethereum', 'BABYDOGE', 0xac57de9c1a09fec648e93eb98875b212db0d460b, 9), ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18), ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8), + ('bubble-imaginary-ones', 'ethereum', 'BUBBLE', 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 18), ('zeta-zetachain', 'ethereum', 'ZETA', 0xf091867ec603a6628ed83d274e835539d82e9cc8, 18), ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 77fe8bfed21f07fc4018b7e85f230ebc2793a9e3 Mon Sep 17 00:00:00 2001 From: Demcruise <115721890+Demcruise@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:36:40 +0700 Subject: [PATCH 064/127] Update prices_ethereum_tokens.sql (#6766) add MSN token price Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 239dceb9139..841939dc332 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1838,6 +1838,7 @@ FROM ('babydoge-baby-doge-coin', 'ethereum', 'BABYDOGE', 0xac57de9c1a09fec648e93eb98875b212db0d460b, 9), ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18), ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8), + ('msn-mesonnetwork', 'ethereum', 'MSN', 0xaa247c0d81b83812e1abf8bab078e4540d87e3fb, 18), ('bubble-imaginary-ones', 'ethereum', 'BUBBLE', 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 18), ('zeta-zetachain', 'ethereum', 'ZETA', 0xf091867ec603a6628ed83d274e835539d82e9cc8, 18), ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) From bbc0ec238b7b5bc1461382111adbd972d77cd68d Mon Sep 17 00:00:00 2001 From: evetliu <143650479+evetliu@users.noreply.github.com> Date: Fri, 20 Sep 2024 02:37:35 +0700 Subject: [PATCH 065/127] Add TRB to prices.usd of ARB, OP and Polygon (#6769) * add TRB to prices.usd on Arbitrum * Add TRB to prices.usd on Optimism * Add TRB to prices.usd on Polygon * update --- .../tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql | 3 ++- .../models/prices/optimism/prices_optimism_tokens_curated.sql | 3 ++- .../tokens/models/prices/polygon/prices_polygon_tokens.sql | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql b/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql index b5715edd066..910cffa60b8 100644 --- a/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/arbitrum/prices_arbitrum_tokens.sql @@ -227,5 +227,6 @@ FROM ('tap-taptoken', 'arbitrum', 'TAP', 0x2c650dab03a59332e2e0c0c4a7f726913e5028c1, 18), ('shibai-aishiba', 'arbitrum', 'SHIBAI', 0xfa296fca3c7dba4a92a42ec0b5e2138da3b29050, 6), ('usdm-mountain-protocol-usd', 'arbitrum', 'USDM', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 18), - ('usdz-anzen-usdz', 'arbitrum', 'USDZ', 0x5018609ab477cc502e170a5accf5312b86a4b94f, 18) + ('usdz-anzen-usdz', 'arbitrum', 'USDZ', 0x5018609ab477cc502e170a5accf5312b86a4b94f, 18), + ('trb-tellor', 'arbitrum', 'TRB', 0xd58d345fd9c82262e087d2d0607624b410d88242, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql b/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql index 6187769ada5..fb2f1cc0a5d 100644 --- a/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql +++ b/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql @@ -133,5 +133,6 @@ FROM ('rseth-rseth', 'rsETH', 0x4186bfc76e2e237523cbc30fd220fe055156b41f, 18), ('dola-dola', 'DOLA',0x8ae125e8653821e851f12a49f7765db9a9ce7384, 18), ('wld-worldcoin', 'WLD',0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1, 18), - ('pendle-pendle', 'PENDLE',0xbc7b1ff1c6989f006a1185318ed4e7b5796e66e1, 18) + ('pendle-pendle', 'PENDLE',0xbc7b1ff1c6989f006a1185318ed4e7b5796e66e1, 18), + ('trb-tellor', 'TRB', 0xaf8ca653fa2772d58f4368b0a71980e9e3ceb888, 18) ) as temp (token_id, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/polygon/prices_polygon_tokens.sql b/dbt_subprojects/tokens/models/prices/polygon/prices_polygon_tokens.sql index bfe2f7ef28b..313d323bf7c 100644 --- a/dbt_subprojects/tokens/models/prices/polygon/prices_polygon_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/polygon/prices_polygon_tokens.sql @@ -137,7 +137,8 @@ FROM ('zro-layerzero', 'polygon', 'ZRO', 0x6985884c4392d348587b19cb9eaaf157f13271cd, 18), ('next-connext-eth', 'polygon', 'NEXT', 0x58b9cb810a68a7f3e1e4f8cb45d1b9b3c79705e8, 18), ('usdm-mountain-protocol-usd', 'polygon', 'USDM', 0x57f5e098cad7a3d1eed53991d4d66c45c9af7812, 18), - ('crowd-crowdswap', 'polygon', 'CROWD', 0x483dd3425278c1f79f377f1034d9d2cae55648b6, 18) + ('crowd-crowdswap', 'polygon', 'CROWD', 0x483dd3425278c1f79f377f1034d9d2cae55648b6, 18), + ('trb-tellor', 'polygon', 'TRB', 0xe3322702bedaaed36cddab233360b939775ae5f1, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( 0xef938b6da8576a896f6e0321ef80996f4890f9c4 -- DG, bad price feed From 51a6d90e66fa2e6e2a549d33460706a009c77ad9 Mon Sep 17 00:00:00 2001 From: zionhaley Date: Fri, 20 Sep 2024 02:39:28 +0700 Subject: [PATCH 066/127] Update prices.usd to include KOI4 on ZKSync (#6770) * Update prices.usd to include KOI4 on ZKSync * update --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../tokens/models/prices/zksync/prices_zksync_tokens.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql b/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql index 119c07a66dd..734c23a9279 100644 --- a/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/zksync/prices_zksync_tokens.sql @@ -58,6 +58,7 @@ FROM ('zkid-zksync-id', 'zksync', 'ZKID', 0x2141d7fe06A1d69c016fC638bA75b6Ef92Fa1435, 18), ('zk-zksync', 'zksync', 'ZK', 0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E, 18), ('weeth-wrapped-eeth', 'zksync', 'weETH', 0xc1fa6e2e8667d9be0ca938a54c7e0285e9df924a, 18), + ('koi4-koi', 'zksync', 'KOI4', 0xa995ad25ce5eb76972ab356168f5e1d9257e4d05, 18), ('mvx-metavault-trade', 'zksync', 'MVX', 0xc8ac6191cdc9c7bf846ad6b52aaaa7a0757ee305, 18), ('zf-zkswap-finance', 'zksync', 'ZF', 0x31c2c031fdc9d33e974f327ab0d9883eae06ca4a, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 7b265bdf0244b02c93e6482bf5bb34dca57ca5b6 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Thu, 19 Sep 2024 16:10:08 -0400 Subject: [PATCH 067/127] DUX-665 trusted tokens: add native (#6774) * add native * remove test, as we already test upstream models --- .../tokens/models/prices/_schema.yml | 5 --- .../models/prices/prices_trusted_tokens.sql | 39 ++++++++++++++----- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/_schema.yml b/dbt_subprojects/tokens/models/prices/_schema.yml index 4b2c89003aa..add46d281a4 100644 --- a/dbt_subprojects/tokens/models/prices/_schema.yml +++ b/dbt_subprojects/tokens/models/prices/_schema.yml @@ -56,11 +56,6 @@ models: config: tags: [ 'prices', 'stability' ] description: "List of trusted tokens across blockchains" - tests: - - dbt_utils.unique_combination_of_columns: - combination_of_columns: - - blockchain - - contract_address columns: - *blockchain - *contract_address diff --git a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql index bbca149afe6..2a079c59cf2 100644 --- a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql @@ -137,16 +137,35 @@ WITH trusted_tokens AS ( , ('zksync', 0xbbeb516fb02a01611cbbe0453fe3c580d7281011) , ('zora', 0x4200000000000000000000000000000000000006) ) AS t (blockchain, contract_address) +), erc20 as ( + SELECT + p.token_id + , p.blockchain + , p.contract_address + , p.symbol + , p.decimals + FROM + {{ ref('prices_tokens') }} AS p + INNER JOIN + trusted_tokens AS tt + ON p.blockchain = tt.blockchain + AND p.contract_address = tt.contract_address +), native_tokens AS ( + SELECT + token_id + , blockchain + , contract_address + , symbol + , decimals + FROM + {{ ref('prices_native_tokens') }} ) SELECT - p.token_id - , p.blockchain - , p.contract_address - , p.symbol - , p.decimals + * +FROM + erc20 +UNION ALL +SELECT + * FROM - {{ ref('prices_tokens') }} AS p -INNER JOIN - trusted_tokens AS tt - ON p.blockchain = tt.blockchain - AND p.contract_address = tt.contract_address + native_tokens \ No newline at end of file From 14d8eef0d882851507cf3f4e6fd13d3b4d6c5f96 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:09:38 -0400 Subject: [PATCH 068/127] trusted tokens: use temp prices_usd_native design (#6775) * use temp prices_usd_native design * remove reused columns, as tests are not needed --- dbt_subprojects/tokens/models/prices/_schema.yml | 7 +------ .../models/prices/prices_trusted_tokens.sql | 15 +++++++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/_schema.yml b/dbt_subprojects/tokens/models/prices/_schema.yml index add46d281a4..eaae709d33a 100644 --- a/dbt_subprojects/tokens/models/prices/_schema.yml +++ b/dbt_subprojects/tokens/models/prices/_schema.yml @@ -55,9 +55,4 @@ models: contributors: hosuke, jeff-dude config: tags: [ 'prices', 'stability' ] - description: "List of trusted tokens across blockchains" - columns: - - *blockchain - - *contract_address - - *symbol - - *decimals \ No newline at end of file + description: "List of trusted tokens across blockchains" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql index 2a079c59cf2..9cae35bf6db 100644 --- a/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql @@ -152,13 +152,16 @@ WITH trusted_tokens AS ( AND p.contract_address = tt.contract_address ), native_tokens AS ( SELECT - token_id - , blockchain - , contract_address - , symbol - , decimals + p.token_id + , evm.blockchain + , {{ var('ETH_ERC20_ADDRESS') }} as contract_address -- 0x00..00 + , p.symbol + , 18 as decimals FROM - {{ ref('prices_native_tokens') }} + {{ source('evms','info') }} evm + INNER JOIN + {{ ref('prices_native_tokens') }} p + on evm.native_token_symbol = p.symbol ) SELECT * From 30c9421c9bbd83f7ed83e0642ede5d59ea86c77e Mon Sep 17 00:00:00 2001 From: Demcruise <115721890+Demcruise@users.noreply.github.com> Date: Fri, 20 Sep 2024 21:44:04 +0700 Subject: [PATCH 069/127] Update prices_bnb_tokens.sql (#6780) add COOKIE price token --- dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql index 95a08b04129..414741581d4 100644 --- a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql @@ -279,7 +279,8 @@ FROM ('bvsd-bvsd','bnb','BVSD',0x7f9ad7a5854658d984924e868187b2135514fb88, 18), ('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18), ('zeta-zetachain', 'bnb', 'ZETA', 0x0000028a2eb8346cd5c0267856ab7594b7a55308, 18), - ('euri-eurite', 'bnb', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) + ('euri-eurite', 'bnb', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18), + ('cookie-cookie', 'bnb', 'COOKIE', 0xc0041ef357b183448b235a8ea73ce4e4ec8c265f, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( 0x2ab0e9e4ee70fff1fb9d67031e44f6410170d00e -- bXEN has bad price feed. From 23a7cbd5f797e355b76e44c0419ef0aae3437e19 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Fri, 20 Sep 2024 10:44:15 -0400 Subject: [PATCH 070/127] add new sky governance token (#6781) --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 841939dc332..b5fef3747e1 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1841,7 +1841,8 @@ FROM ('msn-mesonnetwork', 'ethereum', 'MSN', 0xaa247c0d81b83812e1abf8bab078e4540d87e3fb, 18), ('bubble-imaginary-ones', 'ethereum', 'BUBBLE', 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 18), ('zeta-zetachain', 'ethereum', 'ZETA', 0xf091867ec603a6628ed83d274e835539d82e9cc8, 18), - ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) + ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18), + ('sky-sky', 'ethereum', 'SKY', 0x56072C95FAA701256059aa122697B133aDEd9279, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( -- bad price feeds From 90ebc444cbf1bffe23f0ce9c50873873ee720c42 Mon Sep 17 00:00:00 2001 From: Kofi Date: Fri, 20 Sep 2024 16:28:53 +0100 Subject: [PATCH 071/127] Add cbbtc price info (#6783) --- .../tokens/models/prices/base/prices_base_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql index 39240512a7c..599e5b9343e 100644 --- a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql @@ -168,5 +168,6 @@ FROM ('tn100x-tn100x','base','TN100X',0x5b5dee44552546ecea05edea01dcd7be7aa6144a, 18), ('rdat-rdatadao','base','RDAT',0x4498cd8ba045e00673402353f5a4347562707e7d, 18), ('usdz-anzen-usdz', 'base', 'USDZ',0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 18), - ('moxie-moxie', 'base', 'MOXIE',0x8C9037D1Ef5c6D1f6816278C7AAF5491d24CD527, 18) + ('moxie-moxie', 'base', 'MOXIE',0x8C9037D1Ef5c6D1f6816278C7AAF5491d24CD527, 18), + ('cbbtc-coinbase-wrapped-btc', 'base', 'cbBTC',0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf, 8) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 68e43bac4dab737a4bda9f5b696c2b742c5beaaa Mon Sep 17 00:00:00 2001 From: Rantum Date: Fri, 20 Sep 2024 09:01:08 -0700 Subject: [PATCH 072/127] add blast & mantle nft transfers (#6772) * add blast nft transfers * add blast transfers file * base_txns - not blast_txns * remove correction to linea_Transfers in schema for runtime improvmeents * remove nft_transfers changes * add mantle nft, fix blockchain value in linea schema --- .../nft/models/_sector/transfers/_schema.yml | 46 ++++++++++++++++++- .../transfers/chains/nft_blast_transfers.sql | 20 ++++++++ .../transfers/chains/nft_mantle_transfers.sql | 24 ++++++++++ 3 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 dbt_subprojects/nft/models/_sector/transfers/chains/nft_blast_transfers.sql create mode 100644 dbt_subprojects/nft/models/_sector/transfers/chains/nft_mantle_transfers.sql diff --git a/dbt_subprojects/nft/models/_sector/transfers/_schema.yml b/dbt_subprojects/nft/models/_sector/transfers/_schema.yml index 7000d0828b7..4b2fb972b35 100644 --- a/dbt_subprojects/nft/models/_sector/transfers/_schema.yml +++ b/dbt_subprojects/nft/models/_sector/transfers/_schema.yml @@ -378,7 +378,7 @@ models: - name: nft_linea_transfers meta: - blockchain: scroll + blockchain: linea sector: nft contributors: couralex config: @@ -397,3 +397,47 @@ models: - *token_standard - *transfer_type - *unique_transfer_id + + - name: nft_blast_transfers + meta: + blockchain: blast + sector: nft + contributors: rantum + config: + tags: [ 'nft', 'transfers' ] + description: > + NFT transfers + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - token_id + - amount + columns: + # only listing columns that have tests here for simplicity + - *token_standard + - *transfer_type + - *unique_transfer_id + + - name: nft_mantle_transfers + meta: + blockchain: mantle + sector: nft + contributors: rantum + config: + tags: [ 'nft', 'transfers' ] + description: > + NFT transfers + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - token_id + - amount + columns: + # only listing columns that have tests here for simplicity + - *token_standard + - *transfer_type + - *unique_transfer_id diff --git a/dbt_subprojects/nft/models/_sector/transfers/chains/nft_blast_transfers.sql b/dbt_subprojects/nft/models/_sector/transfers/chains/nft_blast_transfers.sql new file mode 100644 index 00000000000..4ba636a85ff --- /dev/null +++ b/dbt_subprojects/nft/models/_sector/transfers/chains/nft_blast_transfers.sql @@ -0,0 +1,20 @@ +{{ config( + + schema = 'nft_blast', + alias = 'transfers', + partition_by=['block_month'], + materialized='incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['tx_hash', 'evt_index', 'token_id', 'amount'] +) +}} + +{{nft_transfers( + blockchain='blast' + , base_transactions = source('blast','transactions') + , erc721_transfers = source('erc721_blast','evt_transfer') + , erc1155_single = source('erc1155_blast','evt_transfersingle') + , erc1155_batch = source('erc1155_blast', 'evt_transferbatch') +)}} diff --git a/dbt_subprojects/nft/models/_sector/transfers/chains/nft_mantle_transfers.sql b/dbt_subprojects/nft/models/_sector/transfers/chains/nft_mantle_transfers.sql new file mode 100644 index 00000000000..2e8a287941c --- /dev/null +++ b/dbt_subprojects/nft/models/_sector/transfers/chains/nft_mantle_transfers.sql @@ -0,0 +1,24 @@ +{{ + config( + schema="nft_mantle", + alias="transfers", + partition_by=["block_month"], + materialized="incremental", + file_format="delta", + incremental_strategy="merge", + incremental_predicates=[ + incremental_predicate("DBT_INTERNAL_DEST.block_time") + ], + unique_key=["tx_hash", "evt_index", "token_id", "amount"], + ) +}} + +{{ + nft_transfers( + blockchain="mantle", + base_transactions=source("mantle", "transactions"), + erc721_transfers=source("erc721_mantle", "evt_transfer"), + erc1155_single=source("erc1155_mantle", "evt_transfersingle"), + erc1155_batch=source("erc1155_mantle", "evt_transferbatch"), + ) +}} From a869418f2dd614b1dc7e869082654526aeb99bb6 Mon Sep 17 00:00:00 2001 From: max-morrow Date: Fri, 20 Sep 2024 19:01:28 +0300 Subject: [PATCH 073/127] 1inch-U41: fixes & redesign (#6771) * fixed & optimised decimals logic * redesigned to submitted contracts - created escrow config factories macro - transferred lop_macro to submitted contracts - transferred escrow_dst_creations to submitted contracts - added necessary sources * added addition columns to the src <> dst join --- .../CC/oneinch_escrow_cfg_factories_macro.sql | 39 ++++++++ .../CC/oneinch_escrow_dst_creations_macro.sql | 87 ------------------ .../oneinch/LOP/oneinch_lop_macro.sql | 91 ++++++++++++------- .../oneinch/oneinch_escrow_dst_creations.sql | 82 ++++++++++++++++- .../_projects/oneinch/oneinch_swaps.sql | 34 +++---- .../arbitrum/oneinch_arbitrum_sources.yml | 2 + .../oneinch_avalanche_c_sources.yml | 2 + sources/oneinch/base/oneinch_base_sources.yml | 2 + sources/oneinch/bnb/oneinch_bnb_sources.yml | 2 + .../ethereum/oneinch_ethereum_sources.yml | 2 + .../oneinch/gnosis/oneinch_gnosis_sources.yml | 2 + .../optimism/oneinch_optimism_sources.yml | 2 + .../polygon/oneinch_polygon_sources.yml | 2 + 13 files changed, 206 insertions(+), 143 deletions(-) create mode 100644 dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_cfg_factories_macro.sql delete mode 100644 dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_dst_creations_macro.sql diff --git a/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_cfg_factories_macro.sql b/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_cfg_factories_macro.sql new file mode 100644 index 00000000000..c89daee18ed --- /dev/null +++ b/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_cfg_factories_macro.sql @@ -0,0 +1,39 @@ +{% macro oneinch_escrow_cfg_factories_macro() %} + +-- CREATION IMMUTABLES SAMPLES +{% + set immutables = { + "v1": { + "order_hash": "from_hex(creation_map['orderHash'])", + "hashlock": "from_hex(creation_map['hashlock'])", + "maker": "substr(cast(cast(creation_map['maker'] as uint256) as varbinary), 13)", + "taker": "substr(cast(cast(creation_map['taker'] as uint256) as varbinary), 13)", + "token": "substr(cast(cast(creation_map['token'] as uint256) as varbinary), 13)", + "amount": "cast(creation_map['amount'] as uint256)", + "safety_deposit": "cast(creation_map['safetyDeposit'] as uint256)", + "timelocks": "cast(cast(creation_map['timelocks'] as uint256) as varbinary)", + }, + } +%} + +-- CONTRACTS CONFIG +{% + set contracts = { + "EscrowFactoryV1": { + "version": "1", + "blockchains": ["ethereum", "bnb", "polygon", "arbitrum", "avalanche_c", "gnosis", "optimism", "base"], + "start": "2024-08-20", + "dst_creation": dict(immutables["v1"], method="createDstEscrow"), + "src_created": dict(immutables["v1"], event="SrcEscrowCreated", + dst_maker="substr(cast(cast(complement_map['maker'] as uint256) as varbinary), 13)", + dst_token="substr(cast(cast(complement_map['token'] as uint256) as varbinary), 13)", + dst_amount="cast(complement_map['amount'] as uint256)", + dst_chain_id="cast(complement_map['chainId'] as uint256)", + ), + }, + } +%} + +{{ return(contracts) }} + +{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_dst_creations_macro.sql b/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_dst_creations_macro.sql deleted file mode 100644 index bc7fa58b1f3..00000000000 --- a/dbt_subprojects/dex/macros/models/_project/oneinch/CC/oneinch_escrow_dst_creations_macro.sql +++ /dev/null @@ -1,87 +0,0 @@ -{% macro oneinch_escrow_dst_creations_macro(blockchain) %} - -{% set date_from = '2024-08-20' %} - -with - -factories as ( - select factory - from ({{ oneinch_blockchain_macro(blockchain) }}), unnest(escrow_factory_addresses) as f(factory) -) - -, createDstEscrow as ( - select - * - , substr(keccak(concat( - 0xff - , factory - , keccak(concat( - order_hash - , hashlock - , lpad(maker, 32, 0x00) - , lpad(taker, 32, 0x00) - , lpad(token, 32, 0x00) - , cast(amount as varbinary) - , cast(safety_deposit as varbinary) - , to_big_endian_32(cast(to_unixtime(block_time) as int)) - , substr(timelocks, 5) -- replace the first 4 bytes with current block time - )) - , keccak(concat( - 0x3d602d80600a3d3981f3363d3d373d3d3d363d73 - , substr(keccak(concat(0xd6, 0x94, factory, 0x03)), 13) -- dst nonce = 3 - , 0x5af43d82803e903d91602b57fd5bf3) - ) - )), 13) as escrow - from ( - -- will be converted to submitted contracts - select - '{{ blockchain }}' as blockchain - , block_number - , block_time - , tx_hash - , trace_address - , "to" as factory - , substr(input, 4 + 32*0 + 1, 32) as order_hash - , substr(input, 4 + 32*1 + 1, 32) as hashlock - , substr(input, 4 + 32*2 + 12 + 1, 20) as maker - , substr(input, 4 + 32*3 + 12 + 1, 20) as taker - , substr(input, 4 + 32*4 + 12 + 1, 20) as token - , bytearray_to_uint256(substr(input, 4 + 32*5 + 1, 32)) as amount - , bytearray_to_uint256(substr(input, 4 + 32*6 + 1, 32)) as safety_deposit - , substr(input, 4 + 32*7 + 1, 32) as timelocks - , success as call_success - from {{ source(blockchain, 'traces') }} - where - starts_with(input, 0xdea024e4) -- createDstEscrow - and "to" in (select factory from factories) - {% if is_incremental() %} - and {{ incremental_predicate('block_time') }} - {% else %} - and block_time > greatest(timestamp '{{ date_from }}', timestamp {{ oneinch_easy_date() }}) - {% endif %} - ) -) - --- output -- - -select - blockchain - , block_number - , block_time - , tx_hash - , trace_address - , factory - , escrow - , order_hash - , hashlock - , maker - , taker - , token - , amount - , safety_deposit - , timelocks - , call_success - , date_trunc('month', block_time) as block_month -from createDstEscrow - -{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/macros/models/_project/oneinch/LOP/oneinch_lop_macro.sql b/dbt_subprojects/dex/macros/models/_project/oneinch/LOP/oneinch_lop_macro.sql index f4e13b880ed..535b0483490 100644 --- a/dbt_subprojects/dex/macros/models/_project/oneinch/LOP/oneinch_lop_macro.sql +++ b/dbt_subprojects/dex/macros/models/_project/oneinch/LOP/oneinch_lop_macro.sql @@ -74,36 +74,58 @@ orders as ( {% endfor %} ) --- will be converted to submitted contracts , SrcEscrowCreated as ( - with - - factories as ( - select factory - from ({{ oneinch_blockchain_macro(blockchain) }}), unnest(escrow_factory_addresses) as f(factory) - ) - - select - block_number - , tx_hash - , contract_address as factory - , substr(data, 32*0 + 1, 32) as order_hash - , substr(data, 32*1 + 1, 32) as hashlock - , substr(data, 32*2 + 12 + 1, 20) as maker - , substr(data, 32*3 + 12 + 1, 20) as taker - , substr(data, 32*4 + 12 + 1, 20) as token - , bytearray_to_uint256(substr(data, 32*5 + 1, 32)) as amount - , bytearray_to_uint256(substr(data, 32*6 + 1, 32)) as safety_deposit - , substr(data, 32*7 + 1, 32) as timelocks - from {{ source(blockchain, 'logs') }} - where - contract_address in (select factory from factories) - and topic0 = 0x0e534c62f0afd2fa0f0fa71198e8aa2d549f24daf2bb47de0d5486c7ce9288ca - {% if is_incremental() %} - and {{ incremental_predicate('block_time') }} - {% else %} - and block_time > timestamp '2024-08-20' - {% endif %} + {% for factory, factory_data in oneinch_escrow_cfg_factories_macro().items() %} + {% if blockchain in factory_data.blockchains %} + select + evt_block_number as block_number + , evt_tx_hash as tx_hash + , contract_address as factory + , {{ factory_data.src_created.get("order_hash", "null") }} as order_hash + , {{ factory_data.src_created.get("hashlock", "null") }} as hashlock + , {{ factory_data.src_created.get("maker", "null") }} as maker + , {{ factory_data.src_created.get("taker", "null") }} as taker + , {{ factory_data.src_created.get("token", "null") }} as token + , {{ factory_data.src_created.get("amount", "null") }} as amount + , {{ factory_data.src_created.get("safety_deposit", "null") }} as safety_deposit + , {{ factory_data.src_created.get("timelocks", "null") }} as timelocks + , {{ factory_data.src_created.get("dst_maker", "cast(null as varbinary)") }} as dst_maker + , {{ factory_data.src_created.get("dst_token", "cast(null as varbinary)") }} as dst_token + , {{ factory_data.src_created.get("dst_amount", "null") }} as dst_amount + , {{ factory_data.src_created.get("dst_chain_id", "null") }} as dst_chain_id + from ( + select + * + , cast(json_parse({{ factory_data.src_created.get("srcImmutables", '"srcImmutables"') }}) as map(varchar, varchar)) as creation_map + , cast(json_parse({{ factory_data.src_created.get("dstImmutablesComplement", '"dstImmutablesComplement"') }}) as map(varchar, varchar)) as complement_map + from {{ source('oneinch_' + blockchain, factory + '_evt_' + factory_data.src_created.event) }} + {% if is_incremental() %} + where {{ incremental_predicate('evt_block_time') }} + {% else %} + where evt_block_time >= greatest(timestamp '{{ factory_data['start'] }}', timestamp {{ oneinch_easy_date() }}) + {% endif %} + ) + {% else %} + select + null as block_number + , cast(null as varbinary) as tx_hash + , cast(null as varbinary) as factory + , cast(null as varbinary) as order_hash + , cast(null as varbinary) as hashlock + , cast(null as varbinary) as maker + , cast(null as varbinary) as taker + , cast(null as varbinary) as token + , null as amount + , null as safety_deposit + , cast(null as varbinary) as timelocks + , cast(null as varbinary) as dst_maker + , cast(null as varbinary) as dst_token + , null as dst_amount + , null as dst_chain_id + where false + {% endif %} + {% if not loop.last %} union all {% endif %} + {% endfor %} ) , calculations as ( @@ -148,7 +170,11 @@ orders as ( , 0x5af43d82803e903d91602b57fd5bf3) ) )), 13)) as src_escrow - , row_number() over(partition by hashlock order by orders.block_number, orders.tx_hash, call_trace_address) as hashlockNum + , dst_maker + , dst_token + , dst_amount + , dst_chain_id + , row_number() over(partition by hashlock, dst_maker, dst_token, dst_amount, dst_chain_id order by orders.block_number, orders.tx_hash, call_trace_address) as hashlockNum from orders join ({{ oneinch_blockchain_macro(blockchain) }}) on true left join SrcEscrowCreated on @@ -165,6 +191,7 @@ orders as ( , dst as ( select blockchain as dst_blockchain + , chain_id as dst_chain_id , block_number as dst_block_number , block_time as dst_block_time , tx_hash as dst_tx_hash @@ -180,7 +207,7 @@ orders as ( , timelocks , call_success as dst_creation_call_success , wrapped_native_token_address as dst_wrapper - , row_number() over(partition by hashlock order by block_number, tx_hash, trace_address) as hashlockNum + , row_number() over(partition by hashlock, maker, token, amount, chain_id order by block_number, tx_hash, trace_address) as hashlockNum from {{ ref('oneinch_escrow_dst_creations') }} join {{ ref('oneinch_blockchains') }} using(blockchain) {% if is_incremental() %} @@ -250,6 +277,6 @@ from ({{ , columns = ['from', 'to', 'success', 'nonce', 'gas_price', 'priority_fee_per_gas', 'gas_used', 'index'] ) }}) as orders -left join dst using(hashlock, hashlockNum) +left join dst using(hashlock, dst_maker, dst_token, dst_amount, dst_chain_id, hashlockNum) {% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/oneinch/oneinch_escrow_dst_creations.sql b/dbt_subprojects/dex/models/_projects/oneinch/oneinch_escrow_dst_creations.sql index fbb2f6a2efd..5293fd66259 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/oneinch_escrow_dst_creations.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/oneinch_escrow_dst_creations.sql @@ -11,9 +11,85 @@ ) }} +{% set date_from = '2024-08-20' %} +with -{% for blockchain in oneinch_exposed_blockchains_list() %} - select * from ({{ oneinch_escrow_dst_creations_macro(blockchain) }}) +createDstEscrow as ({% for factory, factory_data in oneinch_escrow_cfg_factories_macro().items() %} + select * from ({% for blockchain in factory_data.blockchains %} + select + '{{ blockchain }}' as blockchain + , call_block_number as block_number + , call_block_time as block_time + , call_tx_hash as tx_hash + , call_trace_address as trace_address + , contract_address as factory + , {{ factory_data.dst_creation.get("order_hash", "null") }} as order_hash + , {{ factory_data.dst_creation.get("hashlock", "null") }} as hashlock + , {{ factory_data.dst_creation.get("maker", "null") }} as maker + , {{ factory_data.dst_creation.get("taker", "null") }} as taker + , {{ factory_data.dst_creation.get("token", "null") }} as token + , {{ factory_data.dst_creation.get("amount", "null") }} as amount + , {{ factory_data.dst_creation.get("safety_deposit", "null") }} as safety_deposit + , {{ factory_data.dst_creation.get("timelocks", "null") }} as timelocks + , call_success + from ( + select *, cast(json_parse({{ factory_data.dst_creation.get("dstImmutables", '"dstImmutables"') }}) as map(varchar, varchar)) as creation_map + from {{ source('oneinch_' + blockchain, factory + '_call_' + factory_data.dst_creation.method) }} + {% if is_incremental() %} + where {{ incremental_predicate('call_block_time') }} + {% else %} + where call_block_time >= greatest(timestamp '{{ factory_data['start'] }}', timestamp {{ oneinch_easy_date() }}) + {% endif %} + ) + {% if not loop.last %} union all {% endif %} + {% endfor %}) {% if not loop.last %} union all {% endif %} -{% endfor %} \ No newline at end of file +{% endfor %}) + +, calculations as ( + select + * + , substr(keccak(concat( + 0xff + , factory + , keccak(concat( + order_hash + , hashlock + , lpad(maker, 32, 0x00) + , lpad(taker, 32, 0x00) + , lpad(token, 32, 0x00) + , cast(amount as varbinary) + , cast(safety_deposit as varbinary) + , to_big_endian_32(cast(to_unixtime(block_time) as int)) + , substr(timelocks, 5) -- replace the first 4 bytes with current block time + )) + , keccak(concat( + 0x3d602d80600a3d3981f3363d3d373d3d3d363d73 + , substr(keccak(concat(0xd6, 0x94, factory, 0x03)), 13) -- dst nonce = 3 + , 0x5af43d82803e903d91602b57fd5bf3) + ) + )), 13) as escrow + from createDstEscrow +) +-- output -- + +select + blockchain + , block_number + , block_time + , tx_hash + , trace_address + , factory + , escrow + , order_hash + , hashlock + , maker + , taker + , token + , amount + , safety_deposit + , timelocks + , call_success + , date_trunc('month', block_time) as block_month +from calculations \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql b/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql index 8fc1e2cad53..f47c3a226a5 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql @@ -77,6 +77,7 @@ tokens as ( , contract_address , minute , price + , decimals , symbol from {{ source('prices', 'usd') }} {% if is_incremental() %} @@ -84,14 +85,6 @@ tokens as ( {% endif %} ) -, decimals_cte as ( - select - blockchain as transfer_blockchain - , contract_address - , decimals - from {{ source('tokens', 'erc20') }} -) - , calls as ( select * @@ -153,7 +146,7 @@ tokens as ( {% set src_condition = 'contract_address = _src_token_address' %} {% set dst_condition = 'contract_address = _dst_token_address' %} {% set symbol = 'coalesce(symbol, token_symbol)' %} -{% set decimals = 'coalesce(decimals, token_decimals)' %} +{% set decimals = 'coalesce(token_decimals, decimals)' %} , amounts as ( select @@ -179,29 +172,29 @@ tokens as ( , max(amount) filter(where {{ src_condition }} and amount <= src_token_amount) as _src_token_amount_true -- take only src token amounts less than in the call , max(amount) filter(where {{ dst_condition }} and amount <= dst_token_amount) as _dst_token_amount_true -- take only dst token amounts less than in the call - , max(amount * price / pow(10, decimals)) filter(where {{ src_condition }} and amount <= src_token_amount or {{ dst_condition }} and amount <= dst_token_amount) as sources_amount_usd - , max(amount * price / pow(10, decimals)) as transfers_amount_usd + , max(amount * price / pow(10, {{ decimals }})) filter(where {{ src_condition }} and amount <= src_token_amount or {{ dst_condition }} and amount <= dst_token_amount) as sources_amount_usd + , max(amount * price / pow(10, {{ decimals }})) as transfers_amount_usd -- src $ amount from user - , sum(amount * if(user = transfer_from, price, -price) / pow(10, decimals)) filter(where {{ src_condition }} and user in (transfer_from, transfer_to)) as _amount_usd_from_user + , sum(amount * if(user = transfer_from, price, -price) / pow(10, {{ decimals }})) filter(where {{ src_condition }} and user in (transfer_from, transfer_to)) as _amount_usd_from_user -- dst $ amount to user - , sum(amount * if(user = transfer_to, price, -price) / pow(10, decimals)) filter(where {{ dst_condition }} and user in (transfer_from, transfer_to)) as _amount_usd_to_user + , sum(amount * if(user = transfer_to, price, -price) / pow(10, {{ decimals }})) filter(where {{ dst_condition }} and user in (transfer_from, transfer_to)) as _amount_usd_to_user -- dst $ amount to receiver - , sum(amount * if(receiver = transfer_to, price, -price) / pow(10, decimals)) filter(where {{ dst_condition }} and receiver in (transfer_from, transfer_to)) as _amount_usd_to_receiver + , sum(amount * if(receiver = transfer_to, price, -price) / pow(10, {{ decimals }})) filter(where {{ dst_condition }} and receiver in (transfer_from, transfer_to)) as _amount_usd_to_receiver -- escrow results , sum(amount) filter(where result_escrow = src_escrow and result_method = 'withdraw') as src_withdraw_amount , sum(amount) filter(where result_escrow = src_escrow and result_method = 'cancel') as src_cancel_amount , sum(amount) filter(where result_escrow = src_escrow and result_method = 'rescueFunds') as src_rescue_amount - , sum(amount * price / pow(10, decimals)) filter(where result_escrow = src_escrow and result_method = 'withdraw') as src_withdraw_amount_usd - , sum(amount * price / pow(10, decimals)) filter(where result_escrow = src_escrow and result_method = 'cancel') as src_cancel_amount_usd - , sum(amount * price / pow(10, decimals)) filter(where result_escrow = src_escrow and result_method = 'rescueFunds') as src_rescue_amount_usd + , sum(amount * price / pow(10, {{ decimals }})) filter(where result_escrow = src_escrow and result_method = 'withdraw') as src_withdraw_amount_usd + , sum(amount * price / pow(10, {{ decimals }})) filter(where result_escrow = src_escrow and result_method = 'cancel') as src_cancel_amount_usd + , sum(amount * price / pow(10, {{ decimals }})) filter(where result_escrow = src_escrow and result_method = 'rescueFunds') as src_rescue_amount_usd , sum(amount) filter(where result_escrow = dst_escrow and result_method = 'withdraw') as dst_withdraw_amount , sum(amount) filter(where result_escrow = dst_escrow and result_method = 'cancel') as dst_cancel_amount , sum(amount) filter(where result_escrow = dst_escrow and result_method = 'rescueFunds') as dst_rescue_amount - , sum(amount * price / pow(10, decimals)) filter(where result_escrow = dst_escrow and result_method = 'withdraw') as dst_withdraw_amount_usd - , sum(amount * price / pow(10, decimals)) filter(where result_escrow = dst_escrow and result_method = 'cancel') as dst_cancel_amount_usd - , sum(amount * price / pow(10, decimals)) filter(where result_escrow = dst_escrow and result_method = 'rescueFunds') as dst_rescue_amount_usd + , sum(amount * price / pow(10, {{ decimals }})) filter(where result_escrow = dst_escrow and result_method = 'withdraw') as dst_withdraw_amount_usd + , sum(amount * price / pow(10, {{ decimals }})) filter(where result_escrow = dst_escrow and result_method = 'cancel') as dst_cancel_amount_usd + , sum(amount * price / pow(10, {{ decimals }})) filter(where result_escrow = dst_escrow and result_method = 'rescueFunds') as dst_rescue_amount_usd , count(distinct (contract_address, transfer_native)) as tokens -- count distinct tokens in transfers , count(*) as transfers -- count transfers @@ -213,7 +206,6 @@ tokens as ( {% endif %} ) using(blockchain, block_number, tx_hash, call_trace_address) -- block_number is needed for performance left join prices using(transfer_blockchain, contract_address, minute) - left join decimals_cte using(transfer_blockchain, contract_address) left join tokens using(transfer_blockchain, contract_address) group by 1, 2, 3, 4, 5 ) diff --git a/sources/oneinch/arbitrum/oneinch_arbitrum_sources.yml b/sources/oneinch/arbitrum/oneinch_arbitrum_sources.yml index 6675acccf30..1873950a396 100644 --- a/sources/oneinch/arbitrum/oneinch_arbitrum_sources.yml +++ b/sources/oneinch/arbitrum/oneinch_arbitrum_sources.yml @@ -64,5 +64,7 @@ sources: - name: AggregationRouterV6_call_fillOrderArgs - name: AggregationRouterV6_call_fillContractOrder - name: AggregationRouterV6_call_fillContractOrderArgs + - name: EscrowFactoryV1_call_createDstEscrow + - name: EscrowFactoryV1_evt_SrcEscrowCreated - name: lop - name: ar \ No newline at end of file diff --git a/sources/oneinch/avalanche_c/oneinch_avalanche_c_sources.yml b/sources/oneinch/avalanche_c/oneinch_avalanche_c_sources.yml index f7c820a652b..38f278b0daa 100644 --- a/sources/oneinch/avalanche_c/oneinch_avalanche_c_sources.yml +++ b/sources/oneinch/avalanche_c/oneinch_avalanche_c_sources.yml @@ -57,5 +57,7 @@ sources: - name: AggregationRouterV6_call_fillOrderArgs - name: AggregationRouterV6_call_fillContractOrder - name: AggregationRouterV6_call_fillContractOrderArgs + - name: EscrowFactoryV1_call_createDstEscrow + - name: EscrowFactoryV1_evt_SrcEscrowCreated - name: lop - name: ar \ No newline at end of file diff --git a/sources/oneinch/base/oneinch_base_sources.yml b/sources/oneinch/base/oneinch_base_sources.yml index 22dd420bd43..6309e59ba21 100644 --- a/sources/oneinch/base/oneinch_base_sources.yml +++ b/sources/oneinch/base/oneinch_base_sources.yml @@ -39,5 +39,7 @@ sources: - name: AggregationRouterV6_call_fillOrderArgs - name: AggregationRouterV6_call_fillContractOrder - name: AggregationRouterV6_call_fillContractOrderArgs + - name: EscrowFactoryV1_call_createDstEscrow + - name: EscrowFactoryV1_evt_SrcEscrowCreated - name: lop - name: ar \ No newline at end of file diff --git a/sources/oneinch/bnb/oneinch_bnb_sources.yml b/sources/oneinch/bnb/oneinch_bnb_sources.yml index 1b91847d046..8f608659113 100644 --- a/sources/oneinch/bnb/oneinch_bnb_sources.yml +++ b/sources/oneinch/bnb/oneinch_bnb_sources.yml @@ -68,5 +68,7 @@ sources: - name: AggregationRouterV6_call_fillOrderArgs - name: AggregationRouterV6_call_fillContractOrder - name: AggregationRouterV6_call_fillContractOrderArgs + - name: EscrowFactoryV1_call_createDstEscrow + - name: EscrowFactoryV1_evt_SrcEscrowCreated - name: lop - name: ar \ No newline at end of file diff --git a/sources/oneinch/ethereum/oneinch_ethereum_sources.yml b/sources/oneinch/ethereum/oneinch_ethereum_sources.yml index 725749da6bc..f8581952947 100644 --- a/sources/oneinch/ethereum/oneinch_ethereum_sources.yml +++ b/sources/oneinch/ethereum/oneinch_ethereum_sources.yml @@ -83,6 +83,8 @@ sources: - name: AggregationRouterV6_call_fillOrderArgs - name: AggregationRouterV6_call_fillContractOrder - name: AggregationRouterV6_call_fillContractOrderArgs + - name: EscrowFactoryV1_call_createDstEscrow + - name: EscrowFactoryV1_evt_SrcEscrowCreated - name: lop - name: ar diff --git a/sources/oneinch/gnosis/oneinch_gnosis_sources.yml b/sources/oneinch/gnosis/oneinch_gnosis_sources.yml index e62d7fc4ea9..8b886fe3f49 100644 --- a/sources/oneinch/gnosis/oneinch_gnosis_sources.yml +++ b/sources/oneinch/gnosis/oneinch_gnosis_sources.yml @@ -57,5 +57,7 @@ sources: - name: AggregationRouterV6_call_fillOrderArgs - name: AggregationRouterV6_call_fillContractOrder - name: AggregationRouterV6_call_fillContractOrderArgs + - name: EscrowFactoryV1_call_createDstEscrow + - name: EscrowFactoryV1_evt_SrcEscrowCreated - name: lop - name: ar \ No newline at end of file diff --git a/sources/oneinch/optimism/oneinch_optimism_sources.yml b/sources/oneinch/optimism/oneinch_optimism_sources.yml index 9f9f554174c..170f343992b 100644 --- a/sources/oneinch/optimism/oneinch_optimism_sources.yml +++ b/sources/oneinch/optimism/oneinch_optimism_sources.yml @@ -64,5 +64,7 @@ sources: - name: AggregationRouterV6_call_fillOrderArgs - name: AggregationRouterV6_call_fillContractOrder - name: AggregationRouterV6_call_fillContractOrderArgs + - name: EscrowFactoryV1_call_createDstEscrow + - name: EscrowFactoryV1_evt_SrcEscrowCreated - name: lop - name: ar \ No newline at end of file diff --git a/sources/oneinch/polygon/oneinch_polygon_sources.yml b/sources/oneinch/polygon/oneinch_polygon_sources.yml index 525dee8d1d4..c8bb04b5284 100644 --- a/sources/oneinch/polygon/oneinch_polygon_sources.yml +++ b/sources/oneinch/polygon/oneinch_polygon_sources.yml @@ -65,5 +65,7 @@ sources: - name: AggregationRouterV6_call_fillOrderArgs - name: AggregationRouterV6_call_fillContractOrder - name: AggregationRouterV6_call_fillContractOrderArgs + - name: EscrowFactoryV1_call_createDstEscrow + - name: EscrowFactoryV1_evt_SrcEscrowCreated - name: lop - name: ar \ No newline at end of file From 3b75fac4c982cc9c0c201d48bdf745a01897aafe Mon Sep 17 00:00:00 2001 From: max-morrow Date: Fri, 20 Sep 2024 19:01:53 +0300 Subject: [PATCH 074/127] added columns to project_orders linage (#6779) added tx_from & tx_to --- .../project/oneinch/project/oneinch_project_orders_macro.sql | 4 ++++ .../oneinch/project/oneinch_project_orders_raw_logs_macro.sql | 2 ++ 2 files changed, 6 insertions(+) diff --git a/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_orders_macro.sql b/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_orders_macro.sql index 38baf0dec05..b92475b80bf 100644 --- a/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_orders_macro.sql +++ b/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_orders_macro.sql @@ -16,6 +16,8 @@ logs as ( , block_number , block_time , tx_hash + , tx_from + , tx_to , index , contract_address , topic0 @@ -250,6 +252,8 @@ select , block_number , block_time , tx_hash + , tx_from + , tx_to , tx_success , call_from , call_to diff --git a/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_orders_raw_logs_macro.sql b/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_orders_raw_logs_macro.sql index 3f0cc9475ba..fe9a900cf06 100644 --- a/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_orders_raw_logs_macro.sql +++ b/dbt_subprojects/daily_spellbook/macros/project/oneinch/project/oneinch_project_orders_raw_logs_macro.sql @@ -7,6 +7,8 @@ select block_number , block_time , tx_hash + , tx_from + , tx_to , index , contract_address , topic0 From 188fac5a59e94445c772fdcaeb841f5b30a41730 Mon Sep 17 00:00:00 2001 From: Siciliabird <136583351+QianlongCry@users.noreply.github.com> Date: Mon, 23 Sep 2024 16:11:41 +0200 Subject: [PATCH 075/127] docs: fix broken link (#6787) * docs: fix broken link * docs: fix broken link --- docs/general/sector_spell_design.md | 2 +- docs/macros/macro_overview.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/general/sector_spell_design.md b/docs/general/sector_spell_design.md index 1e2353b1748..ff1e211793a 100644 --- a/docs/general/sector_spell_design.md +++ b/docs/general/sector_spell_design.md @@ -4,7 +4,7 @@ Within Spellbook, there are two main spells which are considered the most popula **Note**: not all sectors are up-to-date in the new structure, but will be considered moving forward -Since these sector-level spells will have their own dedicated `readme` within their directory with specifics, this will remain a high-level overview. Example dex readme [here](/models/_sector/dex/readme.md). +Since these sector-level spells will have their own dedicated `readme` within their directory with specifics, this will remain a high-level overview. Example dex readme [here](/dbt_subprojects/dex/README.md). ## Model level of granularity diff --git a/docs/macros/macro_overview.md b/docs/macros/macro_overview.md index 3f41909e082..8f12ef32e17 100644 --- a/docs/macros/macro_overview.md +++ b/docs/macros/macro_overview.md @@ -28,7 +28,7 @@ Following [this](/dbt_subprojects/dex/macros/models/_project/uniswap_compatible_ - **Multiple Macros in One File** - It's common to have multiple macros within a single file, such as various versions of the uniswap contract code. Group similar macros together logically. -Within models, such as uniswap v2, call macro code with [this approach](/dbt_subprojects/dex/target/compiled/dex/models/trades/ethereum/platforms/uniswap_v2_ethereum_base_trades.sql). +Within models, such as uniswap v2, call macro code with [this approach](/dbt_subprojects/dex/models/trades/ethereum/platforms/uniswap_v2_ethereum_base_trades.sql). ## When to Use a Macro From 9dc17bdbb9fb69a8421db61020a660966ee48958 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Mon, 23 Sep 2024 11:11:51 -0300 Subject: [PATCH 076/127] Add missing tokens to tokens.erc20 (#6803) * Update labels_balancer_v2_pools_polygon.sql * rerun * fix typo * add missing tokens to tokens.erc20 * Update _sources.yml --- .../tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql | 1 + .../tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql | 5 +++-- sources/_subprojects_outputs/hourly_spellbook/_sources.yml | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql index fc06a736b80..3231c9df4d3 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql @@ -100,6 +100,7 @@ FROM (VALUES , (0x90364aa61234b85251ad943681433904c35fa5ce, 'METIS', 18) , (0x4026affabd9032bcc87fa05c02f088905f3dc09b, 'SWISE', 18) , (0xf6d22e29496313d89ad6261fbae8d118181561de, 'GT', 18) + , (0x25ea98ac87a38142561ea70143fd44c4772a16b6, 'MORE', 18) , (0xe7076d4bb604dea53adaa424fce0336ee7f975ff, 'auraezETH/wstETH', 18) , (0xb3cf6721d8f88f7547d90ed8e4119e09945efa9a, 'aurarsETH/wETH', 18) , (0x2f7242373f4b2c831870c145376c4fc9ac76a35d, 'aurarsETH/rETH/wstETH', 18) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql index cf35f9e8226..993f4784fb4 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4589,7 +4589,9 @@ FROM (VALUES , ( 0x866a2bf4e572cbcf37d5071a7a58503bfb36be1b, 'M', 6) , ( 0x20157dbabb84e3bbfe68c349d0d44e48ae7b5ad2, 'dlcBTC', 8) , ( 0xe1B4d34E8754600962Cd944B535180Bd758E6c2e, 'agETH', 18) - , ( 0x5C5b196aBE0d54485975D1Ec29617D42D9198326, 'stdeUSD', 18) + , ( 0x5C5b196aBE0d54485975D1Ec29617D42D9198326, 'stdeUSD', 18) + , ( 0x6dc3ce9c57b20131347fdc9089d740daf6eb34c5, 'balETH', 18) + , ( 0x786f4782d1a5c602ea30bc4a95154110b9e231ea, 'shezBTC', 8) , ( 0x09db87a538bd693e9d08544577d5ccfaa6373a48, 'ynETH', 18) , ( 0x3b50805453023a91a8bf641e279401a0b23fa6f9, 'REZ', 18) , ( 0x7777cec341e7434126864195adef9b05dcc3489c, 'ONI', 18) @@ -4624,5 +4626,4 @@ FROM (VALUES , ( 0x60407266586e204792b69b024558aa18228ab12f, 'MBAKER', 18) , ( 0x048d07bd350ba516b84587e147284881b593eb86, 'SYNK', 18) , ( 0xbbd91d5cda7085a186b1354e1b0744bb58ad7cf6, 'ZOMBIE', 9) - ) AS temp_table (contract_address, symbol, decimals) diff --git a/sources/_subprojects_outputs/hourly_spellbook/_sources.yml b/sources/_subprojects_outputs/hourly_spellbook/_sources.yml index fc633083e38..eac5c639ba9 100644 --- a/sources/_subprojects_outputs/hourly_spellbook/_sources.yml +++ b/sources/_subprojects_outputs/hourly_spellbook/_sources.yml @@ -49,4 +49,4 @@ sources: - name: jelly_swap_sei tables: - - name: pools_metrics_daily \ No newline at end of file + - name: pools_metrics_daily From f50f1abb3879bb6088b9efbfe88fa4164340ed93 Mon Sep 17 00:00:00 2001 From: Mansi <122999960+IrishLatte19@users.noreply.github.com> Date: Mon, 23 Sep 2024 19:42:01 +0530 Subject: [PATCH 077/127] added fbux token price (#6802) --- .../tokens/models/prices/fantom/prices_fantom_tokens.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/fantom/prices_fantom_tokens.sql b/dbt_subprojects/tokens/models/prices/fantom/prices_fantom_tokens.sql index cc99d43fe1b..e3e632c3ece 100644 --- a/dbt_subprojects/tokens/models/prices/fantom/prices_fantom_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/fantom/prices_fantom_tokens.sql @@ -88,7 +88,7 @@ FROM ('polter-polterfinance-protocol-token', 'fantom', 'POLTER', 0x5c725631FD299703D0A74C23F89a55c6B9A0C52F, 18), ('equal-equalizer-dex', 'fantom', 'EQUAL', 0x3fd3a0c85b70754efc07ac9ac0cbbdce664865a6, 18), ('ftails-ftails', 'fantom', 'FTAILS', 0x5cf90b977c86415a53ce3b7be13b26f6abddfee2, 18), - -- ('fbux-fantom-money-market', 'fantom', 'FBUX', 0x1e2ea3f3209d66647f959cf00627107e079b870d, 18), + ('fbux-fantom-money-market', 'fantom', 'FBUX', 0x1e2ea3f3209d66647f959cf00627107e079b870d, 18), ('spirit-spiritswap', 'fantom', 'SPIRIT', 0x5cc61a78f164885776aa610fb0fe1257df78e59b, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( From 87258899f6e2791a4e783ad26d8d6f997660f07a Mon Sep 17 00:00:00 2001 From: Rantum Date: Mon, 23 Sep 2024 07:12:11 -0700 Subject: [PATCH 078/127] add native tokens for scroll & linea (#6788) --- dbt_subprojects/tokens/models/tokens/_schema.yml | 6 +++--- dbt_subprojects/tokens/models/tokens/tokens_native.sql | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dbt_subprojects/tokens/models/tokens/_schema.yml b/dbt_subprojects/tokens/models/tokens/_schema.yml index 6de4d57b157..f1c1236c36a 100644 --- a/dbt_subprojects/tokens/models/tokens/_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/_schema.yml @@ -26,11 +26,11 @@ models: - name: tokens_native meta: - blockchain: avalanche_c, bnb, ethereum, gnosis, optimism, ethereum, arbitrum, solana, fantom, mantle, blast + blockchain: avalanche_c, bnb, ethereum, gnosis, optimism, ethereum, arbitrum, solana, fantom, mantle, blast, scroll, linea sector: tokens - contributors: ilemi + contributors: ilemi, rantum config: - tags: ['tokens','native', 'avalanche_c', 'bnb','ethereum', 'gnosis','optimism','ethereum','solana','arbitrum', 'fantom','mantle', 'blast'] + tags: ['tokens','native', 'avalanche_c', 'bnb','ethereum', 'gnosis','optimism','ethereum','solana','arbitrum', 'fantom','mantle', 'blast','scroll','linea'] description: > The chain native token and symbol, and the prices.usd symbol/address that is closest. columns: diff --git a/dbt_subprojects/tokens/models/tokens/tokens_native.sql b/dbt_subprojects/tokens/models/tokens/tokens_native.sql index 5251fdf0a61..b5d4a319539 100644 --- a/dbt_subprojects/tokens/models/tokens/tokens_native.sql +++ b/dbt_subprojects/tokens/models/tokens/tokens_native.sql @@ -1,10 +1,10 @@ {{ config( alias='native', tags=['static'], - post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","bnb","ethereum","optimism", "gnosis", "fantom", "polygon","solana", "celo", "zksync", "mantle","blast"]\', + post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","bnb","ethereum","optimism", "gnosis", "fantom", "polygon","solana", "celo", "zksync", "mantle","blast","scroll","linea"]\', "sector", "tokens", - \'["0xManny","hildobby","soispoke","dot2dotseurat","mtitus6","wuligy","lgingerich","angus_1","Henrystats"]\') }}')}} + \'["0xManny","hildobby","soispoke","dot2dotseurat","mtitus6","wuligy","lgingerich","angus_1","Henrystats","rantum"]\') }}')}} SELECT chain, symbol, price_symbol, price_address, decimals FROM (VALUES @@ -24,4 +24,6 @@ FROM (VALUES , ('mantle', 'MNT', 'WMNT', 0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8, 18) , ('blast', 'ETH', 'WETH', 0x4300000000000000000000000000000000000004, 18) , ('mode', 'MODE', 'MODE', 0xdfc7c877a950e49d2610114102175a06c2e3167a, 18) + , ('scroll', 'ETH', 'WETH', 0x5300000000000000000000000000000000000004, 18) + , ('linea', 'ETH', 'WETH', 0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f, 18) ) AS temp_table (chain, symbol, price_symbol, price_address, decimals) From 9484d1be4a118bca77ee216d59d038c22d1b7d5c Mon Sep 17 00:00:00 2001 From: ppclunghe <90045511+ppclunghe@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:47:29 +0200 Subject: [PATCH 079/127] wstETH price on BNB (#6806) * prices-wsteth-bnb * fix --- dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql index 414741581d4..ed895f4d0f8 100644 --- a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql @@ -280,7 +280,8 @@ FROM ('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18), ('zeta-zetachain', 'bnb', 'ZETA', 0x0000028a2eb8346cd5c0267856ab7594b7a55308, 18), ('euri-eurite', 'bnb', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18), - ('cookie-cookie', 'bnb', 'COOKIE', 0xc0041ef357b183448b235a8ea73ce4e4ec8c265f, 18) + ('cookie-cookie', 'bnb', 'COOKIE', 0xc0041ef357b183448b235a8ea73ce4e4ec8c265f, 18), + ('wsteth-wrapped-liquid-staked-ether-20', 'bnb', 'wstETH', 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( 0x2ab0e9e4ee70fff1fb9d67031e44f6410170d00e -- bXEN has bad price feed. From 7f6532b3b0294947403baf8f1e22a6df1a5f5d2f Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Mon, 23 Sep 2024 13:48:39 -0300 Subject: [PATCH 080/127] add Avalanche-C models to Gyroscope (#6804) * fix typo * add Avalanche-C models to Gyroscope * again * update cross-chain trades model * update contributors --- .../gyroscope_avalanche_c_schema.yml | 94 +++++++++++++++++++ .../gyroscope_avalanche_c_trades.sql | 56 +++++++++++ .../models/gyroscope/gyroscope_schema.yml | 4 +- .../models/gyroscope/gyroscope_trades.sql | 5 +- .../labels_balancer_v2_pools_avalanche_c.sql | 16 +++- .../gyroscope_avalanche_c_sources.yml | 23 +++++ .../labels_balancer_v2_sources.yml | 29 +++++- 7 files changed, 221 insertions(+), 6 deletions(-) create mode 100644 dbt_subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_schema.yml create mode 100644 dbt_subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_trades.sql create mode 100644 sources/gyroscope/avalanche_c/gyroscope_avalanche_c_sources.yml diff --git a/dbt_subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_schema.yml b/dbt_subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_schema.yml new file mode 100644 index 00000000000..45cc3b0baf0 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_schema.yml @@ -0,0 +1,94 @@ +version: 2 + +models: + + - name: gyroscope_avalanche_c_trades + + meta: + + blockchain: avalanche_c + project: gyroscope + contributors: viniabussafi + + config: + + tags: ["avalanche_c", "gyroscope", "trades"] + + description: trades on gyroscope E-CLP pools on avalanche_c + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_time + - blockchain + - tx_hash + - evt_index + columns: + - &blockchain + name: blockchain + description: "blockchain name(avalanche_c)" + - &project + name: project + description: "gyroscope as project" + - &block_date + name: block_date + description: "UTC event block date" + - &block_month + name: block_month + description: "UTC event block month" + - &block_time + name: block_time + description: "UTC event block time" + - &token_bought_symbol + name: token_bought_symbol + description: "Token symbol for token bought in the trade" + - &token_sold_symbol + name: token_sold_symbol + description: "Token symbol for token sold in the trade" + - &token_pair + name: token_pair + description: "Token symbol pair for each token involved in the trade" + - &token_bought_amount + name: token_bought_amount + description: "Value of the token bought at time of execution in the original currency" + - &token_sold_amount + name: token_sold_amount + description: "Value of the token sold at time of execution in the original currency" + - &token_bought_amount_raw + name: token_bought_amount_raw + description: "Raw value of the token bought at time of execution in the original currency" + - &token_sold_amount_raw + name: token_sold_amount_raw + description: "Raw value of the token sold at time of execution in the original currency" + - &amount_usd + name: amount_usd + description: "USD value of the trade at time of execution" + - &token_bought_address + name: token_bought_address + description: "Contract address of the token bought" + - &token_sold_address + name: token_sold_address + description: "Contract address of the token sold" + - &taker + name: taker + description: "Address of trader who purchased a token" + - &project_contract_address + name: project_contract_address + description: "Ethereum address for the liquidity pool used in transaction" + - &pool_id + name: pool_id + description: "Unique encoded identifier that refers to each pool" + - &swap_fee + name: swap_fee + description: 'Swap fee' + - &tx_hash + name: tx_hash + description: "Transaction hash" + - &tx_from + name: tx_from + description: "transaction.from" + - &tx_to + name: tx_to + description: "transaction.to" + - &evt_index + name: evt_index + description: "Event index" \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_trades.sql b/dbt_subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_trades.sql new file mode 100644 index 00000000000..277c0491d1e --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_trades.sql @@ -0,0 +1,56 @@ +{{ config( + schema = 'gyroscope_avalanche_c', + alias = 'trades', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['block_time', 'blockchain', 'tx_hash', 'evt_index'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] + ) +}} + +with E_CLPs AS ( + SELECT + x.pool + , y.min_block_time + FROM {{ source('gyroscope_avalanche_c','GyroECLPPoolFactory_evt_PoolCreated') }} x + LEFT JOIN ( + SELECT min(evt_block_time) AS min_block_time + FROM {{ source('gyroscope_avalanche_c','GyroECLPPoolFactory_evt_PoolCreated') }} + ) y + on x.pool is not null +) + +SELECT + blockchain, + 'gyroscope' AS project, + block_date, + block_month, + block_time, + token_bought_symbol, + token_sold_symbol, + token_pair, + token_bought_amount, + token_sold_amount, + token_bought_amount_raw, + token_sold_amount_raw, + amount_usd, + token_bought_address, + token_sold_address, + taker, + maker, + project_contract_address, + pool_id, + swap_fee, + tx_hash, + tx_from, + tx_to, + evt_index +FROM {{ source('balancer_v2_avalanche_c', 'trades') }} x +inner join E_CLPs y +on x.block_time >= y.min_block_time +and x.project_contract_address = y.pool +{% if is_incremental() %} +WHERE + {{incremental_predicate('x.block_time')}} +{% endif %} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_schema.yml b/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_schema.yml index ca4964bad6e..1a5799bfb76 100644 --- a/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_schema.yml @@ -6,9 +6,9 @@ models: meta: - blockchain: ethereum, arbitrum, optimism, polygon + blockchain: ethereum, arbitrum, optimism, polygon, avalanche_c project: gyroscope - contributors: fmarrr + contributors: fmarrr, viniabussafi config: diff --git a/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_trades.sql b/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_trades.sql index 9a607a3d773..c7470f4c8f6 100644 --- a/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_trades.sql +++ b/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_trades.sql @@ -2,15 +2,16 @@ schema = 'gyroscope', alias = 'trades', materialized = 'view', - post_hook='{{ expose_spells(\'["arbitrum", "ethereum","optimism", "polygon"]\', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "ethereum","optimism", "polygon"]\', "project", "gyroscope", - \'["fmarrr"]\') }}' + \'["fmarrr", "viniabussafi"]\') }}' ) }} {% set gyroscope_models = [ ref('gyroscope_arbitrum_trades'), + ref('gyroscope_avalanche_c_trades'), ref('gyroscope_ethereum_trades'), ref('gyroscope_optimism_trades'), ref('gyroscope_polygon_trades') diff --git a/dbt_subprojects/dex/models/_projects/balancer/labels/avalanche_c/labels_balancer_v2_pools_avalanche_c.sql b/dbt_subprojects/dex/models/_projects/balancer/labels/avalanche_c/labels_balancer_v2_pools_avalanche_c.sql index ef71780d697..b70f0aee262 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/labels/avalanche_c/labels_balancer_v2_pools_avalanche_c.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/labels/avalanche_c/labels_balancer_v2_pools_avalanche_c.sql @@ -113,6 +113,20 @@ WITH pools AS ( CROSS JOIN UNNEST( CAST(json_extract(settingsParams, '$.tokens') AS ARRAY(VARCHAR)) ) AS t (tokens) + + UNION ALL + + SELECT + c.poolId AS pool_id, + t.tokens AS token_address, + 0 AS normalized_weight, + cc.symbol, + 'ECLP' AS pool_type + FROM {{ source('balancer_v2_avalanche_c', 'Vault_evt_PoolRegistered') }} c + INNER JOIN {{ source('gyroscope_avalanche_c', 'GyroECLPPoolFactory_call_create') }} cc + ON c.evt_tx_hash = cc.call_tx_hash + AND bytearray_substring(c.poolId, 1, 20) = cc.output_0 + CROSS JOIN UNNEST(cc.tokens) AS t(tokens) ), settings AS ( @@ -129,7 +143,7 @@ settings AS ( SELECT 'avalanche_c' AS blockchain, bytearray_substring(pool_id, 1, 20) AS address, - CASE WHEN pool_type IN ('stable', 'linear', 'LBP', 'FX', 'managed') + CASE WHEN pool_type IN ('stable', 'linear', 'LBP', 'FX', 'managed', 'ECLP') THEN lower(pool_symbol) ELSE lower(concat(array_join(array_agg(token_symbol ORDER BY token_symbol), '/'), ' ', array_join(array_agg(cast(norm_weight AS varchar) ORDER BY token_symbol), '/'))) diff --git a/sources/gyroscope/avalanche_c/gyroscope_avalanche_c_sources.yml b/sources/gyroscope/avalanche_c/gyroscope_avalanche_c_sources.yml new file mode 100644 index 00000000000..a27348c9163 --- /dev/null +++ b/sources/gyroscope/avalanche_c/gyroscope_avalanche_c_sources.yml @@ -0,0 +1,23 @@ +version: 2 + +sources: + - name: gyroscope_avalanche_c + description: > + Decoded tables related to gyroscope E-CLP pools on avalanche_c. + tables: + - name: GyroECLPPoolFactory_evt_PoolCreated + description: > + Decoded table of gyroscope pool created + columns: + - name: contract_address + description: 'creator address' + - name: evt_tx_hash + description: 'Primary key of the transaction' + - name: evt_index + description: 'Index value of the transaction' + - name: evt_block_time + description: 'Timestamp for block event time in UTC' + - name: evt_block_number + description: 'Block number which processed the unique transaction hash' + - name: pool + description: 'created ECLP pool address' \ No newline at end of file diff --git a/sources/labels/addresses/__single_category_labels__/balancer_v2/labels_balancer_v2_sources.yml b/sources/labels/addresses/__single_category_labels__/balancer_v2/labels_balancer_v2_sources.yml index 7ddea4f1b7d..885b9c30308 100644 --- a/sources/labels/addresses/__single_category_labels__/balancer_v2/labels_balancer_v2_sources.yml +++ b/sources/labels/addresses/__single_category_labels__/balancer_v2/labels_balancer_v2_sources.yml @@ -1870,4 +1870,31 @@ sources: - *swapFeePercentage - *rateProviders - *symbol - - *tokens \ No newline at end of file + - *tokens + + - name: gyroscope_avalanche_c + tables: + - name: GyroECLPPoolFactory_call_create + description: > + Decoded table of registered pools on the Gyroscope ECLP contract. + columns: + - *call_block_number + - *call_block_time + - *call_success + - *call_trace_address + - *call_tx_hash + - name: capManager + - name: capParams + - name: contract_address + description: "Address of the ECLP Pool contract" + - name: derivedECLPParams + - name: eclpParams + - name: name + - *output_0 + - *owner + - name: pauseManager + - name: pauseParams + - *swapFeePercentage + - *rateProviders + - *symbol + - *tokens \ No newline at end of file From 2d1d595264f2d31017a8ab152e71974917c4c2c0 Mon Sep 17 00:00:00 2001 From: Daniel <32246390+danielpartida@users.noreply.github.com> Date: Mon, 23 Sep 2024 18:50:23 +0200 Subject: [PATCH 081/127] Safe mantle models (#6777) * Add v1.4.1 singletons L1 singleton 0x41675C099F32341bf84BFc5382aF534df5C7461a L2 singleton 0x29fcB43b46531BcA003ddC8FCB67FFE91900C76 * Change goerli test * Declare new Safe models for zkevm * Implement Safe models for zkevm * Update crosschain models with zkevm data Models updated are: - safe_native_transfers.all.sql -> Added safe_zkevm_matic_transfers - safe_safes_all.sql -> Added safe_zkevm_safes - safe_transactions_all.sql -> safe_zkevm_transactions * Bugfix: Joining correctly on celo transactions for safe_celo_transactions spell * Fix project start for safe_polygon_matic_transfers.sql * Implement Safe mantle transfers spell * Implement Safe mantle singletons model * Implement Safe mantle txs spell * Change project start date for Safe mantle models * Add Mantle data to native transfers spell * Add Safe mantles models for all Safes * Add Safe mantle txs to all txs spell * Add Safe mantle data to Safe schema * Create Safe mantle schema * Implement Safe mantle sources file * Removing zkevm transactions model from wrong directory * Fix names of proxy factory contracts * Change file of Safe mantle native token transfers --- .../safe/mantle/safe_mantle_mnt_transfers.sql | 26 +++ .../safe/mantle/safe_mantle_safes.sql | 48 ++++++ .../safe/mantle/safe_mantle_schema.yml | 161 ++++++++++++++++++ .../safe/mantle/safe_mantle_singletons.sql | 21 +++ .../safe/mantle/safe_mantle_transactions.sql | 20 +++ .../safe/safe_native_transfers_all.sql | 3 +- .../models/_project/safe/safe_safes_all.sql | 3 +- .../models/_project/safe/safe_schema.yml | 12 +- .../_project/safe/safe_transactions_all.sql | 3 +- sources/safe/mantle/safe_mantle_sources.yml | 45 +++++ 10 files changed, 333 insertions(+), 9 deletions(-) create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_mnt_transfers.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_safes.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_schema.yml create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_singletons.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_transactions.sql create mode 100644 sources/safe/mantle/safe_mantle_sources.yml diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_mnt_transfers.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_mnt_transfers.sql new file mode 100644 index 00000000000..51b8f396243 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_mnt_transfers.sql @@ -0,0 +1,26 @@ +{{ + config( + schema = 'safe_mantle', + alias= 'mnt_transfers', + partition_by = ['block_month'], + on_schema_change='fail', + materialized='incremental', + file_format ='delta', + incremental_strategy='merge', + unique_key = ['block_date', 'address', 'tx_hash', 'trace_address'], + post_hook = '{{ expose_spells(blockchains = \'["mantle"]\', + spell_type = "project", + spell_name = "safe", + contributors = \'["danielpartida"]\') }}' + ) +}} + +{% set project_start_date = '2023-07-12' %} + +{{ + safe_native_transfers( + blockchain = 'mantle', + native_token_symbol = 'MNT', + project_start_date = project_start_date + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_safes.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_safes.sql new file mode 100644 index 00000000000..79f79916d38 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_safes.sql @@ -0,0 +1,48 @@ +{{ + config( + materialized='incremental', + schema = 'safe_mantle', + alias= 'safes', + partition_by = ['block_month'], + unique_key = ['block_date', 'address'], + on_schema_change='fail', + file_format ='delta', + incremental_strategy='merge', + post_hook = '{{ expose_spells( + blockchains = \'["mantle"]\', + spell_type = "project", + spell_name = "safe", + contributors = \'["danielpartida"]\') }}' + ) +}} + +{% set project_start_date = '2023-07-12' %} + +select + 'mantle' as blockchain, + et."from" as address, + case + when et.to = 0xd9db270c1b5e3bd161e8c8503c55ceabee709552 then '1.3.0' + when et.to = 0x3e5c63644e683549055b9be8653de26e0b4cd36e then '1.3.0L2' + when et.to = 0x41675C099F32341bf84BFc5382aF534df5C7461a then '1.4.1' + when et.to = 0x29fcB43b46531BcA003ddC8FCB67FFE91900C762 then '1.4.1L2' + else 'unknown' + end as creation_version, + try_cast(date_trunc('day', et.block_time) as date) as block_date, + CAST(date_trunc('month', et.block_time) as DATE) as block_month, + et.block_time as creation_time, + et.tx_hash +from {{ source('mantle', 'traces') }} et +join {{ ref('safe_mantle_singletons') }} s + on et.to = s.address +where et.success = true + and et.call_type = 'delegatecall' -- delegatecall to singleton is Safe (proxy) address + and bytearray_substring(et.input, 1, 4) in ( + 0xb63e800d -- setup method v1.3.0, v1.3.0L2, v1.4.1, v.1.4.1L2 + ) + and et.gas_used > 10000 -- to ensure the setup call was successful. excludes e.g. setup calls with missing params that fallback + {% if not is_incremental() %} + and et.block_time > TIMESTAMP '{{project_start_date}}' -- for initial query optimisation + {% else %} + and {{ incremental_predicate('et.block_time') }} + {% endif %} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_schema.yml new file mode 100644 index 00000000000..1dcf7c5e6bb --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_schema.yml @@ -0,0 +1,161 @@ +version: 2 + +models: + - name: safe_mantle_safes + meta: + blockchain: mantle + project: safe + contributors: danielpartida + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } + config: + tags: ['safe', 'mantle'] + description: "Safe addresses" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - address + columns: + - &blockchain + name: blockchain + description: "The blockchain on which the Safe is deployed" + - &address + name: address + description: "Safe contract address" + - &creation_version + name: creation_version + description: "Version of initially created safe" + - &block_date + name: block_date + - &block_month + name: block_month + - &creation_time + name: creation_time + description: "Date/time of safe creation" + - &tx_hash + name: tx_hash + + - name: safe_mantle_mnt_transfers + meta: + blockchain: mantle + project: safe + contributors: danielpartida + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } + config: + tags: ['safe', 'transfers', 'mantle'] + description: "MNT transfers for safes" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - address + - tx_hash + - trace_address + columns: + - *blockchain + - &symbol + name: symbol + description: "Symbol of native gas token: MNT" + - *address + - *block_date + - *block_month + - &block_time + name: block_time + description: "Date of MNT transfer" + - &amount_raw + name: amount_raw + description: "Raw amount of transferred MNT" + - *tx_hash + - &trace_address + name: trace_address + - &amount_usd + name: amount_usd + description: "USD amount of transferred MNT" + + - name: safe_mantle_singletons + meta: + blockchain: mantle + project: safe + contributors: danielpartida + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } + config: + tags: ['safe', 'singletons', 'mantle'] + description: "Singletons addresses used with Safes" + columns: + - name: address + description: "Safe contract address" + + - name: safe_mantle_transactions + meta: + blockchain: mantle + project: safe + contributors: danielpartida + freshness: + warn_after: { count: 12, period: hour } + error_after: { count: 24, period: hour } + config: + tags: ['safe', 'mantle'] + description: "Safe transactions" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - tx_hash + - trace_address + columns: + - *blockchain + - *block_date + - *block_month + - *block_time + - &block_number + name: block_number + description: "Number of block" + - *tx_hash + - name: address + description: "Safe contract address" + - &to + name: to + description: "Destination address" + - &value + name: value + description: "Value of transaction" + - &gas + name: gas + description: "Gas limit set for transaction" + - &execution_gas_used + name: execution_gas_used + description: "Execution gas used during transaction, for more details see https://dune.com/docs/data-tables/raw/evm/traces/?h=traces#gas-used-in-traces" + - &total_gas_used + name: total_gas_used + description: "Total gas used during transaction" + - &tx_index + name: tx_index + description: "Transaction index" + - &sub_traces + name: sub_traces + description: "Number of sub traces" + - *trace_address + - &success + name: success + description: "Success state of transaction" + - &error + name: error + description: "Error of transaction if any" + - &code + name: code + description: "Code" + - &input + name: input + description: "Input data" + - &output + name: output + description: "Output data" + - &method + name: method + description: "Function method" \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_singletons.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_singletons.sql new file mode 100644 index 00000000000..91ab724e511 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_singletons.sql @@ -0,0 +1,21 @@ +{{ + config( + materialized='table', + schema = 'safe_mantle', + alias= 'singletons', + post_hook = '{{ expose_spells( + blockchains = \'["mantle"]\', + spell_type = "project", + spell_name = "safe", + contributors = \'["danielpartida"]\') }}' + ) +}} + + +-- Fetch all known singleton/mastercopy addresses used via factories. +select distinct singleton as address +from {{ source('gnosis_safe_mantle', 'SafeProxyFactory_v1_3_0_evt_ProxyCreation') }} + +union +select distinct singleton as address +from {{ source('gnosis_safe_mantle', 'SafeProxyFactory_v1_4_1_evt_ProxyCreation') }} \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_transactions.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_transactions.sql new file mode 100644 index 00000000000..26ed337c0aa --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/mantle/safe_mantle_transactions.sql @@ -0,0 +1,20 @@ +{{ + config( + materialized='incremental', + schema = 'safe_mantle', + alias= 'transactions', + partition_by = ['block_month'], + unique_key = ['block_date', 'tx_hash', 'trace_address'], + file_format ='delta', + incremental_strategy='merge', + post_hook = '{{ expose_spells( + blockchains = \'["mantle"]\', + spell_type = "project", + spell_name = "safe", + contributors = \'["danielpartida"]\') }}' + ) +}} + +{% set project_start_date = '2023-07-12' %} + +{{ safe_transactions('mantle', project_start_date) }} diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_native_transfers_all.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_native_transfers_all.sql index f5e01729566..a93c63bef1a 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_native_transfers_all.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_native_transfers_all.sql @@ -1,7 +1,7 @@ {{ config( schema = 'safe', alias = 'native_transfers_all', - post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\', + post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","gnosis","goerli","linea","mantle","optimism","polygon","scroll","zkevm","zksync"]\', "project", "safe", \'["kryptaki", "danielpartida"]\') }}' @@ -19,6 +19,7 @@ ,ref('safe_gnosis_xdai_transfers') ,ref('safe_goerli_eth_transfers') ,ref('safe_linea_eth_transfers') +,ref('safe_mantle_mnt_transfers') ,ref('safe_optimism_eth_transfers') ,ref('safe_polygon_matic_transfers') ,ref('safe_scroll_eth_transfers') diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_safes_all.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_safes_all.sql index 422871b6bc2..e0c1da95cff 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_safes_all.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_safes_all.sql @@ -1,7 +1,7 @@ {{ config( schema = 'safe', alias = 'safes_all', - post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","fantom","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\', + post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","fantom","gnosis","goerli","linea","mantle","optimism","polygon","scroll","zkevm","zksync"]\', "project", "safe", \'["tschubotz", "danielpartida", "kryptaki"]\') }}' @@ -20,6 +20,7 @@ ,ref('safe_gnosis_safes') ,ref('safe_goerli_safes') ,ref('safe_linea_safes') +,ref('safe_mantle_safes') ,ref('safe_optimism_safes') ,ref('safe_polygon_safes') ,ref('safe_scroll_safes') diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_schema.yml index f944311f8b7..a6cae3d8159 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_schema.yml @@ -3,11 +3,11 @@ version: 2 models: - name: safe_safes_all meta: - blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, fantom, gnosis, goerli, linea, optimism, polygon, scroll, zkevm, zksync + blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, fantom, gnosis, goerli, linea, , mantle, optimism, polygon, scroll, zkevm, zksync project: safe contributors: tschubotz, danielpartida, kryptaki config: - tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'linea', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync'] + tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'linea', 'mantle', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync'] description: > Lists all Safes across chains. columns: @@ -32,14 +32,14 @@ models: - name: safe_transactions_all meta: - blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, fantom, gnosis, goerli, linea, optimism, polygon, scroll, zkevm, zksync + blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, fantom, gnosis, goerli, linea, mantle, optimism, polygon, scroll, zkevm, zksync project: safe contributors: kryptaki, danielpartida freshness: warn_after: { count: 12, period: hour } error_after: { count: 24, period: hour } config: - tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'linea', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync'] + tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'fantom', 'gnosis', 'goerli', 'linea', 'mantle', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync'] description: "Safe transactions" columns: - *blockchain @@ -94,14 +94,14 @@ models: - name: safe_native_transfers_all meta: - blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, gnosis, goerli, linea, optimism, polygon, scroll, zkevm, zksync + blockchain: arbitrum, avalanche_c, base, blast, bnb, celo, ethereum, gnosis, goerli, linea, mantle, optimism, polygon, scroll, zkevm, zksync project: safe contributors: kryptaki, tschubotz, danielpartida freshness: warn_after: { count: 12, period: hour } error_after: { count: 24, period: hour } config: - tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'gnosis', 'goerli', 'linea', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync'] + tags: ['arbitrum', 'avalanche_c', 'base', 'blast', 'bnb', 'celo','ethereum', 'gnosis', 'goerli', 'linea', 'mantle', 'optimism', 'polygon', 'safe', 'scroll', 'zkevm', 'zksync'] description: "Native gas token transfers into or out of Safes" tests: - dbt_utils.unique_combination_of_columns: diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_transactions_all.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_transactions_all.sql index e2b069e5cfa..292f471fddf 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_transactions_all.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/safe_transactions_all.sql @@ -1,7 +1,7 @@ {{ config( schema = 'safe', alias = 'transactions_all', - post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","fantom","gnosis","goerli","linea","optimism","polygon","scroll","zkevm","zksync"]\', + post_hook='{{ expose_spells(\'["arbitrum","avalanche_c","base","blast","bnb","celo","ethereum","fantom","gnosis","goerli","linea","mantle","optimism","polygon","scroll","zkevm","zksync"]\', "project", "safe", \'["kryptaki", "danielpartida"]\') }}' @@ -20,6 +20,7 @@ ,ref('safe_gnosis_transactions') ,ref('safe_goerli_transactions') ,ref('safe_linea_transactions') +,ref('safe_mantle_transactions') ,ref('safe_optimism_transactions') ,ref('safe_polygon_transactions') ,ref('safe_scroll_transactions') diff --git a/sources/safe/mantle/safe_mantle_sources.yml b/sources/safe/mantle/safe_mantle_sources.yml new file mode 100644 index 00000000000..01237b0084e --- /dev/null +++ b/sources/safe/mantle/safe_mantle_sources.yml @@ -0,0 +1,45 @@ +version: 2 + +sources: + - name: gnosis_safe_mantle + freshness: + warn_after: { count: 12, period: hour } + tables: + - name: SafeProxyFactory_v1_3_0_evt_ProxyCreation + loaded_at_field: evt_block_time + description: "Safe v1.3.0 factory ProxyCreation events" + columns: + - &contract_address + name: contract_address + description: "Contract address" + - &evt_block_number + name: evt_block_number + description: "Event block number" + - &evt_block_time + name: evt_block_time + description: "Event block time" + - &evt_index + name: evt_index + description: "Event index" + - &evt_tx_hash + name: evt_tx_hash + description: "Event tx hash" + - &proxy + name: proxy + description: "Address of created Safe proxy" + - &singleton + name: singleton + description: "Singleton" + - name: SafeProxyFactory_v1_4_1_evt_ProxyCreation + loaded_at_field: evt_block_time + description: "Safe v1.4.1 factory ProxyCreation events" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - name: proxy + description: "Address of created Safe proxy" + - name: singleton + description: "Singleton" \ No newline at end of file From f0507df098373405cbc334ab20f5010cd660d197 Mon Sep 17 00:00:00 2001 From: Andrew <47720952+andrewhong5297@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:23:14 -0400 Subject: [PATCH 082/127] fix epochs (#6801) * Update staking_solana_validator_stake_account_epochs_raw.sql * Revert "Update staking_solana_validator_stake_account_epochs_raw.sql" This reverts commit dacd5334f5a4f5cf4d34c88d65dc1ced48988c2b. * increase lookup time for epochs --------- Co-authored-by: jeff-dude --- .../staking_solana_validator_stake_account_epochs_raw.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/solana/models/_sector/staking/solana/staking_solana_validator_stake_account_epochs_raw.sql b/dbt_subprojects/solana/models/_sector/staking/solana/staking_solana_validator_stake_account_epochs_raw.sql index ff6dd1975a6..11b607dae74 100644 --- a/dbt_subprojects/solana/models/_sector/staking/solana/staking_solana_validator_stake_account_epochs_raw.sql +++ b/dbt_subprojects/solana/models/_sector/staking/solana/staking_solana_validator_stake_account_epochs_raw.sql @@ -22,7 +22,7 @@ with LEFT JOIN {{ ref('solana_utils_epochs') }} epoch ON first_block_epoch = true --cross join {% if is_incremental() %} - AND {{incremental_predicate('epoch.block_time')}} + AND epoch.block_time >= date_trunc('day', now() - interval '7' day) {% endif %} WHERE vote.block_slot < epoch.block_slot --only get changes to accounts before start of epoch GROUP BY 1,2,3,4,5 From 3e11e53bb59a9cfc2bda825ce33e22e1f6708931 Mon Sep 17 00:00:00 2001 From: Rantum Date: Tue, 24 Sep 2024 10:23:45 -0700 Subject: [PATCH 083/127] add mantle & blast to cross-chain spell (#6784) --- dbt_subprojects/nft/models/_sector/transfers/_schema.yml | 6 +++--- .../nft/models/_sector/transfers/nft_transfers.sql | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/dbt_subprojects/nft/models/_sector/transfers/_schema.yml b/dbt_subprojects/nft/models/_sector/transfers/_schema.yml index 4b2fb972b35..4ce60886e35 100644 --- a/dbt_subprojects/nft/models/_sector/transfers/_schema.yml +++ b/dbt_subprojects/nft/models/_sector/transfers/_schema.yml @@ -3,11 +3,11 @@ version: 2 models: - name: nft_transfers meta: - blockchain: ethereum, base, polygon, bnb, avalanche_c, gnosis, optimism, arbitrum, fantom, goerli, celo, zksync, zora + blockchain: ethereum, base, polygon, bnb, avalanche_c, gnosis, optimism, arbitrum, fantom, goerli, celo, zksync, zora, scroll, mantle, blast, sector: nft - contributors: hildobby + contributors: hildobby, rantum config: - tags: ['nft', 'ethereum', 'base', 'polygon', 'bnb', 'avalanche_c', 'gnosis', 'optimism', 'arbitrum', 'fantom', 'goerli', 'celo', 'zksync', 'zora', 'transfers'] + tags: ['nft', 'ethereum', 'base', 'polygon', 'bnb', 'avalanche_c', 'gnosis', 'optimism', 'arbitrum', 'fantom', 'goerli', 'celo', 'zksync', 'zora', 'scroll', 'mantle', 'blast', 'transfers'] description: > NFT transfers tests: diff --git a/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql b/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql index eb0fd05d822..f38899ca6dd 100644 --- a/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql +++ b/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql @@ -8,10 +8,10 @@ incremental_strategy = 'merge', incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], unique_key = ['tx_hash', 'evt_index', 'token_id', 'amount'], - post_hook='{{ expose_spells(\'["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum", "polygon", "fantom", "goerli", "base", "celo", "zksync"]\', + post_hook='{{ expose_spells(\'["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum", "polygon", "fantom", "goerli", "base", "celo", "zksync", "zora", "scroll", "linea", "blast", "mantle"]\', "sector", "nft", - \'["hildobby", "0xRob"]\') }}' + \'["hildobby", "0xRob", "rantum"]\') }}' ) }} @@ -31,6 +31,8 @@ ,ref('nft_celo_transfers') ,ref('nft_scroll_transfers') ,ref('nft_linea_transfers') +,ref('nft_blast_transfers') +,ref('nft_mantle_transfers') ] %} SELECT * From 9b8d39e0516415efacbc515c155923f8b293d513 Mon Sep 17 00:00:00 2001 From: Rantum Date: Tue, 24 Sep 2024 10:26:00 -0700 Subject: [PATCH 084/127] Add missing fields to evms.logs (#6813) * Add missing fields to evms.logs * remove blob fields --- dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql | 5 ++++- dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql b/dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql index 36a66355e7f..7eb81a4af1c 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_logs.sql @@ -5,7 +5,7 @@ post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "goerli", "zksync", "zora", "scroll", "linea", "zkevm", "blast", "mantle"]\', "sector", "evms", - \'["hildobby"]\') }}' + \'["hildobby","rantum"]\') }}' ) }} @@ -49,6 +49,9 @@ FROM ( , tx_hash , index , tx_index + , block_date + , tx_from + , tx_to FROM {{ logs_model[1] }} {% if not loop.last %} UNION ALL diff --git a/dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml b/dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml index 68b56b52d23..f6d861905c4 100644 --- a/dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/evms/evms_schema.yml @@ -155,7 +155,7 @@ models: meta: blockchain: ethereum, polygon, bnb, avalanche_c, gnosis, fantom, optimism, arbitrum, celo, base, goerli, zksync, zora, scroll, linea, zkevm, blast, mantle, mode, sei sector: evms - contributors: [hildobby, synthquest] + contributors: [hildobby, synthquest, rantum] config: tags: ['evms', 'logs'] description: "An EVM log can be used to describe an event within a smart contract, like a token transfer or a change of ownership." From feda163d186187362db203c14024c26d4a406a45 Mon Sep 17 00:00:00 2001 From: Rantum Date: Tue, 24 Sep 2024 10:29:15 -0700 Subject: [PATCH 085/127] add new stablecoins (#6812) * add new stablecoins * commas * add missing decimal value * add gho, dyad --- .../tokens_arbitrum_erc20_stablecoins.sql | 15 ++++++++++-- .../arbitrum/tokens_arbitrum_schema.yml | 2 +- .../tokens_avalanche_c_erc20_stablecoins.sql | 7 ++++-- .../avalanche_c/tokens_avalanche_c_schema.yml | 2 +- .../base/tokens_base_erc20_stablecoins.sql | 9 ++++--- .../models/tokens/base/tokens_base_schema.yml | 2 +- .../bnb/tokens_bnb_erc20_stablecoins.sql | 6 +++-- .../models/tokens/bnb/tokens_bnb_schema.yml | 2 +- .../tokens_ethereum_erc20_stablecoins.sql | 24 ++++++++++++++++--- .../ethereum/tokens_ethereum_schema.yml | 2 +- .../tokens_optimism_erc20_stablecoins.sql | 5 ++-- .../optimism/tokens_optimism_schema.yml | 2 +- .../tokens_polygon_erc20_stablecoins.sql | 5 ++-- .../tokens/polygon/tokens_polygon_schema.yml | 2 +- 14 files changed, 62 insertions(+), 23 deletions(-) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20_stablecoins.sql index 335216bcd6b..28bd841786b 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20_stablecoins.sql @@ -5,7 +5,7 @@ , post_hook='{{ expose_spells(\'["arbitrum"]\', "sector", "tokens_arbitrum", - \'["synthquest"]\') }}' + \'["synthquest","rantum"]\') }}' , unique_key = ['contract_address'] ) }} @@ -30,5 +30,16 @@ FROM (VALUES ('arbitrum', 0x3509f19581afedeff07c53592bc0ca84e4855475, 'Crypto-backed stablecoin', 'xUSD', 18, ''), ('arbitrum', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 'Fiat-backed stablecoin', 'USDM', 18, ''), ('arbitrum', 0xff970a61a04b1ca14834a43f5de4533ebddb5cc8, 'Fiat-backed stablecoin', 'USDC', 6, ''), - ('arbitrum', 0x4d15a3a2286d883af0aa1b3f21367843fac63e07, 'Fiat-backed stablecoin', 'TUSD', 18, '') + ('arbitrum', 0x4d15a3a2286d883af0aa1b3f21367843fac63e07, 'Fiat-backed stablecoin', 'TUSD', 18, ''), + ('arbitrum', 0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34, 'Crypto-backed stablecoin', 'USDe', 18, ''), + ('arbitrum', 0xeb466342c4d449bc9f53a865d5cb90586f405215, 'Crypto-backed stablecoin', 'axlUDC', 6, ''), + ('arbitrum', 0xd3443ee1e91af28e5fb858fbd0d72a63ba8046e0, 'Crypto-backed stablecoin', 'gUSDC', 6, ''), + ('arbitrum', 0x7cfadfd5645b50be87d546f42699d863648251ad, 'Crypto-backed stablecoin', 'stataArbUSDCn', 6, ''), + ('arbitrum', 0x12275dcb9048680c4be40942ea4d92c74c63b844, 'Crypto-backed stablecoin', 'eUSD', 18, ''), + ('arbitrum', 0xb165a74407fe1e519d6bcbdec1ed3202b35a4140, 'Crypto-backed stablecoin', 'stataArbUSDT', 6, ''), + ('arbitrum', 0x323665443cef804a3b5206103304bd4872ea4253, 'Crypto-backed stablecoin', 'USDV', 6, ''), + ('arbitrum', 0x4cfa50b7ce747e2d61724fcac57f24b748ff2b2a, 'Crypto-backed stablecoin', 'fUSDC', 6, ''), + ('arbitrum', 0x57f5e098cad7a3d1eed53991d4d66c45c9af7812, 'Crypto-backed stablecoin', 'sUSDM', 18, ''), + ('arbitrum', 0x7dff72693f6a4149b17e7c6314655f6a9f7c8b33, 'Crypto-backed stablecoin', 'GHO', 18, '') + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml index 0d566872dc6..01c696367f9 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_schema.yml @@ -86,7 +86,7 @@ models: meta: blockchain: arbitrum sector: stablecoins - contributors: synthquest + contributors: synthquest, rantum config: tags: ['tokens', 'arbitrum', 'erc20', 'stablecoins'] description: > diff --git a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20_stablecoins.sql index c6d569bd584..7ab0fa26f00 100644 --- a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_erc20_stablecoins.sql @@ -5,7 +5,7 @@ , post_hook='{{ expose_spells(\'["avalanche_c"]\', "sector", "tokens_avalanche_c", - \'["synthquest"]\') }}' + \'["synthquest","rantum"]\') }}' , unique_key = ['contract_address'] ) }} @@ -27,6 +27,9 @@ FROM (VALUES ('avalanche_c', 0x1c20e891bab6b1727d14da358fae2984ed9b59eb, 'Fiat-backed stablecoin', 'TUSD', 18, ''), ('avalanche_c', 0xdacde03d7ab4d81feddc3a20faa89abac9072ce2, 'Crypto-backed stablecoin', 'USP', 18, ''), ('avalanche_c', 0xa7d7079b0fead91f3e65f86e8915cb59c1a4c664, 'Crypto-backed stablecoin', 'USDC.e', 6, ''), - ('avalanche_c', 0x8861f5c40a0961579689fdf6cdea2be494f9b25a, 'Hybrid stablecoin', 'iUSDS', 18, '') + ('avalanche_c', 0x8861f5c40a0961579689fdf6cdea2be494f9b25a, 'Hybrid stablecoin', 'iUSDS', 18, ''), + ('avalanche_c', 0xc7198437980c041c805a1edcba50c1ce5db95118, 'Crypto-backed stablecoin', 'USDT.e', 6, ''), + ('avalanche_c', 0xabe7a9dfda35230ff60d1590a929ae0644c47dc1, 'Crypto-backed stablecoin', 'aUSD', 18, ''), + ('avalanche_c', 0xfab550568c688d5d8a52c7d794cb93edc26ec0ec, 'Crypto-backed stablecoin', 'axlUSD', 6, '') ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_schema.yml b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_schema.yml index 22c9c8c7cec..20ae182a593 100644 --- a/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/avalanche_c/tokens_avalanche_c_schema.yml @@ -90,7 +90,7 @@ models: meta: blockchain: avalanche_c sector: stablecoins - contributors: synthquest + contributors: synthquest, rantum config: tags: ['tokens', 'avalanche_c', 'erc20', 'stablecoins'] description: > diff --git a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20_stablecoins.sql index 8cbcbdcb911..50f24ffc47c 100644 --- a/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/base/tokens_base_erc20_stablecoins.sql @@ -5,7 +5,7 @@ , post_hook='{{ expose_spells(\'["base"]\', "sector", "tokens_base", - \'["synthquest"]\') }}' + \'["synthquest","rantum"]\') }}' , unique_key = ['contract_address'] ) }} @@ -20,7 +20,10 @@ FROM (VALUES ('base', 0x833589fcd6edb6e08f4c7c32d4f71b54bda02913, 'Fiat-backed stablecoin', 'USDC', 6, ''), ('base', 0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 'Fiat-backed stablecoin', 'USDz', 18, ''), ('base', 0x4621b7a9c75199271f773ebd9a499dbd165c3191, 'Crypto-backed stablecoin', 'DOLA', 18, ''), - ('base', 0xca72827a3d211cfd8f6b00ac98824872b72cab49, 'Fiat-backed stablecoin', 'cgUSD', 6, '') - + ('base', 0xca72827a3d211cfd8f6b00ac98824872b72cab49, 'Fiat-backed stablecoin', 'cgUSD', 6, ''), + ('base', 0x4621b7a9c75199271f773ebd9a499dbd165c3191, 'Crypto-backed stablecoin', 'DOLA', 18, ''), + ('base', 0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca, 'Stable-backed stablecoin', 'USDbC', 6, ''), + ('base', 0xfde4c96c8593536e31f229ea8f37b2ada2699bb2, 'Stable-backed stablecoin', 'USDT', 6, ''), + ('base', 0xeb466342c4d449bc9f53a865d5cb90586f405215, 'Crypto-backed stablecoin', 'axlUSDC', 6, '') ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml b/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml index 3cd3f9fe144..85bfcdf06db 100644 --- a/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/base/tokens_base_schema.yml @@ -86,7 +86,7 @@ models: meta: blockchain: base sector: stablecoins - contributors: synthquest + contributors: synthquest, rantum config: tags: ['tokens', 'base', 'erc20', 'stablecoins'] description: > diff --git a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_erc20_stablecoins.sql index 2d1457e851f..bc06307d26f 100644 --- a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_erc20_stablecoins.sql @@ -5,7 +5,7 @@ , post_hook='{{ expose_spells(\'["bnb"]\', "sector", "tokens_bnb", - \'["synthquest"]\') }}' + \'["synthquest","rantum"]\') }}' , unique_key = ['contract_address'] ) }} @@ -36,7 +36,9 @@ FROM (VALUES ('bnb', 0xb5102cee1528ce2c760893034a4603663495fd72, 'Crypto-backed stablecoin', 'USX', 18, ''), ('bnb', 0xb7f8cd00c5a06c0537e2abff0b58033d02e5e094, 'Crypto-backed stablecoin', 'PAX', 18, ''), ('bnb', 0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3, 'Hybrid stablecoin', 'DAI', 18, ''), - ('bnb', 0xd17479997f34dd9156deef8f95a52d81d265be9c, 'Algorithmic stablecoin', 'USDD', 18, '') + ('bnb', 0xd17479997f34dd9156deef8f95a52d81d265be9c, 'Algorithmic stablecoin', 'USDD', 18, ''), + ('bnb', 0x4268b8f0b87b6eae5d897996e6b845ddbd99adf3, 'Crypto-backed stablecoin', 'axlUSDC', 6, '') + diff --git a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml index 5ebe3c50929..efa478e7176 100644 --- a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_schema.yml @@ -86,7 +86,7 @@ models: meta: blockchain: bnb sector: stablecoins - contributors: synthquest + contributors: synthquest, rantum config: tags: ['tokens', 'bnb', 'erc20', 'stablecoins'] description: > diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql index 8072f092389..69adcbb06ef 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql @@ -5,7 +5,7 @@ , post_hook='{{ expose_spells(\'["ethereum"]\', "sector", "tokens_ethereum", - \'["Henrystats", "synthquest"]\') }}' + \'["Henrystats", "synthquest","rantum"]\') }}' , unique_key = ['contract_address'] ) }} @@ -60,7 +60,25 @@ FROM (VALUES ('ethereum', 0x57Ab1E02fEE23774580C119740129eAC7081e9D3, 'Crypto-backed stablecoin', 'sUSD', 18, 'Synthetix sUSD'), ('ethereum', 0xa693b19d2931d498c5b318df961919bb4aee87a5, 'Crypto-backed stablecoin', 'UST', 6, 'UST (Wormhole)'), ('ethereum', 0xe07F9D810a48ab5c3c914BA3cA53AF14E4491e8A, 'Crypto-backed stablecoin', 'GYD', 18, 'Gyro Dollar'), - ('ethereum', 0xdb25f211ab05b1c97d595516f45794528a807ad8, 'Fiat-backed stablecoin', 'EURS', 18, 'STASIS EURS') - + ('ethereum', 0xdb25f211ab05b1c97d595516f45794528a807ad8, 'Fiat-backed stablecoin', 'EURS', 18, 'STASIS EURS'), + ('ethereum', 0x15f74458ae0bfdaa1a96ca1aa779d715cc1eefe4, 'Crypto-backed stablecoin', 'GRAI', 18, 'Gravita Protocol'), + ('ethereum', 0xf939e0a03fb07f59a73314e73794be0e57ac1b4e, 'Crypto-backed stablecoin', 'crvUSD', 18, ''), + ('ethereum', 0xab5eb14c09d416f0ac63661e57edb7aecdb9befa, 'Crypto-backed stablecoin', 'msUSD', 18, ''), + ('ethereum', 0x9d39a5de30e57443bff2a8307a4256c8797a3497, 'Crypto-backed stablecoin', 'sUSDe', 18, ''), + ('ethereum', 0x15700b564ca08d9439c58ca5053166e8317aa138, 'Crypto-backed stablecoin', 'deUSD', 18, ''), + ('ethereum', 0x085780639cc2cacd35e474e71f4d000e2405d8f6, 'Crypto-backed stablecoin', 'fxUSD', 18, ''), + ('ethereum', 0x00000000efe302beaa2b3e6e1b18d08d69a9012a, 'Crypto-backed stablecoin', 'AUSD', 6, ''), + ('ethereum', 0xa0d69e286b938e21cbf7e51d71f6a4c8918f482f, 'Crypto-backed stablecoin', 'eUSD', 18, ''), + ('ethereum', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 'Crypto-backed stablecoin', 'USDz', 18, ''), + ('ethereum', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 'Crypto-backed stablecoin', 'USDM', 18, ''), + ('ethereum', 0x79c58f70905f734641735bc61e45c19dd9ad60bc, 'Crypto-backed stablecoin', 'usdc-dai-usdt', 18, 'Balancer'), + ('ethereum', 0x0000206329b97db379d5e1bf586bbdb969c63274, 'Crypto-backed stablecoin', 'USDA', 18, ''), + ('ethereum', 0x35d8949372d46b7a3d5a56006ae77b215fc69bc0, 'Crypto-backed stablecoin', 'USD0++', 18, ''), + ('ethereum', 0x4591dbff62656e7859afe5e45f6f47d3669fbb28, 'Crypto-backed stablecoin', 'mkUSD', 18, ''), + ('ethereum', 0x0bffdd787c83235f6f0afa0faed42061a4619b7a, 'Crypto-backed stablecoin', 'VUSD', 6, ''), + ('ethereum', 0xcfc5bd99915aaa815401c5a41a927ab7a38d29cf, 'Crypto-backed stablecoin', 'thUSD', 18, ''), + ('ethereum', 0xdf3ac4f479375802a821f7b7b46cd7eb5e4262cc, 'Crypto-backed stablecoin', 'eUSD', 18, ''), + ('ethereum', 0xbbaec992fc2d637151daf40451f160bf85f3c8c1, 'Crypto-backed stablecoin', 'USDM', 6, ''), + ('ethereum', 0x7945b0a6674b175695e5d1d08ae1e6f13744abb0, 'Crypto-backed stablecoin', 'BaoUSD', 18, '') ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml index 2577f0e571e..52d06246f05 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_schema.yml @@ -89,7 +89,7 @@ models: meta: blockchain: ethereum sector: stablecoins - contributors: synthquest + contributors: synthquest, rantum config: tags: ['tokens', 'ethereum', 'erc20', 'stablecoins'] description: > diff --git a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_stablecoins.sql index 42837c64d4d..81f65b76823 100644 --- a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_erc20_stablecoins.sql @@ -5,7 +5,7 @@ , post_hook='{{ expose_spells(\'["optimism"]\', "sector", "tokens_optimism", - \'["msilb7", "synthquest"]\') }}' + \'["msilb7", "synthquest","rantum"]\') }}' , unique_key = ['contract_address'] ) }} @@ -43,7 +43,8 @@ FROM (VALUES ('optimism', 0x2057c8ecb70afd7bee667d76b4cd373a325b1a20, 'Bridge-backed stablecoin', 'hUSDT', 6, 'Tether USD Hop Token'), ('optimism', 0x9485aca5bbbe1667ad97c7fe7c4531a624c8b1ed, 'Crypto-backed stablecoin', 'agEUR', 18, 'agEUR'), ('optimism', 0xbfd291da8a403daaf7e5e9dc1ec0aceacd4848b9, 'Crypto-backed stablecoin', 'USX', 18, 'dForce USD'), - ('optimism', 0xba28feb4b6a6b81e3f26f08b83a19e715c4294fd, 'Algorithmic stablecoin', 'UST', 6, 'UST (Wormhole)') + ('optimism', 0xba28feb4b6a6b81e3f26f08b83a19e715c4294fd, 'Algorithmic stablecoin', 'UST', 6, 'UST (Wormhole)'), + ('optimism', 0xeb466342c4d449bc9f53a865d5cb90586f405215, 'Crypto-backed stablecoin', 'axlUSDC', 6, 'Axelar USDC') ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml index b3bb4c83c68..9a23a764e8b 100644 --- a/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/optimism/tokens_optimism_schema.yml @@ -173,7 +173,7 @@ models: meta: blockchain: optimism sector: stablecoins - contributors: synthquest + contributors: synthquest, rantum config: tags: ['tokens', 'optimism', 'erc20', 'stablecoins'] description: > diff --git a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20_stablecoins.sql index 3e705292284..c4d2d4523eb 100644 --- a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20_stablecoins.sql @@ -5,7 +5,7 @@ , post_hook='{{ expose_spells(\'["polygon"]\', "sector", "tokens_polygon", - \'["synthquest"]\') }}' + \'["synthquest","rantum"]\') }}' , unique_key = ['contract_address'] ) }} @@ -31,7 +31,8 @@ FROM (VALUES ('polygon', 0xa3fa99a148fa48d14ed51d610c367c61876997f1, 'Crypto-backed stablecoin', 'miMATIC', 18, ''), ('polygon', 0xdab529f40e671a1d4bf91361c21bf9f0c9712ab7, 'Fiat-backed stablecoin', 'BUSD', 18, ''), ('polygon', 0x3a3e7650f8b9f667da98f236010fbf44ee4b2975, 'Crypto-backed stablecoin', 'xUSD', 18, ''), - ('polygon', 0x23001f892c0c82b79303edc9b9033cd190bb21c7, 'Crypto-backed stablecoin', 'LUSD', 18, '') + ('polygon', 0x23001f892c0c82b79303edc9b9033cd190bb21c7, 'Crypto-backed stablecoin', 'LUSD', 18, ''), + ('polygon', 0x750e4c4984a9e0f12978ea6742bc1c5d248f40ed, 'Crypto-backed stablecoin', 'axlUSDC', 6, '') ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_schema.yml b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_schema.yml index 69aa6724c74..f19ec34af9a 100644 --- a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_schema.yml @@ -86,7 +86,7 @@ models: meta: blockchain: polygon sector: stablecoins - contributors: synthquest + contributors: synthquest, rantum config: tags: ['tokens', 'polygon', 'erc20', 'stablecoins'] description: > From 41cf356db46d692a07f469a815a2d076b0c8d968 Mon Sep 17 00:00:00 2001 From: Rantum Date: Tue, 24 Sep 2024 10:31:25 -0700 Subject: [PATCH 086/127] add stablecoins (blast, mantle, linea, scroll) (#6810) * add stablecoins on linea, scroll, blast, mantle * update backing * add to cross chain spell * blast * re-add blast * remove dai dup --- .../tokens/models/tokens/_schema.yml | 6 ++-- .../blast/tokens_blast_erc20_stablecoins.sql | 28 +++++++++++++++++++ .../tokens/blast/tokens_blast_schema.yml | 25 ++++++++++++++++- .../linea/tokens_linea_erc20_stablecoins.sql | 27 ++++++++++++++++++ .../tokens/linea/tokens_linea_schema.yml | 23 +++++++++++++++ .../tokens_mantle_erc20_stablecoins.sql | 20 +++++++++++++ .../tokens/mantle/tokens_mantle_schema.yml | 25 ++++++++++++++++- .../tokens_scroll_erc20_stablecoins.sql | 21 ++++++++++++++ .../tokens/scroll/tokens_scroll_schema.yml | 23 +++++++++++++++ .../tokens/tokens_erc20_stablecoins.sql | 8 ++++-- 10 files changed, 199 insertions(+), 7 deletions(-) create mode 100644 dbt_subprojects/tokens/models/tokens/blast/tokens_blast_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/linea/tokens_linea_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/mantle/tokens_mantle_erc20_stablecoins.sql create mode 100644 dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_erc20_stablecoins.sql diff --git a/dbt_subprojects/tokens/models/tokens/_schema.yml b/dbt_subprojects/tokens/models/tokens/_schema.yml index f1c1236c36a..d382c8644f7 100644 --- a/dbt_subprojects/tokens/models/tokens/_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/_schema.yml @@ -66,11 +66,11 @@ models: - name: tokens_erc20_stablecoins meta: - blockchain: arbitrum, avalanche_c, bnb, ethereum, fantom, gnosis, optimism, polygon, base + blockchain: arbitrum, avalanche_c, bnb, ethereum, fantom, gnosis, optimism, polygon, base, blast, linea, mantle, scroll sector: tokens - contributors: hildobby, synthquest + contributors: hildobby, synthquest, rantum config: - tags: ['tokens','stablecoin', 'arbitrum','avalanche_c','bnb','ethereum','fantom','gnosis','optimism','polygon','base'] + tags: ['tokens','stablecoin', 'arbitrum','avalanche_c','bnb','ethereum','fantom','gnosis','optimism','polygon','base', 'blast', 'liena', 'mantle', 'scroll'] description: > Stablecoin (ERC20) tokens tests: diff --git a/dbt_subprojects/tokens/models/tokens/blast/tokens_blast_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/blast/tokens_blast_erc20_stablecoins.sql new file mode 100644 index 00000000000..1f9dcc28ef4 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/blast/tokens_blast_erc20_stablecoins.sql @@ -0,0 +1,28 @@ +{{ config( + schema = 'tokens_blast' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["blast"]\', + "sector", + "tokens_blast", + \'["rantum"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + ('blast', 0x4300000000000000000000000000000000000003, 'Hybrid stablecoin', 'USDB', 6, ''), + ('blast', 0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34, 'Crypto-backed stablecoin', 'USDe', 18, ''), + ('blast', 0xeb466342c4d449bc9f53a865d5cb90586f405215, 'Crypto-backed stablecoin', 'axlUSDC', 6, ''), + ('blast', 0x211cc4dd073734da055fbf44a2b4667d5e5fe5d2, 'Crypto-backed stablecoin', 'sUSDe', 18, ''), + ('blast', 0x52056ed29fe015f4ba2e3b079d10c0b87f46e8c6, 'Fiat-backed stablecoin', 'USDz', 18, ''), + ('blast', 0x9d889e2d7ff49ece580e5354ce934ccd1d6e78dc, 'Crypto-backed stablecoin', 'expUSD', 18, ''), + ('blast', 0x1a3d9b2fa5c6522c8c071dc07125ce55df90b253, 'Fiat-backed stablecoin', 'DUSD', 18, ''), + ('blast', 0xc608dfb90a430df79a8a1edbc8be7f1a0eb4e763, 'Crypto-backed stablecoin', 'arUSD', 18, ''), + ('blast', 0x836aed3b0e0ee44c77e0b6db34d170abcce9baac, 'Fiat-backed stablecoin', 'USDBx', 18, ''), + ('blast', 0x578122317baca7a3c7bb5301460d2f4f96e9394a, 'Crypto-backed stablecoinn', 'DUSD', 18, ''), + ('blast', 0x837fe561e9c5dfa73f607fda679295dbc2be5e40, 'Crypto-backed stablecoin', 'MUSD', 18, '') + + + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/blast/tokens_blast_schema.yml b/dbt_subprojects/tokens/models/tokens/blast/tokens_blast_schema.yml index b2e34b596c1..3363cbebe19 100644 --- a/dbt_subprojects/tokens/models/tokens/blast/tokens_blast_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/blast/tokens_blast_schema.yml @@ -18,4 +18,27 @@ models: - name: symbol description: "ERC20 token symbol" - name: decimals - description: "Number of decimals, refers to how divisible an ERC20 token can be" \ No newline at end of file + description: "Number of decimals, refers to how divisible an ERC20 token can be" + + - name: tokens_blast_erc20_stablecoins + meta: + blockchain: blast + sector: stablecoins + contributors: rantum + config: + tags: ['tokens', 'blast', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_erc20_stablecoins.sql new file mode 100644 index 00000000000..9ee2c37178d --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_erc20_stablecoins.sql @@ -0,0 +1,27 @@ +{{ config( + schema = 'tokens_linea' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["linea"]\', + "sector", + "tokens_linea", + \'["rantum"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + ('linea', 0xa219439258ca9da29e9cc4ce5596924745e12b93, 'Fiat-backed stablecoin', 'USDT', 6, ''), + ('linea', 0x176211869ca2b568f2a7d4ee941e073a821ee1ff, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('linea', 0x4af15ec2a0bd43db75dd04e62faa3b8ef36b00d5, 'Hybrid stablecoin', 'DAI', 18, ''), + ('linea', 0xeb466342c4d449bc9f53a865d5cb90586f405215, 'Fiat-backed stablecoin', 'axlUSDC', 6, ''), + ('linea', 0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34, 'Crypto-backed stablecoin', 'USDe', 18, ''), + ('linea', 0x7d43aabc515c356145049227cee54b608342c0ad, 'Fiat-backed stablecoin', 'BUSD', 18, ''), + ('linea', 0xba2f9e7ae9f5f03fce7d560f986743659e768bbf, 'Fiat-backed stablecoin', 'eUSD', 18, ''), + ('linea', 0xc608dfb90a430df79a8a1edbc8be7f1a0eb4e763, 'Fiat-backed stablecoin', 'arUSD', 18, ''), + ('linea', 0xa88b54e6b76fb97cdb8ecae868f1458e18a953f4, 'Fiat-backed stablecoin', 'DUSD', 18, ''), + ('linea', 0x894134a25a5fac1c2c26f1d8fbf05111a3cb9487, 'Fiat-backed stablecoin', 'GRAI', 18, ''), + ('linea', 0xb79dd08ea68a908a97220c76d19a6aa9cbde4376, 'Crypto-backed stablecoin', 'USD+', 18, ''), + ('linea', 0x1e1f509963a6d33e169d9497b11c7dbfe73b7f13, 'Crypto-backed stablecoin', 'USDT+', 18, '') + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_schema.yml b/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_schema.yml index d2fb3fd6976..4f1659e727d 100644 --- a/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/linea/tokens_linea_schema.yml @@ -19,3 +19,26 @@ models: description: "ERC20 token symbol" - name: decimals description: "Number of decimals, refers to how divisible an ERC20 token can be" + + - name: tokens_linea_erc20_stablecoins + meta: + blockchain: linea + sector: stablecoins + contributors: rantum + config: + tags: ['tokens', 'linea', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" diff --git a/dbt_subprojects/tokens/models/tokens/mantle/tokens_mantle_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/mantle/tokens_mantle_erc20_stablecoins.sql new file mode 100644 index 00000000000..ec329f3f930 --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/mantle/tokens_mantle_erc20_stablecoins.sql @@ -0,0 +1,20 @@ +{{ config( + schema = 'tokens_mantle' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["mantle"]\', + "sector", + "tokens_mantle", + \'["rantum"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + ('mantle', 0x201eba5cc46d216ce6dc03f6a759e8e766e956ae, 'Fiat-backed stablecoin', 'USDT', 6, ''), + ('mantle', 0x09bc4e0d864854c6afb6eb9a9cdf58ac190d0df9, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('mantle', 0x5be26527e817998a7206475496fde1e68957c5a6, 'Fiat-backed stablecoin', 'USDY', 18, ''), + ('mantle', 0xeb466342c4d449bc9f53a865d5cb90586f405215, 'Crypto-backed stablecoin', 'axlUSDC', 6, ''), + ('mantle', 0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34, 'Crypto-backed stablecoin', 'USDe', 18, '') + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/mantle/tokens_mantle_schema.yml b/dbt_subprojects/tokens/models/tokens/mantle/tokens_mantle_schema.yml index e278f6121aa..6e9631ec3d6 100644 --- a/dbt_subprojects/tokens/models/tokens/mantle/tokens_mantle_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/mantle/tokens_mantle_schema.yml @@ -18,4 +18,27 @@ models: - name: symbol description: "ERC20 token symbol" - name: decimals - description: "Number of decimals, refers to how divisible an ERC20 token can be" \ No newline at end of file + description: "Number of decimals, refers to how divisible an ERC20 token can be" + + - name: tokens_mantle_erc20_stablecoins + meta: + blockchain: mantle + sector: stablecoins + contributors: rantum + config: + tags: ['tokens', 'mantle', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_erc20_stablecoins.sql new file mode 100644 index 00000000000..34211e2092f --- /dev/null +++ b/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_erc20_stablecoins.sql @@ -0,0 +1,21 @@ +{{ config( + schema = 'tokens_scroll' + , alias = 'erc20_stablecoins' + , tags=['static'] + , post_hook='{{ expose_spells(\'["scroll"]\', + "sector", + "tokens_scroll", + \'["rantum"]\') }}' + , unique_key = ['contract_address'] + ) +}} + +SELECT blockchain, contract_address, backing, symbol, decimals, name +FROM (VALUES + ('scroll', 0xf55bec9cafdbe8730f096aa55dad6d22d44099df, 'Fiat-backed stablecoin', 'USDT', 6, ''), + ('scroll', 0x06efdbff2a14a7c8e15944d1f4a48f9f95f663a4, 'Fiat-backed stablecoin', 'USDC', 6, ''), + ('scroll', 0xca77eb3fefe3725dc33bccb54edefc3d9f764f97, 'Hybrid stablecoin', 'DAI', 18, ''), + ('scroll', 0x5d3a1ff2b6bab83b63cd9ad0787074081a52ef34, 'Crypto-backed stablecoin', 'USDe', 18, ''), + ('scroll', 0x77fbf86399ed764a084f77b9accb049f3dbc32d2, 'Crypto-backed stablecoin', 'loreUSD', 18, ''), + ('scroll', 0xedeabc3a1e7d21fe835ffa6f83a710c70bb1a051, 'Crypto-backed stablecoin', 'LUSD', 18, '') + ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) diff --git a/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_schema.yml b/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_schema.yml index 72eef1c075c..ada743c5a98 100644 --- a/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_schema.yml +++ b/dbt_subprojects/tokens/models/tokens/scroll/tokens_scroll_schema.yml @@ -19,3 +19,26 @@ models: description: "ERC20 token symbol" - name: decimals description: "Number of decimals, refers to how divisible an ERC20 token can be" + + - name: tokens_scroll_erc20_stablecoins + meta: + blockchain: scroll + sector: stablecoins + contributors: rantum + config: + tags: ['tokens', 'scroll', 'erc20', 'stablecoins'] + description: > + Selection of stablecoin token addresses. + columns: + - name: blockchain + description: "Blockchain name" + - name: contract_address + description: "Stablecoin contract address" + - name: backing + description: "Stablecoin backing" + - name: symbol + description: "Stablecoin symbol" + - name: name + description: "Stablecoin project name" + - name: decimals + description: "Number of decimals" diff --git a/dbt_subprojects/tokens/models/tokens/tokens_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/tokens_erc20_stablecoins.sql index a51741e0877..83d32e2c3c0 100644 --- a/dbt_subprojects/tokens/models/tokens/tokens_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/tokens_erc20_stablecoins.sql @@ -3,10 +3,10 @@ alias = 'erc20_stablecoins', materialized='table', tags = ['static'], - post_hook = '{{ expose_spells(\'["ethereum", "arbitrum", "gnosis", "optimism", "bnb", "avalanche_c", "polygon", "fantom", "base"]\', + post_hook = '{{ expose_spells(\'["ethereum", "arbitrum", "gnosis", "optimism", "bnb", "avalanche_c", "polygon", "fantom", "base", "mantle", "scroll", "blast", "linea"]\', "sector", "stablecoins", - \'["synthquest"]\') }}' + \'["synthquest","rantum"]\') }}' ) }} @@ -20,6 +20,10 @@ , ref('tokens_optimism_erc20_stablecoins') , ref('tokens_polygon_erc20_stablecoins') , ref('tokens_base_erc20_stablecoins') +, ref('tokens_blast_erc20_stablecoins') +, ref('tokens_mantle_erc20_stablecoins') +, ref('tokens_scroll_erc20_stablecoins') +, ref('tokens_linea_erc20_stablecoins') ] %} From 1b46dc499daf0d61167177ac178e727f1b97da3f Mon Sep 17 00:00:00 2001 From: synthquest <112836792+Synthquest@users.noreply.github.com> Date: Tue, 24 Sep 2024 13:35:33 -0400 Subject: [PATCH 087/127] Daily Arbitrum Stablecoin Balances (#6757) * initialize arbitrum stablecoin balances * update naming * move to daily spellbook * USDC test * limit start date * open time limit * update sources test * open time limit --------- Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../stablecoins_arbitrum_balances.sql | 38 +++++ .../arbitrum/stablecoins_arbitrum_schema.yml | 62 ++++++++ .../_subprojects_outputs/tokens/_sources.yml | 143 +++++++++++++++++- 3 files changed, 241 insertions(+), 2 deletions(-) create mode 100644 dbt_subprojects/daily_spellbook/models/_sector/stablecoins/arbitrum/stablecoins_arbitrum_balances.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_sector/stablecoins/arbitrum/stablecoins_arbitrum_schema.yml diff --git a/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/arbitrum/stablecoins_arbitrum_balances.sql b/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/arbitrum/stablecoins_arbitrum_balances.sql new file mode 100644 index 00000000000..547dfe30a39 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/arbitrum/stablecoins_arbitrum_balances.sql @@ -0,0 +1,38 @@ +{{ + config( + schema = 'stablecoins_arbitrum', + alias = 'balances', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['day', 'address', 'token_address', 'blockchain'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.day')] + ) +}} + +with +stablecoin_tokens as ( + select + symbol, + contract_address as token_address + from + {{ source('tokens_arbitrum', 'erc20_stablecoins')}} +) + +,balances as ( + {{ + balances_incremental_subset_daily( + blockchain = 'arbitrum', + token_list = 'stablecoin_tokens', + start_date = '2021-05-26' + ) + }} +) + +select + t.symbol + ,b.* +from balances b +left join stablecoin_tokens t + on b.token_address = t.token_address + \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/arbitrum/stablecoins_arbitrum_schema.yml b/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/arbitrum/stablecoins_arbitrum_schema.yml new file mode 100644 index 00000000000..d86af2b6fde --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_sector/stablecoins/arbitrum/stablecoins_arbitrum_schema.yml @@ -0,0 +1,62 @@ +version: 2 + +models: + - name: stablecoins_arbitrum_balances + + meta: + blockchain: arbitrum + sector: stablecoin + project: stablecoin + contributors: synthquest + + config: + tags: ['stablecoin', 'balances'] + description: "Balances of stablecoin token holders" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - day + - address + - token_address + columns: + - &blockchain + name: blockchain + description: "Blockchain for the token" + - &symbol + name: symbol + description: "Symbol for the token" + - &version + name: version + description: "Version of the token" + - &day + name: day + description: "Date on which the token balance is logged" + - &address + name: address + description: "Address for the token holder" + - &token_symbol + name: token_symbol + description: "Symbol for the token" + - &token_address + name: token_address + description: "Address for the token" + - &token_standard + name: token_standard + description: "Standard for the token" + - &token_id + name: token_id + description: "ID for the token" + - &balance + name: balance + description: "Balance for the user" + - &balance_usd + name: balance_usd + description: "USD value of balance for the user" + - &last_updated + name: last_updated + description: "UTC timestamp when data was last updated" + - &next_update + name: next_update + description: "UTC timestamp when data is next updated" + + \ No newline at end of file diff --git a/sources/_subprojects_outputs/tokens/_sources.yml b/sources/_subprojects_outputs/tokens/_sources.yml index d965c7cba6c..dfdcf010e6a 100644 --- a/sources/_subprojects_outputs/tokens/_sources.yml +++ b/sources/_subprojects_outputs/tokens/_sources.yml @@ -107,6 +107,20 @@ sources: description: "NFT collection symbol" - name: standard description: "NFT collection standard" + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_arbitrum @@ -120,6 +134,20 @@ sources: - name: decimals data_type: integer - name: nft + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_avalanche_c tables: @@ -132,6 +160,20 @@ sources: - name: decimals data_type: integer - name: nft + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_base @@ -145,6 +187,20 @@ sources: - name: decimals data_type: integer - name: nft + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_bnb tables: @@ -157,6 +213,20 @@ sources: - name: decimals data_type: integer - name: nft + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_celo tables: @@ -182,13 +252,26 @@ sources: data_type: integer - name: nft - name: stablecoins - - name: rebase columns: - name: contract_address data_type: varbinary - name: symbol data_type: varchar + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_fantom @@ -202,6 +285,20 @@ sources: - name: decimals data_type: integer - name: nft + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_goerli tables: @@ -226,6 +323,20 @@ sources: - name: decimals data_type: integer - name: nft + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_optimism @@ -290,6 +401,20 @@ sources: data_type: timestamp(3) with time zone - name: nft - name: nft_bridged_mapping + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_polygon @@ -303,6 +428,20 @@ sources: - name: decimals data_type: integer - name: nft + - name: erc20_stablecoins + columns: + - name: blockchain + data_type: varchar + - name: contract_address + data_type: varbinary + - name: backing + data_type: varchar + - name: symbol + data_type: varchar + - name: decimals + data_type: integer + - name: name + data_type: varchar - name: tokens_zksync @@ -355,4 +494,4 @@ sources: - name: prices_native tables: - - name: tokens + - name: tokens \ No newline at end of file From 856941ffc3e7fc6513e3109e4153d7e8bb7ae5a9 Mon Sep 17 00:00:00 2001 From: AIDataMaster Date: Tue, 24 Sep 2024 20:39:33 +0300 Subject: [PATCH 088/127] New Event Models for GMX Project (#6808) * Added OrderFrozen Event Model * Fix error in tests on uniqueness * Added Order Updated Event Model * Update markets_data event model * Run tests again --- .../arbitrum/gmx_v2_arbitrum_event_schema.yml | 127 +++++++++-- .../gmx_v2_arbitrum_order_created.sql | 2 +- .../arbitrum/gmx_v2_arbitrum_order_frozen.sql | 178 +++++++++++++++ .../gmx_v2_arbitrum_order_updated.sql | 204 ++++++++++++++++++ .../gmx_v2_avalanche_c_event_schema.yml | 129 +++++++++-- .../gmx_v2_avalanche_c_order_created.sql | 2 +- .../gmx_v2_avalanche_c_order_frozen.sql | 178 +++++++++++++++ .../gmx_v2_avalanche_c_order_updated.sql | 204 ++++++++++++++++++ .../gmx/event/gmx_v2_event_schema.yml | 129 +++++++++-- .../gmx/event/gmx_v2_order_created.sql | 2 +- .../gmx/event/gmx_v2_order_frozen.sql | 37 ++++ .../gmx/event/gmx_v2_order_updated.sql | 41 ++++ .../arbitrum/gmx_v2_arbitrum_markets_data.sql | 6 +- .../gmx_v2_avalanche_c_markets_data.sql | 6 +- .../daily_spellbook/package-lock.yml | 4 +- 15 files changed, 1186 insertions(+), 63 deletions(-) create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_frozen.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_frozen.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_frozen.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml index 73b2bedf455..d4cbca2f796 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml @@ -126,11 +126,13 @@ models: description: The change in initial collateral amount. tests: - not_null - - name: trigger_price + - &trigger_price + name: trigger_price description: The price that triggers the order execution. tests: - - not_null - - name: acceptable_price + - not_null + - &acceptable_price + name: acceptable_price description: The minimum acceptable price for order execution. tests: - not_null @@ -142,15 +144,17 @@ models: description: The gas limit set for callback functions. tests: - not_null - - name: min_output_amount + - &min_output_amount_raw + name: min_output_amount_raw description: The minimum amount of output tokens expected from the order, based on the markets in the swap path. tests: - not_null - name: updated_at_block description: The block number at which the order was last updated. tests: - - not_null - - name: updated_at_time + - not_null + - &updated_at_time + name: updated_at_time description: The timestamp when the order was last updated. - &is_long name: is_long @@ -161,7 +165,8 @@ models: description: Boolean indicating if the native token should be unwrapped. - name: is_frozen description: Boolean indicating if the order is frozen. - - name: key + - &key + name: key description: The unique identifier for the order, stored as a bytes32 value. tests: - not_null @@ -196,11 +201,7 @@ models: tests: - not_null - *msg_sender - - name: key - description: The key associated with the executed order. Extracted as a bytes32 value. - tests: - - not_null - - unique + - *key - name: account description: The address associated with the order - name: secondary_order_type @@ -243,11 +244,7 @@ models: tests: - not_null - *msg_sender - - name: key - description: The key associated with the cancelled order. Extracted as a bytes32 value - tests: - - not_null - - unique + - *key - name: account description: The address associated with the order - name: reason_bytes @@ -818,4 +815,98 @@ models: - *is_increase - *order_key - *position_key - - *referral_code \ No newline at end of file + - *referral_code + + + - name: gmx_v2_arbitrum_order_frozen + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'order_frozen'] + description: | + Extracts and decodes the `OrderFrozen` event log data from the Arbitrum blockchain. + This model processes log entries related to frozen orders, extracting key variables such as + account addresses, event keys, and strings representing the reason for the order being frozen. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - key + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - *tx_from + - *tx_to + - name: event_name + description: The type of event recorded, always 'OrderFrozen' for this model + tests: + - not_null + - *msg_sender + - name: key + description: The key associated with the frozen order. Extracted as a bytes32 value + tests: + - not_null + - name: account + description: The address associated with the order + - name: reason_bytes + description: The reason for the order being frozen in byte format. + tests: + - not_null + - name: reason + description: The reason for the order being frozen in string format. + tests: + - not_null + + + - name: gmx_v2_arbitrum_order_updated + meta: + blockchain: arbitrum + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'gmx', 'event', 'order_updated'] + description: | + Extracts and decodes the `OrderUpdated` event log data from the Arbitrum blockchain. + This model processes log entries related to updated orders, extracting key variables such as + account addresses, event keys, and strings representing the reason for cancellation. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - *tx_from + - *tx_to + - name: event_name + description: The type of event recorded, always 'OrderUpdated' for this model. + tests: + - not_null + - *msg_sender + - name: key + description: The key associated with the updated order. Extracted as a bytes32 value + tests: + - not_null + - name: market + description: The market in which the order was updated. + tests: + - not_null + - name: account + description: The address associated with the order. + - *size_delta_usd + - *trigger_price + - *acceptable_price + - *min_output_amount_raw + - *updated_at_time \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql index 97aa0cdc6aa..632bfaee161 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql @@ -275,7 +275,7 @@ WITH evt_data_1 AS ( END AS acceptable_price, execution_fee / POWER(10, 18) AS execution_fee, callback_gas_limit, - min_output_amount AS min_output_amount, + min_output_amount AS min_output_amount_raw, updated_at_block, CASE diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_frozen.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_frozen.sql new file mode 100644 index 00000000000..b0cc9d09f62 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_frozen.sql @@ -0,0 +1,178 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'order_frozen', + materialized = 'table' + ) +}} + +{%- set event_name = 'OrderFrozen' -%} +{%- set blockchain_name = 'arbitrum' -%} + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + ORDER BY evt_block_time ASC +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + ORDER BY evt_block_time ASC +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + + FROM + evt_data +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'key' THEN value END) AS key, + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(key) AS key, + from_hex(account) AS account, + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql new file mode 100644 index 00000000000..85af3142f28 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql @@ -0,0 +1,204 @@ +{{ + config( + schema = 'gmx_v2_arbitrum', + alias = 'order_updated', + materialized = 'table' + ) +}} + +{%- set event_name = 'OrderUpdated' -%} +{%- set blockchain_name = 'arbitrum' -%} + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + ORDER BY evt_block_time ASC +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_arbitrum','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + ORDER BY evt_block_time ASC +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION DISTINCT + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'key' THEN value END) AS key, + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'sizeDeltaUsd' THEN value END) AS size_delta_usd, + MAX(CASE WHEN key_name = 'acceptablePrice' THEN value END) AS acceptable_price, + MAX(CASE WHEN key_name = 'triggerPrice' THEN value END) AS trigger_price, + MAX(CASE WHEN key_name = 'minOutputAmount' THEN value END) AS min_output_amount, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(key) AS key, + from_hex(account) AS account, + TRY_CAST(size_delta_usd AS DOUBLE) AS size_delta_usd, + TRY_CAST(acceptable_price AS DOUBLE) AS acceptable_price, + TRY_CAST(trigger_price AS DOUBLE) AS trigger_price, + TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +-- full data +, full_data AS ( + SELECT + ED.blockchain, + ED.block_time, + DATE(ED.block_time) AS block_date, + ED.block_number, + ED.tx_hash, + ED.index, + ED.contract_address, + ED.event_name, + ED.msg_sender, + + ED.key, + OC.market, + ED.account, + ED.size_delta_usd / POWER(10, 30) AS size_delta_usd, + CASE + WHEN MD.index_token_decimals IS NULL THEN ED.acceptable_price / POWER(10, 30) + ELSE ED.acceptable_price / POWER(10, 30 - MD.index_token_decimals) + END AS acceptable_price, + CASE + WHEN MD.index_token_decimals IS NULL THEN ED.trigger_price / POWER(10, 30) + ELSE ED.trigger_price / POWER(10, 30 - MD.index_token_decimals) + END AS trigger_price, + ED.min_output_amount AS min_output_amount_raw, + CASE + WHEN ED.updated_at_time = 0 THEN NULL + ELSE ED.updated_at_time + END AS updated_at_time + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_arbitrum_order_created') }} AS OC + ON ED.key = OC.key + LEFT JOIN {{ ref('gmx_v2_arbitrum_markets_data') }} AS MD + ON OC.market = MD.market + +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml index 1ad13d266cc..e2845ea5e81 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml @@ -126,11 +126,13 @@ models: description: The change in initial collateral amount. tests: - not_null - - name: trigger_price + - &trigger_price + name: trigger_price description: The price that triggers the order execution. tests: - - not_null - - name: acceptable_price + - not_null + - &acceptable_price + name: acceptable_price description: The minimum acceptable price for order execution. tests: - not_null @@ -141,16 +143,18 @@ models: - name: callback_gas_limit description: The gas limit set for callback functions. tests: - - not_null - - name: min_output_amount + - not_null + - &min_output_amount_raw + name: min_output_amount_raw description: The minimum amount of output tokens expected from the order, based on the markets in the swap path. tests: - not_null - name: updated_at_block description: The block number at which the order was last updated. tests: - - not_null - - name: updated_at_time + - not_null + - &updated_at_time + name: updated_at_time description: The timestamp when the order was last updated. - &is_long name: is_long @@ -161,7 +165,8 @@ models: description: Boolean indicating if the native token should be unwrapped. - name: is_frozen description: Boolean indicating if the order is frozen. - - name: key + - &key + name: key description: The unique identifier for the order, stored as a bytes32 value. tests: - not_null @@ -196,11 +201,7 @@ models: tests: - not_null - *msg_sender - - name: key - description: The key associated with the executed order. Extracted as a bytes32 value. - tests: - - not_null - - unique + - *key - name: account description: The address associated with the order - name: secondary_order_type @@ -243,11 +244,7 @@ models: tests: - not_null - *msg_sender - - name: key - description: The key associated with the cancelled order. Extracted as a bytes32 value - tests: - - not_null - - unique + - *key - name: account description: The address associated with the order - name: reason_bytes @@ -818,4 +815,98 @@ models: - *is_increase - *order_key - *position_key - - *referral_code \ No newline at end of file + - *referral_code + + + - name: gmx_v2_avalanche_c_order_frozen + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'order_frozen'] + description: | + Extracts and decodes the `OrderFrozen` event log data from the Avalanche blockchain. + This model processes log entries related to frozen orders, extracting key variables such as + account addresses, event keys, and strings representing the reason for the order being frozen. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - key + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - *tx_from + - *tx_to + - name: event_name + description: The type of event recorded, always 'OrderFrozen' for this model + tests: + - not_null + - *msg_sender + - name: key + description: The key associated with the frozen order. Extracted as a bytes32 value + tests: + - not_null + - name: account + description: The address associated with the order + - name: reason_bytes + description: The reason for the order being frozen in byte format. + tests: + - not_null + - name: reason + description: The reason for the order being frozen in string format. + tests: + - not_null + + + - name: gmx_v2_avalanche_c_order_updated + meta: + blockchain: avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['avalanche_c', 'gmx', 'event', 'order_updated'] + description: | + Extracts and decodes the `OrderUpdated` event log data from the Avalanche blockchain. + This model processes log entries related to updated orders, extracting key variables such as + account addresses, event keys, and strings representing the reason for cancellation. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - *tx_from + - *tx_to + - name: event_name + description: The type of event recorded, always 'OrderUpdated' for this model. + tests: + - not_null + - *msg_sender + - name: key + description: The key associated with the updated order. Extracted as a bytes32 value + tests: + - not_null + - name: market + description: The market in which the order was updated. + tests: + - not_null + - name: account + description: The address associated with the order. + - *size_delta_usd + - *trigger_price + - *acceptable_price + - *min_output_amount_raw + - *updated_at_time \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql index 79bf89a1d44..5e04a171406 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql @@ -275,7 +275,7 @@ WITH evt_data_1 AS ( END AS acceptable_price, execution_fee / POWER(10, 18) AS execution_fee, callback_gas_limit, - min_output_amount AS min_output_amount, + min_output_amount AS min_output_amount_raw, updated_at_block, CASE diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_frozen.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_frozen.sql new file mode 100644 index 00000000000..0de9538f4a7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_frozen.sql @@ -0,0 +1,178 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'order_frozen', + materialized = 'table' + ) +}} + +{%- set event_name = 'OrderFrozen' -%} +{%- set blockchain_name = 'avalanche_c' -%} + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + ORDER BY evt_block_time ASC +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + ORDER BY evt_block_time ASC +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.bytesItems' OMIT QUOTES) AS bytes_items, + json_query(data, 'lax $.stringItems' OMIT QUOTES) AS string_items + + FROM + evt_data +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, bytes_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, string_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(string_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM bytes_items_parsed + UNION ALL + SELECT * + FROM string_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'key' THEN value END) AS key, + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'reasonBytes' THEN value END) AS reason_bytes, + MAX(CASE WHEN key_name = 'reason' THEN value END) AS reason + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, full_data AS ( + SELECT + blockchain, + block_time, + DATE(block_time) AS block_date, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(key) AS key, + from_hex(account) AS account, + from_hex(reason_bytes) AS reason_bytes, + reason + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql new file mode 100644 index 00000000000..1515489060d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql @@ -0,0 +1,204 @@ +{{ + config( + schema = 'gmx_v2_avalanche_c', + alias = 'order_updated', + materialized = 'table' + ) +}} + +{%- set event_name = 'OrderUpdated' -%} +{%- set blockchain_name = 'avalanche_c' -%} + +WITH evt_data_1 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog1')}} + WHERE eventName = '{{ event_name }}' + ORDER BY evt_block_time ASC +) + +, evt_data_2 AS ( + SELECT + -- Main Variables + '{{ blockchain_name }}' AS blockchain, + evt_block_time AS block_time, + evt_block_number AS block_number, + evt_tx_hash AS tx_hash, + evt_index AS index, + contract_address, + eventName AS event_name, + eventData AS data, + msgSender AS msg_sender + FROM {{ source('gmx_v2_avalanche_c','EventEmitter_evt_EventLog2')}} + WHERE eventName = '{{ event_name }}' + ORDER BY evt_block_time ASC +) + +-- unite 2 tables +, evt_data AS ( + SELECT * + FROM evt_data_1 + UNION DISTINCT + SELECT * + FROM evt_data_2 +) + +, parsed_data AS ( + SELECT + tx_hash, + index, + json_query(data, 'lax $.bytes32Items' OMIT QUOTES) AS bytes32_items, + json_query(data, 'lax $.addressItems' OMIT QUOTES) AS address_items, + json_query(data, 'lax $.uintItems' OMIT QUOTES) AS uint_items + FROM + evt_data +) + +, bytes32_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(bytes32_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, address_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(address_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, uint_items_parsed AS ( + SELECT + tx_hash, + index, + json_extract_scalar(CAST(item AS VARCHAR), '$.key') AS key_name, + json_extract_scalar(CAST(item AS VARCHAR), '$.value') AS value + FROM + parsed_data, + UNNEST( + CAST(json_extract(uint_items, '$.items') AS ARRAY(JSON)) + ) AS t(item) +) + +, combined AS ( + SELECT * + FROM bytes32_items_parsed + UNION ALL + SELECT * + FROM address_items_parsed + UNION ALL + SELECT * + FROM uint_items_parsed +) + +, evt_data_parsed AS ( + SELECT + tx_hash, + index, + MAX(CASE WHEN key_name = 'key' THEN value END) AS key, + MAX(CASE WHEN key_name = 'account' THEN value END) AS account, + MAX(CASE WHEN key_name = 'sizeDeltaUsd' THEN value END) AS size_delta_usd, + MAX(CASE WHEN key_name = 'acceptablePrice' THEN value END) AS acceptable_price, + MAX(CASE WHEN key_name = 'triggerPrice' THEN value END) AS trigger_price, + MAX(CASE WHEN key_name = 'minOutputAmount' THEN value END) AS min_output_amount, + MAX(CASE WHEN key_name = 'updatedAtTime' THEN value END) AS updated_at_time + FROM + combined + GROUP BY tx_hash, index +) + +-- full data +, event_data AS ( + SELECT + blockchain, + block_time, + block_number, + ED.tx_hash, + ED.index, + contract_address, + event_name, + msg_sender, + + from_hex(key) AS key, + from_hex(account) AS account, + TRY_CAST(size_delta_usd AS DOUBLE) AS size_delta_usd, + TRY_CAST(acceptable_price AS DOUBLE) AS acceptable_price, + TRY_CAST(trigger_price AS DOUBLE) AS trigger_price, + TRY_CAST(min_output_amount AS DOUBLE) AS min_output_amount, + TRY_CAST(updated_at_time AS DOUBLE) AS updated_at_time + + FROM evt_data AS ED + LEFT JOIN evt_data_parsed AS EDP + ON ED.tx_hash = EDP.tx_hash + AND ED.index = EDP.index +) + +-- full data +, full_data AS ( + SELECT + ED.blockchain, + ED.block_time, + DATE(ED.block_time) AS block_date, + ED.block_number, + ED.tx_hash, + ED.index, + ED.contract_address, + ED.event_name, + ED.msg_sender, + + ED.key, + OC.market, + ED.account, + ED.size_delta_usd / POWER(10, 30) AS size_delta_usd, + CASE + WHEN MD.index_token_decimals IS NULL THEN ED.acceptable_price / POWER(10, 30) + ELSE ED.acceptable_price / POWER(10, 30 - MD.index_token_decimals) + END AS acceptable_price, + CASE + WHEN MD.index_token_decimals IS NULL THEN ED.trigger_price / POWER(10, 30) + ELSE ED.trigger_price / POWER(10, 30 - MD.index_token_decimals) + END AS trigger_price, + ED.min_output_amount AS min_output_amount_raw, + CASE + WHEN ED.updated_at_time = 0 THEN NULL + ELSE ED.updated_at_time + END AS updated_at_time + + FROM event_data AS ED + LEFT JOIN {{ ref('gmx_v2_avalanche_c_order_created') }} AS OC + ON ED.key = OC.key + LEFT JOIN {{ ref('gmx_v2_avalanche_c_markets_data') }} AS MD + ON OC.market = MD.market + +) + +--can be removed once decoded tables are fully denormalized +{{ + add_tx_columns( + model_cte = 'full_data' + , blockchain = blockchain_name + , columns = ['from', 'to'] + ) +}} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml index e39685590bc..ebc5d3b69fb 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml @@ -126,11 +126,13 @@ models: description: The change in initial collateral amount. tests: - not_null - - name: trigger_price + - &trigger_price + name: trigger_price description: The price that triggers the order execution. tests: - - not_null - - name: acceptable_price + - not_null + - &acceptable_price + name: acceptable_price description: The minimum acceptable price for order execution. tests: - not_null @@ -141,16 +143,18 @@ models: - name: callback_gas_limit description: The gas limit set for callback functions. tests: - - not_null - - name: min_output_amount + - not_null + - &min_output_amount_raw + name: min_output_amount_raw description: The minimum amount of output tokens expected from the order, based on the markets in the swap path. tests: - not_null - name: updated_at_block description: The block number at which the order was last updated. tests: - - not_null - - name: updated_at_time + - not_null + - &updated_at_time + name: updated_at_time description: The timestamp when the order was last updated. - &is_long name: is_long @@ -161,7 +165,8 @@ models: description: Boolean indicating if the native token should be unwrapped. - name: is_frozen description: Boolean indicating if the order is frozen. - - name: key + - &key + name: key description: The unique identifier for the order, stored as a bytes32 value. tests: - not_null @@ -196,11 +201,7 @@ models: tests: - not_null - *msg_sender - - name: key - description: The key associated with the executed order. Extracted as a bytes32 value. - tests: - - not_null - - unique + - *key - name: account description: The address associated with the order - name: secondary_order_type @@ -243,11 +244,7 @@ models: tests: - not_null - *msg_sender - - name: key - description: The key associated with the cancelled order. Extracted as a bytes32 value - tests: - - not_null - - unique + - *key - name: account description: The address associated with the order - name: reason_bytes @@ -818,4 +815,98 @@ models: - *is_increase - *order_key - *position_key - - *referral_code \ No newline at end of file + - *referral_code + + + - name: gmx_v2_order_frozen + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum','avalanche_c', 'gmx', 'event', 'order_frozen'] + description: | + Extracts and decodes the `OrderFrozen` event log data from the Arbitrum and Avalanche blockchains. + This model processes log entries related to frozen orders, extracting key variables such as + account addresses, event keys, and strings representing the reason for the order being frozen. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - key + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - *tx_from + - *tx_to + - name: event_name + description: The type of event recorded, always 'OrderFrozen' for this model + tests: + - not_null + - *msg_sender + - name: key + description: The key associated with the frozen order. Extracted as a bytes32 value + tests: + - not_null + - name: account + description: The address associated with the order + - name: reason_bytes + description: The reason for the order being frozen in byte format. + tests: + - not_null + - name: reason + description: The reason for the order being frozen in string format. + tests: + - not_null + + + - name: gmx_v2_order_updated + meta: + blockchain: arbitrum, avalanche_c + sector: dex + project: gmx + contributors: ai_data_master, gmx-io + config: + tags: ['arbitrum', 'avalanche_c', 'gmx', 'event', 'order_updated'] + description: | + Extracts and decodes the `OrderUpdated` event log data from the Arbitrum and Avalanche blockchains. + This model processes log entries related to updated orders, extracting key variables such as + account addresses, event keys, and strings representing the reason for cancellation. + + columns: + - *blockchain + - *block_time + - *block_date + - *block_number + - *tx_hash + - *index + - *contract_address + - *tx_from + - *tx_to + - name: event_name + description: The type of event recorded, always 'OrderUpdated' for this model. + tests: + - not_null + - *msg_sender + - name: key + description: The key associated with the updated order. Extracted as a bytes32 value + tests: + - not_null + - name: market + description: The market in which the order was updated. + tests: + - not_null + - name: account + description: The address associated with the order. + - *size_delta_usd + - *trigger_price + - *acceptable_price + - *min_output_amount_raw + - *updated_at_time \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql index 6356fd3f027..02bf92593fb 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql @@ -41,7 +41,7 @@ SELECT acceptable_price, execution_fee, callback_gas_limit, - min_output_amount, + min_output_amount_raw, updated_at_block, updated_at_time, is_long, diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_frozen.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_frozen.sql new file mode 100644 index 00000000000..50bf3e8686f --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_frozen.sql @@ -0,0 +1,37 @@ +{{ config( + schema='gmx_v2', + alias = 'order_frozen', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} + +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + key, + account, + reason_bytes, + reason +FROM {{ ref('gmx_v2_' ~ chain ~ '_order_cancelled') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql new file mode 100644 index 00000000000..48361db2c6d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql @@ -0,0 +1,41 @@ +{{ config( + schema='gmx_v2', + alias = 'order_updated', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c"]\', + "project", + "gmx", + \'["ai_data_master","gmx-io"]\') }}' + ) +}} + +{%- set chains = [ + 'arbitrum', + 'avalanche_c', +] -%} +{%- for chain in chains -%} +SELECT + blockchain, + block_time, + block_date, + block_number, + tx_hash, + index, + contract_address, + tx_from, + tx_to, + event_name, + msg_sender, + key, + market, + account, + size_delta_usd, + acceptable_price, + trigger_price, + min_output_amount_raw, + updated_at_time + +FROM {{ ref('gmx_v2_' ~ chain ~ '_order_updated') }} +{% if not loop.last %} +UNION ALL +{% endif %} +{%- endfor -%} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_markets_data.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_markets_data.sql index b107f7ef61f..5c4682b2fe8 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_markets_data.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/arbitrum/gmx_v2_arbitrum_markets_data.sql @@ -8,7 +8,11 @@ SELECT MCE.market_token AS market, - CONCAT(ERC20_IT.symbol, '/USD [', ERC20_LT.symbol, '-', ERC20_ST.symbol, ']') AS market_name, + CASE + WHEN MCE.index_token = 0x0000000000000000000000000000000000000000 + THEN CONCAT('SWAP-ONLY [', ERC20_LT.symbol, '-', ERC20_ST.symbol, ']') + ELSE CONCAT(ERC20_IT.symbol, '/USD [', ERC20_LT.symbol, '-', ERC20_ST.symbol, ']') + END AS market_name, 'GM' AS market_token_symbol, 18 AS market_token_decimals, ERC20_IT.symbol AS index_token_symbol, diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_markets_data.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_markets_data.sql index 7a55c753da4..c8fda944fb9 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_markets_data.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/tokens/avalanche_c/gmx_v2_avalanche_c_markets_data.sql @@ -8,7 +8,11 @@ SELECT MCE.market_token AS market, - CONCAT(ERC20_IT.symbol, '/USD [', ERC20_LT.symbol, '-', ERC20_ST.symbol, ']') AS market_name, + CASE + WHEN MCE.index_token = 0x0000000000000000000000000000000000000000 + THEN CONCAT('SWAP-ONLY [', ERC20_LT.symbol, '-', ERC20_ST.symbol, ']') + ELSE CONCAT(ERC20_IT.symbol, '/USD [', ERC20_LT.symbol, '-', ERC20_ST.symbol, ']') + END AS market_name, 'GM' AS market_token_symbol, 18 AS market_token_decimals, ERC20_IT.symbol AS index_token_symbol, diff --git a/dbt_subprojects/daily_spellbook/package-lock.yml b/dbt_subprojects/daily_spellbook/package-lock.yml index c0962720778..9159e5ec7e2 100644 --- a/dbt_subprojects/daily_spellbook/package-lock.yml +++ b/dbt_subprojects/daily_spellbook/package-lock.yml @@ -1,4 +1,4 @@ packages: - package: dbt-labs/dbt_utils - version: 1.1.1 -sha1_hash: 23451c207c1d4dd71b5925f12a5cd66f2ebb2b3b + version: 1.3.0 +sha1_hash: e60f3271d7a9f853b7ff6316d14feb1341ef78ea From b7c34d52eedad88cb8a073d69b50c7bcc6a26842 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Tue, 24 Sep 2024 16:37:48 -0400 Subject: [PATCH 089/127] `dex.prices_beta` filter out trades without a trusted token (#6824) * filter out trades without a trusted token * fix alias --- .../dex/models/prices/dex_prices_beta.sql | 37 +++++++++++++------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql index 477e7b3b862..558a1b946f7 100644 --- a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql +++ b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql @@ -10,22 +10,35 @@ with dex_trades as ( select distinct - blockchain - , block_time - , token_bought_address - , token_bought_amount_raw - , token_bought_amount - , token_sold_address - , token_sold_amount_raw - , token_sold_amount - , amount_usd + t.blockchain + , t.block_time + , t.token_bought_address + , t.token_bought_amount_raw + , t.token_bought_amount + , t.token_sold_address + , t.token_sold_amount_raw + , t.token_sold_amount + , t.amount_usd from - {{ ref('dex_trades') }} + {{ ref('dex_trades') }} as t where 1 = 1 - and amount_usd > 0 + and t.amount_usd > 0 + and exists ( + -- only output trades which contain a trusted token on either side of the trade + select + 1 + from + {{ source('prices', 'trusted_tokens') }} as tt + where + t.blockchain = tt.blockchain + and ( + t.token_bought_address = tt.contract_address + or t.token_sold_address = tt.contract_address + ) + ) {% if is_incremental() %} - and block_time > (select max(block_time) from {{ this }}) + and t.block_time > (select max(block_time) from {{ this }}) {% endif %} ), dex_bought as ( From e33cdce2bc0dd54dd00a0f08f7dce142f0c93552 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:05:58 -0400 Subject: [PATCH 090/127] flip to inner join (#6827) --- .../dex/models/prices/dex_prices_beta.sql | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql index 558a1b946f7..ed10f98454e 100644 --- a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql +++ b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql @@ -21,22 +21,16 @@ with dex_trades as ( , t.amount_usd from {{ ref('dex_trades') }} as t + inner join + {{ source('prices', 'trusted_tokens') }} as tt -- only output trades which contain a trusted token on either side of the trade + on t.blockchain = tt.blockchain + and ( + t.token_bought_address = tt.contract_address + or t.token_sold_address = tt.contract_address + ) where 1 = 1 and t.amount_usd > 0 - and exists ( - -- only output trades which contain a trusted token on either side of the trade - select - 1 - from - {{ source('prices', 'trusted_tokens') }} as tt - where - t.blockchain = tt.blockchain - and ( - t.token_bought_address = tt.contract_address - or t.token_sold_address = tt.contract_address - ) - ) {% if is_incremental() %} and t.block_time > (select max(block_time) from {{ this }}) {% endif %} From fbc99f72aab8414095efb713d706f767072862d7 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Tue, 24 Sep 2024 19:04:38 -0400 Subject: [PATCH 091/127] Revert dex prices updates (#6829) * Revert "flip to inner join (#6827)" This reverts commit e33cdce2bc0dd54dd00a0f08f7dce142f0c93552. * Revert "`dex.prices_beta` filter out trades without a trusted token (#6824)" This reverts commit b7c34d52eedad88cb8a073d69b50c7bcc6a26842. --- .../dex/models/prices/dex_prices_beta.sql | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql index ed10f98454e..477e7b3b862 100644 --- a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql +++ b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql @@ -10,29 +10,22 @@ with dex_trades as ( select distinct - t.blockchain - , t.block_time - , t.token_bought_address - , t.token_bought_amount_raw - , t.token_bought_amount - , t.token_sold_address - , t.token_sold_amount_raw - , t.token_sold_amount - , t.amount_usd + blockchain + , block_time + , token_bought_address + , token_bought_amount_raw + , token_bought_amount + , token_sold_address + , token_sold_amount_raw + , token_sold_amount + , amount_usd from - {{ ref('dex_trades') }} as t - inner join - {{ source('prices', 'trusted_tokens') }} as tt -- only output trades which contain a trusted token on either side of the trade - on t.blockchain = tt.blockchain - and ( - t.token_bought_address = tt.contract_address - or t.token_sold_address = tt.contract_address - ) + {{ ref('dex_trades') }} where 1 = 1 - and t.amount_usd > 0 + and amount_usd > 0 {% if is_incremental() %} - and t.block_time > (select max(block_time) from {{ this }}) + and block_time > (select max(block_time) from {{ this }}) {% endif %} ), dex_bought as ( From 2f0312e886e294e659e5ce5ab069b3418f245ffa Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Tue, 24 Sep 2024 19:33:41 -0400 Subject: [PATCH 092/127] exclude failing model (#6830) --- .../models/_projects/odos/optimism/odos_v1_optimism_trades.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/models/_projects/odos/optimism/odos_v1_optimism_trades.sql b/dbt_subprojects/dex/models/_projects/odos/optimism/odos_v1_optimism_trades.sql index 786d86c388e..1c05f62dbaa 100644 --- a/dbt_subprojects/dex/models/_projects/odos/optimism/odos_v1_optimism_trades.sql +++ b/dbt_subprojects/dex/models/_projects/odos/optimism/odos_v1_optimism_trades.sql @@ -1,5 +1,6 @@ {{ config( - schema = 'odos_v1_optimism' + tags = ['prod_exclude'] + ,schema = 'odos_v1_optimism' ,alias = 'trades' ,materialized = 'incremental' ,file_format = 'delta' From 84f62f406160534c26c879b76492c1d30c7f3a12 Mon Sep 17 00:00:00 2001 From: AIDataMaster Date: Wed, 25 Sep 2024 18:39:28 +0300 Subject: [PATCH 093/127] Upgrade OrderCreated and OrderUpdated Event Models (GMX) (#6833) * Update OrderCreated and OrderUpdated Event Models * Renamed column names --- .../arbitrum/gmx_v2_arbitrum_event_schema.yml | 20 ++++++++----------- .../gmx_v2_arbitrum_order_created.sql | 8 ++++---- .../gmx_v2_arbitrum_order_updated.sql | 8 ++++---- .../gmx_v2_avalanche_c_event_schema.yml | 20 ++++++++----------- .../gmx_v2_avalanche_c_order_created.sql | 8 ++++---- .../gmx_v2_avalanche_c_order_updated.sql | 8 ++++---- .../gmx/event/gmx_v2_event_schema.yml | 20 ++++++++----------- .../gmx/event/gmx_v2_order_created.sql | 4 ++-- .../gmx/event/gmx_v2_order_updated.sql | 4 ++-- 9 files changed, 44 insertions(+), 56 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml index d4cbca2f796..a9a096600cc 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_event_schema.yml @@ -126,16 +126,12 @@ models: description: The change in initial collateral amount. tests: - not_null - - &trigger_price - name: trigger_price - description: The price that triggers the order execution. - tests: - - not_null - - &acceptable_price - name: acceptable_price - description: The minimum acceptable price for order execution. - tests: - - not_null + - &trigger_price_raw + name: trigger_price_raw + description: The price that triggers the order execution. + - &acceptable_price_raw + name: acceptable_price_raw + description: The minimum acceptable price for order execution. - name: execution_fee description: The fee paid for executing the order in native tokens tests: @@ -906,7 +902,7 @@ models: - name: account description: The address associated with the order. - *size_delta_usd - - *trigger_price - - *acceptable_price + - *trigger_price_raw + - *acceptable_price_raw - *min_output_amount_raw - *updated_at_time \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql index 632bfaee161..503c46f61a8 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_created.sql @@ -266,13 +266,13 @@ WITH evt_data_1 AS ( size_delta_usd / POWER(10, 30) AS size_delta_usd, initial_collateral_delta_amount / POWER(10, collateral_token_decimals) AS initial_collateral_delta_amount, CASE - WHEN index_token_decimals IS NULL THEN trigger_price / POWER(10, 30) + WHEN index_token_decimals IS NULL THEN NULL ELSE trigger_price / POWER(10, 30 - index_token_decimals) - END AS trigger_price, + END AS trigger_price_raw, CASE - WHEN index_token_decimals IS NULL THEN acceptable_price / POWER(10, 30) + WHEN index_token_decimals IS NULL THEN NULL ELSE acceptable_price / POWER(10, 30 - index_token_decimals) - END AS acceptable_price, + END AS acceptable_price_raw, execution_fee / POWER(10, 18) AS execution_fee, callback_gas_limit, min_output_amount AS min_output_amount_raw, diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql index 85af3142f28..cbb9c0da7e1 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/arbitrum/gmx_v2_arbitrum_order_updated.sql @@ -173,13 +173,13 @@ WITH evt_data_1 AS ( ED.account, ED.size_delta_usd / POWER(10, 30) AS size_delta_usd, CASE - WHEN MD.index_token_decimals IS NULL THEN ED.acceptable_price / POWER(10, 30) + WHEN MD.index_token_decimals IS NULL THEN NULL ELSE ED.acceptable_price / POWER(10, 30 - MD.index_token_decimals) - END AS acceptable_price, + END AS acceptable_price_raw, CASE - WHEN MD.index_token_decimals IS NULL THEN ED.trigger_price / POWER(10, 30) + WHEN MD.index_token_decimals IS NULL THEN NULL ELSE ED.trigger_price / POWER(10, 30 - MD.index_token_decimals) - END AS trigger_price, + END AS trigger_price_raw, ED.min_output_amount AS min_output_amount_raw, CASE WHEN ED.updated_at_time = 0 THEN NULL diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml index e2845ea5e81..c1c2ee3a4c3 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_event_schema.yml @@ -126,16 +126,12 @@ models: description: The change in initial collateral amount. tests: - not_null - - &trigger_price - name: trigger_price - description: The price that triggers the order execution. - tests: - - not_null - - &acceptable_price - name: acceptable_price - description: The minimum acceptable price for order execution. - tests: - - not_null + - &trigger_price_raw + name: trigger_price_raw + description: The price that triggers the order execution. + - &acceptable_price_raw + name: acceptable_price_raw + description: The minimum acceptable price for order execution. - name: execution_fee description: The fee paid for executing the order in native tokens tests: @@ -906,7 +902,7 @@ models: - name: account description: The address associated with the order. - *size_delta_usd - - *trigger_price - - *acceptable_price + - *trigger_price_raw + - *acceptable_price_raw - *min_output_amount_raw - *updated_at_time \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql index 5e04a171406..57c13a4488c 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_created.sql @@ -266,13 +266,13 @@ WITH evt_data_1 AS ( size_delta_usd / POWER(10, 30) AS size_delta_usd, initial_collateral_delta_amount / POWER(10, collateral_token_decimals) AS initial_collateral_delta_amount, CASE - WHEN index_token_decimals IS NULL THEN trigger_price / POWER(10, 30) + WHEN index_token_decimals IS NULL THEN NULL ELSE trigger_price / POWER(10, 30 - index_token_decimals) - END AS trigger_price, + END AS trigger_price_raw, CASE - WHEN index_token_decimals IS NULL THEN acceptable_price / POWER(10, 30) + WHEN index_token_decimals IS NULL THEN NULL ELSE acceptable_price / POWER(10, 30 - index_token_decimals) - END AS acceptable_price, + END AS acceptable_price_raw, execution_fee / POWER(10, 18) AS execution_fee, callback_gas_limit, min_output_amount AS min_output_amount_raw, diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql index 1515489060d..3199683750c 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/avalanche_c/gmx_v2_avalanche_c_order_updated.sql @@ -173,13 +173,13 @@ WITH evt_data_1 AS ( ED.account, ED.size_delta_usd / POWER(10, 30) AS size_delta_usd, CASE - WHEN MD.index_token_decimals IS NULL THEN ED.acceptable_price / POWER(10, 30) + WHEN MD.index_token_decimals IS NULL THEN NULL ELSE ED.acceptable_price / POWER(10, 30 - MD.index_token_decimals) - END AS acceptable_price, + END AS acceptable_price_raw, CASE - WHEN MD.index_token_decimals IS NULL THEN ED.trigger_price / POWER(10, 30) + WHEN MD.index_token_decimals IS NULL THEN NULL ELSE ED.trigger_price / POWER(10, 30 - MD.index_token_decimals) - END AS trigger_price, + END AS trigger_price_raw, ED.min_output_amount AS min_output_amount_raw, CASE WHEN ED.updated_at_time = 0 THEN NULL diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml index ebc5d3b69fb..11a605db364 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_event_schema.yml @@ -126,16 +126,12 @@ models: description: The change in initial collateral amount. tests: - not_null - - &trigger_price - name: trigger_price - description: The price that triggers the order execution. - tests: - - not_null - - &acceptable_price - name: acceptable_price - description: The minimum acceptable price for order execution. - tests: - - not_null + - &trigger_price_raw + name: trigger_price_raw + description: The price that triggers the order execution. + - &acceptable_price_raw + name: acceptable_price_raw + description: The minimum acceptable price for order execution. - name: execution_fee description: The fee paid for executing the order in native tokens tests: @@ -906,7 +902,7 @@ models: - name: account description: The address associated with the order. - *size_delta_usd - - *trigger_price - - *acceptable_price + - *trigger_price_raw + - *acceptable_price_raw - *min_output_amount_raw - *updated_at_time \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql index 02bf92593fb..1b8e9f5f5e1 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_created.sql @@ -37,8 +37,8 @@ SELECT decrease_position_swap_type, size_delta_usd, initial_collateral_delta_amount, - trigger_price, - acceptable_price, + trigger_price_raw, + acceptable_price_raw, execution_fee, callback_gas_limit, min_output_amount_raw, diff --git a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql index 48361db2c6d..ab790d79396 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/gmx/event/gmx_v2_order_updated.sql @@ -29,8 +29,8 @@ SELECT market, account, size_delta_usd, - acceptable_price, - trigger_price, + acceptable_price_raw, + trigger_price_raw, min_output_amount_raw, updated_at_time From da77ca33076cf496846a89abe052092e025c7c4c Mon Sep 17 00:00:00 2001 From: tomfutago <35136350+tomfutago@users.noreply.github.com> Date: Wed, 25 Sep 2024 16:39:41 +0100 Subject: [PATCH 094/127] Nexus Mutual - staking updates (#3) (#6821) * fix: reset product_id as non-nullable * feat: add tranche expiry date & chain level, output full history * docs: add new columns to schema.yml * trigger re-run --- .../models/nexusmutual/ethereum/staking/_schema.yml | 5 +++++ .../staking/nexusmutual_ethereum_base_staking_pools.sql | 4 ++-- .../nexusmutual_ethereum_staking_deposit_extensions.sql | 8 ++++++-- .../staking/nexusmutual_ethereum_staking_pools.sql | 7 ++++--- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/_schema.yml b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/_schema.yml index e36496a3bee..468841a72ee 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/_schema.yml @@ -206,6 +206,11 @@ models: description: "current staking tranche period (most recent one in the chain of extensions)" - name: total_amount description: "total staking amount (initial deposit + all top-up amounts)" + - *tranche_expiry_date - *is_active + - name: chain_level + description: "chain (recursion) level" + - name: token_tranche_rn + description: "descending row number per pool, token & tranche" - *evt_index - *tx_hash diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_base_staking_pools.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_base_staking_pools.sql index 1bd487e9e6b..0ebf657ee4e 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_base_staking_pools.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_base_staking_pools.sql @@ -104,7 +104,7 @@ staking_pool_products_combined as ( spp.block_time_created, spu.block_time_updated, coalesce(spp.pool_id, spu.pool_id) as pool_id, - coalesce(spp.product_id, spu.product_id) as product_id, + coalesce(spp.product_id, spu.product_id, -1) as product_id, spp.initial_price, spp.target_price, spu.target_price as updated_target_price, @@ -200,7 +200,7 @@ staking_pool_fee_updates as ( products as ( select - p.product_id, + cast(p.product_id as int) as product_id, p.product_name, pt.product_type_id, pt.product_type_name as product_type diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_extensions.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_extensions.sql index 2836497589b..58aefb450ff 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_extensions.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_extensions.sql @@ -11,7 +11,7 @@ ) }} -with recursive deposit_chain (pool_address, token_id, tranche_id, new_tranche_id, total_amount, block_time, is_active, evt_index, tx_hash, chain_level) as ( +with recursive deposit_chain (pool_address, token_id, tranche_id, new_tranche_id, total_amount, block_time, tranche_expiry_date, is_active, evt_index, tx_hash, chain_level) as ( select pool_address, token_id, @@ -19,6 +19,7 @@ with recursive deposit_chain (pool_address, token_id, tranche_id, new_tranche_id tranche_id as new_tranche_id, sum(amount) as total_amount, max(block_time) as block_time, + max_by(tranche_expiry_date, block_time) as tranche_expiry_date, max_by(is_active, block_time) as is_active, max_by(evt_index, block_time) as evt_index, max_by(tx_hash, block_time) as tx_hash, @@ -36,6 +37,7 @@ with recursive deposit_chain (pool_address, token_id, tranche_id, new_tranche_id d.new_tranche_id, dc.total_amount + coalesce(d.topup_amount, 0) as total_amount, d.block_time, + d.tranche_expiry_date, d.is_active, d.evt_index, d.tx_hash, @@ -54,7 +56,10 @@ select tranche_id as init_tranche_id, new_tranche_id as current_tranche_id, total_amount, + tranche_expiry_date, is_active, + chain_level, + rn as token_tranche_rn, evt_index, tx_hash from ( @@ -63,4 +68,3 @@ from ( row_number() over (partition by pool_address, token_id, tranche_id order by chain_level desc) as rn from deposit_chain ) t -where rn = 1 diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_pools.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_pools.sql index ad21b3e3559..adce06fa39c 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_pools.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_pools.sql @@ -38,6 +38,7 @@ select tx_hash_created, tx_hash_updated from {{ ref('nexusmutual_ethereum_base_staking_pools') }} -{% if is_incremental() %} -where {{ incremental_predicate('block_time_updated') }} -{% endif %} +where true + {% if is_incremental() %} + and {{ incremental_predicate('block_time_updated') }} + {% endif %} From 5b26a3a552005c270d16473ba87e6546f7a62782 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Wed, 25 Sep 2024 12:45:20 -0300 Subject: [PATCH 095/127] add missing tokens to tokens.erc20 (#6834) --- .../tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql index 3231c9df4d3..9a4beed6aee 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql @@ -112,4 +112,9 @@ FROM (VALUES , (0x9aee3c99934c88832399d6c6e08ad802112ebeab, 'FU', 18) , (0xe47ba52f326806559c1dec7ddd997f6957d0317d, 'SHELL', 18) , (0x79ead7a012d97ed8deece279f9bc39e264d7eef9, 'Bonsai', 18) + , (0x8b65c028b223b83b13fcf1d1f0873320e6cab132, 'UPDOGE', 18) + , (0x8d7c2588c365b9e98ea464b63dbccdf13ecd9809, 'AI', 18) + , (0xd2cc61a36c31425b3eb9bbeecce74a82a2e32e27, 'RATS', 18) + , (0x27f485b62c4a7e635f561a87560adf5090239e93, 'DFX', 18) + , (0x39a49bc5017fc668299cd32e734c9269acc35295, 'PHONON', 18) ) AS temp_table (contract_address, symbol, decimals) From 869051c364b1840e8c0ba5aaec4f10891dc1e6ae Mon Sep 17 00:00:00 2001 From: max-morrow Date: Wed, 25 Sep 2024 18:51:35 +0300 Subject: [PATCH 096/127] added columns to project_orders linage (#6793) added tx_from & tx_to --- .../models/_projects/oneinch/oneinch_project_orders.sql | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/oneinch_project_orders.sql b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/oneinch_project_orders.sql index 10c5ba818e2..8b781421029 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/oneinch/oneinch_project_orders.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/oneinch/oneinch_project_orders.sql @@ -17,6 +17,8 @@ 'block_number', 'block_time', 'tx_hash', + 'tx_from', + 'tx_to', 'method', 'call_selector', 'call_trace_address', @@ -125,6 +127,8 @@ meta as ( , coalesce(order_hash, concat(tx_hash, to_big_endian_32(cast(counter as int)))) as order_hash , call_trade , any_value(block_time) as block_time + , any_value(tx_from) as tx_from + , any_value(tx_to) as tx_to , any_value(project) as project , any_value(call_selector) as call_selector , any_value(call_from) as call_from @@ -160,6 +164,8 @@ select , block_number , block_time , tx_hash + , tx_from + , tx_to , project , call_trace_address , call_selector From 5f769145a37d7855758137b8d801b3d23e34974b Mon Sep 17 00:00:00 2001 From: max-morrow Date: Wed, 25 Sep 2024 18:51:46 +0300 Subject: [PATCH 097/127] 1inch-U44: updates for fusion_executors (#6823) * updated fusion_executors added fusion+ executors promotions * fix * fix * fix * updated oneinch.blockchains * neat * cosmetic --- .../oneinch/_meta/oneinch_blockchains.sql | 19 +++++++++++++++++-- .../_meta/oneinch_fusion_executors.sql | 13 +++++++++---- .../dex/models/_projects/oneinch/_schema.yml | 2 ++ .../ethereum/oneinch_ethereum_sources.yml | 1 + 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/dbt_subprojects/dex/models/_projects/oneinch/_meta/oneinch_blockchains.sql b/dbt_subprojects/dex/models/_projects/oneinch/_meta/oneinch_blockchains.sql index d14b6444660..7e491baf44e 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/_meta/oneinch_blockchains.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/_meta/oneinch_blockchains.sql @@ -7,9 +7,24 @@ ) }} +{% set + blockchains = [ + 'ethereum', + 'bnb', + 'polygon', + 'arbitrum', + 'optimism', + 'avalanche_c', + 'gnosis', + 'fantom', + 'base', + 'zksync', + 'aurora', + 'klaytn', + ] +%} - -{% for blockchain in oneinch_exposed_blockchains_list() %} +{% for blockchain in blockchains %} {{ oneinch_blockchain_macro(blockchain) }} {% if not loop.last %} union all {% endif %} {% endfor %} diff --git a/dbt_subprojects/dex/models/_projects/oneinch/_meta/oneinch_fusion_executors.sql b/dbt_subprojects/dex/models/_projects/oneinch/_meta/oneinch_fusion_executors.sql index 20229c73a92..3c3108a8378 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/_meta/oneinch_fusion_executors.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/_meta/oneinch_fusion_executors.sql @@ -14,25 +14,30 @@ executors as ( promoter as resolver_address , promotee as resolver_executor , chainId as chain_id + , mode , min(evt_block_time) as first_promoted_at , max(evt_block_time) as last_promoted_at from ( - select promoter, promotee, chainId, evt_block_time + select promoter, promotee, chainId, evt_block_time, 'intra_chain' as mode from {{ source('oneinch_ethereum', 'FusionWhitelistRegistryV1_evt_Promotion') }} union all - select promoter, promotee, chainId, evt_block_time + select promoter, promotee, chainId, evt_block_time, 'intra_chain' as mode from {{ source('oneinch_ethereum', 'FusionWhitelistRegistryV2_evt_Promotion') }} + union all + select promoter, promotee, chainId, evt_block_time, 'cross_chain' as mode + from {{ source('oneinch_ethereum', 'CrosschainWhitelistRegistryV1_evt_Promotion') }} ) - group by 1, 2, 3 + group by 1, 2, 3, 4 ) -- output -- -select +select blockchain , resolver_address , resolver_executor , chain_id + , mode , first_promoted_at , last_promoted_at from executors diff --git a/dbt_subprojects/dex/models/_projects/oneinch/_schema.yml b/dbt_subprojects/dex/models/_projects/oneinch/_schema.yml index 8f961c8908c..8b8262bde46 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/oneinch/_schema.yml @@ -500,6 +500,7 @@ models: - dbt_utils.unique_combination_of_columns: combination_of_columns: - chain_id + - resolver_address - resolver_executor columns: - name: resolver_address @@ -511,6 +512,7 @@ models: - name: chain_id tests: - not_null + - name: mode - name: first_promoted_at - name: last_promoted_at diff --git a/sources/oneinch/ethereum/oneinch_ethereum_sources.yml b/sources/oneinch/ethereum/oneinch_ethereum_sources.yml index f8581952947..84fe9496058 100644 --- a/sources/oneinch/ethereum/oneinch_ethereum_sources.yml +++ b/sources/oneinch/ethereum/oneinch_ethereum_sources.yml @@ -64,6 +64,7 @@ sources: - name: FusionWhitelistRegistryV2_evt_Registered - name: FusionWhitelistRegistryV2_evt_Unregistered - name: FusionWhitelistRegistryV2_evt_Promotion + - name: CrosschainWhitelistRegistryV1_evt_Promotion - name: AggregationRouterV6_call_swap - name: AggregationRouterV6_call_clipperSwap - name: AggregationRouterV6_call_clipperSwapTo From fe376e187f620cc3ad15e5230835065e14861817 Mon Sep 17 00:00:00 2001 From: Eduard Gorkh <40689054+grkhr@users.noreply.github.com> Date: Wed, 25 Sep 2024 18:51:56 +0300 Subject: [PATCH 098/127] dex raw pools: add fee column (#6820) * implement fee * apply easy date * Revert "apply easy date" This reverts commit dfb8e2a532c2240d5fd5b66e92ba5a783e73c4b7. * v2 fee * Reapply "apply easy date" This reverts commit 6e974313fba0fc6a0fa57dcf585f6206f80f4884. * Revert "Reapply "apply easy date"" This reverts commit 2e7d6e15f1fbc932d6cc9f8fa389078888144b87. --- dbt_subprojects/dex/models/pools/_schema.yml | 8 +++++--- .../dex/models/pools/dex_raw_pool_creations.sql | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/dbt_subprojects/dex/models/pools/_schema.yml b/dbt_subprojects/dex/models/pools/_schema.yml index 2509126abe0..7b0eec51be6 100644 --- a/dbt_subprojects/dex/models/pools/_schema.yml +++ b/dbt_subprojects/dex/models/pools/_schema.yml @@ -69,6 +69,9 @@ models: - &tokens name: tokens description: "Tokens in the pool" + - &fee + name: fee + description: "Defined fee" - &creation_block_time name: creation_block_time description: "Block time of pool creation" @@ -101,6 +104,7 @@ models: - *token0 - *token1 - *tokens + - *fee - *creation_block_time - *creation_block_number - name: contract_address @@ -127,9 +131,7 @@ models: description: "Project name of the DEX" - *version - *pool - - &fee - name: fee - description: "Defined fee" + - *fee - *token0 - *token1 - *creation_block_time diff --git a/dbt_subprojects/dex/models/pools/dex_raw_pool_creations.sql b/dbt_subprojects/dex/models/pools/dex_raw_pool_creations.sql index 28c7161171c..5ba5991f3f6 100644 --- a/dbt_subprojects/dex/models/pools/dex_raw_pool_creations.sql +++ b/dbt_subprojects/dex/models/pools/dex_raw_pool_creations.sql @@ -58,24 +58,28 @@ 'version': 'Factory V1 Plain', 'tokens_position': 4 + 1 + 32 * 2, 'tokens_count': 4, + 'fee_position': 4 + 1 + 32 * 7, }, '0xd4b9e214': { 'type': 'curve_compatible', 'version': 'Factory V1 Plain', 'tokens_position': 4 + 1 + 32 * 2, 'tokens_count': 4, + 'fee_position': 4 + 1 + 32 * 7, }, '0xcd419bb5': { 'type': 'curve_compatible', 'version': 'Factory V1 Plain', 'tokens_position': 4 + 1 + 32 * 2, 'tokens_count': 4, + 'fee_position': 4 + 1 + 32 * 7, }, '0x5c16487b': { 'type': 'curve_compatible', 'version': 'Factory V1 Plain', 'tokens_position': 4 + 1 + 32 * 2, 'tokens_count': 4, + 'fee_position': 4 + 1 + 32 * 7, }, '0xc955fa04': { @@ -83,6 +87,7 @@ 'version': 'Factory V2', 'tokens_position': 4 + 1 + 32 * 2, 'tokens_count': 2, + 'fee_position': 4 + 1 + 32 * 4, }, '0xaa38b385': { 'type': 'curve_compatible', @@ -96,9 +101,8 @@ 'version': 'Factory V1 Plain Stableswap', 'tokens_position': 4 + 1 + 32 * 16, 'tokens_count': 8, + 'fee_position': 4 + 1 + 32 * 4, }, - - } %} @@ -157,6 +161,7 @@ uniswap_pool_created_logs as ( , substr(data, {{ data.pool_position }}, 20) as pool , substr(topic1, 13) as token0 , substr(topic2, 13) as token1 + , coalesce(bytearray_to_uint256(topic3), uint256 '3000') as fee , block_number , block_time , contract_address @@ -184,6 +189,7 @@ uniswap_pool_created_logs as ( , substr(output, 13, 20) as pool , trace_address , transform(sequence(1, 32 * {{ data.tokens_count }}, 32), x -> substr(substr(substr(input, {{ data.tokens_position }}, 32 * {{ data.tokens_count }}), x, 32), 13)) tokens + , {% if data.fee_position %} bytearray_to_uint256(substr(input, {{ data.fee_position }}, 32)) {% else %} cast(null as uint256) {% endif %} as fee , block_number , block_time , "to" as contract_address @@ -262,6 +268,7 @@ uniswap_pool_created_logs as ( , token0 , token1 , array[token0, token1] as tokens + , cast(fee as uint256) as fee , creation_block_time , creation_block_number , contract_address @@ -281,6 +288,7 @@ uniswap_pool_created_logs as ( , token0 , token1 , array[token0, token1] as tokens + , fee , block_time , block_number , contract_address @@ -297,6 +305,7 @@ uniswap_pool_created_logs as ( , tokens[1] as token0 , tokens[2] as token1 , tokens + , fee , block_time , block_number , contract_address @@ -314,6 +323,7 @@ uniswap_pool_created_logs as ( , token0 , token1 , tokens + , fee , block_time as creation_block_time , block_number as creation_block_number , contract_address From e111c62712e8f53d43974fa2eed1a06e1f566f31 Mon Sep 17 00:00:00 2001 From: Rantum Date: Wed, 25 Sep 2024 09:08:25 -0700 Subject: [PATCH 099/127] zeroex - add blast trades (#6786) * add mantle & blast to cross-chain spell * add seed * add seed * remove nft changes * restore nft schema changes * restore nft schema changes * restore nft schema changes * restore nft schema changes * add seed file * add blast model files * revise to use nft.transfers - not nft_blast.transfers --- .../zeroex/blast/zeroex_blast_schema.yml | 111 +++++++ .../blast/zeroex_blast_settler_trades.sql | 296 ++++++++++++++++++ .../zeroex/zeroex_api_fills_deduped.sql | 1 + .../models/_projects/zeroex/zeroex_schema.yml | 4 +- .../seeds/_project/zeroex/blast/_schema.yml | 11 + .../zeroex_blast_settler_trades_sample.csv | 3 + 6 files changed, 424 insertions(+), 2 deletions(-) create mode 100644 dbt_subprojects/dex/models/_projects/zeroex/blast/zeroex_blast_schema.yml create mode 100644 dbt_subprojects/dex/models/_projects/zeroex/blast/zeroex_blast_settler_trades.sql create mode 100644 dbt_subprojects/dex/seeds/_project/zeroex/blast/_schema.yml create mode 100644 dbt_subprojects/dex/seeds/_project/zeroex/blast/zeroex_blast_settler_trades_sample.csv diff --git a/dbt_subprojects/dex/models/_projects/zeroex/blast/zeroex_blast_schema.yml b/dbt_subprojects/dex/models/_projects/zeroex/blast/zeroex_blast_schema.yml new file mode 100644 index 00000000000..d427aa5c7c2 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/zeroex/blast/zeroex_blast_schema.yml @@ -0,0 +1,111 @@ +version: 2 + +models: + - name: zeroex_blast_settler_trades + meta: + blockchain: blast + project: zeroex + contributors: rantum + config: + tags: ['blast','0x','dex_aggregator','dex','aggregator'] + description: > + 0x API erc20 trades through 0x Settler contracts. No fills, only deduped transactions. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_month + - block_date + - tx_hash + - evt_index + - check_seed: + seed_file: ref('zeroex_blast_settler_trades_sample') + match_columns: + - tx_hash + check_columns: + - taker + - maker_token + - taker_token + columns: + - &blockchain + name: blockchain + description: "Blockchain which the aggregator project is deployed" + - &block_date + name: block_date + description: "UTC event block date of each trade" + - &block_month + name: block_month + description: "UTC event block month of each trade" + - &block_time + name: block_time + description: "UTC event block time of each trade" + - &taker_symbol + name: taker_symbol + description: "Symbol of the token taker sells" + - &maker_symbol + name: maker_symbol + description: "Symbol of the token taker buys" + - &token_pair + name: token_pair + description: "Token pair traded" + - &taker_token_amount + name: taker_token_amount + description: "The after-decimal amount of the token taker sells" + - &taker_token_amount_raw + name: taker_token_amount_raw + description: "The raw amount of the token taker sells" + - &maker_token_amount + name: maker_token_amount + description: "The after-decimal amount of the token taker buys" + - &maker_token_amount_raw + name: maker_token_amount_raw + description: "The raw amount of the token taker buys" + - &volume_usd + name: volume_usd + description: "Trading volume measured in USD value" + - &taker_token + name: taker_token + description: "Contract address of the token taker sells" + - &maker_token + name: maker_token + description: "Contract address of the token taker buys" + - &maker + name: maker + description: "buyer of the trade" + - &taker + name: taker + description: "seller of the trade" + - &affiliate_address + name: affiliate_address + description: "The recipient address of the affiliate, or the applications that is using 0x API, for receiving affiliate fee" + - &tx_hash + name: tx_hash + description: "Transaction hash of the fill" + - &tx_from + name: tx_from + description: "Address which initiated the trade" + - &tx_to + name: tx_to + description: "Address which received the trade" + - &evt_index + name: evt_index + description: "Index of the corresponding order filled event" + - &type + name: type + description: "The liquidity route the order went thru" + - &swap_flag + name: swap_flag + description: "If the swap was filled/consumed thru 0x API" + - &contract_address + name: contract_address + desctiption: "The address of the contract which fired the fill/swap event" + - &fills_within + name: fills_within + description: "fills in then multihop, if present" + + + + + + + + \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/zeroex/blast/zeroex_blast_settler_trades.sql b/dbt_subprojects/dex/models/_projects/zeroex/blast/zeroex_blast_settler_trades.sql new file mode 100644 index 00000000000..1b741a62f5c --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/zeroex/blast/zeroex_blast_settler_trades.sql @@ -0,0 +1,296 @@ +{{ config( + schema = 'zeroex_blast', + alias = 'settler_trades', + materialized='incremental', + partition_by = ['block_month'], + unique_key = ['block_month', 'block_date', 'tx_hash', 'evt_index'], + on_schema_change='sync_all_columns', + file_format ='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] +)}} + +{% set zeroex_settler_start_date = '2024-07-15' %} + +WITH tbl_addresses AS ( + SELECT + blockchain, + token_id, + to AS settler_address, + block_time AS begin_block_time, + block_number AS begin_block_number + FROM + {{ source('nft', 'transfers') }} + WHERE + contract_address = 0x00000000000004533fe15556b1e086bb1a72ceae + AND blockchain = 'blast' + and block_time > TIMESTAMP '2024-05-23' +), + +tbl_end_times AS ( + SELECT + *, + LEAD(begin_block_time) OVER (PARTITION BY blockchain, token_id ORDER BY begin_block_time) AS end_block_time, + LEAD(begin_block_number) OVER (PARTITION BY blockchain, token_id ORDER BY begin_block_number) AS end_block_number + FROM + tbl_addresses +), + +result_0x_settler_addresses AS ( + SELECT + * + FROM + tbl_end_times + WHERE + settler_address != 0x0000000000000000000000000000000000000000 +), + +settler_txs AS ( + SELECT + tx_hash, + block_time, + block_number, + method_id, + contract_address, + settler_address, + MAX(varbinary_substring(tracker,2,12)) AS zid, + CASE + WHEN method_id = 0x1fff991f THEN MAX(varbinary_substring(tracker,14,3)) + WHEN method_id = 0xfd3ad6d4 THEN MAX(varbinary_substring(tracker,13,3)) + END AS tag + FROM ( + SELECT + tr.tx_hash, + block_number, + block_time, + "to" AS contract_address, + varbinary_substring(input,1,4) AS method_id, + varbinary_substring(input,varbinary_position(input,0xfd3ad6d4)+132,32) tracker, + a.settler_address + FROM + {{ source('blast', 'traces') }} AS tr + JOIN + result_0x_settler_addresses a ON a.settler_address = tr.to AND a.blockchain = 'blast' AND tr.block_time > a.begin_block_time + WHERE + (a.settler_address IS NOT NULL OR tr.to = 0xca11bde05977b3631167028862be2a173976ca11) + AND varbinary_substring(input,1,4) IN (0x1fff991f, 0xfd3ad6d4) + {% if is_incremental() %} + AND {{ incremental_predicate('block_time') }} + {% else %} + AND block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + GROUP BY + 1,2,3,4,5,6 +), +tbl_trades as ( + +with tbl_all_logs AS ( + SELECT + logs.tx_hash, + logs.block_time, + logs.block_number, + index, + coalesce(bytearray_substring(logs.topic2,13,20), first_value(bytearray_substring(logs.topic1,13,20)) over (partition by logs.tx_hash order by index) ) as taker, + logs.contract_address as maker_token, + first_value(logs.contract_address) over (partition by logs.tx_hash order by index) as taker_token, + first_value(try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) ) over (partition by logs.tx_hash order by index) as taker_amount, + try_cast(bytearray_to_uint256(bytearray_substring(DATA, 22,11)) as int256) as maker_amount, + method_id, + tag, + st.settler_address, + zid, + st.settler_address as contract_address + FROM + {{ source('blast', 'logs') }} AS logs + JOIN + settler_txs st ON st.tx_hash = logs.tx_hash AND logs.block_time = st.block_time AND st.block_number = logs.block_number + + WHERE + topic0 IN ( 0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65, + 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, + 0xe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c ) + and topic1 != 0x0000000000000000000000000000000000000000000000000000000000000000 + and zid != 0xa00000000000000000000000 + {% if is_incremental() %} + AND {{ incremental_predicate('logs.block_time') }} + {% else %} + AND logs.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ), + tbl_valid_logs as ( + select * + , row_number() over (partition by tx_hash order by index desc) rn + from tbl_all_logs + where maker_token != taker_token + ) + select * from tbl_valid_logs + where rn = 1 +), + + +tokens AS ( + with token_list as ( + select + distinct maker_token as token + from + tbl_trades + + union distinct + + select + distinct taker_token as token + from tbl_trades + ) + + select * + from + token_list tl + join + {{ source('tokens', 'erc20') }} AS te ON te.contract_address = tl.token + WHERE + te.blockchain = 'blast' +), + +prices AS ( + SELECT DISTINCT + pu.* + FROM + {{ source('prices', 'usd') }} AS pu + JOIN + tbl_trades ON (pu.contract_address = taker_token OR pu.contract_address = maker_token) AND date_trunc('minute',block_time) = minute + WHERE + pu.blockchain = 'blast' + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= DATE '{{zeroex_settler_start_date}}' + {% endif %} +), + +fills as ( + with signatures as ( + select distinct signature + from {{ source('blast', 'logs_decoded') }} l + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + and event_name in ('TokenExchange', 'OtcOrderFilled', 'SellblastToken', 'Swap', 'BuyGem', 'DODOSwap', 'SellGem', 'Submitted') + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + ) + + select tt.tx_hash, tt.block_number, tt.block_time, count(*) fills_within + from {{ source('blast', 'logs') }} l + join signatures on signature = topic0 + join tbl_trades tt on tt.tx_hash = l.tx_hash and l.block_time = tt.block_time and l.block_number = tt.block_number + WHERE 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('l.block_time') }} + {% else %} + AND l.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} + group by 1,2,3 + ), + +results AS ( + SELECT + trades.block_time, + trades.block_number, + zid, + trades.contract_address, + method_id, + trades.tx_hash, + "from" AS tx_from, + "to" AS tx_to, + trades.index AS tx_index, + case when varbinary_substring(tr.data,1,4) = 0x500c22bc then "from" else taker end as taker, + CAST(NULL AS varbinary) AS maker, + taker_token, + pt.price, + COALESCE(tt.symbol, pt.symbol) AS taker_symbol, + taker_amount AS taker_token_amount_raw, + taker_amount / POW(10,COALESCE(tt.decimals,pt.decimals)) AS taker_token_amount, + taker_amount / POW(10,COALESCE(tt.decimals,pt.decimals)) * pt.price AS taker_amount, + maker_token, + COALESCE(tm.symbol, pm.symbol) AS maker_symbol, + maker_amount AS maker_token_amount_raw, + maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) AS maker_token_amount, + maker_amount / POW(10,COALESCE(tm.decimals,pm.decimals)) * pm.price AS maker_amount, + tag, + fills_within + FROM + tbl_trades trades + JOIN + {{ source('blast', 'transactions') }} tr ON tr.hash = trades.tx_hash AND tr.block_time = trades.block_time AND tr.block_number = trades.block_number + LEFT JOIN + fills f ON f.tx_hash = trades.tx_hash AND f.block_time = trades.block_time AND f.block_number = trades.block_number + LEFT JOIN + tokens tt ON tt.blockchain = 'blast' AND tt.contract_address = taker_token + LEFT JOIN + tokens tm ON tm.blockchain = 'blast' AND tm.contract_address = maker_token + LEFT JOIN + prices pt ON pt.blockchain = 'blast' AND pt.contract_address = taker_token AND pt.minute = DATE_TRUNC('minute', trades.block_time) + LEFT JOIN + prices pm ON pm.blockchain = 'blast' AND pm.contract_address = maker_token AND pm.minute = DATE_TRUNC('minute', trades.block_time) + WHERE + 1=1 + {% if is_incremental() %} + AND {{ incremental_predicate('tr.block_time') }} + {% else %} + AND tr.block_time >= DATE '{{zeroex_settler_start_date}}' + {% endif %} +), + +results_usd AS ( + SELECT + 'blast' AS blockchain, + '0x-API' AS project, + 'settler' AS version, + DATE_TRUNC('day', block_time) block_date, + DATE_TRUNC('month', block_time) AS block_month, + block_time, + taker_symbol, + maker_symbol, + CASE WHEN LOWER(taker_symbol) > LOWER(maker_symbol) THEN CONCAT(maker_symbol, '-', taker_symbol) ELSE CONCAT(taker_symbol, '-', maker_symbol) END AS token_pair, + taker_token_amount, + maker_token_amount, + taker_token_amount_raw, + maker_token_amount_raw, + CASE WHEN maker_token IN (0x4300000000000000000000000000000000000004, + 0x4300000000000000000000000000000000000003, + 0xb1a5700fa2358173fe465e6ea4ff52e36e88e2ad ) AND maker_amount IS NOT NULL + THEN maker_amount + WHEN taker_token IN (0x4300000000000000000000000000000000000004, + 0x4300000000000000000000000000000000000003, + 0xb1a5700fa2358173fe465e6ea4ff52e36e88e2ad ) AND taker_amount IS NOT NULL + THEN taker_amount + ELSE COALESCE(maker_amount, taker_amount) + END AS volume_usd, + taker_token, + maker_token, + taker, + maker, + tag, + zid, + tx_hash, + tx_from, + tx_to, + tx_index AS evt_index, + (ARRAY[-1]) AS trace_address, + 'settler' AS type, + TRUE AS swap_flag, + fills_within, + contract_address + FROM + results +) + +SELECT DISTINCT + * +FROM + results_usd +ORDER BY + block_time DESC \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql index 8bfdd619be5..f037d694f47 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql +++ b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_api_fills_deduped.sql @@ -31,6 +31,7 @@ ,ref('zeroex_arbitrum_settler_trades') ,ref('zeroex_scroll_settler_trades') ,ref('zeroex_linea_settler_trades') + ,ref('zeroex_blast_settler_trades') ] %} diff --git a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml index e93f4f91ef8..2af511b28f5 100644 --- a/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml +++ b/dbt_subprojects/dex/models/_projects/zeroex/zeroex_schema.yml @@ -105,7 +105,7 @@ models: - name: zeroex_api_fills_deduped meta: - blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb, base, scroll, linea + blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb, base, scroll, linea, blast sector: dex project: zeroex contributors: rantum, bakabhai993 @@ -158,7 +158,7 @@ models: - name: zeroex_trades meta: - blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb, base, linea, scroll + blockchain: ethereum, optimism, polygon, arbitrum, fantom, avalanche, bnb, base, linea, scroll, blast project: zeroex contributors: rantum, danning.sui, bakabhai993 config: diff --git a/dbt_subprojects/dex/seeds/_project/zeroex/blast/_schema.yml b/dbt_subprojects/dex/seeds/_project/zeroex/blast/_schema.yml new file mode 100644 index 00000000000..aab9ffaad7a --- /dev/null +++ b/dbt_subprojects/dex/seeds/_project/zeroex/blast/_schema.yml @@ -0,0 +1,11 @@ +version: 2 + +seeds: + - name: zeroex_blast_settler_trades_sample + config: + column_types: + tx_hash: varbinary + taker: varbinary + taker_token: varbinary + maker_token: varbinary + taker_token_amount: double \ No newline at end of file diff --git a/dbt_subprojects/dex/seeds/_project/zeroex/blast/zeroex_blast_settler_trades_sample.csv b/dbt_subprojects/dex/seeds/_project/zeroex/blast/zeroex_blast_settler_trades_sample.csv new file mode 100644 index 00000000000..6485f75e989 --- /dev/null +++ b/dbt_subprojects/dex/seeds/_project/zeroex/blast/zeroex_blast_settler_trades_sample.csv @@ -0,0 +1,3 @@ +tx_hash,taker,taker_token,maker_token,taker_token_amount +0x92f05d2cc3e693ae5863e5a3c08475a9fb62c1db76acce05461aa8538cb9689a,0x4ea754349ace5303c82f0d1d491041e042f2ad22,0x4300000000000000000000000000000000000003,0x4300000000000000000000000000000000000004,1 +0x4477ae1598016d0abee946f6bd7a0f6cbdbd6a87a3dde5eae1007d9f6a8ced06,0x4ea754349ace5303c82f0d1d491041e042f2ad22,0x4300000000000000000000000000000000000003,0x4300000000000000000000000000000000000004,1e-12 \ No newline at end of file From 0a6583d1fd122c6481dac434366717d6a21cfca1 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Wed, 25 Sep 2024 14:31:20 -0400 Subject: [PATCH 100/127] update sushiswap source (#6837) --- .../arbitrum/platforms/sushiswap_v2_arbitrum_base_trades.sql | 2 +- sources/_sector/dex/trades/arbitrum/_sources.yml | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/models/trades/arbitrum/platforms/sushiswap_v2_arbitrum_base_trades.sql b/dbt_subprojects/dex/models/trades/arbitrum/platforms/sushiswap_v2_arbitrum_base_trades.sql index 98808748296..a880e132ddd 100644 --- a/dbt_subprojects/dex/models/trades/arbitrum/platforms/sushiswap_v2_arbitrum_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/arbitrum/platforms/sushiswap_v2_arbitrum_base_trades.sql @@ -16,6 +16,6 @@ project = 'sushiswap', version = '2', Pair_evt_Swap = source('sushiswap_v3_pool_arbitrum', 'UniswapV3Pool_evt_Swap'), - Factory_evt_PoolCreated = source('sushi_v2_arbitrum', 'Factory_evt_PoolCreated') + Factory_evt_PoolCreated = source('sushiswap_arbitrum', 'UniswapV3Factory_evt_PoolCreated') ) }} diff --git a/sources/_sector/dex/trades/arbitrum/_sources.yml b/sources/_sector/dex/trades/arbitrum/_sources.yml index 70ac7417282..a0e6345db2c 100644 --- a/sources/_sector/dex/trades/arbitrum/_sources.yml +++ b/sources/_sector/dex/trades/arbitrum/_sources.yml @@ -18,6 +18,9 @@ sources: tables: - name: Pair_evt_Swap - name: Factory_evt_PairCreated + - name: sushiswap_arbitrum + tables: + - name: UniswapV3Factory_evt_PoolCreated - name: sushi_v2_arbitrum tables: - name: Pool_evt_Swap From 3177cadeec20ce2b25dcfa12666d8c16b5f27f00 Mon Sep 17 00:00:00 2001 From: Rantum Date: Thu, 26 Sep 2024 07:18:09 -0700 Subject: [PATCH 101/127] add tokens (#6836) --- .../tokens/arbitrum/tokens_arbitrum_erc20.sql | 6 +++++- .../tokens/models/tokens/bnb/tokens_bnb_bep20.sql | 15 +++++++++++++++ .../tokens/ethereum/tokens_ethereum_erc20.sql | 6 ++++++ .../tokens/polygon/tokens_polygon_erc20.sql | 6 ++++++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql index 9a4beed6aee..286f6aadfcb 100644 --- a/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/arbitrum/tokens_arbitrum_erc20.sql @@ -116,5 +116,9 @@ FROM (VALUES , (0x8d7c2588c365b9e98ea464b63dbccdf13ecd9809, 'AI', 18) , (0xd2cc61a36c31425b3eb9bbeecce74a82a2e32e27, 'RATS', 18) , (0x27f485b62c4a7e635f561a87560adf5090239e93, 'DFX', 18) - , (0x39a49bc5017fc668299cd32e734c9269acc35295, 'PHONON', 18) + , (0x39a49bc5017fc668299cd32e734c9269acc35295, 'PHONON', 18) + , (0x89073b7aaae498771bdb789360b0d3de9d15ad56, 'STC', 18) + , (0xb59c8912c83157a955f9d715e556257f432c35d7, 'TRUF', 18) + , (0xe1d3495717f9534db67a6a8d4940dd17435b6a9e, 'LOCUS', 18) + , (0x764bfc309090e7f93edce53e5befa374cdcb7b8e, 'GRIMACE', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_bep20.sql b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_bep20.sql index 21782b7f17d..a9bfcdd9379 100644 --- a/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_bep20.sql +++ b/dbt_subprojects/tokens/models/tokens/bnb/tokens_bnb_bep20.sql @@ -593,4 +593,19 @@ FROM (VALUES , (0x6985884c4392d348587b19cb9eaaf157f13271cd, 'ZRO', 18) , (0xfceb31a79f71ac9cbdcf853519c1b12d379edc46, 'LISTA', 18) , (0x0e7779e698052f8fe56c415c3818fcf89de9ac6d, 'ULTI', 18) + , (0x617cab4aaae1f8dfb3ee138698330776a1e1b324, 'ARTY', 6) + , (0x2940566eb50f15129238f4dc599adc4f742d7d8e, 'BCCoin', 18) + , (0xc5d27f27f08d1fd1e3ebbaa50b3442e6c0d50439, 'APP', 18) + , (0x7b56748a3ef9970a5bae99c58ad8bc67b26c525f, 'CHAPZ', 10) + , (0x23b891e5c62e0955ae2bd185990103928ab817b3, 'nUSD', 18) + , (0xbda011d7f8ec00f66c1923b049b94c67d148d8b2, 'AI', 18) + , (0x4a8049c015ae1c6665fc9e49f053458ae3a102d0, 'BabyRWA', 9) + , (0x75e8ddb518bb757b4282cd5b83bb70d4101d12fb, 'NFP', 18) + , (0x51e72dd1f2628295cc2ef931cb64fdbdc3a0c599, 'KAS', 8) + , (0xe6d19cfa419fc81029b11b335ba5c53a0aa6e37f, 'DEMON', 18) + , (0xd404829f8634c99c7ac945b69a02a5b7a8d4de8c, 'MEMEAI', 18) + , (0xeb880acb83c63ea3eab4baae9693dc5dd9d324a3, 'SCPT', 18) + , (0xdb6c248902ad2722a5e01e9689824c28bd0a5f75, 'Baby-LP', 18) + , (0xd1b6d02c03e632a845460c8167eb05d2d9e03a35, 'Sorai', 18) + , (0x0f327343c7902233c0419724946b17fa664f2fe0, 'LBTC', 18) ) AS temp_table (contract_address, symbol, decimals) \ No newline at end of file diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql index 993f4784fb4..5a075a3286a 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4626,4 +4626,10 @@ FROM (VALUES , ( 0x60407266586e204792b69b024558aa18228ab12f, 'MBAKER', 18) , ( 0x048d07bd350ba516b84587e147284881b593eb86, 'SYNK', 18) , ( 0xbbd91d5cda7085a186b1354e1b0744bb58ad7cf6, 'ZOMBIE', 9) + , ( 0xdd157bd06c1840fa886da18a138c983a7d74c1d7, 'GSTOP', 18) + , ( 0x525574c899a7c877a11865339e57376092168258, 'GURU', 18) + , ( 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 'BUBBLE', 9) + , ( 0xeb9951021698b42e4399f9cbb6267aa35f82d59d, 'LIF', 18) + , ( 0x707f9118e33a9b8998bea41dd0d46f38bb963fc8, 'bETH', 18) + ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20.sql b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20.sql index 6e911f2ebfd..4fe9958dc2c 100644 --- a/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/polygon/tokens_polygon_erc20.sql @@ -51,4 +51,10 @@ FROM (VALUES , (0x94f05506b6a9c564839d8e95b21f9fb4f42ff2aa, 'SFRIED', 18) , (0x9b8b6a1298d34b3c4bbddce8a7ff0149121592c1, 'AMBO', 18) , (0xe9d2fa815b95a9d087862a09079549f351dab9bd, 'BONSAI', 18) + , (0xe0cca86b254005889ac3a81e737f56a14f4a38f5, 'ALTA', 18) + , (0x421b9b487d5a9b76e4b81809c0f1b9bb8cb24cb9, 'PBOS', 18) + , (0x13646e0e2d768d31b75d1a1e375e3e17f18567f2, 'NWS', 18) + , (0xbae28251b2a4e621aa7e20538c06dee010bc06de, 'dHEDGE', 18) + , (0xdfe21992da3c135f009f273a281bfe4ee84d9872, 'XOXO', 18) + , (0xf9b2ebdfa24688f0dfb12cc55782e635f91e64a2, 'CLEO', 18) ) AS temp_table (contract_address, symbol, decimals) From 7f636d2cb12e458a064a5d55a3728742a9667dcd Mon Sep 17 00:00:00 2001 From: Andrew <47720952+andrewhong5297@users.noreply.github.com> Date: Thu, 26 Sep 2024 12:00:19 -0400 Subject: [PATCH 102/127] adding token2022 support for orca swaps (#6811) * basic * fix? * QAed --- .../_sector/dex/dex_solana_base_trades.sql | 1 + .../orca_whirlpool/orca_whirlpool_schema.yml | 13 + .../orca_whirlpool_v2_base_trades.sql | 257 ++++++++++++++++++ .../orca_whirlpool_trades_sources.yml | 5 +- 4 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 dbt_subprojects/solana/models/_sector/dex/orca_whirlpool/orca_whirlpool_v2_base_trades.sql diff --git a/dbt_subprojects/solana/models/_sector/dex/dex_solana_base_trades.sql b/dbt_subprojects/solana/models/_sector/dex/dex_solana_base_trades.sql index ad9e2b60a09..3816731b919 100644 --- a/dbt_subprojects/solana/models/_sector/dex/dex_solana_base_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/dex_solana_base_trades.sql @@ -13,6 +13,7 @@ {% set solana_dexes = [ ref('orca_whirlpool_base_trades') + , ref('orca_whirlpool_v2_base_trades') , ref('raydium_v3_base_trades') , ref('raydium_v4_base_trades') , ref('phoenix_v1_base_trades') diff --git a/dbt_subprojects/solana/models/_sector/dex/orca_whirlpool/orca_whirlpool_schema.yml b/dbt_subprojects/solana/models/_sector/dex/orca_whirlpool/orca_whirlpool_schema.yml index 75576e495ae..2eb319d5473 100644 --- a/dbt_subprojects/solana/models/_sector/dex/orca_whirlpool/orca_whirlpool_schema.yml +++ b/dbt_subprojects/solana/models/_sector/dex/orca_whirlpool/orca_whirlpool_schema.yml @@ -14,6 +14,19 @@ models: - dbt_utils.unique_combination_of_columns: combination_of_columns: [ 'tx_id', 'outer_instruction_index', 'inner_instruction_index', 'tx_index', 'block_month' ] + - name: orca_whirlpool_v2_base_trades + meta: + blockchain: solana + contributors: [ ilemi ] + config: + tags: [ 'solana','dex' ] + description: > + all raw whirlpool dex trades on Solana + tests: + - check_columns_solana_dex_trades + - dbt_utils.unique_combination_of_columns: + combination_of_columns: [ 'tx_id', 'outer_instruction_index', 'inner_instruction_index', 'tx_index', 'block_month' ] + - name: orca_whirlpool_trades meta: blockchain: solana diff --git a/dbt_subprojects/solana/models/_sector/dex/orca_whirlpool/orca_whirlpool_v2_base_trades.sql b/dbt_subprojects/solana/models/_sector/dex/orca_whirlpool/orca_whirlpool_v2_base_trades.sql new file mode 100644 index 00000000000..12782363d95 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/orca_whirlpool/orca_whirlpool_v2_base_trades.sql @@ -0,0 +1,257 @@ + {{ + config( + + schema = 'orca_whirlpool_v2', + alias = 'base_trades', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['tx_id', 'outer_instruction_index', 'inner_instruction_index', 'tx_index','block_month'], + pre_hook='{{ enforce_join_distribution("PARTITIONED") }}' + ) +}} + +{% set project_start_date = '2024-05-27' %} --blocktime of upgrade is 268396603 +--you can QA with the tx id 2P2hcK79CV82MqjXa6S4xxKoTHkgqmYkszWkxY1KmASvCek8YfSekSrB8rtdRJSTUYYyuCVxMXFrQd11bXDZqn6K + +with + whirlpools as ( + with + fee_tiers_defaults as ( + --the fee tier has defaults that can be changed. Once the pool is initialized, the fee tier is set to the default fee tier. + SELECT + account_feeTier as fee_tier + , defaultfeeRate as fee_rate + , call_block_time as fee_time + FROM {{ source('whirlpool_solana', 'whirlpool_call_initializeFeeTier') }} + + UNION ALL + + SELECT + account_feeTier as fee_tier + , defaultfeeRate as fee_rate + , call_block_time as fee_time + FROM {{ source('whirlpool_solana', 'whirlpool_call_setDefaultFeeRate') }} + ) + + --https://docs.orca.so/reference/trading-fees, should track protocol fees too. and rewards. + , fee_updates as ( + SELECT + whirlpool_id + , update_time + , fee_rate + FROM ( + --get defaultFeeRate at time of pool init based on account_feeTier + SELECT + fi.account_whirlpool as whirlpool_id + , fi.call_block_time as update_time + , fi.account_feeTier as fee_tier + , ftd.fee_time + , ftd.fee_rate + , row_number() over (partition by fi.account_whirlpool order by ftd.fee_time desc) as recent_update + FROM {{ source('whirlpool_solana', 'whirlpool_call_initializePoolV2') }} fi + LEFT JOIN fee_tiers_defaults ftd ON ftd.fee_tier = account_feeTier AND ftd.fee_time <= fi.call_block_time + ) + WHERE recent_update = 1 + + UNION all + + --after being initialized, the fee rate can be set manually using setFeeRate on the pool (does not update with defaultFeeRate) + SELECT + account_whirlpool as whirlpool_id + , call_block_time as update_time + , feeRate as fee_rate + FROM {{ source('whirlpool_solana', 'whirlpool_call_setFeeRate') }} + ) + + SELECT + account_tokenMintA as tokenA + , account_tokenVaultA as tokenAVault + , account_tokenMintB as tokenB + , account_tokenVaultB as tokenBVault + , ip.tickSpacing + , ip.account_whirlpool as whirlpool_id + , fu.update_time + , fu.fee_rate + , ip.call_tx_id as init_tx + FROM {{ source('whirlpool_solana', 'whirlpool_call_initializePoolV2') }} ip + LEFT JOIN fee_updates fu ON fu.whirlpool_id = ip.account_whirlpool + ) + + , two_hop as ( + SELECT + account_whirlpoolOne as account_whirlpool + , call_outer_instruction_index + , call_inner_instruction_index + , call_is_inner + , call_tx_signer + , call_tx_id + , call_tx_index + , call_block_time + , call_block_slot + , call_outer_executing_account + FROM {{ source('whirlpool_solana', 'whirlpool_call_twoHopSwapV2') }} sp + + UNION ALL + + --for second hop, we're going to spoof things so that the join on +1 and +2 still work just fine. + --this might not work in our token extension case since +2 is not guaranteed + SELECT + account_whirlpoolTwo as account_whirlpool + , call_outer_instruction_index + , COALESCE(call_inner_instruction_index,0) + 2 as call_inner_instruction_index + , true as call_is_inner + , call_tx_signer + , call_tx_id + , call_tx_index + , call_block_time + , call_block_slot + , call_outer_executing_account + FROM {{ source('whirlpool_solana', 'whirlpool_call_twoHopSwapV2') }} sp + ) + + , all_swaps as ( + SELECT + sp.call_block_time as block_time + , sp.call_block_slot as block_slot + , 'whirlpool' as project + , 2 as version + , 'solana' as blockchain + , case when sp.call_outer_executing_account = 'whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc' then 'direct' + else sp.call_outer_executing_account + end as trade_source + -- token bought is always the second instruction (transfer) in the inner instructions + , tr_2.amount as token_bought_amount_raw + , tr_1.amount as token_sold_amount_raw + , wp.fee_rate + , wp.whirlpool_id + , sp.call_tx_signer as trader_id + , sp.call_tx_id as tx_id + , sp.call_outer_instruction_index as outer_instruction_index + , COALESCE(sp.call_inner_instruction_index, 0) as inner_instruction_index + , sp.call_tx_index as tx_index + , case when tr_1.token_mint_address = wp.tokenA then wp.tokenB + else wp.tokenA + end as token_bought_mint_address + , case when tr_1.token_mint_address = wp.tokenA then wp.tokenA + else wp.tokenB + end as token_sold_mint_address + , case when tr_1.token_mint_address = wp.tokenA then wp.tokenBVault + else wp.tokenAVault + end as token_bought_vault + , case when tr_1.token_mint_address = wp.tokenA + then wp.tokenAVault + else wp.tokenBVault + end as token_sold_vault + , wp.update_time + --we need a row_number for the transfer out filter to get the first transfer out from the tr_2 join + , row_number() over (partition by sp.call_tx_id, sp.call_outer_instruction_index, sp.call_inner_instruction_index + order by COALESCE(tr_2.inner_instruction_index, 0) asc) as first_transfer_out + FROM ( + SELECT + account_whirlpool + , call_outer_instruction_index + , call_inner_instruction_index + , call_is_inner + , call_tx_signer + , call_tx_id + , call_tx_index + , call_block_time + , call_block_slot + , call_outer_executing_account + FROM {{ source('whirlpool_solana', 'whirlpool_call_swapV2') }} + WHERE 1=1 + {% if is_incremental() %} + AND {{incremental_predicate('call_block_time')}} + {% else %} + AND call_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + + UNION ALL + + SELECT * FROM two_hop + WHERE 1=1 + {% if is_incremental() %} + AND {{incremental_predicate('call_block_time')}} + {% else %} + AND call_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + sp + INNER JOIN whirlpools wp + ON sp.account_whirlpool = wp.whirlpool_id + AND sp.call_block_time >= wp.update_time + --join on memo program at index + 1 to see if the first token has memo extension active or not. if active everything gets offset by 1 + LEFT JOIN {{ source('solana', 'instruction_calls')}} memo + ON memo.tx_id = sp.call_tx_id + AND memo.block_slot = sp.call_block_slot + AND memo.outer_instruction_index = sp.call_outer_instruction_index + AND ((sp.call_is_inner = false AND memo.inner_instruction_index = 1) + OR (sp.call_is_inner = true AND memo.inner_instruction_index = sp.call_inner_instruction_index + 1) + ) + AND memo.executing_account = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr' + {% if is_incremental() %} + AND {{incremental_predicate('memo.block_time')}} + {% else %} + AND memo.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + --token extension transfer could be preceeded by the memo program and followed by a post execution hook + even potentially more instructions. + INNER JOIN {{ ref('tokens_solana_transfers') }} tr_1 + ON tr_1.tx_id = sp.call_tx_id + AND tr_1.block_slot = sp.call_block_slot + AND tr_1.outer_instruction_index = sp.call_outer_instruction_index + AND ((sp.call_is_inner = false AND tr_1.inner_instruction_index = CASE WHEN memo.tx_id IS NOT NULL THEN 2 ELSE 1 END) + OR (sp.call_is_inner = true AND tr_1.inner_instruction_index = sp.call_inner_instruction_index + CASE WHEN memo.tx_id IS NOT NULL THEN 2 ELSE 1 END)) + {% if is_incremental() %} + AND {{incremental_predicate('tr_1.block_time')}} + {% else %} + AND tr_1.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + INNER JOIN {{ ref('tokens_solana_transfers') }} tr_2 + ON tr_2.tx_id = sp.call_tx_id + AND tr_2.block_slot = sp.call_block_slot + AND tr_2.outer_instruction_index = sp.call_outer_instruction_index + AND ((sp.call_is_inner = false AND (tr_2.inner_instruction_index >= CASE WHEN memo.tx_id IS NOT NULL THEN 3 ELSE 2 END)) + OR (sp.call_is_inner = true AND (tr_2.inner_instruction_index >= sp.call_inner_instruction_index + CASE WHEN memo.tx_id IS NOT NULL THEN 3 ELSE 2 END)) + ) + {% if is_incremental() %} + AND {{incremental_predicate('tr_2.block_time')}} + {% else %} + AND tr_2.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + +SELECT + tb.blockchain + , tb.project + , tb.version + , CAST(date_trunc('month', tb.block_time) AS DATE) as block_month + , tb.block_time + , tb.block_slot + , tb.trade_source + , tb.token_bought_amount_raw + , tb.token_sold_amount_raw + , cast(tb.fee_rate as double)/1000000 as fee_tier + , tb.token_sold_mint_address + , tb.token_bought_mint_address + , tb.token_sold_vault + , tb.token_bought_vault + , tb.whirlpool_id as project_program_id + , 'whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc' as project_main_id + , tb.trader_id + , tb.tx_id + , tb.outer_instruction_index + , tb.inner_instruction_index + , tb.tx_index + , recent_update +FROM ( + SELECT + * + , row_number() OVER (partition by tx_id, outer_instruction_index, inner_instruction_index, tx_index order by update_time desc) as recent_update + FROM all_swaps + WHERE first_transfer_out = 1 + ) + tb +WHERE recent_update = 1 diff --git a/sources/orca_whirlpool/orca_whirlpool_trades_sources.yml b/sources/orca_whirlpool/orca_whirlpool_trades_sources.yml index 9c0b7183c69..ee2c9ce0519 100644 --- a/sources/orca_whirlpool/orca_whirlpool_trades_sources.yml +++ b/sources/orca_whirlpool/orca_whirlpool_trades_sources.yml @@ -5,8 +5,11 @@ sources: description: "whirlpool decoded tables" tables: - name: whirlpool_call_initializePool - - name: whirlpool_call_setFeeRate - name: whirlpool_call_swap - name: whirlpool_call_twoHopSwap + - name: whirlpool_call_initializePoolV2 + - name: whirlpool_call_swapV2 + - name: whirlpool_call_twoHopSwapV2 + - name: whirlpool_call_setFeeRate - name: whirlpool_call_initializeFeeTier - name: whirlpool_call_setDefaultFeeRate From 2caeeba2f0d8f39169c07536d598d9b436333944 Mon Sep 17 00:00:00 2001 From: max-morrow Date: Thu, 26 Sep 2024 22:10:38 +0300 Subject: [PATCH 103/127] implemented trusted tokens logic to 1inch lineage (#6841) --- .../dex/models/_projects/oneinch/oneinch_swaps.sql | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql b/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql index f47c3a226a5..3353812373d 100644 --- a/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql +++ b/dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql @@ -143,6 +143,15 @@ tokens as ( and cardinality(call_trace_address) = 0 ) +, trusted_tokens as ( + select + blockchain as transfer_blockchain + , contract_address + , true as trusted + from {{ source('prices', 'trusted_tokens') }} + group by 1, 2, 3 +) + {% set src_condition = 'contract_address = _src_token_address' %} {% set dst_condition = 'contract_address = _dst_token_address' %} {% set symbol = 'coalesce(symbol, token_symbol)' %} @@ -173,7 +182,9 @@ tokens as ( , max(amount) filter(where {{ src_condition }} and amount <= src_token_amount) as _src_token_amount_true -- take only src token amounts less than in the call , max(amount) filter(where {{ dst_condition }} and amount <= dst_token_amount) as _dst_token_amount_true -- take only dst token amounts less than in the call , max(amount * price / pow(10, {{ decimals }})) filter(where {{ src_condition }} and amount <= src_token_amount or {{ dst_condition }} and amount <= dst_token_amount) as sources_amount_usd + , max(amount * price / pow(10, {{ decimals }})) filter(where ({{ src_condition }} and amount <= src_token_amount or {{ dst_condition }} and amount <= dst_token_amount) and trusted) as sources_amount_usd_trusted , max(amount * price / pow(10, {{ decimals }})) as transfers_amount_usd + , max(amount * price / pow(10, {{ decimals }})) filter(where trusted) as transfers_amount_usd_trusted -- src $ amount from user , sum(amount * if(user = transfer_from, price, -price) / pow(10, {{ decimals }})) filter(where {{ src_condition }} and user in (transfer_from, transfer_to)) as _amount_usd_from_user @@ -207,6 +218,7 @@ tokens as ( ) using(blockchain, block_number, tx_hash, call_trace_address) -- block_number is needed for performance left join prices using(transfer_blockchain, contract_address, minute) left join tokens using(transfer_blockchain, contract_address) + left join trusted_tokens using(transfer_blockchain, contract_address) group by 1, 2, 3, 4, 5 ) @@ -256,7 +268,7 @@ select , coalesce(_dst_token_symbol_to_user, _dst_token_symbol_to_receiver, _dst_token_symbol) as dst_token_symbol , dst_token_decimals , coalesce(_dst_token_amount_true, dst_token_amount) as dst_token_amount - , coalesce(sources_amount_usd, transfers_amount_usd) as amount_usd -- sources $ amount first if found prices, then $ amount of connector tokens + , coalesce(sources_amount_usd_trusted, sources_amount_usd, transfers_amount_usd_trusted, transfers_amount_usd) as amount_usd -- sources $ amount first if found prices, then $ amount of connector tokens , sources_amount_usd , transfers_amount_usd , greatest(coalesce(_amount_usd_from_user, 0), coalesce(_amount_usd_to_user, _amount_usd_to_receiver, 0)) as user_amount_usd -- actual user $ amount From 85a13e0281e5a809b07103f34d04439b7b826c5e Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:01:44 -0400 Subject: [PATCH 104/127] update to median price per block (#6843) --- .../dex/models/prices/dex_prices_beta.sql | 52 ++++++++++++++----- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql index 477e7b3b862..2468371f394 100644 --- a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql +++ b/dbt_subprojects/dex/models/prices/dex_prices_beta.sql @@ -9,8 +9,9 @@ }} with dex_trades as ( - select distinct + select blockchain + , block_number , block_time , token_bought_address , token_bought_amount_raw @@ -34,6 +35,7 @@ dex_bought as ( , d.token_bought_address as contract_address , t.symbol as symbol , t.decimals as decimals + , d.block_number as block_number , d.block_time as block_time , d.token_bought_amount as amount , d.amount_usd @@ -60,6 +62,7 @@ dex_sold as ( , d.token_sold_address as contract_address , t.symbol as symbol , t.decimals as decimals + , d.block_number as block_number , d.block_time as block_time , d.token_sold_amount as amount , d.amount_usd @@ -105,17 +108,38 @@ volume_filter as ( sum(amount_usd) >= 10000 ) select - dp.blockchain - , dp.contract_address - , dp.symbol - , dp.decimals - , cast(date_trunc('month', dp.block_time) as date) as block_month -- for partitioning - , dp.block_time - , dp.amount - , dp.amount_usd - , dp.price + blockchain + , contract_address + , symbol + , decimals + , block_number + , cast(date_trunc('month', block_time) as date) as block_month -- for partitioning + , block_time + , amount + , amount_usd + , price from - dex_prices as dp -inner join volume_filter as vf - on dp.blockchain = vf.blockchain - and dp.contract_address = vf.contract_address \ No newline at end of file +( + select + dp.blockchain + , dp.contract_address + , dp.symbol + , dp.decimals + , dp.block_number + , dp.block_time + , sum(dp.amount) as amount + , sum(dp.amount_usd) as amount_usd + , approx_percentile(dp.price, 0.5) AS price + from + dex_prices as dp + inner join volume_filter as vf + on dp.blockchain = vf.blockchain + and dp.contract_address = vf.contract_address + group by + dp.blockchain + , dp.contract_address + , dp.symbol + , dp.decimals + , dp.block_number + , dp.block_time +) \ No newline at end of file From 7b6fc1cce4960ac481ead74988d88c57334e7c33 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:47:12 -0400 Subject: [PATCH 105/127] remove bad price feeds (#6845) --- dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql | 2 +- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql index ed895f4d0f8..e638e058d1c 100644 --- a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql @@ -274,7 +274,6 @@ FROM ('pepe-pepecoin-bsc', 'bnb', 'PEPE', 0xb46584e0efde3092e04010a13f2eae62adb3b9f0, 18), ('babydoge-baby-doge-coin', 'bnb', 'BABYDOGE', 0xc748673057861a797275cd8a068abb95a902e8de, 9), ('bwjup-bsc-wrapped-jupiter', 'bnb', 'bwJUP', 0x0231f91e02debd20345ae8ab7d71a41f8e140ce7, 18), - ('lovely-lovely-inu-finance', 'bnb', 'LOVELY', 0x9e24415d1e549ebc626a13a482bb117a2b43e9cf, 8), --('pvc-pvc-meta','bnb','PVC',0x75ca521892de7f2ecfb070cab545c250d0ceb7e3, 9), --token_id not found ('bvsd-bvsd','bnb','BVSD',0x7f9ad7a5854658d984924e868187b2135514fb88, 18), ('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18), @@ -289,4 +288,5 @@ where contract_address not in ( ,0x7ddee176f665cd201f93eede625770e2fd911990 -- GALA doesn't exists on BSC, it's a scam-token address. ,0xe552fb52a4f19e44ef5a967632dbc320b0820639 -- METIS has bad price feed since PolyNetwork incident and will be replaced by new contract ,0x9fdc3ae5c814b79dca2556564047c5e7e5449c19 -- DG, bad price feed + ,0x9e24415d1e549ebc626a13a482bb117a2b43e9cf -- LOVELY, rugpull ) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index b5fef3747e1..9e37d5e8f5c 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1839,7 +1839,6 @@ FROM ('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18), ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8), ('msn-mesonnetwork', 'ethereum', 'MSN', 0xaa247c0d81b83812e1abf8bab078e4540d87e3fb, 18), - ('bubble-imaginary-ones', 'ethereum', 'BUBBLE', 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 18), ('zeta-zetachain', 'ethereum', 'ZETA', 0xf091867ec603a6628ed83d274e835539d82e9cc8, 18), ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18), ('sky-sky', 'ethereum', 'SKY', 0x56072C95FAA701256059aa122697B133aDEd9279, 18) @@ -1869,4 +1868,5 @@ where contract_address not in ( ,0x630d98424efe0ea27fb1b3ab7741907dffeaad78 -- PEAKDEFI ,0xee06a81a695750e71a662b51066f2c74cf4478a0 -- DG, bad price feed ,0x9e24415d1e549ebc626a13a482bb117a2b43e9cf -- LOVELY, rugpull + ,0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 -- BUBBLE, bad price feed ) From ab3369546a6f436dc19265c87559468732318f5f Mon Sep 17 00:00:00 2001 From: Rantum Date: Fri, 27 Sep 2024 06:40:54 -0700 Subject: [PATCH 106/127] add gho, dyad (#6840) --- .../tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql index 69adcbb06ef..a2233cdf6e1 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql @@ -79,6 +79,8 @@ FROM (VALUES ('ethereum', 0xcfc5bd99915aaa815401c5a41a927ab7a38d29cf, 'Crypto-backed stablecoin', 'thUSD', 18, ''), ('ethereum', 0xdf3ac4f479375802a821f7b7b46cd7eb5e4262cc, 'Crypto-backed stablecoin', 'eUSD', 18, ''), ('ethereum', 0xbbaec992fc2d637151daf40451f160bf85f3c8c1, 'Crypto-backed stablecoin', 'USDM', 6, ''), - ('ethereum', 0x7945b0a6674b175695e5d1d08ae1e6f13744abb0, 'Crypto-backed stablecoin', 'BaoUSD', 18, '') + ('ethereum', 0x7945b0a6674b175695e5d1d08ae1e6f13744abb0, 'Crypto-backed stablecoin', 'BaoUSD', 18, ''), + ('ethereum', 0x40d16fc0246ad3160ccc09b8d0d3a2cd28ae6c2f, 'Crypto-backed stablecoin', 'GHO', 18, ''), + ('ethereum', 0xfd03723a9a3abe0562451496a9a394d2c4bad4ab, 'Crypto-backed stablecoin', 'DYAD', 18, '') ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) From 125a91111868996534fc0527d7df05bb509506ff Mon Sep 17 00:00:00 2001 From: Bob Baxley Date: Fri, 27 Sep 2024 09:41:33 -0400 Subject: [PATCH 107/127] enable maverick v2 on zksync (#6842) --- .../trades/zksync/platforms/maverick_v2_zksync_base_trades.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/dbt_subprojects/dex/models/trades/zksync/platforms/maverick_v2_zksync_base_trades.sql b/dbt_subprojects/dex/models/trades/zksync/platforms/maverick_v2_zksync_base_trades.sql index 74933cc4505..16d2fd40861 100644 --- a/dbt_subprojects/dex/models/trades/zksync/platforms/maverick_v2_zksync_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/zksync/platforms/maverick_v2_zksync_base_trades.sql @@ -1,6 +1,5 @@ {{ config( - tags = ['prod_exclude'], schema = 'maverick_v2_zksync', alias = 'base_trades', materialized = 'incremental', From 92c3fd3c6f10a5d1f1c84fa32ec71f7748000006 Mon Sep 17 00:00:00 2001 From: Huang Geyang Date: Fri, 27 Sep 2024 21:41:43 +0800 Subject: [PATCH 108/127] Add firebird_finance_optimism_base_trades (#6816) * Add firebird_finance_optimism_base_trades * Refactor firebird_finance_optimism_trades --- .../firebird_finance/optimism/_schema.yml | 45 ++++++- .../firebird_finance_optimism_base_trades.sql | 73 +++++++++++ .../firebird_finance_optimism_trades.sql | 121 ++---------------- .../dex_aggregator_base_trades.sql | 1 + .../dex_aggregator_trades.sql | 1 - 5 files changed, 127 insertions(+), 114 deletions(-) create mode 100644 dbt_subprojects/dex/models/_projects/firebird_finance/optimism/firebird_finance_optimism_base_trades.sql diff --git a/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/_schema.yml b/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/_schema.yml index d28e89bb0e1..94b10960ae3 100644 --- a/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/_schema.yml @@ -96,4 +96,47 @@ models: description: "" - &trace_address name: trace_address - description: "" \ No newline at end of file + description: "" + + - name: firebird_finance_optimism_base_trades + meta: + blockchain: optimism + sector: dex + project: firebird_finance + contributors: ARDev097, hosuke + config: + tags: [ 'optimism','trades', 'firebird_finance','dex' ] + description: > + firebird_finance dex base trades on optimism + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - blockchain + - project + - version + - tx_hash + - evt_index + - check_dex_aggregator_seed: + blockchain: optimism + project: firebird_finance + version: 1 + columns: + - *blockchain + - *project + - *version + - *block_date + - *block_time + - *token_bought_amount_raw + - *token_sold_amount_raw + - *token_bought_address + - *token_sold_address + - *taker + - *maker + - *project_contract_address + - *tx_hash + - *tx_from + - *tx_to + - *trace_address + - *evt_index + - *block_month \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/firebird_finance_optimism_base_trades.sql b/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/firebird_finance_optimism_base_trades.sql new file mode 100644 index 00000000000..0b025e9d5d9 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/firebird_finance_optimism_base_trades.sql @@ -0,0 +1,73 @@ +{{ config( + alias='base_trades', + schema='firebird_finance_optimism', + partition_by=['block_month'], + materialized='incremental', + file_format='delta', + incremental_strategy='merge', + unique_key=['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index'] + ) +}} + +{% set project_start_date = '2022-07-11' %} +{% set firebird_finance_optimism_evt_trade_tables = [ + source('firebird_finance_optimism', 'FireBirdRouter_evt_Swapped') +] %} + +with dexs as ( + {% for evt_trade_table in firebird_finance_optimism_evt_trade_tables %} + SELECT + evt_block_time AS block_time, + sender AS taker, + CAST(NULL as VARBINARY) AS maker, + returnAmount AS token_bought_amount_raw, + spentAmount AS token_sold_amount_raw, + CAST(NULL AS double) AS amount_usd, + dstToken AS token_bought_address, + srcToken AS token_sold_address, + contract_address AS project_contract_address, + evt_tx_hash AS tx_hash, + array[-1] AS trace_address, + evt_index + FROM {{ evt_trade_table }} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% else %} + WHERE evt_block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + + {% if not loop.last %} + UNION ALL + {% endif %} + + {% endfor %} +) + +SELECT + 'optimism' AS blockchain, + 'firebird_finance' AS project, + '1' AS version, + TRY_CAST(date_trunc('DAY', dexs.block_time) AS date) AS block_date, + TRY_CAST(date_trunc('MONTH', dexs.block_time) AS date) AS block_month, + dexs.block_time, + dexs.token_bought_amount_raw AS token_bought_amount_raw, + dexs.token_sold_amount_raw AS token_sold_amount_raw, + dexs.token_bought_address, + dexs.token_sold_address, + COALESCE(dexs.taker, tx."from") AS taker, + dexs.maker, + dexs.project_contract_address, + dexs.tx_hash, + tx."from" AS tx_from, + tx.to AS tx_to, + dexs.evt_index, + dexs.trace_address +FROM dexs +INNER JOIN {{ source('optimism', 'transactions') }} tx + ON dexs.tx_hash = tx.hash + {% if not is_incremental() %} + AND tx.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + {% if is_incremental() %} + AND {{ incremental_predicate('tx.block_time') }} + {% endif %} \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/firebird_finance_optimism_trades.sql b/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/firebird_finance_optimism_trades.sql index 095a1b136f6..268059bfdad 100644 --- a/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/firebird_finance_optimism_trades.sql +++ b/dbt_subprojects/dex/models/_projects/firebird_finance/optimism/firebird_finance_optimism_trades.sql @@ -1,118 +1,15 @@ {{ config( alias='trades', schema='firebird_finance_optimism', - partition_by=['block_month'], - materialized='incremental', - file_format='delta', - incremental_strategy='merge', - unique_key=['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index'], - post_hook='{{ expose_spells(\'["optimism"]\', - "project", - "firebird_finance", - \'["ARDev097"]\') }}' + materialized='view', + post_hook='{{ expose_spells(blockchains = \'["optimism"]\', + spell_type = "project", + spell_name = "firebird_finance", + contributors = \'["ARDev097", "hosuke"]\') }}' ) }} -{% set project_start_date = '2022-07-11' %} -{% set firebird_finance_optimism_evt_trade_tables = [ - source('firebird_finance_optimism', 'FireBirdRouter_evt_Swapped') -] %} - -with dexs as ( - {% for evt_trade_table in firebird_finance_optimism_evt_trade_tables %} - SELECT - evt_block_time AS block_time, - sender AS taker, - CAST(NULL as VARBINARY) AS maker, - returnAmount AS token_bought_amount_raw, - spentAmount AS token_sold_amount_raw, - CAST(NULL AS double) AS amount_usd, - dstToken AS token_bought_address, - srcToken AS token_sold_address, - contract_address AS project_contract_address, - evt_tx_hash AS tx_hash, - array[-1] AS trace_address, - evt_index - FROM {{ evt_trade_table }} - {% if is_incremental() %} - WHERE evt_block_time >= date_trunc('day', now() - interval '7' day) - {% else %} - WHERE evt_block_time >= TIMESTAMP '{{project_start_date}}' - {% endif %} - - {% if not loop.last %} - UNION ALL - {% endif %} - - {% endfor %} -) - -SELECT - 'optimism' AS blockchain, - 'firebird_finance' AS project, - '1' AS version, - TRY_CAST(date_trunc('DAY', dexs.block_time) AS date) AS block_date, - TRY_CAST(date_trunc('MONTH', dexs.block_time) AS date) AS block_month, - dexs.block_time, - erc20a.symbol AS token_bought_symbol, - erc20b.symbol AS token_sold_symbol, - CASE - WHEN lower(erc20a.symbol) > lower(erc20b.symbol) - THEN concat(erc20b.symbol, '-', erc20a.symbol) - ELSE concat(erc20a.symbol, '-', erc20b.symbol) - END AS token_pair, - dexs.token_bought_amount_raw / power(10, erc20a.decimals) AS token_bought_amount, - dexs.token_sold_amount_raw / power(10, erc20b.decimals) AS token_sold_amount, - dexs.token_bought_amount_raw AS token_bought_amount_raw, - dexs.token_sold_amount_raw AS token_sold_amount_raw, - COALESCE( - dexs.amount_usd, - (dexs.token_bought_amount_raw / power(10, erc20a.decimals)) * p_bought.price, - (dexs.token_sold_amount_raw / power(10, erc20b.decimals)) * p_sold.price - ) AS amount_usd, - dexs.token_bought_address, - dexs.token_sold_address, - COALESCE(dexs.taker, tx."from") AS taker, - dexs.maker, - dexs.project_contract_address, - dexs.tx_hash, - tx."from" AS tx_from, - tx.to AS tx_to, - dexs.evt_index, - dexs.trace_address -FROM dexs -INNER JOIN {{ source('optimism', 'transactions') }} tx - ON dexs.tx_hash = tx.hash - {% if not is_incremental() %} - AND tx.block_time >= TIMESTAMP '{{project_start_date}}' - {% endif %} - {% if is_incremental() %} - AND tx.block_time >= date_trunc('day', now() - interval '7' day) - {% endif %} -LEFT JOIN {{ source('tokens', 'erc20') }} erc20a - ON erc20a.contract_address = dexs.token_bought_address - AND erc20a.blockchain = 'optimism' -LEFT JOIN {{ source('tokens', 'erc20') }} erc20b - ON erc20b.contract_address = dexs.token_sold_address - AND erc20b.blockchain = 'optimism' -LEFT JOIN {{ source('prices', 'usd') }} p_bought - ON p_bought.minute = date_trunc('minute', dexs.block_time) - AND p_bought.contract_address = dexs.token_bought_address - AND p_bought.blockchain = 'optimism' - {% if not is_incremental() %} - AND p_bought.minute >= TIMESTAMP '{{project_start_date}}' - {% endif %} - {% if is_incremental() %} - AND p_bought.minute >= date_trunc('day', now() - interval '7' day) - {% endif %} -LEFT JOIN {{ source('prices', 'usd') }} p_sold - ON p_sold.minute = date_trunc('minute', dexs.block_time) - AND p_sold.contract_address = dexs.token_sold_address - AND p_sold.blockchain = 'optimism' - {% if not is_incremental() %} - AND p_sold.minute >= TIMESTAMP '{{project_start_date}}' - {% endif %} - {% if is_incremental() %} - AND p_sold.minute >= date_trunc('day', now() - interval '7' day) - {% endif %} - +SELECT * +FROM {{ ref('dex_aggregator_trades') }} +WHERE project = 'firebird_finance' + AND blockchain = 'optimism' diff --git a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_base_trades.sql b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_base_trades.sql index 9b7ee783f7e..21d6c86acf6 100644 --- a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_base_trades.sql +++ b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_base_trades.sql @@ -12,6 +12,7 @@ {% set base_trade_models = [ ref('lifi_base_trades') + , ref('firebird_finance_optimism_base_trades') ] %} with base_union as ( diff --git a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql index ff4aefc4cb0..a153eb875df 100644 --- a/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql +++ b/dbt_subprojects/dex/models/aggregator_trades/dex_aggregator_trades.sql @@ -22,7 +22,6 @@ ,ref('zeroex_trades') ,ref('kyberswap_aggregator_trades') ,ref('tokenlon_trades') - ,ref('firebird_finance_optimism_trades') ,ref('oneinch_ar_trades') ,ref('unidex_optimism_trades') ,ref('odos_trades') From f99d3464391ac15add839c6a979d04d8c3057f8e Mon Sep 17 00:00:00 2001 From: clizzard <145153355+clizzard7@users.noreply.github.com> Date: Fri, 27 Sep 2024 15:42:47 +0200 Subject: [PATCH 109/127] add jubot (#6835) * add jubot add jupbot sql and add to schema * update schema.yml * add seed * moved seedfile * fixed typo * seed from test query --------- Co-authored-by: whale_hunter <143016036+whalehunting@users.noreply.github.com> --- .../_sector/dex/bot_trades/solana/_schema.yml | 25 ++- .../platforms/jupbot_solana_bot_trades.sql | 151 ++++++++++++++++++ .../jupbot/jupbot_solana_trades_seed.csv | 21 +++ 3 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/jupbot_solana_bot_trades.sql create mode 100644 dbt_subprojects/solana/seeds/jupbot/jupbot_solana_trades_seed.csv diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml index 270652d829a..7b3cb551e7d 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/_schema.yml @@ -533,5 +533,26 @@ models: tags: ["solana", "dex", "bot_trades"] columns: - name: user - tests: unique - + tests: unique + + - name: jupbot_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: jupbot + contributors: whale_hunter + config: + tags: ["solana", "dex", "jupbot", "trades"] + description: > + Jupbot trades on Solana + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - tx_id + - tx_index + - outer_instruction_index + - inner_instruction_index + - check_bot_trades_seed: + seed_file: ref('jupbot_solana_trades_seed') + blockchain: solana \ No newline at end of file diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/jupbot_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/jupbot_solana_bot_trades.sql new file mode 100644 index 00000000000..3c8080a89a5 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/jupbot_solana_bot_trades.sql @@ -0,0 +1,151 @@ +{{ config( + alias = 'bot_trades', + schema = 'jupbot_solana', + partition_by = ['block_month'], + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + unique_key = ['blockchain', 'tx_id', 'tx_index', 'outer_instruction_index', 'inner_instruction_index'] + ) +}} + +{% set project_start_date = '2024-09-12' %} +{% set buy_fee_receiver_1 = 'H2mM9cXi42efgwkSzTRKMVaWHrqJJx1nzNdV1NxWaHjC' %} +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + balance_change / 1e9 AS fee_token_amount, + '{{wsol_token}}' AS fee_token_mint_address + FROM + {{ source('solana','account_activity') }} + WHERE + {% if is_incremental() %} + {{ incremental_predicate('block_time') }} + {% else %} + block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + AND tx_success + AND balance_change > 0 + AND address = '{{buy_fee_receiver_1}}' + + ), + botTrades AS ( + SELECT + trades.block_time, + CAST(date_trunc('day', trades.block_time) AS date) AS block_date, + CAST(date_trunc('month', trades.block_time) AS date) AS block_month, + 'solana' AS blockchain, + amount_usd, + IF( + token_sold_mint_address = '{{wsol_token}}', + 'Buy', + 'Sell' + ) AS type, + token_bought_amount, + token_bought_symbol, + token_bought_mint_address AS token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_mint_address AS token_sold_address, + fee_token_amount * price AS fee_usd, + fee_token_amount, + IF(feeTokenType = 'SOL', 'SOL', symbol) AS fee_token_symbol, + fee_token_mint_address AS fee_token_address, + project, + version, + token_pair, + project_program_id AS project_contract_address, + trader_id AS user, + trades.tx_id, + tx_index, + outer_instruction_index, + inner_instruction_index + FROM + {{ ref('dex_solana_trades') }} AS trades + JOIN allFeePayments AS feePayments ON trades.tx_id = feePayments.tx_id + LEFT JOIN {{ source('prices', 'usd') }} AS feeTokenPrices ON ( + feeTokenPrices.blockchain = 'solana' + AND fee_token_mint_address = toBase58 (feeTokenPrices.contract_address) + AND date_trunc('minute', block_time) = minute + {% if is_incremental() %} + AND {{ incremental_predicate('minute') }} + {% else %} + AND minute >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + JOIN {{ source('solana','transactions') }} AS transactions ON ( + trades.tx_id = id + {% if is_incremental() %} + AND {{ incremental_predicate('transactions.block_time') }} + {% else %} + AND transactions.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ) + WHERE + trades.trader_id != '{{buy_fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{buy_fee_receiver_1}}' -- Exclude trades signed by FeeWallet + {% if is_incremental() %} + AND {{ incremental_predicate('trades.block_time') }} + {% else %} + AND trades.block_time >= TIMESTAMP '{{project_start_date}}' + {% endif %} + ), + highestInnerInstructionIndexForEachTrade AS ( + SELECT + tx_id, + outer_instruction_index, + MAX(inner_instruction_index) AS highestInnerInstructionIndex + FROM + botTrades + GROUP BY + tx_id, + outer_instruction_index + ) +SELECT + block_time, + block_date, + block_month, + 'Jupbot' as bot, + blockchain, + amount_usd, + type, + token_bought_amount, + token_bought_symbol, + token_bought_address, + token_sold_amount, + token_sold_symbol, + token_sold_address, + fee_usd, + fee_token_amount, + fee_token_symbol, + fee_token_address, + project, + version, + token_pair, + project_contract_address, + user, + botTrades.tx_id, + tx_index, + botTrades.outer_instruction_index, + COALESCE(inner_instruction_index, 0) AS inner_instruction_index, + IF( + inner_instruction_index = highestInnerInstructionIndex, + true, + false + ) AS is_last_trade_in_transaction +FROM + botTrades + JOIN highestInnerInstructionIndexForEachTrade ON ( + botTrades.tx_id = highestInnerInstructionIndexForEachTrade.tx_id + AND botTrades.outer_instruction_index = highestInnerInstructionIndexForEachTrade.outer_instruction_index + ) +ORDER BY + block_time DESC, + tx_index DESC, + outer_instruction_index DESC, + inner_instruction_index DESC diff --git a/dbt_subprojects/solana/seeds/jupbot/jupbot_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/jupbot/jupbot_solana_trades_seed.csv new file mode 100644 index 00000000000..ed7bd7a03cc --- /dev/null +++ b/dbt_subprojects/solana/seeds/jupbot/jupbot_solana_trades_seed.csv @@ -0,0 +1,21 @@ +block_time,block_date,block_month,bot,blockchain,amount_usd,type,token_bought_amount,token_bought_symbol,token_bought_address,token_sold_amount,token_sold_symbol,token_sold_address,fee_usd,fee_token_amount,fee_token_symbol,fee_token_address,project,version,token_pair,project_contract_address,user,tx_id,tx_index,outer_instruction_index,inner_instruction_index,is_last_trade_in_transaction +2024-09-22 22:05:57.000 UTC,2024-09-22,2024-09-01,Jupbot,solana,9.485474414359999,Sell,0.066883898,SOL,So11111111111111111111111111111111111111112,8541662.403881,RIZ0,rizo34MUwbCBqpSTSfnEktdWB4CTByqqYh8zBxL3WAR,0.18970935213999998,0.001337677,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-RIZ0,6nmiCc4QSXqjsNYWgPRBVtij7GdHfDTud71eEGqApqav,5MrieS7fwgyXxXyAAves9Fe3z76iG9c5xb6y7TJyg9jm,WB2eBeutgCmo3FTwQChLWM5wtjtA7VejtcVDUAtGRNvAQXoNqVKVUPpdPDdDqrMDMtjLe8o2B89kWuaTWV4455i,1207,3,1,true +2024-09-24 14:32:27.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,140.53687770696,Buy,19.29906357,HNT,hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux,0.968952549,SOL,So11111111111111111111111111111111111111112,31.230417171519996,0.215322788,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-HNT,91axdGmMoqQQg2MPUXKxT3bdqX4p2RMLXqZSQgXn2JpM,DvfLpvgbuPSBi4CWw6o6vEPMBxfYcwv9f9yBCqSybqJZ,59vpKFmYzC4vo8KVK3m9CC3Adwv9AvH7j5vvw1EdBR3BZ2wqkMa6AeY599eh9ALtLiSdp4ueHnrVL5hXQiuffvv8,878,7,2,false +2024-09-24 14:32:27.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,1420.9839871057598,Buy,195.14349727,HNT,hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux,9.797186894,SOL,So11111111111111111111111111111111111111112,31.230417171519996,0.215322788,SOL,So11111111111111111111111111111111111111112,whirlpool,1,SOL-HNT,CSP4RmB6kBHkKGkyTnzt9zYYXDA8SbZ5Do5WfZcjqjE4,DvfLpvgbuPSBi4CWw6o6vEPMBxfYcwv9f9yBCqSybqJZ,59vpKFmYzC4vo8KVK3m9CC3Adwv9AvH7j5vvw1EdBR3BZ2wqkMa6AeY599eh9ALtLiSdp4ueHnrVL5hXQiuffvv8,878,7,6,true +2024-09-19 17:55:09.000 UTC,2024-09-19,2024-09-01,Jupbot,solana,0.1403458,Buy,365.905989774,$PCORN,Ee4n93iv9vtY8cYcUEqFCpBtmCq1ZMKR3pLzPQsmDMY5,0.00098,SOL,So11111111111111111111111111111111111111112,0.002806916,0.0000196,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-$PCORN,FUJFiFpsZKkPhYpDviN2XN2S2vKbrvYKDEVPVZ8N6CPK,Ci1ar7awYyQYjTaFCoMtNNj3asw9mD59nBf5tMffTru7,2ZppJkVmStWbCWbBMcaX2NFPR6Fsm6pSe8ozFVQuQGAfdc5X6eR5DNeh23HA955AJAdtfMMP4ffb5RDYAsfeCSHX,33,5,1,true +2024-09-23 20:57:52.000 UTC,2024-09-23,2024-09-01,Jupbot,solana,893.2176223468562,Sell,0.001683402,,2e6NAJy1qaKMq8PaswP2uzimMDvbr71Tbw38G6q9SNZ2,893.042586,USDT,Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB,17.870368238759998,0.124384828,SOL,So11111111111111111111111111111111111111112,lifinity,2,,EiEAydLqSKFqRPpuwYoVxEJ6h9UZh9tsTaHgs4f8b8Z5,Cv8yQZhb2p4hLaWPF9RPwGSuVeBnQMM2X2Y7UjPmUwzB,57trXhPHMbPfDtaWoq9FV2UMnx4qBZF3pbCT9Nh4eVc8UBGkA7tZZWCKPfCaCd9Qibfr9hTgq1eJTjPbqgcMKxex,300,3,1,true +2024-09-24 17:48:21.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,557.300951807754,Buy,557.500537,USDT,Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB,3.76316083,SOL,So11111111111111111111111111111111111111112,11.15701913984,0.075263216,SOL,So11111111111111111111111111111111111111112,whirlpool,1,USDT-SOL,FwewVm8u6tFPGewAyHmWAqad9hmF7mvqxK4mJ7iNqqGC,Dup31RWDS3MTTGMiHZwuWMVchpyihtz12uX53BpzDXUT,2VixUV9nXftBMHtF2NVWgEQ8YpumsCMGtZPTwoP9Tfahvo9yoMndiKtJwRsmfLXUReXmuL78obmw2M8EfifB9nXB,134,7,2,true +2024-09-24 09:12:00.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,124.31130723228,Buy,19229.630419948,USEDCAR,9gwTegFJJErDpWJKjPfLr2g2zrE3nL1v5zpwbtsk3c6P,0.840054786,SOL,So11111111111111111111111111111111111111112,2.4862260380999994,0.016801095,SOL,So11111111111111111111111111111111111111112,raydium,4,USEDCAR-SOL,Cf628kRZSmUb5VZf6KGpRDRRxWRT8b4vLuYPEtLs73WD,HZB1puYqXJsj4XpPMHaEpWCQcxUFWmjNTufFCUosDPnd,PC3Ji6S7ZKAkZ3V1k4gcgp91AdVUKT5c9hstM1ZVUr5BS9fXNd79atNK3WiY9Q75zzz8sBvNvsaB7FLcDJZ4bow,194,6,1,true +2024-09-24 09:49:31.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,1724.495158701,Buy,19116.709495,MOTHER,3S8qX1MsMqRbiwKg2cQyx7nis1oHMgaCuc9c4VfvVdPN,11.731259583,SOL,So11111111111111111111111111111111111111112,34.489903077,0.234625191,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-MOTHER,HcPgh6B2yHNvT6JsEmkrHYT8pVHu9Xiaoxm4Mmn2ibWw,9fvVi6TDjMgRcPJ8y6GmyWuFwueReyCyoStToUFkM4So,5VyevQMA2wDQDcEEXiCGHKrWS5VeLmFV6RRPF4v9fcrmmbW5pJgeLD3Xhw2nAYGNMUL1ZcaJqZqSQoExRrrgWQJR,1430,7,1,true +2024-09-24 11:10:40.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,634.2138995739999,Sell,4.343930819,SOL,So11111111111111111111111111111111111111112,40983.562948,BRAINLET,8NNXWrWVctNw1UFeaBypffimTdcLCcD8XJzHvYsmgwpF,12.684277936,0.086878616,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BRAINLET,CW9DFoTWEUiwxyxVGnQFYhbrYEfGkvaqXEgxKZG7d7X1,27JwZFWWeHwPKM9Ua7ag8indKfE8zKXjBe91jj9AWZbN,3Vahc42snvcQwezC1t843LLmtqbgtLR2iufdfUA3kAUCFGJhpG6EKv3Nq95aCuySsENfBd97mgoLCsCCutFyWc7x,289,3,1,true +2024-09-22 05:52:18.000 UTC,2024-09-22,2024-09-01,Jupbot,solana,7.2299500000000005,Buy,328188.720296788,XP,HDdBA7kHSMpSyCJMcr3CWh7a6HU5cgVUpKADKWG71j8w,0.049,SOL,So11111111111111111111111111111111111111112,0.144599,0.00098,SOL,So11111111111111111111111111111111111111112,raydium,4,XP-SOL,2WpYE3efcuXCffkwzKz4BCH5Tm42sWFGHtVQGzgf6ZdS,5MrieS7fwgyXxXyAAves9Fe3z76iG9c5xb6y7TJyg9jm,45CxudRR76PyBM1Xar3YeSiEPLxTkpJJLkVp5YHUidzHJinRoo4kxYK7MEPDwbMRHGkCbhABZtQH7hq6T4pPvqVe,128,6,1,true +2024-09-19 18:19:58.000 UTC,2024-09-19,2024-09-01,Jupbot,solana,0.1405418,Buy,365.904209342,$PCORN,Ee4n93iv9vtY8cYcUEqFCpBtmCq1ZMKR3pLzPQsmDMY5,0.00098,SOL,So11111111111111111111111111111111111111112,0.0028108359999999997,0.0000196,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-$PCORN,FUJFiFpsZKkPhYpDviN2XN2S2vKbrvYKDEVPVZ8N6CPK,Ci1ar7awYyQYjTaFCoMtNNj3asw9mD59nBf5tMffTru7,3rBabEtvxHgxX5YJrW1uzAWXgzfTfhtoSWFuwUwoNkCvqnj9pGVLV22MaT88pbnWmspybbDVzxAHHpLAWmQcytqp,918,5,1,true +2024-09-23 15:44:42.000 UTC,2024-09-23,2024-09-01,Jupbot,solana,1080.6260739674499,Sell,7.486152227,SOL,So11111111111111111111111111111111111111112,29795.437741,hehe,BreuhVohXX5fv6q41uyb3sojtAuGoGaiAhKBMtcrpump,21.6125214014,0.149723044,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-hehe,23KJaRate7XthAQ7C5XbJJYK5cyG1sNA2ikCPsiAcbVP,5hT6rWEUyULoWux1h66CTjtNYxXBdxk5FiTfbKPKiEXG,4x4a4BA5R6oyqW65KjQrL4aXUT8ATDMQqp8MNaAUUZBKy4qE3SvhQzN8V1pUNZr7Hz9RD3yU2oBZ7dMokciuEq5z,145,3,1,true +2024-09-24 07:52:24.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,296.32371093252,Sell,2.018828934,SOL,So11111111111111111111111111111111111111112,1.655689816,mSOL,mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So,5.926474118840001,0.040376578,SOL,So11111111111111111111111111111111111111112,meteora,1,SOL-mSOL,HcjZvfeSNJbNkfLD4eEcRBr96AD3w1GpmMppaeRZf7ur,6ozPcBDF7opwtmg8EkQwiYRC2FwGnbeGHu5w8aQBN1PE,3y2Y7RYmwwtGjzWZX4AWYidcf7cAHnEhQB6oedWAHHBMFNHD84c328Q8BM2fykKfMQBffao6PuGXTEYHumsgRjS3,1447,4,1,true +2024-09-21 15:55:21.000 UTC,2024-09-21,2024-09-01,Jupbot,solana,5.7929759999999995,Buy,5616.738498,BONKEY,6y4rgKVoPUc8HMcnWfca8siuBa3gAjxNaRrHxVmMpump,0.0392,SOL,So11111111111111111111111111111111111111112,0.11585952,0.000784,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-BONKEY,BecDGSmGxdiiQV6pMCf1evuNjmgNB4mJhCseNSshrhcD,7DtLV4eguy7Eg9Wf6AehfjfjSZNFwYE4TGqk4Fob6vHE,5zkRQybxM2XigDy5UyFQZ7ZQuMZMB5pb27xepke5G8Nz8xt9PtPdrgjX5uKBAv49bubf7q5tKpayoewnduUuA92d,1382,6,1,true +2024-09-25 01:13:05.000 UTC,2024-09-25,2024-09-01,Jupbot,solana,494.92799795428,Sell,0.070543,,DriFtupJYLTosbwoN8koMbEYSx54aFAVLddWsbksjwg7,494.89484,USDC,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,9.888836797799998,0.06499827,SOL,So11111111111111111111111111111111111111112,phoenix,1,,8BV6rrWsUabnTDA3dE6A69oUDJAj3hMhtBHTJyXB7czp,ET71c3wQF92i4EGn5aztAMYPszmZrE8AJFLvyLTBAqqw,2ajcuXNQQcKo7Uy4VjHF4MhitmV1PrnhJbx8DNHVa3e1DVwxsS9oMXkoMLhoqPyyRKH5v4sAtjmP9kC5AWTpEKsv,115,7,7,true +2024-09-24 19:08:59.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,383.36847314116005,Sell,2.606530277,SOL,So11111111111111111111111111111111111111112,2.287962514,JitoSOL,J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn,7.667377325720001,0.052130659,SOL,So11111111111111111111111111111111111111112,raydium,3,SOL-JitoSOL,2uoKbPEidR7KAMYtY4x7xdkHXWqYib5k4CutJauSL3Mc,3PtzA1bgtFY6rN7rsoRfZsryC5qSmuvuAYVqXPZKfvEG,2vrF2VneYFA7gdAwGzUbtKXQVvTEzhDzhfPnVn22jV8uvvWgKxbPCtidmo9h2CF8RX83eCKaaGBWr7S7zr1sAtML,367,3,1,true +2024-09-24 15:45:57.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,954.11638561901,Buy,1059086.353385,ball,HPfY3VCj1twecf556rDFWLJpDfh1vPoTtBjPehzKpump,6.574218877,SOL,So11111111111111111111111111111111111111112,19.082327634010003,0.131484377,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-ball,7jaj84BxnuwWc9a2VEFEudvPQ5AxkrUKFCmTZRM1cbdE,8i5QapkUnbnb6vEaEFcJFpsR1x3XF5N4FyL6HEAb1gpf,2iSBpMcxmjob6f1amwUC7M5bV9ZNAQ9kDsu8Z2s7J8aTTow9in7k5asjVqFcz8EtvyZUx3RQVjWEMdNdtyw7zuKV,1200,6,1,true +2024-09-23 20:52:52.000 UTC,2024-09-23,2024-09-01,Jupbot,solana,930.15180360432,Sell,6.474674952,SOL,So11111111111111111111111111111111111111112,6.334130789,sSOL,sSo14endRuUbvQaJS3dq36Q829a3A6BEfoeeRGJywEh,18.60303606634,0.129493499,SOL,So11111111111111111111111111111111111111112,whirlpool,1,sSOL-SOL,8X5tAh7EcafARDGhmLHxkiG5CousuB1yLtYsbuM9tD1T,EkN4oxatCq7RRndbzw8bZRV4uA7YvW2wDbKcQKZPBgpw,5QiDGEUH6FL2eZrUS1usQ9YuX41ZgguNxdQSGXeuc5TdqzU4yeSn2wB2VwbS2bMDuNDbcDthzgBtBHfTYghry7rC,265,3,1,true +2024-09-24 13:20:12.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,0.0011863542,Sell,0.000008054,SOL,So11111111111111111111111111111111111111112,1186.791951,USDC,EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v,23.731174815600003,0.161107772,SOL,So11111111111111111111111111111111111111112,phoenix,1,USDC-SOL,HUaSnNPwGZv18W7XynTfrgTAUWSMMHsdGXXLaEQbnKJz,CY7trDMTcg8KVBJWXbAdUX9uQCtEffAfKHLzuRmeSKzW,3tkxMBas8SPQZBWE5SW7acxZZYLTzEiphjsqziTVUfBxFmrtRoVk7ai4D5Tahy4XXHQGK3kr1iugjVvnz7eRKP7Z,942,4,6,true +2024-09-24 15:27:40.000 UTC,2024-09-24,2024-09-01,Jupbot,solana,1101.81663929152,Sell,7.554968728,SOL,So11111111111111111111111111111111111111112,1264106.88068,ball,HPfY3VCj1twecf556rDFWLJpDfh1vPoTtBjPehzKpump,22.026021962,0.151028675,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-ball,7jaj84BxnuwWc9a2VEFEudvPQ5AxkrUKFCmTZRM1cbdE,GKN8EJjLhtBeKwzcA9CQCdiKEHPGso2KtFCMFTJwCkgD,66npQKbqogUKyrpPJCNcUNeuFp5nhicJhFLaRKGRDyXvnPC1Du2nYNxz88Qnh5Gn5zbpK6tvbNvSWJEq7pgSvMrf,1053,3,1,true \ No newline at end of file From f24b9893c00486dd5b0d0463b968be2a22c9e65d Mon Sep 17 00:00:00 2001 From: Rantum Date: Mon, 30 Sep 2024 08:02:24 -0700 Subject: [PATCH 110/127] add USDS [sky] (#6848) * add USDS - sky * add to tokens and prices lists * remove inactives --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 5 +++-- .../tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql | 1 + .../tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 9e37d5e8f5c..0dc3d95b49c 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1840,8 +1840,9 @@ FROM ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8), ('msn-mesonnetwork', 'ethereum', 'MSN', 0xaa247c0d81b83812e1abf8bab078e4540d87e3fb, 18), ('zeta-zetachain', 'ethereum', 'ZETA', 0xf091867ec603a6628ed83d274e835539d82e9cc8, 18), - ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18), - ('sky-sky', 'ethereum', 'SKY', 0x56072C95FAA701256059aa122697B133aDEd9279, 18) + ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) + --('sky-sky', 'ethereum', 'SKY', 0x56072C95FAA701256059aa122697B133aDEd9279, 18), + --('usds-usds', 'ethereum', 'USDS', 0xdc035d45d973e3ec169d2276ddab16f1e407384f, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( -- bad price feeds diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql index 5a075a3286a..1e9ef995585 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4631,5 +4631,6 @@ FROM (VALUES , ( 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 'BUBBLE', 9) , ( 0xeb9951021698b42e4399f9cbb6267aa35f82d59d, 'LIF', 18) , ( 0x707f9118e33a9b8998bea41dd0d46f38bb963fc8, 'bETH', 18) + , ( 0xdc035d45d973e3ec169d2276ddab16f1e407384f, 'USDS', 18) ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql index a2233cdf6e1..bb049ac987b 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20_stablecoins.sql @@ -81,6 +81,7 @@ FROM (VALUES ('ethereum', 0xbbaec992fc2d637151daf40451f160bf85f3c8c1, 'Crypto-backed stablecoin', 'USDM', 6, ''), ('ethereum', 0x7945b0a6674b175695e5d1d08ae1e6f13744abb0, 'Crypto-backed stablecoin', 'BaoUSD', 18, ''), ('ethereum', 0x40d16fc0246ad3160ccc09b8d0d3a2cd28ae6c2f, 'Crypto-backed stablecoin', 'GHO', 18, ''), - ('ethereum', 0xfd03723a9a3abe0562451496a9a394d2c4bad4ab, 'Crypto-backed stablecoin', 'DYAD', 18, '') + ('ethereum', 0xfd03723a9a3abe0562451496a9a394d2c4bad4ab, 'Crypto-backed stablecoin', 'DYAD', 18, ''), + ('ethereum', 0xdc035d45d973e3ec169d2276ddab16f1e407384f, 'Crypto-backed stablecoin', 'USDS', 18, '') ) AS temp_table (blockchain, contract_address, backing, symbol, decimals, name) From bc30cab394ffc45ce0f36686d8c06772842c26ac Mon Sep 17 00:00:00 2001 From: Rantum Date: Mon, 30 Sep 2024 08:04:20 -0700 Subject: [PATCH 111/127] add new tokens from coinpaprika updates (#6849) * add new tokens from coinpaprika * babyrwa * remove inactive * remove inactive * remove more inactive * fix commas after remove inactives --- .../tokens/models/prices/base/prices_base_tokens.sql | 5 ++++- .../tokens/models/prices/bnb/prices_bnb_tokens.sql | 8 +++++++- .../models/prices/polygon/prices_polygon_tokens.sql | 4 +++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql index 599e5b9343e..371c686f3a0 100644 --- a/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/base/prices_base_tokens.sql @@ -169,5 +169,8 @@ FROM ('rdat-rdatadao','base','RDAT',0x4498cd8ba045e00673402353f5a4347562707e7d, 18), ('usdz-anzen-usdz', 'base', 'USDZ',0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 18), ('moxie-moxie', 'base', 'MOXIE',0x8C9037D1Ef5c6D1f6816278C7AAF5491d24CD527, 18), - ('cbbtc-coinbase-wrapped-btc', 'base', 'cbBTC',0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf, 8) + ('cbbtc-coinbase-wrapped-btc', 'base', 'cbBTC',0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf, 8), + --('weirdo-weirdo', 'base', 'weirdo',0x76734b57dfe834f102fb61e1ebf844adf8dd931e, 8), + --('lune-luneko', 'base', 'LUNE',0xacd1caef47e4c47bafe8a51b3f4305fc38203b7a, 18), + ('peach-based-peaches', 'base', 'PEACH',0x8319767a7b602f88e376368dca1b92d38869b9b4, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) diff --git a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql index e638e058d1c..eacc6918696 100644 --- a/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/bnb/prices_bnb_tokens.sql @@ -280,7 +280,13 @@ FROM ('zeta-zetachain', 'bnb', 'ZETA', 0x0000028a2eb8346cd5c0267856ab7594b7a55308, 18), ('euri-eurite', 'bnb', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18), ('cookie-cookie', 'bnb', 'COOKIE', 0xc0041ef357b183448b235a8ea73ce4e4ec8c265f, 18), - ('wsteth-wrapped-liquid-staked-ether-20', 'bnb', 'wstETH', 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C, 18) + ('wsteth-wrapped-liquid-staked-ether-20', 'bnb', 'wstETH', 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C, 18), + ('arty-artyfact', 'bnb', 'ARTY', 0x617cab4aaae1f8dfb3ee138698330776a1e1b324, 6), + ('bccoin-blackcardcoin', 'bnb', 'BCCOIN', 0x2940566eb50f15129238f4dc599adc4f742d7d8e, 18), + ('app-moon-app', 'bnb', 'APP', 0xc5d27f27f08d1fd1e3ebbaa50b3442e6c0d50439, 18), + ('chapz-chappyz', 'bnb', 'CHAPZ', 0x7b56748a3ef9970a5bae99c58ad8bc67b26c525f, 10), + ('babyrwa-babyrwa', 'bnb', 'BABYRWA', 0x4a8049c015ae1c6665fc9e49f053458ae3a102d0, 9) + ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( 0x2ab0e9e4ee70fff1fb9d67031e44f6410170d00e -- bXEN has bad price feed. diff --git a/dbt_subprojects/tokens/models/prices/polygon/prices_polygon_tokens.sql b/dbt_subprojects/tokens/models/prices/polygon/prices_polygon_tokens.sql index 313d323bf7c..1fa36eb8255 100644 --- a/dbt_subprojects/tokens/models/prices/polygon/prices_polygon_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/polygon/prices_polygon_tokens.sql @@ -138,7 +138,9 @@ FROM ('next-connext-eth', 'polygon', 'NEXT', 0x58b9cb810a68a7f3e1e4f8cb45d1b9b3c79705e8, 18), ('usdm-mountain-protocol-usd', 'polygon', 'USDM', 0x57f5e098cad7a3d1eed53991d4d66c45c9af7812, 18), ('crowd-crowdswap', 'polygon', 'CROWD', 0x483dd3425278c1f79f377f1034d9d2cae55648b6, 18), - ('trb-tellor', 'polygon', 'TRB', 0xe3322702bedaaed36cddab233360b939775ae5f1, 18) + ('trb-tellor', 'polygon', 'TRB', 0xe3322702bedaaed36cddab233360b939775ae5f1, 18) + --('alta-alta-finance', 'polygon', 'ALTA', 0xe0cca86b254005889ac3a81e737f56a14f4a38f5, 18), + --('pbos-phobos-token', 'polygon', 'PBOS', 0x421b9b487d5a9b76e4b81809c0f1b9bb8cb24cb9, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) where contract_address not in ( 0xef938b6da8576a896f6e0321ef80996f4890f9c4 -- DG, bad price feed From e89dfe947f969a2c0a942db9f3ade3d99fbdf97e Mon Sep 17 00:00:00 2001 From: 0xroll <96259407+0xroll@users.noreply.github.com> Date: Mon, 30 Sep 2024 23:04:51 +0800 Subject: [PATCH 112/127] Update README.md (#6851) --- dbt_subprojects/tokens/models/prices/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/tokens/models/prices/README.md b/dbt_subprojects/tokens/models/prices/README.md index 59db804c5d2..990fc8d0c19 100644 --- a/dbt_subprojects/tokens/models/prices/README.md +++ b/dbt_subprojects/tokens/models/prices/README.md @@ -11,7 +11,7 @@ - Find the API ID in the overview section, slightly down the page: `uni-uniswap` - Test the API call result in my web browser: https://api.coinpaprika.com/v1/coins/uni-uniswap - Ensure the token feed via the API is live, with the `"is_active":true` flag -- Add a row to the Ethereum prices spell: https://github.com/duneanalytics/spellbook/blob/main/models/prices/ethereum/prices_ethereum_tokens.sql +- Add a row to the Ethereum prices spell: https://github.com/duneanalytics/spellbook/blob/main/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql - In the PR process to add a token, tests will run to ensure unique address value - Tests against the API will also run, to ensure results return as expected - Request review from maintainers to get PR merged @@ -46,4 +46,4 @@ Any time! Dune team will do their best to merge as quickly as possible to get li - If a token is cross-chain with the same address, but a blockchain isn't supported, the data can be pulled from the other blockchain -- be sure to keep blockchain consistent with the spell it's in, even if pulling from different one on the API - What if my token can't be found on Coinpaprika? - Please follow their process to add tokens [here](https://coinpaprika.com/add/) - - If request is urgent, Dune team may be able to expedite request once it's made in above link \ No newline at end of file + - If request is urgent, Dune team may be able to expedite request once it's made in above link From 4cec2424c3e0498aa56be5b8af410f359a1eb8b0 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Mon, 30 Sep 2024 12:05:56 -0300 Subject: [PATCH 113/127] add missing tokens (#6852) Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../models/gyroscope/gyroscope_gyro_tokens.sql | 2 ++ .../tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql | 5 ++++- .../tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_gyro_tokens.sql b/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_gyro_tokens.sql index cc7cf42684d..d581e22edf0 100644 --- a/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_gyro_tokens.sql +++ b/dbt_subprojects/daily_spellbook/models/gyroscope/gyroscope_gyro_tokens.sql @@ -14,6 +14,8 @@ WITH gyro_tokens as ( (0x4EA71A20e655794051D1eE8b6e4A3269B13ccaCc, 'stataBasUSDC', 6, 'base'), (0x270ba1f35d8b87510d24f693fccc0da02e6e4eeb, 'stataGnoUSDC', 6, 'base'), (0x862c57d48becB45583AEbA3f489696D22466Ca1b, 'stataEthUSDT', 6, 'ethereum'), + (0x848107491e029afde0ac543779c7790382f15929, 'stataEthcrvUSD', 18, 'ethereum'), + (0xDBf5E36569798D1E39eE9d7B1c61A7409a74F23A, 'stataEthLUSD', 18, 'ethereum'), (0x87A1fdc4C726c459f597282be639a045062c0E46, 'stataPolUSDT', 6, 'polygon'), (0x2dCa80061632f3F87c9cA28364d1d0c30cD79a19, 'stataPolUSDCn', 6, 'polygon'), (0x4dd03dfd36548c840b563745e3fbec320f37ba7e, 'stataOptUSDCn', 6, 'optimism'), diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql index 1e9ef995585..4f45276ca99 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4631,6 +4631,9 @@ FROM (VALUES , ( 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 'BUBBLE', 9) , ( 0xeb9951021698b42e4399f9cbb6267aa35f82d59d, 'LIF', 18) , ( 0x707f9118e33a9b8998bea41dd0d46f38bb963fc8, 'bETH', 18) + , ( 0x848107491e029afde0ac543779c7790382f15929, 'stataEthcrvUSD', 18) + , ( 0xDBf5E36569798D1E39eE9d7B1c61A7409a74F23A, 'stataEthLUSD', 18) + , ( 0x63e5dC7C071C1F18d44b69bc86f4c80F24851388, 'KAI', 18) + , ( 0xFFd9c960bC303b8d3aAED58229ce8a7310bCc5b8, 'KAIAURA', 18) , ( 0xdc035d45d973e3ec169d2276ddab16f1e407384f, 'USDS', 18) - ) AS temp_table (contract_address, symbol, decimals) diff --git a/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql b/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql index d99c973b8bc..04262687f94 100644 --- a/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/gnosis/tokens_gnosis_erc20.sql @@ -7798,4 +7798,9 @@ FROM (VALUES , ( 0x4e5af8c1bd8ec1ffafa8a6043e57c3d384a7c574, 'ZTLN', 18) , ( 0x0deee1f9b96cac0b0ec85e8f800bc0b33e901e9a, 'IDOL', 18) , ( 0xfef5f9d8fe3b23fe4a242a461e537bb69364de94, 'VCUSD', 18) + , ( 0x14a5f2872396802c3cc8942a39ab3e4118ee5038, 'bTSLA', 18) + , ( 0x7212088a11b4d8f6fc90fbb3dfe793b45dd72323, 'bGME', 18) + , ( 0xac28c9178acc8ba4a11a29e013a3a2627086e422, 'bMSTR', 18) + , ( 0xa34c5e0abe843e10461e2c9586ea03e55dbcc495, 'bNVDA', 18) + , ( 0xbbcb0356bb9e6b3faa5cbf9e5f36185d53403ac9, 'bCOIN', 18) ) AS temp_table (contract_address, symbol, decimals) From c62a18284439c4ced55f1d795702b60e207c3470 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:21:51 -0400 Subject: [PATCH 114/127] exclude due to dupes failing prod (#6854) --- .../daily_spellbook/models/dao/balances/dao_balances.sql | 1 + .../daily_spellbook/models/dao/balances/dao_balances_steth.sql | 2 +- .../transactions/ethereum/dao_transactions_ethereum_erc20.sql | 2 +- .../dao/transactions/ethereum/dao_transactions_ethereum_eth.sql | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/models/dao/balances/dao_balances.sql b/dbt_subprojects/daily_spellbook/models/dao/balances/dao_balances.sql index 418150e1abf..89689d569a0 100644 --- a/dbt_subprojects/daily_spellbook/models/dao/balances/dao_balances.sql +++ b/dbt_subprojects/daily_spellbook/models/dao/balances/dao_balances.sql @@ -1,4 +1,5 @@ {{ config( + tags = ['prod_exclude'], schema = 'dao', alias = 'balances', materialized = 'table', diff --git a/dbt_subprojects/daily_spellbook/models/dao/balances/dao_balances_steth.sql b/dbt_subprojects/daily_spellbook/models/dao/balances/dao_balances_steth.sql index 0001f4b7fcc..c84751d58bd 100644 --- a/dbt_subprojects/daily_spellbook/models/dao/balances/dao_balances_steth.sql +++ b/dbt_subprojects/daily_spellbook/models/dao/balances/dao_balances_steth.sql @@ -1,5 +1,5 @@ {{ config( - + tags = ['prod_exclude'], alias = 'balances_steth', materialized = 'table', file_format = 'delta', diff --git a/dbt_subprojects/daily_spellbook/models/dao/transactions/ethereum/dao_transactions_ethereum_erc20.sql b/dbt_subprojects/daily_spellbook/models/dao/transactions/ethereum/dao_transactions_ethereum_erc20.sql index e74f72321ae..74ae570c317 100644 --- a/dbt_subprojects/daily_spellbook/models/dao/transactions/ethereum/dao_transactions_ethereum_erc20.sql +++ b/dbt_subprojects/daily_spellbook/models/dao/transactions/ethereum/dao_transactions_ethereum_erc20.sql @@ -1,5 +1,5 @@ {{ config( - + tags = ['prod_exclude'], alias = 'transactions_ethereum_erc20', partition_by = ['block_month'], materialized = 'incremental', diff --git a/dbt_subprojects/daily_spellbook/models/dao/transactions/ethereum/dao_transactions_ethereum_eth.sql b/dbt_subprojects/daily_spellbook/models/dao/transactions/ethereum/dao_transactions_ethereum_eth.sql index 4491c5f4da9..ca7c74e7157 100644 --- a/dbt_subprojects/daily_spellbook/models/dao/transactions/ethereum/dao_transactions_ethereum_eth.sql +++ b/dbt_subprojects/daily_spellbook/models/dao/transactions/ethereum/dao_transactions_ethereum_eth.sql @@ -1,5 +1,5 @@ {{ config( - + tags = ['prod_exclude'], alias = 'transactions_ethereum_eth', partition_by = ['block_month'], materialized = 'incremental', From 3a8f8371eb47f20415998ac7f30d0b9eb4ce106e Mon Sep 17 00:00:00 2001 From: Tiago <66181828+tiagofilipenunes@users.noreply.github.com> Date: Mon, 30 Sep 2024 18:28:27 +0100 Subject: [PATCH 115/127] Re-add cREAL now that it has more volume (#6853) --- .../tokens/models/prices/celo/prices_celo_tokens.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/celo/prices_celo_tokens.sql b/dbt_subprojects/tokens/models/prices/celo/prices_celo_tokens.sql index 8bb307e023b..88ef25c5f76 100644 --- a/dbt_subprojects/tokens/models/prices/celo/prices_celo_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/celo/prices_celo_tokens.sql @@ -19,7 +19,7 @@ FROM ('celo-celo', 'celo', 'CELO', 0x471ece3750da237f93b8e339c536989b8978a438, 18), ('cusd-celo-dollar', 'celo', 'cUSD', 0x765de816845861e75a25fca122bb6898b8b1282a, 18), ('ceur-celo-euro', 'celo', 'cEUR', 0xd8763cba276a3738e6de85b4b3bf5fded6d6ca73, 18), --requested add to coinPaprika 2023-08-10 - --('creal-celo-brazilian-real', 'celo', 'cREAL', 0xe8537a3d056DA446677B9E9d6c5dB704EaAb4787, 18), --listed but no much volume + ('creal-celo-brazilian-real', 'celo', 'cREAL', 0xe8537a3d056DA446677B9E9d6c5dB704EaAb4787, 18), ('ico-axelar', 'celo', 'AXL', 0x23ee2343B892b1BB63503a4FAbc840E0e2C6810f, 6), --requested add to coinPaprika 2023-08-10 --('mimatic-mimatic', 'celo', 'MAI', 0xb9c8f0d3254007ee4b98970b94544e473cd610ec, 18), --requested add to coinPaprika 2023-08-10 ('wbtc-wrapped-bitcoin', 'celo', 'WBTC', 0xd629eb00deced2a080b7ec630ef6ac117e614f1b, 18), From 6cb4ee648e7981ba6b1e30ed511c5afa230cf4c0 Mon Sep 17 00:00:00 2001 From: stabble-devops <110252704+stabble-devops@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:29:24 -0400 Subject: [PATCH 116/127] add stabble to jupiter_solana_aggregator (#6844) --- .../solana/models/jupiter/jupiter_solana_aggregator_swaps.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbt_subprojects/solana/models/jupiter/jupiter_solana_aggregator_swaps.sql b/dbt_subprojects/solana/models/jupiter/jupiter_solana_aggregator_swaps.sql index ebcc159fcb7..44e2459824a 100644 --- a/dbt_subprojects/solana/models/jupiter/jupiter_solana_aggregator_swaps.sql +++ b/dbt_subprojects/solana/models/jupiter/jupiter_solana_aggregator_swaps.sql @@ -22,6 +22,8 @@ with FROM ( --use this api https://station.jup.ag/api-v6/get-program-id-to-label values + ('stabble Stable Swap', 'swapNyd8XiQwJ6ianp9snpu4brUqFxadzvHebnAXjJZ'), + ('stabble Weighted Swap', 'swapFpHZwjELNnjvThjajtiVmkz3yPQEHjLtka2fwHW'), ('Invariant', 'HyaB3W9q6XdA5xwpU4XnSZV94htfmbmqJXZcEbRaJutt'), ('Saber (Decimals)', 'DecZY86MU5Gj7kppfUCEmd4LbXXuyZH1yHaP2NTqdiZB'), ('Balansol', 'D3BBjqUdCYuP18fNvvMbPAZ8DpcRi4io2EsYHQawJDag'), From 95d42ef7d710860475902823eaeda4ebae96ebe1 Mon Sep 17 00:00:00 2001 From: henrystats <65398020+henrystats@users.noreply.github.com> Date: Tue, 1 Oct 2024 14:10:01 +0100 Subject: [PATCH 117/127] Add eigen to tokens.erc20 (#6860) --- .../tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql index 4f45276ca99..dc0ed2338d6 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4636,4 +4636,5 @@ FROM (VALUES , ( 0x63e5dC7C071C1F18d44b69bc86f4c80F24851388, 'KAI', 18) , ( 0xFFd9c960bC303b8d3aAED58229ce8a7310bCc5b8, 'KAIAURA', 18) , ( 0xdc035d45d973e3ec169d2276ddab16f1e407384f, 'USDS', 18) + , ( 0xec53bF9167f50cDEB3Ae105f56099aaaB9061F83, 'EIGEN', 18) ) AS temp_table (contract_address, symbol, decimals) From c82170935a85dc620d94970dc3adf03e472f62f9 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Tue, 1 Oct 2024 10:10:11 -0300 Subject: [PATCH 118/127] Update prices_ethereum_tokens.sql (#6859) --- .../tokens/models/prices/ethereum/prices_ethereum_tokens.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql index 0dc3d95b49c..71c8e1028f8 100644 --- a/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql +++ b/dbt_subprojects/tokens/models/prices/ethereum/prices_ethereum_tokens.sql @@ -1840,7 +1840,8 @@ FROM ('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8), ('msn-mesonnetwork', 'ethereum', 'MSN', 0xaa247c0d81b83812e1abf8bab078e4540d87e3fb, 18), ('zeta-zetachain', 'ethereum', 'ZETA', 0xf091867ec603a6628ed83d274e835539d82e9cc8, 18), - ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18) + ('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18), + ('eigen-eigenlayer', 'ethereum', 'EIGEN', 0xec53bF9167f50cDEB3Ae105f56099aaaB9061F83, 18) --('sky-sky', 'ethereum', 'SKY', 0x56072C95FAA701256059aa122697B133aDEd9279, 18), --('usds-usds', 'ethereum', 'USDS', 0xdc035d45d973e3ec169d2276ddab16f1e407384f, 18) ) as temp (token_id, blockchain, symbol, contract_address, decimals) From 6bfd75541bde5ee19b0bd8be0d379721844ccf7f Mon Sep 17 00:00:00 2001 From: hildobby Date: Tue, 1 Oct 2024 15:10:34 +0200 Subject: [PATCH 119/127] fantasy.events small update (#6858) * add traded_ids col * fix --- .../daily_spellbook/models/_projects/fantasy/_schema.yml | 2 ++ .../models/_projects/fantasy/fantasy_events.sql | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/daily_spellbook/models/_projects/fantasy/_schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/fantasy/_schema.yml index 6baed668877..628ddb341a7 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/fantasy/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/_projects/fantasy/_schema.yml @@ -33,6 +33,8 @@ models: description: "The list of minted fantasy.top card token ids" - name: burned_ids description: "The list of burned fantasy.top card token ids" + - name: traded_ids + description: "The list of traded fantasy.top card token ids" - name: traded_with description: "Who was on the other side of this executed trade" - name: tx_from diff --git a/dbt_subprojects/daily_spellbook/models/_projects/fantasy/fantasy_events.sql b/dbt_subprojects/daily_spellbook/models/_projects/fantasy/fantasy_events.sql index 4ee6c7bc4f4..63233f8b65b 100644 --- a/dbt_subprojects/daily_spellbook/models/_projects/fantasy/fantasy_events.sql +++ b/dbt_subprojects/daily_spellbook/models/_projects/fantasy/fantasy_events.sql @@ -57,6 +57,7 @@ SELECT m.evt_block_time AS block_time , m.firstTokenId+90, m.firstTokenId+91, m.firstTokenId+92, m.firstTokenId+93, m.firstTokenId+94, m.firstTokenId+95, m.firstTokenId+96, m.firstTokenId+97, m.firstTokenId+98, m.firstTokenId+99 ], x -> x <= lastTokenId) AS minted_ids , NULL AS burned_ids +, NULL AS traded_ids , NULL AS traded_with , m.evt_tx_from AS tx_from , m.evt_tx_to AS tx_to @@ -93,6 +94,7 @@ SELECT evt_block_time AS block_time , CAST(cardinality(burntTokenIds) AS double) AS cards_burned , ARRAY[mintedTokenId] AS minted_ids , burntTokenIds AS burned_ids +, NULL AS traded_ids , NULL AS traded_with , evt_tx_from AS tx_from , evt_tx_to AS tx_to @@ -125,6 +127,7 @@ SELECT evt_block_time AS block_time , CAST(cardinality(burntTokenIds) AS double) AS cards_burned , mintedTokenIds AS minted_ids , burntTokenIds AS burned_ids +, NULL AS traded_ids , NULL AS traded_with , evt_tx_from AS tx_from , evt_tx_to AS tx_to @@ -157,6 +160,7 @@ SELECT nftt.block_time , CAST(0 AS double) AS cards_burned , NULL AS minted_ids , NULL AS burned_ids +, nftt.token_id AS traded_ids , CASE WHEN nftt.trade_category='Buy' THEN nftt.seller ELSE nftt.buyer END AS traded_with , nftt.tx_from , nftt.tx_to @@ -178,7 +182,7 @@ INNER JOIN {{ source('blast', 'transactions') }} txs ON txs.block_number=nftt.bl AND txs.hash=nftt.tx_hash LEFT JOIN {{source('nft_blast', 'wash_trades')}} wt ON wt.project = 'fantasy' AND wt.block_number=nftt.block_number - AND wt.tx_hash=nftt.tx_hash + AND nftt.unique_trade_id=wt.unique_trade_id WHERE nftt.blockchain = 'blast' AND nftt.project = 'fantasy' @@ -196,6 +200,7 @@ SELECT block_time , CAST(0 AS double) AS cards_burned , NULL AS minted_ids , NULL AS burned_ids +, NULL AS traded_ids , NULL AS traded_with , tx_from , tx_to From a32b0e638aca16ed77ec80382494f0843999eac5 Mon Sep 17 00:00:00 2001 From: Vitalii Tsyhulov <83537328+0xVitalii@users.noreply.github.com> Date: Tue, 1 Oct 2024 06:10:44 -0700 Subject: [PATCH 120/127] Update prices_optimism_tokens_curated.sql (#6856) Adding new token --- .../models/prices/optimism/prices_optimism_tokens_curated.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql b/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql index fb2f1cc0a5d..9691ac9393c 100644 --- a/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql +++ b/dbt_subprojects/tokens/models/prices/optimism/prices_optimism_tokens_curated.sql @@ -134,5 +134,6 @@ FROM ('dola-dola', 'DOLA',0x8ae125e8653821e851f12a49f7765db9a9ce7384, 18), ('wld-worldcoin', 'WLD',0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1, 18), ('pendle-pendle', 'PENDLE',0xbc7b1ff1c6989f006a1185318ed4e7b5796e66e1, 18), - ('trb-tellor', 'TRB', 0xaf8ca653fa2772d58f4368b0a71980e9e3ceb888, 18) + ('trb-tellor', 'TRB', 0xaf8ca653fa2772d58f4368b0a71980e9e3ceb888, 18), + ('dtoro-dextoro', 'DTORO', 0x1cef2d62af4cd26673c7416957cc4ec619a696a7, 18) ) as temp (token_id, symbol, contract_address, decimals) From 8fd4c15e0a6d7b0f67d1ff2166a8e42d4d9223eb Mon Sep 17 00:00:00 2001 From: hildobby Date: Tue, 1 Oct 2024 15:19:51 +0200 Subject: [PATCH 121/127] add puffer addresses (#6825) --- ..._ethereum_entities_depositor_addresses.sql | 289 +++++++++++------- 1 file changed, 181 insertions(+), 108 deletions(-) diff --git a/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_depositor_addresses.sql b/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_depositor_addresses.sql index 4d57d43f058..22ee2f9e356 100644 --- a/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_depositor_addresses.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/staking/ethereum/entities/staking_ethereum_entities_depositor_addresses.sql @@ -121,114 +121,187 @@ FROM , (0xea674fdde714fd979de3edf0f56aa9716b898ec8, 'Ethermine', 'Ethermine', 'Staking Pool') , (0x25e821b7197b146f7713c3b89b6a4d83516b912d, 'ether.fi', 'ether.fi', 'Liquid Restaking') , (0xe60ca7abf24de99af64e7d9057659ae2dbc2eb2c, 'Puffer Finance', 'Puffer Finance 1', 'Liquid Restaking') - , (0x53bdF36503864593406D8e0e9fe848f2cEB91817, 'Puffer Finance', 'Puffer Finance 2', 'Liquid Restaking') - , (0x4d7c3fc856ab52753b91a6c9213adf013309dd25, 'Puffer Finance', 'Puffer Finance 3', 'Liquid Restaking') - , (0xf831b40e80ffd364b0a08619666ee09df3a3f73a, 'Puffer Finance', 'Puffer Finance 4', 'Liquid Restaking') - , (0x6d069d7210A97a5F86150698Ccc8D750fcA2512f, 'Puffer Finance', 'Puffer Finance 5', 'Liquid Restaking') - , (0x175da1e44c8fbf124714a3bba5dc18a7e65664d6, 'Puffer Finance', 'Puffer Finance 6', 'Liquid Restaking') - , (0xf5d31b441b8f1c53c7c5beb80089fec228c531fb, 'Puffer Finance', 'Puffer Finance 7', 'Liquid Restaking') - , (0x1719e587d4Cb7e9F3a0e9351c83ADc48dC9e7bCF, 'Puffer Finance', 'Puffer Finance 8', 'Liquid Restaking') - , (0x73f23013c5a4c209de945cdc58595a4d53d23084, 'Puffer Finance', 'Puffer Finance 9', 'Liquid Restaking') - , (0xa4c78fdae426d16baa010acedeec87706ac3f76b, 'Puffer Finance', 'Puffer Finance 10', 'Liquid Restaking') - , (0x0e3AC3cD91889343B6F9D24Fda634E571BBCE643, 'Puffer Finance', 'Puffer Finance 11', 'Liquid Restaking') - , (0x59639aeee35c4108923fd16e66055b347fbeadd2, 'Puffer Finance', 'Puffer Finance 12', 'Liquid Restaking') - , (0xbb43dcafa77fb5d1888a087ce6a30c287981c391, 'Puffer Finance', 'Puffer Finance 13', 'Liquid Restaking') - , (0xc8c131befBeFE0bC0eD06C0C263335a01322D000, 'Puffer Finance', 'Puffer Finance 14', 'Liquid Restaking') - , (0xdd6859450e80665db854022e85fb0ed2f0240cb9, 'Puffer Finance', 'Puffer Finance 15', 'Liquid Restaking') - , (0xbca580b952801236322734bb146f3e27894f736e, 'Puffer Finance', 'Puffer Finance 16', 'Liquid Restaking') - , (0x6Ab300BA5C74d3F2AaC53F730fa16A9E1588B46c, 'Puffer Finance', 'Puffer Finance 17', 'Liquid Restaking') - , (0xe48e7102c03812dfa1fdf0bbe6dbba6dc70b0f33, 'Puffer Finance', 'Puffer Finance 18', 'Liquid Restaking') - , (0x48c09cad9d785e21210a4e84fcb0ff5a3a73c58d, 'Puffer Finance', 'Puffer Finance 19', 'Liquid Restaking') - , (0x0e54A434b0a8Fb4c7f549FBEc551638754736944, 'Puffer Finance', 'Puffer Finance 20', 'Liquid Restaking') - , (0xe859a34cdd097ac7e8167ad828ca9ad969925a6a, 'Puffer Finance', 'Puffer Finance 21', 'Liquid Restaking') - , (0x5fde1b2d371243edca74b77082d40e01c5f15b31, 'Puffer Finance', 'Puffer Finance 22', 'Liquid Restaking') - , (0x92223B7CaCCDCc1A1164F581BA41C9356482932e, 'Puffer Finance', 'Puffer Finance 23', 'Liquid Restaking') - , (0xc327e3152ef9784faf0190cfa2592ddea5455430, 'Puffer Finance', 'Puffer Finance 24', 'Liquid Restaking') - , (0xC06B5AEbE343336C382ef397c718f4dfdcEB3424, 'Puffer Finance', 'Puffer Finance 25', 'Liquid Restaking') - , (0x4cee5738cc8cc1ff262034c4ddcf42675504afa9, 'Puffer Finance', 'Puffer Finance 26', 'Liquid Restaking') - , (0x1c354702D52b3aCf46372fd3578CE7ba9170F70c, 'Puffer Finance', 'Puffer Finance 27', 'Liquid Restaking') - , (0x9afca71c47910fe300fe0419a621a29c79537337, 'Puffer Finance', 'Puffer Finance 28', 'Liquid Restaking') - , (0xaCc1C68400C589BBA01b8F1CAA2Cb82eE9f389a4, 'Puffer Finance', 'Puffer Finance 29', 'Liquid Restaking') - , (0x0c9e6af5ad0d4826d81b8d51c4f4c2044ad05763, 'Puffer Finance', 'Puffer Finance 30', 'Liquid Restaking') - , (0xEDdB5f8dbEEF8959208daA10B931BB060F90CD6E, 'Puffer Finance', 'Puffer Finance 31', 'Liquid Restaking') - , (0xf66a37b7d6e99b9af3d835d1b33c80abe339915d, 'Puffer Finance', 'Puffer Finance 32', 'Liquid Restaking') - , (0x62d9019E0CCd6c8257F64651640BCd1AE23BC61f, 'Puffer Finance', 'Puffer Finance 33', 'Liquid Restaking') - , (0x2ab60aa450c7f16afd70f27a789833ebc638a9d0, 'Puffer Finance', 'Puffer Finance 34', 'Liquid Restaking') - , (0x40dcF0463a9b7FD50a8D8c7D8601798E12Effd36, 'Puffer Finance', 'Puffer Finance 35', 'Liquid Restaking') - , (0xc6910530820b3b85053be0db2863f332d6f45792, 'Puffer Finance', 'Puffer Finance 36', 'Liquid Restaking') - , (0x9d64c17F8C0fE43173818f9BD42D68638d3eD127, 'Puffer Finance', 'Puffer Finance 37', 'Liquid Restaking') - , (0x4d92687163dcfd582bb9e103e9086904901b55f8, 'Puffer Finance', 'Puffer Finance 38', 'Liquid Restaking') - , (0x9C938360b31bDDeab8C1B372b14dBd7E6270c5a8, 'Puffer Finance', 'Puffer Finance 39', 'Liquid Restaking') - , (0xfbe7657e38fe774027978271603ec22d95c1eb54, 'Puffer Finance', 'Puffer Finance 40', 'Liquid Restaking') - , (0x9481dC8d24578256A38e9Fe094A4493fdcf72b4e, 'Puffer Finance', 'Puffer Finance 41', 'Liquid Restaking') - , (0xf22a3f429905f9faa2ebe5947fc2d58b6ecce440, 'Puffer Finance', 'Puffer Finance 42', 'Liquid Restaking') - , (0xeBD58Fd9125ADaA16dB719bCf85dCFf1Eb71FAAc, 'Puffer Finance', 'Puffer Finance 43', 'Liquid Restaking') - , (0x5a2b0b1a12af2b10c7d6a4ab612a667cb8ba278d, 'Puffer Finance', 'Puffer Finance 44', 'Liquid Restaking') - , (0x7CBab465543E4cCE8E81bf25732A4bac551cCC3c, 'Puffer Finance', 'Puffer Finance 45', 'Liquid Restaking') - , (0xfe80649dc2cb126dd10603be02f0d94afc364fc9, 'Puffer Finance', 'Puffer Finance 46', 'Liquid Restaking') - , (0x2aAc86bD3bc5baE447bBcAF5a201656a95fACE7C, 'Puffer Finance', 'Puffer Finance 47', 'Liquid Restaking') - , (0x2d8f1a00e3e768d679fa7bd6fe567faa70f726b2, 'Puffer Finance', 'Puffer Finance 48', 'Liquid Restaking') - , (0x95401f1B03C11E16840119556a495549953F47A6, 'Puffer Finance', 'Puffer Finance 49', 'Liquid Restaking') - , (0x3000ca8ae328ae3996ee22c30b609d8e2b701599, 'Puffer Finance', 'Puffer Finance 50', 'Liquid Restaking') - , (0x67e3020efd52b14be4158eb888611f6d6930e02a, 'Puffer Finance', 'Puffer Finance 51', 'Liquid Restaking') - , (0x7822be4356b5e633bb8a445952c3d35fdb642986, 'Puffer Finance', 'Puffer Finance 52', 'Liquid Restaking') - , (0x031f5c9a8c1af1eb5ad48b9f6ab4253a66c5d4b6, 'Puffer Finance', 'Puffer Finance 53', 'Liquid Restaking') - , (0xda2dcde31b020b6b6f8c02d2bf4821db22091750, 'Puffer Finance', 'Puffer Finance 54', 'Liquid Restaking') - , (0x21b5e2044f73b257cdbe3bdc402f02b404cbfbf1, 'Puffer Finance', 'Puffer Finance 55', 'Liquid Restaking') - , (0x32eec068c4d0578b94169726890d5395d4647dc4, 'Puffer Finance', 'Puffer Finance 56', 'Liquid Restaking') - , (0xd346547f70ef624b36d5ec284c6d27710920b712, 'Puffer Finance', 'Puffer Finance 57', 'Liquid Restaking') - , (0x70d8c06125145281710dd73de382b7c1938200ea, 'Puffer Finance', 'Puffer Finance 58', 'Liquid Restaking') - , (0xd52fcbb08732de26a99a7f0c0a50412820a4b683, 'Puffer Finance', 'Puffer Finance 59', 'Liquid Restaking') - , (0x55efc9f901a5ada996011276450f7320729223b0, 'Puffer Finance', 'Puffer Finance 60', 'Liquid Restaking') - , (0x970601aeecf72a18c3afddd29078fd89a4bc267e, 'Puffer Finance', 'Puffer Finance 61', 'Liquid Restaking') - , (0xc1102180394132f19b6a50a158ec313ceffc4a3a, 'Puffer Finance', 'Puffer Finance 62', 'Liquid Restaking') - , (0x779190349f31c7bba1db2da051f118bf3074a477, 'Puffer Finance', 'Puffer Finance 63', 'Liquid Restaking') - , (0xf2d65e8093201c1645b822f9849fe375ea96056a, 'Puffer Finance', 'Puffer Finance 64', 'Liquid Restaking') - , (0x3923eb2d93c84baf3fa60a277db720228647def7, 'Puffer Finance', 'Puffer Finance 65', 'Liquid Restaking') - , (0xb1ee744162e94cced7cab1d53d81664950e41c39, 'Puffer Finance', 'Puffer Finance 66', 'Liquid Restaking') - , (0xd7988e9347f0eaea570695e88acea9cc6b66be13, 'Puffer Finance', 'Puffer Finance 67', 'Liquid Restaking') - , (0x6c6f3c472b5180df84efc7d65e81f7950d87a3f6, 'Puffer Finance', 'Puffer Finance 68', 'Liquid Restaking') - , (0xdf762d0afc382850c5160e6a4d3cf521774032f9, 'Puffer Finance', 'Puffer Finance 69', 'Liquid Restaking') - , (0xca3964974bae15cb7d941b32712302b2b6c5d4ab, 'Puffer Finance', 'Puffer Finance 70', 'Liquid Restaking') - , (0xf8baa75b11d8dda80ad286254aac9d08edb505c1, 'Puffer Finance', 'Puffer Finance 71', 'Liquid Restaking') - , (0xb53d7bcbc30652ff35650246e3b591a064266b2b, 'Puffer Finance', 'Puffer Finance 72', 'Liquid Restaking') - , (0x57f514aab0ec72cdb9d2d01cae0dd6ecd4981ce1, 'Puffer Finance', 'Puffer Finance 73', 'Liquid Restaking') - , (0xfa33e7d1bdfcb213e0cffa6e981fcad12d1638fa, 'Puffer Finance', 'Puffer Finance 74', 'Liquid Restaking') - , (0x8e59e546b97eaaab54f9650c89dc3875556d9635, 'Puffer Finance', 'Puffer Finance 75', 'Liquid Restaking') - , (0x024d2378d80df4c6f49cb1f388d5a53d42c3e5fd, 'Puffer Finance', 'Puffer Finance 76', 'Liquid Restaking') - , (0x4bbe8d3bb39d30e1f29678ad0b3039b397c1d55f, 'Puffer Finance', 'Puffer Finance 77', 'Liquid Restaking') - , (0x8c81d590cc94ca2451c4bde24c598193da74a575, 'Puffer Finance', 'Puffer Finance 78', 'Liquid Restaking') - , (0x2a89d38a2fd5b3d90c6f3813d23e0c2ed33cd7e2, 'Puffer Finance', 'Puffer Finance 79', 'Liquid Restaking') - , (0x9ae3eb1948e70c7f9804e30a34e8c25e0dd8261d, 'Puffer Finance', 'Puffer Finance 80', 'Liquid Restaking') - , (0x5905361a292c4582139a9ceaec1a71ea950d0677, 'Puffer Finance', 'Puffer Finance 81', 'Liquid Restaking') - , (0x3c12e47bd31b7c72ab05b514abae4b5abe871072, 'Puffer Finance', 'Puffer Finance 82', 'Liquid Restaking') - , (0x4cda1525b7d6577a59b6325201b3a68939da91d8, 'Puffer Finance', 'Puffer Finance 83', 'Liquid Restaking') - , (0xe097f793464e4503616e55d28294bf0fb982d14f, 'Puffer Finance', 'Puffer Finance 84', 'Liquid Restaking') - , (0xb92ac33d59ec4f93787acc773ba6e26ef536749a, 'Puffer Finance', 'Puffer Finance 85', 'Liquid Restaking') - , (0xad3f79fdf705cda1e8d9d7c398a678ee6ebb2cab, 'Puffer Finance', 'Puffer Finance 86', 'Liquid Restaking') - , (0xdbe13208672a329ac8827d5752ba3e63253617aa, 'Puffer Finance', 'Puffer Finance 87', 'Liquid Restaking') - , (0x11d28e6a3a8513432af889b25318d9b94bcb0d99, 'Puffer Finance', 'Puffer Finance 88', 'Liquid Restaking') - , (0xd695b18944902c0a2c899aaa789e06d30e6b0c6c, 'Puffer Finance', 'Puffer Finance 89', 'Liquid Restaking') - , (0xec77866c71f19b694b2d1640b0dc8585a3555596, 'Puffer Finance', 'Puffer Finance 90', 'Liquid Restaking') - , (0x5fee3852b09fd5be7043ba5eca71e674ea80c3ff, 'Puffer Finance', 'Puffer Finance 91', 'Liquid Restaking') - , (0x00c89174d831744ab9f004fc8056f85152443acc, 'Puffer Finance', 'Puffer Finance 92', 'Liquid Restaking') - , (0x4e15b6331eadaa84750870e4e24b84780c88ff91, 'Puffer Finance', 'Puffer Finance 93', 'Liquid Restaking') - , (0x444595c69006f6ac6acbf55d362d3036f5b636aa, 'Puffer Finance', 'Puffer Finance 94', 'Liquid Restaking') - , (0xd44cf40b14249811a50dcb6dbd809e94e421929e, 'Puffer Finance', 'Puffer Finance 95', 'Liquid Restaking') - , (0x572c5dfcbbec6815978adf2a835a34e8f04156fb, 'Puffer Finance', 'Puffer Finance 96', 'Liquid Restaking') - , (0xfe41129f707591fda06bfa30df467351d09f1806, 'Puffer Finance', 'Puffer Finance 97', 'Liquid Restaking') - , (0x5cc1a39d0b448ece222a3e2891315b7d3c104d62, 'Puffer Finance', 'Puffer Finance 98', 'Liquid Restaking') - , (0xc360a5080719b3819531e6a9135d7062a9aa71a4, 'Puffer Finance', 'Puffer Finance 99', 'Liquid Restaking') - , (0xd96ffffb94f1484903c4022f128830f636c696ef, 'Puffer Finance', 'Puffer Finance 100', 'Liquid Restaking') - , (0x1d5b496c6992e6ebcf7a38a4097017fad76457a8, 'Puffer Finance', 'Puffer Finance 101', 'Liquid Restaking') - , (0x364942ade69dd27ec53092aece9b0604c1ec45ae, 'Puffer Finance', 'Puffer Finance 102', 'Liquid Restaking') - , (0x31710a5588cd7fadbf5002744ee433a3ec5bf75b, 'Puffer Finance', 'Puffer Finance 103', 'Liquid Restaking') - , (0x75408e3a95a0d4db54a11b171e591f706d991e7a, 'Puffer Finance', 'Puffer Finance 104', 'Liquid Restaking') - , (0xb25cfe029b6dcd87d5d9ae333e587b7a4873ce29, 'Puffer Finance', 'Puffer Finance 105', 'Liquid Restaking') - , (0xd338e780a5b900ac66d16c106f8babb47040e47b, 'Puffer Finance', 'Puffer Finance 106', 'Liquid Restaking') - , (0xdd86602cda86bfa8d26cadb8fdafccf325e35433, 'Puffer Finance', 'Puffer Finance 107', 'Liquid Restaking') - , (0x97f51ba27bdee65bb87ffe38e4a88c9c938272f7, 'Puffer Finance', 'Puffer Finance 108', 'Liquid Restaking') - , (0xe1e2cac176c707d83206d27b49ade82d94807212, 'Puffer Finance', 'Puffer Finance 109', 'Liquid Restaking') + , (0x53bdf36503864593406d8e0e9fe848f2ceb91817, 'Puffer Finance', 'Puffer Finance 2', 'Liquid Restaking') + , (0xf831b40e80ffd364b0a08619666ee09df3a3f73a, 'Puffer Finance', 'Puffer Finance 3', 'Liquid Restaking') + , (0x6d069d7210a97a5f86150698ccc8d750fca2512f, 'Puffer Finance', 'Puffer Finance 4', 'Liquid Restaking') + , (0xf5d31b441b8f1c53c7c5beb80089fec228c531fb, 'Puffer Finance', 'Puffer Finance 5', 'Liquid Restaking') + , (0x1719e587d4cb7e9f3a0e9351c83adc48dc9e7bcf, 'Puffer Finance', 'Puffer Finance 6', 'Liquid Restaking') + , (0x9afca71c47910fe300fe0419a621a29c79537337, 'Puffer Finance', 'Puffer Finance 7', 'Liquid Restaking') + , (0xacc1c68400c589bba01b8f1caa2cb82ee9f389a4, 'Puffer Finance', 'Puffer Finance 8', 'Liquid Restaking') + , (0x0c9e6af5ad0d4826d81b8d51c4f4c2044ad05763, 'Puffer Finance', 'Puffer Finance 9', 'Liquid Restaking') + , (0xeddb5f8dbeef8959208daa10b931bb060f90cd6e, 'Puffer Finance', 'Puffer Finance 10', 'Liquid Restaking') + , (0xf66a37b7d6e99b9af3d835d1b33c80abe339915d, 'Puffer Finance', 'Puffer Finance 11', 'Liquid Restaking') + , (0x62d9019e0ccd6c8257f64651640bcd1ae23bc61f, 'Puffer Finance', 'Puffer Finance 12', 'Liquid Restaking') + , (0x2ab60aa450c7f16afd70f27a789833ebc638a9d0, 'Puffer Finance', 'Puffer Finance 13', 'Liquid Restaking') + , (0x40dcf0463a9b7fd50a8d8c7d8601798e12effd36, 'Puffer Finance', 'Puffer Finance 14', 'Liquid Restaking') + , (0xc6910530820b3b85053be0db2863f332d6f45792, 'Puffer Finance', 'Puffer Finance 15', 'Liquid Restaking') + , (0x9d64c17f8c0fe43173818f9bd42d68638d3ed127, 'Puffer Finance', 'Puffer Finance 16', 'Liquid Restaking') + , (0x4d92687163dcfd582bb9e103e9086904901b55f8, 'Puffer Finance', 'Puffer Finance 17', 'Liquid Restaking') + , (0x9c938360b31bddeab8c1b372b14dbd7e6270c5a8, 'Puffer Finance', 'Puffer Finance 18', 'Liquid Restaking') + , (0xfbe7657e38fe774027978271603ec22d95c1eb54, 'Puffer Finance', 'Puffer Finance 19', 'Liquid Restaking') + , (0x9481dc8d24578256a38e9fe094a4493fdcf72b4e, 'Puffer Finance', 'Puffer Finance 20', 'Liquid Restaking') + , (0xf22a3f429905f9faa2ebe5947fc2d58b6ecce440, 'Puffer Finance', 'Puffer Finance 21', 'Liquid Restaking') + , (0xebd58fd9125adaa16db719bcf85dcff1eb71faac, 'Puffer Finance', 'Puffer Finance 22', 'Liquid Restaking') + , (0x5a2b0b1a12af2b10c7d6a4ab612a667cb8ba278d, 'Puffer Finance', 'Puffer Finance 23', 'Liquid Restaking') + , (0x7cbab465543e4cce8e81bf25732a4bac551ccc3c, 'Puffer Finance', 'Puffer Finance 24', 'Liquid Restaking') + , (0xfe80649dc2cb126dd10603be02f0d94afc364fc9, 'Puffer Finance', 'Puffer Finance 25', 'Liquid Restaking') + , (0x2aac86bd3bc5bae447bbcaf5a201656a95face7c, 'Puffer Finance', 'Puffer Finance 26', 'Liquid Restaking') + , (0x2d8f1a00e3e768d679fa7bd6fe567faa70f726b2, 'Puffer Finance', 'Puffer Finance 27', 'Liquid Restaking') + , (0x95401f1b03c11e16840119556a495549953f47a6, 'Puffer Finance', 'Puffer Finance 28', 'Liquid Restaking') + , (0x3000ca8ae328ae3996ee22c30b609d8e2b701599, 'Puffer Finance', 'Puffer Finance 29', 'Liquid Restaking') + , (0x67e3020efd52b14be4158eb888611f6d6930e02a, 'Puffer Finance', 'Puffer Finance 30', 'Liquid Restaking') + , (0x7822be4356b5e633bb8a445952c3d35fdb642986, 'Puffer Finance', 'Puffer Finance 31', 'Liquid Restaking') + , (0x031f5c9a8c1af1eb5ad48b9f6ab4253a66c5d4b6, 'Puffer Finance', 'Puffer Finance 32', 'Liquid Restaking') + , (0xda2dcde31b020b6b6f8c02d2bf4821db22091750, 'Puffer Finance', 'Puffer Finance 33', 'Liquid Restaking') + , (0x21b5e2044f73b257cdbe3bdc402f02b404cbfbf1, 'Puffer Finance', 'Puffer Finance 34', 'Liquid Restaking') + , (0x32eec068c4d0578b94169726890d5395d4647dc4, 'Puffer Finance', 'Puffer Finance 35', 'Liquid Restaking') + , (0xd346547f70ef624b36d5ec284c6d27710920b712, 'Puffer Finance', 'Puffer Finance 36', 'Liquid Restaking') + , (0x70d8c06125145281710dd73de382b7c1938200ea, 'Puffer Finance', 'Puffer Finance 37', 'Liquid Restaking') + , (0xd52fcbb08732de26a99a7f0c0a50412820a4b683, 'Puffer Finance', 'Puffer Finance 38', 'Liquid Restaking') + , (0x55efc9f901a5ada996011276450f7320729223b0, 'Puffer Finance', 'Puffer Finance 39', 'Liquid Restaking') + , (0x970601aeecf72a18c3afddd29078fd89a4bc267e, 'Puffer Finance', 'Puffer Finance 40', 'Liquid Restaking') + , (0xc1102180394132f19b6a50a158ec313ceffc4a3a, 'Puffer Finance', 'Puffer Finance 41', 'Liquid Restaking') + , (0x779190349f31c7bba1db2da051f118bf3074a477, 'Puffer Finance', 'Puffer Finance 42', 'Liquid Restaking') + , (0xf2d65e8093201c1645b822f9849fe375ea96056a, 'Puffer Finance', 'Puffer Finance 43', 'Liquid Restaking') + , (0x3923eb2d93c84baf3fa60a277db720228647def7, 'Puffer Finance', 'Puffer Finance 44', 'Liquid Restaking') + , (0xb1ee744162e94cced7cab1d53d81664950e41c39, 'Puffer Finance', 'Puffer Finance 45', 'Liquid Restaking') + , (0xd7988e9347f0eaea570695e88acea9cc6b66be13, 'Puffer Finance', 'Puffer Finance 46', 'Liquid Restaking') + , (0x6c6f3c472b5180df84efc7d65e81f7950d87a3f6, 'Puffer Finance', 'Puffer Finance 47', 'Liquid Restaking') + , (0xdf762d0afc382850c5160e6a4d3cf521774032f9, 'Puffer Finance', 'Puffer Finance 48', 'Liquid Restaking') + , (0xca3964974bae15cb7d941b32712302b2b6c5d4ab, 'Puffer Finance', 'Puffer Finance 49', 'Liquid Restaking') + , (0xf8baa75b11d8dda80ad286254aac9d08edb505c1, 'Puffer Finance', 'Puffer Finance 50', 'Liquid Restaking') + , (0xb53d7bcbc30652ff35650246e3b591a064266b2b, 'Puffer Finance', 'Puffer Finance 51', 'Liquid Restaking') + , (0x57f514aab0ec72cdb9d2d01cae0dd6ecd4981ce1, 'Puffer Finance', 'Puffer Finance 52', 'Liquid Restaking') + , (0xfa33e7d1bdfcb213e0cffa6e981fcad12d1638fa, 'Puffer Finance', 'Puffer Finance 53', 'Liquid Restaking') + , (0x8e59e546b97eaaab54f9650c89dc3875556d9635, 'Puffer Finance', 'Puffer Finance 54', 'Liquid Restaking') + , (0x024d2378d80df4c6f49cb1f388d5a53d42c3e5fd, 'Puffer Finance', 'Puffer Finance 55', 'Liquid Restaking') + , (0x4bbe8d3bb39d30e1f29678ad0b3039b397c1d55f, 'Puffer Finance', 'Puffer Finance 56', 'Liquid Restaking') + , (0x2a89d38a2fd5b3d90c6f3813d23e0c2ed33cd7e2, 'Puffer Finance', 'Puffer Finance 57', 'Liquid Restaking') + , (0x9ae3eb1948e70c7f9804e30a34e8c25e0dd8261d, 'Puffer Finance', 'Puffer Finance 58', 'Liquid Restaking') + , (0x5905361a292c4582139a9ceaec1a71ea950d0677, 'Puffer Finance', 'Puffer Finance 59', 'Liquid Restaking') + , (0x3c12e47bd31b7c72ab05b514abae4b5abe871072, 'Puffer Finance', 'Puffer Finance 60', 'Liquid Restaking') + , (0x4cda1525b7d6577a59b6325201b3a68939da91d8, 'Puffer Finance', 'Puffer Finance 61', 'Liquid Restaking') + , (0xe097f793464e4503616e55d28294bf0fb982d14f, 'Puffer Finance', 'Puffer Finance 62', 'Liquid Restaking') + , (0xb92ac33d59ec4f93787acc773ba6e26ef536749a, 'Puffer Finance', 'Puffer Finance 63', 'Liquid Restaking') + , (0xad3f79fdf705cda1e8d9d7c398a678ee6ebb2cab, 'Puffer Finance', 'Puffer Finance 64', 'Liquid Restaking') + , (0xdbe13208672a329ac8827d5752ba3e63253617aa, 'Puffer Finance', 'Puffer Finance 65', 'Liquid Restaking') + , (0x11d28e6a3a8513432af889b25318d9b94bcb0d99, 'Puffer Finance', 'Puffer Finance 66', 'Liquid Restaking') + , (0xd695b18944902c0a2c899aaa789e06d30e6b0c6c, 'Puffer Finance', 'Puffer Finance 67', 'Liquid Restaking') + , (0xec77866c71f19b694b2d1640b0dc8585a3555596, 'Puffer Finance', 'Puffer Finance 68', 'Liquid Restaking') + , (0x5fee3852b09fd5be7043ba5eca71e674ea80c3ff, 'Puffer Finance', 'Puffer Finance 69', 'Liquid Restaking') + , (0x00c89174d831744ab9f004fc8056f85152443acc, 'Puffer Finance', 'Puffer Finance 70', 'Liquid Restaking') + , (0x4e15b6331eadaa84750870e4e24b84780c88ff91, 'Puffer Finance', 'Puffer Finance 71', 'Liquid Restaking') + , (0x444595c69006f6ac6acbf55d362d3036f5b636aa, 'Puffer Finance', 'Puffer Finance 72', 'Liquid Restaking') + , (0xd44cf40b14249811a50dcb6dbd809e94e421929e, 'Puffer Finance', 'Puffer Finance 73', 'Liquid Restaking') + , (0x572c5dfcbbec6815978adf2a835a34e8f04156fb, 'Puffer Finance', 'Puffer Finance 74', 'Liquid Restaking') + , (0xfe41129f707591fda06bfa30df467351d09f1806, 'Puffer Finance', 'Puffer Finance 75', 'Liquid Restaking') + , (0x5cc1a39d0b448ece222a3e2891315b7d3c104d62, 'Puffer Finance', 'Puffer Finance 76', 'Liquid Restaking') + , (0xc360a5080719b3819531e6a9135d7062a9aa71a4, 'Puffer Finance', 'Puffer Finance 77', 'Liquid Restaking') + , (0xd96ffffb94f1484903c4022f128830f636c696ef, 'Puffer Finance', 'Puffer Finance 78', 'Liquid Restaking') + , (0x1d5b496c6992e6ebcf7a38a4097017fad76457a8, 'Puffer Finance', 'Puffer Finance 79', 'Liquid Restaking') + , (0x364942ade69dd27ec53092aece9b0604c1ec45ae, 'Puffer Finance', 'Puffer Finance 80', 'Liquid Restaking') + , (0x31710a5588cd7fadbf5002744ee433a3ec5bf75b, 'Puffer Finance', 'Puffer Finance 81', 'Liquid Restaking') + , (0x75408e3a95a0d4db54a11b171e591f706d991e7a, 'Puffer Finance', 'Puffer Finance 82', 'Liquid Restaking') + , (0xb25cfe029b6dcd87d5d9ae333e587b7a4873ce29, 'Puffer Finance', 'Puffer Finance 83', 'Liquid Restaking') + , (0xd338e780a5b900ac66d16c106f8babb47040e47b, 'Puffer Finance', 'Puffer Finance 84', 'Liquid Restaking') + , (0xe859a34cdd097ac7e8167ad828ca9ad969925a6a, 'Puffer Finance', 'Puffer Finance 85', 'Liquid Restaking') + , (0xdd86602cda86bfa8d26cadb8fdafccf325e35433, 'Puffer Finance', 'Puffer Finance 86', 'Liquid Restaking') + , (0x97f51ba27bdee65bb87ffe38e4a88c9c938272f7, 'Puffer Finance', 'Puffer Finance 87', 'Liquid Restaking') + , (0xe1e2cac176c707d83206d27b49ade82d94807212, 'Puffer Finance', 'Puffer Finance 88', 'Liquid Restaking') + , (0x56bfcc391b0be76a0fbd3c1b3c5e934680c92b0c, 'Puffer Finance', 'Puffer Finance 89', 'Liquid Restaking') + , (0xb74f9126dd7f3817dc69ae0830e25c03bdb5475f, 'Puffer Finance', 'Puffer Finance 90', 'Liquid Restaking') + , (0xef9c44b3b1a8101eba04e75c21f6ac67a4e0e626, 'Puffer Finance', 'Puffer Finance 91', 'Liquid Restaking') + , (0x36b955ca9b2a40d47a0b0ba39c1e70331e344918, 'Puffer Finance', 'Puffer Finance 92', 'Liquid Restaking') + , (0xa709eb9a291304f99b830017523af8f1b9196fdf, 'Puffer Finance', 'Puffer Finance 93', 'Liquid Restaking') + , (0x3a4c38b8f96c55ca42d7d1185cae7443d1d15c2b, 'Puffer Finance', 'Puffer Finance 94', 'Liquid Restaking') + , (0x4b408f1ca8f09d0d9707ae5124238f451175d2ac, 'Puffer Finance', 'Puffer Finance 95', 'Liquid Restaking') + , (0x29346db21c7a5cdc9cd6fca73bbfea30054ab5dc, 'Puffer Finance', 'Puffer Finance 96', 'Liquid Restaking') + , (0x141e6f34ff332e998f431199bedd6b0d0d10f860, 'Puffer Finance', 'Puffer Finance 97', 'Liquid Restaking') + , (0xc303c9f5fa828c01a85434e53fe0c8f899585461, 'Puffer Finance', 'Puffer Finance 98', 'Liquid Restaking') + , (0xc7b096aa18541d4d9a3d617108f6935e65e5d069, 'Puffer Finance', 'Puffer Finance 99', 'Liquid Restaking') + , (0xfbd2ab8d3b73a101e004bcfbac71caccf59071a5, 'Puffer Finance', 'Puffer Finance 100', 'Liquid Restaking') + , (0x4bd8704cc263618e0620db01dbe30211de1dc72e, 'Puffer Finance', 'Puffer Finance 101', 'Liquid Restaking') + , (0x6b54b0c3df5c0b40f56ecc47761ba28d00776c16, 'Puffer Finance', 'Puffer Finance 102', 'Liquid Restaking') + , (0x09d4a923d904a86898898a79530190c40f5259e6, 'Puffer Finance', 'Puffer Finance 103', 'Liquid Restaking') + , (0xde377a6dc62a749daf6598cb0dba960c63d96ce7, 'Puffer Finance', 'Puffer Finance 104', 'Liquid Restaking') + , (0xc764054bded8ec0b71558e84615745f75cb6fd5c, 'Puffer Finance', 'Puffer Finance 105', 'Liquid Restaking') + , (0x123f83325405375fec9aa1be806668ee67d0602a, 'Puffer Finance', 'Puffer Finance 106', 'Liquid Restaking') + , (0xc63bf25a5f1f0ddaf87708087c8a1ea6de97ff23, 'Puffer Finance', 'Puffer Finance 107', 'Liquid Restaking') + , (0xdd5546d2849fbf9af452df2b1f8f00f8c32cd645, 'Puffer Finance', 'Puffer Finance 108', 'Liquid Restaking') + , (0x940c8dfad0c5e596d98e6acbf34d5edfbef11042, 'Puffer Finance', 'Puffer Finance 109', 'Liquid Restaking') + , (0x4a012f0388b469615740ebfbbd2dcd847922659b, 'Puffer Finance', 'Puffer Finance 110', 'Liquid Restaking') + , (0x311a752130c8e136dd1c6de8313d269b6105d319, 'Puffer Finance', 'Puffer Finance 111', 'Liquid Restaking') + , (0xdd6c3b2f31e0db1eaadbd55245cfcb69d9c7a67c, 'Puffer Finance', 'Puffer Finance 112', 'Liquid Restaking') + , (0x4f0f64afca99e253a89823c835ddb4d950cf6652, 'Puffer Finance', 'Puffer Finance 113', 'Liquid Restaking') + , (0x3a431a60e0281bcd600fd02e6d4ab03ca72d7210, 'Puffer Finance', 'Puffer Finance 114', 'Liquid Restaking') + , (0x0753edfd731698a1ac669c7c07602cbc3946bc5b, 'Puffer Finance', 'Puffer Finance 115', 'Liquid Restaking') + , (0x5a575603eaba67982da722f94b6ea60cf9b877b0, 'Puffer Finance', 'Puffer Finance 116', 'Liquid Restaking') + , (0xfb31d482c5736a1bde326ac4621af0a142ce4046, 'Puffer Finance', 'Puffer Finance 117', 'Liquid Restaking') + , (0x0b45151f012adcbf717f007d18a18302e020c01f, 'Puffer Finance', 'Puffer Finance 118', 'Liquid Restaking') + , (0x7b658386c82cd2752eb839f7a188cf048744686f, 'Puffer Finance', 'Puffer Finance 119', 'Liquid Restaking') + , (0x7de3ed7d22cb8d443ca2e67d9c23cc2b14a99f35, 'Puffer Finance', 'Puffer Finance 120', 'Liquid Restaking') + , (0xad9b35123d1921a36a34ec806589e5d7c0777e72, 'Puffer Finance', 'Puffer Finance 121', 'Liquid Restaking') + , (0x092af2ef103626f55507b5a0efe1ed3f69af2c70, 'Puffer Finance', 'Puffer Finance 122', 'Liquid Restaking') + , (0xb2a550fcf3cfd3b16758b6efc7394aaf2ddf0601, 'Puffer Finance', 'Puffer Finance 123', 'Liquid Restaking') + , (0x0018ad99b4c14f03f23012032fc50d1c3c011967, 'Puffer Finance', 'Puffer Finance 124', 'Liquid Restaking') + , (0x18d2df1cc6a44c32b52ffef413b15f14970f4002, 'Puffer Finance', 'Puffer Finance 125', 'Liquid Restaking') + , (0x7c1b25774b2eb89499a73c71b629aa03f0ba4c3c, 'Puffer Finance', 'Puffer Finance 126', 'Liquid Restaking') + , (0xb21f8d9fc1d40ca63e190394fa8ad65cb4048d6f, 'Puffer Finance', 'Puffer Finance 127', 'Liquid Restaking') + , (0x89c31588cc483227355ad2f315f58c4c4db5026d, 'Puffer Finance', 'Puffer Finance 128', 'Liquid Restaking') + , (0xc2159dfff1c97c79678b40ae234eef8246ff6332, 'Puffer Finance', 'Puffer Finance 129', 'Liquid Restaking') + , (0xd20ec2ccff5a0918179f351b15cd476e6ce7a5f3, 'Puffer Finance', 'Puffer Finance 130', 'Liquid Restaking') + , (0xca36526e36283a6420d740ff8d6b3b5a834c363e, 'Puffer Finance', 'Puffer Finance 131', 'Liquid Restaking') + , (0xaad53d757777594c36c6651db07f71bbd8fe1930, 'Puffer Finance', 'Puffer Finance 132', 'Liquid Restaking') + , (0x055057b3f45c308b7b45c1fdd5b68ae17d3f781f, 'Puffer Finance', 'Puffer Finance 133', 'Liquid Restaking') + , (0x3bd05798c9d0ed496a1765a132f26f210b9dadc7, 'Puffer Finance', 'Puffer Finance 134', 'Liquid Restaking') + , (0x98968937aa45a038a33c9874aac8d054a1bb8746, 'Puffer Finance', 'Puffer Finance 135', 'Liquid Restaking') + , (0x3de5c8a0e6de069a3de7f45e52b90904cf55835f, 'Puffer Finance', 'Puffer Finance 136', 'Liquid Restaking') + , (0xd9dc6ae799c8b6ab05e52f9afc11e2a9d7d51652, 'Puffer Finance', 'Puffer Finance 137', 'Liquid Restaking') + , (0xadac63898060366642ba068650054d3a8c5e73d9, 'Puffer Finance', 'Puffer Finance 138', 'Liquid Restaking') + , (0x32e0c22fce8996ccf63fad5aaa13b5556bec13ef, 'Puffer Finance', 'Puffer Finance 139', 'Liquid Restaking') + , (0x05e8728dd7e1e10f06c9db765cbeabbf194c3e3f, 'Puffer Finance', 'Puffer Finance 140', 'Liquid Restaking') + , (0xccc08fe71dbec373c58053c58a3ccbec3a820369, 'Puffer Finance', 'Puffer Finance 141', 'Liquid Restaking') + , (0x9b0255f8a853df6c32e1a355cb8b93281250f558, 'Puffer Finance', 'Puffer Finance 142', 'Liquid Restaking') + , (0x09f2180e5636a00f561853e39e0ac65dbfc79232, 'Puffer Finance', 'Puffer Finance 143', 'Liquid Restaking') + , (0x623bf63a1ff6f302a027439ba274057752172b38, 'Puffer Finance', 'Puffer Finance 144', 'Liquid Restaking') + , (0xc97474cdc5e92c6ff908cbcbacd310d57d0c73fe, 'Puffer Finance', 'Puffer Finance 145', 'Liquid Restaking') + , (0x7fae2df6c1c5baff660596d4d9c406b15d47d003, 'Puffer Finance', 'Puffer Finance 146', 'Liquid Restaking') + , (0x026503a3c936366d47527d9354d1c614365af921, 'Puffer Finance', 'Puffer Finance 147', 'Liquid Restaking') + , (0x163994918de24bfd5151846b29f441aff6d2cd7b, 'Puffer Finance', 'Puffer Finance 148', 'Liquid Restaking') + , (0xdd5a51b834bd1ee100d2d23eb99c669ad8c11362, 'Puffer Finance', 'Puffer Finance 149', 'Liquid Restaking') + , (0x48e81b5d6ac6f03f71da4ac1a40217ebfad5351e, 'Puffer Finance', 'Puffer Finance 150', 'Liquid Restaking') + , (0xe141859cf4477f04c50c9c5f8c281204671c83cf, 'Puffer Finance', 'Puffer Finance 151', 'Liquid Restaking') + , (0x865b02589436c61e7c0c4ab0e14156c698b203b2, 'Puffer Finance', 'Puffer Finance 152', 'Liquid Restaking') + , (0xdc717de5d799fca961daf88c12f61385ce898212, 'Puffer Finance', 'Puffer Finance 153', 'Liquid Restaking') + , (0xa76e9964f530a5290a3507160a7225ec52cbf159, 'Puffer Finance', 'Puffer Finance 154', 'Liquid Restaking') + , (0xc3fa8b2a4fd55b33ac09e3054b2dbc2a36ef7eac, 'Puffer Finance', 'Puffer Finance 155', 'Liquid Restaking') + , (0x7d9a197229bc1cc75567a31391f6db4d815cf218, 'Puffer Finance', 'Puffer Finance 156', 'Liquid Restaking') + , (0xca4be9d9c8f038097cf0a8265da5202556960e52, 'Puffer Finance', 'Puffer Finance 157', 'Liquid Restaking') + , (0x45d43e2f059553c003029d66c0ed0827a9652260, 'Puffer Finance', 'Puffer Finance 158', 'Liquid Restaking') + , (0x32d334624fc6c8e95a531f6304e5448830c53fde, 'Puffer Finance', 'Puffer Finance 159', 'Liquid Restaking') + , (0xff08e263ac3fe9f480db17d9d32a84a380d7da61, 'Puffer Finance', 'Puffer Finance 160', 'Liquid Restaking') + , (0x5e46cc19b371577b91336cca60d071d694a74c6d, 'Puffer Finance', 'Puffer Finance 161', 'Liquid Restaking') + , (0x5dd6862e9ae19096a6c3e41070a0edeafea87ef0, 'Puffer Finance', 'Puffer Finance 162', 'Liquid Restaking') + , (0x6537dd3904653ec917b78d58f4ceac0235504464, 'Puffer Finance', 'Puffer Finance 163', 'Liquid Restaking') + , (0x39e6481ac8ce709fb8179769c0cbc9724c4e60f2, 'Puffer Finance', 'Puffer Finance 164', 'Liquid Restaking') + , (0x044be5d76576e34b00c199833a043dd483f8485b, 'Puffer Finance', 'Puffer Finance 165', 'Liquid Restaking') + , (0x4973a0a7de9b6942d297b82a783f6d0b8ec766cf, 'Puffer Finance', 'Puffer Finance 166', 'Liquid Restaking') + , (0x3b181d9b973265f2e690082b7b7deee660257384, 'Puffer Finance', 'Puffer Finance 167', 'Liquid Restaking') + , (0x83fc4377413827eca613a285376decce83354e02, 'Puffer Finance', 'Puffer Finance 168', 'Liquid Restaking') + , (0x5a2ea2b6d4ad7dab917e32ff45f85d1d5b4839ad, 'Puffer Finance', 'Puffer Finance 169', 'Liquid Restaking') + , (0x5418384a834ed08d2b5834f0ded7dcd4d8e02854, 'Puffer Finance', 'Puffer Finance 170', 'Liquid Restaking') + , (0xa74034c7f7f4388e024f63b33626213181d6b984, 'Puffer Finance', 'Puffer Finance 171', 'Liquid Restaking') + , (0xc9ac5524af6ca89f751aa49fb0da479cf5456bb0, 'Puffer Finance', 'Puffer Finance 172', 'Liquid Restaking') + , (0xc48e944c94be1ec121d6cf68f79f2ef94ec44ca5, 'Puffer Finance', 'Puffer Finance 173', 'Liquid Restaking') + , (0x01362e34c82d4e08a2218684f100391789921168, 'Puffer Finance', 'Puffer Finance 174', 'Liquid Restaking') + , (0x45b3dca5af653c791ca49387f64b1e83cb96994c, 'Puffer Finance', 'Puffer Finance 175', 'Liquid Restaking') + , (0xf5b0876efca1d435b619a694df60f446e93b3575, 'Puffer Finance', 'Puffer Finance 176', 'Liquid Restaking') + , (0x955d790417412ea7796676a16984c3a4ea5f830e, 'Puffer Finance', 'Puffer Finance 177', 'Liquid Restaking') + , (0x79a22635558dbae83af0b43d18b11e9d14d66764, 'Puffer Finance', 'Puffer Finance 178', 'Liquid Restaking') + , (0xd753548fc97aed8e3c30181bdb5f3a26836e4f4a, 'Puffer Finance', 'Puffer Finance 179', 'Liquid Restaking') + , (0xf2fe031f1c1bbecdb21d3aba73db5146885ad56b, 'Puffer Finance', 'Puffer Finance 180', 'Liquid Restaking') + , (0x13e0d6f093f4745b7f619a5cc03c434e435fb7c2, 'Puffer Finance', 'Puffer Finance 181', 'Liquid Restaking') + , (0xad3b31617912a21f07a000022f4ce69f28175d9c, 'Puffer Finance', 'Puffer Finance 182', 'Liquid Restaking') , (0xdf8f9a7f1f8eb645dc3c95354d2c909c2fdaf0e3, 'Eigenpie', 'Eigenpie 1', 'Liquid Restaking') , (0x7ef5d450be41fcbc6191cb09789c5783da53f3fc, 'Copper.co', 'Copper.co', 'Staking Pool') , (0x44894aeee56c2dd589c1d5c8cb04b87576967f97, 'Upbit', 'Upbit 1', 'CEX') From 57936734e195d6927e1c27e8e2be2419152a5404 Mon Sep 17 00:00:00 2001 From: jeff-dude <102681548+jeff-dude@users.noreply.github.com> Date: Tue, 1 Oct 2024 15:34:09 -0400 Subject: [PATCH 122/127] `dex.prices_beta`: filter for trusted token per swap (#6847) * filter for trusted token per swap * update spell name to remove beta * attempt new logic * fix order of operations * fix array syntax * test merge strategy --- dbt_subprojects/dex/models/prices/_schema.yml | 14 +++++++-- ...x_prices_beta.sql => dex_prices_block.sql} | 30 ++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) rename dbt_subprojects/dex/models/prices/{dex_prices_beta.sql => dex_prices_block.sql} (79%) diff --git a/dbt_subprojects/dex/models/prices/_schema.yml b/dbt_subprojects/dex/models/prices/_schema.yml index c023a6b015d..da708e7d8ef 100644 --- a/dbt_subprojects/dex/models/prices/_schema.yml +++ b/dbt_subprojects/dex/models/prices/_schema.yml @@ -1,9 +1,19 @@ version: 2 models: - - name: dex_prices_beta + - name: dex_prices_block description: > - obtain pricing info from dex.trades to feed into prices pipeline + obtain pricing info from dex.trades to feed into prices pipeline, aggregate to the block level and obtain median price + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_month + - blockchain + - contract_address + - symbol + - decimals + - block_number + - block_time - name: dex_prices meta: diff --git a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql b/dbt_subprojects/dex/models/prices/dex_prices_block.sql similarity index 79% rename from dbt_subprojects/dex/models/prices/dex_prices_beta.sql rename to dbt_subprojects/dex/models/prices/dex_prices_block.sql index 2468371f394..91e5eacdd43 100644 --- a/dbt_subprojects/dex/models/prices/dex_prices_beta.sql +++ b/dbt_subprojects/dex/models/prices/dex_prices_block.sql @@ -1,14 +1,16 @@ {{ config( schema = 'dex' - , alias = 'prices_beta' + , alias = 'prices_block' , partition_by = ['block_month'] , materialized = 'incremental' , file_format = 'delta' - , incremental_strategy = 'append' + , incremental_strategy = 'merge' + , unique_key = ['block_month', 'blockchain', 'contract_address', 'symbol', 'decimals', 'block_number', 'block_time'] + , incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] ) }} -with dex_trades as ( +with dex_trades_raw as ( select blockchain , block_number @@ -20,15 +22,35 @@ with dex_trades as ( , token_sold_amount_raw , token_sold_amount , amount_usd + , array[token_bought_address, token_sold_address] as tokens_swapped from {{ ref('dex_trades') }} where 1 = 1 and amount_usd > 0 {% if is_incremental() %} - and block_time > (select max(block_time) from {{ this }}) + and {{ incremental_predicate('block_time') }} {% endif %} ), +dex_trades as ( + select distinct + t.blockchain + , t.block_number + , t.block_time + , t.token_bought_address + , t.token_bought_amount_raw + , t.token_bought_amount + , t.token_sold_address + , t.token_sold_amount_raw + , t.token_sold_amount + , t.amount_usd + from + dex_trades_raw as t + --only output swaps which contain a trusted token + inner join {{ source('prices', 'trusted_tokens') }} as tt + on t.blockchain = tt.blockchain + and contains(t.tokens_swapped, tt.contract_address) +), dex_bought as ( select d.blockchain From e1feaa85df1145f98ce59e3eefcbe4834b87a54b Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:03:43 -0300 Subject: [PATCH 123/127] Create balancer.view_pools_latest (#6819) * 1st attempt * first attempt * fix source * again * update schemas * fix * fix schema * retry * again * again * retry --- .../_project/balancer/pools/_schema.yml | 45 ++++++++++++++++--- .../pools/balancer_view_pools_latest.sql | 37 +++++++++++++++ sources/_datasets/dune_upload_sources.yml | 6 ++- .../ethereum/community_base_sources.yml | 3 +- 4 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_view_pools_latest.sql diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/_schema.yml index 88b3adaa386..e4ae7af282d 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/_schema.yml @@ -42,7 +42,7 @@ models: config: tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'balancer', 'pool', 'stats', 'volume', 'tvl', 'fee'] description: > - This spell aggregates data from the trades, liquidity and protocol fees spells, by day and pool, while also displaying some basic information about the pool + This spell aggregates data from the trades, liquidity and protocol fees spells, by day and pool, while also displaying some basic information about the pool. tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: @@ -77,7 +77,7 @@ models: description: "Total Value Locked on a pool, in USD" - &tvl_eth name: tvl_eth - description: "Total Value Locked on a pool, in eth" + description: "Total Value Locked on a pool, in ETH" - &fee_amount_usd name: fee_amount_usd description: "Daily fees collected on a pool, in USD" @@ -90,7 +90,7 @@ models: config: tags: ['balancer', 'amm', 'trades', 'dex', 'incentives'] description: > - Gauge to Pool mappings for balancer on all chains + Gauge to Pool mappings for balancer on all chains. columns: - *blockchain - *version @@ -119,5 +119,40 @@ models: name: evt_tx_hash description: 'Transaction hash' - &evt_index - name: evT_index - description: 'Event Index' \ No newline at end of file + name: evt_index + description: 'Event Index' + + - name: balancer_view_pools_latest + meta: + blockchain: arbitrum, avalanche_c, base, ethereum, gnosis, optimism, polygon, zkevm + contributors: viniabussafi + config: + tags: ['arbitrum', 'avalanche_c', 'base', 'ethereum', 'gnosis', 'optimism', 'polygon', 'zkevm', 'balancer', 'pool', 'stats', 'volume', 'tvl', 'fee'] + description: > + This spell aggregates data from the trades, liquidity, and protocol fees spells, by pool, while also displaying information about the pool creation. + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - blockchain + - pool_id + columns: + - *blockchain + - name: pool_id + - name: pool_address + - name: pool_symbol + - name: pool_type + - name: factory_version + - name: factory_address + - name: creation_date + - name: tvl_usd + - name: tvl_eth + - name: swap_volume + - name: swap_volume_1y + - name: swap_volume_30d + - name: swap_volume_7d + - name: swap_volume_1d + - name: fees_collected + - name: fees_collected_1y + - name: fees_collected_30d + - name: fees_collected_7d + - name: fees_collected_1d diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_view_pools_latest.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_view_pools_latest.sql new file mode 100644 index 00000000000..2386f636a48 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/pools/balancer_view_pools_latest.sql @@ -0,0 +1,37 @@ +{{ config( + schema = 'balancer', + alias = 'view_pools_latest', + post_hook='{{ expose_spells(blockchains = \'["arbitrum", "avalanche_c", "base", "ethereum", "gnosis", "optimism", "polygon", "zkevm"]\', + spell_type = "project", + spell_name = "balancer", + contributors = \'["viniabussafi"]\') }}' + ) +}} + +SELECT + m.blockchain, + m.pool_id, + m.pool_address, + m.pool_symbol, + m.pool_type, + m.factory_version, + m.factory_address, + m.creation_date, + SUM(CASE WHEN block_date = (SELECT MAX(block_date) FROM {{ref('balancer_pools_metrics_daily')}}) + THEN tvl_usd END) AS tvl_usd, + SUM(CASE WHEN block_date = (SELECT MAX(block_date) FROM {{ref('balancer_pools_metrics_daily')}}) + THEN tvl_eth END) AS tvl_eth, + SUM(swap_amount_usd) AS swap_volume, + SUM(CASE WHEN block_date > CURRENT_DATE - INTERVAL '365' day THEN swap_amount_usd END) AS swap_volume_1y, + SUM(CASE WHEN block_date > CURRENT_DATE - INTERVAL '30' day THEN swap_amount_usd END) AS swap_volume_30d, + SUM(CASE WHEN block_date > CURRENT_DATE - INTERVAL '7' day THEN swap_amount_usd END) AS swap_volume_7d, + SUM(CASE WHEN block_date > CURRENT_DATE - INTERVAL '1' day THEN swap_amount_usd END) AS swap_volume_1d, + SUM(fee_amount_usd) AS fees_collected, + SUM(CASE WHEN block_date > CURRENT_DATE - INTERVAL '365' day THEN fee_amount_usd END) AS fees_collected_1y, + SUM(CASE WHEN block_date > CURRENT_DATE - INTERVAL '30' day THEN fee_amount_usd END) AS fees_collected_30d, + SUM(CASE WHEN block_date > CURRENT_DATE - INTERVAL '7' day THEN fee_amount_usd END) AS fees_collected_7d, + SUM(CASE WHEN block_date > CURRENT_DATE - INTERVAL '1' day THEN fee_amount_usd END) AS fees_collected_1d +FROM {{ source("balancer", "dataset_factory_pool_mapping", database = "dune") }} m +LEFT JOIN {{ref('balancer_pools_metrics_daily')}} p ON m.blockchain = p.blockchain +AND m.pool_address = p.project_contract_address +GROUP BY 1, 2, 3, 4, 5, 6, 7, 8 \ No newline at end of file diff --git a/sources/_datasets/dune_upload_sources.yml b/sources/_datasets/dune_upload_sources.yml index fc30a52aa94..5fb8590b981 100644 --- a/sources/_datasets/dune_upload_sources.yml +++ b/sources/_datasets/dune_upload_sources.yml @@ -8,4 +8,8 @@ sources: - name: op_stack_chain_metadata - name: op_airdrop1_addresses_detailed_list - name: op_airdrop2_addresses_detailed_list - - name: op_airdrop_3_addresses_detailed_list \ No newline at end of file + - name: op_airdrop_3_addresses_detailed_list + + - name: balancer + tables: + - name: dataset_factory_pool_mapping \ No newline at end of file diff --git a/sources/_datasets/reservoir/ethereum/community_base_sources.yml b/sources/_datasets/reservoir/ethereum/community_base_sources.yml index 983e89be1b3..4ee4d1d7a8d 100644 --- a/sources/_datasets/reservoir/ethereum/community_base_sources.yml +++ b/sources/_datasets/reservoir/ethereum/community_base_sources.yml @@ -7,7 +7,6 @@ sources: tables: - name: collections - name: collection_floor_ask_events - description: "todo: add reservoir table description!" columns: - name: created_at @@ -27,4 +26,4 @@ sources: - name: tx_timestamp - name: valid_until - name: tx_timestamp_dt - - name: valid_until_dt \ No newline at end of file + - name: valid_until_dt From eead2f232efb9d49789fa0129cf9505785c123b0 Mon Sep 17 00:00:00 2001 From: ppclunghe <90045511+ppclunghe@users.noreply.github.com> Date: Wed, 2 Oct 2024 18:04:04 +0200 Subject: [PATCH 124/127] Lido liquidity updates (#6815) * lido liquidity updates * fix pancake bnb * pancake pools * thena pools * maverick pools * nuri pools * lynex pools * lynex fix * balancer pools --- ...lido_liquidity_arbitrum_balancer_pools.sql | 7 +- ...iquidity_arbitrum_pancakeswap_v3_pools.sql | 263 +++++++++++++++++ .../lido_liquidity_base_maverick_pools.sql | 254 ++++++++++++++++ ...do_liquidity_base_pancakeswap_v3_pools.sql | 263 +++++++++++++++++ ...ido_liquidity_bnb_pancakeswap_v3_pools.sql | 263 +++++++++++++++++ .../bnb/lido_liquidity_bnb_schema.yml | 64 ++++ .../bnb/lido_liquidity_bnb_thena_pools.sql | 242 +++++++++++++++ ...lido_liquidity_ethereum_balancer_pools.sql | 6 +- ...dity_ethereum_curve_wsteth_pufeth_pool.sql | 236 +++++++++++++++ .../lido_liquidity_linea_lynex_pools.sql | 275 +++++++++++++++++ .../lido_liquidity_scroll_maverick_pools.sql | 254 ++++++++++++++++ .../lido_liquidity_scroll_nuri_pools.sql | 276 ++++++++++++++++++ ..._liquidity_zksync_pancakeswap_v3_pools.sql | 263 +++++++++++++++++ .../lido_liquidity_arbitrum_sources.yml | 8 +- .../base/lido_liquidity_base_sources.yml | 13 + .../bnb/lido_liquidity_bnb_sources.yml | 22 ++ .../lido_liquidity_ethereum_sources.yml | 8 +- .../linea/lido_liquidity_linea_sources.yml | 5 + .../scroll/lido_liquidity_scroll_sources.yml | 12 + .../zksync/lido_liquidity_zksync_sources.yml | 7 +- 20 files changed, 2736 insertions(+), 5 deletions(-) create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/arbitrum/lido_liquidity_arbitrum_pancakeswap_v3_pools.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/base/lido_liquidity_base_maverick_pools.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/base/lido_liquidity_base_pancakeswap_v3_pools.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_pancakeswap_v3_pools.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_schema.yml create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_thena_pools.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/ethereum/lido_liquidity_ethereum_curve_wsteth_pufeth_pool.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/linea/lido_liquidity_linea_lynex_pools.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/scroll/lido_liquidity_scroll_maverick_pools.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/scroll/lido_liquidity_scroll_nuri_pools.sql create mode 100644 dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/zksync/lido_liquidity_zksync_pancakeswap_v3_pools.sql create mode 100644 sources/lido/liquidity/bnb/lido_liquidity_bnb_sources.yml diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/arbitrum/lido_liquidity_arbitrum_balancer_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/arbitrum/lido_liquidity_arbitrum_balancer_pools.sql index e1bb4e49682..a867ab6a63e 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/arbitrum/lido_liquidity_arbitrum_balancer_pools.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/arbitrum/lido_liquidity_arbitrum_balancer_pools.sql @@ -25,7 +25,12 @@ values (0xfb5e6d0c1dfed2ba000fbc040ab8df3615ac329c000000000000000000000159, 0xfb5e6d0c1dfed2ba000fbc040ab8df3615ac329c), (0xb5bd58c733948e3d65d86ba9604e06e5da276fd10002000000000000000003e6, 0xb5bd58c733948e3d65d86ba9604e06e5da276fd1), (0x178e029173417b1f9c8bc16dcec6f697bc323746000200000000000000000158, 0x178e029173417b1f9c8bc16dcec6f697bc323746), -(0x45c4d1376943ab28802b995acffc04903eb5223f000000000000000000000470, 0x45c4d1376943ab28802b995acffc04903eb5223f) +(0x45c4d1376943ab28802b995acffc04903eb5223f000000000000000000000470, 0x45c4d1376943ab28802b995acffc04903eb5223f), +(0x9791d590788598535278552eecd4b211bfc790cb000000000000000000000498, 0x9791d590788598535278552eecd4b211bfc790cb), +(0x7967fa58b9501600d96bd843173b9334983ee6e600020000000000000000056e, 0x7967fa58b9501600d96bd843173b9334983ee6e6), +(0xb61371ab661b1acec81c699854d2f911070c059e000000000000000000000516, 0xb61371ab661b1acec81c699854d2f911070c059e), +(0xcdcef9765d369954a4a936064535710f7235110a000200000000000000000558, 0xcdcef9765d369954a4a936064535710f7235110a) + ) , tokens as ( diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/arbitrum/lido_liquidity_arbitrum_pancakeswap_v3_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/arbitrum/lido_liquidity_arbitrum_pancakeswap_v3_pools.sql new file mode 100644 index 00000000000..abc8c3bc136 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/arbitrum/lido_liquidity_arbitrum_pancakeswap_v3_pools.sql @@ -0,0 +1,263 @@ +{{ config( + schema='lido_liquidity_arbitrum', + alias = 'pancakeswap_v3_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["arbitrum"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2023-11-22' %} + +with + +pools as ( +select pool as address, 'arbitrum' as blockchain, 'pancakeswap' as project, max(cast(fee as double))/10000 as fee +from {{ source('pancakeswap_v3_arbitrum','PancakeV3Factory_evt_PoolCreated')}} +where token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 or token1 = 0x5979D7b546E38E414F7E9822514be443A4800529 +group by 1,2,3 +) + +, tokens as ( +select distinct token as address +from ( +select token1 as token +from {{ source('pancakeswap_v3_arbitrum','PancakeV3Factory_evt_PoolCreated')}} +where token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 +union +select token0 +from {{ source('pancakeswap_v3_arbitrum','PancakeV3Factory_evt_PoolCreated')}} +where token1 = 0x5979D7b546E38E414F7E9822514be443A4800529 +union +select 0x5979D7b546E38E414F7E9822514be443A4800529 +) t +) + +, tokens_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + contract_address as token, + decimals, + symbol, + avg(price) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'arbitrum' + and contract_address in (select address from tokens) + group by 1,2,3,4 + union all + SELECT distinct + DATE_TRUNC('day', minute), + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'arbitrum' + and contract_address in (select address from tokens) +) + +, tokens_prices_hourly AS ( + select time, + lead(time,1, DATE_TRUNC('hour', now() + interval '1' hour)) over (partition by token order by time) as next_time, + token, price, decimals, symbol + from ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'arbitrum' + and contract_address in (select address from tokens) +) p +) + + +, swap_events as ( + select + date_trunc('day', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.token0, cr.token1, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + + from {{ source('pancakeswap_v3_arbitrum', 'PancakeV3Pool_evt_Swap') }} sw + left join {{ source('pancakeswap_v3_arbitrum', 'PancakeV3Factory_evt_PoolCreated') }} cr on sw.contract_address = cr.pool + join pools on sw.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + group by 1,2,3,4 +) + +, mint_events as ( + select + date_trunc('day', mt.evt_block_time) as time, + mt.contract_address as pool, + cr.token0, cr.token1, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('pancakeswap_v3_arbitrum', 'PancakeV3Pool_evt_Mint') }} mt + left join {{ source('pancakeswap_v3_arbitrum', 'PancakeV3Factory_evt_PoolCreated') }} cr on mt.contract_address = cr.pool + join pools on mt.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', mt.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('mt.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + +, burn_events as ( + select + date_trunc('day', bn.evt_block_time) as time, + bn.contract_address as pool, + cr.token0, cr.token1, + (-1)*sum(cast(amount0 as DOUBLE)) as amount0, + (-1)*sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('pancakeswap_v3_arbitrum', 'PancakeV3Pool_evt_Burn') }} bn + left join {{ source('pancakeswap_v3_arbitrum', 'PancakeV3Factory_evt_PoolCreated') }} cr on bn.contract_address = cr.pool + join pools on bn.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', bn.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('bn.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + + , collect_events AS ( + SELECT + date_trunc('day', c.evt_block_time) as time, + c.contract_address AS pool, + cr.token0, + cr.token1, + (-1) * CAST(amount0 AS DOUBLE) AS amount0, + (-1) * CAST(amount1 AS DOUBLE) AS amount1, + c.evt_tx_hash + FROM + {{source('pancakeswap_v3_arbitrum','PancakeV3Pool_evt_Collect')}} AS c + LEFT JOIN {{source('pancakeswap_v3_arbitrum','PancakeV3Factory_evt_PoolCreated')}} AS cr ON c.contract_address = cr.pool + join pools on c.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', c.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('c.evt_block_time') }} + {% endif %} + + ) + + +, daily_delta_balance as ( + select time, pool, token0, token1, sum(coalesce(amount0, 0)) as amount0, sum(coalesce(amount1, 0)) as amount1 + from ( + select time, pool, token0, token1, amount0, amount1 + from swap_events + union all + select time, pool, token0, token1, amount0, amount1 + from mint_events + union all + select time, pool, token0, token1, amount0, amount1 + from collect_events + ) balance + group by 1,2,3,4 +) + +, pool_liquidity as ( + select time, + pool, + token0, + token1, + sum(amount0) as amount0, + sum(amount1) as amount1 + from daily_delta_balance + group by 1,2,3,4 +) + + +, swap_events_hourly as ( + select hour, pool, token0, token1, sum(amount0) as amount0, sum(amount1) as amount1 from ( + select + date_trunc('hour', sw.evt_block_time) as hour, + sw.contract_address as pool, + cr.token0, cr.token1, + coalesce(sum(cast(abs(amount0) as DOUBLE)),0) as amount0, + coalesce(sum(cast(abs(amount1) as DOUBLE)),0) as amount1 + + from {{source('pancakeswap_v3_arbitrum','PancakeV3Pool_evt_Swap')}} sw + left join {{source('pancakeswap_v3_arbitrum','PancakeV3Factory_evt_PoolCreated')}} cr on sw.contract_address = cr.pool + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + and sw.contract_address in (select address from pools) + group by 1,2,3,4 + + ) a group by 1,2,3,4 +) + +, trading_volume_hourly as ( + select hour as time, pool, token0, amount0, p.price, coalesce(p.price*amount0/power(10, p.decimals),0) as volume + from swap_events_hourly s + left join tokens t on s.token0 = t.address + left join tokens_prices_hourly p on s.hour >= p.time and s.hour < p.next_time and s.token0 = p.token + +) + +, trading_volume as ( +select distinct date_trunc('day', time) as time, pool, sum(volume) as volume +from trading_volume_hourly +group by 1,2 +) + +, all_metrics as ( +select l.pool, pools.blockchain, pools.project, pools.fee, cast(l.time as date) as time, + case when token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 then token0 else token1 end main_token, + case when token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 then p0.symbol else p1.symbol end main_token_symbol, + case when token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 then token1 else token0 end paired_token, + case when token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 then p1.symbol else p0.symbol end paired_token_symbol, + case when token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 then amount0/power(10, p0.decimals) else amount1/power(10, p1.decimals) end main_token_reserve, + case when token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 then amount1/power(10, p1.decimals) else amount0/power(10, p0.decimals) end paired_token_reserve, + case when token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 then p0.price else p1.price end as main_token_usd_price, + case when token0 = 0x5979D7b546E38E414F7E9822514be443A4800529 then p1.price else p0.price end as paired_token_usd_price, + volume as trading_volume +from pool_liquidity l +left join pools on l.pool = pools.address +left join tokens t0 on l.token0 = t0.address +left join tokens t1 on l.token1 = t1.address +left join tokens_prices_daily p0 on l.time = p0.time and l.token0 = p0.token +left join tokens_prices_daily p1 on l.time = p1.time and l.token1 = p1.token +left join trading_volume tv on l.time = tv.time and l.pool = tv.pool +) + + + +select blockchain||' '||project||' '||COALESCE(paired_token_symbol, 'unknown')||':'||main_token_symbol||' '||format('%,.3f',round(coalesce(fee,0),4)) as pool_name,* +from all_metrics + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/base/lido_liquidity_base_maverick_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/base/lido_liquidity_base_maverick_pools.sql new file mode 100644 index 00000000000..2a578e58007 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/base/lido_liquidity_base_maverick_pools.sql @@ -0,0 +1,254 @@ +{{ config( + schema='lido_liquidity_base', + alias = 'maverick_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["base"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-06-23' %} + +with + +pools as ( +select poolAddress, tokenA, tokenB, cast(feeAIn as double)/1e16 as fee +from {{source('maverick_v2_base','V2Factory_evt_PoolCreated')}} +where tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 + or tokenB = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +) + + +, tokens as ( +select distinct token as address +from ( +select tokenA as token +from {{source('maverick_v2_base','V2Factory_evt_PoolCreated')}} +where tokenB = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +union +select tokenB +from {{source('maverick_v2_base','V2Factory_evt_PoolCreated')}} +where tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +union +select 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +) t +) + +, tokens_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + contract_address as token, + symbol, + decimals, + avg(price) AS price + FROM {{source('prices','usd')}} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'base' + and contract_address in (select address from tokens) + group by 1,2,3,4 + union all + SELECT distinct + DATE_TRUNC('day', minute), + contract_address as token, + symbol, + decimals, + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{source('prices','usd')}} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'base' + and contract_address in (select address from tokens) +) + +, wsteth_prices_hourly as ( + select time, lead(time,1, DATE_TRUNC('hour', now() + interval '1' hour)) over (order by time) as next_time, price + from ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{source('prices','usd')}} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'base' + and contract_address = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 + ) p +) + +, swap_events as ( + select + date_trunc('day', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.tokenA, cr.tokenB, + sum(case when json_extract_scalar(params, '$.tokenAIn') = 'true' then cast(amountIn as double) else (-1)*cast(amountOut as double) end) as amountA, + sum(case when json_extract_scalar(params, '$.tokenAIn') = 'true' then (-1)*cast(amountOut as double) else cast(amountIn as double) end) as amountB + from {{source('maverick_v2_base','V2Pool_evt_PoolSwap')}} sw + left join {{source('maverick_v2_base','V2Factory_evt_PoolCreated')}} cr on sw.contract_address = cr.poolAddress + join pools on sw.contract_address = pools.poolAddress + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + group by 1,2,3,4 +) + +, addliquidity_events as ( + select date_trunc('day', a.evt_block_time) as time, + a.contract_address as pool, + cr.tokenA, cr.tokenB, + sum(cast(tokenAAmount as double)) as amountA, + sum(cast(tokenBAmount as double)) as amountB +from {{source('maverick_v2_base','V2Pool_evt_PoolAddLiquidity')}} a +left join {{source('maverick_v2_base','V2Factory_evt_PoolCreated')}} cr on a.contract_address = cr.poolAddress +join pools on a.contract_address = pools.poolAddress + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', a.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('a.evt_block_time') }} + {% endif %} +group by 1,2,3,4 +) + +, removeliquidity_events as ( +select date_trunc('day', a.evt_block_time) as time, + a.contract_address as pool, + cr.tokenA, cr.tokenB, + (-1)*sum(cast(tokenAOut as double)) as amountA, + (-1)*sum(cast(tokenBOut as double)) as amountB +from {{source('maverick_v2_base','V2Pool_evt_PoolRemoveLiquidity')}} a +left join {{source('maverick_v2_base','V2Factory_evt_PoolCreated')}} cr on a.contract_address = cr.poolAddress +join pools on a.contract_address = pools.poolAddress + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', a.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('a.evt_block_time') }} + {% endif %} +group by 1,2,3,4 +) + +, daily_delta_balance AS ( + +select time, pool, tokenA, tokenB, sum(amountA) as amountA, sum(amountB) as amountB +from ( +select time, pool,tokenA, tokenB, amountA, amountB +from swap_events + +union all + +select time, pool,tokenA, tokenB, amountA, amountB +from addliquidity_events + +union all + +select time, pool,tokenA, tokenB, amountA, amountB +from removeliquidity_events + +) group by 1,2,3,4 +) + + +, pool_liquidity as ( +SELECT time, pools.fee, + pool, + b.tokenA, + b.tokenB, + coalesce((SUM(amountA)),0) AS amountA, + coalesce((SUM(amountB)),0) AS amountB +FROM daily_delta_balance b +left join pools on b.pool = pools.poolAddress +GROUP BY 1,2,3,4,5 +) + + + +, wsteth_traded_hourly as ( + select + date_trunc('hour', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.tokenA, cr.tokenB, + sum(case when (cr.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 and json_extract_scalar(params, '$.tokenAIn') = 'true') then amountIn + when (cr.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 and json_extract_scalar(params, '$.tokenAIn') = 'false') then amountOut + when (cr.tokenA != 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 and json_extract_scalar(params, '$.tokenAIn') = 'true') then amountOut + when (cr.tokenA != 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 and json_extract_scalar(params, '$.tokenAIn') = 'false') then amountIn + end) as amount + from {{source('maverick_v2_base','V2Pool_evt_PoolSwap')}} sw + left join {{source('maverick_v2_base','V2Factory_evt_PoolCreated')}} cr on sw.contract_address = cr.poolAddress + join pools on sw.contract_address = pools.poolAddress + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + +, trading_volume_hourly as ( +select t.time, pool, t.amount*wp.price as volume_raw +from wsteth_traded_hourly t +left join wsteth_prices_hourly wp on date_trunc('hour',t.time) >= wp.time and date_trunc('hour',t.time) < wp.next_time +order by 1,2 +) + +, trading_volume as ( + select distinct date_trunc('day', time) as time + , pool + , sum(volume_raw)/1e18 as volume + from trading_volume_hourly + GROUP by 1,2 +) + +, all_metrics as ( +select + o.pool, + 'base' as blockchain, + 'maverick' as project, + format('%,.3f',round(coalesce(fee,0),4)) as fee, + cast(o.time as date) time, + case when o.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then o.tokenA else o.tokenB end as main_token, + case when o.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then pA.symbol else pB.symbol end as main_token_symbol, + case when o.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then o.tokenB else o.tokenA end as paired_token, + case when o.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then pB.symbol else pA.symbol end as paired_token_symbol, + case when o.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then amountA/power(10,pA.decimals) else amountB/power(10,pB.decimals) end as main_token_reserve, + case when o.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then amountB/power(10,pB.decimals) else amountA/power(10,pA.decimals) end as paired_token_reserve, + case when o.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then pA.price else pB.price end as main_token_usd_price, + case when o.tokenA = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then pB.price else pA.price end as paired_token_usd_price, + coalesce(t.volume,0) as trading_volume +from pool_liquidity o +left join tokens_prices_daily pA on o.time = pA.time and o.tokenA = pA.token +left join tokens_prices_daily pB on o.time = pB.time and o.tokenB = pB.token +left join trading_volume t on o.time = t.time and o.pool = t.pool +) + + +select blockchain||' '||project||' '||coalesce(paired_token_symbol,'unknown')||':'||main_token_symbol||' '||fee|| '('||cast(pool as varchar)||')' as pool_name, + pool, + blockchain, + project, + fee, + time, + main_token, + main_token_symbol, + paired_token, + paired_token_symbol, + main_token_reserve, + paired_token_reserve, + main_token_usd_price, + paired_token_usd_price, + trading_volume +from all_metrics + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/base/lido_liquidity_base_pancakeswap_v3_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/base/lido_liquidity_base_pancakeswap_v3_pools.sql new file mode 100644 index 00000000000..729355b2bbd --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/base/lido_liquidity_base_pancakeswap_v3_pools.sql @@ -0,0 +1,263 @@ +{{ config( + schema='lido_liquidity_base', + alias = 'pancakeswap_v3_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["base"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-03-13' %} + +with + +pools as ( +select pool as address, 'base' as blockchain, 'pancakeswap' as project, max(cast(fee as double))/10000 as fee +from {{ source('pancakeswap_v3_base','PancakeV3Factory_evt_PoolCreated')}} +where token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 or token1 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +group by 1,2,3 +) + +, tokens as ( +select distinct token as address +from ( +select token1 as token +from {{ source('pancakeswap_v3_base','PancakeV3Factory_evt_PoolCreated')}} +where token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +union +select token0 +from {{ source('pancakeswap_v3_base','PancakeV3Factory_evt_PoolCreated')}} +where token1 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +union +select 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 +) t +) + +, tokens_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + contract_address as token, + decimals, + symbol, + avg(price) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'base' + and contract_address in (select address from tokens) + group by 1,2,3,4 + union all + SELECT distinct + DATE_TRUNC('day', minute), + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'base' + and contract_address in (select address from tokens) +) + +, tokens_prices_hourly AS ( + select time, + lead(time,1, DATE_TRUNC('hour', now() + interval '1' hour)) over (partition by token order by time) as next_time, + token, price, decimals, symbol + from ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'base' + and contract_address in (select address from tokens) +) p +) + + +, swap_events as ( + select + date_trunc('day', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.token0, cr.token1, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + + from {{ source('pancakeswap_v3_base', 'PancakeV3Pool_evt_Swap') }} sw + left join {{ source('pancakeswap_v3_base', 'PancakeV3Factory_evt_PoolCreated') }} cr on sw.contract_address = cr.pool + join pools on sw.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + group by 1,2,3,4 +) + +, mint_events as ( + select + date_trunc('day', mt.evt_block_time) as time, + mt.contract_address as pool, + cr.token0, cr.token1, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('pancakeswap_v3_base', 'PancakeV3Pool_evt_Mint') }} mt + left join {{ source('pancakeswap_v3_base', 'PancakeV3Factory_evt_PoolCreated') }} cr on mt.contract_address = cr.pool + join pools on mt.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', mt.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('mt.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + +, burn_events as ( + select + date_trunc('day', bn.evt_block_time) as time, + bn.contract_address as pool, + cr.token0, cr.token1, + (-1)*sum(cast(amount0 as DOUBLE)) as amount0, + (-1)*sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('pancakeswap_v3_base', 'PancakeV3Pool_evt_Burn') }} bn + left join {{ source('pancakeswap_v3_base', 'PancakeV3Factory_evt_PoolCreated') }} cr on bn.contract_address = cr.pool + join pools on bn.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', bn.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('bn.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + + , collect_events AS ( + SELECT + date_trunc('day', c.evt_block_time) as time, + c.contract_address AS pool, + cr.token0, + cr.token1, + (-1) * CAST(amount0 AS DOUBLE) AS amount0, + (-1) * CAST(amount1 AS DOUBLE) AS amount1, + c.evt_tx_hash + FROM + {{source('pancakeswap_v3_base','PancakeV3Pool_evt_Collect')}} AS c + LEFT JOIN {{source('pancakeswap_v3_base','PancakeV3Factory_evt_PoolCreated')}} AS cr ON c.contract_address = cr.pool + join pools on c.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', c.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('c.evt_block_time') }} + {% endif %} + + ) + + +, daily_delta_balance as ( + select time, pool, token0, token1, sum(coalesce(amount0, 0)) as amount0, sum(coalesce(amount1, 0)) as amount1 + from ( + select time, pool, token0, token1, amount0, amount1 + from swap_events + union all + select time, pool, token0, token1, amount0, amount1 + from mint_events + union all + select time, pool, token0, token1, amount0, amount1 + from collect_events + ) balance + group by 1,2,3,4 +) + +, pool_liquidity as ( + select time, + pool, + token0, + token1, + sum(amount0) as amount0, + sum(amount1) as amount1 + from daily_delta_balance + group by 1,2,3,4 +) + + +, swap_events_hourly as ( + select hour, pool, token0, token1, sum(amount0) as amount0, sum(amount1) as amount1 from ( + select + date_trunc('hour', sw.evt_block_time) as hour, + sw.contract_address as pool, + cr.token0, cr.token1, + coalesce(sum(cast(abs(amount0) as DOUBLE)),0) as amount0, + coalesce(sum(cast(abs(amount1) as DOUBLE)),0) as amount1 + + from {{source('pancakeswap_v3_base','PancakeV3Pool_evt_Swap')}} sw + left join {{source('pancakeswap_v3_base','PancakeV3Factory_evt_PoolCreated')}} cr on sw.contract_address = cr.pool + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + and sw.contract_address in (select address from pools) + group by 1,2,3,4 + + ) a group by 1,2,3,4 +) + +, trading_volume_hourly as ( + select hour as time, pool, token0, amount0, p.price, coalesce(p.price*amount0/power(10, p.decimals),0) as volume + from swap_events_hourly s + left join tokens t on s.token0 = t.address + left join tokens_prices_hourly p on s.hour >= p.time and s.hour < p.next_time and s.token0 = p.token + +) + +, trading_volume as ( +select distinct date_trunc('day', time) as time, pool, sum(volume) as volume +from trading_volume_hourly +group by 1,2 +) + +, all_metrics as ( +select l.pool, pools.blockchain, pools.project, pools.fee, cast(l.time as date) as time, + case when token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then token0 else token1 end main_token, + case when token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then p0.symbol else p1.symbol end main_token_symbol, + case when token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then token1 else token0 end paired_token, + case when token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then p1.symbol else p0.symbol end paired_token_symbol, + case when token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then amount0/power(10, p0.decimals) else amount1/power(10, p1.decimals) end main_token_reserve, + case when token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then amount1/power(10, p1.decimals) else amount0/power(10, p0.decimals) end paired_token_reserve, + case when token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then p0.price else p1.price end as main_token_usd_price, + case when token0 = 0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452 then p1.price else p0.price end as paired_token_usd_price, + volume as trading_volume +from pool_liquidity l +left join pools on l.pool = pools.address +left join tokens t0 on l.token0 = t0.address +left join tokens t1 on l.token1 = t1.address +left join tokens_prices_daily p0 on l.time = p0.time and l.token0 = p0.token +left join tokens_prices_daily p1 on l.time = p1.time and l.token1 = p1.token +left join trading_volume tv on l.time = tv.time and l.pool = tv.pool +) + + + +select blockchain||' '||project||' '||COALESCE(paired_token_symbol, 'unknown')||':'||main_token_symbol||' '||format('%,.3f',round(coalesce(fee,0),4)) as pool_name,* +from all_metrics + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_pancakeswap_v3_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_pancakeswap_v3_pools.sql new file mode 100644 index 00000000000..e4be4ac2fc0 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_pancakeswap_v3_pools.sql @@ -0,0 +1,263 @@ +{{ config( + schema='lido_liquidity_bnb', + alias = 'pancakeswap_v3_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["bnb"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-08-14' %} + +with + +pools as ( +select pool as address, 'bnb' as blockchain, 'pancakeswap' as project, max(cast(fee as double))/10000 as fee +from {{ source('pancakeswap_v3_bnb','PancakeV3Factory_evt_PoolCreated')}} +where token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C or token1 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C +group by 1,2,3 +) + +, tokens as ( +select distinct token as address +from ( +select token1 as token +from {{ source('pancakeswap_v3_bnb','PancakeV3Factory_evt_PoolCreated')}} +where token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C +union +select token0 +from {{ source('pancakeswap_v3_bnb','PancakeV3Factory_evt_PoolCreated')}} +where token1 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C +union +select 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C +) t +) + +, tokens_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + contract_address as token, + decimals, + symbol, + avg(price) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'bnb' + and contract_address in (select address from tokens) + group by 1,2,3,4 + union all + SELECT distinct + DATE_TRUNC('day', minute), + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'bnb' + and contract_address in (select address from tokens) +) + +, tokens_prices_hourly AS ( + select time, + lead(time,1, DATE_TRUNC('hour', now() + interval '1' hour)) over (partition by token order by time) as next_time, + token, price, decimals, symbol + from ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'bnb' + and contract_address in (select address from tokens) +) p +) + + +, swap_events as ( + select + date_trunc('day', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.token0, cr.token1, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + + from {{ source('pancakeswap_v3_bnb', 'PancakeV3Pool_evt_Swap') }} sw + left join {{ source('pancakeswap_v3_bnb', 'PancakeV3Factory_evt_PoolCreated') }} cr on sw.contract_address = cr.pool + join pools on sw.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + group by 1,2,3,4 +) + +, mint_events as ( + select + date_trunc('day', mt.evt_block_time) as time, + mt.contract_address as pool, + cr.token0, cr.token1, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('pancakeswap_v3_bnb', 'PancakeV3Pool_evt_Mint') }} mt + left join {{ source('pancakeswap_v3_bnb', 'PancakeV3Factory_evt_PoolCreated') }} cr on mt.contract_address = cr.pool + join pools on mt.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', mt.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('mt.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + +, burn_events as ( + select + date_trunc('day', bn.evt_block_time) as time, + bn.contract_address as pool, + cr.token0, cr.token1, + (-1)*sum(cast(amount0 as DOUBLE)) as amount0, + (-1)*sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('pancakeswap_v3_bnb', 'PancakeV3Pool_evt_Burn') }} bn + left join {{ source('pancakeswap_v3_bnb', 'PancakeV3Factory_evt_PoolCreated') }} cr on bn.contract_address = cr.pool + join pools on bn.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', bn.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('bn.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + + , collect_events AS ( + SELECT + date_trunc('day', c.evt_block_time) as time, + c.contract_address AS pool, + cr.token0, + cr.token1, + (-1) * CAST(amount0 AS DOUBLE) AS amount0, + (-1) * CAST(amount1 AS DOUBLE) AS amount1, + c.evt_tx_hash + FROM + {{source('pancakeswap_v3_bnb','PancakeV3Pool_evt_Collect')}} AS c + LEFT JOIN {{source('pancakeswap_v3_bnb','PancakeV3Factory_evt_PoolCreated')}} AS cr ON c.contract_address = cr.pool + join pools on c.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', c.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('c.evt_block_time') }} + {% endif %} + + ) + + +, daily_delta_balance as ( + select time, pool, token0, token1, sum(coalesce(amount0, 0)) as amount0, sum(coalesce(amount1, 0)) as amount1 + from ( + select time, pool, token0, token1, amount0, amount1 + from swap_events + union all + select time, pool, token0, token1, amount0, amount1 + from mint_events + union all + select time, pool, token0, token1, amount0, amount1 + from collect_events + ) balance + group by 1,2,3,4 +) + +, pool_liquidity as ( + select time, + pool, + token0, + token1, + sum(amount0) as amount0, + sum(amount1) as amount1 + from daily_delta_balance + group by 1,2,3,4 +) + + +, swap_events_hourly as ( + select hour, pool, token0, token1, sum(amount0) as amount0, sum(amount1) as amount1 from ( + select + date_trunc('hour', sw.evt_block_time) as hour, + sw.contract_address as pool, + cr.token0, cr.token1, + coalesce(sum(cast(abs(amount0) as DOUBLE)),0) as amount0, + coalesce(sum(cast(abs(amount1) as DOUBLE)),0) as amount1 + + from {{source('pancakeswap_v3_bnb','PancakeV3Pool_evt_Swap')}} sw + left join {{source('pancakeswap_v3_bnb','PancakeV3Factory_evt_PoolCreated')}} cr on sw.contract_address = cr.pool + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + and sw.contract_address in (select address from pools) + group by 1,2,3,4 + + ) a group by 1,2,3,4 +) + +, trading_volume_hourly as ( + select hour as time, pool, token0, amount0, p.price, coalesce(p.price*amount0/power(10, p.decimals),0) as volume + from swap_events_hourly s + left join tokens t on s.token0 = t.address + left join tokens_prices_hourly p on s.hour >= p.time and s.hour < p.next_time and s.token0 = p.token + +) + +, trading_volume as ( +select distinct date_trunc('day', time) as time, pool, sum(volume) as volume +from trading_volume_hourly +group by 1,2 +) + +, all_metrics as ( +select l.pool, pools.blockchain, pools.project, pools.fee, cast(l.time as date) as time, + case when token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then token0 else token1 end main_token, + case when token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then p0.symbol else p1.symbol end main_token_symbol, + case when token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then token1 else token0 end paired_token, + case when token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then p1.symbol else p0.symbol end paired_token_symbol, + case when token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then amount0/power(10, p0.decimals) else amount1/power(10, p1.decimals) end main_token_reserve, + case when token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then amount1/power(10, p1.decimals) else amount0/power(10, p0.decimals) end paired_token_reserve, + case when token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then p0.price else p1.price end as main_token_usd_price, + case when token0 = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then p1.price else p0.price end as paired_token_usd_price, + volume as trading_volume +from pool_liquidity l +left join pools on l.pool = pools.address +left join tokens t0 on l.token0 = t0.address +left join tokens t1 on l.token1 = t1.address +left join tokens_prices_daily p0 on l.time = p0.time and l.token0 = p0.token +left join tokens_prices_daily p1 on l.time = p1.time and l.token1 = p1.token +left join trading_volume tv on l.time = tv.time and l.pool = tv.pool +) + + + +select blockchain||' '||project||' '||COALESCE(paired_token_symbol, 'unknown')||':'||main_token_symbol||' '||format('%,.3f',round(coalesce(fee,0),4)) as pool_name,* +from all_metrics + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_schema.yml b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_schema.yml new file mode 100644 index 00000000000..495e2002435 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_schema.yml @@ -0,0 +1,64 @@ +version: 2 + +models: + - name: lido_liquidity_bnb_pancakeswap_v3_pools + meta: + blockchain: bnb + project: lido + contributors: pipistrella + config: + tags: ['bnb','lido','liquidity'] + description: + Lido wstETH liquidity pools on Pancake v3 BNB Chain + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool + - blockchain + - time + columns: + - &pool_name + name: pool_name + description: "Liquidity pool's name consisting of the its blockchain, DEX project, symbols of tokens and fee value" + - &pool + name: pool + description: "Liquidity pool's address" + - &blockchain + name: blockchain + description: "Blockchain which the DEX is deployed" + - &project + name: project + description: "Project name of the DEX" + - &fee + name: fee + description: "Liquidity pool's trading fee" + - &time + name: time + description: "UTC event block date truncated to the day mark" + - &main_token + name: main_token + description: "Main token's address" + - &main_token_symbol + name: main_token_symbol + description: "Token symbol for main pool's token" + - &paired_token + name: paired_token + description: "Paired token's address" + - &paired_token_symbol + name: paired_token_symbol + description: "Token symbol for paired pool's token" + - &main_token_reserve + name: main_token_reserve + description: "Liquidity reserve of the main token in the pool" + - &paired_token_reserve + name: paired_token_reserve + description: "Liquidity reserve of the paired token in the pool" + - &main_token_usd_price + name: main_token_usd_price + description: "Price of the main token in the pool in USD" + - &paired_token_usd_price + name: paired_token_usd_price + description: "Price of the paired token in the pool in USD" + - &trading_volume + name: trading_volume + description: "USD value of the trade" \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_thena_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_thena_pools.sql new file mode 100644 index 00000000000..a861d12f4df --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/bnb/lido_liquidity_bnb_thena_pools.sql @@ -0,0 +1,242 @@ +{{ config( + schema='lido_liquidity_bnb', + alias = 'thena_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["bnb"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-08-10' %} + +with + +pools as ( +select output_pool as address, 'bnb' as blockchain, 'thena' as project +from {{ source('thena_fi_bnb','PairFactory_CL_call_createPool')}} +where tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C or tokenB = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C +group by 1,2,3 +) + +, tokens as ( +select distinct token as address +from ( +select tokenB as token +from {{ source('thena_fi_bnb','PairFactory_CL_call_createPool')}} +where tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C +union +select tokenA +from {{ source('thena_fi_bnb','PairFactory_CL_call_createPool')}} +where tokenB = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C +union +select 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C +) t +) + +, tokens_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + contract_address as token, + decimals, + symbol, + avg(price) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'bnb' + and contract_address in (select address from tokens) + group by 1,2,3,4 + union all + SELECT distinct + DATE_TRUNC('day', minute), + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'bnb' + and contract_address in (select address from tokens) +) + +, tokens_prices_hourly AS ( + select time, + lead(time,1, DATE_TRUNC('hour', now() + interval '1' hour)) over (partition by token order by time) as next_time, + token, price, decimals, symbol + from ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'bnb' + and contract_address in (select address from tokens) +) p +) + + +, swap_events as ( + select + date_trunc('day', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.tokenA, cr.tokenB, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + + from {{ source('thena_bnb', 'AlgebraPool_evt_Swap') }} sw + left join {{ source('thena_fi_bnb', 'PairFactory_CL_call_createPool') }} cr on sw.contract_address = cr.output_pool + join pools on sw.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + group by 1,2,3,4 +) + +, mint_events as ( + select + date_trunc('day', mt.evt_block_time) as time, + mt.contract_address as pool, + cr.tokenA, cr.tokenB, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('thena_bnb', 'AlgebraPool_evt_Mint') }} mt + left join {{ source('thena_fi_bnb', 'PairFactory_CL_call_createPool') }} cr on mt.contract_address = cr.output_pool + join pools on mt.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', mt.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('mt.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + +, burn_events as ( + select + date_trunc('day', bn.evt_block_time) as time, + bn.contract_address as pool, + cr.tokenA, cr.tokenB, + (-1)*sum(cast(amount0 as DOUBLE)) as amount0, + (-1)*sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('thena_bnb', 'AlgebraPool_evt_Burn') }} bn + left join {{ source('thena_fi_bnb', 'PairFactory_CL_call_createPool') }} cr on bn.contract_address = cr.output_pool + join pools on bn.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', bn.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('bn.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + + +, daily_delta_balance as ( + select time, pool, tokenA, tokenB, sum(coalesce(amount0, 0)) as amount0, sum(coalesce(amount1, 0)) as amount1 + from ( + select time, pool, tokenA, tokenB, amount0, amount1 + from swap_events + union all + select time, pool, tokenA, tokenB, amount0, amount1 + from mint_events + union all + select time, pool, tokenA, tokenB, amount0, amount1 + from burn_events + ) balance + group by 1,2,3,4 +) + +, pool_liquidity as ( + select time, + pool, + tokenA, + tokenB, + sum(amount0) as amount0, + sum(amount1) as amount1 + from daily_delta_balance + group by 1,2,3,4 +) + + +, swap_events_hourly as ( + select hour, pool, tokenA, tokenB, sum(amount0) as amount0, sum(amount1) as amount1 from ( + select + date_trunc('hour', sw.evt_block_time) as hour, + sw.contract_address as pool, + cr.tokenA, cr.tokenB, + coalesce(sum(cast(abs(amount0) as DOUBLE)),0) as amount0, + coalesce(sum(cast(abs(amount1) as DOUBLE)),0) as amount1 + + from {{ source('thena_bnb', 'AlgebraPool_evt_Swap') }} sw + left join {{source('thena_fi_bnb','PairFactory_CL_call_createPool')}} cr on sw.contract_address = cr.output_pool + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + and sw.contract_address in (select address from pools) + group by 1,2,3,4 + + ) a group by 1,2,3,4 +) + +, trading_volume_hourly as ( + select hour as time, pool, tokenA, amount0, p.price, coalesce(p.price*amount0/power(10, p.decimals),0) as volume + from swap_events_hourly s + left join tokens t on s.tokenA = t.address + left join tokens_prices_hourly p on s.hour >= p.time and s.hour < p.next_time and s.tokenA = p.token + +) + +, trading_volume as ( +select distinct date_trunc('day', time) as time, pool, sum(volume) as volume +from trading_volume_hourly +group by 1,2 +) + +, all_metrics as ( +select l.pool, pools.blockchain, pools.project, cast(l.time as date) as time, + case when tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then tokenA else tokenB end main_token, + case when tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then p0.symbol else p1.symbol end main_token_symbol, + case when tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then tokenB else tokenA end paired_token, + case when tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then p1.symbol else p0.symbol end paired_token_symbol, + case when tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then amount0/power(10, p0.decimals) else amount1/power(10, p1.decimals) end main_token_reserve, + case when tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then amount1/power(10, p1.decimals) else amount0/power(10, p0.decimals) end paired_token_reserve, + case when tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then p0.price else p1.price end as main_token_usd_price, + case when tokenA = 0x26c5e01524d2E6280A48F2c50fF6De7e52E9611C then p1.price else p0.price end as paired_token_usd_price, + volume as trading_volume +from pool_liquidity l +left join pools on l.pool = pools.address +left join tokens t0 on l.tokenA = t0.address +left join tokens t1 on l.tokenB = t1.address +left join tokens_prices_daily p0 on l.time = p0.time and l.tokenA = p0.token +left join tokens_prices_daily p1 on l.time = p1.time and l.tokenB = p1.token +left join trading_volume tv on l.time = tv.time and l.pool = tv.pool +) + + + +select blockchain||' '||project||' '||COALESCE(paired_token_symbol, 'unknown')||':'||main_token_symbol as pool_name,* +from all_metrics + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/ethereum/lido_liquidity_ethereum_balancer_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/ethereum/lido_liquidity_ethereum_balancer_pools.sql index 8aec58d6c63..7e146f4eb83 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/ethereum/lido_liquidity_ethereum_balancer_pools.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/ethereum/lido_liquidity_ethereum_balancer_pools.sql @@ -83,7 +83,11 @@ values (0x5F1F4E50BA51D723F12385A8A9606AFC3A0555F5000200000000000000000465, 0x5F1F4E50BA51D723F12385A8A9606AFC3A0555F5), (0x25ACCB7943FD73DDA5E23BA6329085A3C24BFB6A000200000000000000000387, 0x25ACCB7943FD73DDA5E23BA6329085A3C24BFB6A), (0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd0000000000000000000005c2, 0x93d199263632a4ef4bb438f1feb99e57b4b5f0bd), -(0x54ca50ee86616379420cc56718e12566aa75abbe000200000000000000000610, 0x54ca50ee86616379420cc56718e12566aa75abbe) +(0x54ca50ee86616379420cc56718e12566aa75abbe000200000000000000000610, 0x54ca50ee86616379420cc56718e12566aa75abbe), +(0x3de27efa2f1aa663ae5d458857e731c129069f29000200000000000000000588, 0x3de27efa2f1aa663ae5d458857e731c129069f29), +(0x63e0d47a6964ad1565345da9bfa66659f4983f02000000000000000000000681, 0x63e0d47a6964ad1565345da9bfa66659f4983f02), +(0xb91159aa527d4769cb9faf3e4adb760c7e8c8ea700000000000000000000067c, 0xb91159aa527d4769cb9faf3e4adb760c7e8c8ea7) + ) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/ethereum/lido_liquidity_ethereum_curve_wsteth_pufeth_pool.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/ethereum/lido_liquidity_ethereum_curve_wsteth_pufeth_pool.sql new file mode 100644 index 00000000000..c0f0c8454dc --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/ethereum/lido_liquidity_ethereum_curve_wsteth_pufeth_pool.sql @@ -0,0 +1,236 @@ +{{ config( + schema='lido_liquidity_ethereum', + alias = 'curve_wsteth_pufeth_pool', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["ethereum"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-03-23' %} + + + +with + +wsteth_in as ( +select + DATE_TRUNC('day', evt_block_time) as time, + sum(cast(value as double))/1e18 as wsteth_in +from {{source('erc20_ethereum','evt_Transfer')}} t +{% if not is_incremental() %} + WHERE DATE_TRUNC('day', evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE DATE_TRUNC('day', evt_block_time) >= DATE_TRUNC('day', NOW() - INTERVAL '1' day) + {% endif %} + and contract_address = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0 + and to = 0xeeda34a377dd0ca676b9511ee1324974fa8d980d +group by 1 +) + +, wsteth_out as ( +select + DATE_TRUNC('day', evt_block_time) as time, + -sum(cast(value as double))/1e18 as wsteth_out +from {{source('erc20_ethereum','evt_Transfer')}} t +{% if not is_incremental() %} + WHERE DATE_TRUNC('day', evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE DATE_TRUNC('day', evt_block_time) >= DATE_TRUNC('day', NOW() - INTERVAL '1' day) + {% endif %} + and contract_address = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0 + and "from" = 0xeeda34a377dd0ca676b9511ee1324974fa8d980d + +group by 1 +) + +, wsteth_daily_balances as ( +select time, sum(wsteth_in) wsteth_balance from ( +select * from wsteth_in +union all +select * from wsteth_out +) group by 1 +) + +, wsteth_balances as ( +select time, + sum(wsteth_balance) as wsteth +from wsteth_daily_balances b +group by 1 +order by 1 +) + + +, pufeth_in as ( +select + DATE_TRUNC('day', evt_block_time) as time, + sum(cast(value as double))/1e18 as pufeth_in +from {{source('erc20_ethereum','evt_Transfer')}} t + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + and contract_address = 0xD9A442856C234a39a81a089C06451EBAa4306a72 + and to = 0xeeda34a377dd0ca676b9511ee1324974fa8d980d + group by 1 +) + +, pufeth_out as ( +select + DATE_TRUNC('day', evt_block_time) as time, + -sum(cast(value as double))/1e18 as pufeth_out +from {{source('erc20_ethereum','evt_Transfer')}} t + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + and contract_address = 0xD9A442856C234a39a81a089C06451EBAa4306a72 + and "from" = 0xeeda34a377dd0ca676b9511ee1324974fa8d980d + group by 1 +) + +, pufeth_daily_balances as ( +select time, sum(pufeth_in) as pufeth_balance from ( +select * from pufeth_in +union all +select * from pufeth_out +) group by 1 +) + +, pufeth_balances as ( +select time, sum(pufeth_balance) pufeth +from pufeth_daily_balances +group by 1 +order by 1 +) + + +, pufeth_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + avg(price) AS price + FROM {{source('prices','usd')}} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'ethereum' + and contract_address = 0xD9A442856C234a39a81a089C06451EBAa4306a72 + group by 1 + union all + SELECT distinct + DATE_TRUNC('day', minute), + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{source('prices','usd')}} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'ethereum' + and contract_address = 0xD9A442856C234a39a81a089C06451EBAa4306a72 + + +) + +, wsteth_prices_hourly AS ( + select time + , lead(time,1, DATE_TRUNC('hour', now() + interval '1' hour)) over (order by time) as next_time + , price + from ( + SELECT distinct + DATE_TRUNC('hour', minute) time + , last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{source('prices','usd')}} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'ethereum' + and contract_address = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0 + +)) + +, wsteth_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + avg(price) AS price + FROM {{source('prices','usd')}} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'ethereum' + and contract_address = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0 + group by 1 + union all + SELECT distinct + DATE_TRUNC('day', minute), + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{source('prices','usd')}} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'ethereum' + and contract_address = 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0 + +) + +, token_exchange_hourly as( + select date_trunc('hour', evt_block_time) as time + , sum(case when cast(sold_id as int) = int '0' then cast(tokens_sold as double) else cast(tokens_bought as double) end) as eth_amount_raw + from {{source('puffer_ethereum','CurveStableSwapNG_evt_TokenExchange')}} c + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} + group by 1 + +) + +, trading_volume_hourly as ( + select t.time + , t.eth_amount_raw * wp.price as volume_raw + from token_exchange_hourly t + left join wsteth_prices_hourly wp on t.time = wp.time + order by 1 +) + +, trading_volume as ( + select distinct date_trunc('day', time) as time + , sum(volume_raw)/1e18 as volume + from trading_volume_hourly + GROUP by 1 +) + +select 'ethereum curve pufETH:wstETH 0.04' as pool_name, + 0xeeda34a377dd0ca676b9511ee1324974fa8d980d as pool, + 'ethereum' as blockchain, + 'curve' as project, + 0.02 as fee, + cast(b.time as date) as time, + 0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0 as main_token, + 'wstETH' as main_token_symbol, + 0xD9A442856C234a39a81a089C06451EBAa4306a72 as paired_token, + 'pufETH' as paired_token_symbol, + wsteth as main_token_reserve, + coalesce(pufeth.pufeth, 0) as paired_token_reserve, + coalesce(wstethp.price, 0)as main_token_usd_price, + pufethp.price as paired_token_usd_price, + v.volume as trading_volume +from wsteth_balances b +left join pufeth_balances pufeth on b.time = pufeth.time +left join wsteth_prices_daily wstethp on b.time = wstethp.time +left join pufeth_prices_daily pufethp on b.time = pufethp.time +left join trading_volume v on b.time = v.time + +order by 1 + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/linea/lido_liquidity_linea_lynex_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/linea/lido_liquidity_linea_lynex_pools.sql new file mode 100644 index 00000000000..bf1d7f9c951 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/linea/lido_liquidity_linea_lynex_pools.sql @@ -0,0 +1,275 @@ +{{ config( + schema='lido_liquidity_linea', + alias = 'lynex_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["linea"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-03-23' %} + +with pools as ( +select pool AS address, + 'linea' AS blockchain, + 'lynex' AS project, + * +from {{source('lynex_linea','AlgebraFactory_evt_Pool')}} +where (token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F + OR token1 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F) +) + +, tokens as ( + select distinct token + from ( + select token0 as token + from {{source('lynex_linea','AlgebraFactory_evt_Pool')}} + where token1 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F + union all + select token1 + from {{source('lynex_linea','AlgebraFactory_evt_Pool')}} + where token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F + union all + select 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F + ) t + ) + + , tokens_prices_daily as ( +select distinct + DATE_TRUNC('day', minute) AS time, + contract_address AS token, + symbol, + decimals, + AVG(price) AS price +FROM {{source('prices','usd')}} p +{% if not is_incremental() %} +WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' +{% else %} +WHERE {{incremental_predicate('p.minute')}} +{% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'linea' + and contract_address IN (select token from tokens) +group by 1,2,3,4 +union all +select distinct + DATE_TRUNC('day', minute), + contract_address AS token, + symbol, + decimals, + LAST_VALUE(price) OVER (PARTITION BY DATE_TRUNC('day', minute),contract_address ORDER BY minute NULLS FIRST range BETWEEN UNBOUNDED preceding AND UNBOUNDED following) AS price + FROM {{source('prices','usd')}} p + WHERE + DATE_TRUNC('day', minute) = current_date + and blockchain = 'linea' + and contract_address IN (select token from tokens) + ) + + , wsteth_prices_hourly AS ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + contract_address as token, + symbol, + decimals, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{incremental_predicate('p.minute')}} + {% endif %} + and blockchain = 'linea' and contract_address = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F + + +) + +, wsteth_prices_hourly_with_lead AS ( +select time, + lead(time, 1, date_trunc('hour', now() + interval '1' hour)) over (order by time) as next_time, + price +from wsteth_prices_hourly +) + +, mint_events AS ( + select DATE_TRUNC('day', m.evt_block_time) AS time, + m.contract_address AS pool, + cr.token0, + cr.token1, + SUM(CAST(amount0 AS DOUBLE)) AS amount0, + SUM(CAST(amount1 AS DOUBLE)) AS amount1 + from {{source('lynex_linea','AlgebraPool_evt_Mint')}} m + left join {{source('lynex_linea','AlgebraFactory_evt_Pool')}} cr on m.contract_address = cr.pool + join pools on m.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', m.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{incremental_predicate('m.evt_block_time')}} + {% endif %} + group by 1,2,3,4 + ) + + , burn_events as ( + select DATE_TRUNC('day', b.evt_block_time) AS time, + b.contract_address AS pool, + cr.token0, + cr.token1, + (-1)*SUM(CAST(amount0 AS DOUBLE)) AS amount0, + (-1)*SUM(CAST(amount1 AS DOUBLE)) AS amount1 + from {{source('lynex_linea','AlgebraPool_evt_Burn')}} b + left join {{source('lynex_linea','AlgebraFactory_evt_Pool')}} cr on b.contract_address = cr.pool + join pools on b.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', b.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{incremental_predicate('b.evt_block_time')}} + {% endif %} + group by 1,2,3,4 + + ) + +, swap_events as ( + select DATE_TRUNC('day', s.evt_block_time) AS time, + s.contract_address AS pool, + cr.token0, + cr.token1, + SUM(CAST(amount0 AS DOUBLE)) AS amount0, + SUM(CAST(amount1 AS DOUBLE)) AS amount1 + from {{source('lynex_linea','AlgebraPool_evt_Swap')}} s + left join {{source('lynex_linea','AlgebraFactory_evt_Pool')}} cr on s.contract_address = cr.pool + join pools on s.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', s.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{incremental_predicate('s.evt_block_time')}} + {% endif %} + group by 1,2,3,4 + +) + + , daily_delta_balance AS ( + +select time, pool, token0, token1, sum(amount0) as amount0, sum(amount1) as amount1 +from ( +select time, pool,token0, token1, amount0, amount1 +from mint_events + +union all + +select time, pool,token0, token1, amount0, amount1 +from swap_events + +union all + +select time, pool,token0, token1, amount0, amount1 +from burn_events + +) group by 1,2,3,4 +) + +, daily_delta_balance_with_lead AS ( +select time, pool, token0, token1, amount0, amount1, +lead(time, 1, now()) over (partition by pool order by time) as next_time +from daily_delta_balance +) + + +, pool_liquidity as ( +SELECT b.time, + b.pool, + token0, + token1, + SUM(amount0) AS amount0, + SUM(amount1) AS amount1 +FROM daily_delta_balance_with_lead b +GROUP BY 1,2,3,4 +) + +, swap_events_hourly as ( + select DATE_TRUNC('hour', s.evt_block_time) AS time, + s.contract_address AS pool, + sum(case when cr.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F then CAST(amount0 AS DOUBLE) + else CAST(amount1 AS DOUBLE) end) as wsteth_amount + from {{source('lynex_linea','AlgebraPool_evt_Swap')}} s + left join {{source('lynex_linea','AlgebraFactory_evt_Pool')}} cr on s.contract_address = cr.pool + join pools on s.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', s.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{incremental_predicate('s.evt_block_time')}} + {% endif %} +group by 1,2 +) + +, trading_volume_hourly AS ( + SELECT + s.time, + pool, + wsteth_amount, + p.price, + COALESCE((p.price * wsteth_amount) / CAST(POWER(10, 18) AS DOUBLE), 0) AS volume + FROM + swap_events_hourly AS s + LEFT JOIN wsteth_prices_hourly_with_lead AS p ON s.time >= p.time + AND s.time < p.next_time + ) + +, trading_volume AS ( + SELECT DISTINCT + DATE_TRUNC('day', time) AS time, + pool, + SUM(volume) AS volume + FROM trading_volume_hourly + GROUP BY 1, 2 + ) + +, all_metrics AS ( + SELECT + l.pool, + pools.blockchain, + pools.project, + cast(l.time as date) as time, + CASE WHEN l.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F THEN l.token0 ELSE l.token1 END AS main_token, + CASE WHEN l.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F THEN p0.symbol ELSE p1.symbol END AS main_token_symbol, + CASE WHEN l.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F THEN l.token1 ELSE l.token0 END AS paired_token, + CASE WHEN l.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F THEN p1.symbol ELSE p0.symbol END AS paired_token_symbol, + CASE WHEN l.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F THEN amount0/CAST(POWER(10,p0.decimals) as double) ELSE amount1/CAST(POWER(10,p1.decimals) as double) END AS main_token_reserve, + CASE WHEN l.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F THEN amount1/CAST(POWER(10, p1.decimals) as double) ELSE amount0/CAST(POWER(10, p0.decimals) as double) END AS paired_token_reserve, + CASE WHEN l.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F THEN p0.price ELSE p1.price END AS main_token_usd_price, + CASE WHEN l.token0 = 0xB5beDd42000b71FddE22D3eE8a79Bd49A568fC8F THEN p1.price ELSE p0.price END AS paired_token_usd_price, + coalesce(volume,0) AS trading_volume + FROM + pool_liquidity AS l + LEFT JOIN pools ON l.pool = pools.address + LEFT JOIN tokens AS t0 ON l.token0 = t0.token + LEFT JOIN tokens AS t1 ON l.token1 = t1.token + LEFT JOIN tokens_prices_daily AS p0 ON l.time = p0.time + AND l.token0 = p0.token + LEFT JOIN tokens_prices_daily AS p1 ON l.time = p1.time + AND l.token1 = p1.token + LEFT JOIN trading_volume AS tv ON l.time = tv.time + AND l.pool = tv.pool + ) + + +SELECT + blockchain || ' ' || project || ' ' || COALESCE(paired_token_symbol, 'unknown') || ':' || main_token_symbol AS pool_name, + pool, + blockchain, + project, + time, + main_token, + main_token_symbol, + paired_token, + paired_token_symbol, + main_token_reserve, + paired_token_reserve, + main_token_usd_price, + paired_token_usd_price, + trading_volume +from all_metrics \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/scroll/lido_liquidity_scroll_maverick_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/scroll/lido_liquidity_scroll_maverick_pools.sql new file mode 100644 index 00000000000..9b032594cce --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/scroll/lido_liquidity_scroll_maverick_pools.sql @@ -0,0 +1,254 @@ +{{ config( + schema='lido_liquidity_scroll', + alias = 'maverick_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["scroll"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-07-29' %} + +with + +pools as ( +select poolAddress, tokenA, tokenB, cast(feeAIn as double)/1e16 as fee +from {{source('maverick_v2_scroll','V2Factory_evt_PoolCreated')}} +where tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 + or tokenB = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 +) + + +, tokens as ( +select distinct token as address +from ( +select tokenA as token +from {{source('maverick_v2_scroll','V2Factory_evt_PoolCreated')}} +where tokenB = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 +union +select tokenB +from {{source('maverick_v2_scroll','V2Factory_evt_PoolCreated')}} +where tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 +union +select 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 +) t +) + +, tokens_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + contract_address as token, + symbol, + decimals, + avg(price) AS price + FROM {{source('prices','usd')}} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'scroll' + and contract_address in (select address from tokens) + group by 1,2,3,4 + union all + SELECT distinct + DATE_TRUNC('day', minute), + contract_address as token, + symbol, + decimals, + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{source('prices','usd')}} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'scroll' + and contract_address in (select address from tokens) +) + +, wsteth_prices_hourly as ( + select time, lead(time,1, DATE_TRUNC('hour', now() + interval '1' hour)) over (order by time) as next_time, price + from ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{source('prices','usd')}} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'scroll' + and contract_address = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 + ) p +) + +, swap_events as ( + select + date_trunc('day', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.tokenA, cr.tokenB, + sum(case when json_extract_scalar(params, '$.tokenAIn') = 'true' then cast(amountIn as double) else (-1)*cast(amountOut as double) end) as amountA, + sum(case when json_extract_scalar(params, '$.tokenAIn') = 'true' then (-1)*cast(amountOut as double) else cast(amountIn as double) end) as amountB + from {{source('maverick_v2_scroll','V2Pool_evt_PoolSwap')}} sw + left join {{source('maverick_v2_scroll','V2Factory_evt_PoolCreated')}} cr on sw.contract_address = cr.poolAddress + join pools on sw.contract_address = pools.poolAddress + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + group by 1,2,3,4 +) + +, addliquidity_events as ( + select date_trunc('day', a.evt_block_time) as time, + a.contract_address as pool, + cr.tokenA, cr.tokenB, + sum(cast(tokenAAmount as double)) as amountA, + sum(cast(tokenBAmount as double)) as amountB +from {{source('maverick_v2_scroll','V2Pool_evt_PoolAddLiquidity')}} a +left join {{source('maverick_v2_scroll','V2Factory_evt_PoolCreated')}} cr on a.contract_address = cr.poolAddress +join pools on a.contract_address = pools.poolAddress + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', a.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('a.evt_block_time') }} + {% endif %} +group by 1,2,3,4 +) + +, removeliquidity_events as ( +select date_trunc('day', a.evt_block_time) as time, + a.contract_address as pool, + cr.tokenA, cr.tokenB, + (-1)*sum(cast(tokenAOut as double)) as amountA, + (-1)*sum(cast(tokenBOut as double)) as amountB +from {{source('maverick_v2_scroll','V2Pool_evt_PoolRemoveLiquidity')}} a +left join {{source('maverick_v2_scroll','V2Factory_evt_PoolCreated')}} cr on a.contract_address = cr.poolAddress +join pools on a.contract_address = pools.poolAddress + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', a.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('a.evt_block_time') }} + {% endif %} +group by 1,2,3,4 +) + +, daily_delta_balance AS ( + +select time, pool, tokenA, tokenB, sum(amountA) as amountA, sum(amountB) as amountB +from ( +select time, pool,tokenA, tokenB, amountA, amountB +from swap_events + +union all + +select time, pool,tokenA, tokenB, amountA, amountB +from addliquidity_events + +union all + +select time, pool,tokenA, tokenB, amountA, amountB +from removeliquidity_events + +) group by 1,2,3,4 +) + + +, pool_liquidity as ( +SELECT time, pools.fee, + pool, + b.tokenA, + b.tokenB, + coalesce((SUM(amountA)),0) AS amountA, + coalesce((SUM(amountB)),0) AS amountB +FROM daily_delta_balance b +left join pools on b.pool = pools.poolAddress +GROUP BY 1,2,3,4,5 +) + + + +, wsteth_traded_hourly as ( + select + date_trunc('hour', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.tokenA, cr.tokenB, + sum(case when (cr.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 and json_extract_scalar(params, '$.tokenAIn') = 'true') then amountIn + when (cr.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 and json_extract_scalar(params, '$.tokenAIn') = 'false') then amountOut + when (cr.tokenA != 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 and json_extract_scalar(params, '$.tokenAIn') = 'true') then amountOut + when (cr.tokenA != 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 and json_extract_scalar(params, '$.tokenAIn') = 'false') then amountIn + end) as amount + from {{source('maverick_v2_scroll','V2Pool_evt_PoolSwap')}} sw + left join {{source('maverick_v2_scroll','V2Factory_evt_PoolCreated')}} cr on sw.contract_address = cr.poolAddress + join pools on sw.contract_address = pools.poolAddress + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + +, trading_volume_hourly as ( +select t.time, pool, t.amount*wp.price as volume_raw +from wsteth_traded_hourly t +left join wsteth_prices_hourly wp on date_trunc('hour',t.time) >= wp.time and date_trunc('hour',t.time) < wp.next_time +order by 1,2 +) + +, trading_volume as ( + select distinct date_trunc('day', time) as time + , pool + , sum(volume_raw)/1e18 as volume + from trading_volume_hourly + GROUP by 1,2 +) + +, all_metrics as ( +select + o.pool, + 'scroll' as blockchain, + 'maverick' as project, + format('%,.3f',round(coalesce(fee,0),4)) as fee, + cast(o.time as date) time, + case when o.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then o.tokenA else o.tokenB end as main_token, + case when o.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then pA.symbol else pB.symbol end as main_token_symbol, + case when o.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then o.tokenB else o.tokenA end as paired_token, + case when o.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then pB.symbol else pA.symbol end as paired_token_symbol, + case when o.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then amountA/power(10,pA.decimals) else amountB/power(10,pB.decimals) end as main_token_reserve, + case when o.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then amountB/power(10,pB.decimals) else amountA/power(10,pA.decimals) end as paired_token_reserve, + case when o.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then pA.price else pB.price end as main_token_usd_price, + case when o.tokenA = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then pB.price else pA.price end as paired_token_usd_price, + coalesce(t.volume,0) as trading_volume +from pool_liquidity o +left join tokens_prices_daily pA on o.time = pA.time and o.tokenA = pA.token +left join tokens_prices_daily pB on o.time = pB.time and o.tokenB = pB.token +left join trading_volume t on o.time = t.time and o.pool = t.pool +) + + +select blockchain||' '||project||' '||coalesce(paired_token_symbol,'unknown')||':'||main_token_symbol||' '||fee|| '('||cast(pool as varchar)||')' as pool_name, + pool, + blockchain, + project, + fee, + time, + main_token, + main_token_symbol, + paired_token, + paired_token_symbol, + main_token_reserve, + paired_token_reserve, + main_token_usd_price, + paired_token_usd_price, + trading_volume +from all_metrics + diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/scroll/lido_liquidity_scroll_nuri_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/scroll/lido_liquidity_scroll_nuri_pools.sql new file mode 100644 index 00000000000..da3e364afd4 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/scroll/lido_liquidity_scroll_nuri_pools.sql @@ -0,0 +1,276 @@ +{{ config( + schema='lido_liquidity_scroll', + alias = 'nuri_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["scroll"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-05-15' %} + +with pools as ( +select pool AS address, + 'scroll' AS blockchain, + 'nuri' AS project, + * +from {{source('nuri_scroll','ClPoolFactory_evt_PoolCreated')}} +where (token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 + OR token1 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32) +) + +, tokens as ( + select distinct token + from ( + select token0 as token + from {{source('nuri_scroll','ClPoolFactory_evt_PoolCreated')}} + where token1 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 + union all + select token1 + from {{source('nuri_scroll','ClPoolFactory_evt_PoolCreated')}} + where token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 + union all + select 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 + ) t + ) + + , tokens_prices_daily as ( +select distinct + DATE_TRUNC('day', minute) AS time, + contract_address AS token, + symbol, + decimals, + AVG(price) AS price +FROM {{source('prices','usd')}} p +{% if not is_incremental() %} +WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' +{% else %} +WHERE {{ incremental_predicate('p.minute') }} +{% endif %} + +and date_trunc('day', minute) < current_date +and blockchain = 'scroll' +and contract_address IN (select token from tokens) +group by 1,2,3,4 +union all +select distinct + DATE_TRUNC('day', minute), + contract_address AS token, + symbol, + decimals, + LAST_VALUE(price) OVER (PARTITION BY DATE_TRUNC('day', minute),contract_address ORDER BY minute NULLS FIRST range BETWEEN UNBOUNDED preceding AND UNBOUNDED following) AS price + FROM + {{source('prices','usd')}} + WHERE + DATE_TRUNC('day', minute) = current_date + and blockchain = 'scroll' + and contract_address IN (select token from tokens) + ) + + , wsteth_prices_hourly AS ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + contract_address as token, + symbol, + decimals, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'scroll' and contract_address = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 + +) + +, wsteth_prices_hourly_with_lead AS ( +select time, + lead(time, 1, date_trunc('hour', now() + interval '1' hour)) over (order by time) as next_time, + price +from wsteth_prices_hourly +) + +, mint_events AS ( + select DATE_TRUNC('day', m.evt_block_time) AS time, + m.contract_address AS pool, + cr.token0, + cr.token1, + SUM(CAST(amount0 AS DOUBLE)) AS amount0, + SUM(CAST(amount1 AS DOUBLE)) AS amount1 + from {{source('nuri_scroll','ClPool_evt_Mint')}} m + left join {{source('nuri_scroll','ClPoolFactory_evt_PoolCreated')}} cr on m.contract_address = cr.pool + join pools on m.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', m.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('m.evt_block_time') }} + {% endif %} + group by 1,2,3,4 + ) + + , collect_events as ( + select DATE_TRUNC('day', b.evt_block_time) AS time, + b.contract_address AS pool, + cr.token0, + cr.token1, + (-1)*SUM(CAST(amount0 AS DOUBLE)) AS amount0, + (-1)*SUM(CAST(amount1 AS DOUBLE)) AS amount1 + from {{source('nuri_scroll','ClPool_evt_Collect')}} b + left join {{source('nuri_scroll','ClPoolFactory_evt_PoolCreated')}} cr on b.contract_address = cr.pool + join pools on b.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', b.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('b.evt_block_time') }} + {% endif %} + group by 1,2,3,4 + + ) + +, swap_events as ( + select DATE_TRUNC('day', s.evt_block_time) AS time, + s.contract_address AS pool, + cr.token0, + cr.token1, + SUM(CAST(amount0 AS DOUBLE)) AS amount0, + SUM(CAST(amount1 AS DOUBLE)) AS amount1 + from {{source('nuri_scroll','ClPool_evt_Swap')}} s + left join {{source('nuri_scroll','ClPoolFactory_evt_PoolCreated')}} cr on s.contract_address = cr.pool + join pools on s.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', s.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('s.evt_block_time') }} + {% endif %} + group by 1,2,3,4 + +) + + , daily_delta_balance AS ( + +select time, pool, token0, token1, sum(amount0) as amount0, sum(amount1) as amount1 +from ( +select time, pool,token0, token1, amount0, amount1 +from mint_events + +union all + +select time, pool,token0, token1, amount0, amount1 +from swap_events + +union all + +select time, pool,token0, token1, amount0, amount1 +from collect_events + +) group by 1,2,3,4 +) + +, daily_delta_balance_with_lead AS ( +select time, pool, token0, token1, amount0, amount1, +lead(time, 1, now()) over (partition by pool order by time) as next_time +from daily_delta_balance +) + + +, pool_liquidity as ( +SELECT b.time, + b.pool, + token0, + token1, + SUM(amount0) AS amount0, + SUM(amount1) AS amount1 +FROM daily_delta_balance_with_lead b +GROUP BY 1,2,3,4 +) + +, swap_events_hourly as ( + select DATE_TRUNC('hour', s.evt_block_time) AS time, + s.contract_address AS pool, + sum(case when cr.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 then CAST(amount0 AS DOUBLE) + else CAST(amount1 AS DOUBLE) end) as wsteth_amount + from {{source('nuri_scroll','ClPool_evt_Swap')}} s + left join {{source('nuri_scroll','ClPoolFactory_evt_PoolCreated')}} cr on s.contract_address = cr.pool + join pools on s.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', s.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('s.evt_block_time') }} + {% endif %} + +group by 1,2 +) + +, trading_volume_hourly AS ( + SELECT + s.time, + pool, + wsteth_amount, + p.price, + COALESCE((p.price * wsteth_amount) / CAST(POWER(10, 18) AS DOUBLE), 0) AS volume + FROM + swap_events_hourly AS s + LEFT JOIN wsteth_prices_hourly_with_lead AS p ON s.time >= p.time + AND s.time < p.next_time + ) + +, trading_volume AS ( + SELECT DISTINCT + DATE_TRUNC('day', time) AS time, + pool, + SUM(volume) AS volume + FROM trading_volume_hourly + GROUP BY 1, 2 + ) + +, all_metrics AS ( + SELECT + l.pool, + pools.blockchain, + pools.project, + cast(l.time as date) as time, + CASE WHEN l.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 THEN l.token0 ELSE l.token1 END AS main_token, + CASE WHEN l.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 THEN p0.symbol ELSE p1.symbol END AS main_token_symbol, + CASE WHEN l.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 THEN l.token1 ELSE l.token0 END AS paired_token, + CASE WHEN l.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 THEN p1.symbol ELSE p0.symbol END AS paired_token_symbol, + CASE WHEN l.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 THEN amount0/CAST(POWER(10,p0.decimals) as double) ELSE amount1/CAST(POWER(10,p1.decimals) as double) END AS main_token_reserve, + CASE WHEN l.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 THEN amount1/CAST(POWER(10, p1.decimals) as double) ELSE amount0/CAST(POWER(10, p0.decimals) as double) END AS paired_token_reserve, + CASE WHEN l.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 THEN p0.price ELSE p1.price END AS main_token_usd_price, + CASE WHEN l.token0 = 0xf610A9dfB7C89644979b4A0f27063E9e7d7Cda32 THEN p1.price ELSE p0.price END AS paired_token_usd_price, + coalesce(volume,0) AS trading_volume + FROM + pool_liquidity AS l + LEFT JOIN pools ON l.pool = pools.address + LEFT JOIN tokens AS t0 ON l.token0 = t0.token + LEFT JOIN tokens AS t1 ON l.token1 = t1.token + LEFT JOIN tokens_prices_daily AS p0 ON l.time = p0.time + AND l.token0 = p0.token + LEFT JOIN tokens_prices_daily AS p1 ON l.time = p1.time + AND l.token1 = p1.token + LEFT JOIN trading_volume AS tv ON l.time = tv.time + AND l.pool = tv.pool + ) + + +select blockchain||' '||project||' '||coalesce(paired_token_symbol,'unknown')||':'||main_token_symbol as pool_name, + pool, + blockchain, + project, + time, + main_token, + main_token_symbol, + paired_token, + paired_token_symbol, + main_token_reserve, + paired_token_reserve, + main_token_usd_price, + paired_token_usd_price, + trading_volume +from all_metrics \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/zksync/lido_liquidity_zksync_pancakeswap_v3_pools.sql b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/zksync/lido_liquidity_zksync_pancakeswap_v3_pools.sql new file mode 100644 index 00000000000..7dd8cde215b --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/models/_project/lido/liquidity/zksync/lido_liquidity_zksync_pancakeswap_v3_pools.sql @@ -0,0 +1,263 @@ +{{ config( + schema='lido_liquidity_zksync', + alias = 'pancakeswap_v3_pools', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['pool', 'time'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.time')], + post_hook='{{ expose_spells(blockchains = \'["zksync"]\', + spell_type = "project", + spell_name = "lido_liquidity", + contributors = \'["pipistrella"]\') }}' + ) +}} + +{% set project_start_date = '2024-01-17' %} + +with + +pools as ( +select pool as address, 'zksync' as blockchain, 'pancakeswap' as project, max(cast(fee as double))/10000 as fee +from {{ source('pancakeswap_v3_zksync','PancakeV3Factory_evt_PoolCreated')}} +where token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 or token1 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 +group by 1,2,3 +) + +, tokens as ( +select distinct token as address +from ( +select token1 as token +from {{ source('pancakeswap_v3_zksync','PancakeV3Factory_evt_PoolCreated')}} +where token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 +union +select token0 +from {{ source('pancakeswap_v3_zksync','PancakeV3Factory_evt_PoolCreated')}} +where token1 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 +union +select 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 +) t +) + +, tokens_prices_daily AS ( + SELECT distinct + DATE_TRUNC('day', minute) AS time, + contract_address as token, + decimals, + symbol, + avg(price) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and date_trunc('day', minute) < current_date + and blockchain = 'zksync' + and contract_address in (select address from tokens) + group by 1,2,3,4 + union all + SELECT distinct + DATE_TRUNC('day', minute), + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('day', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} + WHERE date_trunc('day', minute) = current_date + and blockchain = 'zksync' + and contract_address in (select address from tokens) +) + +, tokens_prices_hourly AS ( + select time, + lead(time,1, DATE_TRUNC('hour', now() + interval '1' hour)) over (partition by token order by time) as next_time, + token, price, decimals, symbol + from ( + SELECT distinct + DATE_TRUNC('hour', minute) time, + contract_address as token, + decimals, + symbol, + last_value(price) over (partition by DATE_TRUNC('hour', minute), contract_address ORDER BY minute range between unbounded preceding AND unbounded following) AS price + FROM {{ source('prices', 'usd') }} p + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', p.minute) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('p.minute') }} + {% endif %} + and blockchain = 'zksync' + and contract_address in (select address from tokens) +) p +) + + +, swap_events as ( + select + date_trunc('day', sw.evt_block_time) as time, + sw.contract_address as pool, + cr.token0, cr.token1, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + + from {{ source('pancakeswap_v3_zksync', 'PancakeV3Pool_evt_Swap') }} sw + left join {{ source('pancakeswap_v3_zksync', 'PancakeV3Factory_evt_PoolCreated') }} cr on sw.contract_address = cr.pool + join pools on sw.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + group by 1,2,3,4 +) + +, mint_events as ( + select + date_trunc('day', mt.evt_block_time) as time, + mt.contract_address as pool, + cr.token0, cr.token1, + sum(cast(amount0 as DOUBLE)) as amount0, + sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('pancakeswap_v3_zksync', 'PancakeV3Pool_evt_Mint') }} mt + left join {{ source('pancakeswap_v3_zksync', 'PancakeV3Factory_evt_PoolCreated') }} cr on mt.contract_address = cr.pool + join pools on mt.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', mt.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('mt.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + +, burn_events as ( + select + date_trunc('day', bn.evt_block_time) as time, + bn.contract_address as pool, + cr.token0, cr.token1, + (-1)*sum(cast(amount0 as DOUBLE)) as amount0, + (-1)*sum(cast(amount1 as DOUBLE)) as amount1 + from {{ source('pancakeswap_v3_zksync', 'PancakeV3Pool_evt_Burn') }} bn + left join {{ source('pancakeswap_v3_zksync', 'PancakeV3Factory_evt_PoolCreated') }} cr on bn.contract_address = cr.pool + join pools on bn.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', bn.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('bn.evt_block_time') }} + {% endif %} + + group by 1,2,3,4 + +) + + , collect_events AS ( + SELECT + date_trunc('day', c.evt_block_time) as time, + c.contract_address AS pool, + cr.token0, + cr.token1, + (-1) * CAST(amount0 AS DOUBLE) AS amount0, + (-1) * CAST(amount1 AS DOUBLE) AS amount1, + c.evt_tx_hash + FROM + {{source('pancakeswap_v3_zksync','PancakeV3Pool_evt_Collect')}} AS c + LEFT JOIN {{source('pancakeswap_v3_zksync','PancakeV3Factory_evt_PoolCreated')}} AS cr ON c.contract_address = cr.pool + join pools on c.contract_address = pools.address + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', c.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('c.evt_block_time') }} + {% endif %} + + ) + + +, daily_delta_balance as ( + select time, pool, token0, token1, sum(coalesce(amount0, 0)) as amount0, sum(coalesce(amount1, 0)) as amount1 + from ( + select time, pool, token0, token1, amount0, amount1 + from swap_events + union all + select time, pool, token0, token1, amount0, amount1 + from mint_events + union all + select time, pool, token0, token1, amount0, amount1 + from collect_events + ) balance + group by 1,2,3,4 +) + +, pool_liquidity as ( + select time, + pool, + token0, + token1, + sum(amount0) as amount0, + sum(amount1) as amount1 + from daily_delta_balance + group by 1,2,3,4 +) + + +, swap_events_hourly as ( + select hour, pool, token0, token1, sum(amount0) as amount0, sum(amount1) as amount1 from ( + select + date_trunc('hour', sw.evt_block_time) as hour, + sw.contract_address as pool, + cr.token0, cr.token1, + coalesce(sum(cast(abs(amount0) as DOUBLE)),0) as amount0, + coalesce(sum(cast(abs(amount1) as DOUBLE)),0) as amount1 + + from {{source('pancakeswap_v3_zksync','PancakeV3Pool_evt_Swap')}} sw + left join {{source('pancakeswap_v3_zksync','PancakeV3Factory_evt_PoolCreated')}} cr on sw.contract_address = cr.pool + {% if not is_incremental() %} + WHERE DATE_TRUNC('day', sw.evt_block_time) >= DATE '{{ project_start_date }}' + {% else %} + WHERE {{ incremental_predicate('sw.evt_block_time') }} + {% endif %} + and sw.contract_address in (select address from pools) + group by 1,2,3,4 + + ) a group by 1,2,3,4 +) + +, trading_volume_hourly as ( + select hour as time, pool, token0, amount0, p.price, coalesce(p.price*amount0/power(10, p.decimals),0) as volume + from swap_events_hourly s + left join tokens t on s.token0 = t.address + left join tokens_prices_hourly p on s.hour >= p.time and s.hour < p.next_time and s.token0 = p.token + +) + +, trading_volume as ( +select distinct date_trunc('day', time) as time, pool, sum(volume) as volume +from trading_volume_hourly +group by 1,2 +) + +, all_metrics as ( +select l.pool, pools.blockchain, pools.project, pools.fee, cast(l.time as date) as time, + case when token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 then token0 else token1 end main_token, + case when token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 then p0.symbol else p1.symbol end main_token_symbol, + case when token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 then token1 else token0 end paired_token, + case when token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 then p1.symbol else p0.symbol end paired_token_symbol, + case when token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 then amount0/power(10, p0.decimals) else amount1/power(10, p1.decimals) end main_token_reserve, + case when token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 then amount1/power(10, p1.decimals) else amount0/power(10, p0.decimals) end paired_token_reserve, + case when token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 then p0.price else p1.price end as main_token_usd_price, + case when token0 = 0x703b52F2b28fEbcB60E1372858AF5b18849FE867 then p1.price else p0.price end as paired_token_usd_price, + volume as trading_volume +from pool_liquidity l +left join pools on l.pool = pools.address +left join tokens t0 on l.token0 = t0.address +left join tokens t1 on l.token1 = t1.address +left join tokens_prices_daily p0 on l.time = p0.time and l.token0 = p0.token +left join tokens_prices_daily p1 on l.time = p1.time and l.token1 = p1.token +left join trading_volume tv on l.time = tv.time and l.pool = tv.pool +) + + + +select blockchain||' '||project||' '||COALESCE(paired_token_symbol, 'unknown')||':'||main_token_symbol||' '||format('%,.3f',round(coalesce(fee,0),4)) as pool_name,* +from all_metrics + diff --git a/sources/lido/liquidity/arbitrum/lido_liquidity_arbitrum_sources.yml b/sources/lido/liquidity/arbitrum/lido_liquidity_arbitrum_sources.yml index 7a969902440..c9365926437 100644 --- a/sources/lido/liquidity/arbitrum/lido_liquidity_arbitrum_sources.yml +++ b/sources/lido/liquidity/arbitrum/lido_liquidity_arbitrum_sources.yml @@ -54,5 +54,11 @@ sources: tables: - name: RamsesV2Pool_evt_Mint - name: RamsesV2Pool_evt_Collect - + + - name: pancakeswap_v3_arbitrum + description: "Arbitrum decoded tables related to Pancake v3 DEX pools contracts" + tables: + - name: PancakeV3Pool_evt_Mint + - name: PancakeV3Pool_evt_Collect + - name: PancakeV3Pool_evt_Burn \ No newline at end of file diff --git a/sources/lido/liquidity/base/lido_liquidity_base_sources.yml b/sources/lido/liquidity/base/lido_liquidity_base_sources.yml index 1423f79a684..b78cef4c12a 100644 --- a/sources/lido/liquidity/base/lido_liquidity_base_sources.yml +++ b/sources/lido/liquidity/base/lido_liquidity_base_sources.yml @@ -32,6 +32,19 @@ sources: - name: UniswapV3Pool_evt_Collect - name: UniswapV3Pool_evt_Burn + - name: pancakeswap_v3_base + description: "Base decoded tables related to Pancake v3 contract" + tables: + - name: PancakeV3Pool_evt_Mint + - name: PancakeV3Pool_evt_Collect + - name: PancakeV3Pool_evt_Burn + + - name: maverick_v2_base + description: "Base decoded tables related to Maverick v2 contract" + tables: + - name: V2Pool_evt_PoolAddLiquidity + - name: V2Pool_evt_PoolRemoveLiquidity + diff --git a/sources/lido/liquidity/bnb/lido_liquidity_bnb_sources.yml b/sources/lido/liquidity/bnb/lido_liquidity_bnb_sources.yml new file mode 100644 index 00000000000..66c7472a5d9 --- /dev/null +++ b/sources/lido/liquidity/bnb/lido_liquidity_bnb_sources.yml @@ -0,0 +1,22 @@ +version: 2 + +sources: + - name: pancakeswap_v3_bnb + description: "BNB decoded tables related to Pancake V3 contracts" + tables: + - name: PancakeV3Pool_evt_Mint + - name: PancakeV3Pool_evt_Burn + - name: PancakeV3Pool_evt_Collect + + - name: thena_fi_bnb + description: "BNB decoded tables related to Thena DEX contracts" + tables: + - name: PairFactory_CL_call_createPool + + - name: thena_bnb + description: "BNB decoded tables related to Thena Algebra pools contracts" + tables: + - name: AlgebraPool_evt_Mint + - name: AlgebraPool_evt_Burn + + diff --git a/sources/lido/liquidity/ethereum/lido_liquidity_ethereum_sources.yml b/sources/lido/liquidity/ethereum/lido_liquidity_ethereum_sources.yml index e525e183b08..5ada5e73153 100644 --- a/sources/lido/liquidity/ethereum/lido_liquidity_ethereum_sources.yml +++ b/sources/lido/liquidity/ethereum/lido_liquidity_ethereum_sources.yml @@ -74,4 +74,10 @@ sources: - name: SolidlyV3Factory_evt_PoolCreated - name: SolidlyV3Pool_evt_Swap - name: SolidlyV3Pool_evt_Mint - - name: SolidlyV3Pool_evt_Collect \ No newline at end of file + - name: SolidlyV3Pool_evt_Collect + + - name: puffer_ethereum + description: "Ethereum decoded tables related to Curve pufETH:wstETH pool contract" + tables: + - name: CurveStableSwapNG_evt_TokenExchange + \ No newline at end of file diff --git a/sources/lido/liquidity/linea/lido_liquidity_linea_sources.yml b/sources/lido/liquidity/linea/lido_liquidity_linea_sources.yml index 6cc0828b7d1..79c8a0dff24 100644 --- a/sources/lido/liquidity/linea/lido_liquidity_linea_sources.yml +++ b/sources/lido/liquidity/linea/lido_liquidity_linea_sources.yml @@ -9,3 +9,8 @@ sources: - name: SyncSwapClassicPool_evt_Burn - name: SyncSwapClassicPool_evt_Swap + - name: lynex_linea + description: "Linea decoded tables related to Lynex contract" + tables: + - name: AlgebraPool_evt_Mint + - name: AlgebraPool_evt_Burn diff --git a/sources/lido/liquidity/scroll/lido_liquidity_scroll_sources.yml b/sources/lido/liquidity/scroll/lido_liquidity_scroll_sources.yml index 9cc0aa1b821..d84e8137ff9 100644 --- a/sources/lido/liquidity/scroll/lido_liquidity_scroll_sources.yml +++ b/sources/lido/liquidity/scroll/lido_liquidity_scroll_sources.yml @@ -12,3 +12,15 @@ sources: tables: - name: ZebraV2Pool_evt_Mint - name: ZebraV2Pool_evt_Burn + + - name: maverick_v2_scroll + description: "Scroll decoded tables related to Maveric v2 contract" + tables: + - name: V2Pool_evt_PoolAddLiquidity + - name: V2Pool_evt_PoolRemoveLiquidity + + - name: nuri_scroll + description: "Scroll decoded tables related to Nuri DEX contract" + tables: + - name: ClPool_evt_Mint + - name: ClPool_evt_Collect \ No newline at end of file diff --git a/sources/lido/liquidity/zksync/lido_liquidity_zksync_sources.yml b/sources/lido/liquidity/zksync/lido_liquidity_zksync_sources.yml index a97224dd1e8..a5837f74ec1 100644 --- a/sources/lido/liquidity/zksync/lido_liquidity_zksync_sources.yml +++ b/sources/lido/liquidity/zksync/lido_liquidity_zksync_sources.yml @@ -19,4 +19,9 @@ sources: - name: pool_call_addLiquidity - name: pool_call_removeLiquidity - + - name: pancakeswap_v3_zksync + description: "Zksync decoded tables related to Pancake V3 contracts" + tables: + - name: PancakeV3Pool_evt_Mint + - name: PancakeV3Pool_evt_Collect + - name: PancakeV3Pool_evt_Burn From d37a584cfce51e362ee58dd172071750fcd4614e Mon Sep 17 00:00:00 2001 From: hildobby Date: Wed, 2 Oct 2024 18:08:40 +0200 Subject: [PATCH 125/127] Rework `addresses_events.first_funded_by` + make a crosschain version (#6052) * rework first_funded_by + make a crosschain version * fixes * fix * fix * fix * fix * fixes * fix * fix * update seed * fix * fix * fix * fix * fix * fix * undo btc change * fix * fix * fixes * more to hourly spellbook * fix * fi * fixes * fix * fix * exclude zksync from prod * add NOW() - `3` month filter for ci tests * also filter bitcoin and solana * change downstream spells to refs * fix * remove block_time filters * cleanup files, remove dupe tests * deprecate goerli * merge crosschain spells into 1 --------- Co-authored-by: jeff-dude Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../addresses_events_first_funded_by.sql | 23 ------ .../addresses_events_blast_first_activity.sql | 37 --------- ...addresses_events_blast_first_funded_by.sql | 14 ---- .../blast/addresses_events_blast_schema.yml | 79 ------------------- ...addresses_events_mantle_first_activity.sql | 37 --------- ...ddresses_events_mantle_first_funded_by.sql | 14 ---- .../mantle/addresses_events_mantle_schema.yml | 79 ------------------- .../addresses_events_schema.yml | 31 -------- ...resses_events_testnets_first_funded_by.sql | 21 ----- ...events_testnets_goerli_first_funded_by.sql | 31 -------- ...ddresses_events_testnets_goerli_schema.yml | 39 --------- .../addresses_events_first_activity.sql | 0 .../addresses_events_first_funded_by.sql | 23 ++++++ .../addresses_events_first_activity.sql | 0 .../addresses_events_first_funded_by.sql | 53 ++++++++----- .../addresses_events_schema.yml | 24 ++++-- ...dresses_events_arbitrum_first_activity.sql | 0 ...resses_events_arbitrum_first_funded_by.sql | 7 +- .../addresses_events_arbitrum_schema.yml | 6 ++ ...sses_events_avalanche_c_first_activity.sql | 0 ...ses_events_avalanche_c_first_funded_by.sql | 7 +- .../addresses_events_avalanche_c_schema.yml | 2 + .../addresses_events_base_first_activity.sql | 0 .../addresses_events_base_first_funded_by.sql | 7 +- .../base/addresses_events_base_schema.yml | 6 ++ ...dresses_events_bitcoin_first_funded_by.sql | 0 .../addresses_events_bitcoin_schema.yml | 2 + .../addresses_events_bnb_first_activity.sql | 0 .../addresses_events_bnb_first_funded_by.sql | 7 +- .../bnb/addresses_events_bnb_schema.yml | 2 + .../addresses_events_celo_first_activity.sql | 0 .../addresses_events_celo_first_funded_by.sql | 7 +- .../celo/addresses_events_celo_schema.yml | 2 + ...dresses_events_ethereum_first_activity.sql | 0 ...resses_events_ethereum_first_funded_by.sql | 7 +- .../addresses_events_ethereum_schema.yml | 6 ++ ...addresses_events_fantom_first_activity.sql | 0 ...ddresses_events_fantom_first_funded_by.sql | 7 +- .../fantom/addresses_events_fantom_schema.yml | 2 + ...addresses_events_gnosis_first_activity.sql | 0 ...ddresses_events_gnosis_first_funded_by.sql | 7 +- .../gnosis/addresses_events_gnosis_schema.yml | 2 + .../addresses_events_linea_first_activity.sql | 0 ...addresses_events_linea_first_funded_by.sql | 7 +- .../linea/addresses_events_linea_schema.yml | 6 ++ ...dresses_events_optimism_first_activity.sql | 0 ...resses_events_optimism_first_funded_by.sql | 7 +- .../addresses_events_optimism_first_path.sql | 2 +- .../addresses_events_optimism_schema.yml | 6 ++ ...ddresses_events_polygon_first_activity.sql | 0 ...dresses_events_polygon_first_funded_by.sql | 7 +- .../addresses_events_polygon_schema.yml | 2 + ...addresses_events_scroll_first_activity.sql | 0 ...ddresses_events_scroll_first_funded_by.sql | 7 +- .../scroll/addresses_events_scroll_schema.yml | 8 +- ...ddresses_events_solana_first_funded_by.sql | 0 .../solana/addresses_events_solana_schema.yml | 2 + .../addresses_events_zkevm_first_activity.sql | 0 ...addresses_events_zkevm_first_funded_by.sql | 7 +- .../zkevm/addresses_events_zkevm_schema.yml | 6 ++ ...addresses_events_zksync_first_activity.sql | 0 ...ddresses_events_zksync_first_funded_by.sql | 8 +- .../zksync/addresses_events_zksync_schema.yml | 6 ++ .../addresses_events_zora_first_activity.sql | 0 .../addresses_events_zora_first_funded_by.sql | 7 +- .../zora/addresses_events_zora_schema.yml | 6 ++ .../_sector}/addresses_events/_schema.yml | 0 .../addresses_events/first_activity_seed.csv | 0 .../addresses_events/first_funded_by_seed.csv | 4 +- .../first_funded_by_seed_bitcoin.csv | 0 .../first_funded_by_seed_solana.csv | 0 .../daily_spellbook/_sources.yml | 1 + .../_subprojects_outputs/tokens/transfers.yml | 4 +- 73 files changed, 229 insertions(+), 465 deletions(-) delete mode 100644 dbt_subprojects/daily_spellbook/macros/sector/addresses_events/addresses_events_first_funded_by.sql delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_first_activity.sql delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_first_funded_by.sql delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_schema.yml delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_first_activity.sql delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_first_funded_by.sql delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_schema.yml delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events_testnets/addresses_events_schema.yml delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events_testnets/addresses_events_testnets_first_funded_by.sql delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events_testnets/goerli/addresses_events_testnets_goerli_first_funded_by.sql delete mode 100644 dbt_subprojects/daily_spellbook/models/addresses_events_testnets/goerli/addresses_events_testnets_goerli_schema.yml rename dbt_subprojects/{daily_spellbook => hourly_spellbook}/macros/sector/addresses_events/addresses_events_first_activity.sql (100%) create mode 100644 dbt_subprojects/hourly_spellbook/macros/sector/addresses_events/addresses_events_first_funded_by.sql rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/addresses_events_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/addresses_events_first_funded_by.sql (51%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/addresses_events_schema.yml (70%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/arbitrum/addresses_events_arbitrum_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/arbitrum/addresses_events_arbitrum_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/arbitrum/addresses_events_arbitrum_schema.yml (89%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/avalanche_c/addresses_events_avalanche_c_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/avalanche_c/addresses_events_avalanche_c_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/avalanche_c/addresses_events_avalanche_c_schema.yml (96%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/base/addresses_events_base_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/base/addresses_events_base_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/base/addresses_events_base_schema.yml (89%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/bitcoin/addresses_events_bitcoin_first_funded_by.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/bitcoin/addresses_events_bitcoin_schema.yml (92%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/bnb/addresses_events_bnb_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/bnb/addresses_events_bnb_first_funded_by.sql (57%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/bnb/addresses_events_bnb_schema.yml (96%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/celo/addresses_events_celo_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/celo/addresses_events_celo_first_funded_by.sql (57%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/celo/addresses_events_celo_schema.yml (92%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/ethereum/addresses_events_ethereum_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/ethereum/addresses_events_ethereum_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/ethereum/addresses_events_ethereum_schema.yml (89%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/fantom/addresses_events_fantom_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/fantom/addresses_events_fantom_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/fantom/addresses_events_fantom_schema.yml (96%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/gnosis/addresses_events_gnosis_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/gnosis/addresses_events_gnosis_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/gnosis/addresses_events_gnosis_schema.yml (96%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/linea/addresses_events_linea_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/linea/addresses_events_linea_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/linea/addresses_events_linea_schema.yml (89%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/optimism/addresses_events_optimism_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/optimism/addresses_events_optimism_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/optimism/addresses_events_optimism_first_path.sql (98%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/optimism/addresses_events_optimism_schema.yml (92%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/polygon/addresses_events_polygon_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/polygon/addresses_events_polygon_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/polygon/addresses_events_polygon_schema.yml (96%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/scroll/addresses_events_scroll_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/scroll/addresses_events_scroll_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/scroll/addresses_events_scroll_schema.yml (88%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/solana/addresses_events_solana_first_funded_by.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/solana/addresses_events_solana_schema.yml (92%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zkevm/addresses_events_zkevm_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zkevm/addresses_events_zkevm_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zkevm/addresses_events_zkevm_schema.yml (89%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zksync/addresses_events_zksync_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zksync/addresses_events_zksync_first_funded_by.sql (52%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zksync/addresses_events_zksync_schema.yml (89%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zora/addresses_events_zora_first_activity.sql (100%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zora/addresses_events_zora_first_funded_by.sql (56%) rename dbt_subprojects/{daily_spellbook/models => hourly_spellbook/models/_sector}/addresses_events/zora/addresses_events_zora_schema.yml (89%) rename dbt_subprojects/{daily_spellbook/seeds => hourly_spellbook/seeds/_sector}/addresses_events/_schema.yml (100%) rename dbt_subprojects/{daily_spellbook/seeds => hourly_spellbook/seeds/_sector}/addresses_events/first_activity_seed.csv (100%) rename dbt_subprojects/{daily_spellbook/seeds => hourly_spellbook/seeds/_sector}/addresses_events/first_funded_by_seed.csv (91%) rename dbt_subprojects/{daily_spellbook/seeds => hourly_spellbook/seeds/_sector}/addresses_events/first_funded_by_seed_bitcoin.csv (100%) rename dbt_subprojects/{daily_spellbook/seeds => hourly_spellbook/seeds/_sector}/addresses_events/first_funded_by_seed_solana.csv (100%) diff --git a/dbt_subprojects/daily_spellbook/macros/sector/addresses_events/addresses_events_first_funded_by.sql b/dbt_subprojects/daily_spellbook/macros/sector/addresses_events/addresses_events_first_funded_by.sql deleted file mode 100644 index 5af330660da..00000000000 --- a/dbt_subprojects/daily_spellbook/macros/sector/addresses_events/addresses_events_first_funded_by.sql +++ /dev/null @@ -1,23 +0,0 @@ -{% macro addresses_events_first_funded_by(blockchain) %} - -SELECT -'{{blockchain}}' as blockchain -, et.to AS address -, MIN_BY(et."from", et.block_number) AS first_funded_by -, MIN(et.block_time) AS block_time -, MIN(et.block_number) AS block_number -, MIN_BY(et.tx_hash, et.block_number) AS tx_hash -FROM {{ source( blockchain , 'traces') }} et -{% if is_incremental() %} -LEFT JOIN {{this}} ffb ON et.to = ffb.address WHERE ffb.address IS NULL -{% else %} -WHERE 1 = 1 -{% endif %} -AND et.success -AND (et.call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR et.call_type IS NULL) -AND CAST(et.value AS double) > 0 -{% if is_incremental() %} -AND et.block_time >= date_trunc('day', now() - interval '7' day) -{% endif %} -GROUP BY et.to -{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_first_activity.sql b/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_first_activity.sql deleted file mode 100644 index 3ea6f9919c6..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_first_activity.sql +++ /dev/null @@ -1,37 +0,0 @@ -{{ config( - schema = 'addresses_events_blast' - , alias = 'first_activity' - , materialized = 'incremental' - , file_format = 'delta' - , incremental_strategy = 'append' - , unique_key = ['address'] - ) -}} - -SELECT 'blast' AS blockchain -, et."from" AS address -, MIN_BY(et."to", et.block_number) AS first_activity_to -, MIN(et.block_time) AS first_block_time -, MIN(et.block_number) AS first_block_number -, MIN_BY(et.hash, et.block_number) AS first_tx_hash -, MIN_BY(COALESCE(sig.function, CAST((bytearray_substring(et.data, 1, 4)) as VARCHAR)), et.block_number) as first_function -, MIN_BY(et.value/1e18, et.block_number) as first_{{native_symbol}}_transferred -FROM -{{ source('blast', 'transactions') }} et -LEFT JOIN ( - SELECT - DISTINCT id, - split_part(signature,'(',1) as function - FROM - {{ source('abi', 'signatures') }} - where type = 'function_call' - AND id NOT IN (0x09779838, 0x00000000) -- for some weird reason these have duplicates functions -) sig - ON sig.id = bytearray_substring(et.data, 1, 4) -{% if is_incremental() %} -LEFT JOIN {{this}} ffb ON et."from" = ffb.address -WHERE ffb.address IS NULL -AND et.block_time >= date_trunc('day', now() - interval '7' day) -{% endif %} - -GROUP BY et."from" diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_first_funded_by.sql b/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_first_funded_by.sql deleted file mode 100644 index 16bd0bca594..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_first_funded_by.sql +++ /dev/null @@ -1,14 +0,0 @@ -{{ config( - schema = 'addresses_events_blast' - , alias = 'first_funded_by' - , materialized = 'incremental' - , file_format = 'delta' - , incremental_strategy = 'append' - , unique_key = ['address'] - ) -}} - - -{{addresses_events_first_funded_by( - blockchain='blast' -)}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_schema.yml b/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_schema.yml deleted file mode 100644 index 75c38b79f16..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/blast/addresses_events_blast_schema.yml +++ /dev/null @@ -1,79 +0,0 @@ -version: 2 - -models: - - name: addresses_events_blast_first_funded_by - meta: - blockchain: blast - sector: addresses_events - project: addresses - contributors: hildobby, lgingerich - config: - tags: ['table', 'funded', 'addresses_events', 'blast'] - description: "Table showing who first funded each blast address in ETH" - tests: - - check_seed: - seed_file: ref('first_funded_by_seed') - filter: - blockchain: blast - match_columns: - - blockchain - - address - check_columns: - - first_funded_by - - block_number - - tx_hash - columns: - - name: blockchain - description: "Blockchain" - - name: address - description: "Concerned blast address" - tests: - - unique - - name: first_funded_by - description: "Which blast address first funded the address with ETH" - - name: block_time - description: "The block time on which the address was first funded with ETH" - - name: block_number - description: "The block number on which the address was first funded with ETH" - - name: tx_hash - description: "The transaction hash on which the address was first funded with ETH" - - - name: addresses_events_blast_first_activity - meta: - blockchain: blast - sector: addresses_events - project: addresses - contributors: hildobby - config: - tags: ['table', 'activity', 'addresses_events', 'blast'] - description: "Table showing first activity of each blast Mainnet address" - tests: - - check_seed: - seed_file: ref('first_activity_seed') - filter: - blockchain: blast - match_columns: - - address - check_columns: - - first_activity_to - - first_block_number - - first_tx_hash - columns: - - name: blockchain - description: "Blockchain" - - name: address - description: "Concerned blast Mainnet address" - tests: - - unique - - name: first_activity_to - description: "First transaction activity to address" - - name: first_block_time - description: "The block time on which the address made it's first activity" - - name: first_block_number - description: "The block number on which the address made it's first activity" - - name: first_tx_hash - description: "The transaction hash on which the address made it's first activity" - - name: first_function - description: "first function called by address" - - name: first_eth_transferred - description: "ETH transferred in transaction" diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_first_activity.sql b/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_first_activity.sql deleted file mode 100644 index 34143da750f..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_first_activity.sql +++ /dev/null @@ -1,37 +0,0 @@ -{{ config( - schema = 'addresses_events_mantle' - , alias = 'first_activity' - , materialized = 'incremental' - , file_format = 'delta' - , incremental_strategy = 'append' - , unique_key = ['address'] - ) -}} - -SELECT 'mantle' AS blockchain -, et."from" AS address -, MIN_BY(et."to", et.block_number) AS first_activity_to -, MIN(et.block_time) AS first_block_time -, MIN(et.block_number) AS first_block_number -, MIN_BY(et.hash, et.block_number) AS first_tx_hash -, MIN_BY(COALESCE(sig.function, CAST((bytearray_substring(et.data, 1, 4)) as VARCHAR)), et.block_number) as first_function -, MIN_BY(et.value/1e18, et.block_number) as first_{{native_symbol}}_transferred -FROM -{{ source('mantle', 'transactions') }} et -LEFT JOIN ( - SELECT - DISTINCT id, - split_part(signature,'(',1) as function - FROM - {{ source('abi', 'signatures') }} - where type = 'function_call' - AND id NOT IN (0x09779838, 0x00000000) -- for some weird reason these have duplicates functions -) sig - ON sig.id = bytearray_substring(et.data, 1, 4) -{% if is_incremental() %} -LEFT JOIN {{this}} ffb ON et."from" = ffb.address -WHERE ffb.address IS NULL -AND et.block_time >= date_trunc('day', now() - interval '7' day) -{% endif %} - -GROUP BY et."from" diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_first_funded_by.sql b/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_first_funded_by.sql deleted file mode 100644 index ab5d5699dd7..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_first_funded_by.sql +++ /dev/null @@ -1,14 +0,0 @@ -{{ config( - schema = 'addresses_events_mantle' - , alias = 'first_funded_by' - , materialized = 'incremental' - , file_format = 'delta' - , incremental_strategy = 'append' - , unique_key = ['address'] - ) -}} - - -{{addresses_events_first_funded_by( - blockchain='mantle' -)}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_schema.yml b/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_schema.yml deleted file mode 100644 index a1dbb96d762..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/mantle/addresses_events_mantle_schema.yml +++ /dev/null @@ -1,79 +0,0 @@ -version: 2 - -models: - - name: addresses_events_mantle_first_funded_by - meta: - blockchain: mantle - sector: addresses_events - project: addresses - contributors: hildobby - config: - tags: ['table', 'funded', 'addresses_events', 'mantle'] - description: "Table showing who first funded each Linea address in ETH" - tests: - - check_seed: - seed_file: ref('first_funded_by_seed') - filter: - blockchain: mantle - match_columns: - - blockchain - - address - check_columns: - - first_funded_by - - block_number - - tx_hash - columns: - - name: blockchain - description: "Blockchain" - - name: address - description: "Concerned mantle address" - tests: - - unique - - name: first_funded_by - description: "Which mantle address first funded the address with ETH" - - name: block_time - description: "The block time on which the address was first funded with ETH" - - name: block_number - description: "The block number on which the address was first funded with ETH" - - name: tx_hash - description: "The transaction hash on which the address was first funded with ETH" - - - name: addresses_events_mantle_first_activity - meta: - blockchain: mantle - sector: addresses_events - project: addresses - contributors: hildobby - config: - tags: ['table', 'activity', 'addresses_events', 'mantle'] - description: "Table showing first activity of each mantle Mainnet address" - tests: - - check_seed: - seed_file: ref('first_activity_seed') - filter: - blockchain: mantle - match_columns: - - address - check_columns: - - first_activity_to - - first_block_number - - first_tx_hash - columns: - - name: blockchain - description: "Blockchain" - - name: address - description: "Concerned mantle Mainnet address" - tests: - - unique - - name: first_activity_to - description: "First transaction activity to address" - - name: first_block_time - description: "The block time on which the address made it's first activity" - - name: first_block_number - description: "The block number on which the address made it's first activity" - - name: first_tx_hash - description: "The transaction hash on which the address made it's first activity" - - name: first_function - description: "first function called by address" - - name: first_eth_transferred - description: "ETH transferred in transaction" diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/addresses_events_schema.yml b/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/addresses_events_schema.yml deleted file mode 100644 index 10b477b25c9..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/addresses_events_schema.yml +++ /dev/null @@ -1,31 +0,0 @@ -version: 2 - -models: - - name: addresses_events_testnets_first_funded_by - meta: - blockchain: goerli - sector: addresses_events_testnets - project: addresses - contributors: hildobby - config: - tags: ['table', 'funded', 'addresses_events', 'testnets'] - description: "Table showing who first funded each address in its native asset on every testnet chain" - columns: - - &blockchain - name: blockchain - description: "Name of the blockchain" - - &address - name: address - description: "Concerned address" - - &first_funded_by - name: first_funded_by - description: "Which address first funded the address with the native asset on that chain" - - &block_time - name: block_time - description: "The block time on which the address was first funded with the native asset on that chain" - - &block_number - name: block_number - description: "The block number on which the address was first funded with the native asset on that chain" - - &tx_hash - name: tx_hash - description: "The transaction hash on which the address was first funded with the native asset on that chain" \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/addresses_events_testnets_first_funded_by.sql b/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/addresses_events_testnets_first_funded_by.sql deleted file mode 100644 index 2edd95c8de5..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/addresses_events_testnets_first_funded_by.sql +++ /dev/null @@ -1,21 +0,0 @@ -{{ config -( - alias = 'first_funded_by', - schema = 'addresses_events_testnets', - post_hook='{{ expose_spells(\'["goerli"]\', - "sector", - "addresses_events_testnets", - \'["hildobby"]\') }}' -) -}} - -SELECT * -FROM ( - SELECT blockchain - , address - , first_funded_by - , block_time - , block_number - , tx_hash - FROM {{ ref('addresses_events_testnets_goerli_first_funded_by') }} -) diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/goerli/addresses_events_testnets_goerli_first_funded_by.sql b/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/goerli/addresses_events_testnets_goerli_first_funded_by.sql deleted file mode 100644 index 126e4b7ea22..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/goerli/addresses_events_testnets_goerli_first_funded_by.sql +++ /dev/null @@ -1,31 +0,0 @@ -{{ config( - schema = 'addresses_events_testnets_goerli' - , alias = 'first_funded_by' - - , materialized = 'incremental' - , file_format = 'delta' - , incremental_strategy = 'merge' - , unique_key = ['address'] - ) -}} - -SELECT 'goerli' AS blockchain -, et.to AS address -, MIN_BY(et."from", et.block_number) AS first_funded_by -, MIN(et.block_time) AS block_time -, MIN(et.block_number) AS block_number -, MIN_BY(et.tx_hash, et.block_number) AS tx_hash -FROM {{ source('goerli', 'traces') }} et -{% if is_incremental() %} -LEFT JOIN {{this}} ffb ON et.to = ffb.address -WHERE ffb.address IS NULL -{% else %} -WHERE 1 = 1 -{% endif %} -AND et.success -AND (et.call_type NOT IN ('delegatecall', 'callcode', 'staticcall') OR et.call_type IS NULL) -AND CAST(et.value AS double) > 0 -{% if is_incremental() %} -AND et.block_time >= date_trunc('day', now() - interval '7' day) -{% endif %} -GROUP BY et.to \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/goerli/addresses_events_testnets_goerli_schema.yml b/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/goerli/addresses_events_testnets_goerli_schema.yml deleted file mode 100644 index 5a32d245636..00000000000 --- a/dbt_subprojects/daily_spellbook/models/addresses_events_testnets/goerli/addresses_events_testnets_goerli_schema.yml +++ /dev/null @@ -1,39 +0,0 @@ -version: 2 - -models: - - name: addresses_events_testnets_goerli_first_funded_by - meta: - blockchain: goerli - sector: addresses_events_testnets - project: addresses - contributors: hildobby - config: - tags: ['table', 'funded', 'addresses_events', 'goerli'] - description: "Table showing who first funded each Goerli address in ETH" - tests: - - check_seed: - seed_file: ref('first_funded_by_seed') - filter: - blockchain: goerli - match_columns: - - blockchain - - address - check_columns: - - first_funded_by - - block_number - - tx_hash - columns: - - name: blockchain - description: "Blockchain" - - name: address - description: "Concerned Goerli address" - tests: - - unique - - name: first_funded_by - description: "Which Goerli address first funded the address with ETH" - - name: block_time - description: "The block time on which the address was first funded with ETH" - - name: block_number - description: "The block number on which the address was first funded with ETH" - - name: tx_hash - description: "The transaction hash on which the address was first funded with ETH" diff --git a/dbt_subprojects/daily_spellbook/macros/sector/addresses_events/addresses_events_first_activity.sql b/dbt_subprojects/hourly_spellbook/macros/sector/addresses_events/addresses_events_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/macros/sector/addresses_events/addresses_events_first_activity.sql rename to dbt_subprojects/hourly_spellbook/macros/sector/addresses_events/addresses_events_first_activity.sql diff --git a/dbt_subprojects/hourly_spellbook/macros/sector/addresses_events/addresses_events_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/macros/sector/addresses_events/addresses_events_first_funded_by.sql new file mode 100644 index 00000000000..7a21f735e95 --- /dev/null +++ b/dbt_subprojects/hourly_spellbook/macros/sector/addresses_events/addresses_events_first_funded_by.sql @@ -0,0 +1,23 @@ +{% macro addresses_events_first_funded_by(blockchain, token_transfers) %} + + +SELECT '{{blockchain}}' as blockchain +, tt.to AS address +, MIN_BY(tt."from", (tt.block_number, tt.tx_index)) AS first_funded_by +, MIN_BY(tt.tx_from, (tt.block_number, tt.tx_index)) AS first_funding_executed_by +, MIN(tt.block_time) AS block_time +, MIN(tt.block_number) AS block_number +, MIN_BY(tt.tx_hash, (tt.block_number, tt.tx_index)) AS tx_hash +, MIN_BY(tt.tx_index, tt.block_number) AS tx_index +, MIN_BY(tt.unique_key, (tt.block_number, tt.tx_index)) AS unique_key +FROM {{token_transfers}} tt +{% if is_incremental() %} +WHERE {{ incremental_predicate('tt.block_time') }} +AND tt.token_standard = 'native' +AND tt.to NOT IN (SELECT address FROM {{this}}) +{% else %} +WHERE tt.token_standard = 'native' +{% endif %} +GROUP BY tt.to + +{% endmacro %} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/addresses_events_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/addresses_events_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/addresses_events_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/addresses_events_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/addresses_events_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/addresses_events_first_funded_by.sql similarity index 51% rename from dbt_subprojects/daily_spellbook/models/addresses_events/addresses_events_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/addresses_events_first_funded_by.sql index 9961a4d1a2e..ffd24f99e98 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/addresses_events_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/addresses_events_first_funded_by.sql @@ -2,10 +2,10 @@ ( alias = 'first_funded_by', schema = 'addresses_events', - post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "bnb", "ethereum", "fantom", "gnosis", "optimism", "polygon", "celo", "zksync", "zora", "base", "scroll", "mantle", "blast"]\', + post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "bnb", "ethereum", "fantom", "gnosis", "optimism", "polygon", "celo", "zora", "base", "scroll"]\', "sector", "addresses_events", - \'["hildobby", "Henrystats"]\') }}' + \'["hildobby"]\') }}' ) }} @@ -19,28 +19,41 @@ ref('addresses_events_arbitrum_first_funded_by') , ref('addresses_events_optimism_first_funded_by') , ref('addresses_events_polygon_first_funded_by') , ref('addresses_events_celo_first_funded_by') -, ref('addresses_events_zksync_first_funded_by') , ref('addresses_events_zora_first_funded_by') , ref('addresses_events_base_first_funded_by') , ref('addresses_events_scroll_first_funded_by') , ref('addresses_events_zkevm_first_funded_by') , ref('addresses_events_linea_first_funded_by') -, ref('addresses_events_mantle_first_funded_by') -, ref('addresses_events_blast_first_funded_by') ] %} -SELECT * -FROM ( - {% for addresses_events_model in addresses_events_models %} - SELECT blockchain - , address - , first_funded_by - , block_time - , block_number - , tx_hash - FROM {{ addresses_events_model }} - {% if not loop.last %} - UNION ALL - {% endif %} - {% endfor %} -) +WITH joined_data AS ( + SELECT * + FROM ( + {% for addresses_events_model in addresses_events_models %} + SELECT blockchain + , address + , first_funded_by + , first_funding_executed_by + , block_time + , block_number + , tx_hash + , tx_index + FROM {{ addresses_events_model }} + {% if not loop.last %} + UNION ALL + {% endif %} + {% endfor %} + ) + ) + +SELECT MIN_BY(blockchain, block_time) AS blockchain +, address +, MIN_BY(first_funded_by, block_time) AS first_funded_by +, array_distinct(array_agg(blockchain)) AS chains_funded_on +, MIN_BY(first_funding_executed_by, block_time) AS first_funding_executed_by +, MIN(block_time) AS block_time +, MIN(block_number) AS block_number +, MIN_BY(tx_hash, block_time) AS tx_hash +, MIN_BY(tx_index, block_time) AS tx_index +FROM joined_data +GROUP BY address \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/addresses_events_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/addresses_events_schema.yml similarity index 70% rename from dbt_subprojects/daily_spellbook/models/addresses_events/addresses_events_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/addresses_events_schema.yml index b17dd9faf2e..09862de49ff 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/addresses_events_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/addresses_events_schema.yml @@ -1,15 +1,20 @@ version: 2 models: + - name: addresses_events_first_funded_by meta: - blockchain: arbitrum, avalanche_c, bnb, ethereum, fantom, gnosis, optimism, polygon, celo, zksync, base, scroll, zkevm, linea + blockchain: arbitrum, avalanche_c, bnb, ethereum, fantom, gnosis, optimism, polygon, celo, base, scroll, zkevm, linea sector: addresses_events project: addresses - contributors: hildobby, Henrystats + contributors: hildobby config: - tags: ['table', 'funded', 'addresses_events', 'mainnets'] - description: "Table showing who first funded each address in its native asset on every chain" + tags: ['table', 'funded', 'addresses_events', 'mainnets', 'crosschain'] + description: "Table showing what chain an address was first funded on and its details" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - address columns: - &blockchain name: blockchain @@ -20,6 +25,12 @@ models: - &first_funded_by name: first_funded_by description: "Which address first funded the address with the native asset on that chain" + - &chains_funded_on + name: chains_funded_on + description: "Name of all the blockchains it was funded on" + - &first_funding_executed_by + name: first_funding_executed_by + description: "Which address executed the first funding tx" - &block_time name: block_time description: "The block time on which the address was first funded with the native asset on that chain" @@ -29,6 +40,9 @@ models: - &tx_hash name: tx_hash description: "The transaction hash on which the address was first funded with the native asset on that chain" + - &tx_index + name: tx_index + description: "The transaction index within its block on which the address was first funded with the native asset on that chain" - name: addresses_events_first_activity meta: @@ -56,4 +70,4 @@ models: description: "The transaction hash on which the address made it's first activity" - &first_function name: first_function - description: "first function called by address" + description: "first function called by address" \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/arbitrum/addresses_events_arbitrum_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/arbitrum/addresses_events_arbitrum_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/arbitrum/addresses_events_arbitrum_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/arbitrum/addresses_events_arbitrum_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/arbitrum/addresses_events_arbitrum_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/arbitrum/addresses_events_arbitrum_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/arbitrum/addresses_events_arbitrum_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/arbitrum/addresses_events_arbitrum_first_funded_by.sql index 4147d1f7664..640ee4503d5 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/arbitrum/addresses_events_arbitrum_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/arbitrum/addresses_events_arbitrum_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'arbitrum' %} + {{ config( - schema = 'addresses_events_arbitrum' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='arbitrum' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/arbitrum/addresses_events_arbitrum_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/arbitrum/addresses_events_arbitrum_schema.yml similarity index 89% rename from dbt_subprojects/daily_spellbook/models/addresses_events/arbitrum/addresses_events_arbitrum_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/arbitrum/addresses_events_arbitrum_schema.yml index 50899ebe55c..4f244bcf844 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/arbitrum/addresses_events_arbitrum_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/arbitrum/addresses_events_arbitrum_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned Arbitrum address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Arbitrum address first funded the address with ETH" - name: block_time @@ -37,6 +39,10 @@ models: description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_arbitrum_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/avalanche_c/addresses_events_avalanche_c_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/avalanche_c/addresses_events_avalanche_c_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/avalanche_c/addresses_events_avalanche_c_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/avalanche_c/addresses_events_avalanche_c_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/avalanche_c/addresses_events_avalanche_c_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/avalanche_c/addresses_events_avalanche_c_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/avalanche_c/addresses_events_avalanche_c_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/avalanche_c/addresses_events_avalanche_c_first_funded_by.sql index 362929fceac..4cff982189d 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/avalanche_c/addresses_events_avalanche_c_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/avalanche_c/addresses_events_avalanche_c_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'avalanche_c' %} + {{ config( - schema = 'addresses_events_avalanche_c' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='avalanche_c' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/avalanche_c/addresses_events_avalanche_c_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/avalanche_c/addresses_events_avalanche_c_schema.yml similarity index 96% rename from dbt_subprojects/daily_spellbook/models/addresses_events/avalanche_c/addresses_events_avalanche_c_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/avalanche_c/addresses_events_avalanche_c_schema.yml index f8c1fd7defe..675ce94fc3a 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/avalanche_c/addresses_events_avalanche_c_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/avalanche_c/addresses_events_avalanche_c_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned Avalanche address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Avalanche address first funded the address with AVAX" - name: block_time diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/base/addresses_events_base_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/base/addresses_events_base_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/base/addresses_events_base_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/base/addresses_events_base_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_first_funded_by.sql index eab2fcbefb0..87f4cc81159 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/base/addresses_events_base_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'base' %} + {{ config( - schema = 'addresses_events_base' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' , file_format = 'delta' @@ -10,5 +12,6 @@ {{addresses_events_first_funded_by( - blockchain='base' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/base/addresses_events_base_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_schema.yml similarity index 89% rename from dbt_subprojects/daily_spellbook/models/addresses_events/base/addresses_events_base_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_schema.yml index 16a665547a2..916a202b41f 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/base/addresses_events_base_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/base/addresses_events_base_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned base address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which base address first funded the address with ETH" - name: block_time @@ -37,6 +39,10 @@ models: description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_base_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/bitcoin/addresses_events_bitcoin_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bitcoin/addresses_events_bitcoin_first_funded_by.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/bitcoin/addresses_events_bitcoin_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bitcoin/addresses_events_bitcoin_first_funded_by.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/bitcoin/addresses_events_bitcoin_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bitcoin/addresses_events_bitcoin_schema.yml similarity index 92% rename from dbt_subprojects/daily_spellbook/models/addresses_events/bitcoin/addresses_events_bitcoin_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bitcoin/addresses_events_bitcoin_schema.yml index 64504a249c3..76daf363213 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/bitcoin/addresses_events_bitcoin_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bitcoin/addresses_events_bitcoin_schema.yml @@ -28,6 +28,8 @@ models: description: "Concerned Bitcoin address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Bitcoin address first funded the address with BTC" - name: block_time diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/bnb/addresses_events_bnb_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bnb/addresses_events_bnb_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/bnb/addresses_events_bnb_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bnb/addresses_events_bnb_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/bnb/addresses_events_bnb_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bnb/addresses_events_bnb_first_funded_by.sql similarity index 57% rename from dbt_subprojects/daily_spellbook/models/addresses_events/bnb/addresses_events_bnb_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bnb/addresses_events_bnb_first_funded_by.sql index 9fed90aa27e..88a633488aa 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/bnb/addresses_events_bnb_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bnb/addresses_events_bnb_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'bnb' %} + {{ config( - schema = 'addresses_events_bnb' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='bnb' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/bnb/addresses_events_bnb_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bnb/addresses_events_bnb_schema.yml similarity index 96% rename from dbt_subprojects/daily_spellbook/models/addresses_events/bnb/addresses_events_bnb_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bnb/addresses_events_bnb_schema.yml index fec63938363..08bd45d0613 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/bnb/addresses_events_bnb_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/bnb/addresses_events_bnb_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned BNB address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which BNB address first funded the address with BNB" - name: block_time diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/celo/addresses_events_celo_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/celo/addresses_events_celo_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/celo/addresses_events_celo_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/celo/addresses_events_celo_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/celo/addresses_events_celo_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/celo/addresses_events_celo_first_funded_by.sql similarity index 57% rename from dbt_subprojects/daily_spellbook/models/addresses_events/celo/addresses_events_celo_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/celo/addresses_events_celo_first_funded_by.sql index 2c95be19ccb..cd4fe6c4508 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/celo/addresses_events_celo_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/celo/addresses_events_celo_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'celo' %} + {{ config( - schema = 'addresses_events_celo' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='celo' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/celo/addresses_events_celo_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/celo/addresses_events_celo_schema.yml similarity index 92% rename from dbt_subprojects/daily_spellbook/models/addresses_events/celo/addresses_events_celo_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/celo/addresses_events_celo_schema.yml index 4471b530e68..76103f8ff91 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/celo/addresses_events_celo_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/celo/addresses_events_celo_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned Celo address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Celo address first funded the address with CELO" - name: block_time diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/ethereum/addresses_events_ethereum_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ethereum/addresses_events_ethereum_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/ethereum/addresses_events_ethereum_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ethereum/addresses_events_ethereum_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/ethereum/addresses_events_ethereum_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ethereum/addresses_events_ethereum_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/ethereum/addresses_events_ethereum_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ethereum/addresses_events_ethereum_first_funded_by.sql index 467c7a9d846..f4df9768ee2 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/ethereum/addresses_events_ethereum_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ethereum/addresses_events_ethereum_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'ethereum' %} + {{ config( - schema = 'addresses_events_ethereum' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='ethereum' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/ethereum/addresses_events_ethereum_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ethereum/addresses_events_ethereum_schema.yml similarity index 89% rename from dbt_subprojects/daily_spellbook/models/addresses_events/ethereum/addresses_events_ethereum_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ethereum/addresses_events_ethereum_schema.yml index 7feb4e8e3c9..20aab914fac 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/ethereum/addresses_events_ethereum_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/ethereum/addresses_events_ethereum_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned Ethereum address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Ethereum address first funded the address with ETH" - name: block_time @@ -37,6 +39,10 @@ models: description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_ethereum_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/fantom/addresses_events_fantom_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/fantom/addresses_events_fantom_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/fantom/addresses_events_fantom_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/fantom/addresses_events_fantom_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/fantom/addresses_events_fantom_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/fantom/addresses_events_fantom_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/fantom/addresses_events_fantom_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/fantom/addresses_events_fantom_first_funded_by.sql index eaa14b364e9..d3051e3ccf1 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/fantom/addresses_events_fantom_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/fantom/addresses_events_fantom_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'fantom' %} + {{ config( - schema = 'addresses_events_fantom' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='fantom' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/fantom/addresses_events_fantom_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/fantom/addresses_events_fantom_schema.yml similarity index 96% rename from dbt_subprojects/daily_spellbook/models/addresses_events/fantom/addresses_events_fantom_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/fantom/addresses_events_fantom_schema.yml index 02c89931eb6..d7d0a5a58cd 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/fantom/addresses_events_fantom_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/fantom/addresses_events_fantom_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned Fantom address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Fantom address first funded the address with FTM" - name: block_time diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/gnosis/addresses_events_gnosis_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/gnosis/addresses_events_gnosis_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/gnosis/addresses_events_gnosis_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/gnosis/addresses_events_gnosis_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/gnosis/addresses_events_gnosis_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/gnosis/addresses_events_gnosis_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/gnosis/addresses_events_gnosis_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/gnosis/addresses_events_gnosis_first_funded_by.sql index 1c1ad1e39b5..db8bfcaa248 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/gnosis/addresses_events_gnosis_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/gnosis/addresses_events_gnosis_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'gnosis' %} + {{ config( - schema = 'addresses_events_gnosis' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='gnosis' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/gnosis/addresses_events_gnosis_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/gnosis/addresses_events_gnosis_schema.yml similarity index 96% rename from dbt_subprojects/daily_spellbook/models/addresses_events/gnosis/addresses_events_gnosis_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/gnosis/addresses_events_gnosis_schema.yml index b6e1214c105..2cc827fba41 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/gnosis/addresses_events_gnosis_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/gnosis/addresses_events_gnosis_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned Gnosis address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Gnosis address first funded the address with xDAI" - name: block_time diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/linea/addresses_events_linea_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/linea/addresses_events_linea_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/linea/addresses_events_linea_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/linea/addresses_events_linea_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_first_funded_by.sql index da13fa6499d..caabc37629d 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/linea/addresses_events_linea_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'linea' %} + {{ config( - schema = 'addresses_events_linea' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' , file_format = 'delta' @@ -10,5 +12,6 @@ {{addresses_events_first_funded_by( - blockchain='linea' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/linea/addresses_events_linea_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_schema.yml similarity index 89% rename from dbt_subprojects/daily_spellbook/models/addresses_events/linea/addresses_events_linea_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_schema.yml index 9d870c858dc..d39b416c7fc 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/linea/addresses_events_linea_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/linea/addresses_events_linea_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned linea address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which linea address first funded the address with ETH" - name: block_time @@ -37,6 +39,10 @@ models: description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_linea_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_funded_by.sql index aaaf8e8ccaf..4cf8e04348a 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'optimism' %} + {{ config( - schema = 'addresses_events_optimism' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='optimism' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_first_path.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_path.sql similarity index 98% rename from dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_first_path.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_path.sql index c14530829ea..2e5aa11c9f0 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_first_path.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_first_path.sql @@ -150,6 +150,6 @@ LEFT JOIN ( ) sig ON sig.id = f.function LEFT JOIN -{{ ref('contracts_optimism_contract_mapping') }} cm +{{ source('contracts_optimism', 'contract_mapping') }} cm ON f.to_address = cm.contract_address GROUP BY 1, 2 diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_schema.yml similarity index 92% rename from dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_schema.yml index 969c7d990c8..09b728929ed 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/optimism/addresses_events_optimism_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/optimism/addresses_events_optimism_schema.yml @@ -28,6 +28,8 @@ models: description: "Concerned Optimism address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Optimism address first funded the address with ETH" - name: block_time @@ -36,6 +38,10 @@ models: description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_optimism_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/polygon/addresses_events_polygon_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/polygon/addresses_events_polygon_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/polygon/addresses_events_polygon_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/polygon/addresses_events_polygon_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/polygon/addresses_events_polygon_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/polygon/addresses_events_polygon_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/polygon/addresses_events_polygon_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/polygon/addresses_events_polygon_first_funded_by.sql index a7c40a2d41a..e3b7c8e5f0c 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/polygon/addresses_events_polygon_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/polygon/addresses_events_polygon_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'polygon' %} + {{ config( - schema = 'addresses_events_polygon' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' @@ -11,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='polygon' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/polygon/addresses_events_polygon_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/polygon/addresses_events_polygon_schema.yml similarity index 96% rename from dbt_subprojects/daily_spellbook/models/addresses_events/polygon/addresses_events_polygon_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/polygon/addresses_events_polygon_schema.yml index 7de364f68f1..c2ecc231928 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/polygon/addresses_events_polygon_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/polygon/addresses_events_polygon_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned Polygon address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Polygon address first funded the address with MATIC" - name: block_time diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/scroll/addresses_events_scroll_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/scroll/addresses_events_scroll_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/scroll/addresses_events_scroll_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/scroll/addresses_events_scroll_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_first_funded_by.sql index 942c0c2b100..9ddcb28873a 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/scroll/addresses_events_scroll_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'scroll' %} + {{ config( - schema = 'addresses_events_scroll' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' , file_format = 'delta' @@ -10,5 +12,6 @@ {{addresses_events_first_funded_by( - blockchain='scroll' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/scroll/addresses_events_scroll_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_schema.yml similarity index 88% rename from dbt_subprojects/daily_spellbook/models/addresses_events/scroll/addresses_events_scroll_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_schema.yml index 329c8d88c80..6a2ac61c815 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/scroll/addresses_events_scroll_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/scroll/addresses_events_scroll_schema.yml @@ -29,14 +29,20 @@ models: description: "Concerned scroll address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which scroll address first funded the address with ETH" - name: block_time description: "The block time on which the address was first funded with ETH" - - name: block_number + - name: block_numbers description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_scroll_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/solana/addresses_events_solana_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/solana/addresses_events_solana_first_funded_by.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/solana/addresses_events_solana_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/solana/addresses_events_solana_first_funded_by.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/solana/addresses_events_solana_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/solana/addresses_events_solana_schema.yml similarity index 92% rename from dbt_subprojects/daily_spellbook/models/addresses_events/solana/addresses_events_solana_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/solana/addresses_events_solana_schema.yml index 6c7c67cd849..07d65840954 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/solana/addresses_events_solana_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/solana/addresses_events_solana_schema.yml @@ -30,6 +30,8 @@ models: description: "Concerned Solana address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which Solana address first funded the address with SOL" - name: block_time diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zkevm/addresses_events_zkevm_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zkevm/addresses_events_zkevm_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zkevm/addresses_events_zkevm_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zkevm/addresses_events_zkevm_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zkevm/addresses_events_zkevm_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zkevm/addresses_events_zkevm_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zkevm/addresses_events_zkevm_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zkevm/addresses_events_zkevm_first_funded_by.sql index d5d5f71d23c..88c0c084059 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/zkevm/addresses_events_zkevm_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zkevm/addresses_events_zkevm_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'zkevm' %} + {{ config( - schema = 'addresses_events_zkevm' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' , file_format = 'delta' @@ -10,5 +12,6 @@ {{addresses_events_first_funded_by( - blockchain='zkevm' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zkevm/addresses_events_zkevm_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zkevm/addresses_events_zkevm_schema.yml similarity index 89% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zkevm/addresses_events_zkevm_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zkevm/addresses_events_zkevm_schema.yml index 9b873a709db..6f4feeccd86 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/zkevm/addresses_events_zkevm_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zkevm/addresses_events_zkevm_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned zkevm address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which zkevm address first funded the address with ETH" - name: block_time @@ -37,6 +39,10 @@ models: description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_zkevm_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zksync/addresses_events_zksync_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zksync/addresses_events_zksync_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zksync/addresses_events_zksync_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zksync/addresses_events_zksync_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zksync/addresses_events_zksync_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zksync/addresses_events_zksync_first_funded_by.sql similarity index 52% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zksync/addresses_events_zksync_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zksync/addresses_events_zksync_first_funded_by.sql index 20799cd881c..38f683f6389 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/zksync/addresses_events_zksync_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zksync/addresses_events_zksync_first_funded_by.sql @@ -1,5 +1,8 @@ +{% set blockchain = 'zksync' %} + {{ config( - schema = 'addresses_events_zksync' + tags = ['prod_exclude'] + , schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' , file_format = 'delta' @@ -10,5 +13,6 @@ {{addresses_events_first_funded_by( - blockchain='zksync' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zksync/addresses_events_zksync_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zksync/addresses_events_zksync_schema.yml similarity index 89% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zksync/addresses_events_zksync_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zksync/addresses_events_zksync_schema.yml index e3b5e6fd047..3a6be3c6b61 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/zksync/addresses_events_zksync_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zksync/addresses_events_zksync_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned zksync address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which zksync address first funded the address with ETH" - name: block_time @@ -37,6 +39,10 @@ models: description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_zksync_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zora/addresses_events_zora_first_activity.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zora/addresses_events_zora_first_activity.sql similarity index 100% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zora/addresses_events_zora_first_activity.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zora/addresses_events_zora_first_activity.sql diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zora/addresses_events_zora_first_funded_by.sql b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zora/addresses_events_zora_first_funded_by.sql similarity index 56% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zora/addresses_events_zora_first_funded_by.sql rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zora/addresses_events_zora_first_funded_by.sql index 655ce09f3bd..314bdf0b9ee 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/zora/addresses_events_zora_first_funded_by.sql +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zora/addresses_events_zora_first_funded_by.sql @@ -1,5 +1,7 @@ +{% set blockchain = 'zora' %} + {{ config( - schema = 'addresses_events_zora' + schema = 'addresses_events_' + blockchain , alias = 'first_funded_by' , materialized = 'incremental' , file_format = 'delta' @@ -10,5 +12,6 @@ {{addresses_events_first_funded_by( - blockchain='zora' + blockchain = blockchain + , token_transfers = source('tokens_' + blockchain, 'transfers') )}} diff --git a/dbt_subprojects/daily_spellbook/models/addresses_events/zora/addresses_events_zora_schema.yml b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zora/addresses_events_zora_schema.yml similarity index 89% rename from dbt_subprojects/daily_spellbook/models/addresses_events/zora/addresses_events_zora_schema.yml rename to dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zora/addresses_events_zora_schema.yml index 56d0f31cab2..3caac08c6b4 100644 --- a/dbt_subprojects/daily_spellbook/models/addresses_events/zora/addresses_events_zora_schema.yml +++ b/dbt_subprojects/hourly_spellbook/models/_sector/addresses_events/zora/addresses_events_zora_schema.yml @@ -29,6 +29,8 @@ models: description: "Concerned zora address" tests: - unique + - name: first_funding_executed_by + description: "Which address executed the first funding tx" - name: first_funded_by description: "Which zora address first funded the address with ETH" - name: block_time @@ -37,6 +39,10 @@ models: description: "The block number on which the address was first funded with ETH" - name: tx_hash description: "The transaction hash on which the address was first funded with ETH" + - name: tx_index + description: "The transaction index within the block on which the address was first funded with ETH" + - name: unique_key + description: "Unique transfer identifier key" - name: addresses_events_zora_first_activity meta: diff --git a/dbt_subprojects/daily_spellbook/seeds/addresses_events/_schema.yml b/dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/_schema.yml similarity index 100% rename from dbt_subprojects/daily_spellbook/seeds/addresses_events/_schema.yml rename to dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/_schema.yml diff --git a/dbt_subprojects/daily_spellbook/seeds/addresses_events/first_activity_seed.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_activity_seed.csv similarity index 100% rename from dbt_subprojects/daily_spellbook/seeds/addresses_events/first_activity_seed.csv rename to dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_activity_seed.csv diff --git a/dbt_subprojects/daily_spellbook/seeds/addresses_events/first_funded_by_seed.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_funded_by_seed.csv similarity index 91% rename from dbt_subprojects/daily_spellbook/seeds/addresses_events/first_funded_by_seed.csv rename to dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_funded_by_seed.csv index 28edb9b7e3e..ea44ebdc7a0 100644 --- a/dbt_subprojects/daily_spellbook/seeds/addresses_events/first_funded_by_seed.csv +++ b/dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_funded_by_seed.csv @@ -19,7 +19,7 @@ fantom,0xf4cc855ce33b9ffad5dd85799190811157a0271b,0xe2922b289bd364c8b0fe25fc5bc3 fantom,0xf4cd008d798a3b757c12ade2a16311ba5bf8a7c5,0xeabbf24d080722c86c6441faceefa4070a25af67,16865837,0x90502ef842d078af330e082b5ab257a1fbe3b5117fcd7373a15f6cf0a2b55c62 celo,0x273BFe950BDc3d16e88ba755DAD845CC77Dbf9B6,0x4F93Fa058b03953C851eFaA2e4FC5C34afDFAb84,19059311,0x1d3e9cfcc476f0f146e10e1de0f4e30a560373f2d03f2e6ebb436ad49f685b53 celo,0x7df13800cf9352513e0f64dbce2947bbd416fd8a,0xdd3826a3a3e0fff1fa3424f5fc5d4523e3256cef,21411795,0xe500f615634d56bfb24515c4d94d1388c3ae19f6a51afb3b7c4f50d3b182c65c -zksync,0x67eecbd0d594a760aa569d20c3f33592c8865d1d,0x621425a1ef6abe91058e9712575dcc4258f8d091,2219807,0x13685fb1135194c37377359ab28856f1c430c120237316189d6c8c14a283bffc -zksync,0x9d9d6e47bd5eb4f166444bb9220b2638228d06d5,0x621425a1ef6abe91058e9712575dcc4258f8d091,2269832,0xafc90f065a5ea2fa81222c1631a97f8776bdd847c0954d3e1bfa1fa5a787d8a9 +zksync,0x5dcc03586098648a92aa3862d25c66295024b049,0x888270ff52f486729ef865466340d4eac83a31d6,9872121,0xc6175daf3025aef766cf9ed0bd302e284571b4d65e0b1721d733361a63e8ddfc +zksync,0x65b7446d7be552e4a0bc72e921951000ff709c3b,0xe4edb277e41dc89ab076a1f049f4a3efa700bce8,1548262,0x63f2c92dd302f49c5e2772cc6e0d1d01ac09761ff2ce2f659ffadcb3ca0874e8 zora,0x3fab184622dc19b6109349b94811493bf2a45362,0xad031eee55f595df6dbd61e9ef3b908fad1b3671,10626,0x33f1a09bb2011aea90e56a66975d7ed3f3e20880f7f2395474f4e197cedb9e6d zora,0xf2989961bf987bdd6c86cd6b845b6faca194a8e4,0xc4da93843ca009814325aa5437412c85612d3f1f,41445,0x6eef8829fbf19a266ee42f4bf1908ea0fa570a8b5a8521830b71104164b87bba \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/seeds/addresses_events/first_funded_by_seed_bitcoin.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_funded_by_seed_bitcoin.csv similarity index 100% rename from dbt_subprojects/daily_spellbook/seeds/addresses_events/first_funded_by_seed_bitcoin.csv rename to dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_funded_by_seed_bitcoin.csv diff --git a/dbt_subprojects/daily_spellbook/seeds/addresses_events/first_funded_by_seed_solana.csv b/dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_funded_by_seed_solana.csv similarity index 100% rename from dbt_subprojects/daily_spellbook/seeds/addresses_events/first_funded_by_seed_solana.csv rename to dbt_subprojects/hourly_spellbook/seeds/_sector/addresses_events/first_funded_by_seed_solana.csv diff --git a/sources/_subprojects_outputs/daily_spellbook/_sources.yml b/sources/_subprojects_outputs/daily_spellbook/_sources.yml index c1521130161..aaa30c99dee 100644 --- a/sources/_subprojects_outputs/daily_spellbook/_sources.yml +++ b/sources/_subprojects_outputs/daily_spellbook/_sources.yml @@ -16,6 +16,7 @@ sources: tables: - name: disperse_contracts - name: contract_creator_project_mapping + - name: contract_mapping - name: labels tables: diff --git a/sources/_subprojects_outputs/tokens/transfers.yml b/sources/_subprojects_outputs/tokens/transfers.yml index 59fe74d7e62..e229ae82b19 100644 --- a/sources/_subprojects_outputs/tokens/transfers.yml +++ b/sources/_subprojects_outputs/tokens/transfers.yml @@ -67,4 +67,6 @@ sources: tables: - name: transfers - + - name: tokens_mantle + tables: + - name: transfers \ No newline at end of file From 389e9af8e865e5d9a399d568bbd576984d139f05 Mon Sep 17 00:00:00 2001 From: monidob <122102789+monidob@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:11:27 +0300 Subject: [PATCH 126/127] Update tokens_ethereum_erc20.sql (#6865) Wrong decimals value was entered for token 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3 --- .../tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql index dc0ed2338d6..4be68ef4e22 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4628,7 +4628,7 @@ FROM (VALUES , ( 0xbbd91d5cda7085a186b1354e1b0744bb58ad7cf6, 'ZOMBIE', 9) , ( 0xdd157bd06c1840fa886da18a138c983a7d74c1d7, 'GSTOP', 18) , ( 0x525574c899a7c877a11865339e57376092168258, 'GURU', 18) - , ( 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 'BUBBLE', 9) + , ( 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 'BUBBLE', 18) , ( 0xeb9951021698b42e4399f9cbb6267aa35f82d59d, 'LIF', 18) , ( 0x707f9118e33a9b8998bea41dd0d46f38bb963fc8, 'bETH', 18) , ( 0x848107491e029afde0ac543779c7790382f15929, 'stataEthcrvUSD', 18) From bd7f463eaf294452524e9290cfd287795ddb0316 Mon Sep 17 00:00:00 2001 From: tomfutago <35136350+tomfutago@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:42:18 +0100 Subject: [PATCH 127/127] Nexus Mutual - staking rewards & staked history (#6861) * refactor: staking events * fix: amend product_id to non-nullable & trigger incremental re-run * feat: add staking rewards and staked per pool & token * fix: staking deposit entensions uniqueness --- .../nexusmutual/ethereum/staking/_schema.yml | 121 +++++++++++++++++- ...exusmutual_ethereum_base_staking_pools.sql | 10 +- .../nexusmutual_ethereum_staked_per_pool.sql | 90 +++++++++++++ .../nexusmutual_ethereum_staked_per_token.sql | 98 ++++++++++++++ ...al_ethereum_staking_deposit_extensions.sql | 55 ++++---- ...utual_ethereum_staking_deposit_ordered.sql | 67 ++++++++++ .../nexusmutual_ethereum_staking_events.sql | 1 + .../nexusmutual_ethereum_staking_pools.sql | 7 +- .../nexusmutual_ethereum_staking_rewards.sql | 64 +++++++++ .../ethereum/nexusmutual_ethereum_sources.yml | 3 + 10 files changed, 482 insertions(+), 34 deletions(-) create mode 100644 dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staked_per_pool.sql create mode 100644 dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staked_per_token.sql create mode 100644 dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_ordered.sql create mode 100644 dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_rewards.sql diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/_schema.yml b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/_schema.yml index 468841a72ee..b75aa207bc6 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/_schema.yml +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/_schema.yml @@ -132,7 +132,7 @@ models: contributors: tomfutago config: tags: ["ethereum", "nexusmutual", "staking"] - description: "Staking pools event history for Nexus Mutual on Ethereum" + description: "Staking pools event history" tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: @@ -147,6 +147,9 @@ models: - &block_time name: block_time description: "UTC event block time" + - &block_date + name: block_date + description: "event block date" - *pool_address - &token_id name: token_id @@ -182,6 +185,42 @@ models: name: tx_hash description: "unique transaction hash value" + - name: nexusmutual_ethereum_staking_deposit_ordered + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "staking"] + description: "Staking pools deposit ordered" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - flow_type + - block_time + - evt_index + - tx_hash + columns: + - *block_time + - *flow_type + - &stake_start_date + name: stake_start_date + - &stake_end_date + name: stake_end_date + - *pool_address + - *token_id + - *tranche_id + - *init_tranche_id + - *new_tranche_id + - *tranche_expiry_date + - *is_active + - *amount + - *topup_amount + - *user + - *evt_index + - *tx_hash + - name: deposit_rn + - name: nexusmutual_ethereum_staking_deposit_extensions meta: blockchain: ethereum @@ -189,7 +228,7 @@ models: contributors: tomfutago config: tags: ["ethereum", "nexusmutual", "staking"] - description: "Staking pools deposit extensions for Nexus Mutual on Ethereum" + description: "Staking pools deposit extensions" tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: @@ -197,16 +236,20 @@ models: - token_id - init_tranche_id - current_tranche_id + - stake_start_date + - stake_end_date columns: - *block_time + - *block_date - *pool_address - *token_id - *init_tranche_id - name: current_tranche_id description: "current staking tranche period (most recent one in the chain of extensions)" - - name: total_amount + - name: amount description: "total staking amount (initial deposit + all top-up amounts)" - - *tranche_expiry_date + - *stake_start_date + - *stake_end_date - *is_active - name: chain_level description: "chain (recursion) level" @@ -214,3 +257,73 @@ models: description: "descending row number per pool, token & tranche" - *evt_index - *tx_hash + + - name: nexusmutual_ethereum_staking_rewards + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "staking"] + description: "Staking rewards minted at cover buy event - to be streamed over cover period" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - pool_id + - cover_id + columns: + - *block_time + - *block_date + - *pool_id + - *product_id + - name: cover_id + - name: cover_start_date + - name: cover_end_date + - name: reward_amount_expected_total + - name: reward_amount_per_second + - name: reward_amount_per_day + - *tx_hash + + - name: nexusmutual_ethereum_staked_per_pool + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "staking"] + description: "Staking rewards minted at cover buy event - to be streamed over cover period" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + columns: + - *block_date + - *pool_id + - *pool_address + - &total_staked_nxm + name: total_staked_nxm + - name: pool_date_rn + + - name: nexusmutual_ethereum_staked_per_token + meta: + blockchain: ethereum + project: nexusmutual + contributors: tomfutago + config: + tags: ["ethereum", "nexusmutual", "staking"] + description: "Staking rewards minted at cover buy event - to be streamed over cover period" + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - block_date + - pool_id + - token_id + columns: + - *block_date + - *pool_id + - *pool_address + - *token_id + - *total_staked_nxm + - name: stake_expiry_date + - name: token_date_rn diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_base_staking_pools.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_base_staking_pools.sql index 0ebf657ee4e..84423810d7a 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_base_staking_pools.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_base_staking_pools.sql @@ -202,10 +202,16 @@ products as ( select cast(p.product_id as int) as product_id, p.product_name, - pt.product_type_id, + cast(pt.product_type_id as int) as product_type_id, pt.product_type_name as product_type from {{ ref('nexusmutual_ethereum_product_types_v2') }} pt inner join {{ ref('nexusmutual_ethereum_products_v2') }} p on pt.product_type_id = p.product_type_id + union all + select + -1 as product_id, + null as product_name, + -1 as product_type_id, + null as product_type ) select @@ -247,6 +253,6 @@ select ) as tx_hash_updated from staking_pools_created_ext sp inner join staking_pool_products_combined spc on sp.pool_id = spc.pool_id - left join products p on spc.product_id = p.product_id + inner join products p on spc.product_id = p.product_id left join staking_pool_managers spm on sp.pool_id = spm.pool_id left join staking_pool_fee_updates spf on sp.pool_address = spf.pool_address diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staked_per_pool.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staked_per_pool.sql new file mode 100644 index 00000000000..9b903a7335a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staked_per_pool.sql @@ -0,0 +1,90 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'staked_per_pool', + materialized = 'view', + unique_key = ['block_date', 'pool_id'], + post_hook = '{{ expose_spells(blockchains = \'["ethereum"]\', + spell_type = "project", + spell_name = "nexusmutual", + contributors = \'["tomfutago"]\') }}' + ) +}} + +with + +staking_pools as ( + select distinct + sp.pool_id, + sp.pool_address, + se.first_stake_event_date + from {{ ref('nexusmutual_ethereum_staking_pools') }} sp + inner join ( + select + pool_address, + cast(min(block_time) as date) as first_stake_event_date + from {{ ref('nexusmutual_ethereum_staking_events') }} + group by 1 + ) se on sp.pool_address = se.pool_address +), + +staking_pool_day_sequence as ( + select + sp.pool_id, + sp.pool_address, + s.block_date + from staking_pools sp + cross join unnest ( + sequence( + cast(date_trunc('day', sp.first_stake_event_date) as timestamp), + cast(date_trunc('day', now()) as timestamp), + interval '1' day + ) + ) as s(block_date) +), + +staked_nxm_per_pool as ( + select + block_date, + pool_id, + pool_address, + sum(coalesce(total_amount, 0)) as total_staked_nxm, + dense_rank() over (partition by pool_id order by block_date desc) as pool_date_rn + from ( + -- deposits & deposit extensions + select + d.block_date, + d.pool_id, + d.pool_address, + sum(se.amount) as total_amount + from staking_pool_day_sequence d + left join {{ ref('nexusmutual_ethereum_staking_deposit_extensions') }} se + on d.pool_address = se.pool_address + and d.block_date >= se.stake_start_date + and d.block_date < se.stake_end_date + group by 1, 2, 3 + union all + -- withdrawals & burns + select + d.block_date, + d.pool_id, + d.pool_address, + sum(se.amount) as total_amount + from staking_pool_day_sequence d + left join {{ ref('nexusmutual_ethereum_staking_events') }} se + on d.pool_address = se.pool_address + and d.block_date >= date_trunc('day', se.block_time) + and d.block_date < coalesce(se.tranche_expiry_date, current_date) + where flow_type in ('withdraw', 'stake burn') + group by 1, 2, 3 + ) t + group by 1, 2, 3 +) + +select + block_date, + pool_id, + pool_address, + total_staked_nxm, + pool_date_rn +from staked_nxm_per_pool diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staked_per_token.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staked_per_token.sql new file mode 100644 index 00000000000..d59db6f0032 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staked_per_token.sql @@ -0,0 +1,98 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'staked_per_token', + materialized = 'view', + unique_key = ['block_date', 'pool_id', 'token_id'], + post_hook = '{{ expose_spells(blockchains = \'["ethereum"]\', + spell_type = "project", + spell_name = "nexusmutual", + contributors = \'["tomfutago"]\') }}' + ) +}} + +with + +staking_pools as ( + select distinct + sp.pool_id, + sp.pool_address, + se.first_stake_event_date + from {{ ref('nexusmutual_ethereum_staking_pools') }} sp + inner join ( + select + pool_address, + cast(min(block_time) as date) as first_stake_event_date + from {{ ref('nexusmutual_ethereum_staking_events') }} + group by 1 + ) se on sp.pool_address = se.pool_address +), + +staking_pool_day_sequence as ( + select + sp.pool_id, + sp.pool_address, + s.block_date + from staking_pools sp + cross join unnest ( + sequence( + cast(date_trunc('day', sp.first_stake_event_date) as timestamp), + cast(date_trunc('day', now()) as timestamp), + interval '1' day + ) + ) as s(block_date) +), + +staked_nxm_per_pool_n_token as ( + select + block_date, + pool_id, + pool_address, + token_id, + sum(coalesce(total_amount, 0)) as total_staked_nxm, + max(stake_expiry_date) as stake_expiry_date, + dense_rank() over (partition by pool_id, token_id order by block_date desc) as token_date_rn + from ( + -- deposits & deposit extensions + select + d.block_date, + d.pool_id, + d.pool_address, + se.token_id, + sum(se.amount) as total_amount, + max(se.stake_end_date) as stake_expiry_date + from staking_pool_day_sequence d + left join {{ ref('nexusmutual_ethereum_staking_deposit_extensions') }} se + on d.pool_address = se.pool_address + and d.block_date >= se.stake_start_date + and d.block_date < se.stake_end_date + group by 1, 2, 3, 4 + union all + -- withdrawals & burns? + select + d.block_date, + d.pool_id, + d.pool_address, + se.token_id, + sum(se.amount) as total_amount, + cast(null as date) as stake_expiry_date -- no point pulling stake_expiry_date for withdrawals + from staking_pool_day_sequence d + left join {{ ref('nexusmutual_ethereum_staking_events') }} se + on d.pool_address = se.pool_address + and d.block_date >= date_trunc('day', se.block_time) + and d.block_date < coalesce(se.tranche_expiry_date, current_date) + where flow_type in ('withdraw', 'stake burn') + group by 1, 2, 3, 4 + ) t + group by 1, 2, 3, 4 +) + +select + block_date, + pool_id, + pool_address, + token_id, + total_staked_nxm, + stake_expiry_date, + token_date_rn +from staked_nxm_per_pool_n_token diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_extensions.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_extensions.sql index 58aefb450ff..7bcd2b6ad2b 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_extensions.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_extensions.sql @@ -3,7 +3,7 @@ schema = 'nexusmutual_ethereum', alias = 'staking_deposit_extensions', materialized = 'view', - unique_key = ['pool_address', 'token_id', 'init_tranche_id', 'current_tranche_id'], + unique_key = ['pool_address', 'token_id', 'init_tranche_id', 'current_tranche_id', 'stake_start_date', 'stake_end_date'], post_hook = '{{ expose_spells(blockchains = \'["ethereum"]\', spell_type = "project", spell_name = "nexusmutual", @@ -11,60 +11,67 @@ ) }} -with recursive deposit_chain (pool_address, token_id, tranche_id, new_tranche_id, total_amount, block_time, tranche_expiry_date, is_active, evt_index, tx_hash, chain_level) as ( +with recursive deposit_chain ( + block_time, pool_address, token_id, tranche_id, new_tranche_id, amount, stake_start_date, stake_end_date, is_active, evt_index, tx_hash, deposit_rn, chain_level +) as ( select + block_time, pool_address, token_id, - tranche_id as tranche_id, + tranche_id, tranche_id as new_tranche_id, - sum(amount) as total_amount, - max(block_time) as block_time, - max_by(tranche_expiry_date, block_time) as tranche_expiry_date, - max_by(is_active, block_time) as is_active, - max_by(evt_index, block_time) as evt_index, - max_by(tx_hash, block_time) as tx_hash, + amount, + stake_start_date, + stake_end_date, + is_active, + evt_index, + tx_hash, + deposit_rn, 1 as chain_level - from {{ ref('nexusmutual_ethereum_staking_events') }} + from {{ ref('nexusmutual_ethereum_staking_deposit_ordered') }} where flow_type = 'deposit' - group by 1,2,3,4 union all select + d.block_time, d.pool_address, d.token_id, dc.tranche_id, - d.new_tranche_id, - dc.total_amount + coalesce(d.topup_amount, 0) as total_amount, - d.block_time, - d.tranche_expiry_date, + coalesce(d.new_tranche_id, dc.tranche_id) as new_tranche_id, + dc.amount + coalesce(d.amount, d.topup_amount, 0) as amount, + d.stake_start_date, + d.stake_end_date, d.is_active, d.evt_index, d.tx_hash, + d.deposit_rn, dc.chain_level + 1 as chain_level from deposit_chain dc - inner join {{ ref('nexusmutual_ethereum_staking_events') }} d on dc.pool_address = d.pool_address - and dc.token_id = d.token_id - and dc.new_tranche_id = d.init_tranche_id - where d.flow_type = 'deposit extended' + inner join {{ ref('nexusmutual_ethereum_staking_deposit_ordered') }} d on dc.pool_address = d.pool_address and dc.token_id = d.token_id + where dc.deposit_rn = d.deposit_rn - 1 + and ((d.flow_type = 'deposit extended' and dc.new_tranche_id = d.init_tranche_id) + or (d.flow_type = 'deposit addon' and dc.new_tranche_id = d.tranche_id)) ) -select +select block_time, + date_trunc('day', block_time) as block_date, pool_address, token_id, tranche_id as init_tranche_id, new_tranche_id as current_tranche_id, - total_amount, - tranche_expiry_date, + amount, + stake_start_date, + stake_end_date, is_active, chain_level, - rn as token_tranche_rn, + token_tranche_rn, evt_index, tx_hash from ( select *, - row_number() over (partition by pool_address, token_id, tranche_id order by chain_level desc) as rn + row_number() over (partition by pool_address, token_id, tranche_id order by chain_level desc) as token_tranche_rn from deposit_chain ) t diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_ordered.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_ordered.sql new file mode 100644 index 00000000000..f5d47b559b4 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_deposit_ordered.sql @@ -0,0 +1,67 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'staking_deposit_ordered', + materialized = 'view', + unique_key = ['flow_type', 'block_time', 'evt_index', 'tx_hash'] + ) +}} + +with + +deposits as ( + select + flow_type, + block_time, + block_date, + pool_address, + token_id, + tranche_id, + init_tranche_id, + new_tranche_id, + tranche_expiry_date, + is_active, + amount, + topup_amount, + user, + evt_index, + tx_hash, + lead(block_date, 1) over (partition by pool_address, token_id order by coalesce(tranche_id, init_tranche_id), block_time) as next_block_date, + lag(flow_type, 1) over (partition by pool_address, token_id order by coalesce(tranche_id, init_tranche_id), block_time) as prev_flow_type, + lead(flow_type, 1) over (partition by pool_address, token_id order by coalesce(tranche_id, init_tranche_id), block_time) as next_flow_type, + lag(token_id, 1) over (partition by pool_address, token_id order by coalesce(tranche_id, init_tranche_id), block_time) as prev_token_id, + lag(tranche_id, 1) over (partition by pool_address, token_id order by coalesce(tranche_id, init_tranche_id), block_time) as prev_tranche_id, + lead(tranche_id, 1) over (partition by pool_address, token_id order by coalesce(tranche_id, init_tranche_id), block_time) as next_tranche_id, + row_number() over (partition by pool_address, token_id order by coalesce(tranche_id, init_tranche_id), block_time) as deposit_rn + from {{ ref('nexusmutual_ethereum_staking_events') }} + where flow_type in ('deposit', 'deposit extended') +) + +select + block_time, + case + when token_id = prev_token_id and flow_type = 'deposit' and prev_flow_type = 'deposit' and prev_tranche_id = tranche_id + then 'deposit addon' + else flow_type + end as flow_type, + block_date as stake_start_date, + case + when flow_type = 'deposit' and next_flow_type <> 'deposit extended' and next_tranche_id <> tranche_id then tranche_expiry_date + when flow_type = 'deposit extended' and next_flow_type = 'deposit' then tranche_expiry_date + when next_block_date > tranche_expiry_date then tranche_expiry_date + else coalesce(next_block_date, tranche_expiry_date) + end as stake_end_date, + pool_address, + token_id, + tranche_id, + init_tranche_id, + new_tranche_id, + tranche_expiry_date, + is_active, + amount, + topup_amount, + user, + evt_index, + tx_hash, + deposit_rn +from deposits diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_events.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_events.sql index 846f286b13c..2d4f1940f77 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_events.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_events.sql @@ -104,6 +104,7 @@ staked_nxm_history as ( select flow_type, block_time, + date_trunc('day', block_time) as block_date, pool_address, token_id, tranche_id, diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_pools.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_pools.sql index adce06fa39c..ad21b3e3559 100644 --- a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_pools.sql +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_pools.sql @@ -38,7 +38,6 @@ select tx_hash_created, tx_hash_updated from {{ ref('nexusmutual_ethereum_base_staking_pools') }} -where true - {% if is_incremental() %} - and {{ incremental_predicate('block_time_updated') }} - {% endif %} +{% if is_incremental() %} +where {{ incremental_predicate('block_time_updated') }} +{% endif %} diff --git a/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_rewards.sql b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_rewards.sql new file mode 100644 index 00000000000..13a26d46de6 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/nexusmutual/ethereum/staking/nexusmutual_ethereum_staking_rewards.sql @@ -0,0 +1,64 @@ +{{ + config( + schema = 'nexusmutual_ethereum', + alias = 'staking_rewards', + materialized = 'view', + unique_key = ['pool_id', 'cover_id'], + post_hook = '{{ expose_spells(blockchains = \'["ethereum"]\', + spell_type = "project", + spell_name = "nexusmutual", + contributors = \'["tomfutago"]\') }}' + ) +}} + +with + +covers as ( + select + cover_id, + cover_start_date, + cover_end_date, + floor(date_diff('day', from_unixtime(0), cover_end_date) / 28) as cover_end_bucket_id, + from_unixtime(28.0 * 86400.0 * cast(floor(date_diff('day', from_unixtime(0), cover_end_time) / 28) + 1 as double)) as cover_end_bucket_expiry_date, + date_diff( + 'second', + cover_start_time, + from_unixtime(28.0 * 86400.0 * cast(floor(date_diff('day', from_unixtime(0), cover_end_time) / 28) + 1 as double)) -- cover_end_bucket_expiry_date (rathan than cover_end_time) + ) as cover_period_seconds, + staking_pool_id, + product_id, + block_number, + trace_address, + tx_hash + from {{ ref("nexusmutual_ethereum_covers_v2") }} +) + +select + mr.call_block_time as block_time, + date_trunc('day', mr.call_block_time) as block_date, + mr.poolId as pool_id, + c.product_id, + c.cover_id, + c.cover_start_date, + c.cover_end_date, + mr.amount / 1e18 as reward_amount_expected_total, + mr.amount / c.cover_period_seconds / 1e18 as reward_amount_per_second, + mr.amount / c.cover_period_seconds * 86400.0 / 1e18 as reward_amount_per_day, + mr.call_tx_hash as tx_hash +from ( + select call_block_time, call_block_number, poolId, amount, call_trace_address, call_tx_hash + from {{ source('nexusmutual_ethereum', 'TokenController_call_mintStakingPoolNXMRewards') }} + where call_success + union all + select call_block_time, call_block_number, poolId, amount, call_trace_address, call_tx_hash + from {{ source('nexusmutual_ethereum', 'TokenController2_call_mintStakingPoolNXMRewards') }} + where call_success + union all + select call_block_time, call_block_number, poolId, amount, call_trace_address, call_tx_hash + from {{ source('nexusmutual_ethereum', 'TokenController3_call_mintStakingPoolNXMRewards') }} + where call_success + ) mr + inner join covers c on mr.call_tx_hash = c.tx_hash and mr.call_block_number = c.block_number +where mr.poolId = c.staking_pool_id + and (c.trace_address is null + or slice(mr.call_trace_address, 1, cardinality(c.trace_address)) = c.trace_address) diff --git a/sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml b/sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml index 81a219ed106..3b555631340 100644 --- a/sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml +++ b/sources/nexusmutual/ethereum/nexusmutual_ethereum_sources.yml @@ -15,6 +15,9 @@ sources: - name: TokenController_call_assignStakingPoolManager - name: TokenController2_call_assignStakingPoolManager - name: TokenController3_call_assignStakingPoolManager + - name: TokenController_call_mintStakingPoolNXMRewards + - name: TokenController2_call_mintStakingPoolNXMRewards + - name: TokenController3_call_mintStakingPoolNXMRewards - name: StakingProducts_evt_ProductUpdated - name: StakingPool_call_manager - name: StakingPool_evt_PoolFeeChanged