Developers
Program
Instructions, accounts, statuses and errors of the Tack Solana program.
Tack is an Anchor program on Solana. Its address on the cluster you are using is in GET /status and in the app's network panel; GET /contract returns the IDL the service was built against, with its SHA-256.
Instructions
| Instruction | Who signs | What it does |
|---|---|---|
initialize_market | anyone, who pays rent | Validates the configuration, reads Phoenix once, and creates the market, its vault and its creator's venue if needed. The signer is the market's admin. |
create_listing(market_index, authority, config) | the creator, who pays rent | Creates a listing: a schedule of maturities, the terms they open with and the authority that may change them. |
configure_listing(config) | the listing's authority | Replaces the schedule and terms. Markets already open keep their terms. |
propose_listing_authority(authority) | the listing's authority | Names a successor. Nothing changes hands until the successor accepts; a new proposal replaces the last. |
accept_listing_authority | the proposed successor | Takes the listing over. |
list_market(maturity) | anyone, who pays rent | Opens a maturity the listing's schedule calls for now, on the listing's terms, with the listing as the market's admin. |
checkpoint(sequence) | anyone, who pays rent | Publishes Phoenix's next funding record as checkpoint sequence. Finalizes the market at the record that starts at maturity. |
create_order(id, notional, fixed_rate, maker_long, collateral) | the maker | Posts a whole-lot quote and moves its collateral to the vault. |
cancel_order | the maker | Returns an open quote's collateral and marks it cancelled. |
take_order(collateral) | the taker | Fills a quote whole and opens a position with both sides' collateral; both legs start at the next funding record. |
settle | anyone | Applies up to eight checkpoints to a position, in order, with maintenance checks. |
liquidate | anyone | Settles to the latest checkpoint, then closes the position if a side is below maintenance. |
top_up(amount) | either side | Settles, then adds collateral to the signer's side. |
withdraw | either side | Pays the signer's balance from a closed position, once. |
finalize_frozen | anyone | Closes a market at its last verified checkpoint when its source has failed past the freeze grace. |
settle, liquidate and top_up take the checkpoints they apply as remaining accounts. Every instruction that touches a position also takes the market's venue account.
Accounts
| Account | Address | Holds |
|---|---|---|
| Market | PDA("market", index u16, maturity i64, admin) | Configuration, reference price, latest source reading, sequence, open interest, liabilities. |
| Vault | PDA("vault", market) | The market's USDC, an SPL Token account with the market as authority. |
| Venue | PDA("venue", index u16, admin) | SOL exposure of every open position across the maturities one creator opens; a listing's markets share the listing's venue. |
| Order | PDA("order", market, maker, id u64) | A quote: maker, side, notional, fixed rate, collateral, status. |
| Swap | PDA("swap", order) | A position: both sides and balances, notional, rate, start time and total, last settled checkpoint and result, status. |
| FundingCheckpoint | PDA("checkpoint", market, sequence u64) | One Phoenix funding record: cumulative funding and the start of its interval. |
| Listing | PDA("listing", index u16, creator) | A schedule (anchor, interval, lead, count), the terms its markets open with, its authority and any proposed successor. |
Integers in seeds are little-endian. Quote and position accounts are never closed: they stay as the record of what happened.
A market's admin is its creator: the signer of initialize_market, or the listing for a market opened with list_market. The address includes it, so a market someone else opens at the same maturity never takes the address of the one Tack lists. Tack's listing is governed by TACK holders; see TACK token.
Errors
| Error | Meaning |
|---|---|
Arithmetic | Checked arithmetic overflowed, or a time or price was invalid. |
InvalidConfig | The market or listing configuration is outside the program's bounds. |
InvalidSource | The account is not Phoenix's PerpAssetMap, or its SOL slot's layout, units, funding interval, period or clamp changed. |
SourceStale | Phoenix's accumulator or index price is older than maxAge, or dated in the future. |
SourceTime | Phoenix's interval or total is inconsistent with what the market saw. |
MarketFrozen | The market is frozen. |
SourceNotFrozen | The source is healthy or the freeze grace has not passed. |
InvalidMint | The mint is not canonical six-decimal USDC. |
MarketClosed | The maturity has passed, or its last funding interval has begun so a fill would start at maturity. |
InvalidOrder | The notional is under 1 USDC, or the rate is over the cap or off the tick. |
Margin | Collateral is under the initial margin. |
OrderClosed | The quote is filled or cancelled. |
SelfTrade | The taker is the maker. |
OpenInterestCap | The fill would pass the open-interest cap. |
Unauthorized | The signer is not the quote's maker, a side of the position, the listing's authority, or its proposed successor. |
SwapClosed | The position has already closed. |
Healthy | The position is above maintenance; nothing to liquidate. |
SwapOpen | Collateral stays locked while the position is open. |
NothingToWithdraw | The signer's balance is already withdrawn. |
VaultInvariant | The vault holds less than the market owes; no USDC leaves. |
CheckpointRequired | Phoenix has a record the market has not published, or the position is not caught up. |
CheckpointSequence | A checkpoint is missing, out of order, or from another market. |
MissedFundingInterval | Phoenix moved more than one interval past the market; close it as frozen after the grace. |
NotScheduled | The listing's schedule does not open this maturity now. |
SourceRollover | Phoenix has not started the current funding interval yet; a market opens once it has, seconds after the hour. |
Addresses
| Address | |
|---|---|
| USDC mint | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |
| SPL Token program | TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA |
| Associated Token program | ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL |
| Phoenix program | EtrnLzgbS7nMMy5fbD42kXiUzGg8XQzJ972Xtk1cjWih |
| Phoenix PerpAssetMap | 2nHGAaEw3D5dd4hVueaUNoygkQFmoeKqRQWnSPqSMFUC |
| Phoenix SOL market | 71Si24E4uc3oCaPbPZTozC1ptSNNqygjjebxSmErSsC2 |
| SPL Governance program | GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw |