Query editor
select'{{chain}}' as chain,position_update.evt_block_time as timestamp,instrument.symbol as symbol,instrument.direction as direction,instrument.correlated as correlated,moneymarket.name as moneymarket,position_update.quantityDelta / instrument.base_unit as quantity,casewhen instrument.direction = 'long' then position_update.quantityDelta / instrument.base_unitelse position_update.quantityDelta / instrument.base_unit * base_price.price / quote_price.priceend as parsed_quantity,position_update.quantityDelta / instrument.base_unit * base_price.price as quantity_usd,position_update.owner as trader,position_update.evt_tx_hash as tx_hash,instrument.symbol_hash as symbol_hash,position_update.positionId as positionId,position_update.typefrom"query_3674932(chain='{{chain}}')" as position_updatejoin dune.contango_xyz.result_v2_money_markets as moneymarket on moneymarket.id = substr(position_update.positionId, 17, 1)join "query_3262665(chain='{{chain}}')" as instrument on instrument.symbol_hash = substr(position_update.positionId, 1, 16)-- enable and swap to the materialised view if performance is an issuejoin "query_3266503" as base_price on lower(base_price.symbol) = lower(instrument.base_symbol)and base_price.hour = date_trunc('hour', position_update.evt_block_time)join "query_3266503" as quote_price on lower(quote_price.symbol) = lower(instrument.quote_symbol)and quote_price.hour = date_trunc('hour', position_update.evt_block_time);