Query editor
with dates as (select datefrom unnest(sequence(date '2024-03-14', current_date)) as c(date)), lp_amounts as (selectd.date, t.token_address,casewhen t.wallet_address = 0x6d33206adB1462992C642BA5dD4F4e16bEb4D047 then 'uniswapv3'when t.wallet_address = 0x66d93F2e6C7Fbcb1B81cDEB48E95A019835f1a71 then 'aerodrome'when t.wallet_address = 0x5F94Ad60d862fD34c98b463614f3a64363F90fEE then 'aerodrome-CL'end source,-- both WETH and ROCK use 18 decimalssum(cast(t.amount_raw as decimal))/1e18 amountfrom dates djoin transfers_base.erc20 t on t.evt_block_time <= d.datewhere (-- uniswap V3 ROCK-WETHt.wallet_address = 0x6d33206adB1462992C642BA5dD4F4e16bEb4D047-- aerodrome ROCK-WETHor t.wallet_address = 0x66d93F2e6C7Fbcb1B81cDEB48E95A019835f1a71-- aerodrome ROCK-WETH concentrated liquidityor t.wallet_address = 0x5F94Ad60d862fD34c98b463614f3a64363F90fEE)and t.token_address in (0xEcE7B98bD817ee5B1F2f536dAf34D0B6af8Bb542, 0x4200000000000000000000000000000000000006)group by d.date, t.token_address, t.wallet_address), weth_prices as (-- prices don't include ROCK, likely need to be top X coinselect contract_address, symbol, date(minute) "date", pricefrom (select *, rank() over (partition by contract_address, date(minute) order by minute desc) as rnkfrom prices.usdwhere blockchain = 'base'and contract_address in (0x4200000000000000000000000000000000000006)) twhere rnk = 1), lp_by_date as (select a.date, a.token_address, a.source, a.amount, coalesce(w.price, r.price) pricefrom lp_amounts aleft join weth_prices won w.contract_address = a.token_addressand w.date = a.date-- rock pricesleft join query_3557966 ron a.token_address = 0xEcE7B98bD817ee5B1F2f536dAf34D0B6af8Bb542and r.block_date = a.date)selectdate,source,sum(amount*price) notionalfrom lp_by_dategroup by date, sourceorder by date, source