Skip to content

Commit

Permalink
Init flare dex (#7243)
Browse files Browse the repository at this point in the history
* Init flare chain

* fix price

* Fix source

* Add tokens.erc20

* Update flare tokens

* Verify source table schema

* Fix source

* Complete docs block

* Update prices_flare_tokens.sql

* Fix native token

* Add yakufff's credit

* Remove post_hook

* Update schema

* Init flare dex

* Fix param

* Update prices

* Add flare dexes

* Add soruce

* Update dbt_subprojects/tokens/models/prices/flare/prices_flare_tokens.sql

* Fix macro name

* Fix param

* Remove blazeswap as source not available yet

* Update dbt_subprojects/tokens/models/prices/flare/prices_flare_tokens.sql

* Remove sparkdex_v2 as source not available yet

* Add sparkdex into dex.info

* Add sparkdex seed

* Revert "Remove sparkdex_v2 as source not available yet"

This reverts commit d8ea547.

* Revert "Remove blazeswap as source not available yet"

This reverts commit b962d91.

* Update sources/_sector/dex/trades/flare/_sources.yml

* Update blazeswap_flare_base_trades

* Add test for blazeswap

* Update sources/_sector/dex/trades/flare/_sources.yml

* Update dbt_subprojects/dex/models/trades/flare/platforms/sparkdex_v2_flare_base_trades.sql

* Refresh schema

* Try to fix bug

* Add seeds

* Add flare

* update enosys v2 source

* update enosys v2 source

* add all projects to dex info

* Update dbt_subprojects/dex/models/trades/dex_base_trades.sql

* Update dbt_subprojects/dex/models/trades/_schema.yml

* Revert "Update dbt_subprojects/dex/models/trades/dex_base_trades.sql"

This reverts commit 90f0256.

* feat(dex/flare): remove enosys v3 trades

- Remove enosys v3 model and its references
- Keep enosys v2, sparkdex v2/v3, and blazeswap in flare trades

* Revert "Update dbt_subprojects/dex/models/trades/_schema.yml"

This reverts commit e72e698.

---------

Co-authored-by: 0xRob <[email protected]>
Co-authored-by: jeff-dude <[email protected]>
  • Loading branch information
3 people authored Jan 7, 2025
1 parent dd38855 commit 37d914e
Show file tree
Hide file tree
Showing 13 changed files with 283 additions and 1 deletion.
3 changes: 3 additions & 0 deletions dbt_subprojects/dex/models/dex_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ FROM (VALUES
, ('jetswap', 'JetSwap', 'Direct', 'Jetfuelfinance')
, ('bridgers', 'Bridgers', 'Direct', 'Bridgersxyz')
, ('levinswap', 'Levinswap', 'Direct', 'levinswap')
, ('sparkdex', 'SparkDEX', 'Direct', 'SparkDexAI')
, ('blazeswap', 'BlazeSwap', 'Direct', 'blazeswapdex')
, ('enosys', 'Enosys', 'Direct', 'enosys_global')
, ('gravity_finance', 'GravityFinance', 'Direct', 'Gravity_Finance')
, ('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, viniabussafi
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
85 changes: 85 additions & 0 deletions dbt_subprojects/dex/models/trades/flare/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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: 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')
51 changes: 51 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,51 @@
{{ config(
schema = 'dex_flare'
, alias = 'base_trades'
, materialized = 'view'
)
}}

{% set base_models = [
ref('enosys_v2_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'),
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', 'EnosysPair_evt_Swap')
, Factory_evt_PairCreated = source('enosys_flare', 'EnosysDexFactory_evt_PairCreated')
)
}}
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 @@ -4605,6 +4605,21 @@ seeds:
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: gravity_finance_polygon_base_trades_seed
config:
column_types:
Expand Down Expand Up @@ -4634,3 +4649,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
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: EnosysPair_evt_Swap
- name: EnosysDexFactory_evt_PairCreated
- name: EnosysDexV3Pool_evt_Swap
- name: EnosysDexV3Factory_evt_PoolCreated

0 comments on commit 37d914e

Please sign in to comment.