Program instructions
Every instruction the agora program takes, with its arguments, accounts, effects and errors.
Agora is one Anchor program. The API serves its IDL at GET /idl.json, and every table on this page is read from it:
| Program | Address | Version |
|---|---|---|
agora | AwiCVSwQj1KaBBfyNmpkMhB2Dj6LdKdhaSqzd47NNsmw | 0.1.0 |
Amounts are u64: whole units for instruments, cash atoms for ledger cash. Times are Solana Unix timestamps in seconds. Every instruction also takes event_authority and program, for the event it emits through a self-CPI (Events). Account names follow the IDL, which is snake_case; Anchor's TypeScript client turns them into camelCase.
| Instruction | Arguments | Signers | Emits |
|---|---|---|---|
initialize | operator: Pubkey, fee_recipient: Pubkey | admin | Configured |
update_config | admin_key: Pubkey, operator: Pubkey, fee_recipient: Pubkey, fee_bps: u16 | admin | Configured |
admit | role: Role, entity_name: string | wallet, operator | Admission |
deposit | amount: u64 | owner | CashMoved |
withdraw | amount: u64 | owner | CashMoved |
list_instrument | code: string, name: string, terms: Terms | issuer | InstrumentListed |
issue | units: u64 | issuer | UnitsIssued |
post_offer | id: u64, side: Side, price: u64, units: u64 | maker | OfferPosted |
cancel_offer | none | maker | OfferCancelled |
take_offer | units: u64 | taker | Trade |
post_repo_offer | id: u64, advance_per_unit: u64, rate_bps: u16, term_seconds: u32, cash_available: u64 | lender | RepoOfferPosted |
cancel_repo_offer | none | lender | RepoOfferCancelled |
take_repo_offer | id: u64, units: u64 | borrower | RepoOpened |
repay_repo | none | borrower | RepoRepaid |
settle_default | none | caller | RepoDefaulted |
pay_income | amount: u64 | issuer | IncomePaid |
claim_income | none | owner | IncomeClaimed |
initialize
Creates the Ledger config and the cash vault, once. The signer must be the program's upgrade authority, named in its ProgramData account; it becomes the admin. The cash mint must have 6 decimals and is fixed for good. The fee starts at 2 bps.
Arguments
| Argument | Type | Description |
|---|---|---|
operator | Pubkey | Wallet whose signature authorizes a new member. |
fee_recipient | Pubkey | Wallet whose cash ATA receives the settlement fee. |
Accounts
| Account | Access | Description |
|---|---|---|
admin | signer, writable | Program upgrade authority that pays to create the ledger and vault. |
program_data | read | Upgradeable-loader record that identifies Agora's upgrade authority. Seeds: "�� �O+���q����)^/,�bj��%fN". |
ledger | writable | Singleton register configuration and vault authority. Seeds: "ledger". |
cash_mint | read | Six-decimal SPL mint accepted as ledger cash. |
cash_vault | writable | Token account holding cash deposited into the register. Seeds: "vault". |
token_program | read | Classic SPL Token program that moves cash between token accounts. Address TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA. |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits Configured.
Errors
| Code | Name | Message |
|---|---|---|
| 6019 | WrongUpgradeAuthority | The signer must be the program upgrade authority. |
| 6027 | BadCashMint | Cash must use a six-decimal SPL mint. |
| 6031 | UnsetAddress | Authority and fee recipient addresses must be set. |
update_config
Replaces the admin, operator, fee recipient and fee together. Only the current admin signs. The three keys must be set, and the fee is 0 to 50 bps.
Arguments
| Argument | Type | Description |
|---|---|---|
admin_key | Pubkey | Wallet that will administer the ledger after this update. |
operator | Pubkey | Wallet whose signature authorizes a new member. |
fee_recipient | Pubkey | Wallet whose cash ATA receives the settlement fee. |
fee_bps | u16 | Settlement fee in basis points of the gross cash leg. |
Accounts
| Account | Access | Description |
|---|---|---|
admin | signer | Wallet authorized to update ledger settings. |
ledger | writable | Singleton register configuration and vault authority. Seeds: "ledger". |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits Configured.
Errors
| Code | Name | Message |
|---|---|---|
| 6018 | FeeAboveCap | The settlement fee exceeds 50 basis points. |
| 6020 | WrongAdmin | The signer must be the ledger admin. |
| 6031 | UnsetAddress | Authority and fee recipient addresses must be set. |
admit
Creates the wallet's Member with its role and entity name. The wallet signs and pays the rent; the ledger's operator co-signs. The entity name must contain text and fit in 80 UTF-8 bytes. A wallet is admitted once: the member account can't be created twice.
Arguments
| Argument | Type | Description |
|---|---|---|
role | Role | Holder or issuer permissions granted to the member. |
entity_name | string | Entity name approved by the operator for this wallet. |
Accounts
| Account | Access | Description |
|---|---|---|
wallet | signer, writable | Applicant wallet signing admission and paying the member account rent. |
operator | signer | Wallet whose signature authorizes a new member. |
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
member | writable | Permanent membership record for the wallet. Seeds: "member", wallet. |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits Admission.
Errors
| Code | Name | Message |
|---|---|---|
| 6021 | WrongOperator | The admission needs the ledger operator's signature. |
| 6025 | BadName | Names must contain text and fit in 80 UTF-8 bytes. |
deposit
Moves amount cash atoms from the owner's associated token account for the cash mint into the vault, and credits the same amount to the owner's cash position, free. Creates the cash position on first use. The owner must be admitted.
Arguments
| Argument | Type | Description |
|---|---|---|
amount | u64 | Cash atoms to deposit into the vault. |
Accounts
| Account | Access | Description |
|---|---|---|
owner | signer, writable | Member wallet that owns this register position. |
member | read | Permanent membership record for the wallet. Seeds: "member", owner. |
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
owner_ata | writable | Owner's associated token account for the cash mint. |
cash_vault | writable | Token account holding cash deposited into the register. |
cash_position | writable | Owner's free and locked cash lanes on the register. Seeds: "position", owner, ledger.cash_mint. |
token_program | read | Classic SPL Token program that moves cash between token accounts. Address TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA. |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits CashMoved.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6001 | ZeroAmount | The amount must be positive. |
| 6003 | InsufficientFreeCash | The account has insufficient free cash. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6010 | NotAdmitted | This wallet needs an admitted member account. |
| 6030 | InvalidCashAccount | The wallet cash account must be its associated token account. |
withdraw
Debits amount from the owner's free cash and transfers it from the vault to the owner's associated token account for the cash mint. The owner must be admitted.
Arguments
| Argument | Type | Description |
|---|---|---|
amount | u64 | Cash atoms to withdraw from free ledger cash. |
Accounts
| Account | Access | Description |
|---|---|---|
owner | signer | Member wallet that owns this register position. |
member | read | Permanent membership record for the wallet. Seeds: "member", owner. |
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
owner_ata | writable | Owner's associated token account for the cash mint. |
cash_vault | writable | Token account holding cash deposited into the register. |
cash_position | writable | Owner's free and locked cash lanes on the register. Seeds: "position", owner, ledger.cash_mint. |
token_program | read | Classic SPL Token program that moves cash between token accounts. Address TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits CashMoved.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6001 | ZeroAmount | The amount must be positive. |
| 6003 | InsufficientFreeCash | The account has insufficient free cash. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6010 | NotAdmitted | This wallet needs an admitted member account. |
| 6030 | InvalidCashAccount | The wallet cash account must be its associated token account. |
list_instrument
Creates an Instrument from its code, name and terms, with the signer as issuer. The signer must be admitted with the Issuer role. The code is 1 to 12 ASCII uppercase letters or digits and is the account's seed. A bond's maturity must be later than now, and its face is set to 1,000,000,000 cash atoms; an equity's face is 0.
Arguments
| Argument | Type | Description |
|---|---|---|
code | string | Unique uppercase instrument code used to derive its register account. |
name | string | Issuer's display name for the instrument. |
terms | Terms | Equity designation or bond coupon and maturity. |
Accounts
| Account | Access | Description |
|---|---|---|
issuer | signer, writable | Wallet authorized to issue this instrument and pay its income. |
issuer_member | read | Membership record proving the issuer's admission and role. Seeds: "member", issuer. |
instrument | writable | Register account of the security involved in this operation. |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits InstrumentListed.
Errors
| Code | Name | Message |
|---|---|---|
| 6010 | NotAdmitted | This wallet needs an admitted member account. |
| 6022 | WrongRole | The member must hold the issuer role. |
| 6024 | BadCode | Instrument codes must contain 1 to 12 uppercase letters or digits. |
| 6025 | BadName | Names must contain text and fit in 80 UTF-8 bytes. |
| 6026 | BadMaturity | Bond maturity must be in the future. |
issue
Credits units to the recipient's free lane and raises outstanding by the same amount. Only the instrument's issuer signs, and the recipient must have a Member account. The recipient's position settles its income first.
Arguments
| Argument | Type | Description |
|---|---|---|
units | u64 | Positive number of whole instrument units. |
Accounts
| Account | Access | Description |
|---|---|---|
issuer | signer, writable | Wallet authorized to issue this instrument and pay its income. |
recipient_member | read | Membership record identifying the admitted recipient of issued units. |
instrument | writable | Register account of the security involved in this operation. |
position | writable | Owner's security position, including lanes and unpaid income. Seeds: "position", recipient_member.wallet, instrument. |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits UnitsIssued.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6001 | ZeroAmount | The amount must be positive. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6023 | NotIssuer | Only the instrument's issuer may perform this action. |
post_offer
Creates an Offer and locks its side: for Sell, units from the maker's free units; for Buy, units × price from the maker's free cash. id must equal the maker's next_offer_id, which then rises by one. Creates the maker's unit and cash positions as needed.
Arguments
| Argument | Type | Description |
|---|---|---|
id | u64 | Next ID from the signing member's counter. |
side | Side | Buy locks cash and sell locks units. |
price | u64 | Cash atoms per whole unit offered. |
units | u64 | Positive number of whole instrument units. |
Accounts
| Account | Access | Description |
|---|---|---|
maker | signer, writable | Member wallet that posted the offer. |
member | writable | Permanent membership record for the wallet. Seeds: "member", maker. |
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
instrument | read | Register account of the security involved in this operation. |
offer | writable | Spot offer whose reserved balance changes. Seeds: "offer", maker, id (u64, little-endian). |
maker_units | writable | Maker's position in the security offered. Seeds: "position", maker, instrument. |
maker_cash | writable | Maker's cash position reserved or credited by this offer. Seeds: "position", maker, ledger.cash_mint. |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits OfferPosted.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6001 | ZeroAmount | The amount must be positive. |
| 6002 | InsufficientFreeUnits | The account has insufficient free units. |
| 6003 | InsufficientFreeCash | The account has insufficient free cash. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6010 | NotAdmitted | This wallet needs an admitted member account. |
| 6011 | InvalidId | The offer or repo ID differs from the member counter. |
cancel_offer
Returns the offer's remaining lock to the maker's free lane and closes the offer, sending its rent to the maker. Only the maker signs.
Arguments: none.
Accounts
| Account | Access | Description |
|---|---|---|
maker | signer, writable | Member wallet that posted the offer. |
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
instrument | read | Register account of the security involved in this operation. |
offer | writable | Spot offer whose reserved balance changes. |
maker_units | writable | Maker's position in the security offered. Seeds: "position", maker, instrument. |
maker_cash | writable | Maker's cash position reserved or credited by this offer. Seeds: "position", maker, ledger.cash_mint. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits OfferCancelled.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6004 | InsufficientLockedCash | The account has insufficient locked cash. |
| 6005 | InsufficientLockedUnits | The account has insufficient locked units. |
| 6009 | WrongAccount | The account does not belong to this operation. |
take_offer
Fills units of the offer, 1 to its open size. Gross cash is units × price and the fee is floor(gross × fee_bps / 10,000), paid by the taker. Taking an ask: the maker's locked units go to the taker's free lane, and the taker's free cash pays gross plus fee, gross to the maker. Taking a bid: the taker's free units go to the maker's free lane, and the maker's locked cash pays gross, less the fee, to the taker. The fee moves from the vault to the fee recipient's cash ATA. Both unit positions settle income first. The instrument's last price becomes the offer's price, and a fill to zero closes the offer.
Arguments
| Argument | Type | Description |
|---|---|---|
units | u64 | Positive number of whole instrument units. |
Accounts
| Account | Access | Description |
|---|---|---|
taker | signer, writable | Member wallet filling another member's offer and paying the fee. |
taker_member | read | Membership record proving the taker's admission. Seeds: "member", taker. |
maker | writable | Member wallet that posted the offer. |
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
instrument | writable | Register account of the security involved in this operation. |
offer | writable | Spot offer whose reserved balance changes. |
maker_units | writable | Maker's position in the security offered. Seeds: "position", maker, instrument. |
maker_cash | writable | Maker's cash position reserved or credited by this offer. Seeds: "position", maker, ledger.cash_mint. |
taker_units | writable | Taker's security position delivering or receiving the fill. Seeds: "position", taker, instrument. |
taker_cash | writable | Taker's cash position paying or receiving the fill and fee. Seeds: "position", taker, ledger.cash_mint. |
cash_vault | writable | Token account holding cash deposited into the register. |
fee_account | writable | Cash ATA belonging to the configured fee recipient. |
token_program | read | Classic SPL Token program that moves cash between token accounts. Address TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA. |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits Trade.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6001 | ZeroAmount | The amount must be positive. |
| 6002 | InsufficientFreeUnits | The account has insufficient free units. |
| 6003 | InsufficientFreeCash | The account has insufficient free cash. |
| 6004 | InsufficientLockedCash | The account has insufficient locked cash. |
| 6005 | InsufficientLockedUnits | The account has insufficient locked units. |
| 6007 | SelfTrade | The maker cannot take their own offer. |
| 6008 | OfferTooSmall | The requested fill exceeds the available offer. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6010 | NotAdmitted | This wallet needs an admitted member account. |
| 6012 | InvalidFeeAccount | The fee destination must be the recipient's cash ATA. |
post_repo_offer
Creates a RepoOffer and locks cash_available from the lender's free cash. The advance per unit must be positive and fit at least once in the cash; the term is 3,600 to 31,536,000 seconds. id must equal the lender's next_repo_offer_id. Creates the lender's unit position in the instrument, so a default can credit it later.
Arguments
| Argument | Type | Description |
|---|---|---|
id | u64 | Next ID from the signing member's counter. |
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 the lender commits when posting this offer. |
Accounts
| Account | Access | Description |
|---|---|---|
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
lender | signer, writable | Member wallet lending cash against the instrument. |
lender_member | writable | Membership record used for the lender's next offer ID. |
instrument | read | Register account of the security involved in this operation. |
lender_cash | writable | Lender's ledger cash reserved, advanced or returned. Seeds: "position", lender, ledger.cash_mint. |
lender_units | writable | Lender's security position that receives defaulted collateral. Seeds: "position", lender, instrument. |
repo_offer | writable | Lender's offer from which the advance is drawn. Seeds: "repo_offer", lender, id (u64, little-endian). |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits RepoOfferPosted.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6001 | ZeroAmount | The amount must be positive. |
| 6003 | InsufficientFreeCash | The account has insufficient free cash. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6010 | NotAdmitted | This wallet needs an admitted member account. |
| 6011 | InvalidId | The offer or repo ID differs from the member counter. |
| 6013 | TermOutOfRange | Repo terms run from one hour to 365 days. |
| 6017 | InvalidRepoAmount | The available cash must cover at least one collateral unit. |
cancel_repo_offer
Returns the offer's remaining cash to the lender's free lane and closes it, sending its rent to the lender. Only the lender signs.
Arguments: none.
Accounts
| Account | Access | Description |
|---|---|---|
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
lender | signer, writable | Member wallet lending cash against the instrument. |
repo_offer | writable | Lender's offer from which the advance is drawn. |
lender_cash | writable | Lender's ledger cash reserved, advanced or returned. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits RepoOfferCancelled.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6004 | InsufficientLockedCash | The account has insufficient locked cash. |
| 6009 | WrongAccount | The account does not belong to this operation. |
take_repo_offer
Opens a Repo: moves units from the borrower's free lane to pledged, and units × advance_per_unit from the lender's locked cash to the borrower's free cash. Maturity is now plus the term. The repurchase amount is the advance plus ceil(advance × rate_bps × term_seconds / 315,360,000,000). id must equal the borrower's next_repo_id. Closes the repo offer when its cash reaches zero.
Arguments
| Argument | Type | Description |
|---|---|---|
id | u64 | Next ID from the signing member's counter. |
units | u64 | Positive number of whole instrument units. |
Accounts
| Account | Access | Description |
|---|---|---|
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
borrower | signer, writable | Member wallet pledging its units and receiving the advance. |
borrower_member | writable | Membership record used for the borrower's next repo ID. |
lender | writable | Member wallet lending cash against the instrument. |
instrument | read | Register account of the security involved in this operation. |
repo_offer | writable | Lender's offer from which the advance is drawn. |
borrower_units | writable | Borrower's collateral position with its free and pledged lanes. Seeds: "position", borrower, instrument. |
borrower_cash | writable | Borrower's free cash credited at opening or debited on repayment. Seeds: "position", borrower, ledger.cash_mint. |
lender_cash | writable | Lender's ledger cash reserved, advanced or returned. |
repo | writable | Register account for this borrowing agreement. Seeds: "repo", borrower, id (u64, little-endian). |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits RepoOpened.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6001 | ZeroAmount | The amount must be positive. |
| 6002 | InsufficientFreeUnits | The account has insufficient free units. |
| 6004 | InsufficientLockedCash | The account has insufficient locked cash. |
| 6007 | SelfTrade | The maker cannot take their own offer. |
| 6008 | OfferTooSmall | The requested fill exceeds the available offer. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6010 | NotAdmitted | This wallet needs an admitted member account. |
| 6011 | InvalidId | The offer or repo ID differs from the member counter. |
repay_repo
For an active repo before its maturity: moves the repurchase amount from the borrower's free cash to the lender's free cash, moves the pledged units back to the borrower's free lane, and marks the repo Repaid. Only the borrower signs.
Arguments: none.
Accounts
| Account | Access | Description |
|---|---|---|
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
borrower | signer | Member wallet pledging its units and receiving the advance. |
repo | writable | Register account for this borrowing agreement. |
borrower_cash | writable | Borrower's free cash credited at opening or debited on repayment. |
lender_cash | writable | Lender's ledger cash reserved, advanced or returned. |
borrower_units | writable | Borrower's collateral position with its free and pledged lanes. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits RepoRepaid.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6003 | InsufficientFreeCash | The account has insufficient free cash. |
| 6006 | InsufficientPledgedUnits | The account has insufficient pledged units. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6015 | RepoMatured | The repo has reached maturity. |
| 6016 | RepoNotActive | The repo is no longer active. |
settle_default
For an active repo at or after its maturity: moves the pledged units from the borrower to the lender's free lane and marks the repo Defaulted. Any wallet signs. Both unit positions settle income first.
Arguments: none.
Accounts
| Account | Access | Description |
|---|---|---|
caller | signer | Wallet submitting permissionless default settlement. |
instrument | read | Register account of the security involved in this operation. |
repo | writable | Register account for this borrowing agreement. |
borrower_units | writable | Borrower's collateral position with its free and pledged lanes. |
lender_units | writable | Lender's security position that receives defaulted collateral. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits RepoDefaulted.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6006 | InsufficientPledgedUnits | The account has insufficient pledged units. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6014 | RepoNotMatured | The repo has not reached maturity. |
| 6016 | RepoNotActive | The repo is no longer active. |
pay_income
Moves amount from the issuer's free cash into the instrument's income pool and raises its income index by floor(amount × 10^12 / outstanding). Only the instrument's issuer signs, and units must be outstanding.
Arguments
| Argument | Type | Description |
|---|---|---|
amount | u64 | Cash atoms the issuer will distribute to holders. |
Accounts
| Account | Access | Description |
|---|---|---|
issuer | signer | Wallet authorized to issue this instrument and pay its income. |
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
instrument | writable | Register account of the security involved in this operation. |
issuer_cash | writable | Issuer's free ledger cash used to fund the distribution. Seeds: "position", issuer, ledger.cash_mint. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits IncomePaid.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6001 | ZeroAmount | The amount must be positive. |
| 6003 | InsufficientFreeCash | The account has insufficient free cash. |
| 6023 | NotIssuer | Only the instrument's issuer may perform this action. |
| 6028 | NoUnitsOutstanding | The instrument has no units outstanding. |
claim_income
Settles the owner's position in the instrument, then pays all its accrued whole cash atoms from the income pool to the owner's free cash. Creates the cash position if needed.
Arguments: none.
Accounts
| Account | Access | Description |
|---|---|---|
owner | signer, writable | Member wallet that owns this register position. |
ledger | read | Singleton register configuration and vault authority. Seeds: "ledger". |
instrument | writable | Register account of the security involved in this operation. |
position | writable | Owner's security position, including lanes and unpaid income. Seeds: "position", owner, instrument. |
cash_position | writable | Owner's free and locked cash lanes on the register. Seeds: "position", owner, ledger.cash_mint. |
system_program | read | Solana System Program that allocates new register accounts. Address 11111111111111111111111111111111. |
event_authority | read | Agora's PDA authenticating each settlement event. Seeds: "__event_authority". |
program | read | Executable Agora program receiving the event CPI. |
Emits IncomeClaimed.
Errors
| Code | Name | Message |
|---|---|---|
| 6000 | Overflow | An amount exceeds the register's numeric range. |
| 6009 | WrongAccount | The account does not belong to this operation. |
| 6029 | NothingToClaim | The position has no whole cash atoms to claim. |
Framework errors
Anchor checks the accounts before an instruction's own logic runs. A typed account that doesn't exist fails with AccountNotInitialized (issuing to a wallet that has no Member, for example), and a wrong PDA, owner or discriminator on a typed account fails with Anchor's own constraint errors. Where the program reads a member as an unchecked account (deposit, withdraw, list_instrument, take_offer), a missing one raises NotAdmitted instead. A transaction missing a required signature never reaches the program: the runtime rejects it. Creating an account that already exists (a second admission, a code already listed, a stale offer or repo id) fails in the System program as "already in use". SPL Token returns its own errors for a frozen token account or a short USDC balance.