From 004eacd15f6a2109cecfe9acd4622dfac2a1ec10 Mon Sep 17 00:00:00 2001 From: tomfutago <35136350+tomfutago@users.noreply.github.com> Date: Wed, 22 Nov 2023 20:45:42 +0000 Subject: [PATCH] Add aerodrome to `dex.trades_beta` (#4837) * move aerodrome * pair_column_name param * test * Flip seed record to refresh seed file --------- Co-authored-by: Huang Geyang Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com> --- .../_sector/dex/uniswap_compatible_trades.sql | 3 +- models/_sector/dex/trades/base/_schema.yml | 30 +++++++++++++++++-- models/_sector/dex/trades/base/_sources.yml | 6 +++- .../dex/trades/base/dex_base_base_trades.sql | 3 +- .../platforms/aerodrome_base_base_trades.sql | 22 ++++++++++++++ .../aerodrome/base/aerodrome_base_sources.yml | 4 --- .../dex/aerodrome_base_base_trades_seed.csv | 2 +- 7 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 models/_sector/dex/trades/base/platforms/aerodrome_base_base_trades.sql diff --git a/macros/models/_sector/dex/uniswap_compatible_trades.sql b/macros/models/_sector/dex/uniswap_compatible_trades.sql index 02e7d08185c..6fb8a6fad12 100644 --- a/macros/models/_sector/dex/uniswap_compatible_trades.sql +++ b/macros/models/_sector/dex/uniswap_compatible_trades.sql @@ -4,6 +4,7 @@ , version = null , Pair_evt_Swap = null , Factory_evt_PairCreated = null + , pair_column_name = 'pair' ) %} WITH dexs AS @@ -24,7 +25,7 @@ WITH dexs AS {{ Pair_evt_Swap }} t INNER JOIN {{ Factory_evt_PairCreated }} f - ON f.pair = t.contract_address + ON f.{{ pair_column_name }} = t.contract_address {% if is_incremental() %} WHERE {{ incremental_predicate('t.evt_block_time') }} diff --git a/models/_sector/dex/trades/base/_schema.yml b/models/_sector/dex/trades/base/_schema.yml index 564135cba1e..744a34b2629 100644 --- a/models/_sector/dex/trades/base/_schema.yml +++ b/models/_sector/dex/trades/base/_schema.yml @@ -26,5 +26,31 @@ models: - token_sold_address - token_bought_amount_raw - token_sold_amount_raw - - - name: dex_base_base_trades \ No newline at end of file + + - name: aerodrome_base_base_trades + meta: + blockchain: base + sector: dex + project: aerodrome + contributors: msilb7, tomfutago + config: + tags: [ 'base', 'dex', 'trades', 'aerodrome' ] + description: aerodrome base trades + tests: + - dbt_utils.unique_combination_of_columns: + combination_of_columns: + - tx_hash + - evt_index + - check_seed: + seed_file: ref('aerodrome_base_base_trades_seed') + match_columns: + - tx_hash + - evt_index + check_columns: + - block_number + - token_bought_address + - token_sold_address + - token_bought_amount_raw + - token_sold_amount_raw + + - name: dex_base_base_trades diff --git a/models/_sector/dex/trades/base/_sources.yml b/models/_sector/dex/trades/base/_sources.yml index 4d9de0e0281..14b691d608a 100644 --- a/models/_sector/dex/trades/base/_sources.yml +++ b/models/_sector/dex/trades/base/_sources.yml @@ -1,4 +1,8 @@ version: 2 sources: - - name: uniswap_v3_base \ No newline at end of file + - name: uniswap_v3_base + - name: aerodrome_base + tables: + - name: Pool_evt_Swap + - name: PoolFactory_evt_PoolCreated diff --git a/models/_sector/dex/trades/base/dex_base_base_trades.sql b/models/_sector/dex/trades/base/dex_base_base_trades.sql index d979e373774..7869d0cffd3 100644 --- a/models/_sector/dex/trades/base/dex_base_base_trades.sql +++ b/models/_sector/dex/trades/base/dex_base_base_trades.sql @@ -6,7 +6,8 @@ }} {% set base_models = [ - ref('uniswap_v3_base_base_trades') + ref('uniswap_v3_base_base_trades'), + ref('aerodrome_base_base_trades') ] %} WITH base_union AS ( diff --git a/models/_sector/dex/trades/base/platforms/aerodrome_base_base_trades.sql b/models/_sector/dex/trades/base/platforms/aerodrome_base_base_trades.sql new file mode 100644 index 00000000000..ace7300a2ee --- /dev/null +++ b/models/_sector/dex/trades/base/platforms/aerodrome_base_base_trades.sql @@ -0,0 +1,22 @@ +{{ + config( + schema = 'aerodrome_base', + 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 = 'base', + project = 'aerodrome', + version = '1', + Pair_evt_Swap = source('aerodrome_base', 'Pool_evt_Swap'), + Factory_evt_PairCreated = source('aerodrome_base', 'PoolFactory_evt_PoolCreated'), + pair_column_name = 'pool' + ) +}} diff --git a/models/aerodrome/base/aerodrome_base_sources.yml b/models/aerodrome/base/aerodrome_base_sources.yml index 5d7998af6ee..fd28cf27b60 100644 --- a/models/aerodrome/base/aerodrome_base_sources.yml +++ b/models/aerodrome/base/aerodrome_base_sources.yml @@ -6,9 +6,5 @@ sources: freshness: warn_after: { count: 12, period: hour } tables: - - name: Pool_evt_Swap - loaded_at_field: evt_block_time - - name: PoolFactory_evt_PoolCreated - loaded_at_field: evt_block_time - name: Voter_evt_GaugeCreated loaded_at_field: evt_block_time diff --git a/seeds/_sector/dex/aerodrome_base_base_trades_seed.csv b/seeds/_sector/dex/aerodrome_base_base_trades_seed.csv index 985a63608b8..20c008ebad8 100644 --- a/seeds/_sector/dex/aerodrome_base_base_trades_seed.csv +++ b/seeds/_sector/dex/aerodrome_base_base_trades_seed.csv @@ -1,6 +1,6 @@ blockchain,project,version,block_date,tx_hash,evt_index,token_bought_address,token_sold_address,block_number,token_bought_amount_raw,token_sold_amount_raw +base,aerodrome,1,2023-08-29,0x8e6c892e94a991f843932a8b9af962f448d06c25addca4c608eef800aaf2ab70,16,0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca,0x4200000000000000000000000000000000000006,3243890,170841539,100000000000000000 base,aerodrome,1,2023-08-29,0x7d759da49295695ec7cade65a7f8abbdf83d6f639efa03ad73533f46f387375e,21,0x9e53e88dcff56d3062510a745952dec4cefdff9e,0x4200000000000000000000000000000000000006,3241478,949750926402392636677028,200000000000000000 base,aerodrome,1,2023-08-29,0x3c00dfe0b735b6c7f3dd302e41cdb5bc32fa64ce98b958ea2a99e9b868f24976,8,0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca,0x4200000000000000000000000000000000000006,3242321,16521567,10000000000000000 base,aerodrome,1,2023-08-29,0x644579f1f66b20b7aacddc4300ea746963ef3c68c37b32d14c7a9f59a92d2151,17,0x9e53e88dcff56d3062510a745952dec4cefdff9e,0x4200000000000000000000000000000000000006,3241443,1588864691284781064569017,300000000000000000 base,aerodrome,1,2023-08-29,0x552ae20fd4164aa9ef2a37616510c7dd54333733578a4af20074e81dc14af8ce,143,0x4200000000000000000000000000000000000006,0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca,3244933,60625419898954064,100000000 -base,aerodrome,1,2023-08-29,0x8e6c892e94a991f843932a8b9af962f448d06c25addca4c608eef800aaf2ab70,16,0xd9aaec86b65d86f6a7b5b1b0c42ffa531710b6ca,0x4200000000000000000000000000000000000006,3243890,170841539,100000000000000000