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 01/12] 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 02/12] 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 03/12] 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 04/12] 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 05/12] 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 06/12] 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; + From 5cfcad8587109c690b0a1713f38d75d089a68040 Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:12:57 +0100 Subject: [PATCH 07/12] changed name and definition of executing_contract_address column --- dbt_subprojects/dex/models/trades/_schema.yml | 50 ++++++++++++++++++- .../models/trades/dex_multichain_trades.sql | 12 ++--- .../trades/dex_multichain_trades_direct.sql | 12 ++--- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/dbt_subprojects/dex/models/trades/_schema.yml b/dbt_subprojects/dex/models/trades/_schema.yml index 6aff3c511b7..10bb69a3e48 100644 --- a/dbt_subprojects/dex/models/trades/_schema.yml +++ b/dbt_subprojects/dex/models/trades/_schema.yml @@ -6,7 +6,7 @@ models: 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, flare, boba, sonic, corn, berachain, sophon 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. + short_description: The `dex.trades` table captures detailed data on trades executed via decentralized exchanges (DEXs) on EVM chains. This table contains a detailed breakdown of trade execution containing one or many trades per transaction. contributors: 0xRob, hosuke, jeff-dude, tomfutago, viniabussafi config: tags: [ 'dex', 'trades'] @@ -84,3 +84,51 @@ models: - &evt_index name: evt_index description: "Index of the event in the transaction. Can be used to uniquely identify the order of trades within in a transaction" + + - name: dex_multichain_trades + meta: + blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei, ronin, flare, boba, sonic, corn, berachain, sophon, solana + sector: dex + short_description: Unified view of trades executed via decentralized exchanges (DEXs) across EVM-compatible chains and Solana. This table contains detailed data on trade execution with standardized column names. + contributors: kryptaki + config: + tags: [ 'dex', 'trades', 'multichain'] + description: > + Chain-agnostic DEX trades table combining EVM and Solana trades with standardized column names for cross-chain analysis. + columns: + - name: blockchain + description: "Blockchain on which this trade occurred" + - name: timestamp + description: "UTC event block time" + - name: date + description: "UTC event block date" + - name: block_number + description: "Block number in which the trade occurred. On Solana, this is the block slot." + - name: tx_id + description: "The hash of the transaction that this trade was included in. On Solana, this is the tx_id." + - name: trader_id + description: "Address of the account which purchased tokens. On EVM chains, this is the taker address." + - name: project + description: "Name of the dex on which the trade occurred" + - name: executing_contract_address + description: "Address of the contract or program that executed the swap. On Solana, this is the program_main_id. On EVM chains this is the project_contract_address (which can be a pool contract, router/aggregator contract, singleton manager, or other contract associated with the DEX." + - name: token_pair + description: "Symbol pair for the tokens involved in the trade. e.g. 'ETH/USDC'. Always alphabetical order, not trade order." + - name: token_bought_symbol + description: "Symbol of the token bought in the trade" + - name: token_sold_symbol + description: "Symbol of the token sold in the trade" + - name: token_bought_amount + description: "Amount of the token bought in the display unit" + - name: token_sold_amount + description: "Amount of the token sold in the display unit" + - name: token_bought_amount_raw + description: "Amount of the token bought in the base unit" + - name: token_sold_amount_raw + description: "Amount of the token sold in the base unit" + - name: amount_usd + description: "USD value of the trade at time of execution. Can be null if we don't have enough data to calculate the value." + - name: token_bought_id + description: "Contract address of the token bought. For EVM chains, this is token_bought_address. For Solana, this is token_bought_mint_address." + - name: token_sold_id + description: "Contract address of the token sold. For EVM chains, this is token_sold_address. For Solana, this is token_sold_mint_address." diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql index 58f1d92042b..f163bb3b60c 100644 --- a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql +++ b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql @@ -13,10 +13,10 @@ evm_trades AS ( 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, + CAST(tx_hash AS VARCHAR) AS tx_id, + CAST(taker AS VARCHAR) AS trader_id, project, - CONCAT('0x', LOWER(TO_HEX(project_contract_address))) AS pool_id, + CAST(project_contract_address AS VARCHAR) AS executing_contract_address, token_pair, token_bought_symbol, token_sold_symbol, @@ -25,8 +25,8 @@ evm_trades AS ( 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 + CAST(token_bought_address AS VARCHAR) AS token_bought_id, + CAST(token_sold_address AS VARCHAR) AS token_sold_id FROM {{ ref('dex_evm_trades') }} ), @@ -39,7 +39,7 @@ solana_trades AS ( tx_id, trader_id, project, - project_program_id AS pool_id, + project_main_id AS executing_contract_address, token_pair, token_bought_symbol, token_sold_symbol, diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql index c0942a81f8b..b52b0e4b22e 100644 --- a/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql +++ b/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql @@ -13,10 +13,10 @@ evm_trades AS ( 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, + CAST(tx_hash AS VARCHAR) AS tx_id, + CAST(taker AS VARCHAR) AS trader_id, project, - CONCAT('0x', LOWER(TO_HEX(project_contract_address))) AS pool_id, + CAST(project_contract_address AS VARCHAR) AS executing_contract_address, token_pair, token_bought_symbol, token_sold_symbol, @@ -25,8 +25,8 @@ evm_trades AS ( 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 + CAST(token_bought_address AS VARCHAR) AS token_bought_id, + CAST(token_sold_address AS VARCHAR) AS token_sold_id FROM {{ source('dex', 'trades') }} ), @@ -39,7 +39,7 @@ solana_trades AS ( tx_id, trader_id, project, - project_program_id AS pool_id, + project_program_id AS executing_contract_address, token_pair, token_bought_symbol, token_sold_symbol, From 11469642a66c0ce9fc266d5f22120d398f9c615e Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Fri, 9 Jan 2026 11:46:25 +0100 Subject: [PATCH 08/12] reverted change to schema.yml for dex.trades --- dbt_subprojects/dex/models/trades/_schema.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbt_subprojects/dex/models/trades/_schema.yml b/dbt_subprojects/dex/models/trades/_schema.yml index 10bb69a3e48..8f3a26e6462 100644 --- a/dbt_subprojects/dex/models/trades/_schema.yml +++ b/dbt_subprojects/dex/models/trades/_schema.yml @@ -6,7 +6,7 @@ models: 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, flare, boba, sonic, corn, berachain, sophon sector: dex - short_description: The `dex.trades` table captures detailed data on trades executed via decentralized exchanges (DEXs) on EVM chains. This table contains a detailed breakdown of trade execution containing one or many trades per transaction. + 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 config: tags: [ 'dex', 'trades'] From 7c20cc32f53f41fb5779098dce6527aa77926801 Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Fri, 9 Jan 2026 13:13:54 +0100 Subject: [PATCH 09/12] fixed date column names and ref --- dbt_subprojects/dex/models/trades/_schema.yml | 16 +++++++++------- .../dex/models/trades/dex_multichain_trades.sql | 12 +++++++----- .../trades/dex_multichain_trades_direct.sql | 14 ++++++++------ 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/dbt_subprojects/dex/models/trades/_schema.yml b/dbt_subprojects/dex/models/trades/_schema.yml index 8f3a26e6462..3b3c826f303 100644 --- a/dbt_subprojects/dex/models/trades/_schema.yml +++ b/dbt_subprojects/dex/models/trades/_schema.yml @@ -98,20 +98,22 @@ models: columns: - name: blockchain description: "Blockchain on which this trade occurred" - - name: timestamp + - name: block_time description: "UTC event block time" - - name: date + - name: block_date description: "UTC event block date" + - name: block_month + description: "UTC event block month" - name: block_number description: "Block number in which the trade occurred. On Solana, this is the block slot." - name: tx_id - description: "The hash of the transaction that this trade was included in. On Solana, this is the tx_id." + description: "The hash of the transaction that this trade was included in (VARCHAR). On Solana, this is the tx_id." - name: trader_id - description: "Address of the account which purchased tokens. On EVM chains, this is the taker address." + description: "Address of the account which purchased tokens (VARCHAR). On EVM chains, this is the taker address." - name: project description: "Name of the dex on which the trade occurred" - name: executing_contract_address - description: "Address of the contract or program that executed the swap. On Solana, this is the program_main_id. On EVM chains this is the project_contract_address (which can be a pool contract, router/aggregator contract, singleton manager, or other contract associated with the DEX." + description: "Address of the contract or program that executed the swap (VARCHAR). On Solana, this is the project_main_id. On EVM chains this is the project_contract_address (which can be a pool contract, router/aggregator contract, singleton manager, or other contract associated with the DEX)." - name: token_pair description: "Symbol pair for the tokens involved in the trade. e.g. 'ETH/USDC'. Always alphabetical order, not trade order." - name: token_bought_symbol @@ -129,6 +131,6 @@ models: - name: amount_usd description: "USD value of the trade at time of execution. Can be null if we don't have enough data to calculate the value." - name: token_bought_id - description: "Contract address of the token bought. For EVM chains, this is token_bought_address. For Solana, this is token_bought_mint_address." + description: "Contract address of the token bought (VARCHAR). For EVM chains, this is token_bought_address. For Solana, this is token_bought_mint_address." - name: token_sold_id - description: "Contract address of the token sold. For EVM chains, this is token_sold_address. For Solana, this is token_sold_mint_address." + description: "Contract address of the token sold (VARCHAR). For EVM chains, this is token_sold_address. For Solana, this is token_sold_mint_address." \ No newline at end of file diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql index f163bb3b60c..b6f56332fd8 100644 --- a/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql +++ b/dbt_subprojects/dex/models/trades/dex_multichain_trades.sql @@ -10,9 +10,10 @@ WITH evm_trades AS ( SELECT blockchain, - block_time AS timestamp, - block_date AS date, - block_number, --not very chain agnostic + block_time, + block_date, + block_month, + block_number, CAST(tx_hash AS VARCHAR) AS tx_id, CAST(taker AS VARCHAR) AS trader_id, project, @@ -33,8 +34,9 @@ evm_trades AS ( solana_trades AS ( SELECT 'solana' AS blockchain, - block_time AS timestamp, - block_date AS date, + block_time, + block_date, + block_month, block_slot AS block_number, tx_id, trader_id, diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql index b52b0e4b22e..1847b8149b2 100644 --- a/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql +++ b/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql @@ -10,9 +10,10 @@ WITH evm_trades AS ( SELECT blockchain, - block_time AS timestamp, - block_date AS date, - block_number, --not very chain agnostic + block_time, + block_date, + block_month, + block_number, CAST(tx_hash AS VARCHAR) AS tx_id, CAST(taker AS VARCHAR) AS trader_id, project, @@ -27,14 +28,15 @@ evm_trades AS ( amount_usd, CAST(token_bought_address AS VARCHAR) AS token_bought_id, CAST(token_sold_address AS VARCHAR) AS token_sold_id - FROM {{ source('dex', 'trades') }} + FROM {{ ref('dex_trades') }} ), solana_trades AS ( SELECT 'solana' AS blockchain, - block_time AS timestamp, - block_date AS date, + block_time, + block_date, + block_month, block_slot AS block_number, tx_id, trader_id, From 873432392a3c59494ebb94e14e059972792045a8 Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:36:32 +0100 Subject: [PATCH 10/12] deleted test view and cleaned up schema --- dbt_subprojects/dex/models/trades/_schema.yml | 76 ++++++++++++------- .../trades/dex_multichain_trades_direct.sql | 61 --------------- 2 files changed, 49 insertions(+), 88 deletions(-) delete mode 100644 dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql diff --git a/dbt_subprojects/dex/models/trades/_schema.yml b/dbt_subprojects/dex/models/trades/_schema.yml index 3b3c826f303..d1ad5bcc844 100644 --- a/dbt_subprojects/dex/models/trades/_schema.yml +++ b/dbt_subprojects/dex/models/trades/_schema.yml @@ -85,51 +85,73 @@ models: name: evt_index description: "Index of the event in the transaction. Can be used to uniquely identify the order of trades within in a transaction" + - name: dex_evm_trades + meta: + blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei, ronin, flare, boba, sonic, corn, berachain, sophon + sector: dex + short_description: DEX trades data across all EVM-compatible networks. Use this model when you need to query EVM DEX trades specifically, or use dex_multichain.trades if you need data from both EVM and non-EVM chains. This model contains the same data as dex.trades + contributors: kryptaki + config: + tags: [ 'dex', 'trades', 'evm'] + description: '{{ doc("dex_trades_doc") }}' + columns: + - <<: *blockchain + - <<: *project + - <<: *version + - <<: *block_month + - <<: *block_date + - <<: *block_time + - <<: *block_number + - <<: *token_bought_symbol + - <<: *token_sold_symbol + - <<: *token_pair + - <<: *token_bought_amount + - <<: *token_sold_amount + - <<: *token_bought_amount_raw + - <<: *token_sold_amount_raw + - <<: *amount_usd + - <<: *token_bought_address + - <<: *token_sold_address + - <<: *taker + - <<: *maker + - <<: *project_contract_address + - <<: *tx_hash + - <<: *tx_from + - <<: *tx_to + - <<: *evt_index + - name: dex_multichain_trades meta: blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei, ronin, flare, boba, sonic, corn, berachain, sophon, solana sector: dex - short_description: Unified view of trades executed via decentralized exchanges (DEXs) across EVM-compatible chains and Solana. This table contains detailed data on trade execution with standardized column names. + short_description: Detailed data on trades executed via decentralized exchanges (DEXs) across EVM-compatible chains and Solana. For EVM-only transfers, use tokens_evm.transfers, and for Solana-only transfers, use tokens_solana.transfers. contributors: kryptaki config: tags: [ 'dex', 'trades', 'multichain'] description: > Chain-agnostic DEX trades table combining EVM and Solana trades with standardized column names for cross-chain analysis. columns: - - name: blockchain - description: "Blockchain on which this trade occurred" - - name: block_time - description: "UTC event block time" - - name: block_date - description: "UTC event block date" - - name: block_month - description: "UTC event block month" + - <<: *blockchain + - <<: *block_time + - <<: *block_date + - <<: *block_month - name: block_number description: "Block number in which the trade occurred. On Solana, this is the block slot." - name: tx_id description: "The hash of the transaction that this trade was included in (VARCHAR). On Solana, this is the tx_id." - name: trader_id description: "Address of the account which purchased tokens (VARCHAR). On EVM chains, this is the taker address." - - name: project - description: "Name of the dex on which the trade occurred" + - <<: *project - name: executing_contract_address description: "Address of the contract or program that executed the swap (VARCHAR). On Solana, this is the project_main_id. On EVM chains this is the project_contract_address (which can be a pool contract, router/aggregator contract, singleton manager, or other contract associated with the DEX)." - - name: token_pair - description: "Symbol pair for the tokens involved in the trade. e.g. 'ETH/USDC'. Always alphabetical order, not trade order." - - name: token_bought_symbol - description: "Symbol of the token bought in the trade" - - name: token_sold_symbol - description: "Symbol of the token sold in the trade" - - name: token_bought_amount - description: "Amount of the token bought in the display unit" - - name: token_sold_amount - description: "Amount of the token sold in the display unit" - - name: token_bought_amount_raw - description: "Amount of the token bought in the base unit" - - name: token_sold_amount_raw - description: "Amount of the token sold in the base unit" - - name: amount_usd - description: "USD value of the trade at time of execution. Can be null if we don't have enough data to calculate the value." + - <<: *token_pair + - <<: *token_bought_symbol + - <<: *token_sold_symbol + - <<: *token_bought_amount + - <<: *token_sold_amount + - <<: *token_bought_amount_raw + - <<: *token_sold_amount_raw + - <<: *amount_usd - name: token_bought_id description: "Contract address of the token bought (VARCHAR). For EVM chains, this is token_bought_address. For Solana, this is token_bought_mint_address." - name: token_sold_id diff --git a/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql b/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql deleted file mode 100644 index 1847b8149b2..00000000000 --- a/dbt_subprojects/dex/models/trades/dex_multichain_trades_direct.sql +++ /dev/null @@ -1,61 +0,0 @@ -{{ config( - schema = 'dex_multichain' - , alias = 'trades_direct' - , materialized = 'view' - ) -}} - -WITH - -evm_trades AS ( - SELECT - blockchain, - block_time, - block_date, - block_month, - block_number, - CAST(tx_hash AS VARCHAR) AS tx_id, - CAST(taker AS VARCHAR) AS trader_id, - project, - CAST(project_contract_address AS VARCHAR) AS executing_contract_address, - token_pair, - token_bought_symbol, - token_sold_symbol, - token_bought_amount, - token_sold_amount, - token_bought_amount_raw, - token_sold_amount_raw, - amount_usd, - CAST(token_bought_address AS VARCHAR) AS token_bought_id, - CAST(token_sold_address AS VARCHAR) AS token_sold_id - FROM {{ ref('dex_trades') }} -), - -solana_trades AS ( - SELECT - 'solana' AS blockchain, - block_time, - block_date, - block_month, - block_slot AS block_number, - tx_id, - trader_id, - project, - project_program_id AS executing_contract_address, - 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; - From d3987ac3cf87e98e44e88d34089a1da2d8e89ee9 Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Fri, 9 Jan 2026 15:54:09 +0100 Subject: [PATCH 11/12] removed sui source --- sources/_subprojects_outputs/daily_spellbook/_sources.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sources/_subprojects_outputs/daily_spellbook/_sources.yml b/sources/_subprojects_outputs/daily_spellbook/_sources.yml index 56a3083991f..fd5d2439f36 100644 --- a/sources/_subprojects_outputs/daily_spellbook/_sources.yml +++ b/sources/_subprojects_outputs/daily_spellbook/_sources.yml @@ -51,10 +51,6 @@ sources: - name: pools_metrics_daily - name: trades - - name: dex_sui - tables: - - name: trades - - name: utils tables: - name: days_table From 9adb9b33ba9628f90453df4f5de1fe5a2e15c2ff Mon Sep 17 00:00:00 2001 From: alicecha <110170331+alicecha@users.noreply.github.com> Date: Fri, 9 Jan 2026 16:44:39 +0100 Subject: [PATCH 12/12] fixed documentation --- dbt_subprojects/dex/models/trades/_schema.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dbt_subprojects/dex/models/trades/_schema.yml b/dbt_subprojects/dex/models/trades/_schema.yml index d1ad5bcc844..003e1b8955d 100644 --- a/dbt_subprojects/dex/models/trades/_schema.yml +++ b/dbt_subprojects/dex/models/trades/_schema.yml @@ -124,12 +124,12 @@ models: meta: blockchain: arbitrum, avalanche_c, base, bnb, celo, ethereum, fantom, gnosis, kaia, optimism, polygon, scroll, zksync, linea, blast, sei, ronin, flare, boba, sonic, corn, berachain, sophon, solana sector: dex - short_description: Detailed data on trades executed via decentralized exchanges (DEXs) across EVM-compatible chains and Solana. For EVM-only transfers, use tokens_evm.transfers, and for Solana-only transfers, use tokens_solana.transfers. + short_description: Detailed data on trades executed via decentralized exchanges (DEXs) across EVM-compatible chains and Solana. For EVM-only trades, use dex_evm.trades, and for Solana-only trades, use dex_solana.trades. contributors: kryptaki config: tags: [ 'dex', 'trades', 'multichain'] description: > - Chain-agnostic DEX trades table combining EVM and Solana trades with standardized column names for cross-chain analysis. + Multichain DEX trades table combining EVM and Solana trades with standardized column names for cross-chain analysis. columns: - <<: *blockchain - <<: *block_time @@ -143,7 +143,7 @@ models: description: "Address of the account which purchased tokens (VARCHAR). On EVM chains, this is the taker address." - <<: *project - name: executing_contract_address - description: "Address of the contract or program that executed the swap (VARCHAR). On Solana, this is the project_main_id. On EVM chains this is the project_contract_address (which can be a pool contract, router/aggregator contract, singleton manager, or other contract associated with the DEX)." + description: "Address of the contract or program that executed the swap (VARCHAR). On Solana, this is the program_main_id (e.g. Pump.fun AMM or Raydium Liquidity Pool V4). On EVM chains this is the project_contract_address (which can be a pool contract, router/aggregator contract, singleton manager, or other contract associated with the DEX)." - <<: *token_pair - <<: *token_bought_symbol - <<: *token_sold_symbol