Query editor
WITHprices AS (SELECT*,ROW_NUMBER() OVER (PARTITION BYcontract_address,DATE_TRUNC('day', minute)ORDER BYminute DESC) AS rnFROMprices.usdWHEREminute > DATE_TRUNC('day', CURRENT_TIMESTAMP) - INTERVAL '{{time_range}}' dayand blockchain = '{{chain}}'),lpTxns AS (SELECTevt_block_time as time,evt_tx_hash as txn,amount0,amount1,tokenId,'add' as t_from{{v3table}}_evt_IncreaseLiquiditywhereevt_block_time > DATE_TRUNC('day', CURRENT_TIMESTAMP) - INTERVAL '{{time_range}}' dayUNIONSELECTevt_block_time as time,evt_tx_hash as txn,amount0,amount1,tokenId,'remove' as t_from{{v3table}}_evt_DecreaseLiquiditywhereevt_block_time > DATE_TRUNC('day', CURRENT_TIMESTAMP) - INTERVAL '{{time_range}}' day),lpTxns2 AS (SELECTlpTxns.*,from_hex(JSON_EXTRACT_SCALAR(mints.params, '$.token0')) as token0,from_hex(JSON_EXTRACT_SCALAR(mints.params, '$.token1')) as token1FROMlpTxnsLEFT JOIN {{v3table}}_call_mint mints ON lpTxns.tokenId = mints.output_tokenIdWHERE mints.call_success = true-- For some reason this txn is brokenAND mints.call_tx_hash != 0x5666e67c674c0aa9bd73a899c84ff8dc8263abcca4086630e7b63ad1bf8d3f28)SELECTDATE_TRUNC('day', lpTxns2.time) as time,t_,-- *,-- T0.price as t0price, T0.symbol as t0symbol, T0.decimals as t0decimals,