Skip to content

refactor(sdk): replace any with specific types in lend provider sources#405

Open
cats2101 wants to merge 1 commit intoethereum-optimism:mainfrom
cats2101:fix/replace-any-types-sdk-source
Open

refactor(sdk): replace any with specific types in lend provider sources#405
cats2101 wants to merge 1 commit intoethereum-optimism:mainfrom
cats2101:fix/replace-any-types-sdk-source

Conversation

@cats2101
Copy link
Copy Markdown

Summary

Scoped first pass at #337: replaces any with specific types across the lend provider SDK source files (Morpho + Aave). Tests left for a follow-up so this stays reviewable.

Changes

packages/sdk/src/lend/providers/morpho/api.ts

  • Added exported interfaces for the Morpho GraphQL response shape: MorphoRewardAsset, MorphoReward, MorphoMarketState, MorphoAllocation, MorphoVaultState, MorphoApiVault.
  • fetchRewards return type changed from Promise<any | null> to Promise<MorphoApiVault | null>.
  • Response parsing uses a typed MorphoVaultApiResponse shape instead of as any.

packages/sdk/src/lend/providers/morpho/sdk.ts

  • calculateBaseApy(vault: any)calculateBaseApy(vault: AccrualVault) (from @morpho-org/blue-sdk).
  • Inner allocation param typed as VaultMarketAllocation.
  • calculateApyBreakdown vault param typed as AccrualVault.
  • calculateRewardsBreakdown param typed as MorphoApiVault.
  • Inner .reduce callback alloc param now inferred from the typed array.

packages/sdk/src/lend/providers/aave/sdk.ts

  • calculateApyBreakdown reserve param typed with FormatReserveUSDResponse from @aave/math-utils instead of any.

packages/sdk/src/services/__mocks__/MockChainManager.ts

  • Two as any casts tightened to as unknown as PublicClient / as unknown as BundlerClient.

packages/sdk/src/lend/__mocks__/MockLendProvider.ts

  • simulateError mock method typed as MockedFunction<(...args: never[]) => unknown> instead of any.

Test adjustments

  • morpho/__tests__/api.test.ts: added non-null assertions where tests already check expect(vaultData).not.toBeNull() beforehand.
  • morpho/__tests__/sdk.test.ts: partial fixtures cast with as unknown as AccrualVault / as unknown as MorphoApiVault at call sites, per the pattern suggested in the issue.

Scope

This PR only touches lend provider source files and the mocks/tests directly affected by those signature changes. The remaining any warnings are in other test files and unrelated modules — happy to tackle those in follow-up PRs to keep reviews focused.

Verification

  • pnpm typecheck — passes
  • pnpm lint — 13 @typescript-eslint/no-explicit-any warnings resolved (35 → 22); no new warnings introduced
  • pnpm -r test — 467 passed, 10 skipped

Part of #337.

@cats2101 cats2101 requested a review from a team as a code owner April 19, 2026 00:15
@cats2101 cats2101 requested a review from jefr90 April 19, 2026 00:15
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 19, 2026

👷 Deploy request for actions-ui pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit d26dea7

@cats2101 cats2101 force-pushed the fix/replace-any-types-sdk-source branch 2 times, most recently from 35f069b to cc0ddea Compare April 22, 2026 05:03
Part of ethereum-optimism#337. Replaces `any` with specific types in SDK source files
(tests other than the directly-affected fixtures are untouched):

- `lend/providers/morpho/api.ts`: type the GraphQL response with a
  `MorphoApiVault` interface and surface it from the fetch helper.
- `lend/providers/morpho/sdk.ts`: type vault inputs as `AccrualVault`
  and allocations as `VaultMarketAllocation` from `@morpho-org/blue-sdk`;
  use `MorphoApiVault` for the GraphQL-sourced variant.
- `lend/providers/aave/sdk.ts`: type `formattedReserve` as
  `FormatReserveUSDResponse` from `@aave/math-utils`.
- `services/__mocks__/MockChainManager.ts` and
  `lend/__mocks__/MockLendProvider.ts`: replace `as any` with
  `as unknown as <SpecificType>` per the issue guidelines.

Direct fixture call sites in the Morpho sdk tests are cast with
`as unknown as AccrualVault` / `MorphoApiVault` to keep the partial
test objects compatible. Remaining `any` warnings live in other test
files and are left for follow-up PRs.

pnpm typecheck, pnpm lint (no new warnings), and pnpm test all pass.
@cats2101 cats2101 force-pushed the fix/replace-any-types-sdk-source branch from cc0ddea to d26dea7 Compare April 30, 2026 10:09
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