Query editor
-- YS - LP Tracker: Gas Cost Breakdown-- Gas costs by operation type for all LP transactions-- Multi-chainWITH wallet AS (SELECT {{wallet_address}} AS addr),owned_tokens AS (SELECT DISTINCT chain, tokenIdFROM uniswap_v3_multichain.nonfungiblepositionmanager_evt_transferWHERE "to" = (SELECT addr FROM wallet)AND evt_block_date >= DATE '2021-05-01'),-- Rank increases to distinguish Mint vs Addincrease_ranks AS (SELECT chain, tokenId, evt_tx_hash, evt_block_time,ROW_NUMBER() OVER (PARTITION BY chain, tokenId ORDER BY evt_block_time, evt_tx_hash) AS rnFROM uniswap_v3_multichain.nonfungiblepositionmanager_evt_increaseliquidityWHERE (chain, tokenId) IN (SELECT chain, tokenId FROM owned_tokens)AND evt_block_date >= DATE '2021-05-01'),-- All operations with type labelsall_ops AS (SELECTchain,CASE WHEN rn = 1 THEN 'Mint' ELSE 'Add Liquidity' END AS operation_type,evt_tx_hash AS tx_hash,evt_block_timeFROM increase_ranksUNION ALLSELECTchain,'Remove Liquidity',evt_tx_hash,evt_block_timeFROM uniswap_v3_multichain.nonfungiblepositionmanager_evt_decreaseliquidityWHERE (chain, tokenId) IN (SELECT chain, tokenId FROM owned_tokens)AND evt_block_date >= DATE '2021-05-01'UNION ALLSELECTchain,'Collect',evt_tx_hash,evt_block_timeFROM uniswap_v3_multichain.nonfungiblepositionmanager_evt_collectWHERE (chain, tokenId) IN (SELECT chain, tokenId FROM owned_tokens)AND evt_block_date >= DATE '2021-05-01'),-- Deduplicate: one tx may appear multiple times, take the first operation type per chain+txdeduped AS (SELECT chain, operation_type, tx_hash, evt_block_time,ROW_NUMBER() OVER (PARTITION BY chain, tx_hash ORDER BY