CartanGroupPYUSD Liquidity (Test) copy
Updated 2024-07-24
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 mattkstew / PYUSD Liquidity (Test) @ https://flipsidecrypto.xyz/mattkstew/q/XsEr58_SBsJF/pyusd-liquidity-test
with tab1 as (
select
date_trunc('hour', block_timestamp) as Date,
tx_from as User,
sum(-1*amount) as Total_PYUSD
from solana.core.fact_transfers
where tx_from in ('9tXiuRRw7kbejLhZXtxDxYs2REe43uH2e7k1kocgdM9B', '39GrsozbzM9Sg1U7EDnEtQ69fsVF3pmVtmV2DGDAQQJ5')
and mint like '2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo'
group by 1,2
UNION ALL
select
date_trunc('hour', block_timestamp) as Date,
tx_to as User,
sum(amount) as Total_PYUSD
from solana.core.fact_transfers
where tx_to in ('9tXiuRRw7kbejLhZXtxDxYs2REe43uH2e7k1kocgdM9B', '39GrsozbzM9Sg1U7EDnEtQ69fsVF3pmVtmV2DGDAQQJ5')
and mint like '2b1kV6DkPAnxd5ixfnxCpjxmKwqjjaYmCZfHsFu24GXo'
group by 1,2
)
select
Date,
case when user like '9tXiuRRw7kbejLhZXtxDxYs2REe43uH2e7k1kocgdM9B' then 'ORCA: USDC/PYUSD'
else 'ORCA: USDT/PYUSD' end as Pool,
sum(Total_PYUSD) as Balance_PYUSD,
SUM(sum(Total_PYUSD)) OVER (PARTITION BY Pool ORDER BY Date) AS Cumulative_Balance_PYUSD
from tab1
group by 1,2
order by 1 desc
QueryRunArchived: QueryRun has been archived