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

DUX-808 Init viction dex #7294

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
51 changes: 51 additions & 0 deletions dbt_subprojects/dex/models/trades/viction/_schema.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
version: 2

models:
- name: dex_viction_base_trades
data_tests:
- check_dex_info_relationship

- name: baryon_viction_base_trades
meta:
blockchain: viction
sector: dex
project: baryon
contributors: hosuke
config:
tags: [ 'viction', 'dex', 'trades', 'baryon', 'v2' ]
description: "Baryon base trades"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index

- name: rabbitswap_viction_base_trades
meta:
blockchain: viction
sector: dex
project: rabbitswap
contributors: hosuke
config:
tags: [ 'viction', 'dex', 'trades', 'rabbitswap', 'v3' ]
description: "RabbitSwap base trades"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index

- name: mori_viction_base_trades
meta:
blockchain: viction
sector: dex
project: mori
contributors: hosuke
config:
tags: [ 'viction', 'dex', 'trades', 'mori', 'v3' ]
description: "Mori base trades"
data_tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- tx_hash
- evt_index
Hosuke marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{{ config(
schema = 'dex_viction'
, alias = 'base_trades'
, materialized = 'view'
)
}}

{% set base_models = [
-- Pending for Swap event tables
ref('baryon_viction_base_trades'),
ref('rabbitswap_viction_base_trades')
-- Pending for contract deployment and event tables
-- ref('mori_viction_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 = 'viction'
, columns = ['from', 'to', 'index']
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
TODO: This model is pending for Swap event table
Currently only PairCreated event is available
*/

{{
config(
schema = 'baryon_viction',
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')]
)
}}

/* Uncomment when Swap event table is available
{{
uniswap_compatible_v2_trades(
blockchain = 'viction',
project = 'baryon',
version = '2',
Pair_evt_Swap = source('baryon_viction', 'CONTRACT_PAIR_evt_Swap'),
Factory_evt_PairCreated = source('baryon_viction', 'CONTRACT_FACTORY_evt_PairCreated')
)
}}
*/

-- Return empty result set for now
SELECT
'viction' as blockchain,
'baryon' as project,
'2' as version,
CAST(NULL as timestamp) as block_month,
CAST(NULL as date) as block_date,
CAST(NULL as timestamp) as block_time,
CAST(NULL as bigint) as block_number,
CAST(NULL as double) as token_bought_amount_raw,
CAST(NULL as double) as token_sold_amount_raw,
CAST(NULL as string) as token_bought_address,
CAST(NULL as string) as token_sold_address,
CAST(NULL as string) as taker,
CAST(NULL as string) as maker,
CAST(NULL as string) as project_contract_address,
CAST(NULL as string) as tx_hash,
CAST(NULL as integer) as evt_index
WHERE 1=0
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{
config(
schema = 'mori_viction',
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 = 'viction',
project = 'mori',
version = '3',
Pair_evt_Swap = source('mori_viction', 'UniswapV3Pool_evt_Swap'),
Factory_evt_PoolCreated = source('mori_viction', 'UniswapV3Factory_evt_PoolCreated')
)
}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
TODO: This model is pending for Swap event table
Currently only PoolCreated event is available
*/

{{
config(
schema = 'rabbitswap_xyz_viction',
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')]
)
}}

/* Uncomment when Swap event table is available
{{
uniswap_compatible_v3_trades(
blockchain = 'viction',
project = 'rabbitswap',
version = '3',
Pair_evt_Swap = source('rabbitswap_xyz_viction', 'RabbitSwapV3Pool_evt_Swap'),
Factory_evt_PoolCreated = source('rabbitswap_xyz_viction', 'RabbitSwapV3Factory_evt_PoolCreated')
)
}}
*/

-- Return empty result set for now
SELECT
'viction' as blockchain,
'rabbitswap' as project,
'3' as version,
CAST(NULL as timestamp) as block_month,
CAST(NULL as date) as block_date,
CAST(NULL as timestamp) as block_time,
CAST(NULL as bigint) as block_number,
CAST(NULL as double) as token_bought_amount_raw,
CAST(NULL as double) as token_sold_amount_raw,
CAST(NULL as string) as token_bought_address,
CAST(NULL as string) as token_sold_address,
CAST(NULL as string) as taker,
CAST(NULL as string) as maker,
CAST(NULL as string) as project_contract_address,
CAST(NULL as string) as tx_hash,
CAST(NULL as integer) as evt_index
WHERE 1=0
20 changes: 20 additions & 0 deletions sources/_sector/dex/trades/viction/_sources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2

sources:
- name: baryon_viction
tables:
- name: BaryonFactory_evt_PairCreated
# Pending for Swap event table
# - name: CONTRACT_PAIR_evt_Swap

- name: rabbitswap_xyz_viction
tables:
- name: RabbitSwapV3Factory_evt_PoolCreated
# Pending for Swap event table
# - name: RabbitSwapV3Pool_evt_Swap
Comment on lines +7 to +14
Copy link
Member

Choose a reason for hiding this comment

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

nia is actively looking to decode these, more to come soon 🙏


# Pending for contract deployment and event tables
# - name: mori_viction
# tables:
# - name: UniswapV3Pool_evt_Swap
# - name: UniswapV3Factory_evt_PoolCreated
Hosuke marked this conversation as resolved.
Show resolved Hide resolved
Loading