Skip to content

Commit

Permalink
Merge branch 'main' into beetsdexspells
Browse files Browse the repository at this point in the history
  • Loading branch information
jeff-dude authored Jan 9, 2025
2 parents b8dc7cb + 3e264a4 commit 832cf31
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 27 deletions.
3 changes: 2 additions & 1 deletion dbt_subprojects/dex/models/dex_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
tags = [ 'static'],
schema='dex',
alias = 'info',
post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "solana", "zksync"]\',
post_hook='{{ expose_spells(\'["ethereum", "polygon", "bnb", "avalanche_c", "gnosis", "fantom", "optimism", "arbitrum", "celo", "base", "solana", "zksync", "boba"]\',
"sector",
"dex",
\'["hildobby"]\') }}')
Expand Down Expand Up @@ -200,4 +200,5 @@ FROM (VALUES
, ('gravity_finance', 'GravityFinance', 'Direct', 'Gravity_Finance')
, ('fluid', 'Fluid DEX', 'Direct', '0xfluid')
, ('beets', 'Beets DEX', 'Direct', 'beets_fi')
, ('icecreamswap', 'IceCreamSwap', 'Direct', 'icecream_swap')
) AS temp_table (project, name, marketplace_type, x_username)
2 changes: 1 addition & 1 deletion dbt_subprojects/dex/models/trades/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ models:
- name: dex_trades
meta:
docs_slug: /curated/trading/DEX/dex-trades
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei, ronin, flare, sonic
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei, ronin, flare, boba, sonic
sector: dex
short_description: The `dex.trades` table captures detailed data on trades executed via decentralized exchanges (DEXs). This table contains a detailed breakdown of trade execution containing one or many trades per transaction.
contributors: 0xRob, hosuke, jeff-dude, tomfutago, viniabussafi
Expand Down
1 change: 1 addition & 0 deletions dbt_subprojects/dex/models/trades/arbitrum/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ models:
version:
- 2
- stableswap
- pcsx

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

dexs AS (
dexs_ss AS (
-- PancakeSwap v2 stableswap
SELECT
'stableswap' AS version,
Expand All @@ -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,
Expand All @@ -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
25 changes: 25 additions & 0 deletions dbt_subprojects/dex/models/trades/boba/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
version: 2

models:
- name: dex_boba_base_trades
data_tests:
- check_dex_info_relationship

- name: icecreamswap_boba_base_trades
meta:
blockchain: boba
sector: dex
project: icecreamswap
contributors: hosuke
config:
tags: ["boba", "dex", "trades", "icecreamswap"]
description: "IceCreamSwap boba 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('icecreamswap_boba_base_trades_seed')
filter:
version: 1
48 changes: 48 additions & 0 deletions dbt_subprojects/dex/models/trades/boba/dex_boba_base_trades.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{ config(
schema = 'dex_boba'
, alias = 'base_trades'
, materialized = 'view'
)
}}

{% set base_models = [
ref('icecreamswap_boba_base_trades')
] %}

WITH base_union AS (
SELECT *
FROM (
{% for base_model in base_models %}
SELECT
blockchain
, project
, version
, block_month
, block_date
, block_time
, block_number
, token_bought_amount_raw
, token_sold_amount_raw
, token_bought_address
, token_sold_address
, taker
, maker
, project_contract_address
, tx_hash
, evt_index
FROM
{{ base_model }}
{% if not loop.last %}
UNION ALL
{% endif %}
{% endfor %}
)
)

{{
add_tx_columns(
model_cte = 'base_union'
, blockchain = 'boba'
, columns = ['from', 'to', 'index']
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'icecreamswap_boba',
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 = 'boba',
project = 'icecreamswap',
version = '1',
Pair_evt_Swap = source('icecreamswap_boba', 'IceCreamSwapV2Pair_evt_Swap'),
Factory_evt_PairCreated = source('icecreamswap_boba', 'IceCreamSwapV2Factory_evt_PairCreated')
)
}}
1 change: 1 addition & 0 deletions dbt_subprojects/dex/models/trades/dex_base_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
, ref('dex_base_base_trades')
, ref('dex_blast_base_trades')
, ref('dex_bnb_base_trades')
, ref('dex_boba_base_trades')
, ref('dex_celo_base_trades')
, ref('dex_ethereum_base_trades')
, ref('dex_fantom_base_trades')
Expand Down
1 change: 1 addition & 0 deletions dbt_subprojects/dex/models/trades/dex_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
, "base"
, "blast"
, "bnb"
, "boba"
, "celo"
, "ethereum"
, "fantom"
Expand Down
26 changes: 23 additions & 3 deletions dbt_subprojects/dex/seeds/trades/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4573,7 +4573,7 @@ seeds:
token_sold_address: varbinary
token_bought_amount_raw: uint256
token_sold_amount_raw: uint256
block_date: timestamp
block_date: timestamp

- name: bridgers_optimism_base_trades_seed
config:
Expand Down Expand Up @@ -4664,7 +4664,8 @@ seeds:
token_bought_amount_raw: uint256
token_sold_amount_raw: uint256
block_date: timestamp
- name: blazeswap_flare_base_trades_seed

- name: blazeswap_flare_base_trades_seed
config:
column_types:
blockchain: varchar
Expand All @@ -4677,4 +4678,23 @@ seeds:
token_sold_address: varbinary
token_bought_amount_raw: uint256
token_sold_amount_raw: uint256
block_date: timestamp
block_date: timestamp

- name: icecreamswap_boba_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
taker: varbinary
maker: varbinary
project_contract_address: varbinary
block_month: timestamp
block_time: timestamp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
blockchain,project,version,block_month,block_date,block_time,block_number,token_bought_amount_raw,token_sold_amount_raw,token_bought_address,token_sold_address,taker,maker,project_contract_address,tx_hash,evt_index
boba,icecreamswap,1,2024-11-01 00:00,2024-11-24 00:00,2024-11-24 14:15,10726459,65183603501016643,300000000000000000,0x7d5a56742c082fcdfc240cd7d1775f00e059771f,0xa18bf3994c0cc6e3b63ac420308e5383f53120d7,0x85767bcbb2b5e95bddb3523406419d1aa7efdcf2,0x46d172bfdd9b03575229614bcf46da014d8ac8b1,0x46d172bfdd9b03575229614bcf46da014d8ac8b1,0x2a59b0f2abc8c29029c4dee209b0b82f2f1c89b825bca663a3d1c2b4deeb58b1,9
boba,icecreamswap,1,2024-07-01 00:00,2024-07-19 00:00,2024-07-19 16:57,5201714,661356424536501999965,169150000000000000000,0xa18bf3994c0cc6e3b63ac420308e5383f53120d7,0x7d5a56742c082fcdfc240cd7d1775f00e059771f,0x0604e652a188931e245717d45feb26f583b92908,0x46d172bfdd9b03575229614bcf46da014d8ac8b1,0x46d172bfdd9b03575229614bcf46da014d8ac8b1,0x01f3b8af8421fa428fca4cf2dc85498614d94b637bc5887c29e50abc7897c2b3,3
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -1870,8 +1870,9 @@ FROM
('mstr-mstr2100', 'ethereum', 'MSTR', 0x42069026EAC8Eee0Fd9b5f7aDFa4f6E6D69a2B39, 9),
('usdl-lift-dollar', 'ethereum', 'USDL', 0xbdC7c08592Ee4aa51D06C27Ee23D5087D65aDbcD, 18),
('usr-resolv-usr', 'ethereum', 'USR', 0x66a1e37c9b0eaddca17d3662d6c05f4decf3e110, 18),
('sovrn-sovrun','ethereum', 'SOVRN', 0x031B8d752d73d7Fe9678ACEf26e818280D0646b4, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
('sovrn-sovrun','ethereum', 'SOVRN', 0x031B8d752d73d7Fe9678ACEf26e818280D0646b4, 18),
('apw-spectra','ethereum', 'APW', 0x4104b135dbc9609fc1a9490e61369036497660c8, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
where contract_address not in (
-- bad price feeds
0x841fb148863454a3b3570f515414759be9091465 -- SHIH
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ FROM (VALUES
, (0x2d0e0814e62d80056181f5cd932274405966e4f0, 'BEETS', 18)
, (0xd3DCe716f3eF535C5Ff8d041c1A41C3bd89b97aE, 'scUSD', 6)
, (0x3bce5cb273f0f148010bbea2470e7b5df84c7812, 'scETH', 18)
, (0xddf26b42c1d903de8962d3f79a74a501420d5f19, 'EQUAL', 18)
, (0x313636D4f23859142b523a7965B76F6e3965Af64, 'SonicSwap', 18)
, (0x4eec869d847a6d13b0f6d1733c5dec0d1e741b4f, 'INDI', 18)
) as temp (contract_address, symbol, decimals)
9 changes: 5 additions & 4 deletions sources/_sector/dex/trades/arbitrum/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions sources/_sector/dex/trades/boba/_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2

sources:
- name: icecreamswap_boba
tables:
- name: IceCreamSwapV2Pair_evt_Swap
- name: IceCreamSwapV2Factory_evt_PairCreated

0 comments on commit 832cf31

Please sign in to comment.