Borrow
Routes for borrowing from your own wallet: you sign every transaction yourself, and loans open in your address's name. All need a session. To have an agent borrow for you instead, create a borrower agent: see Agents.
Quote#
— what each route would give, before anything is signed.
| Field | Type |
|---|---|
| collateral | decimal string, SUI |
| amount | decimal string, USDC |
{
"ok": true,
"price": { "spot": "0.93592165", "ema": "0.93672012", "publishMs": 1792901005000 },
"market": { "ltvBps": 5000, "liqBps": 7500, "bonusBps": 500 },
"health": { "valueAtBorrow": "…", "ltvBps": 3200, "liqBps": 7500, "underwater": false, "liquidationPrice": "…" },
"routes": {
"offer": { "offerId": "0x…", "rateBps": 800, "termMs": 86400000 },
"pool": { "rateBps": 520, "floating": true, "available": "…" },
"room": { "rateBps": null, "note": "lenders bid blind; you see the rates only after close" }
},
"warnings": []
}Values are illustrative.
routes.offer and routes.pool are null when that route does not qualify. The null has no reason field of its own. The reason that the server attaches is a top-level warnings entry.
routes.offeris the cheapest listed offer that is still open, lasts at least 6 hours, fitsamountinside its min and max fill and its remaining size, and whose LTV ceiling and lend rules accept this borrower. It isnullwhen none qualify. It is alsonullwhile the offer index is loading.routes.poolisnullwhen there is no pool, the pool quote could not be read, or the pool holds less thanamount. A missing pool is not itself a warning.routes.roomis always present and itsrateBpsis alwaysnull: lenders bid blind, and the rates are unknown until close.- Quote
warningscodes:OFFERS_LOADING— "the offer list is still loading from the chain: try again in a moment".routes.offerisnullin that case.LTV_TOO_HIGH— "over the market's borrow limit: add SUI or borrow less". The quote still returnsok: true. This warning does not by itself null a route: an offer whose own LTV ceiling allows the loan can still beroutes.offer, and the pool route does not apply the market LTV.
Other warning codes, on loans and rooms rather than on the quote:
| Code | Where |
|---|---|
LIQUIDATABLE | A loan, over the safety line at both prices. |
LTV_NEAR_LINE | A loan, within 10 points of that line. |
MATURITY_SOON | A loan, due within the hour. |
PAST_MATURITY | A loan, past due. |
REFINANCE_CHEAPER | A loan; carries offerId. |
PRICE_STALE | A loan list, when the SUI price is stale. |
ROOM_CLOSING | A room, bidding ends within a minute. |
SETTLE_WINDOW_CLOSING | A room, within five minutes of the end of the settle window. |
ROOM_NO_BIDS | A room, no bid. |
ROOM_REFUNDABLE | A room, the settle window has passed. |
Errors: BAD_COLLATERAL 400, BAD_AMOUNT 400, PRICE_STALE 409.
Preview a borrower agent's rules#
With { form } → { ok, sentence, chain } or 400 BAD_FORM with errors. The form is described in Agent transactions. chain holds suiBudget, cashFloat, cashBudget, capExpiresAtMs, repayByMs, maxOwed, and borrow — the borrow rules { maxRateBps, minTermMs, latestMaturityMs, poolId, allowance } the deposit will write on chain; poolId is the deployment's pool for a switcher and null otherwise, and allowance (a string in USDC base units) is the form's amount plus 0.001 USDC per refinance for a switcher.
Rooms#
{ ok, nowMs, rooms }The sealed rooms you opened.
{ ok, nowMs, room, offers, seal }| Field | What it is |
|---|---|
| room | The room's terms and state, plus phase and warnings. |
| offers | Each sealed bid: {index, lender, commitment, ciphertext}, ciphertext in base64. |
| seal | What your browser needs to open the bids: {pkg, loanCoin, identity, keyServers, threshold}. |
phase is bidding, open-bids, refundable, settled, declined or refunded. Room warnings: ROOM_CLOSING (bidding ends within a minute), SETTLE_WINDOW_CLOSING (within five minutes), ROOM_NO_BIDS, ROOM_REFUNDABLE.
Errors: BAD_ROOM_ID 400, NO_SUCH_ROOM 404 (also for a room that is not yours).
Loans#
{ ok, nowMs, priceStale, offersLoading, more, loans }The newest 50 loans your address opened whose deed it still holds; more is true when older ones were not read, offersLoading while the offer list is still loading (no cheaper-offer hints until it has).
| Field | Notes |
|---|---|
| loanId, deedId, state, principal, collateral, lenderKind, maturityMs | maturityMs is 0 for a pool loan. |
| rateBps, floating | A pool loan's rate is the pool's this second, and floating is true. |
| owedNow | What it owes this second. |
| health | {valueAtBorrow, ltvBps, liqBps, underwater, liquidationPrice}, or null when the price is stale or the loan is closed. |
| warnings | See below. |
| Warning | Meaning |
|---|---|
LIQUIDATABLE | Over the line at both prices; anyone can close it now. |
LTV_NEAR_LINE | Within 10 points of the line. |
MATURITY_SOON | Due within the hour. |
PAST_MATURITY | Past due; after the grace period the lender can collect. |
REFINANCE_CHEAPER | A cheaper offer you can move to is open; carries offerId. |
PRICE_STALE | The SUI price is over five minutes old. |
History#
{ ok, more, loans }Newest first: every loan your address opened and everything that happened to it since.
| Field | Notes |
|---|---|
| loanId, lenderKind, lenderId, principal, rateBps, collateralAtOpen | |
| openedAtMs, openDigest, closedAtMs, closeDigest | |
| outcome | open, repaid, refinanced, liquidated, written-off, defaulted or claimed. |
| refinancedInto | The new loan's id after a refinance. |
| steps | Each event: {kind, atMs, digest, data}. |
The history covers the newest 50 loans your address opened; more is true when older ones were not read.