Query editor
with tokens as(select token as contract_address from hmx_arbitrum.CrossMarginService_evt_LogDepositCollateralgroup by token),glp_prices as (selectdate_trunc('day', block_time) as time,'sGLP' as symbol,18 as decimals,from_hex('0x5402b5f40310bded796c7d0f3ff6683f5c0cffdf') as contract_address,avg(price) as avg_pricefrom(selectevt_block_time as block_time,(usdgAmount * 1e18 / mintAmount) / 1e18 as pricefrom gmx_arbitrum.GlpManager_updated_evt_AddLiquidity) as p_glpwhere p_glp.block_time >= timestamp '2023-06-21 00:00'group by 1, 2, 3, 4),token_prices as (selectdate_trunc('day', minute) as time,p.symbol,p.decimals,t.contract_address,avg(price) as avg_pricefrom prices.usd pinner join tokens ton p.contract_address = t.contract_addresswhere p.minute >= timestamp '2023-06-21 00:00'group by 1, 2, 3, 4union all(select time, symbol, decimals, contract_address, avg_pricefrom glp_prices)union all(select time, symbol, decimals, contract_address, price as avg_pricefrom query_3186167 -- https://dune.com/queries/3186167)),full_token_date as(select full_date_token.date_ as date_ , full_date_token.contract_address as contract_address ,tp.symbol as symbol from(select date_ , contract_address from(select date_trunc('day', evt_block_time) as date_ from hmx_arbitrum.TradeService_evt_LogIncreasePosition group by 1)cross join tokens) full_date_tokenleft join token_prices tpon full_date_token.contract_address = tp.contract_address and full_date_token.date_ = tp.time