Query editor
-- OETH incremental aggregate with a versioned internal checkpoint_state column.-- Baseline: query8668164, execution01M2642RSHMM6W8K0Q5Z5HNQ2E, 1241 days, 213.038 credits.-- All 28 SQD names/types preserved; the user-approved 29th column retains internal replay state.-- Latest validation/execution/cost status lives in the QUERY DESCRIPTION, not these comments.-- New SQL text (including comment edits) starts a new checkpoint; description edits preserve it.-- Restoring exactly matching earlier SQL can recover that SQL text's earlier checkpoint.-- One previous.query.result store. Keep SQL unchanged between bootstrap and measured refresh.-- Dune persists amo_supply UINT256 as Parquet STRING: read VARCHAR, cast back to UINT256.-- Retain dates before max(previous date)-1 day; recompute the overlapping completed days.-- refresh_mode=full rebuilds all history. Empty previous results also bootstrap full history.-- checkpoint_state JSON v1 stores exact close states: nine vault actors and both Curve pools.-- Vault: WETH balance, native principal, approval and uncertainty. Curve: reserves, LP supply, unknown.-- Large integers are JSON strings. Resume strictly AFTER the checkpoint UTC day, before overlap.-- Missing/incompatible internal snapshots fall back to original full event replay for that component.-- Both inactive and active actors/pools stay current so later reapproval has valid opening state.-- Other components still scan historical events; this does not claim every scan is incremental.-- APR/APY, cumulative yield and supply classification keep their validated opening-state logic.-- No separate materialized views, schedules, RPC, HTTP, Chainlink or SQD query inputs.-- PRICE TABLE: prices_external.minute, Coinpaprika native ETH/USD; ETH:WETH=1:1.-- Prices affect ONLY rate_usd and market_cap_usd; this is the approved replacement definition.-- peg and accounts_over_threshold stay NULL. All documented SQD differences remain.-- Sep8-9 supply-split SQD cause remains unresolved; no reconciliation offsets.-- Inlined components let a single root checkpoint reach their internal output boundaries.WITH inc_previous AS (SELECT "id","chain_id","block_number","timestamp","otoken","date","apr","apy","apy7","apy14","apy30","peg","rate_usd","rate_eth","rate_native","total_supply","rebasing_supply","non_rebasing_supply","wrapped_supply","rate_wrapped",CAST("amo_supply" AS uint256) AS "amo_supply","dripper_weth","yield","fees","cumulative_yield","cumulative_fees","market_cap_usd","accounts_over_threshold","checkpoint_state" FROM TABLE(previous.query.result(schema => DESCRIPTOR("id" varchar,"chain_id" integer,"block_number" bigint,"timestamp" timestamp(3) with time zone,"otoken" varchar(42),"date" varchar,"apr" double,"apy" double,"apy7" double,"apy14" double,"apy30" double,"peg" decimal(38, 0),"rate_usd" decimal(38, 0),"rate_eth" decimal(19, 0),"rate_native" decimal(19, 0),"total_supply" decimal(38, 0),"rebasing_supply" decimal(38, 0),"non_rebasing_supply" decimal(38, 0),"wrapped_supply" decimal(38, 0),"rate_wrapped" decimal(38, 0),"amo_supply" varchar,"dripper_weth" decimal(38, 0),"yield" decimal(38, 0),"fees" decimal(38, 0),"cumulative_yield" decimal(38, 0),"cumulative_fees" decimal(38, 0),"market_cap_usd" double,"accounts_over_threshold" integer,"checkpoint_state" varchar)))),inc_checkpoint AS (SELECT CASE WHEN '{{refresh_mode}}'='full' THEN DATE '2023-04-18'ELSE greatest(DATE '2023-04-18',least(current_date-INTERVAL '1' DAY,coalesce(max(CAST(date AS date))-INTERVAL '1' DAY,DATE '2023-04-18'))) END AS cutoff