Query editor
-- Kasu platform metrics, per day and chain, all figures in USD.---- Three arms, two provenances -- the `source` column keeps them distinguishable:-- query_8816702 Base (USDC) -- queried from base.logs -> "Dune on-chain"-- query_8816718 Plume (pUSD) -- queried from plume.logs -> "Dune on-chain"-- dune.kasu.dataset_kasu_xdc_audd_daily-- XDC (AUDD) -- uploaded log scan -> "Uploaded log scan"---- TOTAL ACTIVE LENDING follows the app's definition: the lenders' pool-token claim-- plus the senior funding provided by the institutional lender, which sits-- off-protocol and is recorded on-chain by ops. The app shows the same amount as-- the "Senior" row of a strategy's lending options.---- That component is broken out as `institutional_senior_funding` because it is-- recorded by ops rather than derived from pool accounting -- subtract it for the-- purely chain-derived figure. It currently arises only on XDC; the equivalent-- register reads zero across Base, and Plume has none.---- EVERY ARM IS TRUNCATED TO THE COMMON `as_of` DATE. The on-chain arms advance-- daily by themselves while the XDC arm only moves when the scan is re-uploaded,-- so without this the newest day would carry Base and Plume but not XDC -- and the-- platform total would silently shed the whole XDC book for a day. Clipping to the-- oldest arm's last day keeps every series the same length and the totals honest;-- the cost is that the dashboard lags by however stale the upload is.---- USDC and pUSD are dollar-pegged (1:1). AUDD is AUD-pegged, so the XDC arm carries-- a per-day AUD->USD rate from Frankfurter -- the same source kasu-ui uses -- exposed-- as `fx_rate` so the conversion is checkable. No rate is interpolated or invented.---- Kasu's fourth deployment, XDC USDC, is omitted: all four pools read zero on every-- field, so it has never taken a deposit.WITH bounds AS (SELECT least((SELECT max(day) FROM query_8816702),(SELECT max(day) FROM query_8816718),(SELECT max(CAST(day AS date)) FROM dune.kasu.dataset_kasu_xdc_audd_daily)) AS as_of)SELECTb.as_of AS data_as_of,q.day,'Base (USDC)' AS chain,'Dune on-chain' AS source,CAST(NULL AS double) AS fx_rate,q.total_lent,q.total_active_lending,CAST(0 AS double) AS institutional_senior_funding,q.lender_interest_earned,q.fees_cumulative AS protocol_fees_accrued,q.revenue_cumulative AS protocol_fees_paid,q.losses_cumulativeFROM query_8816702 q CROSS JOIN bounds bWHERE q.day <= b.as_ofUNION ALLSELECTb.as_of, q.day,'Plume (retired)', 'Dune on-chain',CAST(NULL AS double),