theericstoneexample PUNK - WETH swaps
Updated 2022-08-02
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 punkin as (
select
block_timestamp,
'$PUNK in ↪️' as direction,
amount_out_usd / (amount_in / pow(10,18)) as usd_per_punk,
amount_out / (amount_in / pow(10,18)) as weth_per_punk
from ethereum.core.ez_dex_swaps
where (
token_in = lower('0x269616D549D7e8Eaa82DFb17028d0B212D11232A') -- PUNK token
and token_out = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2') -- WETH
)
and block_timestamp > current_date - {{days}}
),
punkout as (
select
block_timestamp,
'$PUNK out ↩️' as direction,
amount_in_usd / (amount_out / pow(10,18)) as usd_per_punk,
amount_in / (amount_out / pow(10,18)) as weth_per_punk
from ethereum.core.ez_dex_swaps
where (
token_out = lower('0x269616D549D7e8Eaa82DFb17028d0B212D11232A')-- PUNK token
and token_in = lower('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2') -- WETH
)
and block_timestamp > current_date - {{days}}
)
select
block_timestamp::date as day,
avg(usd_per_punk) as usd_per_punk,
avg(weth_per_punk) as weth_per_punk
from
(select * from punkin where weth_per_punk < 130
UNION
select * from punkout where weth_per_punk < 130)
group by 1 order by 1 desc;
Run a query to Download Data