with transactions as (
select
block_timestamp,
raw_amount/1e18 as amount
from flipside_prod_db.ethereum_core.fact_token_transfers
where contract_address = '0x6b175474e89094c44da98b954eedeac495271d0f'
and from_address = '0x0000000000000000000000000000000000000000'
union all
select
block_timestamp,
-raw_amount/1e18 as amount
from flipside_prod_db.ethereum_core.fact_token_transfers
where contract_address = '0x6b175474e89094c44da98b954eedeac495271d0f'
and to_address = '0x0000000000000000000000000000000000000000'
)
select
date_trunc('month', block_timestamp) as time,
sum(amount) as monthly_minting,
sum(monthly_minting) over (order by time) as circulating_supply
from transactions
group by 1