Skip to content

Commit

Permalink
Add Uniswap Blast (V2 & V3) - Ready for review (#6177)
Browse files Browse the repository at this point in the history
* Add Uniswap Blast (V2 & V3)

* fix seed naming

* push

* Update tests

* trigger rerun

* smol fix
  • Loading branch information
henrystats authored Jun 18, 2024
1 parent e69946b commit 571ed0d
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dex/models/trades/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
models:
- name: dex_trades
meta:
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, optimism, polygon, scroll, zksync, linea
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, optimism, polygon, scroll, zksync, linea, blast
sector: dex
contributors: 0xRob, hosuke, jeff-dude, tomfutago
config:
Expand Down Expand Up @@ -99,7 +99,7 @@ models:

- name: dex_base_trades
meta:
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, optimism, polygon, scroll, zksync, linea
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, optimism, polygon, scroll, zksync, linea, blast
sector: dex
contributors: 0xRob, hosuke, jeff-dude, tomfutago
config:
Expand Down
44 changes: 44 additions & 0 deletions dex/models/trades/blast/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
version: 2

models:
- name: dex_blast_base_trades
tests:
- check_dex_info_relationship

- name: uniswap_v3_blast_base_trades
meta:
blockchain: blast
sector: dex
project: uniswap
contributors: Henrystats
config:
tags: [ 'blast', 'dex', 'trades', 'uniswap', 'v3' ]
description: "uniswap blast v3 base trades"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('uniswap_blast_base_trades_seed')
filter:
version: 3

- name: uniswap_v2_blast_base_trades
meta:
blockchain: blast
sector: dex
project: uniswap
contributors: Henrystats
config:
tags: [ 'blast', 'dex', 'trades', 'uniswap', 'v2' ]
description: "uniswap blast v2 base trades"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('uniswap_blast_base_trades_seed')
filter:
version: 2
49 changes: 49 additions & 0 deletions dex/models/trades/blast/dex_blast_base_trades.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{ config(
schema = 'dex_blast'
, alias = 'base_trades'
, materialized = 'view'
)
}}

{% set base_models = [
ref('uniswap_v3_blast_base_trades')
, ref('uniswap_v2_blast_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 = 'blast'
, columns = ['from', 'to', 'index']
)
}}
21 changes: 21 additions & 0 deletions dex/models/trades/blast/platforms/uniswap_v2_blast_base_trades.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'uniswap_v2_blast',
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 = 'blast',
project = 'uniswap',
version = '2',
Pair_evt_Swap = source('uniswap_v2_blast', 'Pair_evt_Swap'),
Factory_evt_PairCreated = source('uniswap_v2_blast', 'UniswapV2Factory_evt_PairCreated')
)
}}
20 changes: 20 additions & 0 deletions dex/models/trades/blast/platforms/uniswap_v3_blast_base_trades.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ config(
schema = 'uniswap_v3_blast'
, 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_v3_trades(
blockchain = 'blast'
, project = 'uniswap'
, version = '3'
, Pair_evt_Swap = source('uniswap_v3_blast', 'UniswapV3Pool_evt_Swap')
, Factory_evt_PoolCreated = source('uniswap_v3_blast', 'UniswapV3Factory_evt_PoolCreated')
)
}}
1 change: 1 addition & 0 deletions dex/models/trades/dex_base_trades.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
, ref('dex_zora_base_trades')
, ref('dex_zkevm_base_trades')
, ref('dex_linea_base_trades')
, ref('dex_blast_base_trades')
] %}

with base_union as (
Expand Down
15 changes: 15 additions & 0 deletions dex/seeds/trades/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1920,6 +1920,21 @@ seeds:
token_sold_amount_raw: uint256
block_date: timestamp

- name: uniswap_blast_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

- name: uniswap_celo_base_trades_seed
config:
column_types:
Expand Down
5 changes: 5 additions & 0 deletions dex/seeds/trades/uniswap_blast_base_trades_seed.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
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
blast,uniswap,3,2024-05-23,0x551d4e0f41354ae704d4741dcf4cc04545e8d57244970f82aa555e1133b7540d,46,0x4300000000000000000000000000000000000003,0x4300000000000000000000000000000000000004,3838988,1493638757736905160844,398348972910668948
blast,uniswap,3,2024-04-16,0x179f36ba037f73bba13287344a8500eb1d2afbc0d431397cd53a01dc3f7b4526,7,0x4300000000000000000000000000000000000004,0x2416092f143378750bb29b79ed961ab195cceea5,2246306,2105445002466536,2057258487654622
blast,uniswap,2,2024-06-07,0x1719c8d79cc064f4863417c7fae613857ef1c3b6a30f0071d9e416b4bb8385ec,23,0x4300000000000000000000000000000000000003,0x4300000000000000000000000000000000000004,4471336,1135362542678049275,298977031258286
blast,uniswap,2,2024-04-16,0x5057cf71829bebf2b9c9c19255355125906ec48123743fbdfbec6b6aa5c363a5,8,0x4300000000000000000000000000000000000003,0x4300000000000000000000000000000000000004,2215230,30824068867802868,10000000000000
11 changes: 11 additions & 0 deletions sources/_sector/dex/trades/blast/_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2

sources:
- name: uniswap_v3_blast
tables:
- name: UniswapV3Pool_evt_Swap
- name: UniswapV3Factory_evt_PoolCreated
- name: uniswap_v2_blast
tables:
- name: Pair_evt_Swap
- name: UniswapV2Factory_evt_PairCreated

0 comments on commit 571ed0d

Please sign in to comment.