Query editor
with base as (select t1.call_tx_hash as tx_hash,t1.call_block_time as block_time,'linea' as blockchain,u.source,u.token,u.amountfrom foxconnect_linea.foxconnectus_call_withdraw as t1CROSS JOIN UNNEST(t1.sources, t1.tokens, t1.amounts) AS u (source, token, amount)union allselect t1.call_tx_hash as tx_hash,t1.call_block_time as block_time,'linea' as blockchain,u.source,u.token,u.amountfrom foxconnect_linea.foxconnect_call_withdraw as t1CROSS JOIN UNNEST(t1.sources, t1.tokens, t1.amounts) AS u (source, token, amount)union allselect t1.call_tx_hash as tx_hash,t1.call_block_time as block_time,'base' as blockchain,u.source,u.token,u.amountfrom foxconnect_base.w3card_call_withdraw as t1CROSS JOIN UNNEST(t1.sources, t1.tokens, t1.amounts) AS u (source, token, amount)),base_price as (select t1.*,case when t1.token=0x374D7860c4f2f604De0191298dD393703Cce84f3 then 0x176211869cA2b568f2A7D4EE941E073a821EE1ffwhen t1.token=0x3Bce82cf1A2bc357F956dd494713Fe11DC54780f then 0x5cb9073902f2035222b9749f8fb0c9bfe5527108else t1.tokenend as price_contract,case when t1.token=0x3Bce82cf1A2bc357F956dd494713Fe11DC54780f then 'gnosis'else t1.blockchainend as price_blockchainfrom base as t1),prices as (selectt1.*,t4.symbol,(t1.amount/power(10,t4.decimals))*coalesce(t2.price, t3.price) as USDfrom base_price as t1left join tokens.erc20 as t4 on t1.token=t4.contract_addressleft join prices.usd as t2 on t1.price_contract=t2.contract_address and t1.block_time=t2.minute and t1.price_blockchain=t2.blockchainleft join prices.hour as t3 on t1.price_contract=t3.contract_address and date_trunc('hour', t1.block_time)=t3.timestamp and t1.price_blockchain=t3.blockchain)select cast(t1.tx_hash as varchar) as tx_hash,t1.block_time,cast(t1.source as varchar) as "from",t1.symbol,t1.usd,t1.blockchainfrom prices as t1union all