Skip to content

fix: update Morpho GraphQL queries for upstream schema changes (MOO-391)#303

Merged
lyoungblood merged 1 commit into
mainfrom
luke/moo-391-fix-morpho-market-uniquekey
Jun 12, 2026
Merged

fix: update Morpho GraphQL queries for upstream schema changes (MOO-391)#303
lyoungblood merged 1 commit into
mainfrom
luke/moo-391-fix-morpho-market-uniquekey

Conversation

@lyoungblood

Copy link
Copy Markdown
Collaborator

Summary

The Morpho API shipped breaking schema changes that caused the SDK's Morpho GraphQL queries to fail with HTTP 400 — and because getGraphQL swallows errors silently, every Morpho vault has been reporting an empty rewards array and rewardsApy: 0 through the legacy (non-Lunar-indexer) data path. This is the root cause of MOO-391: the yield-backend (SDK 0.9.15, legacy path) returns an empty rewards object for mwcbBTC (and all other vaults).

Upstream changes handled:

  • Market.uniqueKey renamed to marketId (the uniqueKey_in where-filter is unchanged and still valid)
  • PublicAllocatorSharedLiquidity.allocationMarket replaced by withdrawMarket — aliased back to allocationMarket in the query so the SDK's public types are unchanged
  • VaultState.rewards deprecated in favor of allRewards (removal 2026-09-30) — migrated
  • amountPerSuppliedToken / amountPerBorrowedToken deprecated with removal 2026-06-24 — dropped; reward token amounts are now reported as 0 since the API no longer exposes a replacement

Also: Morpho GraphQL errors are now logged with console.error outside browser contexts, so server-side consumers (e.g. Cloudflare Workers) see these failures in logs instead of silently getting empty rewards.

Verification

  • pnpm typecheck, pnpm lint, pnpm build pass
  • pnpm test: 34 failed / 515 passed — identical to clean main baseline (pre-existing live-network failures in getUserVotingPowers, getMorphoVaultUserPosition, getMorphoVault, getMorphoVaults)
  • Live smoke test of the fixed query path: getMorphoVaultsRewards for the cbBTC V1 vault 0x5432...a796 returns WELL supplyApr 0.758 (the expected ~0.77% from MOO-391)
  • All three fixed/affected queries validated against https://api.morpho.org/graphql with real data

🤖 Generated with Claude Code

The Morpho API renamed Market.uniqueKey to marketId and replaced
PublicAllocatorSharedLiquidity.allocationMarket with withdrawMarket,
causing the vault rewards and shared-liquidity queries to 400 and all
Morpho vaults to report empty rewards (MOO-391).

- Rename uniqueKey field selections to marketId (the uniqueKey_in
  where-filter is unchanged and still valid)
- Alias withdrawMarket back to allocationMarket to keep public types
- Migrate vault rewards to state.allRewards and drop the deprecated
  amountPerSuppliedToken/amountPerBorrowedToken fields ahead of their
  scheduled removal; reward token amounts are now reported as 0
- Log Morpho GraphQL errors outside browser contexts so failures
  surface in server logs instead of silently returning no rewards

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Quality Gate: ✅ PASS

Metric Baseline Current Δ Verdict
coverage.lines 81.6% 83.9% +2.33pp ✅ PASS
coverage.statements 81.6% 83.9% +2.33pp ✅ PASS
coverage.functions 51.1% 57.8% +6.77pp ✅ PASS
coverage.branches 81.8% 84.0% +2.25pp ✅ PASS
lint.errors 0 0 0.00 ✅ PASS
lint.warnings 0 0 0.00 ✅ PASS
audit.critical 0 0 0.00 ✅ PASS
audit.high 0 0 0.00 ✅ PASS
duplication.percentage 9.3% 8.9% -0.34pp ✅ PASS
duplication.clones 101 95 -6.00 ✅ PASS

Informational (non-gating)

Metric Baseline Current Δ
audit.moderate 1 1 0.00
audit.low 0 0 0.00
duplication.duplicatedLines 1980 1919 -61.00

Notes

All gated metrics held or improved. If this PR raised the floor (e.g., added tests), consider running pnpm gate:update-baseline after merge to lock the new floor in.

@lyoungblood lyoungblood merged commit 6538cef into main Jun 12, 2026
3 of 4 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 12, 2026
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