mhmTable - Impermanent Loss on Ethereum
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 usdc_deposits as (
select block_number, block_timestamp, tx_hash, origin_from_address, amount_usd, amount
from ethereum.core.ez_token_transfers
where ORIGIN_FUNCTION_SIGNATURE = '0xf305d719'
and ORIGIN_TO_ADDRESS = '0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f' -- Sushiswap Router
and symbol in ('USDC')
and block_number between '14000000' and '15180000'
), eth_price as (
select hour::date as date, avg(price) as eth_price
from ethereum.core.fact_hourly_token_prices
where symbol = 'WETH'
and date = '2022-07-20' -- block 15180000
group by 1
)
select
-- weth_dep.block_number,
weth_dep.block_timestamp::date as date,
weth_dep.origin_from_address as lp_provider,
weth_dep.amount as weth_amount,
usdc_dep.amount as usdc_amount,
usdc_amount / weth_amount as exact_eth_price,
weth_amount * exact_eth_price as weth_amount_usd,
usdc_dep.amount_usd as usdc_amount_usd,
weth_amount_usd + usdc_amount_usd as "Total amount USD Deposited",
weth_amount_usd / usdc_amount_usd as "ETH/USDC Ratio",
weth_amount * eth_price as weth_amount_usd_new,
weth_amount_usd_new + usdc_amount_usd as "Total amount USD LAST",
weth_amount_usd_new / usdc_amount_usd as "ETH/USDC Ratio LAST",
"ETH/USDC Ratio LAST" - "ETH/USDC Ratio" as change_ratio,
"Total amount USD LAST" - "Total amount USD Deposited" as Impermanent_Loss_USD,
Run a query to Download Data