Skip to content

Add historical optimization allocations - #1330

Draft
rossgalloway wants to merge 1 commit into
mainfrom
codex/optimization-allocation-completeness
Draft

Add historical optimization allocations#1330
rossgalloway wants to merge 1 commit into
mainfrom
codex/optimization-allocation-completeness

Conversation

@rossgalloway

Copy link
Copy Markdown
Collaborator

Summary

Strengthen the optimization API's allocation-completeness contract without changing the raw DOA optimizer fields. Records now distinguish optimizer coverage residuals from authoritative idle capital, expose freshness metadata, and add timestamp-aligned historical allocation snapshots when Envio and archive RPC data are available.

Historical snapshots use Envio StrategyChanged events to establish the strategy universe, archive RPC multicalls for same-block debt and idle-capital values, and Kong only as a provenance-tagged strategy-name catalog. When those sources are incomplete or unavailable, the API returns an explicit incomplete fallback instead of copying current state or synthesizing Unallocated.

How to review

  1. Start with allocationCoverage.ts and reconcile.ts for the public semantics and unknown/outside-scope handling.
  2. Review historicalAllocation.ts, envio.ts, and rpc.ts for source authority, batching, caching, retries, and bounded fallback behavior.
  3. Check change.ts for requested-vault enrichment versus the no-fan-out unscoped response.
  4. Use manual-allocation-reallocation-data-spec.md as the consumer contract and worked yvWETH example.

Test plan

  • Automated: bun run test — 176 files, 929 tests passed
  • Automated: focused optimization suite — 8 files, 31 tests passed
  • Automated: bun run tslint
  • Automated: bun run lint
  • Automated: bun run build
  • Commit hooks: Biome format/lint, client/server boundary check, and TypeScript
  • Manual: validated a yvWETH recommendation at 2026-07-25 00:15:29 UTC against Ethereum block 25,606,129, including its full strategy composition and 2 bps of same-block idle capital

Risk / impact

This changes additive API metadata and historical enrichment only; raw optimizer fields remain intact. Historical enrichment depends on Envio lifecycle completeness and archive-capable RPC access, so failures intentionally degrade to allocationSnapshot.complete: false with unknown true idle capital. A dedicated provider can be configured with OPTIMIZATION_ARCHIVE_RPC_URL_<chainId> to avoid public-provider rate limits.

The downstream optimization visualizer must adopt the new fields separately and stop treating optimizer residuals as confirmed unallocated capital.

Strengthen optimizer records with explicit allocation coverage and freshness metadata while preserving the raw DOA payload.

- Reconcile timestamp-aligned strategy debt and idle capital through Envio and archive RPC
- Keep omitted strategies unknown unless scope is authoritative
- Add bounded fallbacks, source provenance, contract documentation, and focused tests
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
yearnfi Ready Ready Preview Jul 30, 2026 10:11pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
yearnfi-nextjs Ignored Ignored Jul 30, 2026 10:11pm
yearnfi-nextjs-2 Ignored Ignored Jul 30, 2026 10:11pm

Request Review

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant