maybeyonas3pool-swaps
Updated 2021-09-20
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
›
⌄
-- 0-DAI
-- 1-USDC
-- 2-USDT
with swaps as (
select --*
block_timestamp,
tx_id,
event_inputs:buyer::string as user,
case event_inputs:sold_id
when 0 then event_inputs:tokens_sold/pow(10,18)
else event_inputs:tokens_sold/pow(10,6) end as swap_in_amt,
case event_inputs:bought_id
when 0 then event_inputs:tokens_bought/pow(10,18)
else event_inputs:tokens_bought/pow(10,6) end as swap_out_amt,
case event_inputs:bought_id
when 0 then '0x6b175474e89094c44da98b954eedeac495271d0f'
when 1 then '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
else '0xdac17f958d2ee523a2206206994597c13d831ec7' end as token_out,
case event_inputs:sold_id
when 0 then '0x6b175474e89094c44da98b954eedeac495271d0f'
when 1 then '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
else '0xdac17f958d2ee523a2206206994597c13d831ec7' end as token_in,
case event_inputs:bought_id
when 0 then 'DAI'
when 1 then 'USDC'
else 'USDT' end as token_out_symbol,
case event_inputs:sold_id
when 0 then 'DAI'
when 1 then 'USDC'
else 'USDT' end as token_in_symbol
from ethereum.events_emitted
where
tx_succeeded = TRUE
and contract_address = lower('0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7')
and event_name = 'TokenExchange'
Run a query to Download Data