Query editor
withtrades AS (SELECT *FROM dex.tradesWHERE blockchain = 'base'),swaps AS (SELECT tx_hash AS tx, amount_usdFROM tradesWHERE project_contract_address = {{pool}}),transactions AS (SELECTtx,tx_from,tx_to,COALESCE(c.label, 'Unknown') AS caller--COALESCE(l.label, 'Unknown') AS sourceFROM (SELECT hash AS tx, "from" AS tx_from, "to" AS tx_toFROM base.transactionsWHERE hash in (SELECT tx FROM swaps)) q-- https://dune.com/queries/4320407--LEFT JOIN query_4320407 l ON q.tx_to = l.addressLEFT JOIN query_4320407 c ON q.tx_from = c.address),aggregate AS (SELECT s.tx, t.*FROM swaps sLEFT JOIN trades t ON s.tx = t.tx_hash),tokens AS (SELECT DISTINCT tx, tokenFROM (SELECT tx, token_bought_symbol AS token FROM aggregateUNIONSELECT tx, token_sold_symbol AS token FROM aggregate)),positions AS (SELECT tx, flagFROM (SELECT evt_tx_hash AS tx, true AS flagFROM aerodrome_base.NonfungiblePositionManager_evt_IncreaseLiquidityWHERE evt_tx_hash IN (SELECT tx FROM swaps)UNIONSELECT evt_tx_hash AS tx, true AS flagFROM aerodrome_base.NonfungiblePositionManager_evt_DecreaseLiquidityWHERE evt_tx_hash IN (SELECT tx FROM swaps))),query AS (SELECT DISTINCTblock_time,date_trunc('day', block_time) AS day,'<a href=https://basescan.org/tx/' || cast(a.tx as varchar) || ' target=_blank>' || 'BaseScan' ||'</a>' as basescan,a.tx,(SELECT SUM(amount_usd) FROM swaps s1 WHERE s1.tx = a.tx) AS pool_volume_usd,t.caller,