Orders and matching
In the contracts, orders are called intents. Amounts are in the token's smallest units, rates are yearly in basis
points (620 is 6.20%), durations are in seconds and times are Unix timestamps.
This page describes behaviour. Field and function names below are the onchain call surface builders use today; contract source is not verified on the explorer yet.
Lend order#
Posted through Main. Optional: a position hint so the rate-sorted list stays cheap to update.
| Setting | Meaning |
|---|---|
| Loan asset | The asset lent, e.g. USDC. |
| Smallest fill | The minimum amount one loan can take. |
| Total size | The most this order can lend in total. |
Rate (minRate) | Fixed yearly rate in basis points. Every match against this order runs at exactly this rate (not a floor). |
| Shortest / longest term | Allowed loan length, in seconds. |
| Collateral | The one collateral asset accepted. |
| Max LTV / liquidation LTV | Origination and liquidation loan-to-value, in basis points (origination against principal plus full-term interest). |
| Open until | When the order stops matching. |
| Funding | Earn source, or the wallet (zero address). |
| Partial fills | Whether fills below the total size are allowed. |
| Max per borrower | Cap on how much one wallet can fill in total. 0 means no limit. |
| Early repayment | Fee as basis points of interest left to maturity, or blocked entirely. |
Lifecycle hooks are not set on the order. Lenders opt in once via
LenderCallbackDispatcher.register — see Lender callbacks.
Available capacity is the lesser of what's left on the order and the owner's free funds after their other open orders with the same asset and funding source (Earn balance, or wallet balance and allowance).
When the order is posted, the protocol also snapshots interest, refinancing and early-repayment fees. A loan opened from the order keeps the lower of that snapshot and the fee at origination, so a later fee increase never applies to it.
Borrow order#
Posted through Main, or posted and matched in the same transaction (see Matching).
| Setting | Meaning |
|---|---|
| Loan asset | The asset to borrow. |
| Amount | How much to borrow, before matching and origination fees come out of it. |
| Max rate | Highest yearly rate accepted, in basis points. |
| Term | Loan length, in seconds. |
| Collateral | Asset locked, and the most the borrower will lock across fills. |
| Open until | When the order stops matching. |
| Auto-refinance threshold | Lets anyone refinance to a lend order below this rate. 0 turns it off. |
| Matching fee | Tip to the solver who settles a fill, capped by the protocol. |
| Fill rules | All-or-none, and/or a smallest single fill. |
| Lender terms accepted | Highest early-repayment fee, whether blocked early repayment is OK, and lowest liquidation LTV accepted. |
When the order is posted, the protocol snapshots the origination fee. Every fill is charged the lower of that snapshot and the fee at fill time.
A match against a lender outside the borrower's terms reverts. Lend and borrow orders smaller than the market's minimum fill are rejected.
Stored orders#
Each order has an id, owner, filled amount and active flag. It deactivates when fully filled, cancelled or expired. Anyone can deactivate a lend order that has expired, or whose owner no longer has the funds behind it. Cancel your own order through Main.
Matching#
A match pairs a lend order with a borrow order and opens a loan in the same transaction. All matching goes through Main, except liquidation.
| Path | Who calls | What happens |
|---|---|---|
| Manual | Owner of either order | Matches two existing orders. |
| Submit and match | The borrower | Posts a borrow order and matches it with a chosen lend order, atomically. |
| Auto-match | The borrower | Posts a borrow order and matches it with the best compatible lend order. Reverts if none fits; simulate first. |
| Solver batch | Any solver | Settles many matches at once. The caller's own transaction authorises the batch; there is no separate signature. |
Every path runs at the lender's fixed rate (minRate), which must be at most the borrower's max rate. Only solver
batches pay the matching fee, and only when a solver other than the borrower settles the match.
Solver batches#
A batch lists matches as parallel arrays of lend order ids, borrow order ids and fill amounts, plus the solver address
(must be the caller) and a deadline. There is no rate or tip field on the batch: each loan takes the lender's fixed rate
(minRate) and pays the borrow order's own matching fee.
Each match opens its own loan. Registered lender callbacks are best-effort (gas-capped, failures ignored), so a reverting hook can't stop a later match in the batch. See Solvers and keepers and Lender callbacks.
Refinancing#
| Who | What happens |
|---|---|
| The borrower | Moves the loan to a chosen lend order. |
| Anyone (keeper) | If auto-refinance is on, moves the loan to the first lend order below the threshold with room and the same collateral. The keeper earns a share of the refinancing fee, whether it calls the matching engine or Main. A borrower who triggers their own loan earns none. |
Both close the old loan and open a new one with the remaining term. Both count as early repayment: they revert if the old lender blocked early repayment. The outgoing lender is paid principal, interest so far and any early-repayment fee, less protocol fees. A refinance can't worsen early-repayment terms.
Pausing#
Matching and refinancing respect protocol, market and feature pauses. Check pause state onchain before sending. Liquidation, repayment, withdrawal and adding collateral are not paused by those checks.