articoloquintoImpermanent Loss % distribution - Ethereum
Updated 2022-07-23
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 block_15180000 as (select avg(amount_out/amount_in) as "WETH price at block 15180000"
from ethereum.sushi.ez_swaps
where token_in = '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'
and token_out = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'
and block_number between 15179900 and 15180000)
select count(*) as "count",
case when "IL %" between -1 and 0 then '<= 1 %'
when "IL %" < -1 and "IL %" >= -2 then '> 1 <= 2 %'
when "IL %" < -2 and "IL %" >= -3 then '> 2 <= 3 %'
when "IL %" < -3 and "IL %" >= -4 then '> 3 <= 4 %'
when "IL %" < -4 and "IL %" >= -5 then '> 4 <= 5 %'
when "IL %" < -5 and "IL %" >= -6 then '> 5 <= 6 %'
when "IL %" < -6 and "IL %" >= -7 then '> 6 <= 7 %'
when "IL %" < -7 then '> 7 %' end as "%"
from(
select block_number as "block number",
tx_hash as "transaction hash",
origin_from_address as "liquidity provider",
event_inputs:amount1::numeric/1e18 as "amount WETH",
event_inputs:amount0::numeric/1e6 as "amount USDC",
"amount USDC"/"amount WETH" as "WETH price",
"amount USDC"+"amount WETH"*"WETH price" as "LP value in usd",
(select "WETH price at block 15180000" from block_15180000) as "WETH price at block 15180000",
("WETH price at block 15180000"-"WETH price")/"WETH price"*100 as "WETH price change %",
sqrt(("amount WETH"*"amount USDC")/"WETH price at block 15180000")*"WETH price at block 15180000"+
sqrt(("amount WETH"*"amount USDC")*"WETH price at block 15180000") as "LP value at block 15180000",
"amount WETH"*"WETH price at block 15180000"+"amount USDC" as "value of the tokens at block 15180000",
"LP value at block 15180000"-"value of the tokens at block 15180000" as "IL at block 15180000 in usd",
"IL at block 15180000 in usd"*100/"value of the tokens at block 15180000" as "IL %"
from ethereum.core.fact_event_logs
where block_number between 14000000 and 15180000
and origin_to_address = '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f'
and contract_address = '0x397ff1542f962076d0bfe58ea045ffa2d347aca0'
and event_name = 'Mint'
and tx_status = 'SUCCESS'
Run a query to Download Data