theericstoneInterest Paid Out on Compound by Market by Day
Updated 2021-11-10
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 markets as (
select
distinct
ctoken_address,
ms.contract_name,
underlying_contract,
er.decimals as decimals
from
compound.market_stats ms
join
ethereum.token_prices_hourly er
on er.token_address = ms.underlying_contract
where ms.block_hour > current_timestamp - interval '12 hours'
and er.hour > current_timestamp - interval '12 hours'
),
token_prices as (
select block_hour,
ctoken_address,
token_price
from compound.market_stats
where block_hour > current_date - interval '31 days'
),
accruals as (
select block_timestamp,
m.contract_name as market_name,
ee.contract_address as market_contract_address,
m.decimals as decs,
cp.token_price as price,
(event_inputs:interestAccumulated / pow(10,decs)) * cp.token_price as interest_owed
from ethereum.events_emitted ee
join markets m on ee.contract_address = m.ctoken_address
join token_prices cp on cp.block_hour = date_trunc('hour',ee.block_timestamp) and cp.ctoken_address = ee.contract_address
and ee.event_name = 'AccrueInterest' and ee.block_timestamp > current_date - interval '31 days'
)
Run a query to Download Data