Skip to main content

Settlement State Machine

The Launchpad program enforces a strict state machine for every token launch. Each launch progresses through a series of states, with specific instructions triggering each transition.

States

State Definitions

StateEnum ValueDescription
Created0LaunchConfig and Token-2022 mint created. Escrows not yet initialized.
EscrowsInitialized1All 5 escrow accounts created and tokens minted to escrows.
AuctionReady2CCA V2 auction initialized via CPI. Waiting for auction start slot.
AuctionActive3Implied state (not set by any instruction). Auction is live after start_slot.
Finalized4Auction ended and graduated. Final clearing price recorded.
ProceedsSwept5Quote tokens swept from CCA vault to proceeds escrow.
PoolCreated6Raydium CPMM pool created and LP tokens burned.
Settled7Team tokens distributed, claims enabled, mint authority renounced. Terminal state.
Cancelled8Launch cancelled before auction started. All tokens returned to creator. Terminal state.
EmergencyWithdrawn9Emergency recovery after settlement timeout. All remaining assets returned to creator. Terminal state.
FailedRecovery10Recovery from a non-graduated auction. All tokens returned to creator. Terminal state.

Transition Table

From StateTo StateInstructionConditions
(none)Createdcreate_launch_step_1Protocol not paused, valid params
CreatedEscrowsInitializedcreate_launch_step_2Creator only
EscrowsInitializedAuctionReadyinitialize_cca_auctionCreator only, supply steps hash matches, duration matches
AuctionReady / AuctionActiveFinalizedfinalize_auctionslot >= end_slot, graduated
AuctionReady / AuctionActiveFailedRecoveryrecover_failed_auctionslot >= end_slot, NOT graduated
Created / EscrowsInitializedCancelledcancel_launchCreator only, auction not started
AuctionReadyCancelledcancel_launchCreator only, current_slot < start_slot
FinalizedProceedsSweptsweep_to_escrowSettlement not paused
ProceedsSweptPoolCreatedcreate_raydium_poolSettlement not paused, min LP proceeds met
PoolCreatedSettledenable_claimsSettlement not paused
Finalized / ProceedsSwept / PoolCreatedEmergencyWithdrawnemergency_withdrawslot > finalized_slot + emergency_timeout_slots

Happy Path

The typical successful launch follows this flow:

  1. Creator calls create_launch_step_1 -- creates token and launch config
  2. Creator calls create_launch_step_2 -- sets up escrows, mints tokens
  3. Creator calls initialize_cca_auction -- creates CCA auction via CPI
  4. Auction runs -- bidders place bids, keepers create checkpoints
  5. Anyone calls finalize_auction -- records final clearing price
  6. Anyone calls sweep_to_escrow -- sweeps proceeds via CCA CPI
  7. Anyone calls create_raydium_pool -- creates liquidity, burns LP tokens
  8. Anyone calls enable_claims -- distributes team tokens, enables claims, renounces mint

Steps 5-8 are permissionless (keeper pattern). Any wallet can submit these transactions.

Failure Paths

Non-Graduated Auction

If the auction ends without raising enough currency to meet the required_currency_raised threshold:

  1. Auction reaches end_slot without graduating
  2. Anyone calls recover_failed_auction
  3. All tokens (auction, LP, team) are returned to the creator
  4. Bidders recover their quote currency via CCA V2's exit_bid (non-graduated auctions give full refunds)

Cancelled Launch

If the creator decides to cancel before the auction starts:

  1. Creator calls cancel_launch
  2. All escrowed tokens are returned to the creator
  3. Fee escrow SOL is returned to the creator
  4. State becomes Cancelled (terminal)

Settlement Stall (Emergency)

If settlement stalls after finalization (e.g., Raydium pool creation fails):

  1. Wait for emergency_timeout_slots after finalized_slot
  2. Anyone calls emergency_withdraw
  3. All remaining LP tokens, team tokens, proceeds, and fee SOL are sent to the creator
  4. Mint authority is renounced (no more minting possible)

Idempotency

Settlement instructions (finalize_auction, sweep_to_escrow, create_raydium_pool, enable_claims) are idempotent. If the state is already at or past the target state, they return Ok(()) without error. This means keepers can safely retry without worrying about transaction failures from duplicate calls.

Access Control Summary

InstructionWho Can CallNotes
create_launch_step_1Any signerFirst caller becomes creator
create_launch_step_2Creator only
initialize_cca_auctionCreator only
finalize_auctionAnyonePermissionless (keeper)
sweep_to_escrowAnyonePermissionless (keeper)
create_raydium_poolAnyonePermissionless (keeper)
enable_claimsAnyonePermissionless (keeper)
cancel_launchCreator onlyBefore auction starts
emergency_withdrawAnyoneAfter timeout; funds go to validated creator
recover_failed_auctionAnyoneAfter auction ends; funds go to validated creator