Query editor
withend_strategy as (selecttopic1 as positionId,varbinary_ltrim (topic2) as owner,tx_hashfrom{{chain}}.logswheretopic0 = 0xe95aa63b1883254a4494c9e600f7509ec1a5a78dc2f6aef8214b6038d3c45834)select'{{chain}}' as chain,evt_block_time,evt_block_number,quantityDelta,COALESCE(es.owner, pu.owner) as owner,evt_tx_hash,pu.positionId,casewhen quantityDelta = 0 then 'Modification'else 'Trade'end as typefromcontango_v2_{{chain}}.Contango_evt_PositionUpserted puleft join end_strategy es on evt_tx_hash = tx_hashand pu.positionId = es.positionIdunionselectchain,evt_block_time,evt_block_number,quantityDelta,owner,evt_tx_hash,positionId,'Liquidation' as typefromdune.contango_xyz.result_all_liquidationswherechain = '{{chain}}'