For the complete documentation index, see llms.txt. This page is also available as Markdown.

Embed Credit (Borrowers & Builders)

Embed approval-gated credit directly in your product — let your users request financing, draw it down, and repay, without them ever touching a contract UI. This is the borrower side of a market, driven by the API for reads and wallet transactions for writes.


The borrower flow

Step
Who
Contract call
Notes

1. Request

Borrower

requestFinancing / requestFixedFinancing

Needs the market’s access token (NFT) — no ERC-20 approve.

2. Approve

Approver

approveRequest / declineRequest

Opens a timed receive window; moves no funds.

3. Draw down

Borrower

receiveFinancing

Fills from intents, cheapest first (auto-selected).

4. Repay

Anyone

repay / payInterest / repayPrincipal

Requires ERC-20 approve to the market.

See the Financing Request Lifecycle for the full state machine.


1. Discover markets and eligibility

# markets your arena exposes
curl -H "X-Arena-Key: $ARENA_KEY" "$ARENAS_API/lending/markets"
# access-token (NFT) contracts that gate borrowing, per chain
curl -H "X-Arena-Key: $ARENA_KEY" "$ARENAS_API/arena/access-tokens"

A user can request in a market only if they own one of that market’s access tokens.


2. Create a request

Build a requestFinancing (interest-accrual) or requestFixedFinancing (fixed-repayment) transaction against the market address (market.id). Key inputs:

  • amount and minAmount — the acceptable fill band (denormalize by assetToken.decimals).

  • maxRate (accrual) — annual APR converted to a per-second 1e18 rate; or repayAmount + duration (fixed).

  • recipient — where funds land; 0x0 defaults to the access-token holder.

While status = REQUESTED (0), the borrower can modifyRequest or closeRequest.


3. Draw down after approval

Once status = APPROVED (1) and inside the window (earliestReceiveTslatestReceiveTs, in ms), call receiveFinancing(requestId, intents):

  • Read market.intents[], keep usable ones, sort by rate ascending, and pack (adapter, intentId) into bytes32[] up to market.tranchesLimit.

  • In the standard flow, intent selection is automatic — the app picks the optimal set and shows a read-only preview.

  • Simulate first: the call returns (financingId, amount, err); a tx can mine yet still report LACK_OF_CAPACITY, MAX_RATE_EXCEEDED, or BELOW_MIN_AMOUNT.

See Intents & Liquidity.


4. Repay

Read live obligations on-chain (interestObligations + principalObligations) for an exact payoff — don’t trust the API leftToRepay snapshot. Then approve the asset token to the market and call repay (full) or payInterest / repayPrincipal (partial). Any address can pay.


After every write

Poll GET /provisioning-sync/last-synced-blocks until the transaction’s block is indexed, then refetch markets/requests so your UI reflects the new state.

Last updated