From 89b0238b128311c49735068aad00d084db61517a Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Tue, 23 Dec 2025 14:31:24 +0100 Subject: [PATCH 1/6] created dex_evm.trades view --- dbt_subprojects/dex/models/trades/dex_evm_trades.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 dbt_subprojects/dex/models/trades/dex_evm_trades.sql diff --git a/dbt_subprojects/dex/models/trades/dex_evm_trades.sql b/dbt_subprojects/dex/models/trades/dex_evm_trades.sql new file mode 100644 index 00000000000..88030a646d2 --- /dev/null +++ b/dbt_subprojects/dex/models/trades/dex_evm_trades.sql @@ -0,0 +1,10 @@ +{{ config( + schema = 'dex_evm' + , alias = 'trades' + , materialized = 'view' + ) +}} + +SELECT * +FROM {{ ref('dex_trades') }} + From 8d8f6d549ec06bcdf40795ef83724dd47cd2391d Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Tue, 23 Dec 2025 15:01:06 +0100 Subject: [PATCH 2/6] added dex_sui.trades as source --- sources/_subprojects_outputs/daily_spellbook/_sources.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sources/_subprojects_outputs/daily_spellbook/_sources.yml b/sources/_subprojects_outputs/daily_spellbook/_sources.yml index fd5d2439f36..56a3083991f 100644 --- a/sources/_subprojects_outputs/daily_spellbook/_sources.yml +++ b/sources/_subprojects_outputs/daily_spellbook/_sources.yml @@ -51,6 +51,10 @@ sources: - name: pools_metrics_daily - name: trades + - name: dex_sui + tables: + - name: trades + - name: utils tables: - name: days_table From 72631e182b336c740ee1a12387563fa10d62f58a Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Tue, 23 Dec 2025 15:01:35 +0100 Subject: [PATCH 3/6] created dex_multichain_trades model with evm, solana and sui. --- .../models/trades/dex_multichain_trades.sql | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 dbt_subprojects/dex/models/trades/dex_multichain_trades.sql diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql new file mode 100644 index 00000000000..eae813bd51c --- /dev/null +++ b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql @@ -0,0 +1,86 @@ +{{ config( + schema = 'dex_multichain' + , alias = 'trades' + , materialized = 'view' + ) +}} + +WITH + +evm_trades AS ( + SELECT + blockchain, + block_time AS timestamp, + block_date AS date, + block_number, --not very chain agnostic + CONCAT('0x', LOWER(TO_HEX(tx_hash))) AS tx_id, + CONCAT('0x', LOWER(TO_HEX(taker))) AS trader_id, + CONCAT('0x', LOWER(TO_HEX(tx_from))) AS tx_signer, + project, + CONCAT('0x', LOWER(TO_HEX(project_contract_address))) AS pool_id, + token_pair, + token_bought_symbol, + token_sold_symbol, + token_bought_amount, + token_sold_amount, + token_bought_amount_raw, + token_sold_amount_raw, + amount_usd, + CONCAT('0x', LOWER(TO_HEX(token_bought_address))) AS token_bought_id, + CONCAT('0x', LOWER(TO_HEX(token_sold_address))) AS token_sold_id + FROM {{ ref('dex_evm_trades') }} +), + +solana_trades AS ( + SELECT + 'solana' AS blockchain, + block_time AS timestamp, + block_date AS date, + block_slot AS block_number, + tx_id, + trader_id, + trader_id AS tx_signer, + project, + project_program_id AS pool_id, + token_pair, + token_bought_symbol, + token_sold_symbol, + token_bought_amount, + token_sold_amount, + token_bought_amount_raw, + token_sold_amount_raw, + amount_usd, + token_bought_mint_address AS token_bought_id, + token_sold_mint_address AS token_sold_id + FROM {{ source('dex_solana', 'trades') }} +), + +sui_trades AS ( + SELECT + 'sui' AS blockchain, + block_time AS timestamp, + block_date AS date, + CAST(checkpoint AS BIGINT) AS block_number, + transaction_digest AS tx_id, + CONCAT('0x', LOWER(TO_HEX(sender))) AS trader_id, + CONCAT('0x', LOWER(TO_HEX(sender))) AS tx_signer, + project, + pool_id, + token_pair, + token_bought_symbol, + token_sold_symbol, + CAST(token_bought_amount AS DOUBLE) AS token_bought_amount, + CAST(token_sold_amount AS DOUBLE) AS token_sold_amount, + CAST(token_bought_amount_raw AS DOUBLE) AS token_bought_amount_raw, + CAST(token_sold_amount_raw AS DOUBLE) AS token_sold_amount_raw, + CAST(amount_usd AS DOUBLE) AS amount_usd, + token_bought_address AS token_bought_id, + token_sold_address AS token_sold_id + FROM {{ source('dex_sui', 'trades') }} +) + +SELECT * FROM evm_trades +UNION ALL +SELECT * FROM solana_trades +UNION ALL +SELECT * FROM sui_trades; From 4b8dcf87807eff8f445c5b735df77c00643a8b13 Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:06:02 +0100 Subject: [PATCH 4/6] remove tx_signer, not available across all Solana models --- dbt_subprojects/dex/models/trades/dex_multichain_trades.sql | 2 -- 1 file changed, 2 deletions(-) diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql index eae813bd51c..77c859bed3d 100644 --- a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql +++ b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql @@ -15,7 +15,6 @@ evm_trades AS ( block_number, --not very chain agnostic CONCAT('0x', LOWER(TO_HEX(tx_hash))) AS tx_id, CONCAT('0x', LOWER(TO_HEX(taker))) AS trader_id, - CONCAT('0x', LOWER(TO_HEX(tx_from))) AS tx_signer, project, CONCAT('0x', LOWER(TO_HEX(project_contract_address))) AS pool_id, token_pair, @@ -39,7 +38,6 @@ solana_trades AS ( block_slot AS block_number, tx_id, trader_id, - trader_id AS tx_signer, project, project_program_id AS pool_id, token_pair, From 57f96ce9eed6a96277162616f9a5e7a7bb5123ba Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:08:24 +0100 Subject: [PATCH 5/6] remove SUI --- .../models/trades/dex_multichain_trades.sql | 28 +------------------ 1 file changed, 1 insertion(+), 27 deletions(-) diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql index 77c859bed3d..58f1d92042b 100644 --- a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql +++ b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql @@ -51,34 +51,8 @@ solana_trades AS ( token_bought_mint_address AS token_bought_id, token_sold_mint_address AS token_sold_id FROM {{ source('dex_solana', 'trades') }} -), - -sui_trades AS ( - SELECT - 'sui' AS blockchain, - block_time AS timestamp, - block_date AS date, - CAST(checkpoint AS BIGINT) AS block_number, - transaction_digest AS tx_id, - CONCAT('0x', LOWER(TO_HEX(sender))) AS trader_id, - CONCAT('0x', LOWER(TO_HEX(sender))) AS tx_signer, - project, - pool_id, - token_pair, - token_bought_symbol, - token_sold_symbol, - CAST(token_bought_amount AS DOUBLE) AS token_bought_amount, - CAST(token_sold_amount AS DOUBLE) AS token_sold_amount, - CAST(token_bought_amount_raw AS DOUBLE) AS token_bought_amount_raw, - CAST(token_sold_amount_raw AS DOUBLE) AS token_sold_amount_raw, - CAST(amount_usd AS DOUBLE) AS amount_usd, - token_bought_address AS token_bought_id, - token_sold_address AS token_sold_id - FROM {{ source('dex_sui', 'trades') }} ) SELECT * FROM evm_trades UNION ALL -SELECT * FROM solana_trades -UNION ALL -SELECT * FROM sui_trades; +SELECT * FROM solana_trades; From 16776245a868ace4b09f4e6788dc2c653faeaec5 Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Thu, 8 Jan 2026 15:16:49 +0100 Subject: [PATCH 6/6] added model without evm view step for testing --- .../trades/dex_multichain_trades_direct.sql | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql new file mode 100644 index 00000000000..c0942a81f8b --- /dev/null +++ b/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql @@ -0,0 +1,59 @@ +{{ config( + schema = 'dex_multichain' + , alias = 'trades_direct' + , materialized = 'view' + ) +}} + +WITH + +evm_trades AS ( + SELECT + blockchain, + block_time AS timestamp, + block_date AS date, + block_number, --not very chain agnostic + CONCAT('0x', LOWER(TO_HEX(tx_hash))) AS tx_id, + CONCAT('0x', LOWER(TO_HEX(taker))) AS trader_id, + project, + CONCAT('0x', LOWER(TO_HEX(project_contract_address))) AS pool_id, + token_pair, + token_bought_symbol, + token_sold_symbol, + token_bought_amount, + token_sold_amount, + token_bought_amount_raw, + token_sold_amount_raw, + amount_usd, + CONCAT('0x', LOWER(TO_HEX(token_bought_address))) AS token_bought_id, + CONCAT('0x', LOWER(TO_HEX(token_sold_address))) AS token_sold_id + FROM {{ source('dex', 'trades') }} +), + +solana_trades AS ( + SELECT + 'solana' AS blockchain, + block_time AS timestamp, + block_date AS date, + block_slot AS block_number, + tx_id, + trader_id, + project, + project_program_id AS pool_id, + token_pair, + token_bought_symbol, + token_sold_symbol, + token_bought_amount, + token_sold_amount, + token_bought_amount_raw, + token_sold_amount_raw, + amount_usd, + token_bought_mint_address AS token_bought_id, + token_sold_mint_address AS token_sold_id + FROM {{ source('dex_solana', 'trades') }} +) + +SELECT * FROM evm_trades +UNION ALL +SELECT * FROM solana_trades; +