Afonso_Diaz2023-08-13 12:58 AM
Updated 2023-08-12
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
›
⌄
with t1 as (
select date(block_timestamp) as date,
token_in ,
(sum(amount_out)/sum(amount_in)) as price
from near.core.ez_dex_swaps
where token_out = 'wNEAR'
and amount_out > 0 and amount_in > 0
and date >= current_date - 14
and token_in ilike '%sweat%'
group by 1, 2
),
t2 as (
select timestamp::date as date,
'Near' as symbol,
avg(price_usd) as near_price_usd
from near.core.fact_prices
where token = 'LiNEAR'
and timestamp >= current_date - 14
group by 1, 2
),
t3 as (
select
t2.date,
price * near_price_usd as sweat_price_usd
from t2 left join t1
using(date)
)
select
t2.date,
sweat_price_usd,
near_price_usd
from t2
left join t3
Run a query to Download Data