adriaparcerisasSushiswap impermanent loss 3
Updated 2023-06-29
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 polygon_raw as (
select
block_timestamp::date as date,
case when token_in = '0x2791bca1f2de4661ed88a30c99a7a9449aa84174' then amount_in/amount_out else amount_out/amount_in end as price,
row_number() over (partition by block_timestamp::date order by block_timestamp) as nomor_asc,
row_number() over (partition by block_timestamp::date order by block_timestamp desc) as nomor_dsc
from
polygon.core.ez_dex_swaps
where
contract_address = lower('{{Polygon_Pool_Address}}') --'0x34965ba0ac2451a34a0471f04cca3f990b8dea27'
and
amount_in_usd is not null
and
amount_out_usd is not null
)
, max_min_pol as (
select
date,
max(price) as max_price,
min(price) as min_price
from
polygon_raw
group by 1
)
, first_pol as (
select * from polygon_raw where nomor_asc = 1
)
, last_pol as (
select * from polygon_raw where nomor_dsc = 1
)
, fix_pol as (
select
a.date,
'sushi' as label,
(max_price + min_price + b.price + c.price)/4 as price
from
Run a query to Download Data