Query editor
WITH LP_Lock_ETH as (SELECT _lpToken, CAST(_amount as double) as amount, call_block_time, from_unixtime(CAST(_unlock_date AS DOUBLE)) as _unlock_date, sequence(date('2020-12-01'), date(current_date), interval '1' MONTH) AS date_arrayFROM unicrypt_ethereum.UniswapV2Locker_call_lockLPToken -- LP Lock function callWHERE call_success = true --Only pull data for successful function callsAND contract_address = 0x663a5c229c09b049e36dcc11a9b0d4a8eb9db214-- 0x663a5c229c09b049e36dcc11a9b0d4a8eb9db214 -> Uniswap (14,389 lock calls)-- 0xed9180976c2a4742c7a57354fd39d8bec6cbd8ab -> SushiSwap (42 lock calls) 0.29%-- This is for testing, Should shorten the query lengths and see is the results are correct-- AND _lpToken IN (lower(''), lower(''), lower(''))), Lock_ETH AS (SELECT SUM(amount) AS _amount, _lpToken, date_pointFROM (SELECT _lpToken, amount, call_block_time, _unlock_date,b.channel as date_pointFROM LP_Lock_ETH aCROSS JOIN UNNEST(a.date_array) as b(channel))WHERE date_point > call_block_time AND date_point < _unlock_date-- we do not use _unlock_date + 1 month because the Lock isnt lock at the start of the next month, so therefore we do not count itGROUP BY _lpToken, date_pointORDER BY _lpToken, date_point), ETH_TokenPairs as (-- collects all token pair contracts based on LP_Locks (~1 min run time)SELECT a.token0 AS TokenA, a.token1 AS TokenB, b.*FROM uniswap_v2_ethereum.Factory_evt_PairCreated a-- FROM pancakeswap_v2_bnb.PancakePair_call_initialize a aRIGHT JOIN Lock_ETH b ON a.pair = b._lpTokenORDER BY _lpToken, date_point) select block_month, blockchain, token_pair,_lpToken, sum(amount_usd) as usd_amtfrom ETH_TokenPairs e left joindex.trades t on e._lpToken=t.project_contract_addresswhere t.blockchain in ('ethereum','base')and t.block_date >= date '2024-06-01'group by block_month, blockchain, token_pair,_lpToken having sum(amount_usd)>100000order by blockchain, block_month, usd_amt desc