Skip to main content
POST
Closes an active loan whose debt is zero and releases the pledged collateral. In FREEZE markets the tokens are unfrozen in the borrower’s wallet. In CUSTODY markets they are transferred back from the adapter. Only the loan’s borrower can sign it, and closing moves no settlement money and charges no fee. A repayment that clears the whole debt already closes the loan in the same transaction. A loan repaid through Repay Loan with all: true therefore needs no close call, and closing it again returns LOAN_ALREADY_CLOSED.
On a CUSTODY market whose collateral token refuses the return, closing does not revert. The adapter escrows the collateral instead, so the borrower signs a transaction that confirms and delivers nothing. The calldata response then carries collateralRelease and warning. Show them before the borrower signs, and reclaim the collateral through Claim Escrowed Collateral once the restriction is lifted.
The endpoint validates loan state on-chain before offering a transaction, so a loan with any outstanding balance is refused with a clear reason rather than an opaque revert.

Path Parameters

string
required
The market’s record ID, as id on List Markets, not its contract address. See Market IDs.

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
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.

Response Fields

object
Interest accrues until the moment of repayment, so a loan repaid with a stale quote almost always carries a small residual balance. DEBT_OUTSTANDING reports the exact remainder. Repay the rest with all: true, which closes the loan itself.
A confirmed close also marks the Trusset position with a closedAt timestamp and the status REPAID, or LIQUIDATED when the position was liquidated and nothing was repaid since. A position already marked LIQUIDATED keeps that status. Without a confirm call, the position is reconciled on the next sync.

Error Codes

Confirming with txHash can also return any transaction verification error.