Atomic settlement
Taking an offer moves the units, the cash and the fee in one instruction. If any leg can't move, none does.
take_offer is delivery versus payment in one Solana instruction. The units go from seller to buyer, the cash from buyer to seller, and the taker's settlement fee to the fee recipient, all before the instruction returns. A Solana transaction applies every change or none, so a trade can't be half settled.
Seller · maker
3kLm…Pq8w
- HALDEN31 locked
400- Cash free
- +41,212.00
Fee 8.24 USD (2 bps, paid by the taker) to the fee recipient
Buyer · taker
7Hq2…xT9a
- HALDEN31 free
- +40
- Cash free
- −41,220.24
The legs
Take 40 units from an ask at 25.50 USD, with the fee at 2 bps. The cash leg is 40 × 25,500,000 = 1,020,000,000 atoms (1,020.00 USD) and the fee is 204,000 atoms (0.204 USD).
| Leg | From | To | Amount |
|---|---|---|---|
| Units | maker, locked | taker, free | 40 units |
| Cash | taker, free | maker, free | 1,020.00 USD |
| Fee | taker, free | fee recipient's USDC account | 0.204 USD |
Taking a bid runs the other way: the taker's free units go to the maker's free lane, the maker's locked cash goes to the taker, and the taker receives the cash leg less the fee.
| Taker | Pays | Receives |
|---|---|---|
| Buys (takes an ask) | cash leg + fee, from free cash | the units, free |
| Sells (takes a bid) | the units, from free | cash leg − fee, free |
The fee is floor(cash leg × fee_bps / 10,000), paid by the taker on every fill. It leaves the vault for the fee recipient's USDC account in the same instruction. See Fees and the AGORA token.
What has to hold
The program checks every leg before it moves any of them. Any one of these fails the whole transaction:
| Check | Error |
|---|---|
| The taker is admitted | NotAdmitted |
| The taker isn't the maker | SelfTrade |
| Units are 1 to the offer's open size | ZeroAmount, OfferTooSmall |
| A buying taker has the cash leg plus the fee, free | InsufficientFreeCash |
| A selling taker has the units, free | InsufficientFreeUnits |
| The maker's lock covers the fill | InsufficientLockedUnits, InsufficientLockedCash |
| The fee account is the fee recipient's USDC account | InvalidFeeAccount |
Because the maker's side was locked when the offer was posted (Immediate execution), the lock check holds for every offer the program created.
After the fill
- The offer's open size falls by the units filled; at zero the offer closes and its rent goes back to the maker.
- The instrument's last price becomes the offer's price.
- Both parties' unit positions settle their income first, so income paid before the trade stays with the seller.
The settlement record
Every instruction emits one event that lists each balance it moved as a leg: owner, asset, lane, amount and direction. The indexer stores it as a settlement with the transaction's signature, slot and block time, and the ledger shows it the moment it lands. A take is the kind trade.
| Kind | Instruction | What settled |
|---|---|---|
admission | admit | A wallet was admitted. |
deposit | deposit | USDC deposited into free ledger cash. |
withdraw | withdraw | Free ledger cash withdrawn as USDC. |
list | list_instrument | An instrument was listed. |
issue | issue | Units were issued to a member. |
post-offer | post_offer | An offer was posted and its side locked. |
cancel-offer | cancel_offer | An offer was cancelled and its lock released. |
trade | take_offer | An offer was filled, in part or in full. |
post-repo-offer | post_repo_offer | A repo offer was posted and its cash locked. |
cancel-repo-offer | cancel_repo_offer | A repo offer was cancelled and its cash released. |
repo-open | take_repo_offer | A repo opened: units pledged, cash advanced. |
repo-repay | repay_repo | A repo was repaid and its pledge released. |
default | settle_default | A matured repo's pledged units went to the lender. |
income | pay_income | An issuer paid income into an instrument. |
claim | claim_income | A holder claimed income into free cash. |
At any hour
The program has no session and no calendar: every instruction runs in whichever slot it lands in, at any hour of any day.
··:··UTC now
- Agora ledger 00:00 to 24:00 UTC, every day
- NYSE regular session 14:30 to 21:00 UTC on weekdays, while New York is on standard time
Both legs settle on this ledger, against ledger cash. Settling against cash held on another chain is the road build "Cash on another chain", and choosing a later settlement time is "Settlement at a chosen time".