Skip to content
Fossa

Transactions and authority

Generated builders, account lifecycle, configuration, and errors.

Instruction builder

The router uses generated Anchor instruction data and account metas. args.rs defines inputs; contexts.rs defines account order, permissions, and constraints. Use those types to build instructions.

This helper constructs an instruction without signing or executing it. Remaining accounts, where required, follow the generated metas.

Build a deposit

The generated Deposit account group binds market, user, owner, source, vault authority, vault, mint, and token program. The owner signs the resulting transaction. amount_atoms uses the payment mint’s smallest units.

This function uses the helper above. Constructing it does not reserve funds or transfer tokens.

Market initialization and authority

initialize_market creates a market with the council signer and an initialized six-decimal payment mint. The fresh market account also signs. The council pays for creation. New list creation starts disabled.

configure_fees requires the council. It configures the bank and list-creation payment. Enabling creation requires a valid mint and token program supplied as two remaining accounts, plus a positive net price. Disabling creation requires no remaining accounts. This setting does not disable existing lists.

configure_dex binds the router to the supported DEX and its USDC configuration. Their council and payment mint must match. rotate_council requires signatures from both current and next council. It changes future router authorization and treasury routing. It does not rewrite existing bookings or rotate the DEX council automatically.

Council and router treasury describe one wallet’s authority and funds. bank receives model-token transfer taxes. DEX treasury is a separate role. Program upgrade authority is separate from these application accounts.

Close completed storage

close_booking accepts released (3), finalized (4), or available (5) bookings. Its recipient must equal the recorded rent payer. Available reusable storage additionally requires that recipient to sign. Reserved storage cannot close.

Closure returns the account’s lamports to that recipient. The user’s generation counter survives booking closure. Model books and user accounts have no close instruction in the current program.

Transaction costs and storage reuse

Reusable bookings avoid creating an account for each request. Settlement, release, or expiry makes their storage available again. Account funding remains tied to storage until an allowed closure returns it. Network transaction fees are spent separately.

Instructions execute in message order. Compatible actions can share a transaction, including booking initialization followed by reservation. Reusable claims remain top-level instructions. Packet size, account permissions, compute, and required signatures limit batching.

If an instruction fails, transaction state changes roll back. Network fees can still apply. A signature identifies signed bytes; it does not prove execution. An uncertain result requires reconciliation before treating an action as failed. Re-signing with another blockhash creates another transaction.

Errors

The program declares named RouterError variants. Anchor and token programs can also return errors before or during a handler.

ErrorMeaning
ArithmeticOverflow, underflow, or invalid exact accounting.
InvalidAccountWrong account identity, ownership, or relationship.
InvalidArgumentInput or remaining-account shape fails validation.
UnauthorizedRequired authority or booking binding fails.
SlippageA bounded operation exceeds its limit.
UnavailableNo eligible offer, full storage, or disabled list creation.
InvalidStateWrong lifecycle, generation, or deadline.
LimitExceededUsage, payment, or redemption bounds fail.

Interpret errors against the invoked instruction and its account constraints.