0xHaM-dMarinade Swap Over Time
Updated 2025-02-19
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
-- forked from Swap Over Time @ https://flipsidecrypto.xyz/studio/queries/f9a33527-ef4d-4fc4-bd4d-4102bae75457
with balanceTb as (
select
owner ,
balance
from solana.core.fact_token_balances
where mint = 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'
qualify row_number() over (partition by owner order by block_timestamp desc) = 1
)
, mnde_price as (
select
hour,
price as price
from solana.price.ez_prices_hourly
where symbol = 'MSOL'
)
select
trunc(BLOCK_TIMESTAMP,'week') as date,
avg(price) as price,
count(distinct TX_ID) as swaps,
count(distinct SWAPPER) as swappers,
sum(case when SWAP_FROM_MINT = 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So' then SWAP_FROM_AMOUNT_USD else 0 end) as swap_from_amount_usd,
sum(case when SWAP_TO_MINT = 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So' then SWAP_TO_AMOUNT_USD else 0 end) as swap_TO_amount_usd,
sum(coalesce(SWAP_FROM_AMOUNT_USD,SWAP_TO_AMOUNT_USD)) as swap_amount_usd,
sum(swaps) over (order by date) as total_swaps,
sum(swap_amount_usd) over (order by date) as total_swap_amount_usd
from solana.marinade.ez_swaps
join mnde_price on trunc(BLOCK_TIMESTAMP,'d') = trunc(hour,'d')
where (
SWAP_FROM_MINT = 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'
or SWAP_TO_MINT = 'mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So'
)
and SWAPPER in (select distinct owner from balanceTb)
group by 1
order by 1 desc
QueryRunArchived: QueryRun has been archived