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

Swapline DEX on Base #7284

Closed
wants to merge 8 commits into from
Closed
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
2 changes: 2 additions & 0 deletions dbt_subprojects/dex/models/dex_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ FROM (VALUES
, ('stablebase', 'StableBase', 'Direct', 'stablebasefi')
, ('flashliquidity', 'Flashliquidity', 'Direct', 'flashliquidity')
, ('akronswap', 'Akronswap', 'Direct', 'AkronFinance')
, ('saddle_finance', 'Saddle Finance', 'Direct', 'saddlefinance')
, ('swapline', 'Swapline', 'Direct', 'SwaplineDEX')
, ('katana', 'Katana', 'Direct', 'AxieInfinity')
, ('jetswap', 'JetSwap', 'Direct', 'Jetfuelfinance')
) AS temp_table (project, name, marketplace_type, x_username)
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 @@ -1024,6 +1024,23 @@ models:
- evt_index
- check_dex_base_trades_seed:
seed_file: ref('flashliquidity_base_base_trades_seed')

- name: swapline_base_base_trades
meta:
blockchain: base
sector: dex
project: swapline
contributors: princi
config:
tags: [ 'base', 'dex', 'trades', 'swapline' ]
description: "swapline base 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('swapline_base_base_trades_seed')

- name: akronswap_base_base_trades
meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
, ref('infusion_base_base_trades')
, ref('flashliquidity_base_base_trades')
, ref('akronswap_base_base_trades')
, ref('swapline_base_base_trades')
] %}

WITH base_union AS (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{ config(
schema = 'swapline_base',
alias = 'base_trades',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index']
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index']
unique_key = ['tx_hash', 'evt_index']

) }}

WITH token_swaps AS (
SELECT
evt_block_number AS block_number,
CAST(evt_block_time AS timestamp(3) with time zone) AS block_time,
evt_tx_from AS maker,
evt_tx_to AS taker,
amount0In AS token_sold_amount_raw,
amount0Out AS token_bought_amount_raw,
sender AS token_sold_address,
to AS token_bought_address,
contract_address AS project_contract_address,
evt_tx_hash AS tx_hash,
evt_index AS evt_index
FROM
{{ source('swapline_base', 'SwaplinePair_evt_Swap') }}
{% if is_incremental() %}
WHERE
{{ incremental_predicate('evt_block_time') }}
{% endif %}
)
Comment on lines +11 to +30
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we need to apply uniswap_compatible_v2_trades macro here with LBFactory_evt_LBPairCreated table to produce dex.trades.


SELECT
'base' AS blockchain,
'swapline' AS project,
'1' AS version,
CAST(date_trunc('month', token_swaps.block_time) AS date) AS block_month,
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
17 changes: 17 additions & 0 deletions dbt_subprojects/dex/models/trades/optimism/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,20 @@ models:
seed_file: ref('swaap_optimism_base_trades_seed')
filter:
version: 2

- name: saddle_finance_optimism_base_trades
meta:
blockchain: optimism
sector: dex
project: saddle_finance
contributors: princi
config:
tags: [ 'optimism', 'dex', 'trades', 'saddle_finance']
description: "saddle finance optimism 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('saddle_finance_optimism_base_trades_seed')
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
, ref('elk_finance_optimism_base_trades')
, ref('fraxswap_optimism_base_trades')
, ref('swaap_v2_optimism_base_trades')
, ref('saddle_finance_optimism_base_trades')
] %}

WITH base_union AS (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{{ config(
schema = 'saddle_finance_optimism',
alias = 'base_trades',
partition_by = ['block_month'],
materialized = 'incremental',
file_format = 'delta',
incremental_strategy = 'merge',
unique_key = ['block_date', 'blockchain', 'project', 'version', 'tx_hash', 'evt_index']
) }}

WITH token_swaps AS (
SELECT
evt_block_number AS block_number,
CAST(evt_block_time AS timestamp(3) with time zone) AS block_time,
evt_tx_from AS maker,
evt_tx_to AS taker,
tokensSold AS token_sold_amount_raw,
tokensBought AS token_bought_amount_raw,
CAST(soldId AS varbinary) AS token_sold_address,
CAST(boughtId AS varbinary) AS token_bought_address,
contract_address AS project_contract_address,
evt_tx_hash AS tx_hash,
evt_index AS evt_index
FROM
{{ source('saddle_finance_optimism', 'SwapFlashLoan_evt_TokenSwap') }}
{% if is_incremental() %}
WHERE
{{ incremental_predicate('evt_block_time') }}
{% endif %}
)

SELECT
'optimism' AS blockchain,
'saddle_finance' AS project,
'1' AS version,
CAST(date_trunc('month', token_swaps.block_time) AS date) AS block_month,
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
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 @@ -4499,6 +4499,36 @@ seeds:
token_bought_amount_raw: uint256
token_sold_amount_raw: uint256
block_date: timestamp

- name: saddle_finance_optimism_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: swapline_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: akronswap_base_base_trades_seed
config:
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
optimism,saddle_finance,1,2022-08-01 00:00,2022-08-05 00:00,2022-08-05 19:11,17943155,74907384,74857799085655995549,0x0000000000000000000000000000000000000000000000000000000000000000,0x0000000000000000000000000000000000000000000000000000000000000001,0xd131f1bcdd547e067af447dd3c36c99d6be9fdeb,0xf6c2e0adc659007ba7c48446f5a4e4e94dfe08b5,0xf6c2e0adc659007ba7c48446f5a4e4e94dfe08b5,0xbccdcd4ab61e5ad3384eb173156c3c0507d3bb3f2d2f5a406379e74aafbec38d,3
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,swapline,1,2024-10-01 00:00,2024-10-11 00:00,2024-10-11 11:52,20929092,0,7956190551055,0xfdf03f9b84babb7d8bf2fd583a85ba3858abd4c4,0xfdf03f9b84babb7d8bf2fd583a85ba3858abd4c4,0xb0385062b7516893e53aba24584b93fb20a3029f,0x19ceead7105607cd444f5ad10dd51356436095a1,0xe16d9cabbf84a8598e678e858d0e5000b279cb55,0xe51cb694f4c97883d1e9a695c044fae6d31da3d1ea12be3a1d11569c9772b90b,287
4 changes: 3 additions & 1 deletion sources/_sector/dex/trades/base/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,6 @@ sources:
tables:
- name: UniswapV2Pair_evt_Swap
- name: UniswapV2Factory_evt_PairCreated

- name: swapline_base
tables:
- name: SwaplinePair_evt_Swap
Comment on lines +204 to +206
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- name: swapline_base
tables:
- name: SwaplinePair_evt_Swap
- name: swapline_base
tables:
- name: SwaplinePair_evt_Swap
- name: LBPair_evt_Swap
- name: LBFactory_evt_LBPairCreated

3 changes: 3 additions & 0 deletions sources/_sector/dex/trades/optimism/_sources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,6 @@ sources:
- name: swaap_v2_optimism
tables:
- name: Vault_evt_Swap
- name: saddle_finance_optimism
tables:
- name: SwapFlashLoan_evt_TokenSwap
Loading