Docs
$RETURNOpen app
Get startedBorrowLendSafetyDevelopers
Developers
Developers
Developer overviewDeployments

Guides

Sign and fill ordersSettle loans

Reference

FunctionsEvents and errorsLimits and roundingABI

Settle loans

Open in Claude

Pay back, claim or collect a loan through the contract, with only its funding transaction.

Every settlement call takes the loan's Loan struct, from its Opened event. Nothing else is needed: anyone can settle a loan from a block explorer or a script.

Without code

  1. Find the loan's funding transaction on a Robinhood Chain block explorer, or open the terms file saved from the loan page (see Track your loans).
  2. Copy the loan tuple from the Opened event exactly as recorded. A changed field gives a different loan ID, which the contract does not recognise.
  3. To repay: approve the market contract for the payback amount of the loan token, then call repay(loan).
  4. To claim after the deadline: call foreclose(loan). To collect a held payback: call collectRepayment(loan). To get collateral back after someone else paid back: call reclaimCollateral(loan) from the borrower wallet.

With code

repay.ts
const [opened] = await client.getContractEvents({
  address: MARKET, abi: loansAbi, eventName: "Opened", args: { id: loanId }, fromBlock: DEPLOY_BLOCK,
})
const loan = opened.args.loan

await wallet.writeContract({ account, address: loan.loanToken, abi: erc20Abi, functionName: "approve", args: [MARKET, loan.repayment] })
await wallet.writeContract({ account, address: MARKET, abi: loansAbi, functionName: "repay", args: [loan] })

foreclose, collectRepayment and reclaimCollateral take the same loan.

Checking a loan first

CallReturns
loanState(id)Maturity, and whether it is paid back and its collateral released.
repaymentDeadline(loan)The current last second to repay, including any extension. Zero for unknown terms.
heldRepayment(loan)A payback held for a note holder that could not receive it.
ownerOf(uint256(id))The current note holder, while the note exists.

Last updated 22 October 2026

Sign and fill orders

Make, list, find, fill and cancel orders, with viem.

Functions

Every function in the Return market contract: what it does, who may call it, and when.

On this page

Without codeWith codeChecking a loan first