Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init flare dex #7243

Draft
wants to merge 48 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8592350
Init flare chain
Hosuke Dec 2, 2024
7ab7883
fix price
Hosuke Dec 2, 2024
5307ccd
Fix source
Hosuke Dec 2, 2024
47524d5
Merge branch '1202-init-flare' of ssh://github.com/Hosuke/spellbook i…
Hosuke Dec 2, 2024
1ed5702
Add tokens.erc20
Hosuke Dec 2, 2024
390bf60
Merge branch 'main' into 1202-init-flare
Hosuke Dec 4, 2024
124ad53
Update flare tokens
Hosuke Dec 4, 2024
e87fa52
Verify source table schema
Hosuke Dec 4, 2024
24944a9
Fix source
Hosuke Dec 4, 2024
e965bf8
Complete docs block
Hosuke Dec 4, 2024
f4ac044
Update prices_flare_tokens.sql
Hosuke Dec 4, 2024
715c31c
Fix native token
Hosuke Dec 4, 2024
78a7222
Add yakufff's credit
Hosuke Dec 4, 2024
b8b0b02
Remove post_hook
Hosuke Dec 4, 2024
2d80043
Update schema
Hosuke Dec 4, 2024
3597854
Init flare dex
Hosuke Dec 5, 2024
428cc8d
Merge branch 'main' into 1202-init-flare
Hosuke Dec 5, 2024
ab4b6bc
Fix param
Hosuke Dec 5, 2024
0228adf
Update prices
Hosuke Dec 9, 2024
1e2864f
Add flare dexes
Hosuke Dec 10, 2024
dd4aa1f
Add soruce
Hosuke Dec 10, 2024
7bad8d6
Update dbt_subprojects/tokens/models/prices/flare/prices_flare_tokens…
Hosuke Dec 10, 2024
946fd3d
Merge branch 'main' into 1202-init-flare
Hosuke Dec 10, 2024
c3eac5e
Fix macro name
Hosuke Dec 10, 2024
c7afb8d
Fix param
Hosuke Dec 10, 2024
b962d91
Remove blazeswap as source not available yet
Hosuke Dec 10, 2024
4f90e63
Update dbt_subprojects/tokens/models/prices/flare/prices_flare_tokens…
Hosuke Dec 10, 2024
d8ea547
Remove sparkdex_v2 as source not available yet
Hosuke Dec 10, 2024
7038f8b
Merge branch 'main' into 1202-init-flare
Hosuke Dec 10, 2024
971bfa1
Add sparkdex into dex.info
Hosuke Dec 10, 2024
74b7ac6
Add sparkdex seed
Hosuke Dec 10, 2024
fc179af
Merge branch 'main' into 1202-init-flare
Hosuke Dec 11, 2024
0aabb40
Revert "Remove sparkdex_v2 as source not available yet"
Hosuke Dec 11, 2024
c11c6ba
Revert "Remove blazeswap as source not available yet"
Hosuke Dec 11, 2024
5fa11d5
Merge branch 'main' into 1202-init-flare
Hosuke Dec 14, 2024
66f1266
Update sources/_sector/dex/trades/flare/_sources.yml
Hosuke Dec 16, 2024
cc59fa1
Merge branch 'main' into 1202-init-flare
Hosuke Dec 16, 2024
c329da2
Update blazeswap_flare_base_trades
Hosuke Dec 16, 2024
19c8ff8
Add test for blazeswap
Hosuke Dec 16, 2024
3b93c79
Update sources/_sector/dex/trades/flare/_sources.yml
Hosuke Dec 19, 2024
5cb7a4c
Update dbt_subprojects/dex/models/trades/flare/platforms/sparkdex_v2_…
Hosuke Dec 19, 2024
89a1b29
Merge branch 'main' into 1202-init-flare
Hosuke Dec 19, 2024
96dabd3
Refresh schema
Hosuke Dec 19, 2024
f405830
Try to fix bug
Hosuke Dec 19, 2024
7da8284
Add seeds
Hosuke Dec 19, 2024
d921508
Add flare
Hosuke Dec 19, 2024
99cb987
Merge branch 'main' into 1202-init-flare
0xRobin Dec 20, 2024
431e6bd
Merge branch 'main' into 1202-init-flare
Hosuke Dec 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dbt_subprojects/dex/models/dex_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -192,5 +192,6 @@ FROM (VALUES
, ('katana', 'Katana', 'Direct', 'AxieInfinity')
, ('jetswap', 'JetSwap', 'Direct', 'Jetfuelfinance')
, ('levinswap', 'Levinswap', 'Direct', 'levinswap')
, ('sparkdex', 'SparkDEX', 'Direct', 'SparkDexAI')
, ('fluid', 'Fluid DEX', 'Direct', '0xfluid')
) 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
blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei, ronin, flare
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
Expand Down
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 @@ -33,6 +33,7 @@
, ref('dex_zkevm_base_trades')
, ref('dex_zksync_base_trades')
, ref('dex_zora_base_trades')
, ref('dex_flare_base_trades')
] %}

with base_union as (
Expand Down
100 changes: 100 additions & 0 deletions dbt_subprojects/dex/models/trades/flare/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
version: 2

models:
- name: dex_flare_base_trades
meta:
blockchain: flare
sector: dex
project: dex
contributors: hosuke
config:
tags: ['flare', 'dex', 'trades']
description: >
Flare DEX trades
data_tests:
- check_dex_info_relationship

- name: enosys_v2_flare_base_trades
meta:
blockchain: flare
sector: dex
project: enosys
contributors: hosuke
config:
tags: [ 'flare', 'dex', 'trades', 'enosys', 'v2' ]
description: "Enosys V2 Flare base trades"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index

- name: enosys_v3_flare_base_trades
meta:
blockchain: flare
sector: dex
project: enosys
contributors: hosuke
config:
tags: [ 'flare', 'dex', 'trades', 'enosys', 'v3' ]
description: "Enosys V3 Flare base trades"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index

- name: sparkdex_v2_flare_base_trades
meta:
blockchain: flare
sector: dex
project: sparkdex
contributors: hosuke
config:
tags: ['flare', 'dex', 'trades', 'sparkdex', 'v2']
description: "SparkDex (UniswapV2 fork) base trades on Flare"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('sparkdex_flare_base_trades_seed')
filter:
version: 2

- name: sparkdex_v3_flare_base_trades
meta:
blockchain: flare
sector: dex
project: sparkdex
contributors: hosuke
config:
tags: [ 'flare', 'dex', 'trades', 'sparkdex', 'v3' ]
description: "SparkDex (UniswapV3 fork) base trades on Flare"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('sparkdex_flare_base_trades_seed')
filter:
version: 3

- name: blazeswap_flare_base_trades
meta:
blockchain: flare
sector: dex
project: blazeswap
contributors: hosuke
config:
tags: [ 'flare', 'dex', 'trades', 'blazeswap' ]
description: "Blazeswap Flare 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('blazeswap_flare_base_trades_seed')
52 changes: 52 additions & 0 deletions dbt_subprojects/dex/models/trades/flare/dex_flare_base_trades.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{ config(
schema = 'dex_flare'
, alias = 'base_trades'
, materialized = 'view'
)
}}

{% set base_models = [
ref('enosys_v2_flare_base_trades')
, ref('enosys_v3_flare_base_trades')
, ref('sparkdex_v2_flare_base_trades')
, ref('sparkdex_v3_flare_base_trades')
, ref('blazeswap_flare_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 = 'flare'
, columns = ['from', 'to', 'index']
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'blazeswap_flare',
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 = 'flare',
project = 'blazeswap',
version = '2',
Pair_evt_Swap = source('blazeswap_flare', 'BLAZE_LP_evt_Swap'),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Factory_evt_PairCreated = source('blazeswap_flare', 'BlazeSwapFactory_evt_PairCreated')
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ config(
schema = 'enosys_v2_flare'
, 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 = 'flare'
, project = 'enosys'
, version = '2'
, Pair_evt_Swap = source('enosys_flare', 'EnosysDexPair_evt_Swap')
, Factory_evt_PairCreated = source('enosys_flare', 'EnosysDexFactory_evt_PairCreated')
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ config(
schema = 'enosys_v3_flare'
, 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 = 'flare'
, project = 'enosys'
, version = '3'
, Pair_evt_Swap = source('enosys_flare', 'EnosysDexV3Pool_evt_Swap')
, Factory_evt_PoolCreated = source('enosys_flare', 'EnosysDexV3Factory_evt_PoolCreated')
)
}}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'sparkdex_v2_flare',
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 = 'flare',
project = 'sparkdex',
version = '2',
Pair_evt_Swap = source('sparkdex_flare', 'UniswapV2Pool_evt_Swap'),
Factory_evt_PairCreated = source('sparkdex_flare', 'UniswapV2Factory_evt_PairCreated')
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'sparkdex_v3_flare',
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 = 'flare',
project = 'sparkdex',
version = '3',
Pair_evt_Swap = source('sparkdex_flare', 'UniswapV3Pool_evt_Swap'),
Factory_evt_PoolCreated = source('sparkdex_flare', 'UniswapV3Factory_evt_PoolCreated')
)
}}
30 changes: 30 additions & 0 deletions dbt_subprojects/dex/seeds/trades/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4574,6 +4574,21 @@ seeds:
token_bought_amount_raw: uint256
token_sold_amount_raw: uint256
block_date: timestamp

- name: sparkdex_flare_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: fluid_ethereum_base_trades_seed
config:
Expand All @@ -4589,3 +4604,18 @@ seeds:
token_bought_amount_raw: uint256
token_sold_amount_raw: uint256
block_date: timestamp

- name: blazeswap_flare_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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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
flare,blazeswap,2,2024-10-06,0x51407c99b67d71815b993420f8811900b5865cb673ba893ef07dcca5f85aa06d,30,0xe6505f92583103af7ed9974dec451a7af4e3a3be,0x1d80c49bbbcd1c0911346656b529df9e5c2f783d,30881152,1335216349117423088152,5497558138880000000000
flare,blazeswap,2,2024-10-17,0x55de50c11e29636db85763b75c25a2b718dc18b4fe2c37539e5f324ac52e6e24,30,0x1d80c49bbbcd1c0911346656b529df9e5c2f783d,0xe6505f92583103af7ed9974dec451a7af4e3a3be,31449410,105931708336615473057,44371879946728776388
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
flare,sparkdex,2,2024-12-19,0x17b97c773299bb5432f7513ec1090b7182326dc6e8a8a772bbcc14639e2e5e74,16,0xfbda5f676cb37624f28265a144a48b0d6e87d3b6,0x1d80c49bbbcd1c0911346656b529df9e5c2f783d,34744392,164250,5873468685772181578
flare,sparkdex,2,2024-12-19,0xe1ac5909a57022912a5853ccb70e2de4604eae3c6dd3483fc719338cf18a0625,23,0xfbda5f676cb37624f28265a144a48b0d6e87d3b6,0x1d80c49bbbcd1c0911346656b529df9e5c2f783d,34747482,658,24000000000000000
flare,sparkdex,3,2024-12-04,0x2e172e22c714f28e9e8f29a89799ec5102397e29926a070a2bd11f92637106a3,10,0x1d80c49bbbcd1c0911346656b529df9e5c2f783d,0xfbda5f676cb37624f28265a144a48b0d6e87d3b6,34014169,4999999985390174801119,166057407
flare,sparkdex,3,2024-10-29,0x2e29ac0d54b4bd75c4788a285a9806ea57ed801b4c931a877b2a17aeaa3dafff,10,0xfbda5f676cb37624f28265a144a48b0d6e87d3b6,0x1d80c49bbbcd1c0911346656b529df9e5c2f783d,32113089,4955860,353988522618423672831
4 changes: 2 additions & 2 deletions sources/_base_sources/other/ton_base_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ sources:
columns:
- name: block_time
description: "Block timestamp"
tests:
data_tests:
- not_null
data_type: timestamp

- name: block_date
description: "Block date"
tests:
data_tests:
- not_null
data_type: date

Expand Down
21 changes: 21 additions & 0 deletions sources/_sector/dex/trades/flare/_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: 2

sources:
- name: blazeswap_flare
tables:
- name: BlazeSwapFactory_evt_PairCreated
- name: BLAZE_LP_evt_Swap

- name: sparkdex_flare
tables:
- name: UniswapV3Factory_evt_PoolCreated
- name: UniswapV2Factory_evt_PairCreated
- name: UniswapV3Pool_evt_Swap
- name: UniswapV2Pool_evt_Swap

- name: enosys_flare
tables:
- name: EnosysDexPair_evt_Swap
- name: EnosysDexFactory_evt_PairCreated
- name: EnosysDexV3Pool_evt_Swap
- name: EnosysDexV3Factory_evt_PoolCreated
Loading