binhachonStability Fee (May 13) - mint burn amount
Updated 2022-05-18
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
›
⌄
with DAI_mint_burn_raw as (
select
date_trunc('week', block_timestamp) as blocktime,
sum(amount) as amount
from ethereum.udm_events
where contract_address = '0x6b175474e89094c44da98b954eedeac495271d0f'
and from_address = '0x0000000000000000000000000000000000000000'
group by blocktime
union all
select
date_trunc('week', block_timestamp) as blocktime,
-sum(amount) as amount
from ethereum.udm_events
where contract_address = '0x6b175474e89094c44da98b954eedeac495271d0f'
and to_address = '0x0000000000000000000000000000000000000000'
group by blocktime
),
DAI_mint_burn as (
select
blocktime,
sum(case when amount > 0 then amount else 0 end) as mint_amount,
sum(case when amount < 0 then amount else 0 end) as burn_amount,
sum(amount) as net_mint_amount
from DAI_mint_burn_raw
group by blocktime
)
select
blocktime,
mint_amount,
burn_amount,
net_mint_amount as "Weekly net minting amount",
avg("Weekly net minting amount") over (order by blocktime rows between 3 preceding and current row) as "4-week moving average",
sum(net_mint_amount) over (order by blocktime) as total_mint_amount
from DAI_mint_burn
Run a query to Download Data