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 39 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)
129 changes: 129 additions & 0 deletions dbt_subprojects/dex/models/trades/flare/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
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
columns:
- name: blockchain
description: "Blockchain"
- name: project
description: "Project name of the DEX"
- name: version
description: "Version of the DEX protocol"
- name: block_month
description: "UTC event block month"
- name: block_date
description: "UTC event block date"
- name: block_time
description: "UTC event block time"
- name: block_number
description: "Block number"
- name: token_bought_amount_raw
description: "Raw amount of token bought (not normalized)"
- name: token_sold_amount_raw
description: "Raw amount of token sold (not normalized)"
- name: token_bought_address
description: "Contract address of the token bought"
- name: token_sold_address
description: "Contract address of the token sold"
- name: taker
description: "Address of trader who initiated the trade"
- name: maker
description: "Address of trader who provided liquidity"
- name: project_contract_address
description: "Project's contract address that executed the trade"
- name: tx_hash
description: "Transaction hash"
- name: evt_index
description: "Event index"
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

- 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', 'UniswapV2Pair_evt_Swap'),
Hosuke marked this conversation as resolved.
Show resolved Hide resolved
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,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,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
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: UniswapV2Pair_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.

This one is still missing.

Hosuke marked this conversation as resolved.
Show resolved Hide resolved

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