AephiaSAGE_prices (daily)_old
Updated 2024-11-03
999
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 SAGE_prices (daily) @ https://flipsidecrypto.xyz/edit/queries/226c5278-5517-4745-a6fe-509b5e59b5ec
WITH atlas_price AS (
select
--*
date_trunc('day', block_timestamp) as date,
sum(case when (swap_from_mint = 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx' AND swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
then swap_from_amount
when (swap_to_mint = 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx' AND swap_from_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
then swap_to_amount end) as ATLAS,
sum(case when (swap_from_mint = 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx' AND swap_to_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
then swap_to_amount
when (swap_to_mint = 'ATLASXmbPQxBUYbxPsV97usA3fPQYEqzQBUHgiFCUsXx' AND swap_from_mint = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v')
then swap_from_amount end) as USDC,
USDC / ATLAS as atlas_price
from solana.defi.fact_swaps
WHERE succeeded = 'true'
AND program_id IN ('JUP3c2Uh3WA4Ng34tw6kPd2G4C5BB21Xo36Je1s32Ph', 'JUP2jxvXaqu7NQY1GmNF4m1vodw12LVXYxbFL2uJvfo')
AND block_timestamp > '2023-09-27' --current_date-7 --AND block_timestamp < current_date
group by 1
),
sdu_and_gt_volumes AS (
select
--*
date_trunc('day', block_timestamp) as date,
----------------------------------------------------
sum(case when inner_instruction:instructions[2]:parsed:info:mint::string = 'SDUsgfSZaDhhZ76U3ZgvtFiXsfnHbf2VrzYxjBZ5YbM'
then inner_instruction:instructions[2]:parsed:info:tokenAmount:uiAmount
end) AS SDU_amount,
sum(case when inner_instruction:instructions[2]:parsed:info:mint::string = 'SDUsgfSZaDhhZ76U3ZgvtFiXsfnHbf2VrzYxjBZ5YbM'
AND inner_instruction:instructions[1]:parsed:info:mint::string = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'
then (inner_instruction:instructions[0]:parsed:info:tokenAmount:uiAmount + inner_instruction:instructions[1]:parsed:info:tokenAmount:uiAmount)
end) AS SDU_usdc_amount,
sum(case when inner_instruction:instructions[2]:parsed:info:mint::string = 'SDUsgfSZaDhhZ76U3ZgvtFiXsfnHbf2VrzYxjBZ5YbM'
QueryRunArchived: QueryRun has been archived