Skip to Content
PluginsMorpho

Morpho

Morpho is a trustless, permissionless lending protocol deployed as a singleton contract. It enables overcollateralized borrowing and lending of ERC-20 tokens through isolated markets, each defined by a loan token, collateral token, oracle, interest rate model, and liquidation LTV.

This plugin provides actions for the full lending lifecycle: supplying and withdrawing loan tokens, borrowing and repaying against collateral, managing collateral positions, liquidating unhealthy positions, monitoring market state, and managing authorization. Read-only actions work without credentials. Write actions require a connected wallet. Actions that take MarketParams (supply, withdraw, borrow, repay, collateral, liquidate, accrue-interest) accept the 5 struct fields as flat inputs; the runtime reshapes them into the Solidity tuple automatically.

Supported chains: Ethereum (1), Base (8453).

Actions

ActionTypeCredentialsDescription
Get PositionReadNoCheck a user’s supply shares, borrow shares, and collateral in a market
Get MarketReadNoCheck total supply, borrows, last update time, and fee for a market
Get Market ParamsReadNoResolve a market ID to its loan token, collateral, oracle, IRM, and LLTV
Check AuthorizationReadNoCheck if an address is authorized to act on behalf of another
Set AuthorizationWriteWalletGrant or revoke authorization for another address
Flash LoanWriteWalletBorrow tokens and repay within the same transaction
SupplyWriteWalletSupply loan tokens to a market
WithdrawWriteWalletWithdraw supplied loan tokens from a market
BorrowWriteWalletBorrow loan tokens against deposited collateral
RepayWriteWalletRepay borrowed loan tokens
Supply CollateralWriteWalletDeposit collateral tokens into a market
Withdraw CollateralWriteWalletRemove collateral tokens from a position
LiquidateWriteWalletLiquidate an undercollateralized position
Accrue InterestWriteWalletTrigger interest accrual for a market

Get Position

Check a user’s supply shares, borrow shares, and collateral in a Morpho market. Markets are identified by their bytes32 market ID (keccak256 hash of MarketParams).

Inputs:

InputTypeDescription
idbytes32Market ID
useraddressUser Address

Outputs:

OutputTypeDescription
supplySharesuint256Supply Shares
borrowSharesuint128Borrow Shares
collateraluint128Collateral

When to use: Monitor lending positions, track collateral health, trigger alerts when positions approach liquidation thresholds.


Get Market

Check total supply, borrows, last update time, and fee for a Morpho market.

Inputs:

InputTypeDescription
idbytes32Market ID

Outputs:

OutputTypeDescription
totalSupplyAssetsuint128Total Supply Assets
totalSupplySharesuint128Total Supply Shares
totalBorrowAssetsuint128Total Borrow Assets
totalBorrowSharesuint128Total Borrow Shares
lastUpdateuint128Last Update Timestamp
feeuint128Fee

When to use: Monitor market utilization, track total supply and borrow volumes, calculate interest rates from supply/borrow ratios.


Get Market Params

Resolve a market ID to its full parameters: loan token, collateral token, oracle address, interest rate model, and liquidation LTV.

Inputs:

InputTypeDescription
idbytes32Market ID

Outputs:

OutputTypeDescription
loanTokenaddressLoan Token
collateralTokenaddressCollateral Token
oracleaddressOracle
irmaddressInterest Rate Model
lltvuint256Liquidation LTV

When to use: Discover market configuration, verify market parameters before interacting, build market dashboards.


Check Authorization

Check if an address is authorized to act on behalf of another in Morpho. Authorization is required for bundler contracts and delegation patterns.

Inputs:

InputTypeDescription
authorizeraddressAuthorizer Address
authorizedaddressAuthorized Address

Outputs:

OutputTypeDescription
isAuthorizedboolIs Authorized

When to use: Verify bundler authorization before executing batched operations, check delegation status for managed positions.


Set Authorization

Grant or revoke authorization for another address to act on your behalf in Morpho. Required before using bundler contracts for batched supply, borrow, or other operations.

Inputs:

InputTypeDescription
authorizedaddressAuthorized Address
newIsAuthorizedboolAuthorize

Outputs: success, transactionHash, transactionLink, error

When to use: Authorize the Morpho bundler before batched operations, set up delegation for managed positions, revoke access when no longer needed.


Flash Loan

Borrow tokens and repay within the same transaction via Morpho flash loan. The callback data parameter encodes the operations to perform with the borrowed funds.

Inputs:

InputTypeDescription
tokenaddressToken Address
assetsuint256Amount (wei)
databytesCallback Data

Outputs: success, transactionHash, transactionLink, error

When to use: Execute arbitrage, perform liquidations with borrowed capital, rebalance positions atomically.


Supply

Supply loan tokens to a Morpho market. Specify the amount in assets or shares (set the other to 0). The MarketParams fields identify which market to supply to.

Inputs:

InputTypeDescription
loanTokenaddressLoan Token Address
collateralTokenaddressCollateral Token Address
oracleaddressOracle Address
irmaddressIRM Address
lltvuint256Liquidation LTV
assetsuint256Asset Amount
sharesuint256Share Amount (default: 0)
onBehalfaddressOn Behalf Of
databytesCallback Data (default: 0x)

Outputs: success, transactionHash, transactionLink, error

When to use: Deposit idle tokens to earn yield, automate periodic supply into high-utilization markets, rebalance across markets.


Withdraw

Withdraw supplied loan tokens from a Morpho market. Specify the amount in assets or shares (set the other to 0).

Inputs:

InputTypeDescription
loanTokenaddressLoan Token Address
collateralTokenaddressCollateral Token Address
oracleaddressOracle Address
irmaddressIRM Address
lltvuint256Liquidation LTV
assetsuint256Asset Amount
sharesuint256Share Amount (default: 0)
onBehalfaddressOn Behalf Of
receiveraddressReceiver Address

Outputs: success, transactionHash, transactionLink, error

When to use: Exit lending positions, withdraw funds when utilization drops, automate withdrawals based on rate conditions.


Borrow

Borrow loan tokens from a Morpho market against deposited collateral. Specify the amount in assets or shares (set the other to 0).

Inputs:

InputTypeDescription
loanTokenaddressLoan Token Address
collateralTokenaddressCollateral Token Address
oracleaddressOracle Address
irmaddressIRM Address
lltvuint256Liquidation LTV
assetsuint256Asset Amount
sharesuint256Share Amount (default: 0)
onBehalfaddressOn Behalf Of
receiveraddressReceiver Address

Outputs: success, transactionHash, transactionLink, error

When to use: Leverage collateral positions, automate borrowing when rates are favorable, open leveraged yield strategies.


Repay

Repay borrowed loan tokens to a Morpho market. Specify the amount in assets or shares (set the other to 0).

Inputs:

InputTypeDescription
loanTokenaddressLoan Token Address
collateralTokenaddressCollateral Token Address
oracleaddressOracle Address
irmaddressIRM Address
lltvuint256Liquidation LTV
assetsuint256Asset Amount
sharesuint256Share Amount (default: 0)
onBehalfaddressOn Behalf Of
databytesCallback Data (default: 0x)

Outputs: success, transactionHash, transactionLink, error

When to use: Reduce debt before liquidation, automate partial repayments, close borrow positions entirely.


Supply Collateral

Deposit collateral tokens into a Morpho market for borrowing.

Inputs:

InputTypeDescription
loanTokenaddressLoan Token Address
collateralTokenaddressCollateral Token Address
oracleaddressOracle Address
irmaddressIRM Address
lltvuint256Liquidation LTV
assetsuint256Collateral Amount
onBehalfaddressOn Behalf Of
databytesCallback Data (default: 0x)

Outputs: success, transactionHash, transactionLink, error

When to use: Prepare collateral before borrowing, top up collateral to avoid liquidation, automate collateral management.


Withdraw Collateral

Remove collateral tokens from a Morpho market position.

Inputs:

InputTypeDescription
loanTokenaddressLoan Token Address
collateralTokenaddressCollateral Token Address
oracleaddressOracle Address
irmaddressIRM Address
lltvuint256Liquidation LTV
assetsuint256Collateral Amount
onBehalfaddressOn Behalf Of
receiveraddressReceiver Address

Outputs: success, transactionHash, transactionLink, error

When to use: Free excess collateral, rebalance collateral across markets, exit positions after repaying debt.


Liquidate

Liquidate an undercollateralized position in a Morpho market. Specify either seized collateral amount or repaid shares (set the other to 0).

Inputs:

InputTypeDescription
loanTokenaddressLoan Token Address
collateralTokenaddressCollateral Token Address
oracleaddressOracle Address
irmaddressIRM Address
lltvuint256Liquidation LTV
borroweraddressBorrower Address
seizedAssetsuint256Seized Collateral Amount
repaidSharesuint256Repaid Shares (default: 0)
databytesCallback Data (default: 0x)

Outputs: success, transactionHash, transactionLink, error

When to use: Run a liquidation keeper bot, automate liquidations when positions become unhealthy, earn liquidation incentives.


Accrue Interest

Trigger interest accrual for a Morpho market to update supply and borrow indices. This is a public function anyone can call.

Inputs:

InputTypeDescription
loanTokenaddressLoan Token Address
collateralTokenaddressCollateral Token Address
oracleaddressOracle Address
irmaddressIRM Address
lltvuint256Liquidation LTV

Outputs: success, transactionHash, transactionLink, error

When to use: Force index updates before reading accurate balances, ensure interest is accrued before liquidation checks.


Example Workflows

Monitor Position Health

Schedule (hourly) -> Morpho: Get Position -> Condition (collateral < threshold) -> Discord: Send Message

Periodically check a lending position’s collateral level and send an alert if it drops below a safety threshold.

Track Market Utilization

Schedule (daily) -> Morpho: Get Market -> Math (totalBorrowAssets / totalSupplyAssets) -> Condition (> 0.9) -> Telegram: Send Message

Monitor a market’s utilization ratio and alert when it exceeds 90%, indicating high borrow demand.

Authorization Check Before Bundler Use

Manual -> Morpho: Check Authorization -> Condition (isAuthorized = false) -> Morpho: Set Authorization

Verify bundler authorization status and automatically grant it if not already set. Prepares the wallet for batched Morpho operations.

Auto-Supply on High Utilization

Schedule (hourly) -> Morpho: Get Market -> Math (totalBorrowAssets / totalSupplyAssets) -> Condition (> 0.85) -> Morpho: Supply

Monitor market utilization and automatically supply tokens when borrow demand is high, capturing elevated interest rates.

Liquidation Keeper Bot

Schedule (every 5 min) -> Morpho: Get Position (target borrower) -> Condition (collateral < threshold) -> Morpho: Liquidate -> Discord: Send Message

Monitor an undercollateralized borrower and automatically liquidate when their position becomes unhealthy. Send a notification on execution.


Supported Chains

ChainContracts Available
Ethereum (1)Morpho Blue
Base (8453)Morpho Blue

Morpho Blue uses the same singleton contract address on both chains. All markets on each chain are accessed through this single contract.