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

Curve code added #7386

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -13,6 +13,7 @@ FROM (VALUES
('uniswap', 'Uniswap', 'Direct', 'Uniswap')
, ('pancakeswap', 'PancakeSwap', 'Direct', 'PancakeSwap')
, ('curve', 'Curve', 'Direct', 'CurveFinance')
, ('curvefi', 'Curve', 'Direct', 'CurveFinance')
PatelPrinci marked this conversation as resolved.
Show resolved Hide resolved
, ('sushiswap', 'SushiSwap', 'Direct', 'SushiSwap')
, ('mdex', 'Mdex', 'Direct', 'Mdextech')
, ('dodo', 'DODO', 'Direct & Aggregator', 'BreederDodo') -- To Fix, should be just dodo
Expand Down
17 changes: 17 additions & 0 deletions dbt_subprojects/dex/models/trades/base/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ models:
- check_dex_base_trades_seed:
seed_file: ref('stablebase_base_base_trades_seed')

- name: curvefi_base_base_trades
meta:
blockchain: base
sector: dex
project: curvefi
contributors: principatel
config:
tags: ["base", "dex", "trades", "curvefi"]
description: curvefi 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('curvefi_base_base_trades_seed')

- name: sushiswap_v1_base_base_trades
meta:
blockchain: base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
, ref('sushiswap_v1_base_base_trades')
, ref('sushiswap_v2_base_base_trades')
, ref('stablebase_base_base_trades')
, ref('curvefi_base_base_trades')
, ref('aerodrome_base_base_trades')
, ref('pancakeswap_v2_base_base_trades')
, ref('pancakeswap_v3_base_base_trades')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{{
config(
schema = 'curvefi_base',
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')]
)
}}

WITH token_swaps AS (
SELECT
evt_block_number AS block_number,
TRY_CAST(evt_block_time AS TIMESTAMP(3) WITH TIME ZONE) AS block_time,
evt_tx_from AS maker,
evt_tx_to AS taker,
in_amount AS token_sold_amount_raw,
out_amount AS token_bought_amount_raw,
TRY_CAST(route[1] AS VARBINARY) AS token_sold_address,
TRY_CAST(route[CARDINALITY(route)] AS VARBINARY) AS token_bought_address,
contract_address AS project_contract_address,
evt_tx_hash AS tx_hash,
evt_index AS evt_index
FROM delta_prod.curvefi_base.CurveRouter_evt_Exchange
)
SELECT
'base' AS blockchain,
'curve' AS project,
'1' AS version,
TRY_CAST(DATE_TRUNC('month', token_swaps.block_time) AS DATE) AS block_month,
TRY_CAST(DATE_TRUNC('day', token_swaps.block_time) AS DATE) AS block_date,
token_swaps.block_time,
token_swaps.block_number,
token_swaps.token_sold_amount_raw,
token_swaps.token_bought_amount_raw,
token_swaps.token_sold_address,
token_swaps.token_bought_address,
token_swaps.maker,
token_swaps.taker,
token_swaps.project_contract_address,
token_swaps.tx_hash,
token_swaps.evt_index
FROM token_swaps
15 changes: 15 additions & 0 deletions dbt_subprojects/dex/seeds/trades/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4500,6 +4500,21 @@ seeds:
token_sold_amount_raw: uint256
block_date: timestamp

- name: curvefi_base_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: saddle_finance_optimism_base_trades_seed
config:
column_types:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
blockchain,project,version,block_month,block_date,block_time,block_number,token_sold_amount_raw,token_bought_amount_raw,token_sold_address,token_bought_address,maker,taker,project_contract_address,tx_hash,evt_index
base,curve,1,2025-01-01 00:00,2025-01-04 00:00,2025-01-04 03:40,24586349,59108712362989960,97919901691993224,0x4200000000000000000000000000000000000006,0x0000000000000000000000000000000000000000,0x03d9964f4d93a24b58c0fc3a8df3474b59ba8557,0xecd5b452e399e78f852809cd8a03c472947a1a97,0xd6681e74eea20d196c15038c580f721ef2ab6320,0x0a59e47dacd9cc31b4be2b3248649f6249e0972c432e12d546aab85118452503,338
3 changes: 3 additions & 0 deletions sources/_sector/dex/trades/base/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ sources:
- name: stablebase_base
tables:
- name: SwapFlashLoan_evt_TokenSwap
- name: curvefi_base
tables:
- name: StableSwap_evt_TokenExchange
- name: basex_base
tables:
- name: UniswapV3Pool_evt_Swap
Expand Down
Loading