Skip to content

Commit

Permalink
Add PancakeSwapX on Ethereum to Dex Trades (#7383)
Browse files Browse the repository at this point in the history
* Update orca_whirlpool_base_trades.sql

* Update orca_whirlpool_v2_base_trades.sql

* Add hardcode date filter to prevent memory errors

* Revert "Add hardcode date filter to prevent memory errors"

This reverts commit e4f46af.

* PCSX on Ethereum

* add back source

* Update pancakeswap_ethereum_base_trades_seed.csv

* Update pancakeswap_v2_ethereum_base_trades.sql

* Update pancakeswap_v2_ethereum_base_trades.sql

* Update pancakeswap_v2_ethereum_base_trades.sql

* Update pancakeswap_v2_ethereum_base_trades.sql

* Update pancakeswap_v2_ethereum_base_trades.sql

* Update pancakeswap_v2_ethereum_base_trades.sql
  • Loading branch information
chef-seaweed authored Jan 3, 2025
1 parent 368e174 commit ad59ddc
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions dbt_subprojects/dex/models/trades/ethereum/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ models:
version:
- 2
- mmpool
- pcsx

- name: shibaswap_v1_ethereum_base_trades
meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,44 @@ dexs_macro AS (
}}
),

transfer as (
select * from {{ source('tokens', 'transfers') }}
where blockchain = 'ethereum'
and block_date >= date '2024-09-20'
and tx_hash in (select evt_tx_hash from {{ source('pancakeswap_ethereum', '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_ethereum', '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 %}
),

dexs_mm AS (
-- PancakeSwap v2 MMPool
SELECT
Expand Down Expand Up @@ -129,3 +167,24 @@ SELECT
dexs_ss.tx_hash,
dexs_ss.evt_index
FROM dexs_ss
UNION ALL
SELECT
'ethereum' 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ ethereum,pancakeswap,3,2023-04-01,0x942d7e8064aa1925e484ad9e38b25b0eea8620aa2b85
ethereum,pancakeswap,stableswap,2024-09-03 00:00:00.000 UTC,0x76706147bb031c1dff5386142d866ec083578420885fb24160124a66800ef418,299,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,20668595,9967437,10000000
ethereum,pancakeswap,stableswap,2024-09-04 00:00:00.000 UTC,0x6639947fd9c9d5e07425f2500f3f50b13bb7b4bd92316d5392866e759aa7e97c,74,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,20680551,1251896,1177998
ethereum,pancakeswap,stableswap,2024-09-08 00:00:00.000 UTC,0x7e07e90e2230148bd1a5c49ccaa94a36408dc3df2f39c923c6c49b154d6c7ba4,72,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,0xbdf245957992bfbc62b07e344128a1eec7b7ee3f,20704016,13399197,13511099
ethereum,pancakeswap,pcsx,2024-12-12,0xa9f85566c718fa84dfe82dfc9638e8383271856e1c61f2ba11d3c4d23be6c8fc,226,0xdac17f958d2ee523a2206206994597c13d831ec7,0x2260fac5e5542a773aa44fbcfedf7c193bc2c599,21386209,20000000000,20072678
ethereum,pancakeswap,pcsx,2024-12-12,0xdd63f84eca7f3b7cdfc174ae93b80d1fded3bc145be5a63479eb30c525e07f51,430,0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,0x95ad61b0a150d79219dcf64e1e6cc01f0b64c4ce,21386418,1610345878716657319,220881632899203791230293346
ethereum,pancakeswap,pcsx,2024-12-12,0x96a89245d9f67ae8f23bdb4c54879e805b727403bbef6214d08fdcc771aa3f51,447,0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48,0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9,21386687,553168032,1521057740000000000
3 changes: 3 additions & 0 deletions sources/_sector/dex/trades/ethereum/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,6 @@ sources:
- name: fluid_ethereum
tables:
- name: FluidDexT1_evt_Swap
- name: pancakeswap_ethereum
tables:
- name: ExclusiveDutchOrderReactor_evt_Fill

0 comments on commit ad59ddc

Please sign in to comment.