Skip to content

Commit

Permalink
Add aerodrome to dex.trades_beta (duneanalytics#4837)
Browse files Browse the repository at this point in the history
* move aerodrome

* pair_column_name param

* test

* Flip seed record to refresh seed file

---------

Co-authored-by: Huang Geyang <Sukebeta@outlook.com>
Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 22, 2023
1 parent 876f685 commit 004eacd
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 10 deletions.
3 changes: 2 additions & 1 deletion macros/models/_sector/dex/uniswap_compatible_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
, version = null
, Pair_evt_Swap = null
, Factory_evt_PairCreated = null
, pair_column_name = 'pair'
)
%}
WITH dexs AS
Expand All @@ -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') }}
Expand Down
30 changes: 28 additions & 2 deletions models/_sector/dex/trades/base/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,31 @@ models:
- token_sold_address
- token_bought_amount_raw
- token_sold_amount_raw

- name: dex_base_base_trades

- 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
6 changes: 5 additions & 1 deletion models/_sector/dex/trades/base/_sources.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
version: 2

sources:
- name: uniswap_v3_base
- name: uniswap_v3_base
- name: aerodrome_base
tables:
- name: Pool_evt_Swap
- name: PoolFactory_evt_PoolCreated
3 changes: 2 additions & 1 deletion models/_sector/dex/trades/base/dex_base_base_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
)
}}
4 changes: 0 additions & 4 deletions models/aerodrome/base/aerodrome_base_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion seeds/_sector/dex/aerodrome_base_base_trades_seed.csv
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 004eacd

Please sign in to comment.