Query editor
-- =====================================================================-- NEAR VAULT METRICS DAILY: TVL + flows + fees time series for NEAR-- =====================================================================-- EVM OAV vaults come from Vault Metrics Daily (8092271), filtered to NEAR.-- Kamino SOL Balanced is not an EVM OAV proxy, so it is unioned in from the-- reporting-DB upload (dune.yieldxyz.dataset_kamino_tvl / _actions), attributed-- to NEAR via team_name = 'Defuse Labs'.-- * TVL is a WEEKLY Monday snapshot carried forward; pps_as_of exposes the-- real snapshot date so staleness is visible.-- * fees are 0: the Kamino vault runs performanceFeeBps = 0 and the-- Yield.xyz 7% project fee has no observed on-chain payout yet.-- Same grain as 8092271: one row per vault per day.-- Powers the Near dashboard (yieldxyz/near).-- =====================================================================WITH evm AS (SELECT day, client, report_name, vault_name, blockchain, und_symbol, vault_address,vault_shares, pps_as_of, tvl_underlying, tvl_usd, n_deposits, n_withdrawals,inflow_underlying, outflow_underlying, inflow_usd, outflow_usd, net_flow_usd,total_volume_usd, volume_usd_cumulative, harvest_count, fee_shares,fees_underlying, fees_usd, fees_usd_cumulative, underlying_usd_price,unique_depositors, client_unique_addresses, total_unique_addressesFROM query_8092271WHERE client = 'NEAR'),kam_days AS (SELECT d.dayFROM (SELECT sequence(DATE '2026-06-19', CAST(DATE_TRUNC('day', NOW()) AS DATE), INTERVAL '1' DAY) AS s) tCROSS JOIN UNNEST(t.s) AS d(day)),kam_snap AS (SELECT CAST(event_date AS DATE) AS snapshot_day,SUM(CAST(amount AS DOUBLE)) AS tvl_underlying,SUM(CAST(usd_amount AS DOUBLE)) AS tvl_usd,COUNT(DISTINCT address) AS holdersFROM dune.yieldxyz.dataset_kamino_tvlWHERE integration_id = 'solana-kamino-sol-dccrsdum-vault'AND partner = 'NEAR'AND CAST(is_partner_facing AS VARCHAR) IN ('true', 't', '1', 'TRUE')GROUP BY 1),kam_carry AS (SELECT d.day,max_by(k.tvl_underlying, k.snapshot_day) AS tvl_underlying,max_by(k.tvl_usd, k.snapshot_day) AS tvl_usd,max_by(k.holders, k.snapshot_day) AS holders,MAX(k.snapshot_day) AS snapshot_dayFROM kam_days dLEFT JOIN kam_snap k ON k.snapshot_day <= d.dayGROUP BY 1),kam_act AS (SELECT CAST(action_date AS DATE) AS day,COUNT(CASE WHEN action_type IN ('STAKE','DEPOSIT') THEN 1 END) AS n_deposits,COUNT(CASE WHEN action_type NOT IN ('STAKE','DEPOSIT') THEN 1 END) AS n_withdrawals,SUM(CASE WHEN action_type IN ('STAKE','DEPOSIT') THEN CAST(amount AS DOUBLE) ELSE 0 END) AS inflow_underlying,SUM(CASE WHEN action_type NOT IN ('STAKE','DEPOSIT') THEN CAST(amount AS DOUBLE) ELSE 0 END) AS outflow_underlying,SUM(CASE WHEN action_type IN ('STAKE','DEPOSIT') THEN CAST(usd_amount AS DOUBLE) ELSE 0 END) AS inflow_usd,SUM(CASE WHEN action_type NOT IN ('STAKE','DEPOSIT') THEN CAST(usd_amount AS DOUBLE) ELSE 0 END) AS outflow_usd,COUNT(DISTINCT address) AS addrs