Midway

Reference

Programs and accounts

The two Solana programs behind Midway and the accounts they derive, for integrators and explorers.

Programs#

ProgramAddressDoes
SettlementA2gVbydTCBPuK1uPWm8UBAsoyC8EU753sMGaGbaCFTe6Vaults, deposits and withdrawals, reservations, Pyth snapshots, fill settlement, fees
Matching (Arcium MXE)7WR2gjtu1S6rxYEF3fEExipKaMffCCdeRhV973ffigoZThe encrypted book, admissions, matching rounds, remaining-size reads, cancellation, the session calendar

The matching program queues computations on Arcium and accepts their results only with the cluster's verified signature.

Accounts#

Every account is derived from fixed seeds, so anyone can find a market's accounts from its stock mint and administrator.

AccountProgramSeeds
MarketSettlement"market", stock mint, administrator
Your vaultSettlement"trader", market, your wallet
USDC vaultSettlement"quote-vault", market
Stock vaultSettlement"stock-vault", market
Encrypted bookMatching"book", market
Settlement authorityMatching"settlement-authority", market

Because the market's address includes its administrator, nobody else can create the market an administrator intends to open.

Events#

EventProgramPublished when
BalanceChangedSettlementa deposit or withdrawal moves a vault balance
OrderLocked, OrderReleasedSettlementa vault is reserved for an order, and released
RoundStarted, RoundFinishedSettlementa matching round takes its oracle snapshot, and closes
FillSettledSettlementa fill settles: buyer, seller, quantity, price, notional, fee, slot
FeesWithdrawnSettlementthe administrator withdraws accrued fees
BookInitializedMatchingthe book's sixteen sealed positions are ready
OrderQueuedMatchingan encrypted order is queued for admission
OrderAdmissionMatchingthe book admits an order, or does not
OrderRemovedMatchingan order is cancelled or expires
RemainingEncryptedMatchinga remaining-size read returns its encrypted answer
RoundDiscardedMatchinga round's result is dropped because its oracle snapshot changed or aged
ComputationRecoveredMatchinga computation pending for ten minutes is fenced
CalendarUpdatedMatchingthe administrator publishes sessions