Alexayv2 polygon - supply/witghdraw
Updated 2023-04-13Copy 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
›
⌄
with deposits as ( select date_trunc('day', block_timestamp) as day, sum(event_inputs:amount/1e18) as deposit
from polygon.core.fact_event_logs
where block_timestamp>=CURRENT_DATE-365 and
event_name = 'Deposit' and contract_address = '0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf'
and event_inputs:reserve = '0xd6df932a45c0f255f85145f286ea0b292b21c90b' -- Aave Token
group by day
order by day desc),
withdraws as ( select date_trunc('day', block_timestamp) as day, -sum(event_inputs:amount/1e18) as withdraw
from polygon.core.fact_event_logs
where block_timestamp >= CURRENT_DATE-365 AND
event_name='Withdraw' and contract_address ='0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf' --aave address
and event_inputs:token = '0xd6df932a45c0f255f85145f286ea0b292b21c90b' -- Aave token
group by day
order by day desc)
select d.day, d.deposit, w.withdraw, (d.deposit + w.withdraw) as net
from deposits d
full outer join withdraws w
on d.day = w.day
Run a query to Download Data