From bc8e098e747238fbbf583e3d4df624997df3610d Mon Sep 17 00:00:00 2001 From: "butterbeer@pancakeswap.com" Date: Tue, 4 Nov 2025 16:18:02 +0800 Subject: [PATCH 1/2] Addded pcs bnb pcsx --- .../dex/models/trades/bnb/_schema.yml | 5 +- .../pancakeswap_v2_bnb_base_trades.sql | 67 +++++++++++++++++++ .../pancakeswap_bnb_base_trades_seed.csv | 3 + sources/_sector/dex/trades/bnb/_sources.yml | 5 +- 4 files changed, 77 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/dex/models/trades/bnb/_schema.yml b/dbt_subprojects/dex/models/trades/bnb/_schema.yml index 163e4ad85f6..ebb7fe665f7 100644 --- a/dbt_subprojects/dex/models/trades/bnb/_schema.yml +++ b/dbt_subprojects/dex/models/trades/bnb/_schema.yml @@ -164,7 +164,7 @@ models: blockchain: bnb sector: dex project: pancakeswap - contributors: hosuke, chef_seaweed, tomfutago + contributors: hosuke, chef_seaweed, tomfutago, chef_butterbeer config: tags: ["bnb", "dex", "trades", "pancakeswap", "uniswap", "v2"] description: "Pancakeswap BNB v2 base trades" @@ -180,6 +180,7 @@ models: - 2 - mmpool - stableswap + - pcsx - name: pancakeswap_v3_bnb_base_trades meta: @@ -647,4 +648,4 @@ models: - check_dex_base_trades_seed: seed_file: ref('eulerswap_bnb_base_trades_seed') filter: - version: 1 \ No newline at end of file + version: 1 diff --git a/dbt_subprojects/dex/models/trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql b/dbt_subprojects/dex/models/trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql index d42c930bc18..fcb166fdef9 100644 --- a/dbt_subprojects/dex/models/trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql @@ -83,6 +83,51 @@ dexs AS ( {% if is_incremental() %} WHERE {{ incremental_predicate('t.evt_block_time') }} {% endif %} +), + +transfer as ( + select + tx_hash, + "from", + to, + contract_address, + sum(amount_raw) as amount_raw + from {{ source('tokens', 'transfers') }} + where blockchain = 'bnb' + and block_date >= date '2025-10-01' + and tx_hash in (select evt_tx_hash from {{ source('pancakeswap_bnb', 'ExclusiveDutchOrderReactor_evt_Fill') }}) + {% if is_incremental() %} + and {{ incremental_predicate('block_time') }} + {% endif %} + group by 1,2,3,4 +), + +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_bnb', '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 @@ -122,3 +167,25 @@ SELECT dexs.tx_hash, dexs.evt_index FROM dexs +UNION ALL +SELECT + 'bnb' 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 +AND token_bought_address is not NULL diff --git a/dbt_subprojects/dex/seeds/trades/pancakeswap_bnb_base_trades_seed.csv b/dbt_subprojects/dex/seeds/trades/pancakeswap_bnb_base_trades_seed.csv index 51cd51a988f..d9e9c580d55 100644 --- a/dbt_subprojects/dex/seeds/trades/pancakeswap_bnb_base_trades_seed.csv +++ b/dbt_subprojects/dex/seeds/trades/pancakeswap_bnb_base_trades_seed.csv @@ -14,3 +14,6 @@ bnb,pancakeswap,3,2023-04-02,0x54ce217448356994969038a892c0e7b5613ae237305a8191a bnb,pancakeswap,3,2023-04-02,0x570f6d65a9f3046b184feb4efea90de552b31e6b06c1a04baf645636a3389ca1,265,0x55d398326f99059ff775485246999027b3197955,0xe9e7cea3dedca5984780bafc599bd69add087d56,27000522,1000000000000000000,1002954374181880957 bnb,pancakeswap,2,2022-10-02,0x621c3436f07ab0c7228b50618195a1d9c19c62268d51f556fe3e9595c21cb2c6,140,0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d,0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82,21836538,4128690371495819498,918229127857603586 bnb,pancakeswap,2,2022-10-06,0x60655c0da9953df69117f9b0d3ff1872a50c97657ace896b365b5781f96d97cf,46,0xe9e7cea3dedca5984780bafc599bd69add087d56,0xaef0d72a118ce24fee3cd1d43d383897d05b4e99,21939022,29176228605313702756,266659423741634885391646 +bnb,pancakeswap,pcsx,2025-10-21,0x7c34b873fd0786b444373d7c3d35d15fedeacdb95e732e6f1c2bf2db1b4ea8e5,145,0x390a684ef9cade28a7ad0dfa61ab1eb3842618c4,0x55d398326f99059ff775485246999027b3197955,65386627,3816689157856130,1000000000000000000 +bnb,pancakeswap,pcsx,2025-10-22,0xc8132431c21be2e03ca89bf5cbb54d8892bf34757d6f198c36b2cfc07dd73ef2,85,0x390a684ef9cade28a7ad0dfa61ab1eb3842618c4,0x55d398326f99059ff775485246999027b3197955,65486149,37940847605191786,10000000000000000000 +bnb,pancakeswap,pcsx,2025-10-22,0x9d6b659142501911275e6e49a00401175fdecec4a2609688662db3e4c88a6a7c,767,0x55d398326f99059ff775485246999027b3197955,0x390a684ef9cade28a7ad0dfa61ab1eb3842618c4,65487461,1996747646194385940,7593121712358169 \ No newline at end of file diff --git a/sources/_sector/dex/trades/bnb/_sources.yml b/sources/_sector/dex/trades/bnb/_sources.yml index f52ef02a79b..b615bde05f9 100644 --- a/sources/_sector/dex/trades/bnb/_sources.yml +++ b/sources/_sector/dex/trades/bnb/_sources.yml @@ -27,6 +27,9 @@ sources: - name: FraxswapFactory_evt_PairCreated - name: trader_joe_v2_1_bnb - name: trader_joe_v2_bnb + - name: pancakeswap_bnb + tables: + - name: ExclusiveDutchOrderReactor_evt_Fill - name: pancakeswap_v2_bnb tables: - name: PancakePair_evt_Swap @@ -141,4 +144,4 @@ sources: - name: NativeRFQPool_evt_RFQTrade - name: bunni_v2_bnb tables: - - name: bunnihook_evt_swap \ No newline at end of file + - name: bunnihook_evt_swap From 1c1b0e31ac94dd2ccf0cf4f33a02de6f5b4286ff Mon Sep 17 00:00:00 2001 From: "butterbeer@pancakeswap.com" Date: Tue, 4 Nov 2025 20:17:03 +0800 Subject: [PATCH 2/2] house keeping --- .../trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/models/trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql b/dbt_subprojects/dex/models/trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql index fcb166fdef9..9eccc68dcd3 100644 --- a/dbt_subprojects/dex/models/trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql +++ b/dbt_subprojects/dex/models/trades/bnb/platforms/pancakeswap_v2_bnb_base_trades.sql @@ -188,4 +188,4 @@ SELECT FROM dexs_pcsx WHERE token_sold_amount_raw > 0 AND token_bought_amount_raw > 0 -AND token_bought_address is not NULL +AND token_bought_address is not NULL \ No newline at end of file