diff --git a/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml b/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml index b3957f89920..98c4fa76559 100644 --- a/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml +++ b/dbt_subprojects/dex/models/trades/arbitrum/_schema.yml @@ -230,6 +230,7 @@ models: version: - 2 - stableswap + - pcsx - name: balancer_v2_arbitrum_base_trades meta: diff --git a/dbt_subprojects/dex/models/trades/arbitrum/platforms/pancakeswap_v2_arbitrum_base_trades.sql b/dbt_subprojects/dex/models/trades/arbitrum/platforms/pancakeswap_v2_arbitrum_base_trades.sql index 382b85091e7..116de4d6b04 100644 --- a/dbt_subprojects/dex/models/trades/arbitrum/platforms/pancakeswap_v2_arbitrum_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/arbitrum/platforms/pancakeswap_v2_arbitrum_base_trades.sql @@ -25,7 +25,7 @@ dexs_macro AS ( }} ), -dexs AS ( +dexs_ss AS ( -- PancakeSwap v2 stableswap SELECT 'stableswap' AS version, @@ -46,8 +46,47 @@ dexs AS ( {% if is_incremental() %} WHERE {{ incremental_predicate('t.evt_block_time') }} {% endif %} +), + +transfer as ( + select * from {{ source('tokens', 'transfers') }} + where blockchain = 'arbitrum' + and block_date >= date '2024-08-01' + and tx_hash in (select evt_tx_hash from {{ source('pancakeswap_arbitrum', 'ExclusiveDutchOrderReactor_evt_Fill') }}) + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% endif %} +), + +dexs_pcsx AS ( + -- PancakeSwapX + SELECT + 'pcsx' AS version, + a.evt_block_number AS block_number, + a.evt_block_time AS block_time, + a.swapper AS taker, + a.filler AS maker, + receive.amount_raw AS token_bought_amount_raw, + send.amount_raw AS token_sold_amount_raw, + receive.contract_address AS token_bought_address, + send.contract_address AS token_sold_address, + a.contract_address AS project_contract_address, + a.evt_tx_hash AS tx_hash, + a.evt_index + + FROM {{ source('pancakeswap_arbitrum', 'ExclusiveDutchOrderReactor_evt_Fill') }} a + + LEFT JOIN transfer AS send + ON a.evt_tx_hash = send.tx_hash AND a.swapper = send."from" + + LEFT JOIN transfer AS receive + on a.evt_tx_hash = receive.tx_hash AND a.swapper = receive."to" + {% if is_incremental() %} + WHERE {{ incremental_predicate('a.evt_block_time') }} + {% endif %} ) + SELECT dexs_macro.blockchain, dexs_macro.project, @@ -70,18 +109,39 @@ UNION ALL SELECT 'arbitrum' AS blockchain, 'pancakeswap' AS project, - dexs.version, - CAST(date_trunc('month', dexs.block_time) AS date) AS block_month, - CAST(date_trunc('day', dexs.block_time) AS date) AS block_date, - dexs.block_time, - dexs.block_number, - dexs.token_bought_amount_raw, - dexs.token_sold_amount_raw, - dexs.token_bought_address, - dexs.token_sold_address, - dexs.taker, - dexs.maker, - dexs.project_contract_address, - dexs.tx_hash, - dexs.evt_index -FROM dexs + dexs_ss.version, + CAST(date_trunc('month', dexs_ss.block_time) AS date) AS block_month, + CAST(date_trunc('day', dexs_ss.block_time) AS date) AS block_date, + dexs_ss.block_time, + dexs_ss.block_number, + dexs_ss.token_bought_amount_raw, + dexs_ss.token_sold_amount_raw, + dexs_ss.token_bought_address, + dexs_ss.token_sold_address, + dexs_ss.taker, + dexs_ss.maker, + dexs_ss.project_contract_address, + dexs_ss.tx_hash, + dexs_ss.evt_index +FROM dexs_ss +UNION ALL +SELECT + 'arbitrum' AS blockchain, + 'pancakeswap' AS project, + dexs_pcsx.version, + CAST(date_trunc('month', dexs_pcsx.block_time) AS date) AS block_month, + CAST(date_trunc('day', dexs_pcsx.block_time) AS date) AS block_date, + dexs_pcsx.block_time, + dexs_pcsx.block_number, + dexs_pcsx.token_bought_amount_raw, + dexs_pcsx.token_sold_amount_raw, + dexs_pcsx.token_bought_address, + dexs_pcsx.token_sold_address, + dexs_pcsx.taker, + dexs_pcsx.maker, + dexs_pcsx.project_contract_address, + dexs_pcsx.tx_hash, + dexs_pcsx.evt_index +FROM dexs_pcsx +WHERE token_sold_amount_raw > 0 +AND token_bought_amount_raw > 0 diff --git a/dbt_subprojects/dex/seeds/trades/pancakeswap_arbitrum_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/pancakeswap_arbitrum_base_trades_seed.csv index 48122ab3011..c20a976f195 100644 --- a/dbt_subprojects/dex/seeds/trades/pancakeswap_arbitrum_base_trades_seed.csv +++ b/dbt_subprojects/dex/seeds/trades/pancakeswap_arbitrum_base_trades_seed.csv @@ -7,3 +7,6 @@ arbitrum,pancakeswap,2,2023-08-10,0x1958fe5d2b768dff806749c4d029be07fd5a0e182d4d arbitrum,pancakeswap,2,2023-08-10,0xb9cda996210e763e0edaa5489a276e96f4db35161b15b95407f95cfd4a8e2c79,10,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,0x82af49447d8a07e3bd95bd0d56f35241523fbab1,120059612,221946,125732913697032 arbitrum,pancakeswap,stableswap,2024-04-01,0x2cf8caf24b570525f082d3654ea210877f7900abb1ec86c463ae70983b6aaee5,26,0xb688ba096b7bb75d7841e47163cd12d18b36a5bf,0x0c880f6761f1af8d9aa9c466984b80dab9a8c9e8,196473076,406168916530447950398,296449467065124408277 arbitrum,pancakeswap,stableswap,2024-04-02,0xbf75e0478b82c5748c534f9f2269016bd818d0b404324cb0a03a5f12f61230cb,12,0xb688ba096b7bb75d7841e47163cd12d18b36a5bf,0x0c880f6761f1af8d9aa9c466984b80dab9a8c9e8,196871367,401013690539420465823,288005566501605715147 +arbitrum,pancakeswap,pcsx,2024-11-05,0xf4451dd2b05bac1c1e0734e06054ebe4433d5880e34f8d43f09b1eeccc27c6c5,7,0x82af49447d8a07e3bd95bd0d56f35241523fbab1,0xaf88d065e77c8cc2239327c5edb3a432268e5831,271321857,806896487382198674,2000000000 +arbitrum,pancakeswap,pcsx,2024-11-05,0x42e4d0b12f4da75dda589127573e03f1cf56526a92bd441c9311f1c4b3a1627c,24,0xaf88d065e77c8cc2239327c5edb3a432268e5831,0x82af49447d8a07e3bd95bd0d56f35241523fbab1,271324628,88451496,35878939559819662 +arbitrum,pancakeswap,pcsx,2024-11-05,0x99b2f309f7e1238dd01cf523e1859c859fe59079d106108ac98175d1d5d7a1aa,49,0xaf88d065e77c8cc2239327c5edb3a432268e5831,0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9,271327750,3895840552,3900000000 \ No newline at end of file diff --git a/sources/_sector/dex/trades/arbitrum/_sources.yml b/sources/_sector/dex/trades/arbitrum/_sources.yml index 818aa443104..fa00d46d12c 100644 --- a/sources/_sector/dex/trades/arbitrum/_sources.yml +++ b/sources/_sector/dex/trades/arbitrum/_sources.yml @@ -40,18 +40,19 @@ sources: - name: LBFactory_evt_LBPairCreated - name: trader_joe_v2_1_arbitrum - name: trader_joe_arbitrum + - name: pancakeswap_arbitrum + tables: + - name: ExclusiveDutchOrderReactor_evt_Fill - name: pancakeswap_v2_arbitrum tables: - name: PancakePair_evt_Swap - name: PancakeFactory_evt_PairCreated + - name: PancakeStableSwapTwoPool_evt_TokenExchange + - name: PancakeStableSwapFactory_evt_NewStableSwapPair - name: pancakeswap_v3_arbitrum tables: - name: PancakeV3Pool_evt_Swap - name: PancakeV3Factory_evt_PoolCreated - - name: pancakeswap_v2_arbitrum - tables: - - name: PancakeStableSwapTwoPool_evt_TokenExchange - - name: PancakeStableSwapFactory_evt_NewStableSwapPair - name: balancer_v2_arbitrum tables: - name: Vault_evt_Swap