Query editor
WITH iau_supply AS (SELECTevt_block_time AS time,contract_address AS token,SUM(CASEWHEN "to" = 0x0000000000000000000000000000000000000000 THEN -valueELSE valueEND) AS amountFROM treehouse_asset_ethereum.internalaccountingunit_teth_evt_transferWHERE contract_address = 0x1B6238E95bBCABEE58997c99BaDD4154ad68BA92AND ("to" = 0x0000000000000000000000000000000000000000 OR "from" = 0x0000000000000000000000000000000000000000)GROUP BY evt_block_time, contract_address), iau_supply_aggregated as (SELECTtime,LEAD(time) OVER (PARTITION BY token ORDER BY time) AS next_time,token,SUM(amount) OVER (PARTITION BY token ORDER BY time ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_supplyFROM iau_supplyORDER BY time DESC),teth_supply AS (SELECTevt_block_time AS time,contract_address AS token,SUM(CASEWHEN "to" = 0x0000000000000000000000000000000000000000 THEN -valueELSE valueEND) AS amountFROM treehouse_asset_ethereum.teth_evt_transferWHERE contract_address = 0xD11c452fc99cF405034ee446803b6F6c1F6d5ED8AND ("to" = 0x0000000000000000000000000000000000000000 OR "from" = 0x0000000000000000000000000000000000000000)GROUP BY evt_block_time, contract_address), teth_supply_aggregated as (SELECTtime,LEAD(time) OVER (PARTITION BY token ORDER BY time) AS next_time,token,SUM(amount) OVER (PARTITION BY token ORDER BY time ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_supplyFROM teth_supplyORDER BY time DESC), trh as(selecti.time,i.next_time,i.cumulative_supply as iau_supply,t.cumulative_supply as teth_supply,i.cumulative_supply*1.0/NULLIF(t.cumulative_supply, 0) AS teth_ratefrom iau_supply_aggregated ileft join teth_supply_aggregated t on i.time = t.time or i.next_time = t.next_timeorder by time desc),block_time_day as (