Program
Accounts, instructions, events and errors of the aside program, rendered from its IDL and source.
Program id 9PGMzRqww2wmM9SXkLqsoPYiFhSqRinWveXokjU2rifz on every cluster. Anchor 0.32.1, with events emitted as self-CPI. Every token account it touches is SPL Token; the configuration lives at DQM8TgHrJ3w3Tjw8BtLtLr9M7JuirdteWdNyYYaTdEUC. Amounts are in base units. Instruction and account names are as the IDL writes them.
Accounts
Config
The desk’s one configuration: admin, fee and allowed mints. Seeds ["config"]. 335 bytes with the 8-byte discriminator.
adminpubkeyWho can change the configuration.
fee_bpsu16The protocol fee, in basis points of the quote leg; at most 100.
fee_recipientpubkeyThe wallet that receives the fee, in its associated token account for each quote mint.
allowed_mintsVec<pubkey>, at most 8The mints the program trades and accepts deposits in; at most eight.
bumpu8The PDA bump.
Maker
One per maker wallet. Also the authority of that maker’s vaults. Seeds ["maker", owner]. 74 bytes with the 8-byte discriminator.
ownerpubkeyThe maker’s wallet.
quote_keypubkeyThe Ed25519 key quotes must be signed with.
activeboolWhether its quotes settle.
bumpu8The PDA bump.
UsedQuote
A record created when a quote settles. Its existence is what refuses the same quote a second time. Seeds ["quote", quote hash]. 80 bytes with the 8-byte discriminator.
makerpubkeyThe maker’s wallet.
takerpubkeyThe taker’s wallet.
slotu64The slot it settled in.
Vault
An SPL Token account at the PDA ["vault", maker owner, mint], one per maker per mint, whose authority is the Maker account. It is created by the maker’s first deposit in that mint, or by settle when it is the vault the maker receives into and does not exist yet.
Instructions
register_maker
Creates the maker account for the signing wallet, active, with the quote key it will sign quotes with. The owner pays its rent.
quote_keypubkeyrequiredThe Ed25519 public key quotes from this maker must be signed with.
| Account | Flags | Address | What it is |
|---|---|---|---|
owner | signer, writable | The maker’s wallet. | |
maker | writable | PDA "maker", owner | The maker account. |
system_program | 11111111111111111111111111111111 | The System program. | |
event_authority | PDA "__event_authority" | Signs the program’s self-CPI events. | |
program | This program, for the event self-CPI. |
Emits MakerRegistered.
set_quote_key
Replaces the maker’s quote key and sets whether it is active. Quotes signed with the old key stop settling once this lands; an inactive maker’s quotes do not settle at all.
quote_keypubkeyrequiredThe new quote key.
activeboolrequiredWhether the maker’s quotes settle.
| Account | Flags | Address | What it is |
|---|---|---|---|
owner | signer | The maker’s wallet. | |
maker | writable | PDA "maker", maker owner | The maker account. |
event_authority | PDA "__event_authority" | Signs the program’s self-CPI events. | |
program | This program, for the event self-CPI. |
Emits QuoteKeyUpdated. Can fail with Unauthorized.
deposit
Moves tokens from the owner’s token account into the maker’s vault for that mint, creating the vault on the first deposit. The mint must be in the allowed list.
amountu64requiredBase units to move; more than zero.
| Account | Flags | Address | What it is |
|---|---|---|---|
owner | signer, writable | The maker’s wallet. | |
config | DQM8TgHrJ3w3Tjw8BtLtLr9M7JuirdteWdNyYYaTdEUC | The configuration. | |
maker | PDA "maker", maker owner | The maker account. | |
mint | The token mint. | ||
owner_token | writable | The owner’s token account for the mint. | |
vault | writable | PDA "vault", owner, mint | The maker’s vault for the mint. |
token_program | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA | SPL Token. | |
system_program | 11111111111111111111111111111111 | The System program. | |
event_authority | PDA "__event_authority" | Signs the program’s self-CPI events. | |
program | This program, for the event self-CPI. |
Emits Deposited. Can fail with Unauthorized, InvalidAmount, MintNotAllowed, ArithmeticOverflow.
withdraw
Moves tokens from the maker’s vault back to the owner’s token account. It works whether or not the maker is active and whether or not the mint is still allowed.
amountu64requiredBase units to move; more than zero and at most the vault balance.
| Account | Flags | Address | What it is |
|---|---|---|---|
owner | signer | The maker’s wallet. | |
maker | PDA "maker", maker owner | The maker account. | |
mint | The token mint. | ||
owner_token | writable | The owner’s token account for the mint. | |
vault | writable | PDA "vault", maker owner, mint | The maker’s vault for the mint. |
token_program | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA | SPL Token. | |
event_authority | PDA "__event_authority" | Signs the program’s self-CPI events. | |
program | This program, for the event self-CPI. |
Emits Withdrawn. Can fail with Unauthorized, InvalidAmount, MakerInventoryShort, ArithmeticOverflow.
settle
Settles one signed quote: checks it against the Ed25519 instruction before it, records its hash, creates the maker’s receiving vault if needed, and moves both legs and the fee. Settlement walks through the checks and transfers.
sideu8required0 when the taker buys the base token, 1 when it sells.
base_amountu64requiredThe quote’s base amount.
quote_amountu64requiredThe quote’s quote amount, before the fee.
expires_ati64requiredThe quote’s expiry, Unix seconds. The quote settles up to and including this second.
nonceu64requiredThe quote’s nonce.
ed25519_indexu16requiredThe position in the transaction of the Ed25519 instruction that verifies this quote.
| Account | Flags | Address | What it is |
|---|---|---|---|
taker | signer, writable | The taker’s wallet. Signs, and pays the rent of the used-quote account and of a receiving vault this instruction creates. | |
config | DQM8TgHrJ3w3Tjw8BtLtLr9M7JuirdteWdNyYYaTdEUC | The configuration. | |
maker | PDA "maker", maker owner | The maker account. | |
base_mint | The base mint of the quote. | ||
quote_mint | The quote mint of the quote. | ||
taker_base | writable | The taker’s token account for the base mint. | |
taker_quote | writable | The taker’s token account for the quote mint. | |
base_vault | writable | PDA "vault", maker owner, base mint | The maker’s vault for the base mint. Created here on a taker sell if it does not exist yet. |
quote_vault | writable | PDA "vault", maker owner, quote mint | The maker’s vault for the quote mint. Created here on a taker buy if it does not exist yet. |
fee_quote | writable | The fee recipient’s associated token account for the quote mint. It must already exist. | |
used_quote | writable | The used-quote account for this quote’s hash, created by this instruction. | |
instructions | Sysvar1nstructions1111111111111111111111111 | The instructions sysvar, to read the Ed25519 instruction. | |
token_program | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA | SPL Token. | |
system_program | 11111111111111111111111111111111 | The System program. | |
event_authority | PDA "__event_authority" | Signs the program’s self-CPI events. | |
program | This program, for the event self-CPI. |
Emits Settled. Can fail with MakerInactive, InvalidSide, InvalidAmount, SameMint, MintNotAllowed, QuoteExpired, QuoteSignatureInvalid, InvalidUsedQuote, QuoteAlreadyUsed, InvalidFeeAccount, InvalidTokenAccount, MakerInventoryShort, ArithmeticOverflow.
init_config
Creates the configuration once. Only the program’s upgrade authority can sign it, and it becomes the admin.
fee_bpsu16requiredThe protocol fee in basis points; at most 100.
fee_recipientpubkeyrequiredThe wallet whose token account for each quote mint receives the fee.
allowed_mintsVec<pubkey>requiredThe mints the desk trades; unique, at most eight.
| Account | Flags | Address | What it is |
|---|---|---|---|
admin | signer, writable | Signs and pays; must be the program’s upgrade authority. | |
config | writable | PDA "config" | The configuration. |
program_account | 9PGMzRqww2wmM9SXkLqsoPYiFhSqRinWveXokjU2rifz | This program. | |
program_data | This program’s ProgramData, which names the upgrade authority. | ||
system_program | 11111111111111111111111111111111 | The System program. | |
event_authority | PDA "__event_authority" | Signs the program’s self-CPI events. | |
program | This program, for the event self-CPI. |
Emits ConfigUpdated. Can fail with Unauthorized, InvalidConfig.
set_config
Replaces the whole configuration. Only the current admin can sign it.
adminpubkeyrequiredThe admin after this change.
fee_bpsu16requiredThe protocol fee in basis points; at most 100.
fee_recipientpubkeyrequiredThe wallet whose token account for each quote mint receives the fee.
allowed_mintsVec<pubkey>requiredThe mints the desk trades; unique, at most eight.
| Account | Flags | Address | What it is |
|---|---|---|---|
authority | signer | The current admin. | |
config | writable | DQM8TgHrJ3w3Tjw8BtLtLr9M7JuirdteWdNyYYaTdEUC | The configuration. |
event_authority | PDA "__event_authority" | Signs the program’s self-CPI events. | |
program | This program, for the event self-CPI. |
Emits ConfigUpdated. Can fail with Unauthorized, InvalidConfig.
Events
Each event is emitted with emit_cpi!: an inner instruction from the program to itself, signed by the event authority PDA ["__event_authority"]. Its data is the 8-byte tag e445a52e51cb9a1d, the event’s discriminator, then the Borsh fields. Events from a failed transaction never count.
ConfigUpdated
Emitted by init_config, set_config. Discriminator 28f1e67a0b13c6c2.
adminpubkeyThe admin.
fee_bpsu16The fee in basis points.
fee_recipientpubkeyThe fee recipient.
allowed_mintsVec<pubkey>, at most 8The allowed mints.
Deposited
Emitted by deposit. Discriminator 6f8d1a2da1236439.
makerpubkeyThe maker account.
ownerpubkeyThe maker’s wallet.
mintpubkeyThe mint.
amountu64Base units moved into the vault.
MakerRegistered
Emitted by register_maker. Discriminator 459f8967267812c4.
makerpubkeyThe maker account.
ownerpubkeyThe maker’s wallet.
quote_keypubkeyIts quote key.
QuoteKeyUpdated
Emitted by set_quote_key. Discriminator 6c8960b64487a938.
makerpubkeyThe maker account.
ownerpubkeyThe maker’s wallet.
quote_keypubkeyThe new quote key.
activeboolWhether the maker is active.
Settled
Emitted by settle. Discriminator e8d228118e7c91ee.
quote_hash[u8; 32]The SHA-256 of the quote message.
makerpubkeyThe maker’s wallet.
takerpubkeyThe taker’s wallet.
base_mintpubkeyThe base mint.
quote_mintpubkeyThe quote mint.
sideu80 when the taker bought the base token, 1 when it sold.
base_amountu64Base units of the base mint that moved.
quote_amountu64The quote amount before the fee.
feeu64The fee paid, in base units of the quote mint.
Withdrawn
Emitted by withdraw. Discriminator 1459dfc6c27cdb0d.
makerpubkeyThe maker account.
ownerpubkeyThe maker’s wallet.
mintpubkeyThe mint.
amountu64Base units moved out of the vault.
Errors
Program errors arrive as custom error codes. Anchor’s own account-constraint errors (2000 to 2999) and SPL Token errors can also fail an instruction when an account or transfer is refused. Through the API, a refused simulation is SIMULATION_FAILED with the program error’s name and number in programError.
| Code | Name | Message | Raised when |
|---|---|---|---|
| 6000 | Unauthorized | The signer does not own this operation. | The signer is not the maker’s owner, the admin, or the upgrade authority the instruction needs. |
| 6001 | InvalidConfig | Fee bps must be at most 100 and allowed mints must be unique with at most eight entries. | The fee is above 100 bps, or the mint list repeats a mint or has more than eight. |
| 6002 | MintNotAllowed | The mint is not allowed. | A mint is not in the allowed list. |
| 6003 | MakerInactive | The maker is inactive. | The quote’s maker is inactive. |
| 6004 | InvalidAmount | Amounts must be greater than zero. | An amount is zero. |
| 6005 | InvalidSide | Side must be zero or one. | The side is neither 0 nor 1. |
| 6006 | SameMint | Base and quote mints must differ. | The base and quote mints are the same. |
| 6007 | QuoteExpired | The quote has expired. | The cluster time is past the quote’s expiry. |
| 6008 | QuoteSignatureInvalid | A prior self-contained Ed25519 instruction must verify the maker key and this exact quote. | The Ed25519 instruction at ed25519_index is missing, malformed, signed by a key other than the maker’s quote key, or over a message other than this quote. |
| 6009 | QuoteAlreadyUsed | The quote has already settled. | The quote has settled before. |
| 6010 | MakerInventoryShort | The maker vault has insufficient inventory. | The vault the maker pays from does not exist or holds less than its leg, or a withdrawal is larger than the vault. |
| 6011 | InvalidFeeAccount | The fee account must be the configured recipient's canonical quote ATA. | The fee account is not the fee recipient’s associated token account for the quote mint. |
| 6012 | InvalidTokenAccount | The token account does not match its owner and mint. | A vault passed to settle exists but is not an SPL Token account of that mint with the maker account as its authority. Other token accounts fail Anchor’s own token constraints instead. |
| 6013 | InvalidUsedQuote | The quote receipt account is invalid. | The used-quote account is not the address derived from this quote’s hash, or holds other data. |
| 6014 | ArithmeticOverflow | The amount arithmetic overflowed. | An amount would overflow 64 bits. |
The quote message the program rebuilds is laid out in What a quote signs.