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 entrypoint is the Morpho SDK - the default abstraction layer that produces ready-to-send transactions for VaultV2, Variable Rate - Blue Market (Morpho Blue), and Fixed Rate - Midnight Market 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 and dependencies, so you never have to reach past it.
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.
The 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, Variable Rate - Blue Market (Morpho Blue), and Fixed Rate - Midnight Market, with VaultV1 (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
- Midnight fixed-rate flows - take offers, publish maker offers, and maintain positions on Morpho's fixed-rate, fixed-term orderbook
- 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 rate (Midnight)
Midnight - fixed-rate, fixed-term lending through signed maker offers matched in an onchain orderbook - is a surface of the Morpho SDK, not a separate SDK: the Midnight page covers taker, maker, and position-maintenance transactions through the same getRequirements / buildTx flow.
Underneath, the Morpho SDK ships the low-level Midnight toolkit (the formerly standalone Midnight SDK, now folded in) and re-exports most of its surface on its own subpaths - /midnight-api, /abis, /constants, /utils, and /errors. Reach for the toolkit directly when you need offer construction, ratification, books and quotes, or tick math:
→ Read the Midnight toolkit guide · Source on GitHub
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.@morpho-org/morpho-sdk/midnight-api- The Midnight HTTP API helpers (books, quotes, takeable offers, mempool validation).
See the Morpho SDK guide for the full surface.
Where next
- Recommended starting point: Morpho SDK guide
- Vault deposits & withdrawals: Vault guide
- Variable-rate lending & borrowing: Blue guide
- Fixed-term lending: Midnight toolkit guide
- Source code:
morpho-org/sdks- the SDK monorepo containing@morpho-org/morpho-sdkand the Midnight toolkit - Need help? Reach out via the chat on help.morpho.org.