0xHaM-dSwap in Total
Updated 2022-09-20Copy Reference Fork
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 price as (
select
hour::date as date,
symbol,
decimals,
avg(price) as avg_price
from ethereum.core.fact_hourly_token_prices
where (symbol in ('USDC','MIM','LINK','USDT','WETH','WBTC','DAI','FRAX')
or token_address in ('0x1f9840a85d5af5bf1d1762f925bdaddc4201f984')) --UNI
group by 1,2,3
)
, gmx_swap as (
select
block_timestamp,
tx_hash,
event_inputs:sender as swapper,
event_inputs:inputToken as token_in,
case when Token_in = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8' then 'USDC' -- desimal = 6
when Token_in = '0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a' then 'MIM'
when Token_in = '0xf97f4df75117a78c1a5a0dbb814af92458539fb4' then 'LINK'
when Token_in = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' then 'WETH' -- desimal = 18
when Token_in = '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f' then 'WBTC' -- desimal = 8
when Token_in = '0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0' then 'UNI'
when Token_in = '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1' then 'DAI' -- desimal = 18
when Token_in = '0x17fc002b466eec40dae837fc4be5c67993ddbd6f' then 'FRAX'
when Token_in = '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9' then 'USDT' -- desimal = 6
else event_inputs:inputToken end as tokenIn_Symbol,
event_inputs:inputValue as tokenIn_Value,
event_inputs:outputToken as token_out,
case when Token_out = '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8' then 'USDC'
when Token_out = '0xfea7a6a0b346362bf88a9e4a88416b77a57d6c2a' then 'MIM'
when Token_out = '0xf97f4df75117a78c1a5a0dbb814af92458539fb4' then 'LINK'
when Token_out = '0x82af49447d8a07e3bd95bd0d56f35241523fbab1' then 'WETH'
when Token_out = '0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f' then 'WBTC'
when Token_out = '0xfa7f8980b0f1e64a2062791cc3b0871572f1f7f0' then 'UNI'
when Token_out = '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1' then 'DAI'
Run a query to Download Data