fix: update Morpho GraphQL queries for upstream schema changes (MOO-391)#303
Merged
Merged
Conversation
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>
Contributor
Quality Gate: ✅ PASS
Informational (non-gating)
NotesAll gated metrics held or improved. If this PR raised the floor (e.g., added tests), consider running |
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
The Morpho API shipped breaking schema changes that caused the SDK's Morpho GraphQL queries to fail with HTTP 400 — and because
getGraphQLswallows errors silently, every Morpho vault has been reporting an emptyrewardsarray andrewardsApy: 0through 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.uniqueKeyrenamed tomarketId(theuniqueKey_inwhere-filter is unchanged and still valid)PublicAllocatorSharedLiquidity.allocationMarketreplaced bywithdrawMarket— aliased back toallocationMarketin the query so the SDK's public types are unchangedVaultState.rewardsdeprecated in favor ofallRewards(removal 2026-09-30) — migratedamountPerSuppliedToken/amountPerBorrowedTokendeprecated with removal 2026-06-24 — dropped; reward token amounts are now reported as 0 since the API no longer exposes a replacementAlso: Morpho GraphQL errors are now logged with
console.erroroutside 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 buildpasspnpm test: 34 failed / 515 passed — identical to clean main baseline (pre-existing live-network failures ingetUserVotingPowers,getMorphoVaultUserPosition,getMorphoVault,getMorphoVaults)getMorphoVaultsRewardsfor the cbBTC V1 vault0x5432...a796returnsWELL supplyApr 0.758(the expected ~0.77% from MOO-391)https://api.morpho.org/graphqlwith real data🤖 Generated with Claude Code