Morpho V2 To Morpho V2 Roller
The Morpho V2 To Morpho V2 Roller enables automatic rolling of fixed-rate borrow positions between maturities in the Morpho V2 protocol. It simplifies the renewal process and minimizes the likelihood of users getting liquidated at maturity.
When enabled, the smart contract allows any third party (e.g. lender) to renew a borrower’s position in a further-dated term, removing the need for manual repayment or monitoring.
If the smart contract is disabled and the user fails to repay their position by maturity, collateral equivalent to the value of the debt is liquidated to repay the position.
A user can combine the Morpho V2 To Morpho V2 Roller with the Morpho V2 To Morpho V1 Roller to create a more flexible renewal policy and reduce even more the likelihood of getting liquidated at maturity. By initially only allowing fixed-term, fixed-rate renewal, and enabling open-term, variable-rate renewal later, the user can ensure that their position is renewed into a fixed-term position if possible, and into a variable-rate position if not.
How It Works
1. Set Roll Parameters
The borrower (or authorized party) calls setUserParams to configure rolling preferences for a specific term market. Parameters are set per termMarketId, which is derived from the loan token and collateral tokens of the Morpho V2 position:
- maxRate: Maximum acceptable interest rate for the new position (max 100% APR)
- minDuration: Minimum duration for the new term
- maxDuration: Maximum duration for the new term (max 2 years)
- auctionDuration: Time window before maturity when rolling is allowed (max 3 days)
- policy: Policy contract that determines auction rates and fees
The borrower can opt into different renewal policies (e.g., Linear Rate Policy, Target Rate Policy) that create an auction mechanism for the renewal rate. These policies calculate time-based auction rates that increase as the position approaches maturity. As the renewal rate increases, it creates a profit opportunity that incentivizes third parties and MEV bots to execute the roll when they find offers at lower rates in the target maturity. Policies can also charge fees on rolls.
The roller contract enforces the borrower's maxRate as a hard cap—even if the policy returns a higher rate, the contract will use the lower of the two values to protect the borrower.
This allows borrowers to have different rolling strategies for different loan/collateral combinations.
2. Roll Execution
When the auction period begins, any third party can call rollPosition to execute the roll:
Validation checks:
- Current time is within the auction window
- Target term maturity is in the future and after source term maturity
- Target term duration is between
minDurationandmaxDuration - Chain IDs match between source and target terms
Policy execution:
- Calls
policy.beforeRoll()for pre-roll logic - Calls
policy.getRate()to determine the maximum acceptable rate for this auction - Takes the lower of policy rate and user's
maxRate
Atomic transfer:
- Takes offer to borrow in target term on behalf of borrower
- Executes optional callback to repay source position and handle fees
- Calculates implied interest rate from actual debt changes
- Validates implied rate does not exceed maximum acceptable rate
- Withdraws collateral from source term proportionally to repaid debt
- Supplies collateral to target term
- Calls
policy.afterRoll()to validate fee payment
3. Clear Parameters
The borrower can call clearUserParams to disable rolling for a specific market