Skip to content

Commit

Permalink
Fixed Raydium Dex Volumes (#654)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunny77D authored Dec 3, 2024
1 parent f3e180c commit 51ee398
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions models/staging/raydium/fact_solana_dex_token_prices.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 51ee398

Please sign in to comment.