Accounts and types
Every account the agora program owns, its address seeds and size, every field, and the types they use.
Every account below is owned by the agora program and starts with Anchor's 8-byte discriminator, which the sizes include. Seeds appear in order: text seeds are their UTF-8 bytes, public keys their 32 bytes, and ids 8 little-endian bytes. A PDA's bump is the canonical one.
| Account | Seeds | Bytes | What it is |
|---|---|---|---|
Ledger | "ledger" | 172 | Singleton settings for the register, admission and custody of ledger cash. |
Member | "member", wallet | 157 | Permanent admission record, identity and counters for one wallet. |
Instrument | "instrument", code | 208 | An issued security, its terms and its income and trading history. |
Position | "position", owner, asset | 120 | One wallet's units or cash across the free, locked and pledged lanes. |
Offer | "offer", maker, id (u64, little-endian) | 114 | Open commitment to buy or sell whole units at a fixed cash price. |
RepoOffer | "repo_offer", lender, id (u64, little-endian) | 110 | Cash a lender has reserved to advance against one instrument. |
Repo | "repo", borrower, id (u64, little-endian) | 185 | A borrower's collateral pledge, received advance and fixed repayment obligation. |
The cash vault is not an Anchor account: it is a classic SPL token account for the cash mint at the PDA with seed "vault", and its token authority is the Ledger account. Sizes and rent are in Measured figures.
Ledger
The singleton config, created by initialize. Its address is also the token authority of the cash vault, so only the program can move cash out of the vault.
| Field | Type | Description |
|---|---|---|
admin | Pubkey | Wallet authorized to update ledger settings. |
operator | Pubkey | Wallet whose signature authorizes a new member. |
cash_mint | Pubkey | Six-decimal SPL mint accepted as ledger cash. |
cash_vault | Pubkey | Token account holding cash deposited into the register. |
fee_recipient | Pubkey | Wallet whose cash ATA receives the settlement fee. |
fee_bps | u16 | Settlement fee in basis points of the gross cash leg. |
bump | u8 | PDA bump used to derive this account. |
vault_bump | u8 | PDA bump used to derive the cash vault. |
Member
Created by admit, one per wallet, never closed. Its three counters set the ids of the member's next offer, repo offer and borrowed repo.
| Field | Type | Description |
|---|---|---|
wallet | Pubkey | Wallet address of the admitted entity. |
role | Role | Holder or issuer permissions granted to the member. |
entity_name | string | Registered name of the entity represented by the wallet. |
admitted_at | i64 | Unix second when the operator and wallet completed admission. |
next_offer_id | u64 | ID the member must use for its next spot offer. |
next_repo_offer_id | u64 | ID the member must use for its next repo offer. |
next_repo_id | u64 | ID the borrower must use for its next repo. |
Instrument
Created by list_instrument. income_index and income_pool carry income; last_price is set by each fill.
| Field | Type | Description |
|---|---|---|
code | string | Unique uppercase instrument code used to derive its register account. |
name | string | Issuer's display name for the instrument. |
issuer | Pubkey | Wallet authorized to issue this instrument and pay its income. |
terms | Terms | Equity designation or bond coupon and maturity. |
face | u64 | Face value per bond unit in cash atoms, or zero for an equity. |
outstanding | u64 | Whole units of this instrument on the register. |
income_index | u128 | Cumulative cash atoms per unit scaled by 10 to the twelfth power. |
income_pool | u64 | Cash atoms still held for distributions to unit owners. |
last_price | u64 | Cash atoms per unit at the last fill, or zero before the first fill. |
created_at | i64 | Unix second when this record was created. |
bump | u8 | PDA bump used to derive this account. |
Position
Created on first use by whichever instruction credits or locks for that owner and asset. For units the asset is the Instrument's address; for ledger cash it is the cash mint, and pledged, snapshot and accrued stay 0.
| Field | Type | Description |
|---|---|---|
owner | Pubkey | Member wallet that owns this register position. |
asset | Pubkey | Instrument PDA for securities or the mint address for ledger cash. |
free | u64 | Whole units or cash atoms available to the owner. |
locked | u64 | Whole units or cash atoms reserved for outstanding offers. |
pledged | u64 | Whole units securing active repos in the owner's own account. |
snapshot | u128 | Instrument income index already accounted for by this position. |
accrued | u64 | Whole cash atoms earned and still available to claim. |
Offer
Created by post_offer, closed by cancel_offer or by the fill that takes its last unit. Rent returns to the maker.
| Field | Type | Description |
|---|---|---|
maker | Pubkey | Member wallet that posted the offer. |
instrument | Pubkey | Register account of the security involved in this operation. |
id | u64 | Wallet-local sequential ID used in the account's PDA seeds. |
side | Side | Buy locks cash and sell locks units. |
price | u64 | Cash atoms per whole unit offered. |
units_open | u64 | Whole units still available to fill after this operation. |
units_at_posting | u64 | Whole units offered before any fills. |
created_at | i64 | Unix second when this record was created. |
bump | u8 | PDA bump used to derive this account. |
RepoOffer
Created by post_repo_offer, closed by cancel_repo_offer or by the take that empties its cash. Rent returns to the lender.
| Field | Type | Description |
|---|---|---|
id | u64 | Wallet-local sequential ID used in the account's PDA seeds. |
lender | Pubkey | Member wallet lending cash against the instrument. |
instrument | Pubkey | Register account of the security involved in this operation. |
advance_per_unit | u64 | Cash atoms advanced per pledged whole unit. |
rate_bps | u16 | Annual simple interest in basis points, using actual seconds and a 365-day year. |
term_seconds | u32 | Seconds between opening the repo and its maturity. |
cash_available | u64 | Cash atoms remaining for further advances from the offer. |
created_at | i64 | Unix second when this record was created. |
Repo
Created by take_repo_offer and kept after it is repaid or defaulted.
| Field | Type | Description |
|---|---|---|
id | u64 | Wallet-local sequential ID used in the account's PDA seeds. |
borrower | Pubkey | Member wallet pledging its units and receiving the advance. |
lender | Pubkey | Member wallet lending cash against the instrument. |
instrument | Pubkey | Register account of the security involved in this operation. |
repo_offer | Pubkey | Lender's offer from which the advance is drawn. |
units_pledged | u64 | Whole collateral units pledged by the borrower. |
cash_advanced | u64 | Cash atoms transferred from the lender to the borrower at opening. |
repurchase_amount | u64 | Full cash atom amount due at repayment, including fixed interest. |
opened_at | i64 | Unix second when the borrower drew the advance. |
maturity | i64 | Unix second when the obligation matures. |
status | RepoStatus | Current repo state, active, repaid or defaulted. |
Types
The structs and enums accounts and events use. An enum is one byte for its variant, followed by the variant's fields.
Leg
One balance that moved, as events list them. A debit has credit: false.
| Field | Type | Description |
|---|---|---|
owner | Pubkey | Wallet for a register lane, instrument for an income pool, or SPL token account for custody. |
asset | Pubkey | Instrument PDA for securities or the mint address for ledger cash. |
lane | Lane | Balance on the register or in token custody affected by this entry. |
credit | bool | True when this entry adds to the named balance; false when it debits it. |
amount | u64 | Unsigned whole units or cash atoms moved on this entry. |
Lane
Where a leg's amount sat or arrived.
| Variant | Fields | Meaning |
|---|---|---|
Free | | A position's free lane. |
Locked | | A position's locked lane. |
Pledged | | A position's pledged lane. |
IncomePool | | An instrument's income pool. The leg's owner is the Instrument address. |
Token | | An SPL token account: the vault, a wallet's cash ATA or the fee account. |
Terms
An instrument's kind and, for a bond, its terms.
| Variant | Fields | Meaning |
|---|---|---|
Equity | | A share. Face is 0. |
Bond | coupon_bps: u16, maturity: i64 | A bond with a yearly coupon in basis points and a maturity in Unix seconds. Face is 1,000,000,000 cash atoms per unit. |
Role
A member's role.
| Variant | Fields | Meaning |
|---|---|---|
Holder | | Holds positions, trades, lends and borrows. |
Issuer | | Can also list instruments, issue their units and pay income. |
Side
An offer's side.
| Variant | Fields | Meaning |
|---|---|---|
Buy | | A bid. The maker locks units times price in cash. |
Sell | | An ask. The maker locks the units. |
RepoStatus
A repo's state.
| Variant | Fields | 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. |
CashDirection
Which way a CashMoved event went.
| Variant | Fields | Meaning |
|---|---|---|
Deposit | | USDC into the vault, credited to free ledger cash. |
Withdraw | | Free ledger cash debited, USDC out of the vault. |