Developer overview
Build on the Return contract. How it is designed, and where to find guides, reference and addresses.
Return is one immutable contract, ReturnERC20Loans, on Robinhood Chain. It fills signed orders, holds collateral, issues each loan as an ERC721 note, and settles. It reads no prices and has no proxy, pool or router.
Design
- Orders are signed off-chain. A maker signs an EIP-712
Orderto lend or to borrow, and a taker fills it on-chain. Listing an order on-chain withpostis optional. - Each fill is its own loan, with its own ID, note and due date. An order can be filled in parts, down to its
minFill. - Loan terms live in events. The
Openedevent carries theLoanstruct. Every settlement call takes that struct back and checks it against the loan ID. - The note is the claim. Whoever holds the note is paid back, or receives the collateral after the deadline.
- Any two admitted tokens can be the collateral and the loan token, in either direction.
A loan, call by call
| Step | Call | Who |
|---|---|---|
| Make | Sign an Order. Optionally post(order, signature). | Maker |
| Take | fill(order, amount, signature) opens a loan and mints the note to the lender. | Taker |
| Pay back | repay(loan), up to repaymentDeadline(loan). | Anyone |
| Claim | foreclose(loan) after the deadline, if unpaid. | Anyone |
| Finish | collectRepayment(loan) if a payment was held; reclaimCollateral(loan) if someone else paid back. | Anyone / borrower |
Integration notes
- Keep the
Loanstruct fromOpened. A changed field is a different loan. - Read
repaymentDeadline(loan). Incident extensions can move it. - Simulate before you send. Balances, approvals and cancellations change;
previewFillchecks a fill's terms. - A repayment can be held. If the note holder cannot receive the loan token,
repayholds the payment and leaves the note untilcollectRepayment.
Resources
Deployments
Contract address and signing domain.
Sign and fill orders
Make, list, find, fill and cancel orders.
Settle loans
Pay back, claim and collect.
Functions
Every call, who may make it, and when.
Events and errors
What the contract emits, and why calls fail.
Limits and rounding
Limits on terms, and how fills are split.
ABI
The contract ABI.
Audits
The independent audit of the contract.
Last updated