API/Endpoints

Borrow transactions

Borrowing from your own wallet follows the same build, sign, execute pattern as agent transactions, on its own routes.

Build#

POST/v1/borrow/tx

With { action, …fields } → 201 { ok, txId, action, bytes, expiresAtMs }.

Every check below runs before anything is signed, so a refusal costs nothing.

The operator pays the network fee for borrow transactions, up to 1 SUI a day for all users together. Once that is used up, the build or the execute answers 429 SPONSOR_BUDGET_SPENT. Build the same transaction again with "gas": "own" in the body and your wallet pays its own fee. The app asks you first.

Execute#

POST/v1/borrow/tx/:txId

With { "signature": "…" }.

JSON
{ "ok": true, "digest": "…", "action": "offer-fill", "loanId": "0x…" }

roomId is returned for room-open; loanId for room-settle, offer-fill, pool-borrow and refinance. Errors: NO_SUCH_TX 404, TX_EXPIRED 410 (after 120 seconds), TX_FAILED 502 with digest.

Actions#

Open a room — room-open#

FieldTypeRule
collateraldecimal stringSUI to escrow.
amountdecimal stringUSDC to borrow.
maxRateBpsinteger1 to 100,000.
termDaysinteger1, 7 or 30.
windowSecondsintegerBidding time, 30 to 21,600.
settleWindowSecondsintegerTime to pick a bid after close. The minimum is 120 seconds; 60 is BAD_SETTLE_WINDOW. The maximum is 21,600.

Refusals: BAD_COLLATERAL, BAD_AMOUNT, BAD_MAX_RATE, BAD_TERM, BAD_WINDOW, BAD_SETTLE_WINDOW, LTV_TOO_HIGH (400); PRICE_STALE, INSUFFICIENT_SUI (409).

Settle a room — room-settle#

Open the bids in your browser first; then send the one you pick.

FieldType
roomIdstring
indexinteger, the bid's index in the room
rateBps, salt, treasuryId, capIdthe bid's opening; salt is 64 hex digits

Refusals: BAD_ROOM_ID, BAD_RATE, BAD_SALT, BAD_TREASURY_ID, BAD_CAP_ID, OVER_MAX_RATE, NO_SUCH_OFFER, OPENING_MISMATCH (400); NO_SUCH_ROOM (404); ROOM_NOT_OPEN, ROOM_NOT_CLOSED, SETTLE_WINDOW_CLOSED, NO_CONSENT, PRICE_STALE (409). NO_CONSENT means the lender's treasury holds no consent for this bid, which the chain would refuse.

Leave a room — room-decline, room-refund#

{ roomId }. Decline works any time the room is open; refund only after the settle window. Refusals: ROOM_NOT_OPEN, SETTLE_WINDOW_OPEN (409).

Fill an offer — offer-fill#

FieldType
offerIdstring
collateral, amountdecimal strings
maxRateBpsinteger; the offer's rate must not exceed it

Refusals, in order: NO_SUCH_OFFER (404), OFFER_EXPIRED, OFFER_TOO_SHORT (409), OVER_MAX_RATE, OUTSIDE_OFFER_FILLS (400), OFFER_FULL (409), LTV_TOO_HIGH, OVER_OFFER_LTV (400), then the lender's mandate as the chain will check it (409), then INSUFFICIENT_SUI (409). OFFER_TOO_SHORT is an offer whose term is under six hours.

The mandate refusals are MANDATE_GONE, CAP_EXPIRED, OUTSIDE_MANDATE_FILLS, OVER_MANDATE_CAP, COLLATERAL_NOT_ALLOWED, OVER_MANDATE_LTV, RATE_BELOW_MANDATE, TERM_OUTSIDE_MANDATE, TAKER_NOT_ALLOWED and LENDER_SHORT.

Borrow from the pool — pool-borrow#

{ collateral, amount, maxRateBps }. maxRateBps caps the pool's rate right after your draw; the loan floats from there. Refusals: NO_POOL (404), POOL_SHORT (409), OVER_MAX_RATE, LTV_TOO_HIGH (400), PRICE_STALE, INSUFFICIENT_SUI (409).

Repay — repay#

{ loanId }. Pays what the loan will owe five minutes from now, to cover signing time; the change comes back in the same transaction. Refusals: BAD_LOAN_ID (400), NO_SUCH_LOAN (404), LOAN_NOT_OPEN, INSUFFICIENT_FUNDS (409).

Add collateral — add-collateral#

{ loanId, collateral } in SUI. Refusals: BAD_COLLATERAL (400), INSUFFICIENT_SUI (409).

Refinance — refinance#

{ loanId, offerId }; use the offerId from a REFINANCE_CHEAPER warning. Refusals: NO_SUCH_OFFER (404), PRICE_STALE, OFFER_DOES_NOT_FIT (409), and the mandate refusals above. Known limit: Ptb.deskRefinance from an offer into another offer of the same lender treasury passes that treasury twice and aborts CommandArgumentError at argument 5. Pool to offer, and offer to a different lender, work. The SDK does not rewrite this.

Claim the leftover — claim-surplus#

{ loanId }, after a liquidation, write-off or default. Refusal: NOTHING_TO_CLAIM (409).

Common refusals#

UNKNOWN_ACTION (400), DAILY_TX_LIMIT (429) and SPONSOR_BUDGET_SPENT (429).

There is no liquidate action. Liquidation is a chain call, and it stays refused until the live Pyth price is through the line at both spot and EMA. See Liquidation & default. room-open opens a v1 loan room, which publishes every losing rate at settle. Open a private_room_v2 room instead (Hand this to your agent).