Query editor
WITH native_deposits AS (SELECTevt_block_date AS block_date,chain,'native' AS token_type,CAST(amount AS double) / 1e18 AS amount_decimal,evt_tx_hashFROM relay_multichain.relaydepository_evt_relaynativedepositWHERE evt_block_date >= CURRENT_DATE - INTERVAL '90' DAY),erc20_deposits AS (SELECTevt_block_date AS block_date,chain,'erc20' AS token_type,token,amount,evt_tx_hashFROM relay_multichain.relaydepository_evt_relayerc20depositWHERE evt_block_date >= CURRENT_DATE - INTERVAL '90' DAY),-- Price native deposits using native token pricesnative_priced AS (SELECTn.block_date,n.chain,n.token_type,n.amount_decimal,n.amount_decimal * p.price AS amount_usd,n.evt_tx_hashFROM native_deposits nLEFT JOIN prices.usd_daily pON p.blockchain = n.chainAND p.contract_address = 0x0000000000000000000000000000000000000000AND p.day = n.block_date),-- Price ERC20 depositserc20_priced AS (SELECTe.block_date,e.chain,e.token_type,CAST(e.amount AS double) / POWER(10, COALESCE(t.decimals, 18)) AS amount_decimal,CAST(e.amount AS double) / POWER(10, COALESCE(t.decimals, 18)) * p.price AS amount_usd,e.evt_tx_hashFROM erc20_deposits eLEFT JOIN tokens.erc20 tON t.blockchain = e.chainAND t.contract_address = e.tokenLEFT JOIN prices.usd_daily pON p.blockchain = e.chainAND p.contract_address = e.tokenAND p.day = e.block_date),combined AS (SELECT block_date, chain, token_type, amount_usd, evt_tx_hash FROM native_pricedUNION ALLSELECT block_date, chain, token_type, amount_usd, evt_tx_hash FROM erc20_priced)