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
| State | Enum Value | Description |
|---|---|---|
Created | 0 | LaunchConfig and Token-2022 mint created. Escrows not yet initialized. |
EscrowsInitialized | 1 | All 5 escrow accounts created and tokens minted to escrows. |
AuctionReady | 2 | CCA V2 auction initialized via CPI. Waiting for auction start slot. |
AuctionActive | 3 | Implied state (not set by any instruction). Auction is live after start_slot. |
Finalized | 4 | Auction ended and graduated. Final clearing price recorded. |
ProceedsSwept | 5 | Quote tokens swept from CCA vault to proceeds escrow. |
PoolCreated | 6 | Raydium CPMM pool created and LP tokens burned. |
Settled | 7 | Team tokens distributed, claims enabled, mint authority renounced. Terminal state. |
Cancelled | 8 | Launch cancelled before auction started. All tokens returned to creator. Terminal state. |
EmergencyWithdrawn | 9 | Emergency recovery after settlement timeout. All remaining assets returned to creator. Terminal state. |
FailedRecovery | 10 | Recovery from a non-graduated auction. All tokens returned to creator. Terminal state. |
Transition Table
| From State | To State | Instruction | Conditions |
|---|---|---|---|
| (none) | Created | create_launch_step_1 | Protocol not paused, valid params |
Created | EscrowsInitialized | create_launch_step_2 | Creator only |
EscrowsInitialized | AuctionReady | initialize_cca_auction | Creator only, supply steps hash matches, duration matches |
AuctionReady / AuctionActive | Finalized | finalize_auction | slot >= end_slot, graduated |
AuctionReady / AuctionActive | FailedRecovery | recover_failed_auction | slot >= end_slot, NOT graduated |
Created / EscrowsInitialized | Cancelled | cancel_launch | Creator only, auction not started |
AuctionReady | Cancelled | cancel_launch | Creator only, current_slot < start_slot |
Finalized | ProceedsSwept | sweep_to_escrow | Settlement not paused |
ProceedsSwept | PoolCreated | create_raydium_pool | Settlement not paused, min LP proceeds met |
PoolCreated | Settled | enable_claims | Settlement not paused |
Finalized / ProceedsSwept / PoolCreated | EmergencyWithdrawn | emergency_withdraw | slot > finalized_slot + emergency_timeout_slots |
Happy Path
The typical successful launch follows this flow:
- Creator calls
create_launch_step_1-- creates token and launch config - Creator calls
create_launch_step_2-- sets up escrows, mints tokens - Creator calls
initialize_cca_auction-- creates CCA auction via CPI - Auction runs -- bidders place bids, keepers create checkpoints
- Anyone calls
finalize_auction-- records final clearing price - Anyone calls
sweep_to_escrow-- sweeps proceeds via CCA CPI - Anyone calls
create_raydium_pool-- creates liquidity, burns LP tokens - 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:
- Auction reaches
end_slotwithout graduating - Anyone calls
recover_failed_auction - All tokens (auction, LP, team) are returned to the creator
- 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:
- Creator calls
cancel_launch - All escrowed tokens are returned to the creator
- Fee escrow SOL is returned to the creator
- State becomes
Cancelled(terminal)
Settlement Stall (Emergency)
If settlement stalls after finalization (e.g., Raydium pool creation fails):
- Wait for
emergency_timeout_slotsafterfinalized_slot - Anyone calls
emergency_withdraw - All remaining LP tokens, team tokens, proceeds, and fee SOL are sent to the creator
- 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
| Instruction | Who Can Call | Notes |
|---|---|---|
create_launch_step_1 | Any signer | First caller becomes creator |
create_launch_step_2 | Creator only | |
initialize_cca_auction | Creator only | |
finalize_auction | Anyone | Permissionless (keeper) |
sweep_to_escrow | Anyone | Permissionless (keeper) |
create_raydium_pool | Anyone | Permissionless (keeper) |
enable_claims | Anyone | Permissionless (keeper) |
cancel_launch | Creator only | Before auction starts |
emergency_withdraw | Anyone | After timeout; funds go to validated creator |
recover_failed_auction | Anyone | After auction ends; funds go to validated creator |