Skip to main content
The Morpho Ability enables Vincent Apps to interact with Morpho lending vaults on behalf of Vincent Users. This allows Vincent Apps to provide yield-generating DeFi functionality through Morpho’s lending markets, including depositing assets to earn yield, withdrawing funds, and managing vault positions.

Key Features

  • Yield Vault Operations: Supports deposit, withdraw, and redeem operations with Morpho’s ERC-4626 compliant vaults using Vincent Wallets within a secure Trusted Execution Environment
  • Multi-Chain Support: Works across multiple networks where Morpho vaults are deployed including Ethereum, Base, Arbitrum, Optimism, and Polygon
  • Comprehensive Vault Discovery: Utilizes the Morpho Vault API to discover and filter vaults by asset, chain, APY, TVL, and other criteria
  • Gas Sponsorship: Optional integration with Alchemy’s gas sponsorship for gasless transactions via EIP-7702

How It Works

The Morpho Ability is built using the Vincent Ability SDK and operates in two phases:
1

Precheck Phase

Validates all prerequisites for the Morpho operation:
  • Validates operation type, vault address, and amount format
  • Verifies the vault exists using the built-in Morpho Vault client and retrieves asset information
  • For deposits, checks the Vincent App User’s Vincent Wallet’s token balance and allowance
  • For withdrawals/redeems, checks the Vincent App User’s Vincent Wallet’s has a vault share balance
  • For withdrawals, converts the requested asset amount to the required vault shares using ERC-4626 convertToShares
  • Estimates gas costs for the operation
  • Returns detailed validation results with current balance/shares
2

Execution Phase

Executes the Morpho vault operation:
  • Discovers and retrieves vault information using the Morpho Vault API, which enables filtering by asset, chain, APY, TVL, and more
  • Constructs the appropriate Morpho vault transaction using ERC-4626 standard methods
  • Signs and submits the transaction (with optional EIP-7702 Alchemy gas sponsorship)
  • Returns transaction hash and operation details

Getting Started

Depending on your role in the Vincent Ecosystem, you’ll be interacting with this Ability in different ways. Click on the link below that matches your role to see how to get started:
  • Vincent App Developers: If you’re building a Vincent App that needs to interact with Morpho vaults, go here.
  • Vincent App Delegatees: If you’re executing this ability on behalf of Vincent App Users, go here.

Adding the Ability to your Vincent App

If you want to enable your App Delegatees to perform Morpho vault operations on behalf of your Vincent App Users, you can add this Ability to your App. Adding Abilities to your Vincent App is done using the Vincent App Dashboard. Visit the Create Vincent App guide to learn more about how to add Abilities to your App during creation, or check out the Updating Your App guide to learn how to add Abilities to an existing App.

Executing the Ability as a Vincent App Delegatee

Before executing Morpho vault operations, the following conditions must be met. You can use the Ability’s precheck function to check if these conditions are met, or you can check them manually.
  • Native Token Balance for Gas Fees: The Vincent App User’s Vincent Wallet must have enough native tokens (ETH, MATIC, etc.) to cover the transaction gas fees for the Morpho operation.
  • ERC20 Token Approval: For deposit operations, the Vincent App User’s Vincent Wallet must have approved the Morpho vault contract to spend the underlying tokens.
To learn more about executing Vincent Abilities, see the Executing Abilities guide.
If your Vincent App has enabled the ERC20 Approval Ability, you can use it to handle submitting the approval transaction using the Vincent Wallet.

Operation-Specific Requirements

Each Morpho operation has specific validation requirements that are checked during the precheck phase:
  • Deposit
  • Withdraw
  • Redeem
Requirements for Deposit Operation:
  • The Vincent App User’s Vincent Wallet must have sufficient balance of the underlying token (e.g., USDC, WETH)
  • Morpho vault contract must be approved to spend the required token amount
  • Both balance and allowance must be greater than or equal to the deposit amount

Executing the precheck Function

This Ability’s precheck function validates all prerequisites for executing a Morpho vault operation and provides detailed account information.
  • Parameters
  • Implementation
  • Response
Before executing the precheck function, you’ll need to provide the following parameters for the Morpho operation:
{
  /**
   * The Morpho operation to perform (deposit, withdraw, redeem)
   */
  operation: 'deposit' | 'withdraw' | 'redeem';
  /**
   * The Morpho vault contract address
   */
  vaultAddress: string;
  /**
   * The amount to operate with, as a decimal string
   * For deposit/withdraw: amount of underlying asset (e.g., "100.5" for 100.5 USDC)
   * For redeem: amount of vault shares
   */
  amount: string;
  /**
   * The blockchain network to perform the operation on
   */
  chain: string;
  /**
   * Custom RPC URL (optional, for precheck only)
   */
  rpcUrl?: string;
  /**
   * Enable Alchemy gas sponsorship (optional)
   */
  alchemyGasSponsor?: boolean;
  /**
   * Alchemy API key (required if gas sponsorship enabled)
   */
  alchemyGasSponsorApiKey?: string;
  /**
   * Alchemy policy ID (required if gas sponsorship enabled)
   */
  alchemyGasSponsorPolicyId?: string;
}

Executing the execute Function

This Ability’s execute function performs the actual Morpho vault operation.
  • Parameters
  • Implementation
  • Response
The execute function expects the same parameters as the precheck function (except rpcUrl which is not allowed):
{
  /**
   * The Morpho operation to perform (deposit, withdraw, redeem)
   */
  operation: 'deposit' | 'withdraw' | 'redeem';
  /**
   * The Morpho vault contract address
   */
  vaultAddress: string;
  /**
   * The amount to operate with, as a decimal string
   * For deposit/withdraw: amount of underlying asset (e.g., "100.5" for 100.5 USDC)
   * For redeem: amount of vault shares
   */
  amount: string;
  /**
   * The blockchain network to perform the operation on
   */
  chain: string;
  /**
   * Enable Alchemy gas sponsorship (optional)
   */
  alchemyGasSponsor?: boolean;
  /**
   * Alchemy API key (required if gas sponsorship enabled)
   */
  alchemyGasSponsorApiKey?: string;
  /**
   * Alchemy policy ID (required if gas sponsorship enabled)
   */
  alchemyGasSponsorPolicyId?: string;
  // Note: rpcUrl is NOT allowed in execute
}
The rpcUrl parameter is not allowed in the execute function for security reasons. Only the chain parameter should be used.

Supported Networks

The Morpho Ability supports operations on the following networks where Morpho vaults are deployed:
Network TypeSupported Chains
Mainnetsethereum, base, arbitrum, optimism, polygon
Testnetssepolia

Important Considerations

The amount parameter should be specified in human-readable format (e.g., “100.5” for 100.5 tokens), not in wei or smallest units.
  • For deposit and withdraw: Amount represents underlying assets (e.g., USDC)
  • For redeem: Amount represents vault shares
When using Alchemy gas sponsorship:
  • Transactions are gasless for the Vincent App User’s Vincent Wallet
  • Requires valid Alchemy API key and policy ID
  • Uses EIP-7702 for gasless transactions
  • For precheck: You can provide either chain or rpcUrl
  • For execute: Only chain is allowed, rpcUrl will cause an error
This is a security feature to prevent RPC URL injection attacks.

Error Handling

  • Insufficient Balance: Not enough tokens for deposit or shares for withdrawal
  • Missing Approval: Token not approved for Morpho vault contract
  • Invalid Vault: Vault address doesn’t exist or isn’t a valid Morpho vault
  • Invalid Chain: Chain not supported or vault not deployed on that chain
  • Gas Issues: Insufficient native tokens for transaction gas fees
  • Liquidity Issues: Vault doesn’t have sufficient liquidity for withdrawals
I