Repo with collateral in place
Borrow cash against units that stay pledged in your own position, earning their income, and move to the lender only if the repo isn't repaid by maturity.
A repo on Agora is a loan of ledger cash against units. The lender posts the terms and locks the cash; a borrower takes it, and in the same instruction the borrower's units become pledged and the cash arrives. The units never leave the borrower's position. What happens at maturity is fixed when the repo opens: repaid in full before then, the pledge releases; not repaid, the pledged units go to the lender.
Borrower 9bFm…a1Cz
NGATE29 180 free · 120 pledged
Cash +108,000.00 USD
Lender 5tQe…Hn2d
NGATE29 0 free
Moves 108,000.00 USD of locked cash advanced
- Advance
- 900.00 USD per unit
- Rate
- 5.00% a year
- Term
- 7 days
- Repurchase
- 108,103.56 USD
- Status
- Active
The repo offer
A lender posts a RepoOffer for one instrument with post_repo_offer:
| Term | Meaning |
|---|---|
| Advance per unit | Cash atoms lent against each pledged unit |
| Rate | Yearly interest in basis points |
| Term | Seconds from opening to maturity, 1 hour to 365 days |
| Cash available | Cash the lender locks for borrowers, at least one unit's advance |
The cash moves from the lender's free lane to locked when the offer is posted. Borrowers can take it in parts until the cash runs out; the offer closes when the available cash reaches zero. The lender can cancel at any time to release what is left, including a remainder smaller than one unit's advance.
Opening a repo
A borrower takes the offer with take_repo_offer for a number of units, and one instruction:
- moves those units from the borrower's free lane to pledged,
- moves units × advance per unit from the lender's locked cash to the borrower's free cash,
- creates the
Repowith its maturity and its repurchase amount.
The maturity is the opening time plus the term. The repurchase amount is the advance plus interest for the whole term, rounded up to the next cash atom:
interest = ceil(advance × rate_bps × term_seconds / (10,000 × 31,536,000))
repurchase = advance + interestA borrower pledges 100 units of HALDEN31 against an offer of 950 USD per unit at 500 bps for 7 days (604,800 seconds). The advance is 95,000.00 USD, the interest 91.095891 USD, and the repurchase amount 95,091.095891 USD. Both are fixed at opening, and repaying early pays the same amount.
While it is open
The pledged units are still the borrower's. They sit in the pledged lane of the borrower's own position, they earn every income payment the issuer makes, and the borrower claims that income as usual. They can't be sold or pledged again until they are free.
Repaying
repay_repo works while the repo is active and the time is before maturity. It moves the repurchase amount from the borrower's free cash to the lender's free cash and releases the pledged units to the borrower's free lane, in one instruction. Repayment is in full only. At or after maturity it fails with RepoMatured.
Default
At or after maturity, settle_default delivers the pledged units to the lender's free lane and marks the repo Defaulted. Any wallet can call it, and there is no grace period. The keeper calls it for each repo on that repo's own maturity. Before maturity it fails with RepoNotMatured.
The transfer needs nothing from the borrower: the units have been pledged on the register since the repo opened, and the lender's unit position was created when the offer was posted, so the delivery is one instruction.
| Status | Meaning |
|---|---|
Active | Open. The borrower can repay until maturity. |
Repaid | Repaid in full before maturity. The pledge was released. |
Defaulted | Settled at or after maturity. The pledged units went to the lender. |
Repo accounts stay on the register after they are repaid or defaulted, as the record of the loan.
Repo ids
A repo's address is derived from the borrower's wallet and the borrower's next_repo_id counter; a repo offer's from the lender's wallet and next_repo_offer_id. Repos are never closed, so a take built on a stale repo id lands on an existing account and the System program refuses it as "already in use". A stale repo offer id fails the same way while that offer is open, and with InvalidId once it has closed. Build again; the API reads the counters when it builds.