Query editor
with vault_info as (select * from query_2208104where vaultName = 'KWENTA-WETH (Optimism)')-------------------------------------------------------------------------------------------- AUX TABLES ----------------------------------------------------------------------------------------------------------------------------------------------------------------------,pools as (select distinct m.contract_address as pool,p.evt_tx_hash,v.vault,cast(p.fee as double) / 1e6 as fee,case when p.token0 = v.token0 then true else false end as vault_order_flagfrom uniswap_v3_optimism.Pair_evt_Mint as minner join vault_info as von v.deployBlock <= m.evt_block_number and v.vault = m.ownerinner join uniswap_v3_optimism.Factory_evt_PoolCreated as pon v.deployBlock > p.evt_block_number and p.evt_block_number > 0 and m.contract_address = p.pool -- bound between Arrakis vault and UniV3 factory deployment) --select * from pools-- use ethereum blocks table (12sec/entry) to generate a timeseries with a 1min interval,time_series as (select distinct date_trunc('day', b.time) as time_atfrom ethereum.blocks as binner join vault_info as von b.time >= v.startAt) --select * from time_series order by 1 asc-- use ethereum blocks table (12sec/entry) to generate a timeseries with a 1min interval,time_series_aux as (select distinct date_trunc('day', b.time) as time_atfrom ethereum.blocks as binner join vault_info as von b.time < v.startAt and b.time >= date('2022-12-16')) --select * from time_series order by 1 asc-------------------------------------------------------------------------------------------- GET POOL LIQUIDITY --------------------------------------------------------------------------------------------------------------------------------------------------------------,mint_burn as (-- mintselect date_trunc('day', m.evt_block_time) as time_at,m.tickLower,m.tickUpper,cast(m.amount as double) as liquidity,m.contract_addressfrom uniswap_v3_optimism.Pair_evt_Mint as minner join pools as pon m.evt_block_number > 0 and p.pool = m.contract_address --after UniV3 factory deploymentunion all-- burnselect date_trunc('day', b.evt_block_time) as time_at,b.tickLower,b.tickUpper,-cast(b.amount as double) as liquidity,b.contract_addressfrom uniswap_v3_optimism.Pair_evt_Burn as binner join pools as pon b.evt_block_number > 0 and p.pool = b.contract_address --after UniV3 factory deployment