Skip to content

morpho-org/sdks

Repository files navigation

Morpho SDKs

image

A collection of Software Development Kits to ease interactions with the Morpho protocol and Morpho Vaults.


Getting Started

Viem

  • @morpho-org/blue-sdk-viem: Viem-based augmentation of @morpho-org/blue-sdk that exports (and optionally injects) viem-based fetch methods
  • @morpho-org/bundler-sdk-viem: Viem-based extension of @morpho-org/simulation-sdk that exports utilities to transform simple interactions on Morpho (such as Blue_Borrow) and Morpho Vaults (such as MetaMorpho_Deposit) into the required bundles (with ERC20 approvals, transfers, etc) to submit to the bundler onchain
  • @morpho-org/liquidity-sdk-viem: Viem-based package that helps seamlessly calculate the liquidity available through the PublicAllocator
  • @morpho-org/liquidation-sdk-viem: Viem-based package that provides utilities to build viem-based liquidation bots on Morpho and examples using Flashbots and Morpho's GraphQL API

Wagmi

Development

Testing

  • @morpho-org/test: Viem-based package that exports utilities to build Vitest & Playwright fixtures that spawn anvil forks as child processes

  • @morpho-org/test-wagmi: Wagmi-based extension of @morpho-org/test that injects a test Wagmi config as a test fixture alongside viem's anvil client

  • @morpho-org/morpho-test: Framework-agnostic extension of @morpho-org/blue-sdk that exports test fixtures useful for E2E tests on forks

Test coverage

  1. Install lcov: sudo apt install lcov
  2. Generate coverage info: pnpm test:coverage
  3. Generate hierarchical coverage report: pnpm coverage:report

Getting involved

Learn how to add a new chain configuration to the sdks.

Debugging

Here's a tutorial on how to link a specific package to debug at runtime:

  1. From the repository in which you want to link the package: pnpm link ../your/relative/path/to/sdks/packages/blue-sdk
-    "@morpho-org/blue-sdk": "5.0.0",
+    "@morpho-org/blue-sdk": "link:../../../sdks/packages/blue-sdk",
  1. Modify blue-sdk package.json to use js main & js files:
-  "main": "src/index.ts",
+  "main": "lib/index.js",
+  "types": "lib/index.d.ts"
  1. In a separate process, start: pnpm --dir packages/blue-sdk build --watch

Authors

License

MIT License