Query editor
withthe_granary_fantom_interest as (selectg.reserve,t.symbol,date_trunc('hour', g.evt_block_time) as hour,avg(CAST(g.liquidityRate AS DOUBLE)) / 1e27 as deposit_apy,avg(CAST(g.stableBorrowRate AS DOUBLE)) / 1e27 as stable_borrow_apy,avg(CAST(g.variableBorrowRate AS DOUBLE)) / 1e27 as variable_borrow_apyfrom the_granary_fantom.LendingPool_evt_ReserveDataUpdated gleft join tokens.erc20 ton g.reserve = t.contract_addresswhere t.symbol in ( 'USDT', 'fUSDT')group by 1,2,3),the_granary_arbitrum_interest as (selectg.reserve,t.symbol,date_trunc('hour', g.evt_block_time) as hour,avg(CAST(g.liquidityRate AS DOUBLE)) / 1e27 as deposit_apy,avg(CAST(g.stableBorrowRate AS DOUBLE)) / 1e27 as stable_borrow_apy,avg(CAST(g.variableBorrowRate AS DOUBLE)) / 1e27 as variable_borrow_apyfrom the_granary_arbitrum.LendingPool_evt_ReserveDataUpdated gleft join tokens.erc20 ton g.reserve = t.contract_addresswhere t.symbol in ( 'USDT', 'fUSDT')group by 1,2,3),the_granary_optimism_interest as (selectg.reserve,t.symbol,date_trunc('hour', g.evt_block_time) as hour,avg(CAST(g.liquidityRate AS DOUBLE)) / 1e27 as deposit_apy,avg(CAST(g.stableBorrowRate AS DOUBLE)) / 1e27 as stable_borrow_apy,avg(CAST(g.variableBorrowRate AS DOUBLE)) / 1e27 as variable_borrow_apyfrom the_granary_optimism.LendingPool_evt_ReserveDataUpdated gleft join tokens.erc20 ton g.reserve = t.contract_addresswhere t.symbol in ( 'USDT', 'fUSDT')group by 1,2,3),all_chains_interest AS (SELECT 'fantom' AS chain, * FROM the_granary_fantom_interestUNION ALLSELECT 'arbitrum' AS chain, * FROM the_granary_arbitrum_interestUNION ALLSELECT 'optimism' AS chain, * FROM the_granary_optimism_interest),gs AS (SELECTtimeFROMUNNEST (SEQUENCE(CAST(SUBSTR(CAST('2019-05-01' AS VARCHAR), 1, 10) AS DATE),CAST(SUBSTR(CAST(CURRENT_TIMESTAMP AS VARCHAR), 1, 10) AS DATE),INTERVAL '1' day) /* WARNING: Check out the docs for example of time series generation: https://dune.com/docs/query/syntax-differences/ */) AS _u (time)