Query editor
-- JIT volume: total & percentage of LPs doing JIT over time, as well as profitability overall & on an individual basis.-- first get mint-burn events for the same nft that happen in the same blockwith jit_events as (selecti.evt_block_number as block_number,i.evt_block_time as block_time,date_trunc('minute', i.evt_block_time) as block_minute,i.evt_tx_hash as mint_tx_hash,i.tokenId as tokenId,i.amount0 as mint_amount0,i.amount1 as mint_amount1,d.evt_tx_hash as burn_tx_hash,d.amount0 as burn_amount0,d.amount1 as burn_amount1fromuniswap_v3_ethereum.NonfungibleTokenPositionManager_evt_IncreaseLiquidity iinner join uniswap_v3_ethereum.NonfungibleTokenPositionManager_evt_DecreaseLiquidity doni.evt_block_number = d.evt_block_number -- same blockand i.tokenId = d.tokenId -- same LP token idand i.evt_index < d.evt_index -- mint before burn),-- get pool_address from pool mint-burn eventsjit_pools as (selectj.*,m.contract_address as pool_addressfromjit_events jinner join uniswap_v3_ethereum.Pair_evt_Mint mon j.mint_tx_hash = m.evt_tx_hashinner join uniswap_v3_ethereum.Pair_evt_Burn bon j.burn_tx_hash = b.evt_tx_hashwhere m.contract_address = b.contract_address -- ensure same token pair),-- get the token0 and token1 addresses from pool creation eventsjit_tokens as (selectj.*,f.token0 as token0,f.token1 as token1fromjit_pools jinner join uniswap_v3_ethereum.Factory_evt_PoolCreated fon j.pool_address = f.pool),-- add in liquidity vol in usd, LP addresses, and profit info-- get burn amount usd using token0 and token1 usd prices at the time of JIT event-- LP addresses & collected fees from collect events-- gas costs deducted from collected fees to get profitjit_events_ext as (selectj.*,( p0.price * cast(burn_amount0 as double) / cast(pow(10, p0.decimals) as double) ) +( p1.price * cast(burn_amount1 as double) / cast(pow(10, p1.decimals) as double) ) as burn_amount_usd, -- usd volumec.recipient as lp_address,