Program

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.

adminpubkey

Who can change the configuration.

fee_bpsu16

The protocol fee, in basis points of the quote leg; at most 100.

fee_recipientpubkey

The wallet that receives the fee, in its associated token account for each quote mint.

allowed_mintsVec<pubkey>, at most 8

The mints the program trades and accepts deposits in; at most eight.

bumpu8

The 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.

ownerpubkey

The maker’s wallet.

quote_keypubkey

The Ed25519 key quotes must be signed with.

activebool

Whether its quotes settle.

bumpu8

The 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.

makerpubkey

The maker’s wallet.

takerpubkey

The taker’s wallet.

slotu64

The 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_keypubkeyrequired

The Ed25519 public key quotes from this maker must be signed with.

AccountFlagsAddressWhat it is
ownersigner, writableThe maker’s wallet.
makerwritablePDA "maker", ownerThe maker account.
system_program11111111111111111111111111111111The System program.
event_authorityPDA "__event_authority"Signs the program’s self-CPI events.
programThis 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_keypubkeyrequired

The new quote key.

activeboolrequired

Whether the maker’s quotes settle.

AccountFlagsAddressWhat it is
ownersignerThe maker’s wallet.
makerwritablePDA "maker", maker ownerThe maker account.
event_authorityPDA "__event_authority"Signs the program’s self-CPI events.
programThis 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.

amountu64required

Base units to move; more than zero.

AccountFlagsAddressWhat it is
ownersigner, writableThe maker’s wallet.
configDQM8TgHrJ3w3Tjw8BtLtLr9M7JuirdteWdNyYYaTdEUCThe configuration.
makerPDA "maker", maker ownerThe maker account.
mintThe token mint.
owner_tokenwritableThe owner’s token account for the mint.
vaultwritablePDA "vault", owner, mintThe maker’s vault for the mint.
token_programTokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DASPL Token.
system_program11111111111111111111111111111111The System program.
event_authorityPDA "__event_authority"Signs the program’s self-CPI events.
programThis 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.

amountu64required

Base units to move; more than zero and at most the vault balance.

AccountFlagsAddressWhat it is
ownersignerThe maker’s wallet.
makerPDA "maker", maker ownerThe maker account.
mintThe token mint.
owner_tokenwritableThe owner’s token account for the mint.
vaultwritablePDA "vault", maker owner, mintThe maker’s vault for the mint.
token_programTokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DASPL Token.
event_authorityPDA "__event_authority"Signs the program’s self-CPI events.
programThis 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.

sideu8required

0 when the taker buys the base token, 1 when it sells.

base_amountu64required

The quote’s base amount.

quote_amountu64required

The quote’s quote amount, before the fee.

expires_ati64required

The quote’s expiry, Unix seconds. The quote settles up to and including this second.

nonceu64required

The quote’s nonce.

ed25519_indexu16required

The position in the transaction of the Ed25519 instruction that verifies this quote.

AccountFlagsAddressWhat it is
takersigner, writableThe taker’s wallet. Signs, and pays the rent of the used-quote account and of a receiving vault this instruction creates.
configDQM8TgHrJ3w3Tjw8BtLtLr9M7JuirdteWdNyYYaTdEUCThe configuration.
makerPDA "maker", maker ownerThe maker account.
base_mintThe base mint of the quote.
quote_mintThe quote mint of the quote.
taker_basewritableThe taker’s token account for the base mint.
taker_quotewritableThe taker’s token account for the quote mint.
base_vaultwritablePDA "vault", maker owner, base mintThe maker’s vault for the base mint. Created here on a taker sell if it does not exist yet.
quote_vaultwritablePDA "vault", maker owner, quote mintThe maker’s vault for the quote mint. Created here on a taker buy if it does not exist yet.
fee_quotewritableThe fee recipient’s associated token account for the quote mint. It must already exist.
used_quotewritableThe used-quote account for this quote’s hash, created by this instruction.
instructionsSysvar1nstructions1111111111111111111111111The instructions sysvar, to read the Ed25519 instruction.
token_programTokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DASPL Token.
system_program11111111111111111111111111111111The System program.
event_authorityPDA "__event_authority"Signs the program’s self-CPI events.
programThis 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_bpsu16required

The protocol fee in basis points; at most 100.

fee_recipientpubkeyrequired

The wallet whose token account for each quote mint receives the fee.

allowed_mintsVec<pubkey>required

The mints the desk trades; unique, at most eight.

AccountFlagsAddressWhat it is
adminsigner, writableSigns and pays; must be the program’s upgrade authority.
configwritablePDA "config"The configuration.
program_account9PGMzRqww2wmM9SXkLqsoPYiFhSqRinWveXokjU2rifzThis program.
program_dataThis program’s ProgramData, which names the upgrade authority.
system_program11111111111111111111111111111111The System program.
event_authorityPDA "__event_authority"Signs the program’s self-CPI events.
programThis 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.

adminpubkeyrequired

The admin after this change.

fee_bpsu16required

The protocol fee in basis points; at most 100.

fee_recipientpubkeyrequired

The wallet whose token account for each quote mint receives the fee.

allowed_mintsVec<pubkey>required

The mints the desk trades; unique, at most eight.

AccountFlagsAddressWhat it is
authoritysignerThe current admin.
configwritableDQM8TgHrJ3w3Tjw8BtLtLr9M7JuirdteWdNyYYaTdEUCThe configuration.
event_authorityPDA "__event_authority"Signs the program’s self-CPI events.
programThis 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.

adminpubkey

The admin.

fee_bpsu16

The fee in basis points.

fee_recipientpubkey

The fee recipient.

allowed_mintsVec<pubkey>, at most 8

The allowed mints.

Deposited

Emitted by deposit. Discriminator 6f8d1a2da1236439.

makerpubkey

The maker account.

ownerpubkey

The maker’s wallet.

mintpubkey

The mint.

amountu64

Base units moved into the vault.

MakerRegistered

Emitted by register_maker. Discriminator 459f8967267812c4.

makerpubkey

The maker account.

ownerpubkey

The maker’s wallet.

quote_keypubkey

Its quote key.

QuoteKeyUpdated

Emitted by set_quote_key. Discriminator 6c8960b64487a938.

makerpubkey

The maker account.

ownerpubkey

The maker’s wallet.

quote_keypubkey

The new quote key.

activebool

Whether the maker is active.

Settled

Emitted by settle. Discriminator e8d228118e7c91ee.

quote_hash[u8; 32]

The SHA-256 of the quote message.

makerpubkey

The maker’s wallet.

takerpubkey

The taker’s wallet.

base_mintpubkey

The base mint.

quote_mintpubkey

The quote mint.

sideu8

0 when the taker bought the base token, 1 when it sold.

base_amountu64

Base units of the base mint that moved.

quote_amountu64

The quote amount before the fee.

feeu64

The fee paid, in base units of the quote mint.

Withdrawn

Emitted by withdraw. Discriminator 1459dfc6c27cdb0d.

makerpubkey

The maker account.

ownerpubkey

The maker’s wallet.

mintpubkey

The mint.

amountu64

Base 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.

CodeNameMessageRaised when
6000UnauthorizedThe signer does not own this operation.The signer is not the maker’s owner, the admin, or the upgrade authority the instruction needs.
6001InvalidConfigFee 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.
6002MintNotAllowedThe mint is not allowed.A mint is not in the allowed list.
6003MakerInactiveThe maker is inactive.The quote’s maker is inactive.
6004InvalidAmountAmounts must be greater than zero.An amount is zero.
6005InvalidSideSide must be zero or one.The side is neither 0 nor 1.
6006SameMintBase and quote mints must differ.The base and quote mints are the same.
6007QuoteExpiredThe quote has expired.The cluster time is past the quote’s expiry.
6008QuoteSignatureInvalidA 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.
6009QuoteAlreadyUsedThe quote has already settled.The quote has settled before.
6010MakerInventoryShortThe 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.
6011InvalidFeeAccountThe 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.
6012InvalidTokenAccountThe 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.
6013InvalidUsedQuoteThe quote receipt account is invalid.The used-quote account is not the address derived from this quote’s hash, or holds other data.
6014ArithmeticOverflowThe amount arithmetic overflowed.An amount would overflow 64 bits.

The quote message the program rebuilds is laid out in What a quote signs.