From 4bd02ed7877c072a66172a0488b75f6ca5b4349e Mon Sep 17 00:00:00 2001 From: Son Do Date: Mon, 2 Dec 2024 15:51:50 -0800 Subject: [PATCH] Fixed Raydium Dex Volumes --- .../raydium/fact_solana_dex_token_prices.sql | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/models/staging/raydium/fact_solana_dex_token_prices.sql b/models/staging/raydium/fact_solana_dex_token_prices.sql index 25ab11dc..8ff9521b 100644 --- a/models/staging/raydium/fact_solana_dex_token_prices.sql +++ b/models/staging/raydium/fact_solana_dex_token_prices.sql @@ -53,13 +53,24 @@ priced_ratio as ( left join {{ ref("fact_raydium_token_prices") }} as token_prices on swap_pricing_data.date = token_prices.date and swap_pricing_data.priced_asset_address = token_prices.solana_mint_address where token_amount > 0 +), +solana_dex_token_prices as ( + select + date + , token_address + , avg(token_price_usd) as price + , count(*) as number_of_swaps + , count(distinct swapper) as unique_traders + from priced_ratio + group by 1, 2 + HAVING count(*) > 1000 and count(distinct swapper) > 50 ) -select - date +select + solana_dex_token_prices.date , token_address - , avg(token_price_usd) as price - , count(*) as number_of_swaps - , count(distinct swapper) as unique_traders -from priced_ratio -group by 1, 2 -HAVING count(*) > 1000 and count(distinct swapper) > 50 + , least(solana_dex_token_prices.price, token_prices.price) as price + , number_of_swaps + , unique_traders +from solana_dex_token_prices +left join {{ ref("fact_raydium_token_prices") }} as token_prices +on solana_dex_token_prices.date = token_prices.date and solana_dex_token_prices.token_address = token_prices.solana_mint_address