Query editor
with v9_trades as (withorders_v8_polygon_tmp as (selectevt_block_time as block_time,cast(user as varchar) as trader,cast(cast(json_extract(t, '$.pairIndex') as int) as uint256) as pair_index,cast(json_extract(t, '$.long') as boolean) as long,null as nft_bot,case orderTypewhen 0 then 'MARKET_OPEN'when 1 then 'MARKET_CLOSE'when 2 then 'LIMIT'when 3 then 'LIMIT'when 4 then 'TP'when 5 then 'SL'when 6 then 'LIQ'else 'UNKNOWN'end as "type",cast (cast(json_extract(t, '$.collateralAmount') as varchar) as uint256) as position_size_dai_temp,cast(json_extract(t, '$.leverage') as decimal) / 1e3 as leverage,cast(cast(json_extract(t, '$.index') as int) as uint256) as "index",cast(cast(json_extract(t, '$.openPrice') as VARCHAR) as uint256) as open_price,percentProfit / 1e12 as percent_profit,0.005 as close_feep2,evt_tx_hash as tx_hash,collateralPriceUsd,'8' as "version",priceImpactP,cast(json_extract(t, '$.collateralIndex') as int) as collateralIndexfromgains_network_polygon.GNSMultiCollatDiamond_evt_LimitExecutedwhereoraclePrice is not nullunionselectevt_block_time as block_time,cast(user as varchar) as trader,cast(cast(json_extract(t, '$.pairIndex') as int) as uint256) as pair_index,cast(json_extract(t, '$.long') as boolean) as long,null as nft_bot,case openwhen true then 'OPEN'when false then 'CLOSE'end as "type",cast (cast(json_extract(t, '$.collateralAmount') as varchar) as uint256) as position_size_dai_temp,cast(json_extract(t, '$.leverage') as decimal) / 1e3 as leverage,cast(cast(json_extract(t, '$.index') as int) as uint256) as "index",cast(cast(json_extract(t, '$.openPrice') as VARCHAR) as uint256