From e093dd3b9ed65c2f330683bf9dcc4f51fe9cce81 Mon Sep 17 00:00:00 2001 From: whale_hunter <143016036+whalehunting@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:29:55 +0100 Subject: [PATCH 01/14] feat: add prophetbots solana bot trades spellbook (#7285) * feat: add prophetbots solana bot trades spellbook * fix: sum balance change * chore: fix seed --- .../_sector/dex/bot_trades/solana/_schema.yml | 22 +++ .../solana/dex_solana_bot_trades.sql | 2 + .../prophetbots_solana_bot_trades.sql | 154 ++++++++++++++++++ .../prophetbots_solana_trades_seed.csv | 21 +++ 4 files changed, 199 insertions(+) create mode 100644 dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/prophetbots_solana_bot_trades.sql create mode 100644 dbt_subprojects/solana/seeds/prophetbots/prophetbots_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 a48042380b2..34b9e61badd 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 @@ -688,3 +688,25 @@ models: - check_bot_trades_seed: seed_file: ref('tradewiz_solana_trades_seed') blockchain: solana + + - name: prophetbots_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: prophetbots + contributors: whale_hunter + config: + tags: ["solana", "dex", "prophetbots", "trades"] + description: > + ProphetBots trades on Solana + data_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('prophetbots_solana_trades_seed') + blockchain: solana 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 3a46f240904..1432bf2fbb6 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 @@ -36,6 +36,8 @@ , ref('wifbot_solana_bot_trades') , ref('autosnipe_solana_bot_trades') , ref('bitfoot_solana_bot_trades') + , ref('tradewiz_solana_bot_trades') + , ref('prophetbots_solana_bot_trades') ] %} {% for bot in solana_trading_bot %} diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/prophetbots_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/prophetbots_solana_bot_trades.sql new file mode 100644 index 00000000000..c52feb51754 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/prophetbots_solana_bot_trades.sql @@ -0,0 +1,154 @@ +{{ config( + alias = 'bot_trades', + schema = 'prophetbots_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-12-02' %} +{% set fee_receiver_1 = '55vkTc7nZoUQM92AfQG7T8bkNKD4TbWeBPRg8KjyUZre' %} -- TeamFeeWallet +{% set fee_receiver_2 = 'Hgckz7Sv8Q5grhLXxDFXGaJD6StPE7Yu8gz611nn1wKS' %} -- RevshareFeeWallet +{% set wsol_token = 'So11111111111111111111111111111111111111112' %} + +WITH + allFeePayments AS ( + SELECT + tx_id, + 'SOL' AS feeTokenType, + sum(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 = '{{fee_receiver_1}}' OR address = '{{fee_receiver_2}}') + GROUP BY tx_id + ), + 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 != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND trades.trader_id != '{{fee_receiver_2}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{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, + 'ProphetBots' 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/prophetbots/prophetbots_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/prophetbots/prophetbots_solana_trades_seed.csv new file mode 100644 index 00000000000..a197c0d8b1c --- /dev/null +++ b/dbt_subprojects/solana/seeds/prophetbots/prophetbots_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-12-05 16:53:54.000 UTC,2024-12-05,2024-12-01,ProphetBots,solana,11.381475,Buy,208793.948484,Luma,ATnB3fxu6HGjieMtQYJgK4kVVyyZVdVXFigF67pLpump,0.0475,SOL,So11111111111111111111111111111111111111112,0.599025,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Luma,4V1fmQBuj5Zy9qkr5sBqip4UXyirfzVybWgqMGf4hYgB,BxqQCDXfuUJaCw51cQmzXpfYSAt7vKSyHR1WeGtxMfBD,5KYz3YEmBxtqqHrqLvQcrSERc6XDzVntNomZSkmFGwmQ419Jo9L8DHKwxgmWdmpSMLBMhu9XC3CH4z3Bxyvdx1aJ,669,8,0,true +2024-12-05 17:07:09.000 UTC,2024-12-05,2024-12-01,ProphetBots,solana,10.77747650966,Sell,0.045045041,SOL,So11111111111111111111111111111111111111112,533.792777,,ZK6mVzkrj9uqEfyFnCwYCLaW1SJkpdevAujqrpkpump,0.5388735742599999,0.002252251,SOL,So11111111111111111111111111111111111111112,raydium,4,,26e6nfrCFsG2z2i2iePrF2bd2M9SiTKUfPhc5PjRfo85,7dCS2PCbi6xxEcd2UP4WX1vJHtkXuBCRT1PRLVkEJGqR,2VnjsoeVPSVAXpp9KatV7SxEx8apm156x7jupbDH6uMjkRU3jZqFVFsXFekXdXUCFxW1j4ABghWGVAWyz9pUWmD8,127,3,0,true +2024-12-03 16:28:35.000 UTC,2024-12-03,2024-12-01,ProphetBots,solana,10.603900000000001,Buy,134166.826871,빌리,D2HR3Hs8eyD1uj8WKpxw1qwpBchPLMUxwC6PVv3Rpump,0.0475,SOL,So11111111111111111111111111111111111111112,0.5581,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,빌리-SOL,DGY9fRjKYnbRqjyRXcHugjqhv7wScdtt2umsrbU2H3AH,FpzkRxf5DZroddaQUQDDhHuEaksAnyQ4foWEYgLorGUL,3WYyKHY9HEqZxeVDmKC3tw6UiaDNmQZmuE7riX3F1ndzBNn1HfusUBQkTZDhR1zRYYMHD1nSfBSTQop67uofZd9C,415,8,0,true +2024-12-06 15:10:45.000 UTC,2024-12-06,2024-12-01,ProphetBots,solana,11.268424999999999,Buy,129045.650649,KENTA,GupH283BAzrWbYH5WfXpm1DxrDuacDaANWjWzeKjpump,0.0475,SOL,So11111111111111111111111111111111111111112,0.593075,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-KENTA,FG7UJVJyuybqGbss85BvjVnsN8iUjyuWdz9Jn1a6ptbz,7dCS2PCbi6xxEcd2UP4WX1vJHtkXuBCRT1PRLVkEJGqR,5Nqmh81Mf55wqFt8WeiMPmLotbyvjNWCzjuxCU5gdpfuHtVetUjE3rzSi96jbeVHozRvTjtbL8k9aehyATXeH78E,1422,8,0,true +2024-12-09 17:19:41.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,2.136835,Buy,17473.63405,WOLF,EpPk97NPq4FnEAXnVgmXtfzQMkvsctc67mkhfyN8pump,0.0095,SOL,So11111111111111111111111111111111111111112,0.11246500000000001,0.0005,SOL,So11111111111111111111111111111111111111112,raydium,4,WOLF-SOL,6zWWGQWWvzTRcZTQrMf4NQJsJssVMBvQm3RvLNENdKD9,7dCS2PCbi6xxEcd2UP4WX1vJHtkXuBCRT1PRLVkEJGqR,2u12GokXffjurqYJYX4WQdnKWppBnS37LcvqrKq47Spg4TYh2ZWuso5WLKajpgcqpiEDaN2W6nRimrHZGseXhwmz,1951,9,0,true +2024-12-09 23:26:11.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,101.63727,Buy,110764.467679,LANA,EsciG7G8g8xVeg9dpy8yJCAavrWNDaykmoMERU8f4Lhv,0.4655,SOL,So11111111111111111111111111111111111111112,5.34933,0.0245,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LANA,8wont5zeLweXUNPU9ntUDb1nfA87t8THvQ9o6SSPZ5xw,BnLwsxtMBqeVSnvub5WMeys8HH51zjLAgLp6zwZsytE9,4jwVMkhhhsTo8igckryRqhF2LpQGkhzrbZyKzT2F6fvjdyHAL6BNkGNCtwhBFhNVGWFT6YZVzxhq1LGeU7CtnMct,165,9,0,true +2024-12-09 23:26:16.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,31.113449999999997,Buy,33360.555797,LANA,EsciG7G8g8xVeg9dpy8yJCAavrWNDaykmoMERU8f4Lhv,0.1425,SOL,So11111111111111111111111111111111111111112,1.63755,0.0075,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LANA,8wont5zeLweXUNPU9ntUDb1nfA87t8THvQ9o6SSPZ5xw,Dn6kWtwBVRWd7rXtCo2718rUfXUTLgoL452BvGSy6a2U,xopZtoxfufcNxRqcToE14p1M6V5C8EPAxTHW1WCCFTNeBXPPmEdPJpEgX84buqiNFxcAoXvbtFMTw6U9yLgqYpv,1980,9,0,true +2024-12-04 03:39:56.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,21.546407681999998,Sell,0.090341332,SOL,So11111111111111111111111111111111111111112,10151.01789,CHAINSAW,7nFvyQr2mwHLjBBECj3MsUxeAbP2D89p7Tx6bQtBpump,1.104251661,0.004629986,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHAINSAW,Eg4hFsUc2MwiBumykUe5dnQws37M3P3WzdGFKpQuqp5t,4Q2nw5FenKdW21hbK3n3VYHmwH7fZqnsC4wMQUyRoc35,3JAxGbnUjSRUe2T4jiDfMGmNvaZ9hFojzSexQw1Ki8NKEuPWJRJMCpMcgDfq9R3CyMwywH9JE7RcTfJDHZdA66Bt,1410,3,0,true +2024-12-04 00:56:14.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,169.404,Buy,359939.716201,ASHLEY,B2GoHwUP5zdPb7NhmvS8fVWcW7AkFE3KD3Rns12Mcpe4,0.7125,SOL,So11111111111111111111111111111111111111112,8.915999999999999,0.0375,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-ASHLEY,AFWtVR884tYLm5XXybRnNP8KZz6pavM7dcWmQUZEpwcw,DBRKwVjWGvZNKFnhuZCv6AHZohbDqBd9Am6khga6UcJA,L3N81RscW5kZqJ4HbD9YpB3tZtd3zohhgrtgykjnjv242R8EUMJTYYShe4J7uVsJ6KJBj8u5kDNeT1kzfLmAAbG,1994,9,0,true +2024-12-09 23:26:06.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,103.7115,Buy,128256.133394,LANA,EsciG7G8g8xVeg9dpy8yJCAavrWNDaykmoMERU8f4Lhv,0.475,SOL,So11111111111111111111111111111111111111112,5.458500000000001,0.025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LANA,8wont5zeLweXUNPU9ntUDb1nfA87t8THvQ9o6SSPZ5xw,Hc7ntYHQ22bxMdjhcWrBhD539u1S2CWjiQe8vvEqFbdS,5VdcNFNTEG4sf5U7hZywQGjixquR1yGaCfmuhRSUvEr3WR9fw6zA5f3V4qpTPAaK4AkBKmJtqWtj4pfsFNLwG3bs,1480,9,0,true +2024-12-04 17:41:44.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,10.831425,Buy,61992.280328,PABLO,s48HTTPaaPga5AUXaWHXUvQbo1ASmrt3ypparC1pump,0.0475,SOL,So11111111111111111111111111111111111111112,0.570075,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PABLO,EzjDsgyNcg5QGHVJABaensJ5aeRKpcqa8x9E6CAUdQzA,FZdJmNuuGBDPkd3uevTiPW5tHcMPcCGdVBuu78yCqPCy,Qz4BFs896AYCUCp9SoAebd55yaZTCah4FmP89CWpBZkT1TjrFgYj2uFzQzKxfidAhg5tEBBPiSFwn2brGp6Z2zA,1240,8,0,true +2024-12-04 17:41:35.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,10.831425,Buy,85020.722187,PABLO,s48HTTPaaPga5AUXaWHXUvQbo1ASmrt3ypparC1pump,0.0475,SOL,So11111111111111111111111111111111111111112,0.570075,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PABLO,EzjDsgyNcg5QGHVJABaensJ5aeRKpcqa8x9E6CAUdQzA,GK1dN6LKFGmS1dhYcjBnLi5zDBThdasCsQ9TwsndNwAX,593qPy9oKsywzormU8Airf7zHmPL3ZvzFMgJTPQjbTEdktatLMKU1rMft9beRQRoGKqegv7d15ccKnqhsje3LxxY,1464,8,0,true +2024-12-05 20:23:43.000 UTC,2024-12-05,2024-12-01,ProphetBots,solana,10.9611,Buy,152919.975464,CHILLKITTY,8sDdRLs9yLcjrKijAQTZTAQAyAHqw7jXsYBF9Ugipump,0.0475,SOL,So11111111111111111111111111111111111111112,0.5769,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHILLKITTY,ASR4CbtEQxegoavEVK9qb9eAbrWi5JBfffHRTQrXLrh2,7dCS2PCbi6xxEcd2UP4WX1vJHtkXuBCRT1PRLVkEJGqR,ea3qhrUjuaM4vBLxfWYjgKYbdTKNoAAHegPNNfAz7oe3fLYcwufh1vAcKmnwCyPMLT45qGyZFRur3ucnwVdiSdn,362,9,0,true +2024-12-09 16:21:24.000 UTC,2024-12-09,2024-12-01,ProphetBots,solana,53.430375,Buy,101861.130337,OCUS,F1ivEAt4ZmFhLeRs2LiLG3956TkzqF9YR23rKPMPpump,0.2375,SOL,So11111111111111111111111111111111111111112,2.812125,0.0125,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-OCUS,5FsRuKzNb5xPtUGRC7XSpS4YxeVREwXXgX8QojB2JueL,AVyFf2NNrCjf3b8comQvZ4bpPWZcgJ29pGS8UV5i6QJd,2UCrtGwkpwNQLVAtBHuyqTycki9cWYyRWqBxykUNTFmxi1FxbciNiCtkcjGJ13mEUePxGTDgSYvKA5mFq3wACWLV,369,8,0,true +2024-12-07 17:24:14.000 UTC,2024-12-07,2024-12-01,ProphetBots,solana,114.4085,Buy,180095.388017,$TEREZA,9sqa899GR5UqAusC4nikGKRiVxi2d9MsNJcKLfAKpump,0.475,SOL,So11111111111111111111111111111111111111112,6.0215000000000005,0.025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-$TEREZA,HJNjqkhhsYn27kkT1ULy6rSoVCNG4RaQ5r8VS7xfvWZE,DBRKwVjWGvZNKFnhuZCv6AHZohbDqBd9Am6khga6UcJA,5HADhaBjPjCagLjbHRnoKrGAt1d1k87zedme4idYBLJBV7wYQ491MYyVSYnUjvdFbK6kZLaZVN1EPf5soxupiMH3,1928,8,0,true +2024-12-08 13:05:41.000 UTC,2024-12-08,2024-12-01,ProphetBots,solana,2.23763,Buy,13629.95139,SKICHILL,FTE6GymYs7Q38Sjj3wu6RpAKvGyssMzM3j1wkhjUpump,0.0095,SOL,So11111111111111111111111111111111111111112,0.11777,0.0005,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SKICHILL,Hsqh3aSb9e7azfCVENW4JFPSiQ2668uY2eEYV4SyokTN,6JxrWa9ZDbrB756kTxk3iHQLY3B2p6Jm3AAcEsZUMh2w,41fxVaks6CjNgt21i9UWo9w1xT4rxD5W8Def5pjnnA3f5PDZ9YAcbnGTDNwYYe1pvYqncLAGsUWqSxTAFQsyztVR,932,8,0,true +2024-12-07 17:43:47.000 UTC,2024-12-07,2024-12-01,ProphetBots,solana,12.71012795631,Sell,0.052710687,SOL,So11111111111111111111111111111111111111112,17489.675256,$TEREZA,9sqa899GR5UqAusC4nikGKRiVxi2d9MsNJcKLfAKpump,0.66360471006,0.002752062,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-$TEREZA,HJNjqkhhsYn27kkT1ULy6rSoVCNG4RaQ5r8VS7xfvWZE,BeWmKAhLsMBzqJto1gwFza6UZbDcxFx24Drr9Lzsqiy5,3XXKYQTWoRkqHx2hGBXJpiBCUmvCzmhyXTrzZqo9LdwFVLmUomrudfo9vTKdUXfAz6tuCZoYSj5vwCxFXYC3My6i,186,3,0,true +2024-12-04 19:34:09.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,110.29499999999999,Buy,384509.740192,FranceCTO,5rLBiuBHD3hPY3Lk5NinJWgW8nXJaGwwMBtdoNvxpump,0.475,SOL,So11111111111111111111111111111111111111112,5.805,0.025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FranceCTO,AD3NnBV7YqdWfuDtHatoGj1GcVgivbzv8jHDmiNZdNWS,5FZJAxJPRLFXwT81NV7c4DkpL83dd1F3MscoAzzekJet,4efvwKH5brMVbame7Uvh35rQEBRV6W3SkyjVk9YWhSBV14NCvU6S6qXsWQnyxk2KY5KRVX6Dja13BLLW1AjwrTbY,219,9,0,true +2024-12-04 03:32:27.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,49.769169999999995,Buy,48037.908896,CHAINSAW,7nFvyQr2mwHLjBBECj3MsUxeAbP2D89p7Tx6bQtBpump,0.209,SOL,So11111111111111111111111111111111111111112,2.61943,0.011,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHAINSAW,Eg4hFsUc2MwiBumykUe5dnQws37M3P3WzdGFKpQuqp5t,wv1cUoRGjXqmnH4mMyAkLPMuUpZHUygCENG6f2KBdTx,3nwNf8SKMc7CFgEFpd3mPRvYgRxdvoQYCuyc8tHbi4HXR8XPeG1BJb8QQuhr9HYjrSmJjVsKfHpkVtZZwk54iGYM,1714,9,0,true +2024-12-04 03:32:31.000 UTC,2024-12-04,2024-12-01,ProphetBots,solana,11.311175,Buy,10419.082351,CHAINSAW,7nFvyQr2mwHLjBBECj3MsUxeAbP2D89p7Tx6bQtBpump,0.0475,SOL,So11111111111111111111111111111111111111112,0.595325,0.0025,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-CHAINSAW,Eg4hFsUc2MwiBumykUe5dnQws37M3P3WzdGFKpQuqp5t,BV3wm6iLVJtDTxC57pWLQYgCcrxnHhsaeNLWQjWVUhws,2D64xoBUAktDMyiWzJRpvW21jfhPn9pJGofAqMEPkM55Ks7XqwSH3d98yQ8N8GbPqxQPvtmcgdu19FsWmz9Rfobd,124,9,0,true From d47ed34f544f3aeff6b481e7aeb2462ac10685ba Mon Sep 17 00:00:00 2001 From: clizzard <145153355+clizzard7@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:31:28 +0100 Subject: [PATCH 02/14] add cswap solana (#7297) * add cswap solana * add correct seed * fix seeds --------- Co-authored-by: 0xRob <83790096+0xRobin@users.noreply.github.com> --- .../_sector/dex/bot_trades/solana/_schema.yml | 23 +++ .../platforms/cswap_solana_bot_trades.sql | 152 ++++++++++++++++++ .../platforms/tradewiz_solana_bot_trades.sql | 2 +- .../seeds/cswap/cswap_solana_trades_seed.csv | 21 +++ .../tradewiz/tradewiz_solana_trades_seed.csv | 40 ++--- 5 files changed, 217 insertions(+), 21 deletions(-) create mode 100644 dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/cswap_solana_bot_trades.sql create mode 100644 dbt_subprojects/solana/seeds/cswap/cswap_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 34b9e61badd..bdf23c8aba1 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 @@ -689,6 +689,29 @@ models: seed_file: ref('tradewiz_solana_trades_seed') blockchain: solana + + - name: cswap_solana_bot_trades + meta: + blockchain: solana + sector: dex + project: ChainSwap + contributors: whale_hunter + config: + tags: ["solana", "dex", "cswap", "trades"] + description: > + ChainSwap trades on Solana + data_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('cswap_solana_trades_seed') + blockchain: solana + - name: prophetbots_solana_bot_trades meta: blockchain: solana diff --git a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/cswap_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/cswap_solana_bot_trades.sql new file mode 100644 index 00000000000..22c84a1da47 --- /dev/null +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/cswap_solana_bot_trades.sql @@ -0,0 +1,152 @@ +{{ config( + alias = 'bot_trades', + schema = 'cswap', + 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-12-06' %} +{% set fee_receiver_1 = 'CSWAP5SpPcVjvpsA1H2n2HjNjMsRaPnZuX8H8bVJN5wy' %} +{% 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 = '{{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 != '{{fee_receiver_1}}' -- Exclude trades signed by FeeWallet + AND transactions.signer != '{{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, + 'ChainSwap' 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/models/_sector/dex/bot_trades/solana/platforms/tradewiz_solana_bot_trades.sql b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/tradewiz_solana_bot_trades.sql index 526385d028c..5227bed50b8 100644 --- a/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/tradewiz_solana_bot_trades.sql +++ b/dbt_subprojects/solana/models/_sector/dex/bot_trades/solana/platforms/tradewiz_solana_bot_trades.sql @@ -111,7 +111,7 @@ SELECT block_time, block_date, block_month, - 'Solgun' as bot, + 'Tradewiz' as bot, blockchain, amount_usd, type, diff --git a/dbt_subprojects/solana/seeds/cswap/cswap_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/cswap/cswap_solana_trades_seed.csv new file mode 100644 index 00000000000..012bac505d7 --- /dev/null +++ b/dbt_subprojects/solana/seeds/cswap/cswap_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-12-08 17:53:40.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,236.41,Buy,5166634.046655,RON,ArVrcEbaLhZPdvfxa4PdXBykhSUTDbKYqKfd6m5DPVvd,1,SOL,So11111111111111111111111111111111111111112,0.70923,0.003,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-RON,6w6ogSTWjpxwNvtBFgNGMyYguxdbxp13yEX2oLtozS9T,FvQ614xsLAfD8TxSszCydwhRJzGECDQBgY1oXaeWPk9P,2vmFMnKPV7SQMAPMuTX6cRsmwiRRYrk3vZAaJ4uM1A6K2T3sMsoLakb6zF6sXQW5TnMF1TYQxvesyb8rPJzSSbT3,2693,4,1,true +2024-12-08 00:56:13.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,631.0501005872401,Sell,2.638389918,SOL,So11111111111111111111111111111111111111112,101040.940582,LIMITLESS,44o1iDPGuzHxQgDrPE3HRb2WXwGLsBsY7yMttX47pump,2.04393445538,0.008545591,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LIMITLESS,14YuCFitrqHrPTzP1hP5fF1pQpnSoQNVucRnzJbYyMB7,8uciVcc4zoGmEQf1ys1ztrLMwPZiBNfGshG2BNrBjQGk,2QZ9boZwkssx1KPm1MDnNaL1pSZk8bawqShH2ACe6YmzJboaAjGFzk6ad8SSWFdb57pSqEhzQzgeEirWQDsimW8k,938,2,1,true +2024-12-09 22:47:21.000 UTC,2024-12-09,2024-12-01,ChainSwap,solana,3.4000866542,Sell,0.01588306,SOL,So11111111111111111111111111111111111111112,32.65,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,0.01081438826,0.000050518,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,DoKCDiii9JAevz8fW9PM8gagkuuHGSaAzMBsfZarNhUt,mTcDV84pRnFFu2JZJpFDjWRdDdotiEoKTu82yu6HeGZbouVy6UDkDtJetkn5JauBmmb5pi7DaMo8Bk7e888w5Nu,1771,2,1,true +2024-12-07 10:11:03.000 UTC,2024-12-07,2024-12-01,ChainSwap,solana,2.39099107707,Sell,0.010026381,SOL,So11111111111111111111111111111111111111112,827830824.8232,SHIKOKU,5Jng6jkLKU1o8BNrCzTEMXMFvPjNJZTpdWR3Hq4RHJb6,0.02362689219,0.000099077,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-SHIKOKU,FyQuZLz6LLJxKhSwXkMpZ5Po6G8bcRv8Ub2s3paU74pC,oN3T43asj7TyEViAgQaFdMmmsScScDNZ6C6V4UeuhXA,LFWJiVrsVbktPzNg2soY96n8NShX6eAae2UP8oK8Fo7BuqbCUX4hwNVfkPH9VYbrzAmBnjAQbGknCz6UvDANe8a,1826,2,1,true +2024-12-08 01:44:03.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,237.46446197876,Sell,0.994324018,SOL,So11111111111111111111111111111111111111112,2665.625316,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,0.71856949706,0.003008833,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,DkGiBk9TAUUm42rDcPWQqRstMWB4pRvN9WxuBm91WX98,5ZNNzu8kj4QFjSYXVKpTdrztYYd2UHW1dAsDtVc8g3P9Ra2fpS9nzTVthvhXcYw3NVttQ4enHcMCGJpcQd6HFYJ2,49,2,1,true +2024-12-08 13:54:49.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,134.775385344,Buy,10618804.080094,KITTY,7TgVhQwYofgkUHrKqyX6NWc4iVb2nnG87xxU3M3pump,0.568672512,SOL,So11111111111111111111111111111111111111112,0.3555,0.0015,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-KITTY,89WiiZ66AfCsEckK4YhLwxVYZhAPmDcaePkzdnXeHbBP,Ex9E6pWf8CXyUby5TubhGkxuCk7NZnLJhyD65D5qidvq,2XkLYLPszv9nWBzYbY2jepTQ4JT2bkcvpkNPSKhyAj7FTfbAoj8tLABwmRwU7ZM2PHW2vyM3o8v6hr6BboYxcSpF,1369,2,4,true +2024-12-10 23:42:51.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,642.24,Buy,2557653.017448,NORM,H4WLmYEc1Q9Fk8cbvieqiqc8ALbYA5W2bhbKdkJE2bth,3,SOL,So11111111111111111111111111111111111111112,1.92672,0.009,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-NORM,CYSLB654GfgYE1gQBe9TNbnyZB2kKFTPd5bweM5vLBGw,A9wB4BddvvsKnGM3BTJSWjhQ4ibs7piBtCXd5bdhJZVY,37Jpm6RfG9joRi9KtGKNF91rnEMHrocD128SRGaNmPkBCpVT6cwRkpDE9Yv3vhq1DbPH6sVbabn4mrr9xE8gxxEq,1747,5,1,true +2024-12-10 01:33:26.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,10770.450408761199,Sell,49.14871958,SOL,So11111111111111111111111111111111111111112,81469.171522,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,32.43617846748,0.148015782,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,88XssAnXed7S4JGS4CFbR7isBtTUbk7CWRtWEbiwCWYX,4FtUdRsx4FKj5kWJDWxsjL3vakYEcWrUUdC2UwS9rcGCyv452zqhJTPF3wBURsYeq6FiHVuBzSXsFfNZqwyoRUEk,98,2,1,true +2024-12-10 22:21:04.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,105.91416678052,Sell,0.497062919,SOL,So11111111111111111111111111111111111111112,546.471895,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,0.32020319996,0.001502737,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,BYCcoE7DoBN8e3SijRC7rhTnjeGsWPZxNJYb3pYY6EiG,3v7TwmmYUrkuETW5f7MciiP5rdQSXVnpigson5hZEgwi2ELRasKMkwowr7JnrJ1waC6hv3grfLDjgkAfJtzBEEaj,2187,2,1,true +2024-12-11 04:55:07.000 UTC,2024-12-11,2024-12-01,ChainSwap,solana,24.38229109238,Sell,0.111344831,SOL,So11111111111111111111111111111111111111112,1142698.17840853,G.O.A.T,9ko9A8Fc7yRTrYxmtQDAk36WAeLtczrsPmaf5yH1RPTS,0.07536503271999999,0.000344164,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-G.O.A.T,3dzEMpvw7MZm8vq9nKKqxnc7fCUpSqUQEAbRweZQArmR,8igyY1CBBC8VnkcXjPtdMQmfdtc1uTQ7Xsd6tiuj7bgv,ySQVVBRdFDEUYJfT6Ed2kQKNTXHy4yWrYzcPmgm5h4F3yuSHbiSyLE2BownRAe6S8NeZsDJ1AGG3Q5by2EoCpZq,1556,4,1,true +2024-12-09 22:13:27.000 UTC,2024-12-09,2024-12-01,ChainSwap,solana,542.30566942638,Buy,7730247.791584,Mario Bros,Hbdb8rSS7NdpDeuVx5NYUyR9VMKPAmo2nVim2pyDpump,2.508119829,SOL,So11111111111111111111111111111111111111112,1.29732,0.006,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Mario Bros,qc2ZDKTXxJ26EWEQKGWPJdfUP5UotNjzt7gNyQvogu5,2v7nLcvVde3fXASST46xX8u1qdcffAXXGtJLZfKD29sH,3uWWHnQSKPwtbPLBEDjdHCcUkvQa6gFvC6RQHcyEC91cMJgB9Bncr4GduNPvmJV3PW3MAA31AKJ7V94iYa359Sqf,2225,1,4,true +2024-12-08 17:03:15.000 UTC,2024-12-08,2024-12-01,ChainSwap,solana,117.94,Buy,890505.749209,Luffy,9yP5HSq8HK3aN49D8GwJoYbuFGcKnRuvQNmYxrRJpump,0.5,SOL,So11111111111111111111111111111111111111112,0.35382,0.0015,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Luffy,tz5JL88F5tvAUPJE9RbShYB8z16LcpqHL4emmJw6ten,FV3Tt7JtCQ7w6WKsbZxP5r2AN9sX7LCjZroWMJpoKjp3,4g2bQ2m8L8HpJDts6MiSs8sQdH6okXXJPCaEmNhzTj9P3UnmL2RJpx9C9v1txXfaEZGMu7RKY8zyax2VbFz4NmnH,508,5,1,true +2024-12-10 16:03:14.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,403.94903408934,Sell,1.953426346,SOL,So11111111111111111111111111111111111111112,4982686.673278,Kawaī,csdwe8ZRjbchjCWdeSZ8GSNw4XWbRzmCewzD9dUpump,1.3224425222099998,0.006395099,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-Kawaī,4VZSRvRECysU1R75kkHqeqnGzgqcBKsL9MaQ5fbgR56E,8BXTUKqo2nws3HJ5SwQHzSH6bECyP5mMyPvj2MuHJdef,8Sd4aEp14mkpVvUW5bdySG2Ee2a9K86pWjyJgw3hKTchE4H1WvjcCjVuhTihHDSGxbHREgpRTFXkmtZuK2menvC,2154,2,1,true +2024-12-07 15:50:02.000 UTC,2024-12-07,2024-12-01,ChainSwap,solana,234.91497195601,Sell,0.978771601,SOL,So11111111111111111111111111111111111111112,115245.068956,VIRGIN,2MtX583jbXXKnE4BvghsEi4ud3uQJEkJVnt7oWc3pump,0.7168522676,0.00298676,SOL,So11111111111111111111111111111111111111112,raydium,4,VIRGIN-SOL,3CLYXZAcAFBjqAfAwxeSUrpbx2ACZyfnGjZ1WvZ1utYj,88XssAnXed7S4JGS4CFbR7isBtTUbk7CWRtWEbiwCWYX,2v49qpLkXkUySc4uyGLQWWQ3TqPsTDTT7zCQLxNQdRWbWWQJEdCJoUaj6jVK4gUAtu9JwWzLv5qrjkw5yT2xx8XU,265,2,1,true +2024-12-10 00:31:19.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,213.85821178848,Sell,0.977771634,SOL,So11111111111111111111111111111111111111112,1731.008892,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,0.65331532768,0.002986994,SOL,So11111111111111111111111111111111111111112,meteora,2,SOL-GRIFFAIN,EN5ji4DsJCaLNXzkJVEX9sgsN6XMxq5ssLkCxgiDJiM9,GPqcYH2yP1w4LPpQN65mDcU5CdBbRmS4QvVAJP8Lo4x7,4DNXtgt1kp3UheG49gSQcfwSNnXuRo4jV1qXZ2azpLznwYUkwos5AH1x3EfPiMcCfguh9CnTkUL1qUzihcnMiuF9,535,2,1,true +2024-12-10 11:43:17.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,3143.608268642,Sell,14.5544158,SOL,So11111111111111111111111111111111111111112,1212813.794696,yumi,FhbqJtDE5XXk9Netjvrx5nhmnXxFRAS9eoGLwMi2pump,16.44982237489,0.076160111,SOL,So11111111111111111111111111111111111111112,meteora,2,yumi-SOL,5SeoX3xAe7F9xxDxXVLvRyRtYfSi8yaB5NakpJt7DHEL,DkGiBk9TAUUm42rDcPWQqRstMWB4pRvN9WxuBm91WX98,1NfcHQvucLuAGsfTpz1cM3UG8WPL4RCe3BCqk2AzXf6KbFpqHC6q1Ez1UQbD3ksvAQL3dKQ8MsFJyWp1KApqE3i,642,2,2,false +2024-12-10 03:05:28.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,851.474647641,Sell,3.997533557,SOL,So11111111111111111111111111111111111111112,5151.222836,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,2.585950995,0.012140615,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,BYCcoE7DoBN8e3SijRC7rhTnjeGsWPZxNJYb3pYY6EiG,3YpZyrUnMJYW28pVc6nfwVbMHXfUeD7iAgt2nJ5JmUxURT4urXGrxtsJyamkfU4cgeAgv18QPCteguiEYAxixN4d,1867,2,1,true +2024-12-10 01:05:46.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,6466.025441846759,Sell,29.630764558,SOL,So11111111111111111111111111111111111111112,49584.452082,GRIFFAIN,KENJSUYLASHUMfHyy5o4Hp2FdNqZg1AsUPhfH2kYvEP,19.09584824328,0.087507324,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GRIFFAIN,CpsMssqi3P9VMvNqxrdWVbSBCwyUHbGgNcrw7MorBq3g,DkGiBk9TAUUm42rDcPWQqRstMWB4pRvN9WxuBm91WX98,vsBxekU3cg4LGUYs4vRCSsdVzdKZUWQZEMZzr6ooXcwTVuCnoK66xjUnyb7m4zZm5DfMpPSrgEgdVAcwZ46Tq5Z,990,2,1,true +2024-12-10 18:46:45.000 UTC,2024-12-10,2024-12-01,ChainSwap,solana,220.71725077265,Sell,1.047990365,SOL,So11111111111111111111111111111111111111112,60094.458308,yumi,FhbqJtDE5XXk9Netjvrx5nhmnXxFRAS9eoGLwMi2pump,0.63149955291,0.002998431,SOL,So11111111111111111111111111111111111111112,raydium,4,yumi-SOL,EvWxeXEmTgMVXLfqcugKvCDQ5yZPGHt8iq9N6ELWKf6,Cq6FCvEqBmfsSa89377vNH1H1b7NDJmqNZMvAw74HRYS,2w59JeJdbzDfABXkmC3ZSohbEgnssKGGhXqVtpWC3FWoVGiqv752SpSeatUZTVvSSNhr8zVbyVRHYEaGpsBvD8Gv,1074,2,1,true +2024-12-09 17:28:52.000 UTC,2024-12-09,2024-12-01,ChainSwap,solana,673.83,Buy,541278.944723,POLYBOT,CXLsXyGNRznVaJRKCcv7Cne3sbxGRBy4BdQMo3Tjpump,3,SOL,So11111111111111111111111111111111111111112,2.02149,0.009,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-POLYBOT,69hWrBg3g86BmRhJ8zAZGz2zP53CyKHCaBoFvqkarqm7,DkGiBk9TAUUm42rDcPWQqRstMWB4pRvN9WxuBm91WX98,4xzRFQPbqB3wJZPNgJLpqT91gJ5a2y1Yh4HUzwzhUr2NzNM7jhZhSWWSCyWYMBoFPBzy1cRFUuPC5TX1CHZ3Rs8D,2003,4,1,true diff --git a/dbt_subprojects/solana/seeds/tradewiz/tradewiz_solana_trades_seed.csv b/dbt_subprojects/solana/seeds/tradewiz/tradewiz_solana_trades_seed.csv index 2525f27cce6..b3d981bede7 100644 --- a/dbt_subprojects/solana/seeds/tradewiz/tradewiz_solana_trades_seed.csv +++ b/dbt_subprojects/solana/seeds/tradewiz/tradewiz_solana_trades_seed.csv @@ -1,21 +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-12-03 03:41:57.000 UTC,2024-12-03,2024-12-01,Solgun,solana,5.10029703516,Buy,130284.164414,VIBE,AB4oELjeXLyeV3t3evMgq3zXrxXAJ1WdRy9qgfinH1oq,0.022402148,SOL,So11111111111111111111111111111111111111112,0.04940438999999999,0.000217,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,VIBE-SOL,AKtxTJHHtyDTBUerXQhWQSY4L8oBreBqPHkiPbkyoL3s,8dRLn2NMHsN7Fu1nxCbfQDujQ4wyPaqmnfqHyfVvBnmj,5xYqUmnvW78WSa1VL9G3H2fkRcBbaGRfr95iDTH9JWNTAheT7pnNguneMDzkge9Bqs5KTK8boRHKHPupBtW4hBL1,1139,7,4,true -2024-12-07 15:17:10.000 UTC,2024-12-07,2024-12-01,Solgun,solana,2.1149015703,Sell,0.008739985,SOL,So11111111111111111111111111111111111111112,312509.10149,CELLAI3,5q4maTRYm1ZPuFZqFzwYRJ7jAA5xkprmndJdGHUnpjwT,0.0209373195,0.000086525,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-CELLAI3,ARUgR3UzG2KCXWAXQNSHdPuuZ5Spmmm8vTENUn3UK4HU,F6coj9TDxLDw1wSFYsQMPmA2iPYhNxu17qBSEZ8vZuDm,5769zBmZrWqPGqWU9QA2LH5CrjPnJTWePmtC8bgTtciupjiLNuNaYuLS3FEkN7eThaQj57NcTc1Hz39VnkdtDgbB,2030,3,2,true -2024-12-06 19:47:39.000 UTC,2024-12-06,2024-12-01,Solgun,solana,5.72664660432,Buy,103332.858778,PAWBLEMS,4fLAZZCA3Mrbj6Wa9PkTUHfUWu3JE2RqGHvDrXiMpump,0.023872964,SOL,So11111111111111111111111111111111111111112,0.047976000000000005,0.0002,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-PAWBLEMS,kLCF7gruvuMfBLvwSL4XZQK2ENKYKm97LFuLAKkxC5b,DksfCf1U4arH6eq9KJJJtHDiYypi3gzwnxbup2266uae,szuK2Sdz9ps9Go88t1FVjFRezggBdh1RqWETVD8voF78mJm97H3pnt6EYrN9aUmYHUmGAvKfrTs46tJfC2F1GCt,1583,5,4,true -2024-12-06 11:48:01.000 UTC,2024-12-06,2024-12-01,Solgun,solana,65.36809866600001,Sell,0.279350849,SOL,So11111111111111111111111111111111111111112,371324.880761,HYPHAL,2gsxJ1fyLi3kzvjQx8Wd8y323Ptigzj9ti54grHkpump,0.658593702,0.002814503,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-HYPHAL,2YeDSYdr9mMvEtiWskGvHbt6WSZ6wHW9xGi8DuB9GjdJ,Ed1rA4YjgtJMExjQ6sjWrEEj7xaeL6f4yvT39sm8fZo8,3VN42UsvXsxqnUDiTDQaHhrWmGCwoWnfJJWyPbz7nvja5n9EZohisb7ZR4ojD3LzDG8rquC74kJY3Z3bHac6FYqh,64,4,0,true -2024-12-03 06:01:15.000 UTC,2024-12-03,2024-12-01,Solgun,solana,12.54215028618,Sell,0.055040814,SOL,So11111111111111111111111111111111111111112,434296.831722,Pooch,csrNabqJ6eKoueCiVxGWTTbN3Bri1MhwbwoCN2Wpump,0.12432632773999999,0.000545602,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Pooch,H82eA83r3Djyt1s4T6213puNzM1As8w2tCSYjgv6kjFz,66gfZJ3yVCxhRY3VvSKxTYhrW4HAUvhbVFRCRrgoATkE,3hhXSyxnoA3U1eYsY2P8EjAqen3mWBscPoPK4pudmobfENN1VKCzAHKPaBQRk4S98W9fB41tm4MgUJ1NE4F4ZjNt,413,3,2,true -2024-12-02 18:50:09.000 UTC,2024-12-02,2024-12-01,Solgun,solana,33.5145,Buy,1090000.477547,FWILL,8aMmdyEH97qmtxge5odgJE45KwwXQkaSZEjM13EDpump,0.15,SOL,So11111111111111111111111111111111111111112,0.335145,0.0015,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FWILL,5QiczEwrbzHNooa54TVkt4oe2HFHLd9u2TCJNX46TJjj,A3kLfkrESnvmZUs54BKYS48bPq4DJT11psfFC5ADMSwS,op8TBkDy4D5gr7xX4VCiC6VvEXCuYV4zo3fhHCEJMFu4Athih23wEzHw24tA1WmjQd4eZ4swA8o7Dii6fk1vC6j,181,6,0,true -2024-12-02 05:59:04.000 UTC,2024-12-02,2024-12-01,Solgun,solana,0.012848601869999999,Sell,0.000056277,SOL,So11111111111111111111111111111111111111112,58135.635755705,LIR,Agdtmev8iBbBJZjXDf6u18M51Bu173gsJTzcWB1patsJ,0.00012876684,5.64e-7,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LIR,84PapxynnSyNL7LRg4vKg41SVrmU2NqRxaudeQe1NYUb,9gxBDddAvsVUmcLAwJWhnKr5dMN8rWkdqn8ZZ4V272bo,3UBAiPDUWx2jpU4H7u3VV4LkkYXMjxUtbnK2uj71mkHb2T22iWFxvtAnjac4rwQA5itbZb9VahYM4XRbvpEEyxdr,552,4,0,true -2024-12-02 20:48:46.000 UTC,2024-12-02,2024-12-01,Solgun,solana,174.81549384187,Buy,14986480.13779,FAITH,CK3TMoqHy5ApzRwooxbxMAbpGDK2w6KpQMdv2rDhpump,0.782137237,SOL,So11111111111111111111111111111111111111112,1.6763249999999998,0.0075,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-FAITH,5PBojHVrS9C6F6kjTosfVEUoBzED8PCxpFdeouWzDQbd,2kNoYHNtpaefWZ3JptWug7H7pyzXZXYYTQufNbnt3Zzy,3gPFS1BtQArtTN2hZwbrUxKETHiHRts4YCcCEZqFxoGo9E8zpYztsjdtNsUmbK14qNT7VdieNJXbY9tBTembavCB,413,7,4,true -2024-12-02 18:06:48.000 UTC,2024-12-02,2024-12-01,Solgun,solana,30.016174407599998,Buy,1809787.710499,ART,CuSXYspmP7khJiov8Kr3XaExcuhPadVDHGm3K3rvpump,0.13517146,SOL,So11111111111111111111111111111111111111112,0.29361128496,0.001322216,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-ART,GD5CvxQZwKLfqMpvMTeLkTecnMVZGNPXnUk597W1j8hb,H9kHjTaJqVrrSuZGwJWgQnjyhVmGANpqsA6eoqbbZrTk,2SZ1av6twfq14Um3gM8KuRopdqdJpDtESqidS725tKMiDMa1zQu2wnr76JMsbXZMrH5LiUyGv9XPUqMkmwbjW4S9,2628,5,4,true -2024-12-01 23:25:30.000 UTC,2024-12-01,2024-12-01,Solgun,solana,12.139543894200001,Buy,1715893.906365,Bio AI,7LL7cbEfKLMiH4oUmfnfYgAhUnnVRWGeksE6iXjDpump,0.050942274,SOL,So11111111111111111111111111111111111111112,0.2383,0.001,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Bio AI,76BfryV9K9e9o8zF69csrqFLaar2PpdYZ8hN7ZRE4Y3e,H5PQNrAj7uKYK44ksRqym8sAfuasNC4xHJZW88WbzDyT,3YXaTrff9qmYHko2ZD5veVtAcF7XfJa8eCmFBmMtV5dLdowbCn2D2ArfkymQ2ZLon5ExhEYr5qbM54JJbE4NiZtU,475,7,4,true -2024-12-03 20:40:46.000 UTC,2024-12-03,2024-12-01,Solgun,solana,148.38664547177999,Buy,17917109.708311,WILDMNKY,75fv3J8gw9mp64ZVcAXjmr1qT8PqJjE1Cc4ocjmCpump,0.645552273,SOL,So11111111111111111111111111111111111111112,1.3791600000000002,0.006,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,WILDMNKY-SOL,7SV8yk5hXtcXNqgohc9tJMdmAbBnLpbKr8oURHdh8s8g,4Nw2v6XZJgaWHmtETqMWtQyTHaGDtQZ27x3otcvjQAHT,ep8K6Nvu25kw1yVWqENPHv2Y4mGRW5T7kMBxeXnmujd6WoDxzSfVtqASa2fz5toNTyX1JDWecAoMHxTdEsXnkxU,601,7,4,true -2024-12-03 00:15:12.000 UTC,2024-12-03,2024-12-01,Solgun,solana,5.12252529562,Sell,0.022631993,SOL,So11111111111111111111111111111111111111112,27129.461569,anthrupad,2okJ4wqqDFFD2Tce3QaU8L866KxBJzJXVoMtLR1ppump,0.052636498700000006,0.000232555,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-anthrupad,FAfDgkWFexH1BA2D1i5pc2uRR8ZYcvt8jY84CK7e9My8,31M2cNExVg8bwB2HwzAzA1w9pHwLeP67ejygZ44UB1UR,2HryhZK2dRLqZeTowRQ4Rd7BGwL9ekAgyjDuaFvYAJyyVZHn5C81cTGGc66eMRg9MhiiWEdU7j1yWKfJDjdfbMRU,499,4,0,true -2024-12-07 18:47:05.000 UTC,2024-12-07,2024-12-01,Solgun,solana,47.17441114759,Sell,0.195040357,SOL,So11111111111111111111111111111111111111112,12392.36946,AFITR,83Ur4XYc5QyRNBshoW2Yu9cCLyNDV9s5krBu11JWDxxq,0.47612907671000004,0.001968533,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-AFITR,5JtbDjPqfN6K4mDF2c5rvJZXXryQbihjViSP2XoMohSV,8uAied3jRqG1mPRzqsmLaeRDz3F22BkarmfgAvoqNWN,3Lr37rTZUVk9m1iYz3h8sg6Dt4dMHm4PhLmuPUe7G1Z3tMxraN54M8boZMP5wdXGqs8NGQPHMDaXLZoKAq1zMZLE,238,4,0,true -2024-12-01 18:04:29.000 UTC,2024-12-01,2024-12-01,Solgun,solana,32.99628642063,Buy,438388.5076,Metanoia,2dPFQnktvPKZe3hjkstWfJx8tDrH8FW9xoiBjZMEpump,0.139218963,SOL,So11111111111111111111111111111111111111112,0.2986326,0.00126,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Metanoia,FpTruBXx6UcyBiVr2Rj7UMf9tNTpJgTyGpXynpuo9HzA,GhqrMrC4tY8zTDvWHiHG7ag4MWPqQ7qLZmeochY6aosY,29TPJAT4vP7rUmMETneBknCmH8UpzdeFaB6ZpJTmzVobE6kTou8KBgqvPPLb588ettce6HRVFUPcSbuSrRJpJnzG,620,5,4,true -2024-12-01 02:27:09.000 UTC,2024-12-01,2024-12-01,Solgun,solana,19.69581542709,Sell,0.083524089,SOL,So11111111111111111111111111111111111111112,313146.63071,GSC,F86FtKmg8vnaCfDoJF7U21NbmLprVazE3L2PshmCpump,0.26366694273,0.001118133,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GSC,7H6MS1nqg9Y6NN8srD9UCovDQwVxuZaozgXrMT7kcH61,35cx6mhp2Nsi33d7QfwnqVrYoEcyWpc17PtgMrCnwfxt,5K5isZKhK8mwM4rZ7akSejvwByViNxZ5GcCMcsqWENmT42WkJ4kUoYsAJQkeq73pwiEBgjwEoUEgRNB8jCt9Bugp,541,4,0,true -2024-12-04 17:48:52.000 UTC,2024-12-04,2024-12-01,Solgun,solana,29.19816884426,Sell,0.128270302,SOL,So11111111111111111111111111111111111111112,1239313.36229,Pretty,8pTpjjcq5pG7NXDm99NinoT1vRoH99X7s3C1Go3upump,0.30598138415,0.001344205,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Pretty,HBiCDY9CVNWENM8vTkHekJoNAeaLZAJoHr7EwvmAf5WY,GhqrMrC4tY8zTDvWHiHG7ag4MWPqQ7qLZmeochY6aosY,53KrU2unKY95pnSKSq3empC6woBXPxQShDv3EmpDNnn1knesLfxHtCetCkbuNPRWPXr3tj3WKuu8B63Ypawx8yvb,977,3,2,true -2024-12-04 04:50:48.000 UTC,2024-12-04,2024-12-01,Solgun,solana,77.97821513972,Buy,1428724.561159,eigenrobot,9qpaeuNMNWwHfa7keQ51D5VJNt2jessw8khxWis5pump,0.327832402,SOL,So11111111111111111111111111111111111111112,0.7135800000000001,0.003,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-eigenrobot,7Ys5V2wmjz3LihubgfnCdSZnwEUvBNBXXLvpAWZLRiS5,5q853P8PLeYiE5PjXg24kQ9nXrf5Qn6r55A9urS4hYF6,2XPV2bKhVjYGjuLGWhxjUK69mPFqyfFYcBM6HTSnErYLxHP1cNSksWp4i3VbF7QesYJtQnPvtt5aixEbkr137nz1,959,7,4,true -2024-12-04 13:04:31.000 UTC,2024-12-04,2024-12-01,Solgun,solana,0.00010256337,Sell,4.41e-7,SOL,So11111111111111111111111111111111111111112,117382.719111186,FCI,7s9q7HcfMhhf4XoFtHUzJWyAPAN3mSEmBDfB17iM67QJ,9.3028e-7,4e-9,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FCI,8AfbS9Ji49Jj4UkZmm4whYACyUN8QQQa1dsj9JuYQjFs,EcpfuULFUmouh7XU4uESrksywAwoND2PBu7T3LJwXJmM,4N2Fw8hjiaKSBHnkc7nbH4C6TbjFtpE5RHas2uQKkJvNVUSbwUuTST6GhTueLsrMJe4ho9Sr13xm3V1QQtNzGcSf,460,4,0,true -2024-12-04 20:35:20.000 UTC,2024-12-04,2024-12-01,Solgun,solana,46.792,Buy,66517.719092,convo,KnrmAHo1wW2fGqVXcSZSpo6kmiKam5vNbDByrURpump,0.2,SOL,So11111111111111111111111111111111111111112,0.46792,0.002,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-convo,Exy58ud7t8LHN1EBnrcRRwRQmz1uSUC3hQF9oHpM1Box,5CEbKj8WbqKkah7nhYxkXGvN97xvz5hxd8fQjYnW5NTV,rNFm4bvTJvPVtqQGoBhyFBPhFbJftPVxoasZccwEhaaJqBA4GMVurr3aJTexbDm4p673RSnpTHpnmxLshHmGEK6,38,5,0,true -2024-12-06 07:59:32.000 UTC,2024-12-06,2024-12-01,Solgun,solana,47.796,Buy,8548.498569,PIZZAGUY,5cN4dWZKqxrpwCCBcwHpsAgus1s7WWyRaguR8YbRiECY,0.2,SOL,So11111111111111111111111111111111111111112,0.47796,0.002,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PIZZAGUY,FgYufZ6c7NpcMvRnbB6tYupsEoyiPCtBw9dZ3bVo8kHE,1EjTzPniAGBxzvi4TBfocfq4Zxuj2GCK42aWnNJEoSS,619fmC5opZwwwAnnci5snSqtVcp9cqPYW2SAiwq8DZQrPVS8F1cLDZW9fzwxdjBYbBKZtBTeMyA9rjeCkLU1U7uE,1700,6,0,true +2024-12-03 03:41:57.000 UTC,2024-12-03,2024-12-01,Tradewiz,solana,5.10029703516,Buy,130284.164414,VIBE,AB4oELjeXLyeV3t3evMgq3zXrxXAJ1WdRy9qgfinH1oq,0.022402148,SOL,So11111111111111111111111111111111111111112,0.04940438999999999,0.000217,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,VIBE-SOL,AKtxTJHHtyDTBUerXQhWQSY4L8oBreBqPHkiPbkyoL3s,8dRLn2NMHsN7Fu1nxCbfQDujQ4wyPaqmnfqHyfVvBnmj,5xYqUmnvW78WSa1VL9G3H2fkRcBbaGRfr95iDTH9JWNTAheT7pnNguneMDzkge9Bqs5KTK8boRHKHPupBtW4hBL1,1139,7,4,true +2024-12-07 15:17:10.000 UTC,2024-12-07,2024-12-01,Tradewiz,solana,2.1149015703,Sell,0.008739985,SOL,So11111111111111111111111111111111111111112,312509.10149,CELLAI3,5q4maTRYm1ZPuFZqFzwYRJ7jAA5xkprmndJdGHUnpjwT,0.0209373195,0.000086525,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-CELLAI3,ARUgR3UzG2KCXWAXQNSHdPuuZ5Spmmm8vTENUn3UK4HU,F6coj9TDxLDw1wSFYsQMPmA2iPYhNxu17qBSEZ8vZuDm,5769zBmZrWqPGqWU9QA2LH5CrjPnJTWePmtC8bgTtciupjiLNuNaYuLS3FEkN7eThaQj57NcTc1Hz39VnkdtDgbB,2030,3,2,true +2024-12-06 19:47:39.000 UTC,2024-12-06,2024-12-01,Tradewiz,solana,5.72664660432,Buy,103332.858778,PAWBLEMS,4fLAZZCA3Mrbj6Wa9PkTUHfUWu3JE2RqGHvDrXiMpump,0.023872964,SOL,So11111111111111111111111111111111111111112,0.047976000000000005,0.0002,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-PAWBLEMS,kLCF7gruvuMfBLvwSL4XZQK2ENKYKm97LFuLAKkxC5b,DksfCf1U4arH6eq9KJJJtHDiYypi3gzwnxbup2266uae,szuK2Sdz9ps9Go88t1FVjFRezggBdh1RqWETVD8voF78mJm97H3pnt6EYrN9aUmYHUmGAvKfrTs46tJfC2F1GCt,1583,5,4,true +2024-12-06 11:48:01.000 UTC,2024-12-06,2024-12-01,Tradewiz,solana,65.36809866600001,Sell,0.279350849,SOL,So11111111111111111111111111111111111111112,371324.880761,HYPHAL,2gsxJ1fyLi3kzvjQx8Wd8y323Ptigzj9ti54grHkpump,0.658593702,0.002814503,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-HYPHAL,2YeDSYdr9mMvEtiWskGvHbt6WSZ6wHW9xGi8DuB9GjdJ,Ed1rA4YjgtJMExjQ6sjWrEEj7xaeL6f4yvT39sm8fZo8,3VN42UsvXsxqnUDiTDQaHhrWmGCwoWnfJJWyPbz7nvja5n9EZohisb7ZR4ojD3LzDG8rquC74kJY3Z3bHac6FYqh,64,4,0,true +2024-12-03 06:01:15.000 UTC,2024-12-03,2024-12-01,Tradewiz,solana,12.54215028618,Sell,0.055040814,SOL,So11111111111111111111111111111111111111112,434296.831722,Pooch,csrNabqJ6eKoueCiVxGWTTbN3Bri1MhwbwoCN2Wpump,0.12432632773999999,0.000545602,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Pooch,H82eA83r3Djyt1s4T6213puNzM1As8w2tCSYjgv6kjFz,66gfZJ3yVCxhRY3VvSKxTYhrW4HAUvhbVFRCRrgoATkE,3hhXSyxnoA3U1eYsY2P8EjAqen3mWBscPoPK4pudmobfENN1VKCzAHKPaBQRk4S98W9fB41tm4MgUJ1NE4F4ZjNt,413,3,2,true +2024-12-02 18:50:09.000 UTC,2024-12-02,2024-12-01,Tradewiz,solana,33.5145,Buy,1090000.477547,FWILL,8aMmdyEH97qmtxge5odgJE45KwwXQkaSZEjM13EDpump,0.15,SOL,So11111111111111111111111111111111111111112,0.335145,0.0015,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FWILL,5QiczEwrbzHNooa54TVkt4oe2HFHLd9u2TCJNX46TJjj,A3kLfkrESnvmZUs54BKYS48bPq4DJT11psfFC5ADMSwS,op8TBkDy4D5gr7xX4VCiC6VvEXCuYV4zo3fhHCEJMFu4Athih23wEzHw24tA1WmjQd4eZ4swA8o7Dii6fk1vC6j,181,6,0,true +2024-12-02 05:59:04.000 UTC,2024-12-02,2024-12-01,Tradewiz,solana,0.012848601869999999,Sell,0.000056277,SOL,So11111111111111111111111111111111111111112,58135.635755705,LIR,Agdtmev8iBbBJZjXDf6u18M51Bu173gsJTzcWB1patsJ,0.00012876684,5.64e-7,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-LIR,84PapxynnSyNL7LRg4vKg41SVrmU2NqRxaudeQe1NYUb,9gxBDddAvsVUmcLAwJWhnKr5dMN8rWkdqn8ZZ4V272bo,3UBAiPDUWx2jpU4H7u3VV4LkkYXMjxUtbnK2uj71mkHb2T22iWFxvtAnjac4rwQA5itbZb9VahYM4XRbvpEEyxdr,552,4,0,true +2024-12-02 20:48:46.000 UTC,2024-12-02,2024-12-01,Tradewiz,solana,174.81549384187,Buy,14986480.13779,FAITH,CK3TMoqHy5ApzRwooxbxMAbpGDK2w6KpQMdv2rDhpump,0.782137237,SOL,So11111111111111111111111111111111111111112,1.6763249999999998,0.0075,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-FAITH,5PBojHVrS9C6F6kjTosfVEUoBzED8PCxpFdeouWzDQbd,2kNoYHNtpaefWZ3JptWug7H7pyzXZXYYTQufNbnt3Zzy,3gPFS1BtQArtTN2hZwbrUxKETHiHRts4YCcCEZqFxoGo9E8zpYztsjdtNsUmbK14qNT7VdieNJXbY9tBTembavCB,413,7,4,true +2024-12-02 18:06:48.000 UTC,2024-12-02,2024-12-01,Tradewiz,solana,30.016174407599998,Buy,1809787.710499,ART,CuSXYspmP7khJiov8Kr3XaExcuhPadVDHGm3K3rvpump,0.13517146,SOL,So11111111111111111111111111111111111111112,0.29361128496,0.001322216,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-ART,GD5CvxQZwKLfqMpvMTeLkTecnMVZGNPXnUk597W1j8hb,H9kHjTaJqVrrSuZGwJWgQnjyhVmGANpqsA6eoqbbZrTk,2SZ1av6twfq14Um3gM8KuRopdqdJpDtESqidS725tKMiDMa1zQu2wnr76JMsbXZMrH5LiUyGv9XPUqMkmwbjW4S9,2628,5,4,true +2024-12-01 23:25:30.000 UTC,2024-12-01,2024-12-01,Tradewiz,solana,12.139543894200001,Buy,1715893.906365,Bio AI,7LL7cbEfKLMiH4oUmfnfYgAhUnnVRWGeksE6iXjDpump,0.050942274,SOL,So11111111111111111111111111111111111111112,0.2383,0.001,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Bio AI,76BfryV9K9e9o8zF69csrqFLaar2PpdYZ8hN7ZRE4Y3e,H5PQNrAj7uKYK44ksRqym8sAfuasNC4xHJZW88WbzDyT,3YXaTrff9qmYHko2ZD5veVtAcF7XfJa8eCmFBmMtV5dLdowbCn2D2ArfkymQ2ZLon5ExhEYr5qbM54JJbE4NiZtU,475,7,4,true +2024-12-03 20:40:46.000 UTC,2024-12-03,2024-12-01,Tradewiz,solana,148.38664547177999,Buy,17917109.708311,WILDMNKY,75fv3J8gw9mp64ZVcAXjmr1qT8PqJjE1Cc4ocjmCpump,0.645552273,SOL,So11111111111111111111111111111111111111112,1.3791600000000002,0.006,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,WILDMNKY-SOL,7SV8yk5hXtcXNqgohc9tJMdmAbBnLpbKr8oURHdh8s8g,4Nw2v6XZJgaWHmtETqMWtQyTHaGDtQZ27x3otcvjQAHT,ep8K6Nvu25kw1yVWqENPHv2Y4mGRW5T7kMBxeXnmujd6WoDxzSfVtqASa2fz5toNTyX1JDWecAoMHxTdEsXnkxU,601,7,4,true +2024-12-03 00:15:12.000 UTC,2024-12-03,2024-12-01,Tradewiz,solana,5.12252529562,Sell,0.022631993,SOL,So11111111111111111111111111111111111111112,27129.461569,anthrupad,2okJ4wqqDFFD2Tce3QaU8L866KxBJzJXVoMtLR1ppump,0.052636498700000006,0.000232555,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-anthrupad,FAfDgkWFexH1BA2D1i5pc2uRR8ZYcvt8jY84CK7e9My8,31M2cNExVg8bwB2HwzAzA1w9pHwLeP67ejygZ44UB1UR,2HryhZK2dRLqZeTowRQ4Rd7BGwL9ekAgyjDuaFvYAJyyVZHn5C81cTGGc66eMRg9MhiiWEdU7j1yWKfJDjdfbMRU,499,4,0,true +2024-12-07 18:47:05.000 UTC,2024-12-07,2024-12-01,Tradewiz,solana,47.17441114759,Sell,0.195040357,SOL,So11111111111111111111111111111111111111112,12392.36946,AFITR,83Ur4XYc5QyRNBshoW2Yu9cCLyNDV9s5krBu11JWDxxq,0.47612907671000004,0.001968533,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-AFITR,5JtbDjPqfN6K4mDF2c5rvJZXXryQbihjViSP2XoMohSV,8uAied3jRqG1mPRzqsmLaeRDz3F22BkarmfgAvoqNWN,3Lr37rTZUVk9m1iYz3h8sg6Dt4dMHm4PhLmuPUe7G1Z3tMxraN54M8boZMP5wdXGqs8NGQPHMDaXLZoKAq1zMZLE,238,4,0,true +2024-12-01 18:04:29.000 UTC,2024-12-01,2024-12-01,Tradewiz,solana,32.99628642063,Buy,438388.5076,Metanoia,2dPFQnktvPKZe3hjkstWfJx8tDrH8FW9xoiBjZMEpump,0.139218963,SOL,So11111111111111111111111111111111111111112,0.2986326,0.00126,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Metanoia,FpTruBXx6UcyBiVr2Rj7UMf9tNTpJgTyGpXynpuo9HzA,GhqrMrC4tY8zTDvWHiHG7ag4MWPqQ7qLZmeochY6aosY,29TPJAT4vP7rUmMETneBknCmH8UpzdeFaB6ZpJTmzVobE6kTou8KBgqvPPLb588ettce6HRVFUPcSbuSrRJpJnzG,620,5,4,true +2024-12-01 02:27:09.000 UTC,2024-12-01,2024-12-01,Tradewiz,solana,19.69581542709,Sell,0.083524089,SOL,So11111111111111111111111111111111111111112,313146.63071,GSC,F86FtKmg8vnaCfDoJF7U21NbmLprVazE3L2PshmCpump,0.26366694273,0.001118133,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-GSC,7H6MS1nqg9Y6NN8srD9UCovDQwVxuZaozgXrMT7kcH61,35cx6mhp2Nsi33d7QfwnqVrYoEcyWpc17PtgMrCnwfxt,5K5isZKhK8mwM4rZ7akSejvwByViNxZ5GcCMcsqWENmT42WkJ4kUoYsAJQkeq73pwiEBgjwEoUEgRNB8jCt9Bugp,541,4,0,true +2024-12-04 17:48:52.000 UTC,2024-12-04,2024-12-01,Tradewiz,solana,29.19816884426,Sell,0.128270302,SOL,So11111111111111111111111111111111111111112,1239313.36229,Pretty,8pTpjjcq5pG7NXDm99NinoT1vRoH99X7s3C1Go3upump,0.30598138415,0.001344205,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-Pretty,HBiCDY9CVNWENM8vTkHekJoNAeaLZAJoHr7EwvmAf5WY,GhqrMrC4tY8zTDvWHiHG7ag4MWPqQ7qLZmeochY6aosY,53KrU2unKY95pnSKSq3empC6woBXPxQShDv3EmpDNnn1knesLfxHtCetCkbuNPRWPXr3tj3WKuu8B63Ypawx8yvb,977,3,2,true +2024-12-04 04:50:48.000 UTC,2024-12-04,2024-12-01,Tradewiz,solana,77.97821513972,Buy,1428724.561159,eigenrobot,9qpaeuNMNWwHfa7keQ51D5VJNt2jessw8khxWis5pump,0.327832402,SOL,So11111111111111111111111111111111111111112,0.7135800000000001,0.003,SOL,So11111111111111111111111111111111111111112,pumpdotfun,1,SOL-eigenrobot,7Ys5V2wmjz3LihubgfnCdSZnwEUvBNBXXLvpAWZLRiS5,5q853P8PLeYiE5PjXg24kQ9nXrf5Qn6r55A9urS4hYF6,2XPV2bKhVjYGjuLGWhxjUK69mPFqyfFYcBM6HTSnErYLxHP1cNSksWp4i3VbF7QesYJtQnPvtt5aixEbkr137nz1,959,7,4,true +2024-12-04 13:04:31.000 UTC,2024-12-04,2024-12-01,Tradewiz,solana,0.00010256337,Sell,4.41e-7,SOL,So11111111111111111111111111111111111111112,117382.719111186,FCI,7s9q7HcfMhhf4XoFtHUzJWyAPAN3mSEmBDfB17iM67QJ,9.3028e-7,4e-9,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-FCI,8AfbS9Ji49Jj4UkZmm4whYACyUN8QQQa1dsj9JuYQjFs,EcpfuULFUmouh7XU4uESrksywAwoND2PBu7T3LJwXJmM,4N2Fw8hjiaKSBHnkc7nbH4C6TbjFtpE5RHas2uQKkJvNVUSbwUuTST6GhTueLsrMJe4ho9Sr13xm3V1QQtNzGcSf,460,4,0,true +2024-12-04 20:35:20.000 UTC,2024-12-04,2024-12-01,Tradewiz,solana,46.792,Buy,66517.719092,convo,KnrmAHo1wW2fGqVXcSZSpo6kmiKam5vNbDByrURpump,0.2,SOL,So11111111111111111111111111111111111111112,0.46792,0.002,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-convo,Exy58ud7t8LHN1EBnrcRRwRQmz1uSUC3hQF9oHpM1Box,5CEbKj8WbqKkah7nhYxkXGvN97xvz5hxd8fQjYnW5NTV,rNFm4bvTJvPVtqQGoBhyFBPhFbJftPVxoasZccwEhaaJqBA4GMVurr3aJTexbDm4p673RSnpTHpnmxLshHmGEK6,38,5,0,true +2024-12-06 07:59:32.000 UTC,2024-12-06,2024-12-01,Tradewiz,solana,47.796,Buy,8548.498569,PIZZAGUY,5cN4dWZKqxrpwCCBcwHpsAgus1s7WWyRaguR8YbRiECY,0.2,SOL,So11111111111111111111111111111111111111112,0.47796,0.002,SOL,So11111111111111111111111111111111111111112,raydium,4,SOL-PIZZAGUY,FgYufZ6c7NpcMvRnbB6tYupsEoyiPCtBw9dZ3bVo8kHE,1EjTzPniAGBxzvi4TBfocfq4Zxuj2GCK42aWnNJEoSS,619fmC5opZwwwAnnci5snSqtVcp9cqPYW2SAiwq8DZQrPVS8F1cLDZW9fzwxdjBYbBKZtBTeMyA9rjeCkLU1U7uE,1700,6,0,true From fbbdd8ce00693d16db675610dafd7d10d7c77001 Mon Sep 17 00:00:00 2001 From: intensodefi Date: Fri, 13 Dec 2024 03:01:50 +0700 Subject: [PATCH 03/14] Add Levinswap to dex.trades (#7315) * Update dex_info.sql * Update _schema.yml * Update dex_gnosis_base_trades.sql * Create levinswap_gnosis_base_trades.sql * Update _schema.yml * Create levinswap_gnosis_base_trades_seed.csv * Update _sources.yml --------- Co-authored-by: Huang Geyang --- dbt_subprojects/dex/models/dex_info.sql | 1 + .../dex/models/trades/gnosis/_schema.yml | 16 ++++++++++++++ .../trades/gnosis/dex_gnosis_base_trades.sql | 1 + .../levinswap_gnosis_base_trades.sql | 21 +++++++++++++++++++ dbt_subprojects/dex/seeds/trades/_schema.yml | 15 +++++++++++++ .../levinswap_gnosis_base_trades_seed.csv | 2 ++ .../_sector/dex/trades/gnosis/_sources.yml | 4 ++++ 7 files changed, 60 insertions(+) create mode 100644 dbt_subprojects/dex/models/trades/gnosis/platforms/levinswap_gnosis_base_trades.sql create mode 100644 dbt_subprojects/dex/seeds/trades/levinswap_gnosis_base_trades_seed.csv diff --git a/dbt_subprojects/dex/models/dex_info.sql b/dbt_subprojects/dex/models/dex_info.sql index f5ffa82a7d7..2de3399cc3c 100644 --- a/dbt_subprojects/dex/models/dex_info.sql +++ b/dbt_subprojects/dex/models/dex_info.sql @@ -191,4 +191,5 @@ FROM (VALUES , ('akronswap', 'Akronswap', 'Direct', 'AkronFinance') , ('katana', 'Katana', 'Direct', 'AxieInfinity') , ('jetswap', 'JetSwap', 'Direct', 'Jetfuelfinance') + , ('levinswap', 'Levinswap', 'Direct', 'levinswap') ) AS temp_table (project, name, marketplace_type, x_username) diff --git a/dbt_subprojects/dex/models/trades/gnosis/_schema.yml b/dbt_subprojects/dex/models/trades/gnosis/_schema.yml index 1ac8909ff33..2dee59ac657 100644 --- a/dbt_subprojects/dex/models/trades/gnosis/_schema.yml +++ b/dbt_subprojects/dex/models/trades/gnosis/_schema.yml @@ -117,3 +117,19 @@ models: - check_dex_base_trades_seed: seed_file: ref('elk_finance_gnosis_base_trades_seed') + - name: levinswap_gnosis_base_trades + meta: + blockchain: gnosis + sector: dex + project: levinswap + contributors: intensodefi + config: + tags: ['gnosis', 'dex', 'trades', 'levinswap'] + description: "levinswap gnosis base trades" + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_dex_base_trades_seed: + seed_file: ref('levinswap_gnosis_base_trades_seed') diff --git a/dbt_subprojects/dex/models/trades/gnosis/dex_gnosis_base_trades.sql b/dbt_subprojects/dex/models/trades/gnosis/dex_gnosis_base_trades.sql index 70883d551bb..599b6cdceb4 100644 --- a/dbt_subprojects/dex/models/trades/gnosis/dex_gnosis_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/gnosis/dex_gnosis_base_trades.sql @@ -12,6 +12,7 @@ , ref('balancer_v3_gnosis_base_trades') , ref('honeyswap_v2_gnosis_base_trades') , ref('elk_finance_gnosis_base_trades') + , ref('levinswap_gnosis_base_trades') ] %} WITH base_union AS ( diff --git a/dbt_subprojects/dex/models/trades/gnosis/platforms/levinswap_gnosis_base_trades.sql b/dbt_subprojects/dex/models/trades/gnosis/platforms/levinswap_gnosis_base_trades.sql new file mode 100644 index 00000000000..48b6edd32f9 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/gnosis/platforms/levinswap_gnosis_base_trades.sql @@ -0,0 +1,21 @@ +{{ + config( + schema = 'levinswap_gnosis', + 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')] + ) +}} + +{{ + uniswap_compatible_v2_trades( + blockchain = 'gnosis', + project = 'levinswap', + version = '1', + Pair_evt_Swap = source('levinswap_gnosis', 'UniswapV2Pair_evt_Swap'), + Factory_evt_PairCreated = source('levinswap_gnosis', 'UniswapV2Factory_evt_PairCreated') + ) +}} diff --git a/dbt_subprojects/dex/seeds/trades/_schema.yml b/dbt_subprojects/dex/seeds/trades/_schema.yml index 5164c88beac..548192dab81 100644 --- a/dbt_subprojects/dex/seeds/trades/_schema.yml +++ b/dbt_subprojects/dex/seeds/trades/_schema.yml @@ -4559,3 +4559,18 @@ seeds: token_bought_amount_raw: uint256 token_sold_amount_raw: uint256 block_date: timestamp + + - name: levinswap_gnosis_base_trades_seed + config: + column_types: + blockchain: varchar + project: varchar + version: varchar + tx_hash: varbinary + evt_index: uint256 + block_number: uint256 + token_bought_address: varbinary + token_sold_address: varbinary + token_bought_amount_raw: uint256 + token_sold_amount_raw: uint256 + block_date: timestamp diff --git a/dbt_subprojects/dex/seeds/trades/levinswap_gnosis_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/levinswap_gnosis_base_trades_seed.csv new file mode 100644 index 00000000000..614606ee402 --- /dev/null +++ b/dbt_subprojects/dex/seeds/trades/levinswap_gnosis_base_trades_seed.csv @@ -0,0 +1,2 @@ +blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +gnosis,levinswap,1,2024-11-22,0x92f310ece1e89b668d91ef9993a2806e4a0d2e4bb2b2803701c05cb455cff397,8,0xc1014b2ad0a731a28c0b74890ad3c50837faa309,0xddafbb505ad214d7b80b1f830fccc89b60fb7a83,37159382,10000000000000000,508965 diff --git a/sources/_sector/dex/trades/gnosis/_sources.yml b/sources/_sector/dex/trades/gnosis/_sources.yml index 821fa073bb9..c040eebe4a1 100644 --- a/sources/_sector/dex/trades/gnosis/_sources.yml +++ b/sources/_sector/dex/trades/gnosis/_sources.yml @@ -20,3 +20,7 @@ sources: tables: - name: ElkPair_evt_Swap - name: ElkFactory_evt_PairCreated + - name: levinswap_gnosis + tables: + - name: UniswapV2Pair_evt_Swap + - name: UniswapV2Factory_evt_PairCreated From ddb63e185f018c4850c4d1892fae8538ef5e254f Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:02:02 +0000 Subject: [PATCH 04/14] add erc4626 token pricing to balancer.trades (#7301) * add erc4626 token pricing to balancer.trades * fix copypasta * add missing comma * remove extra comma * remove extra comma * fix erc4626_token_prices * fix group by * fix wrong reference --- .../ethereum/balancer_v3_ethereum_trades.sql | 26 ++++++++++++++++--- .../gnosis/balancer_v3_gnosis_trades.sql | 26 ++++++++++++++++--- .../spellbook/_sources.yml | 3 +++ 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_v3_ethereum_trades.sql b/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_v3_ethereum_trades.sql index 71d7257a356..ad927febd4c 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_v3_ethereum_trades.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/trades/ethereum/balancer_v3_ethereum_trades.sql @@ -91,6 +91,18 @@ WITH AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time) AND bpt_prices.blockchain = 'ethereum' GROUP BY 1, 2, 3, 4, 5 + ), + + erc4626_prices AS( + SELECT + minute, + wrapped_token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + LEAD(minute, 1, NOW()) OVER (PARTITION BY wrapped_token ORDER BY minute) AS time_of_next_change + FROM {{ source('balancer_v3', 'erc4626_token_prices') }} + WHERE blockchain = 'ethereum' + GROUP BY 1, 2, 3 ) SELECT @@ -110,8 +122,8 @@ SELECT dexs.token_sold_amount_raw, COALESCE( dexs.amount_usd, - dexs.token_bought_amount_raw / POWER(10, COALESCE(erc20a.decimals, 18)) * bpa_bpt_prices.bpt_price, - dexs.token_sold_amount_raw / POWER(10, COALESCE(erc20b.decimals, 18)) * bpb_bpt_prices.bpt_price + dexs.token_bought_amount_raw / POWER(10, COALESCE(erc20a.decimals, erc4626a.decimals, 18)) * COALESCE(bpa_bpt_prices.bpt_price, erc4626a.price), + dexs.token_sold_amount_raw / POWER(10, COALESCE(erc20b.decimals, erc4626b.decimals, 18)) * COALESCE(bpb_bpt_prices.bpt_price, erc4626b.price) ) AS amount_usd, dexs.token_bought_address, dexs.token_sold_address, @@ -148,4 +160,12 @@ FROM dexs LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpb_bpt_prices ON bpb_bpt_prices.contract_address = bpb.contract_address AND bpb_bpt_prices.day = bpb.bpb_max_block_date - AND bpb_bpt_prices.blockchain = 'ethereum' \ No newline at end of file + AND bpb_bpt_prices.blockchain = 'ethereum' + LEFT JOIN erc4626_prices erc4626a + ON erc4626a.wrapped_token = dexs.token_bought_address + AND erc4626a.minute <= dexs.block_time + AND dexs.block_time < erc4626a.time_of_next_change + LEFT JOIN erc4626_prices erc4626b + ON erc4626b.wrapped_token = dexs.token_sold_address + AND erc4626b.minute <= dexs.block_time + AND dexs.block_time < erc4626b.time_of_next_change \ No newline at end of file diff --git a/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_v3_gnosis_trades.sql b/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_v3_gnosis_trades.sql index 71b73f5fa60..7aea4bcc382 100644 --- a/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_v3_gnosis_trades.sql +++ b/dbt_subprojects/dex/models/_projects/balancer/trades/gnosis/balancer_v3_gnosis_trades.sql @@ -91,6 +91,18 @@ WITH AND bpt_prices.day <= DATE_TRUNC('day', dexs.block_time) AND bpt_prices.blockchain = 'gnosis' GROUP BY 1, 2, 3, 4, 5 + ), + + erc4626_prices AS( + SELECT + minute, + wrapped_token, + decimals, + APPROX_PERCENTILE(median_price, 0.5) AS price, + LEAD(minute, 1, NOW()) OVER (PARTITION BY wrapped_token ORDER BY minute) AS time_of_next_change + FROM {{ source('balancer_v3', 'erc4626_token_prices') }} + WHERE blockchain = 'gnosis' + GROUP BY 1, 2, 3 ) SELECT @@ -110,8 +122,8 @@ SELECT dexs.token_sold_amount_raw, COALESCE( dexs.amount_usd, - dexs.token_bought_amount_raw / POWER(10, COALESCE(erc20a.decimals, 18)) * bpa_bpt_prices.bpt_price, - dexs.token_sold_amount_raw / POWER(10, COALESCE(erc20b.decimals, 18)) * bpb_bpt_prices.bpt_price + dexs.token_bought_amount_raw / POWER(10, COALESCE(erc20a.decimals, erc4626a.decimals, 18)) * COALESCE(bpa_bpt_prices.bpt_price, erc4626a.price), + dexs.token_sold_amount_raw / POWER(10, COALESCE(erc20b.decimals, erc4626b.decimals, 18)) * COALESCE(bpb_bpt_prices.bpt_price, erc4626b.price) ) AS amount_usd, dexs.token_bought_address, dexs.token_sold_address, @@ -148,4 +160,12 @@ FROM dexs LEFT JOIN {{ source('balancer', 'bpt_prices') }} bpb_bpt_prices ON bpb_bpt_prices.contract_address = bpb.contract_address AND bpb_bpt_prices.day = bpb.bpb_max_block_date - AND bpb_bpt_prices.blockchain = 'gnosis' \ No newline at end of file + AND bpb_bpt_prices.blockchain = 'gnosis' + LEFT JOIN erc4626_prices erc4626a + ON erc4626a.wrapped_token = dexs.token_bought_address + AND erc4626a.minute <= dexs.block_time + AND dexs.block_time < erc4626a.time_of_next_change + LEFT JOIN erc4626_prices erc4626b + ON erc4626b.wrapped_token = dexs.token_sold_address + AND erc4626b.minute <= dexs.block_time + AND dexs.block_time < erc4626b.time_of_next_change \ No newline at end of file diff --git a/sources/_subprojects_outputs/spellbook/_sources.yml b/sources/_subprojects_outputs/spellbook/_sources.yml index 65c11b935de..9aa040b2036 100644 --- a/sources/_subprojects_outputs/spellbook/_sources.yml +++ b/sources/_subprojects_outputs/spellbook/_sources.yml @@ -116,6 +116,9 @@ sources: - name: balancer_v3_gnosis tables: - name: bpt_prices + - name: balancer_v3 + tables: + - name: erc4626_token_prices - name: addresses_ethereum tables: From 427f6748d2f84829a683df033d6acd1677f6f06a Mon Sep 17 00:00:00 2001 From: Felix Leupold Date: Thu, 12 Dec 2024 21:02:11 +0100 Subject: [PATCH 05/14] Cowprotocol/add base (#7295) * [cowprotocol] Add Base tables * add union in batches * remove comment * fix solver table reference * ad base sources * add another missing base reference * retrigger CI * fix solver query * remove batches changes --- .../models/_projects/cow_protocol/_schema.yml | 107 +++++++- .../base/cow_protocol_base_trades.sql | 257 ++++++++++++++++++ .../cow_protocol/cow_protocol_trades.sql | 30 ++ sources/_subprojects_outputs/dex/_sources.yml | 11 +- .../base/cow_protocol_base_sources.yml | 160 +++++++++++ 5 files changed, 550 insertions(+), 15 deletions(-) create mode 100644 dbt_subprojects/dex/models/_projects/cow_protocol/base/cow_protocol_base_trades.sql create mode 100644 sources/cow_protocol/base/cow_protocol_base_sources.yml diff --git a/dbt_subprojects/dex/models/_projects/cow_protocol/_schema.yml b/dbt_subprojects/dex/models/_projects/cow_protocol/_schema.yml index 958a9d028d5..9e0e203f3ef 100644 --- a/dbt_subprojects/dex/models/_projects/cow_protocol/_schema.yml +++ b/dbt_subprojects/dex/models/_projects/cow_protocol/_schema.yml @@ -8,18 +8,26 @@ models: project: cow_protocol contributors: bh2smith, gentrexha config: - tags: ['ethereum','cow_protocol','trades','dex','aggregator','cross-chain'] + tags: + [ + "ethereum", + "cow_protocol", + "trades", + "dex", + "aggregator", + "cross-chain", + ] description: > - CoW Protocol trades on all chains across all contracts and versions. - This table will load dex trades downstream. - This particular version of the protocol trades table is intended to conform - with the columns as specified in dex.trades sector. - A more detailed version of the protocol trades table can be found under `cow_protocol_ethereum.trades` + CoW Protocol trades on all chains across all contracts and versions. + This table will load dex trades downstream. + This particular version of the protocol trades table is intended to conform + with the columns as specified in dex.trades sector. + A more detailed version of the protocol trades table can be found under `cow_protocol_ethereum.trades` columns: - &blockchain name: blockchain description: "Blockchain which the project is deployed" - - &project + - &project name: project description: "Project name" - &version @@ -92,7 +100,7 @@ models: project: cow_protocol contributors: olgafetisova config: - tags: ['arbitrum','cow_protocol','trades', 'dex', 'aggregator'] + tags: ["arbitrum", "cow_protocol", "trades", "dex", "aggregator"] description: > CoW Protocol enriched trades list on Arbitrum Chain data_tests: @@ -169,7 +177,7 @@ models: project: cow_protocol contributors: bh2smith, gentrexha config: - tags: ['ethereum','cow_protocol','trades', 'dex', 'aggregator'] + tags: ["ethereum", "cow_protocol", "trades", "dex", "aggregator"] description: > CoW Protocol enriched trades list on Ethereum data_tests: @@ -253,7 +261,7 @@ models: project: cow_protocol contributors: bh2smith config: - tags: ['gnosis','cow_protocol','trades', 'dex', 'aggregator'] + tags: ["gnosis", "cow_protocol", "trades", "dex", "aggregator"] description: > CoW Protocol enriched trades list on Gnosis Chain data_tests: @@ -322,4 +330,81 @@ models: - name: flags description: "bitmap with additional trade information (cf. https://github.com/cowprotocol/contracts/blob/main/src/contracts/libraries/GPv2Trade.sol#L58-L94)" - name: surplus_usd - description: "USD value of surplus (difference between limit and executed price)" \ No newline at end of file + description: "USD value of surplus (difference between limit and executed price)" + + - name: cow_protocol_base_trades + meta: + blockchain: base + project: cow_protocol + contributors: felix + config: + tags: ["base", "cow_protocol", "trades", "dex", "aggregator"] + description: > + CoW Protocol enriched trades list on Base + data_tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - order_uid + - evt_index + columns: + - name: block_date + description: "UTC event block date of each trade" + - name: block_time + description: "Timestamp for block event time in UTC" + - name: tx_hash + description: "Transaction hash of trade" + - name: evt_index + description: "Index of the corresponding trade event" + - name: order_uid + description: "Unique identifier of order involved in trade. Note that partially fillable orders can be touched multiple times so this is not a unique ID for trade events." + - name: trader + description: "Owner of the order being traded (aka trader)" + - name: sell_token_address + description: "Ethereum address of sellToken" + - name: sell_token + description: "Symbol of sellToken" + - name: buy_token_address + description: "Ethereum address of buyToken" + - name: buy_token + description: "Symbol of buyToken" + - name: token_pair + description: "Ordered concatenation of buy/sell token symbols involved in trade" + - name: units_sold + description: "Units of sellToken sold (incorporates token decimals)." + - name: atoms_sold + description: "Amount (in atoms) of the sellToken sold" + - name: units_bought + description: "Units of buyToken bought (incorporates token decimals)." + - name: atoms_bought + description: "Amount (in atoms) of the buyToken bought" + - name: usd_value + description: "USD value of trade (taken as the max of buy value, sell value when both available, otherwise whichever is known)" + - name: buy_price + description: "USD price of buyToken at the time of trade" + - name: buy_value_usd + description: "USD value of buyToken amount" + - name: sell_price + description: "USD price of sellToken at the time of trade" + - name: sell_value_usd + description: "USD value of sellToken amount" + - name: fee + description: "Unit of fee taken (in sellToken) - incorporating token decimals" + - name: fee_atoms + description: "Amount (in atoms) of fee - taken in sellToken" + - name: fee_usd + description: "USD value of trade fee" + - name: app_data + description: "Hashed metadata related to trade event (full content available on IPFS)" + - name: receiver + description: "Recipient of trades buyToken" + - name: limit_sell_amount + description: "Sell amount side of the limit price" + - name: limit_buy_amount + description: "Buy amount side of the limit price" + - name: valid_to + description: "epoch timestamp (in seconds) until when the order was valid" + - name: flags + description: "bitmap with additional trade information (cf. https://github.com/cowprotocol/contracts/blob/main/src/contracts/libraries/GPv2Trade.sol#L58-L94)" + - name: surplus_usd + description: "USD value of surplus (difference between limit and executed price)" diff --git a/dbt_subprojects/dex/models/_projects/cow_protocol/base/cow_protocol_base_trades.sql b/dbt_subprojects/dex/models/_projects/cow_protocol/base/cow_protocol_base_trades.sql new file mode 100644 index 00000000000..449e1b0f3d5 --- /dev/null +++ b/dbt_subprojects/dex/models/_projects/cow_protocol/base/cow_protocol_base_trades.sql @@ -0,0 +1,257 @@ +{{ config( + schema='cow_protocol_base', + alias='trades', + materialized='incremental', + partition_by = ['block_month'], + unique_key = ['tx_hash', 'order_uid', 'evt_index'], + on_schema_change='sync_all_columns', + file_format ='delta', + incremental_strategy='merge', + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')], + post_hook='{{ expose_spells(\'["base"]\', + "project", + "cow_protocol", + \'["felix"]\') }}' + ) +}} + +WITH +-- First subquery joins buy and sell token prices from prices.usd. +-- Also deducts fee from sell amount. +trades_with_prices AS ( + SELECT cast(date_trunc('day', evt_block_time) as date) as block_date, + cast(date_trunc('month', evt_block_time) as date) as block_month, + evt_block_time as block_time, + evt_block_number as block_number, + evt_tx_hash as tx_hash, + evt_index, + trade.contract_address as project_contract_address, + owner as trader, + orderUid as order_uid, + sellToken as sell_token, + buyToken as buy_token, + sellAmount - feeAmount as sell_amount, + buyAmount as buy_amount, + feeAmount as fee_amount, + ps.price as sell_price, + pb.price as buy_price + FROM {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_evt_Trade') }} trade + LEFT OUTER JOIN {{ source('prices', 'usd') }} as ps + ON sellToken = ps.contract_address + AND ps.minute = date_trunc('minute', evt_block_time) + AND ps.blockchain = 'base' + {% if is_incremental() %} + AND {{ incremental_predicate('ps.minute') }} + {% endif %} + LEFT OUTER JOIN {{ source('prices', 'usd') }} as pb + ON pb.contract_address = ( + CASE + WHEN buyToken = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + THEN 0x4200000000000000000000000000000000000006 + ELSE buyToken + END) + AND pb.minute = date_trunc('minute', evt_block_time) + AND pb.blockchain = 'base' + {% if is_incremental() %} + AND {{ incremental_predicate('pb.minute') }} + {% endif %} + {% if is_incremental() %} + WHERE {{ incremental_predicate('evt_block_time') }} + {% endif %} +), +-- Second subquery gets token symbol and decimals from tokens.erc20 (to display units bought and sold) +trades_with_token_units as ( + SELECT block_date, + block_month, + block_time, + block_number, + tx_hash, + evt_index, + project_contract_address, + order_uid, + trader, + sell_token as sell_token_address, + (CASE + WHEN ts.symbol IS NULL THEN cast(sell_token as varchar) + ELSE ts.symbol + END) as sell_token, + buy_token as buy_token_address, + (CASE + WHEN tb.symbol IS NULL THEN cast(buy_token as varchar) + WHEN buy_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee THEN 'ETH' + ELSE tb.symbol + END) as buy_token, + sell_amount / pow(10, ts.decimals) as units_sold, + sell_amount as atoms_sold, + buy_amount / pow(10, tb.decimals) as units_bought, + buy_amount as atoms_bought, + -- We use sell value when possible and buy value when not + fee_amount / pow(10, ts.decimals) as fee, + fee_amount as fee_atoms, + sell_price, + buy_price + FROM trades_with_prices + LEFT OUTER JOIN {{ source('tokens', 'erc20') }} ts + ON ts.blockchain='base' AND ts.contract_address = sell_token + LEFT OUTER JOIN {{ source('tokens', 'erc20') }} tb + ON tb.blockchain='base' AND tb.contract_address = + (CASE + WHEN buy_token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + THEN 0x4200000000000000000000000000000000000006 + ELSE buy_token + END) +), +sorted_orders as ( + select + evt_tx_hash, + evt_block_number, + array_agg(orderUid order by evt_index) as order_ids + from ( + select + evt_tx_hash, + evt_index, + evt_block_number, + orderUid + from {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_evt_Trade') }} + {% if is_incremental() %} + where {{ incremental_predicate('evt_block_time') }} + {% endif %} + ) + group by evt_tx_hash, evt_block_number +), + +orders_and_trades as ( + select + evt_tx_hash, + trades, + order_ids + from sorted_orders + inner join {{ source('gnosis_protocol_v2_base', 'GPv2Settlement_call_settle') }} + on evt_block_number = call_block_number + and evt_tx_hash = call_tx_hash +), + +uid_to_app_id as ( + SELECT + distinct uid, + evt_tx_hash as hash, + from_hex(JSON_EXTRACT_SCALAR(trade, '$.appData')) AS app_data, + from_hex(JSON_EXTRACT_SCALAR(trade, '$.receiver')) AS receiver, + cast(JSON_EXTRACT_SCALAR(trade, '$.sellAmount') as uint256) AS limit_sell_amount, + cast(JSON_EXTRACT_SCALAR(trade, '$.buyAmount') as uint256) AS limit_buy_amount, + date_format( + from_unixtime(cast(JSON_EXTRACT_SCALAR(trade, '$.validTo') as double)), + '%Y-%m-%d %T' + ) AS valid_to, + cast(JSON_EXTRACT_SCALAR(trade, '$.flags') as integer) AS flags + FROM + orders_and_trades + CROSS JOIN UNNEST (order_ids) + WITH + ORDINALITY AS o (uid, i) + CROSS JOIN UNNEST (trades) + WITH + ORDINALITY AS t (trade, j) + WHERE + i = j +), + +eth_flow_senders as ( + select + sender, + bytearray_concat( + bytearray_concat( + output_orderHash, + bytearray_substring(event.contract_address, 1, 20) + ), + 0xffffffff + ) AS order_uid + from {{ source('cow_protocol_base', 'CoWSwapEthFlow_evt_OrderPlacement') }} event + inner join {{ source('cow_protocol_base', 'CoWSwapEthFlow_call_createOrder') }} call + on call_block_number = evt_block_number + and call_tx_hash = evt_tx_hash + {% if is_incremental() %} + where {{ incremental_predicate('evt_block_time') }} + {% endif %} +), + +valued_trades as ( + SELECT block_date, + block_month, + block_time, + block_number, + tx_hash, + evt_index, + ARRAY[-1] as trace_address, + project_contract_address, + trades.order_uid, + -- ETH Flow orders have trader = sender of orderCreation. + case when sender is not null then sender else trader end as trader, + sell_token_address, + case when sender is not null then 'ETH' else sell_token end as sell_token, + buy_token_address, + buy_token, + case + when lower(buy_token) > lower(sell_token) then concat(sell_token, '-', buy_token) + else concat(buy_token, '-', sell_token) + end as token_pair, + units_sold, + atoms_sold, + units_bought, + atoms_bought, + (CASE + WHEN sell_price IS NOT NULL THEN + -- Choose the larger of two prices when both not null. + CASE + WHEN buy_price IS NOT NULL and buy_price * COALESCE(units_bought,0) > sell_price * COALESCE(units_sold,0) + then buy_price * units_bought + ELSE sell_price * units_sold + END + WHEN sell_price IS NULL AND buy_price IS NOT NULL THEN buy_price * units_bought + END) as usd_value, + buy_price, + buy_price * units_bought as buy_value_usd, + sell_price, + sell_price * units_sold as sell_value_usd, + fee, + fee_atoms, + (CASE + WHEN sell_price IS NOT NULL THEN + CASE + WHEN buy_price IS NOT NULL and buy_price * COALESCE(units_bought,0) > sell_price * COALESCE(units_sold,0) + then buy_price * units_bought * fee / units_sold + ELSE sell_price * fee + END + WHEN sell_price IS NULL AND buy_price IS NOT NULL + THEN buy_price * units_bought * fee / units_sold + END) as fee_usd, + app_data, + case + when receiver = 0x0000000000000000000000000000000000000000 + then trader + else receiver + end as receiver, + limit_sell_amount, + limit_buy_amount, + valid_to, + flags, + case when (flags % 2) = 0 then 'SELL' else 'BUY' end as order_type, + bitwise_and(flags, 2) != 0 as partial_fill, + (CASE + when (flags % 2) = 0 then atoms_sold / limit_sell_amount + else atoms_bought / limit_buy_amount + end + ) as fill_proportion + FROM trades_with_token_units trades + JOIN uid_to_app_id + ON uid = trades.order_uid + AND hash=tx_hash + LEFT OUTER JOIN eth_flow_senders efs + ON trades.order_uid = efs.order_uid +) + +select *, + -- Relative surplus (in %) is the difference between limit price and executed price as a ratio of the limit price. + -- Absolute surplus (in USD) is relative surplus multiplied with the value of the trade + usd_value * (atoms_bought * limit_sell_amount - atoms_sold * limit_buy_amount) / (atoms_bought * limit_sell_amount) as surplus_usd +from valued_trades diff --git a/dbt_subprojects/dex/models/_projects/cow_protocol/cow_protocol_trades.sql b/dbt_subprojects/dex/models/_projects/cow_protocol/cow_protocol_trades.sql index aa731eafcf3..1b76dbdc8f0 100644 --- a/dbt_subprojects/dex/models/_projects/cow_protocol/cow_protocol_trades.sql +++ b/dbt_subprojects/dex/models/_projects/cow_protocol/cow_protocol_trades.sql @@ -96,4 +96,34 @@ FROM trace_address, evt_index FROM {{ ref('cow_protocol_arbitrum_trades') }} + + UNION ALL + + + SELECT + 'base' AS blockchain, + 'cow_protocol' AS project, + '1' AS version, + block_date, + block_month, + block_time, + buy_token AS token_bought_symbol, + sell_token AS token_sold_symbol, + token_pair, + units_bought AS token_bought_amount, + units_sold AS token_sold_amount, + atoms_bought AS token_bought_amount_raw, + atoms_sold AS token_sold_amount_raw, + usd_value AS amount_usd, + buy_token_address AS token_bought_address, + sell_token_address AS token_sold_address, + trader AS taker, + CAST(NULL AS VARBINARY) AS maker, + project_contract_address, + tx_hash, + trader AS tx_from, + receiver AS tx_to, + trace_address, + evt_index + FROM {{ ref('cow_protocol_base_trades') }} ) diff --git a/sources/_subprojects_outputs/dex/_sources.yml b/sources/_subprojects_outputs/dex/_sources.yml index 82f13efac55..c99a0f0dd97 100644 --- a/sources/_subprojects_outputs/dex/_sources.yml +++ b/sources/_subprojects_outputs/dex/_sources.yml @@ -62,10 +62,10 @@ sources: - name: balancer_v2_pools_optimism - name: balancer_v2_pools_polygon - name: balancer_v2_pools_zkevm - - name: balancer_cowswap_amm_pools + - name: balancer_cowswap_amm_pools - name: balancer_v3_pools_ethereum - name: balancer_v3_pools_gnosis - - name: balancer_v3_pools + - name: balancer_v3_pools - name: uniswap_v3_optimism tables: - name: ovm1_pool_mapping @@ -78,9 +78,12 @@ sources: - name: cow_protocol_arbitrum tables: - name: trades + - name: cow_protocol_base + tables: + - name: trades - name: jelly_swap tables: - - name: trades + - name: trades - name: beethoven_x tables: - - name: trades + - name: trades diff --git a/sources/cow_protocol/base/cow_protocol_base_sources.yml b/sources/cow_protocol/base/cow_protocol_base_sources.yml new file mode 100644 index 00000000000..23b8894756e --- /dev/null +++ b/sources/cow_protocol/base/cow_protocol_base_sources.yml @@ -0,0 +1,160 @@ +version: 2 + +sources: + - name: gnosis_protocol_v2_base + description: "Base Chain decoded tables related to CoW Protocol contract" + tables: + - name: GPv2AllowListAuthentication_evt_SolverAdded + description: "GPv2AllowListAuthentication list of events when a Solver was added" + columns: + - &solver + name: solver + description: "Solver wallet address" + - &contract_address + name: contract_address + description: "Base address of contract emitting the event" + - &evt_block_number + name: evt_block_number + description: "Block number which processed the unique transaction hash" + - &evt_block_time + name: evt_block_time + description: "Timestamp for block event time in UTC" + - &evt_index + name: evt_index + description: "Index of the event within transaction" + - &evt_tx_hash + name: evt_tx_hash + description: "Primary key of the transaction" + data_tests: + - not_null + - name: GPv2AllowListAuthentication_evt_SolverRemoved + description: "GPv2AllowListAuthentication list of events when a solver was removed" + columns: + - *solver + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - name: GPv2Settlement_evt_Trade + description: "Trade events emitted by GPv2Settlement" + columns: + - &feeAmount + name: feeAmount + description: "Amount (in sell token) in atoms of the trade fee" + - &buyAmount + name: buyAmount + description: "Amount (in atoms) of the buyToken bought" + - &buyToken + name: buyToken + description: "Contract address of token obtained in trade. 0xeee...ee represents native asset ETH" + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - &orderUid + name: orderUid + description: "Unique identifier of order involved in trade. Note that partially fillable orders can be touched multiple times so this is not a unique ID for trade events." + - &owner + name: owner + description: "Owner of the order being traded (aka trader address)" + - &sellAmount + name: sellAmount + description: "Amount in atoms of the sellToken sold" + - &sellToken + name: sellToken + description: "Contract address of token sold in trade." + - name: GPv2Settlement_call_settle + description: "Contains all calls to the settle method of GPv2Settlement (both successful and failed)" + columns: + - &call_block_number + name: call_block_number + description: "Block number on which the method was called" + - &call_block_time + name: call_block_time + description: "UTC timestamp at which the method was called" + - &call_success + name: call_success + description: "Whether or not the call resulted in a successful transaction" + - &call_trace_address + name: call_trace_address + description: "Trace address of the call" + - &call_tx_hash + name: call_tx_hash + description: "Transaction hash of call (if successful, will result in a real transaction hash)." + - &clearingPrices + name: clearingPrices + description: "An array of relative token prices (matched with `tokens` by index)" + - *contract_address + - &interactions + name: interactions + description: "An array of internal contract interactions" + - &tokens + name: tokens + description: "An array of token addresses (to be matched by index on `clearingPrices`)" + - &trades + name: trades + description: "An array of order data for the trades being executed" + - name: GPv2Settlement_evt_Settlement + description: "Settlement events emitted by GPv2Settlement" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - *solver + - name: GPv2Settlement_evt_Interaction + description: "Contract Interaction events emitted by GPv2Settlement" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - &selector + name: selector + description: Method ID of the contract being interacted with + - &target + name: target + description: Target contract address of the interaction + - &value + name: value + description: ETH amount (in WEI) being passed into contract interaction + - name: cow_protocol_base + description: "Base decoded tables related to CoW Protocol contract's" + tables: + - name: CoWSwapEthFlow_evt_OrderPlacement + description: "CoWSwapEthFlow Order Placement Events" + columns: + - *contract_address + - *evt_block_number + - *evt_block_time + - *evt_index + - *evt_tx_hash + - &order + name: order + description: "Contains json encoded data for an EthFlowOrder: https://github.com/cowprotocol/ethflowcontract/blob/main/src/libraries/EthFlowOrder.sol#L19-L45" + - &data + name: data + description: "Hex Encoded data containing quoteId and validTo: https://github.com/cowprotocol/ethflowcontract/blob/9c74c8ba36ff9ff3e255172b02454f831c066865/src/CoWSwapEthFlow.sol#L110-L113" + - &sender + name: sender + description: "User who placed the order" + - &signature + name: signature + description: "Onchain EIP1271 signature" + - name: CoWSwapEthFlow_call_createOrder + description: "CoWSwapEthFlow createOrder function calls with input parameters and return value" + columns: + - *call_block_number + - *call_block_time + - *call_success + - *call_trace_address + - *call_tx_hash + - *contract_address + - *order + - &output_orderHash + name: output_orderHash + description: "ETH Flow Order Hash corresponds directly to a GPv2 Order Uid by concatenation with owner = contract_address and validTo = `ffffffff`" From 9f09723151a3c52f948f2acc20101ddf85d9616c Mon Sep 17 00:00:00 2001 From: Peter <157015397+safeintern@users.noreply.github.com> Date: Fri, 13 Dec 2024 04:03:46 +0800 Subject: [PATCH 06/14] Changed activity_start_date for Ronin Safes (#7313) --- .../models/_project/safe/ronin/safe_ronin_safes.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/safe/ronin/safe_ronin_safes.sql b/dbt_subprojects/hourly_spellbook/models/_project/safe/ronin/safe_ronin_safes.sql index ac8b5622cdf..1e16b748588 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/safe/ronin/safe_ronin_safes.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/safe/ronin/safe_ronin_safes.sql @@ -16,7 +16,7 @@ ) }} -{% set project_start_date = '2024-06-30' %} +{% set project_start_date = '2021-01-01' %} select 'ronin' as blockchain, From 0d95fe07cc9dba562daff16b33a38ab31403bb37 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:04:22 +0000 Subject: [PATCH 07/14] fix next_change field on balancer_v3_erc4626_token_prices (#7303) * fix next_change field on balancer_v3_erc4626_token_prices * force run of gnosis liquidity * final * force run of gnosis liquidity * force rerun of balancer_v3_erc4626_token_prices.sql * remove unnecessary files --- .../ethereum/balancer_v3_ethereum_erc4626_token_mapping.sql | 2 +- .../ethereum/balancer_v3_ethereum_erc4626_token_prices.sql | 2 +- .../gnosis/balancer_v3_gnosis_erc4626_token_mapping.sql | 2 +- .../gnosis/balancer_v3_gnosis_erc4626_token_prices.sql | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_mapping.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_mapping.sql index dddfbb06938..5d00d403603 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_mapping.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_mapping.sql @@ -1,7 +1,7 @@ {{ config( schema = 'balancer_v3_ethereum', - alias = 'erc4626_tokens_mapping', + alias = 'erc4626_token_mapping', materialized = 'table', file_format = 'delta' ) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_prices.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_prices.sql index 99f9c1acac8..e00a572b011 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_prices.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/ethereum/balancer_v3_ethereum_erc4626_token_prices.sql @@ -60,6 +60,6 @@ SELECT underlying_token_symbol, decimals, APPROX_PERCENTILE(adjusted_price, 0.5) AS median_price, - LEAD(DATE_TRUNC('day', p.evt_block_time), 1, NOW()) OVER (PARTITION BY wrappedToken ORDER BY p.evt_block_time) AS next_change + LEAD(p.evt_block_time, 1, CURRENT_DATE + INTERVAL '1' day) OVER (PARTITION BY wrappedToken ORDER BY p.evt_block_time) AS next_change FROM price_join p GROUP BY 1, 2, 3, 4, 5, 6, 7 \ No newline at end of file diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_mapping.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_mapping.sql index 697c6133ebb..66d94189050 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_mapping.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_mapping.sql @@ -1,7 +1,7 @@ {{ config( schema = 'balancer_v3_gnosis', - alias = 'erc4626_tokens_mapping', + alias = 'erc4626_token_mapping', materialized = 'table', file_format = 'delta' ) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_prices.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_prices.sql index 9c19ed2da74..34fced964c3 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_prices.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/erc4626_tokens/gnosis/balancer_v3_gnosis_erc4626_token_prices.sql @@ -60,6 +60,6 @@ SELECT underlying_token_symbol, decimals, APPROX_PERCENTILE(adjusted_price, 0.5) AS median_price, - LEAD(DATE_TRUNC('day', p.evt_block_time), 1, NOW()) OVER (PARTITION BY wrappedToken ORDER BY p.evt_block_time) AS next_change + LEAD(p.evt_block_time, 1, CURRENT_DATE + INTERVAL '1' day) OVER (PARTITION BY wrappedToken ORDER BY p.evt_block_time) AS next_change FROM price_join p GROUP BY 1, 2, 3, 4, 5, 6, 7 \ No newline at end of file From a4018d671e2fe67c7f264c1223dafadb78d26912 Mon Sep 17 00:00:00 2001 From: hildobby Date: Thu, 12 Dec 2024 21:04:41 +0100 Subject: [PATCH 08/14] add swell (#7300) Co-authored-by: Huang Geyang --- .../models/_sector/blobs/ethereum/blobs_submitters.sql | 1 + 1 file changed, 1 insertion(+) 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 765e3e7e0c0..4542d4d8391 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 @@ -77,4 +77,5 @@ SELECT address , (0xb6cf39ee72e0127e6ea6059e38b8c197227a6ac7, 'Morph', 'MorphL2') , (0x2986bf308d0684ad77cd32ee1c60429e6573b5af, 'R0AR Chain', 'th3r0ar') , (0x2f60a5184c63ca94f82a27100643dbabe4f3f7fd, 'Unichain', 'unichain') + , (0xf854cd5b26bfd73d51236c0122798907ed65b1f2, 'Swell', 'swellnetworkio') ) AS x(address, entity, x_username) \ No newline at end of file From 4a768fedb81f330fef4c34c75b5134f2fd15753f Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:04:58 +0000 Subject: [PATCH 09/14] update balancer.token_whitelist (#7304) --- .../_project/balancer/support/balancer_token_whitelist.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbt_subprojects/hourly_spellbook/models/_project/balancer/support/balancer_token_whitelist.sql b/dbt_subprojects/hourly_spellbook/models/_project/balancer/support/balancer_token_whitelist.sql index 5727e1a0739..a063cb927cd 100644 --- a/dbt_subprojects/hourly_spellbook/models/_project/balancer/support/balancer_token_whitelist.sql +++ b/dbt_subprojects/hourly_spellbook/models/_project/balancer/support/balancer_token_whitelist.sql @@ -29,6 +29,8 @@ WITH whitelist_token as ( (0xe91d153e0b41518a2ce8dd3d7944fa863463a97d, 'WXDAI', 'gnosis'), (0x6a023ccd1ff6f2045c3309768ead9e68f978f6e1, 'WETH', 'gnosis'), (0x6c76971f98945ae98dd7d4dfca8711ebea946ea6, 'WSTETH', 'gnosis'), + (0xaf204776c7245bf4147c2612bf6e5972ee483701, 'SDAI', 'gnosis'), + (0x9c58bacc331c9aa871afd802db6379a98e80cedb, 'GNO', 'gnosis'), (0xdAC17F958D2ee523a2206206994597C13D831ec7, 'USDT', 'ethereum'), (0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, 'USDC', 'ethereum'), (0x6B175474E89094C44Da98b954EedeAC495271d0F, 'DAI', 'ethereum'), From 92948fd8dac0d3fff80b1b6d25d4a52cbcc6a8e9 Mon Sep 17 00:00:00 2001 From: viniabussafi <131974393+viniabussafi@users.noreply.github.com> Date: Thu, 12 Dec 2024 20:05:13 +0000 Subject: [PATCH 10/14] Update tokens_ethereum_erc20.sql (#7306) * Update tokens_ethereum_erc20.sql * Update tokens_ethereum_erc20.sql --- .../tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql | 4 +++- 1 file changed, 3 insertions(+), 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 141f98c1e86..56a77d10618 100644 --- a/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql +++ b/dbt_subprojects/tokens/models/tokens/ethereum/tokens_ethereum_erc20.sql @@ -4736,5 +4736,7 @@ FROM (VALUES , ( 0x358d94b5b2F147D741088803d932Acb566acB7B6, 'rSWELL', 18) , ( 0x9Ed15383940CC380fAEF0a75edacE507cC775f22, 'earnETH', 18) , ( 0x66E47E6957B85Cf62564610B76dD206BB04d831a, 'earnBTC', 8) - , (0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6, 'apxETH', 18) + , ( 0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6, 'apxETH', 18) + , ( 0xa4f6b2cdcb67bf8f48baa459a333d2667aa4b100, 'shezETH', 8) + , ( 0x7F4B66FF703336CfC35b901144614496Ae0b0D27, 'shezUSD', 18) ) AS temp_table (contract_address, symbol, decimals) From bf8b448233c1169ac2d62b22f3ce2c106f4d31c1 Mon Sep 17 00:00:00 2001 From: Phu <33654804+lequangphu@users.noreply.github.com> Date: Fri, 13 Dec 2024 03:05:43 +0700 Subject: [PATCH 11/14] Bridges of Bungee = {contract: SocketGateway, event: SocketBridge} (#7255) * 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 * Add bridges of LiFi across chains * replace tests which is deprecated * fix name error of avalanche source * add index to unique test * fix concat issue * fix unique test of the main model * try to fix unique key * use surrogate key for data tests * use generate_surrogate_key inside the models * fix and remove redundant schema properties * data_tests * move generate_surrogate_key to schema.yml * 1. create macro lifi_extract_bridge_data_macro.sql and apply it in the models 2. update the models' config 3. flip materialization strategy * data_ again * fix naming of the main model * replace avalanche with avalanche_c * avalanche_c again * 1. add block_date column to the macro to use it in the add_tx_columns macro 2. update model of avalanche_c * rename columns to use add_tx_columns macro * remove evt_ * a few minor changes * add amount_usd column * data_tests again * map native token to wrapped token to avoid null price data * update the main model and schema * move type conversion from models to macro * fix source name * varbinary type doesn't need single quotes * correct collumn name * add post_hook * feat: add bungee bridges * create macro and models for each chain * add macro for bungee bridges * chore: ignore raw.sql * add amount_usd to bungee models * remove syntax error * add bungee sources * add post hook for bungee bridges * change eth address on the chains * change the main model * remove endfor * add for loop --------- Co-authored-by: Huang Geyang Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../bungee/bungee_SocketBridge_macro.sql | 23 ++++ .../arbitrum/bungee_arbitrum_bridges.sql | 42 +++++++ .../bungee_avalanche_c_bridges.sql | 42 +++++++ .../bungee/base/bungee_base_bridges.sql | 42 +++++++ .../bungee/blast/bungee_blast_bridges.sql | 42 +++++++ .../bungee/bnb/bungee_bnb_bridges.sql | 42 +++++++ .../_projects/bungee/bungee_bridges.sql | 46 +++++++ .../ethereum/bungee_ethereum_bridges.sql | 42 +++++++ .../bungee/fantom/bungee_fantom_bridges.sql | 42 +++++++ .../bungee/gnosis/bungee_gnosis_bridges.sql | 42 +++++++ .../bungee/linea/bungee_linea_bridges.sql | 42 +++++++ .../bungee/mantle/bungee_mantle_bridges.sql | 42 +++++++ .../optimism/bungee_optimism_bridges.sql | 42 +++++++ .../bungee/polygon/bungee_polygon_bridges.sql | 42 +++++++ .../models/_projects/bungee/schema.yml | 101 +++++++++++++++ .../bungee/scroll/bungee_scroll_bridges.sql | 42 +++++++ .../bungee/zkevm/bungee_zkevm_bridges.sql | 42 +++++++ .../bungee/zksync/bungee_zksync_bridges.sql | 42 +++++++ sources/bungee/sources.yml | 116 ++++++++++++++++++ 19 files changed, 916 insertions(+) create mode 100644 dbt_subprojects/daily_spellbook/macros/project/bungee/bungee_SocketBridge_macro.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/arbitrum/bungee_arbitrum_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/avalanche_c/bungee_avalanche_c_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/base/bungee_base_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/blast/bungee_blast_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/bnb/bungee_bnb_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/bungee_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/ethereum/bungee_ethereum_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/fantom/bungee_fantom_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/gnosis/bungee_gnosis_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/linea/bungee_linea_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/mantle/bungee_mantle_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/optimism/bungee_optimism_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/polygon/bungee_polygon_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/schema.yml create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/scroll/bungee_scroll_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/zkevm/bungee_zkevm_bridges.sql create mode 100644 dbt_subprojects/daily_spellbook/models/_projects/bungee/zksync/bungee_zksync_bridges.sql create mode 100644 sources/bungee/sources.yml diff --git a/dbt_subprojects/daily_spellbook/macros/project/bungee/bungee_SocketBridge_macro.sql b/dbt_subprojects/daily_spellbook/macros/project/bungee/bungee_SocketBridge_macro.sql new file mode 100644 index 00000000000..93a0a13dbd5 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/macros/project/bungee/bungee_SocketBridge_macro.sql @@ -0,0 +1,23 @@ +{% macro bungee_SocketBridge(blockchain) %} + +select + contract_address, + evt_tx_hash, + evt_index, + evt_block_time, + evt_block_number, + amount, + token, + toChainId, + bridgeName, + sender, + receiver, + metadata, + '{{ blockchain }}' as source_chain, + {{ dbt_utils.generate_surrogate_key(['evt_tx_hash', 'evt_index']) }} as transfer_id +from {{ source('socket_v2_' ~ blockchain, 'SocketGateway_evt_SocketBridge') }} +{% if is_incremental() %} +where {{ incremental_predicate('evt_block_time') }} +{% endif %} + +{% endmacro %} diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/arbitrum/bungee_arbitrum_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/arbitrum/bungee_arbitrum_bridges.sql new file mode 100644 index 00000000000..f8ca6d45091 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/arbitrum/bungee_arbitrum_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_arbitrum', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('arbitrum') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x82af49447d8a07e3bd95bd0d56f35241523fbab1 -- WETH on Arbitrum + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'arbitrum' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/avalanche_c/bungee_avalanche_c_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/avalanche_c/bungee_avalanche_c_bridges.sql new file mode 100644 index 00000000000..ec26a230726 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/avalanche_c/bungee_avalanche_c_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_avalanche_c', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('avalanche_c') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7 -- WAVAX + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'avalanche_c' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/base/bungee_base_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/base/bungee_base_bridges.sql new file mode 100644 index 00000000000..7220bb9b57b --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/base/bungee_base_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_base', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('base') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x4200000000000000000000000000000000000006 -- WETH on Base + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'base' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/blast/bungee_blast_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/blast/bungee_blast_bridges.sql new file mode 100644 index 00000000000..b19a68e3771 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/blast/bungee_blast_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_blast', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('blast') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x4300000000000000000000000000000000000004 -- WETH on Blast + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'blast' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/bnb/bungee_bnb_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/bnb/bungee_bnb_bridges.sql new file mode 100644 index 00000000000..2feb8870be3 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/bnb/bungee_bnb_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_bnb', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('bnb') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c -- WBNB + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'bnb' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/bungee_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/bungee_bridges.sql new file mode 100644 index 00000000000..5e716870189 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/bungee_bridges.sql @@ -0,0 +1,46 @@ +{{ + config( + schema = 'bungee', + alias = 'bridges', + materialized = 'view', + post_hook = '{{ expose_spells(\'[ + "ethereum", "zkevm", "scroll", "blast", "linea", "mantle", "optimism", + "gnosis", "arbitrum", "zksync", "base", "bnb", "polygon", + "avalanche_c", "fantom" + ]\', + "project", "bungee", \'["lequangphu"]\') }}' + ) +}} + +{% set chains = [ + 'ethereum', 'zkevm', 'scroll', 'blast', 'linea', 'mantle', 'optimism', + 'gnosis', 'arbitrum', 'zksync', 'base', 'bnb', 'polygon', + 'avalanche_c', 'fantom' +] %} + +with bungee_bridges as ( + {% for chain in chains %} + select + contract_address, + evt_tx_hash, + evt_index, + evt_block_time, + evt_block_number, + amount, + token, + toChainId, + bridgeName, + sender, + receiver, + metadata, + source_chain, + transfer_id + from {{ ref( 'bungee_' ~ chain ~ '_bridges' ) }} + {% if not loop.last %} + union all + {% endif %} + {% endfor %} +) + +select * +from bungee_bridges \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/ethereum/bungee_ethereum_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/ethereum/bungee_ethereum_bridges.sql new file mode 100644 index 00000000000..31b632b2ae7 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/ethereum/bungee_ethereum_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_ethereum', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('ethereum') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2 -- WETH + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'ethereum' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/fantom/bungee_fantom_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/fantom/bungee_fantom_bridges.sql new file mode 100644 index 00000000000..bb9698e6120 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/fantom/bungee_fantom_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_fantom', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('fantom') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83 -- WFTM + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'fantom' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/gnosis/bungee_gnosis_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/gnosis/bungee_gnosis_bridges.sql new file mode 100644 index 00000000000..262891ca52a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/gnosis/bungee_gnosis_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_gnosis', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('gnosis') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xe91d153e0b41518a2ce8dd3d7944fa863463a97d -- WXDAI + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'gnosis' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/linea/bungee_linea_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/linea/bungee_linea_bridges.sql new file mode 100644 index 00000000000..4d22cc3b2ae --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/linea/bungee_linea_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_linea', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('linea') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f -- WETH on Linea + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'linea' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/mantle/bungee_mantle_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/mantle/bungee_mantle_bridges.sql new file mode 100644 index 00000000000..6f9cc1c609d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/mantle/bungee_mantle_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_mantle', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('mantle') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x78c1b0c915c4faa5fffa6cabf0219da63d7f4cb8 -- WMNT + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'mantle' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/optimism/bungee_optimism_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/optimism/bungee_optimism_bridges.sql new file mode 100644 index 00000000000..5fd6c070d90 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/optimism/bungee_optimism_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_optimism', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('optimism') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x4200000000000000000000000000000000000006 -- WETH on Optimism + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'optimism' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/polygon/bungee_polygon_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/polygon/bungee_polygon_bridges.sql new file mode 100644 index 00000000000..e93d39768ee --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/polygon/bungee_polygon_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_polygon', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('polygon') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270 -- WMATIC + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'polygon' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/schema.yml b/dbt_subprojects/daily_spellbook/models/_projects/bungee/schema.yml new file mode 100644 index 00000000000..9788cf2079a --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/schema.yml @@ -0,0 +1,101 @@ +version: 2 + +models: + - name: bungee_bridges + description: "Unified cross-chain bridges data from Bungee's Socket Bridge" + columns: &common_columns + - name: transfer_id + description: "Unique identifier for each transfer" + data_tests: + - unique + - not_null + - name: contract_address + description: "Address of the Socket Gateway contract" + - name: evt_tx_hash + description: "Transaction hash of the transfer event" + - name: evt_index + description: "Index of the event in the transaction" + - name: evt_block_time + description: "Timestamp of the block containing the transfer" + - name: evt_block_number + description: "Block number containing the transfer" + - name: amount + description: "Amount of tokens transferred" + - name: token + description: "Address of the transferred token" + - name: token_adjusted + description: "Adjusted token address (maps native token to wrapped version)" + - name: toChainId + description: "Destination chain ID" + - name: bridgeName + description: "Name of the bridge used" + - name: sender + description: "Address of the sender" + - name: receiver + description: "Address of the receiver" + - name: metadata + description: "Additional transfer metadata" + - name: source_chain + description: "Source blockchain of the transfer" + - name: amount_usd + description: "USD value of the transferred amount at the time of transfer" + + - name: bungee_ethereum_bridges + description: "Ethereum bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_zkevm_bridges + description: "zkEVM bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_scroll_bridges + description: "Scroll bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_blast_bridges + description: "Blast bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_linea_bridges + description: "Linea bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_mantle_bridges + description: "Mantle bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_optimism_bridges + description: "Optimism bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_gnosis_bridges + description: "Gnosis bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_arbitrum_bridges + description: "Arbitrum bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_zksync_bridges + description: "zkSync bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_base_bridges + description: "Base bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_bnb_bridges + description: "BNB Chain bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_polygon_bridges + description: "Polygon bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_avalanche_c_bridges + description: "Avalanche C-Chain bridges data from Bungee's Socket Bridge" + columns: *common_columns + + - name: bungee_fantom_bridges + description: "Fantom bridges data from Bungee's Socket Bridge" + columns: *common_columns \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/scroll/bungee_scroll_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/scroll/bungee_scroll_bridges.sql new file mode 100644 index 00000000000..9c3a4d3c1e3 --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/scroll/bungee_scroll_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_scroll', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('scroll') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x5300000000000000000000000000000000000004 -- WETH on Scroll + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'scroll' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/zkevm/bungee_zkevm_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/zkevm/bungee_zkevm_bridges.sql new file mode 100644 index 00000000000..2759ebb201d --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/zkevm/bungee_zkevm_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_zkevm', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('zkevm') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9 -- WETH on zkEVM + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'zkevm' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/dbt_subprojects/daily_spellbook/models/_projects/bungee/zksync/bungee_zksync_bridges.sql b/dbt_subprojects/daily_spellbook/models/_projects/bungee/zksync/bungee_zksync_bridges.sql new file mode 100644 index 00000000000..367a8cefcba --- /dev/null +++ b/dbt_subprojects/daily_spellbook/models/_projects/bungee/zksync/bungee_zksync_bridges.sql @@ -0,0 +1,42 @@ +{{ + config( + schema = 'bungee_zksync', + alias = 'bridges', + materialized = 'incremental', + file_format = 'delta', + incremental_strategy = 'merge', + unique_key = ['transfer_id'], + incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.evt_block_time')] + ) +}} + +with source_data as ( + {{ bungee_SocketBridge('zksync') }} +), + +tokens_mapped as ( + select + *, + case + when token = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee + then 0x5aea5775959fbc2557cc8789bc1bf90a239d9a91 -- WETH on zkSync + else token + end as token_adjusted + from source_data +), + +price_data as ( + select + tokens_mapped.*, + p.price * amount / power(10, p.decimals) as amount_usd + from tokens_mapped + left join {{ source('prices', 'usd') }} p + on p.contract_address = tokens_mapped.token_adjusted + and p.blockchain = 'zksync' + and p.minute = date_trunc('minute', tokens_mapped.evt_block_time) + {% if is_incremental() %} + and {{ incremental_predicate('p.minute') }} + {% endif %} +) + +select * from price_data \ No newline at end of file diff --git a/sources/bungee/sources.yml b/sources/bungee/sources.yml new file mode 100644 index 00000000000..c98f528f436 --- /dev/null +++ b/sources/bungee/sources.yml @@ -0,0 +1,116 @@ +version: 2 + +sources: + - name: socket_v2_ethereum + description: "Ethereum Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: &common_columns + - name: contract_address + description: "Contract address of the Socket Gateway" + - name: evt_tx_hash + description: "Transaction hash of the event" + - name: evt_index + description: "Event index in the transaction" + - name: evt_block_time + description: "Timestamp of the block when the event was emitted" + - name: evt_block_number + description: "Block number when the event was emitted" + - name: amount + description: "Amount of tokens being bridged" + - name: token + description: "Address of the token being bridged" + - name: toChainId + description: "Destination chain ID" + - name: bridgeName + description: "Name of the bridge used" + - name: sender + description: "Address of the sender" + - name: receiver + description: "Address of the receiver" + - name: metadata + description: "Additional bridge metadata" + + - name: socket_v2_arbitrum + description: "Arbitrum Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_optimism + description: "Optimism Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_avalanche_c + description: "Avalanche C-Chain Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_bnb + description: "BNB Chain Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_polygon + description: "Polygon Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_fantom + description: "Fantom Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_gnosis + description: "Gnosis Chain Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_zksync + description: "zkSync Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_base + description: "Base Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_zkevm + description: "zkEVM Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_scroll + description: "Scroll Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_linea + description: "Linea Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_mantle + description: "Mantle Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns + + - name: socket_v2_blast + description: "Blast Socket Gateway events" + tables: + - name: SocketGateway_evt_SocketBridge + columns: *common_columns \ No newline at end of file From 5ea5c4c3d3d2b69f5ecce4beced1f1dc9454ca3b Mon Sep 17 00:00:00 2001 From: Peter <49856481+peterrliem@users.noreply.github.com> Date: Fri, 13 Dec 2024 04:06:16 +0800 Subject: [PATCH 12/14] Create NFT Ronin Transfers (#7136) * Create nft_ronin_transfers table * Update nft_transfers.sql Added Ronin * Rename nft_ronin_transfers to nft_ronin_transfers.sql * Update _schema.yml --------- Co-authored-by: 0xRob <83790096+0xRobin@users.noreply.github.com> --- .../nft/models/_sector/transfers/_schema.yml | 22 +++++++++++++++++ .../transfers/chains/nft_ronin_transfers.sql | 24 +++++++++++++++++++ .../_sector/transfers/nft_transfers.sql | 3 ++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 dbt_subprojects/nft/models/_sector/transfers/chains/nft_ronin_transfers.sql diff --git a/dbt_subprojects/nft/models/_sector/transfers/_schema.yml b/dbt_subprojects/nft/models/_sector/transfers/_schema.yml index e28d91c834d..1c470216126 100644 --- a/dbt_subprojects/nft/models/_sector/transfers/_schema.yml +++ b/dbt_subprojects/nft/models/_sector/transfers/_schema.yml @@ -471,3 +471,25 @@ models: - *token_standard - *transfer_type - *unique_transfer_id + + - name: nft_ronin_transfers + meta: + blockchain: ronin + sector: nft + contributors: petertherock + config: + tags: [ 'nft', 'transfers' ] + description: > + NFT transfers + data_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_ronin_transfers.sql b/dbt_subprojects/nft/models/_sector/transfers/chains/nft_ronin_transfers.sql new file mode 100644 index 00000000000..6bd78b2fd49 --- /dev/null +++ b/dbt_subprojects/nft/models/_sector/transfers/chains/nft_ronin_transfers.sql @@ -0,0 +1,24 @@ +{{ + config( + schema="nft_ronin", + 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="ronin", + base_transactions=source("ronin", "transactions"), + erc721_transfers=source("erc721_ronin", "evt_transfer"), + erc1155_single=source("erc1155_ronin", "evt_transfersingle"), + erc1155_batch=source("erc1155_ronin", "evt_transferbatch"), + ) +}} diff --git a/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql b/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql index 721069b7ae1..7f4ffc9fd75 100644 --- a/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql +++ b/dbt_subprojects/nft/models/_sector/transfers/nft_transfers.sql @@ -8,7 +8,7 @@ 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", "zora", "scroll", "linea", "blast", "mantle"]\', + post_hook='{{ expose_spells(\'["ethereum", "bnb", "avalanche_c", "gnosis", "optimism", "arbitrum", "polygon", "fantom", "goerli", "base", "celo", "zksync", "zora", "scroll", "linea", "blast", "mantle", "sei", "ronin"]\', "sector", "nft", \'["hildobby", "0xRob", "rantum","petertherock"]\') }}' @@ -34,6 +34,7 @@ ,ref('nft_blast_transfers') ,ref('nft_mantle_transfers') ,ref('nft_sei_transfers') +,ref('nft_ronin_transfers') ] %} SELECT * From 5db57d23b933c811c16ea713d8ae0ee13a3be7f2 Mon Sep 17 00:00:00 2001 From: 0xRob <83790096+0xRobin@users.noreply.github.com> Date: Fri, 13 Dec 2024 09:50:43 +0100 Subject: [PATCH 13/14] add flag (#7327) --- dbt_subprojects/daily_spellbook/README.md | 2 +- dbt_subprojects/dex/README.md | 2 +- dbt_subprojects/tokens/dbt_project.yml | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dbt_subprojects/daily_spellbook/README.md b/dbt_subprojects/daily_spellbook/README.md index be76883e83d..284f462bfd6 100644 --- a/dbt_subprojects/daily_spellbook/README.md +++ b/dbt_subprojects/daily_spellbook/README.md @@ -1,3 +1,3 @@ ## Daily Spellbook -This is a DBT sub project for the the main models of Spellbook that runs on a daily candence. \ No newline at end of file +This is a DBT sub project for the the main models of Spellbook that runs on a daily candence. diff --git a/dbt_subprojects/dex/README.md b/dbt_subprojects/dex/README.md index 8aef6e6c3ac..f27f945ea18 100644 --- a/dbt_subprojects/dex/README.md +++ b/dbt_subprojects/dex/README.md @@ -8,4 +8,4 @@ This is a DBT subproject for the main lineages of the DEX sector. Included in th - `dex.sandwiched` - ...and more! -This subproject will be dedicated to building the above spells (and others in the future related to DEX) on an hourly cadence in production. All other spells not included within this subproject will treat these spells as sources. For example, labels spells which read from `dex.trades` will now treat the spell as a source, rather than reference within dbt. \ No newline at end of file +This subproject will be dedicated to building the above spells (and others in the future related to DEX) on an hourly cadence in production. All other spells not included within this subproject will treat these spells as sources. For example, labels spells which read from `dex.trades` will now treat the spell as a source, rather than reference within dbt. diff --git a/dbt_subprojects/tokens/dbt_project.yml b/dbt_subprojects/tokens/dbt_project.yml index 9ec35c4c768..4ab163deb41 100644 --- a/dbt_subprojects/tokens/dbt_project.yml +++ b/dbt_subprojects/tokens/dbt_project.yml @@ -14,6 +14,9 @@ quoting: # profile: "spellbook-poc-tokens" profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" From 4774a181eeeeba30234dcea053c1c3bbd56ec1d0 Mon Sep 17 00:00:00 2001 From: 0xRob <83790096+0xRobin@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:09:25 +0100 Subject: [PATCH 14/14] add require_certificate_validation flags (#7328) --- dbt_subprojects/daily_spellbook/dbt_project.yml | 3 +++ dbt_subprojects/dex/dbt_project.yml | 3 +++ dbt_subprojects/hourly_spellbook/dbt_project.yml | 3 +++ dbt_subprojects/nft/dbt_project.yml | 3 +++ dbt_subprojects/solana/dbt_project.yml | 3 +++ 5 files changed, 15 insertions(+) diff --git a/dbt_subprojects/daily_spellbook/dbt_project.yml b/dbt_subprojects/daily_spellbook/dbt_project.yml index 6b78c227a00..3de0a51a609 100644 --- a/dbt_subprojects/daily_spellbook/dbt_project.yml +++ b/dbt_subprojects/daily_spellbook/dbt_project.yml @@ -14,6 +14,9 @@ quoting: # profile: "spellbook-poc-tokens" profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '3') }}" diff --git a/dbt_subprojects/dex/dbt_project.yml b/dbt_subprojects/dex/dbt_project.yml index e7ae73c9424..5e25bae64bd 100644 --- a/dbt_subprojects/dex/dbt_project.yml +++ b/dbt_subprojects/dex/dbt_project.yml @@ -13,6 +13,9 @@ quoting: # This setting configures which "profile" dbt uses for this project. profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" diff --git a/dbt_subprojects/hourly_spellbook/dbt_project.yml b/dbt_subprojects/hourly_spellbook/dbt_project.yml index 401361c36c8..ce172a90410 100644 --- a/dbt_subprojects/hourly_spellbook/dbt_project.yml +++ b/dbt_subprojects/hourly_spellbook/dbt_project.yml @@ -14,6 +14,9 @@ quoting: # profile: "spellbook-poc-tokens" profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" diff --git a/dbt_subprojects/nft/dbt_project.yml b/dbt_subprojects/nft/dbt_project.yml index f26a684eeb9..7fd0b4eb5c3 100644 --- a/dbt_subprojects/nft/dbt_project.yml +++ b/dbt_subprojects/nft/dbt_project.yml @@ -14,6 +14,9 @@ quoting: # profile: "spellbook-poc-tokens" profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}" diff --git a/dbt_subprojects/solana/dbt_project.yml b/dbt_subprojects/solana/dbt_project.yml index ed3a13af12f..9daa19b0fee 100644 --- a/dbt_subprojects/solana/dbt_project.yml +++ b/dbt_subprojects/solana/dbt_project.yml @@ -13,6 +13,9 @@ quoting: # This setting configures which "profile" dbt uses for this project. profile: "spellbook-local" +flags: + require_certificate_validation: true + vars: DBT_ENV_CUSTOM_ENV_S3_BUCKET: "{{ env_var('DBT_ENV_CUSTOM_ENV_S3_BUCKET', 'local') }}" DBT_ENV_INCREMENTAL_TIME: "{{ env_var('DBT_ENV_INCREMENTAL_TIME', '1') }}"