maybeyonasgmx_arb_price
Updated 2022-08-09
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
›
⌄
with
eth_prices as (
select
hour,
price
from ethereum.core.fact_hourly_token_prices
where symbol = 'WETH'
),
gmx_price as (
select
block_timestamp,
1/ (pow(event_inputs:sqrtPriceX96,2)/pow(2,192)) as price_eth, --token0 in terms of token1
price,
price_eth*price as usd_value
from arbitrum.core.fact_event_logs a join eth_prices e on date_trunc(hour,block_timestamp) = hour
where contract_address in (
lower('0x80a9ae39310abf666a87c743d6ebbd0e8c42158e'),
lower('0x1aeedd3727a6431b8f070c0afaa81cc74f273882')
)
and topics[0] = '0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67'
)
select * from (
select
date_trunc(hour,block_timestamp) as date,
price as eth_price,
median(price_eth) as gmx_price_eth,
median(usd_value) as gmx_price_usd
from gmx_price
group by 1,2
)
order by date desc
Run a query to Download Data