Integrate Morpho directly with the Morpho SDK

Building on top of DeFi infrastructure can require significant upfront work, including understanding protocol mechanics, implementing data fetchers, developing transaction logic, and maintaining it all as things change.

The Morpho SDK changes this. It’s an open, comprehensive TypeScript toolkit that provides building blocks to reduce blockchain complexities, and handles most of the infrastructure for integrating Morpho.

Data fetching-based integrations that would take weeks now take just days, allowing builders to focus on creating the best possible product experience.

Built as independent packages, the SDK is modular and flexible. Use only what you need:

  • Core SDK – Market, Vault, and Position entities with calculations
  • Simulation – Test operations before execution
  • Bundler – Combine multiple operations into one transaction
  • React Hooks – Wagmi integration for frontend apps
  • API Client – GraphQL access to indexed data

The Core SDK: Markets, Vaults, & Positions

The Core SDK is organized around the primary components you work with: Markets, Vaults, and Positions. Each comes with the necessary data and calculations.

Working with Markets

No manual conversions. No separate calls for each data point. The SDK retrieves all necessary information from the blockchain and calculates the values you actually need.

import { Market } from "@morpho-org/blue-sdk";

const market = await Market.fetch(userAddress, marketParams, client);

// Get what you need in one line 
const supplyAPY = market.supplyApy; 
const userSupply = market.supplyAssets; 
const availableLiquidity = market.totalSupplyAssets;

Working with Vaults

Same principle for vaults. One call, complete data, ready to use.

import { Vault } from "@morpho-org/blue-sdk";

const vault = await Vault.fetch(vaultAddress, client);
const totalAssets = vault.totalAssets; 
const vaultAPY = vault.apy; 
const userBalance = vault.getPosition(userAddress);

Understanding Positions

Fetching position data, made simple. Complex calculations, such as health factors and borrowing capacity, are readily available.

import { Position } from "@morpho-org/blue-sdk";

const position = await Position.fetch(userAddress, marketParams, client);

const healthFactor = position.healthFactor; const borrowingPower = position.borrowCapacity;

Advanced pre-built simulations

Show users their new health factor, updated APY, or borrowing capacity before they sign a transaction.

Production applications need to show users what will happen before they commit. The Simulation SDK lets you test operations before executing them onchain:

import { SimulationState } from "@morpho-org/simulation-sdk";

const state = new SimulationState();

// Simulate supplying collateral state.supply(marketParams, assets, userAddress);

// See the projected outcome const projectedPosition = state.getPosition(marketParams, userAddress);

Bundling multiple calls into a single transaction

One of DeFi’s biggest UX problems: simple actions require multiple transactions. The Bundler SDK solves this by combining multiple operations into a single atomic transaction.

Want to let users supply collateral and borrow against it in one click? Instead of three separate transactions (approve, supply, borrow), do it in one:

import { BundlerAction } from "@morpho-org/bundler-sdk-viem";

const actions = [
  BundlerAction.morphoSupplyCollateral(marketParams, amount, userAddress),
  BundlerAction.morphoBorrow(marketParams, borrowAmount, userAddress, userAddress)
];

const tx = await bundler.multicall(actions);

Compatible with multiple environments

The SDK works with both React (Wagmi) and Viem:

For React Applications:

React hooks with automatic caching and refetching built in.

import { useMarket } from "@morpho-org/blue-sdk-wagmi";

function MarketDisplay({ marketParams }) {
  const { data: market } = useMarket(marketParams, userAddress);
  
  return <div>Supply APY: {market?.supplyApy}%</div>;
}

For Viem Users:

All SDK packages integrate seamlessly with Viem for blockchain interactions. If you’re using Viem or Wagmi, you’re already compatible.

Access indexed data

The SDK includes a GraphQL client for the Morpho API, giving you access to indexed data without constant RPC calls:

import { MorphoBlueApi } from "@morpho-org/blue-api-sdk";

const api = new MorphoBlueApi({ chainId: 1 });
const markets = await api.getMarkets();

From Weeks to Days

What used to take weeks of development now takes days. The SDK handles the complex parts—blockchain interactions, share conversions, health calculations, transaction batching—so you can focus on building the features your users care about.

The code is production-ready, type-safe, and used in live applications today, including the Morpho App.

Get started

Build on Morpho with less complexity. The Morpho SDK handles the infrastructure, allowing you to focus on your product experience.

Documentation: docs.morpho.org/tools/offchain/sdks

GitHub: github.com/morpho-org/sdks

Questions? Visit help.morpho.org

Discover 
more with us