Repay
GET/v1/actions/lending/repay
Build calldata for repaying a loan. Identify the market via marketUid (format: lender:chainId:address). Approval transactions are automatically filtered: if the user already has sufficient allowances, permissions (envelope) and permissionTxns (per-entry) will be empty. Pass simulate=true to include projected post-trade metrics. When on-chain debt data is available and amount covers the full debt, the API uses protocol-level max-repay mechanisms automatically. If isAll=true but amount is less than the debt, the API falls back to a partial repay to avoid reverts.
Lista DAO fixed-term (brokered) markets: pass loanId to target a specific loan (use the per-loan loanId from the user-positions response, or the type(uint128).max sentinel for the flexible/dynamic position). The broker repays interest-first plus an early-repayment penalty on not-yet-matured fixed loans and refunds any excess, so to fully close a loan fund outstanding + accruedInterest + earlyRepayPenalty from the per-loan term.
Morpho Midnight fixed-term markets (MORPHO_MIDNIGHT_<id>) — repaying to avoid liquidation. A Midnight loan is zero-coupon and fixed-maturity: you owe a static face value — the position's debt in loan-token units — repaid 1:1, which does not grow over time. So the amount to repay is fixed and known up front (the continuous + settlement fees accrue on the lender's side and are never added to your debt), and there is no early-repayment penalty (unlike Lista) — you may repay any time before maturity at face value.
A borrower faces two liquidation triggers; both are cleared by repaying:
- Before maturity — health (LTV) based. As with any collateralised loan, if the collateral's oracle value falls enough to breach the market's LLTV, the position can be liquidated. Keep an LTV buffer, add collateral, or repay down.
- At/after maturity — default. The fixed
maturity(surfaced onparams.market.maturity) is a hard deadline. Once it passes, an unrepaid loan is in default and can be liquidated regardless of health or LTV — being past-due is itself the trigger. This is the Midnight-specific risk to watch: mark the maturity date and fully repay before it, even if the position is comfortably collateralised.
Repay exactly the debt. Over-repaying reverts on-chain (there is no over-repay buffer — do not pad the amount, and isAll does not auto-size here), while under-repaying leaves a dust position that stays open and therefore still liquidatable after maturity. Set amount to the position's current debt (loan-token units) from /v1/data/lending/user-positions and approve exactly that to the Midnight core. To fully close and reclaim collateral, repay the debt and then withdraw the collateral via /v1/actions/lending/withdraw — collateral cannot be freed while any debt remains.
Request
Responses
- 200
- 400
Transaction calldata and approvals for repay
Validation error