WDK logoWDK documentation

Get Started

Install the package, create MorphoProtocolEvm, and review prerequisites.

This guide covers installation, creating the lending client, and prerequisites. Use Node.js 22.13 or later and npm on your machine.

Installation

Run the following to install @morpho-org/wdk-protocol-lending-morpho-evm, the EVM wallet module used by the examples, and the viem peer dependency:

Install with npm
npm install @morpho-org/wdk-protocol-lending-morpho-evm @tetherto/wdk-wallet-evm viem
Install with pnpm
pnpm add @morpho-org/wdk-protocol-lending-morpho-evm @tetherto/wdk-wallet-evm viem

If you use ERC-4337 smart accounts, also install @tetherto/wdk-wallet-evm-erc-4337.

Create the lending client

You can attach Morpho actions to an EVM account from WalletAccountEvm with new MorphoProtocolEvm(account, options):

Create MorphoProtocolEvm
import MorphoProtocolEvm from '@morpho-org/wdk-protocol-lending-morpho-evm'
import { WalletAccountEvm } from '@tetherto/wdk-wallet-evm'

const account = new WalletAccountEvm(seedPhrase, "0'/0/0", {
  provider: 'https://ethereum-rpc.publicnode.com'
})

const morpho = new MorphoProtocolEvm(account, {
  presets: {
    earn: 'sky-money-usdt-savings',
    borrow: 'wsteth'
  }
})

Prerequisites

Runtime: Use Node.js 22.13 or later. Token balance: To supply, supply collateral, or repay, hold the required ERC-20 in the wallet. Gas: Keep native balance for transaction fees unless you use sponsored ERC-4337 flows. Targets: Confirm the configured vault or market matches the token and chain you plan to use.

The built-in presets target Ethereum mainnet. If you configure an explicit vault address, market id, or market params, set chainId in MorphoProtocolOptions.

Requirements before actions

Morpho SDK actions can return approval, signature, or authorization requirements. Call the matching get*Requirements method before the final action when the account has not already satisfied those requirements.

Check supply requirements
const USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7'

const requirements = await morpho.getSupplyRequirements({
  token: USDT,
  amount: 1000000n
})

console.log('Requirements:', requirements)

Send any returned transaction requirements with your EVM account flow before calling the final action. For signature requirements, call the requirement's sign(client, userAddress) helper, then pass the returned requirementSignature to supply, supplyCollateral, or repay.

Next Steps

On this page