Query editor
with pool_info as (select concat(format('USDC/ETH (%.2f', cast(fee as double)/10000),'%)') as poolName,pool--,cast(fee as double)/1000000 as fee--,tickSpacing,token0,token1,case when token0 = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 then 6else 18 end as decimals0,case when token1 = 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 then 6else 18 end as decimals1from uniswap_v3_ethereum.Factory_evt_PoolCreated where pool in (0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640, 0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8)and pool = {{pool}}) --select * from pool_info--select * from uniswap_v3_ethereum.Factory_evt_PoolCreated where pool in (0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640, 0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8),last_price as (select t0.pool, price0, price1 from (select pool, minute, price as price0 from prices.usd as pinner join pool_info as i on p.contract_address = i.token0where blockchain = 'ethereum' and minute >= date_trunc('day', now())order by minute desc limit 1) as t0inner join (select pool, minute, price as price1 from prices.usd as pinner join pool_info as i on p.contract_address = i.token1where blockchain = 'ethereum' and minute >= date_trunc('day', now())order by minute desc limit 1) as t1 on t0.pool = t1.pool) --select * from last_price-------------------------------------------------------------------------------------------- PREPROCESS DATA -----------------------------------------------------------------------------------------------------------------------------------------------------------------,id_to_lp as (select distinct pm.tokenId,e.to as lpfrom uniswap_v3_ethereum.NonfungibleTokenPositionManager_evt_IncreaseLiquidity as pminner join erc721_ethereum.evt_Transfer as eon pm.contract_address = e.contract_address and pm.tokenId = e.tokenIdwhere pm.contract_address = 0xc36442b4a4522e871399cd717abdd847ab11fe88 and e."from" = 0x0000000000000000000000000000000000000000) --select * from id_to_lp,lp_data as (-- MINT ------------------------------------------------------------select i.pool,m.evt_block_time as time_at,1 as event_type,case when m.owner = 0xc36442b4a4522e871399cd717abdd847ab11fe88 then id.lpelse m.owner end as lp,-cast(m.amount0 as double) / pow(10, i.decimals0) as amount0,-cast(m.amount1 as double) / pow(10, i.decimals1) as amount1from uniswap_v3_ethereum.Pair_evt_Mint as minner join pool_info as ion i.pool = m.contract_addressleft join uniswap_v3_ethereum.NonfungibleTokenPositionManager_evt_IncreaseLiquidity as pmon m.owner = pm.contract_address and m.evt_tx_hash = pm.evt_tx_hashinner join id_to_lp as idon pm.tokenId = id.tokenId