Skip to main content
POST
Repays part or all of a loan’s outstanding debt. Accrued interest is settled before principal. Anyone can repay any loan, so a third party can rescue a position approaching liquidation. At least two transactions are required: an approval on the borrow asset, then the repayment. They come back as ordered steps.

Path Parameters

string
required
Market ID.

Body Parameters

integer
required
On-chain loan ID. A positive integer. Accepted as a JSON number or as a numeric string, so the value Get Loan returns passes straight back.
string
Amount to repay as a decimal string in borrow asset units. The contract caps repayment at the total debt, so overpaying does not transfer more than owed. Required unless all is true or you are confirming with txHash.
boolean
Repay the loan in full. The API reads the current debt and sizes the approval with a small overshoot, so interest accruing between the quote and the mine cannot leave dust behind. Use this instead of computing a payoff yourself.
string
Hash of the transaction you broadcast for this operation. Send it to confirm the transaction and record the result. Omit it to receive the calldata.

Transaction Shape

A partial repayment returns two steps: approve on the borrow asset, then repay. A full repayment (all: true) returns three. The third resets the allowance to zero. repay caps the pull at the true debt, so without it the unused approval would stay live against the payer’s funds after the loan closed.
On a full repayment the confirmable step is no longer the last one. Confirm with the hash of the step named by confirmStepIndex, which is always 1 here and always the step whose functionName is repay. Confirming with the allowance-reset hash returns TX_WRONG_TARGET.

Response Fields

object
Repaying the full debt does not release collateral on its own. Follow with Close Loan to unlock the pledged tokens and mark the position repaid.

Error Codes