Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions dbt_subprojects/dex/models/trades/bnb/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,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"
Expand All @@ -179,6 +179,7 @@ models:
- 2
- mmpool
- stableswap
- pcsx

- name: pancakeswap_v3_bnb_base_trades
meta:
Expand Down Expand Up @@ -646,4 +647,4 @@ models:
- check_dex_base_trades_seed:
seed_file: ref('eulerswap_bnb_base_trades_seed')
filter:
version: 1
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion sources/_sector/dex/trades/bnb/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -141,4 +144,4 @@ sources:
- name: NativeRFQPool_evt_RFQTrade
- name: bunni_v2_bnb
tables:
- name: bunnihook_evt_swap
- name: bunnihook_evt_swap
Loading