feat: expose estimated grossAPR/grossAPY and explicit scope marker - #465
Open
matheus1lva wants to merge 8 commits into
Open
feat: expose estimated grossAPR/grossAPY and explicit scope marker#465matheus1lva wants to merge 8 commits into
matheus1lva wants to merge 8 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…posure, docs, coverage - fall back to unscoped emission label for composition when the vault-scoped lookup is empty (isStrategy marker on dual vault/strategy addresses) - expose katRewardsAPR/debtRatio/isStrategy in gql EstimatedAprComponents - diff performance.estimated in the prod/fork comparator - document the frozen legacy v2 read path and reserved output components - test gross promotion end to end in the yvusd containers spec
Cover promotion zeros, null isStrategy without debtRatio, vault-path null netAPR, vault-scoped label over newer unscoped emission, and optional REST list gross. Unique hook.spec addresses and mock fetch. Document new GQL component fields.
Null isStrategy is documented as absent in outputs.md, same as the SQL.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Estimated-APR publishers compute gross, net it, and publish only
netAPR/netAPY; Kong hadnowhere to put gross. This adds optional
grossAPR/grossAPYtoperformance.estimated(schema, promotion, REST list, GraphQL) and replaces the
debtRatiovault-vs-strategysentinel with a publisher-emitted
isStrategymarker, keepingdebtRatioas the legacyfallback. Additive only:
apr/apystill come fromnetAPR/netAPY, never gross, and nopublisher changes are required.
apr/apyvalues stay identical; the observable output changes arelisted under Risk / impact.
How to review
packages/ingest/helpers/apy-apr.ts:promoteEstimatedApris the singlepromotion list, now shared by the vault path and
fetchStrategyPerformance(
packages/ingest/abis/yearn/3/vault/snapshot/hook.ts), which previously hand-rolled itsown copy.
packages/lib/estimated-apr.ts: the scope-resolution subquery. No publisher emitsisStrategyyet, so it reduces to the olddebtRatiofilter today.packages/lib/types.ts,packages/web/app/api/rest/list/db.ts,packages/web/app/api/gql/typeDefs/vault.ts. Zod default-strip means a missed gate dropsgross silently; these three are the only whitelists. REST snapshot serves the untyped
merged blob and needs no change.
docs/estimated-apr.md(new).netAPRno longer writeapr: null, which failedEstimatedAprSchemaand froze composition (same class as fix(ingest): default estimated apr components so composition parse survives netAPR/netAPY-only rows #443).grossAPRmoves fromcomponentsto thetop level. The GraphQL
components.grossAPRfield stays declared but@deprecated.Test plan
bun --filter web test(29/29), touched ingest specsapy-apr.spec.ts+hook.spec.ts(27/27) — counts from before the review-loop specs.Full ingest/lib suites have pre-existing failures from missing RPC
.env, untouched by this diff.hook.spec.tscovers the composition label fallback, the null-value guard,and vault-scoped label winning over a newer unscoped emission;
apy-apr.spec.tscoverspromoteEstimatedAprzeros, nullisStrategywithoutdebtRatio,isStrategy walk-back to an older vault-scoped emission, and null
netAPRon the vault path;packages/web/app/api/gql/typeDefs/vault.spec.tsasserts the new GQL fields;REST list spec asserts gross is kept when present and optional when absent.
Review-loop specs were checked by reading, not executed.
katana-estimated-apr.containers.spec.tsandyvusd-estimated-apr.containers.spec.ts(both need live RPC env); katana
edited to seed gross on STRATEGY only, SIBLING stays net-only as the fix(ingest): default estimated apr components so composition parse survives netAPR/netAPY-only rows #443 freeze guard.
apr/apyidentical, gross absent until publishers emit it.Risk / impact
LATEST_ROWS_BY_ESTIMATED_APR_SQL. Prod-shaped Neon(
outputTimescale 2.13, 141 chunks, 2 in the 7d window): chunk exclusion holds139/141 for old EXISTS, correlated
bool_or, and grouped HAVING. The correlatedbool_orSubPlan was the regression — planner cost ~257k vs ~2.5k, BitmapAnd ofoutput_series_time_idx(~360k rows/chunk), yvUSD 628ms vs old 86ms. Split-EXISTSalso stayed a Filter SubPlan. Uncorrelated
GROUP BY/HAVINGrestores theseries_time index seek (yvUSD 2.5ms, dual-role 2.4ms, crv 5.4ms) and matches old
row sets.
getLatestEstimatedAprLabelis already that index seek (1.3ms).netAPRstrategy rows start composing again. More generally anynull-valued estimated component is now omitted from
componentsinstead of written asnull.label via
getLatestEstimatedAprLabel, so their composition strategies gainperformance.estimatedblocks they did not have before. Output change for existing data, not gated on publishers.
getLatestEstimatedAprLabeladds one indexed round-trip (idx_output_chain_address_label_series_timeprefix on chain_id/address) to the v3 snapshot hook for every vault with no vault-scoped estimate.
components.grossAPRnow resolves null (value promoted toestimated.grossAPR).Audited yearn.fi, yearn-powerglove, ydaemon via GitHub code search: none read
estimated.components.grossAPR(powerglove'sgrossAprcomes fromoracle.apr/ timeseries points).yearn.fi
estimatedAprSchemadoes not whitelistestimated.grossAPR/grossAPY; Zod default-stripdrops them until they add the fields. They keep reading
apr/apyand RESTcomponents.katRewardsAPR.EstimatedAprComponentsnow resolvescompoundingPeriodsPerYear,katRewardsAPR,debtRatio, andisStrategy(the typed object dropped them before). REST list/snapshot alreadypassed those through a
z.record. yearn.fi readskatRewardsAPRfrom REST snapshot components, not GQL.compare-rest-prod-forkdiffs listestimated.apr/apy/grossAPR/grossAPY. yvUSD will reportgrossAPR/grossAPYasmissingvs prod until prod is deployed; that is the promotion, not aprice regression.
getLatestEstimatedApr, crv/velo/aero) applies no scope rule; a v2 publisheremitting
isStrategywould be ignored there. Out of scope, documented indocs/estimated-apr.md.Rollback = revert, nothing persisted in a new shape.