Open the app

Open a repo

Lenders post cash on terms; borrowers pledge units and receive the cash in the same instruction.

A repo starts with a lender posting cash against an instrument on /app/repo. A borrower pledges units of that instrument and receives the cash in the same transaction, and the units stay in the borrower's position, still earning income, until the repo is repaid or defaults.

Lend: post a repo offer

You need free ledger cash for the whole amount you lend.

  1. Lend cash against units

    On /app/repo, choose the instrument under Against instrument and enter the Units you lend against, the Advance per unit in USD, the Rate in percent a year, and a Term of 1h, 1d, 7d, 30d, 90d or 365d.

  2. Check the lock

    Locks now shows the cash that posting locks: units × advance per unit, from your free cash.

  3. Sign and post

    Press Review repo offer, then Sign and post. The offer appears under Repo offers, and the cash shows as locked in your ledger cash.

ts
// Lend against up to 1,000 units of HALDEN31: 950 USD a unit, 500 bps a year, 7 days.
await send(
  await api.buildPostRepoOffer({
    wallet,
    code: 'HALDEN31',
    units: '1000',
    advancePerUnit: '950000000',
    rateBps: 500,
    termSeconds: 604_800,
  }),
  sign,
)

To take the cash back, cancel the offer: Cancel beside it in the Repo panel of your account page, or buildCancelRepoOffer({ wallet, repoOfferId }). Repos already opened from it are not affected.

Borrow: take a repo offer

You need free units of the offer's instrument and the SOL for the repo account's rent.

  1. Choose an offer

    Repo offers lists each lender, the instrument it lends against, the advance per unit, rate, term and cash available. Choose one.

  2. Units to pledge

    The panel reads Borrow against the instrument. Enter the units; it shows the cash you receive now, the repurchase amount and the maturity in UTC.

  3. Sign and pledge

    Press Review repo, then Sign and pledge. Your units move to the pledged lane and the cash is free in your ledger cash. The repo appears under My repos as Borrower, with its maturity and the time left.

ts
const offers = await api.repoOffers()
const offer = offers.find((o) => o.code === 'HALDEN31' && o.status === 'open')
if (offer) {
  const build = await api.buildTakeRepo({ wallet, repoOfferId: offer.id, units: '100' })
  console.log(build.summary.repurchaseAmount, build.summary.maturity) // fixed now, for the whole term
  await send(build, sign)
}

send is the helper from A first settlement.

What it ends in

PostTake 100 units (the example above)
Lender's cashfree → locked: 950,000.00 USDlocked: − 95,000.00 USD
Borrower's unitsfree → pledged: 100
Borrower's cashfree: + 95,000.00 USD
RecordsRepoOffer openRepo active, repurchase 95,091.095891 USD, maturity 7 days on

The settlements are the kinds post-repo-offer and repo-open. From here the borrower repays before maturity, or the lender settles the default after it.

If it fails

  • TermOutOfRange: the term is shorter than 1 hour or longer than 365 days.
  • InvalidRepoAmount: the cash posted doesn't cover one unit's advance.
  • InsufficientFreeCash: the lender's free cash is short of the amount.
  • InsufficientFreeUnits: the borrower's free units are short. Units in an ask or another repo don't count.
  • OfferTooSmall: the units' advance is more than the offer's cash available.
  • SelfTrade: a lender can't borrow from their own offer.