iamnoneUSDC_Comp_ROI
Updated 2021-08-10
999
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
›
⌄
SELECT
to_varchar(a.block_timestamp::DATE,'yyyy-mm-dd') as b_date,
a.block_date,
avg(supply_apy),
avg(borrow_apy),
avg(comp_apy_borrow),
avg(comp_apy_supply),
sum(yvault_deposit) as a_yvault_deposit,
sum(yvault_withdraw) as a_yvault_withdraw,
sum(comp_deposit) as a_comp_deposit,
sum(comp_withdraw) as a_comp_withdraw,
sum(a_comp_deposit) over (order by a.block_date rows between unbounded preceding and current row ) * (avg(supply_apy)/365) as a_supply_rewards,
sum(a_comp_withdraw) over (order by a.block_date rows between unbounded preceding and current row ) * (avg(supply_apy)/365) as a_borrow_rewards,
sum(uni_deposit) as a_uni_deposit,
(sum(a_yvault_deposit) over (order by a.block_date rows between unbounded preceding and current row )
- sum(a_yvault_withdraw) over (order by a.block_date rows between unbounded preceding and current row )) as a_total_deposits,
(a_supply_rewards+a_uni_deposit) - a_borrow_rewards as a_total_rewards,
a_total_rewards/(sum(a_yvault_deposit) over (order by a.block_date rows between unbounded preceding and current row )
- sum(a_yvault_withdraw) over (order by a.block_date rows between unbounded preceding and current row )) *100 as roi,
roi * 365 as apy
from
(
select
d_comp.block_timestamp,
d_comp.block_timestamp::DATE as block_date,
d_comp.block_id as b_id,
d_yvault.block_id,
w_comp.block_id,
d_dydx.block_id,
d_comp.deposit as comp_deposit,
d_comp.deposit - w_comp.withdraw as total_deposit,
comp_deposit-d_dydx.deposit-d_uni.deposit as usdc_deposit,
w_comp.withdraw-w_dydx.withdraw as usdc_withdraw,