Query editor
-- =========================================-- Aster DEX Vault TVL (Top N Assets)-- Net flow (USD) per day -> cumulative TVL per asset-- Filtered to Top 10 assets by latest TVL-- =========================================WITH-- 1) Parametersparams AS (SELECTnow() - interval '3' month AS start_time,10 AS top_n -- <<< change this to your desired N),-- 2) Normalize deposits/withdrawals into signed flowsvault_moves AS (SELECTevt_block_time AS block_time,currency AS token_address,amount AS raw_amount,1 AS directionFROM astherus_bnb.AstherusVault_evt_DepositUNION ALLSELECTevt_block_time AS block_time,currency AS token_address,amount AS raw_amount,-1 AS directionFROM astherus_bnb.AstherusVault_evt_Withdraw),-- 3) Enrich with token metadata + minute pricemoves_priced AS (SELECTdate_trunc('day', m.block_time) AS day,m.token_address,COALESCE(t.symbol, CAST(m.token_address AS varchar)) AS asset,COALESCE(t.decimals, 18) AS decimals,CAST(m.raw_amount AS decimal(38, 0)) AS raw_amount,m.direction,p.price AS price_usdFROM vault_moves mCROSS JOIN params prmLEFT JOIN tokens.erc20 tON t.blockchain = 'bnb'AND t.contract_address = m.token_addressLEFT JOIN prices.usd pON p.blockchain = 'bnb'AND p.contract_address = m.token_addressAND p.minute = date_trunc('minute', m.block_time)WHERE m.block_time >= prm.start_time),-- 4) Daily net USD flow per assetdaily_flows AS (SELECTday,asset,