Morpho SDKs
The Morpho Software Development Kits (SDKs) are a suite of TypeScript packages for building on the Morpho protocol - from a full-featured DeFi application to a liquidation bot, an indexer, or a simple data dashboard.
The recommended starting point is the Morpho SDK - the default abstraction layer that produces ready-to-send transactions for VaultV2 and MarketV1 (Morpho Blue) in a single, consistent surface. When you need raw entity classes, low-level fetchers, or custom calldata composition, the Morpho SDK ships those primitives as subpath exports, so you never have to reach past it. For fixed-rate, fixed-term lending through the Morpho Midnight orderbook, use the Midnight SDK instead.
New here? Go straight to the Morpho SDK - it's what powers Morpho's own consumer surfaces and is the SDK you almost certainly want.
Default: Morpho SDK
@morpho-org/morpho-sdk - the default and recommended SDK for application integrators. It is the abstraction layer that simplifies the Morpho protocol:
- One consistent abstraction layer across VaultV2 and MarketV1 (Morpho Blue), with V1 (MetaMorpho) supported under the hood for migrations / liquidity reallocation
- Builds final, deep-frozen
viemTransactionobjects - no calldata wrangling - Handles ERC-20 approvals, Permit / Permit2 signatures, and Morpho
setAuthorizationfor GeneralAdapter1 via a unifiedgetRequirements()flow - Composes Bundler3 / GeneralAdapter1 bundles for you (atomic supply+borrow, repay+withdraw, Blue-to-Blue refinance, V1→V2 migration, native-token wrapping)
- Slippage-protected by default (
maxSharePrice/minSharePrice, LLTV buffer) - Optional shared-liquidity reallocations through the PublicAllocator for borrow, withdraw, supply+borrow, and refinance flows
- Strict TypeScript, no
any, dedicated error classes for every failure mode
pnpm add @morpho-org/morpho-sdk viem→ Read the Morpho SDK guide · Source on GitHub · Package on npm
Fixed-term lending: Midnight SDK
@morpho-org/midnight-sdk - the viem-based toolkit for Morpho Midnight, fixed-rate / fixed-term lending through signed maker offers matched in an onchain orderbook. It covers both sides of the protocol:
- Make side - construct offers locally, commit them to a Merkle tree, validate against the Midnight API's mempool policy, sign or approve through a ratifier, and publish onchain
- Take side - query books, price levels, and quotes from the Midnight API, and execute ABI-ready takes against the
Midnightcontract
pnpm add @morpho-org/midnight-sdk viem→ Read the Midnight SDK guide · Source on GitHub · Package on npm
Reaching below the abstraction layer
When you need to reach below the abstraction layer - for raw entity classes, low-level on-chain fetchers, custom calldata composition, or simulation pipelines - the Morpho SDK ships those primitives as subpath exports, so you never need a separate package:
@morpho-org/morpho-sdk/entities- Core entity classes (Market,Vault,Position) and offchain computations. The foundation of the rest of the stack.@morpho-org/morpho-sdk/fetch- Viem-based fetchers for live on-chain data.@morpho-org/morpho-sdk/abis,/addresses,/constants,/bundler- ABIs, deployment addresses, protocol constants, and Bundler3 / GeneralAdapter1 helpers.
See the Morpho SDK guide for the full surface.
Where next
- Recommended starting point: Morpho SDK guide
- Fixed-term lending: Midnight SDK guide
- Source code:
morpho-org/sdks- the SDK monorepo containing@morpho-org/morpho-sdkand@morpho-org/midnight-sdk - Need help? Reach out via the chat on help.morpho.org.