Optimus Protocol Error Handling
Error Categories
Authorization Errors
Unauthorized: Thrown when an unauthorized account attempts a privileged operationInvalidGlobal: Thrown when the global account is invalid or not initializedInvalidBondingCurve: Thrown when the bonding curve account is invalidInvalidReferral: Thrown when the referral account is invalid
State Errors
AlphaVaultClosed: Thrown when attempting to deposit to a closed alpha vaultInvalidVaultAccount: Thrown when the vault account is invalidInvalidTreasury: Thrown when the treasury account is invalidVaultHasAlreadyGraduated: Thrown when attempting to graduate an already graduated vault
Trading Errors
BuyNotReady: Thrown when attempting to buy before alpha phase completionOverSlippage: Thrown when transaction would exceed allowed slippagePriceMustNotBeZero: Thrown when price calculation results in zeroInvalidWsolAmountInput: Thrown when wSOL amount doesn't match ATA balance
Balance Errors
InsufficientLamport: Thrown when insufficient lamports for rentTokenAmountMustNotBeZero: Thrown when token account has zero balanceAmountMustNotBeZero: Thrown when account has zero balanceFailSumMatch: Thrown when lamport sums don't match expected values
Protocol State Errors
ProtocolHalted: Thrown when protocol is in halted stateLamportTransferRequiredForSync: Thrown when sync attempted without transferInstructionAlreadyCalled: Thrown when instruction has already been called
Error Handling Flow
Pre-execution Validation
-
Account validation
- Check account existence
- Verify account ownership
- Validate account data
-
State validation
- Check protocol state
- Verify trading conditions
- Validate vault status
-
Balance validation
- Check sufficient funds
- Verify token balances
- Validate reserve requirements
Error Recovery
Automatic Recovery
- Transaction rollback
- State consistency checks
- Balance verification
Manual Recovery
- Emergency protocol halt
- Admin intervention
- State recovery procedures
Error Prevention
Input Validation
- Parameter bounds checking
- Account validation
- State transition validation
State Protection
- Atomic transactions
- State consistency checks
- Balance verification
Emergency Controls
- Protocol halt mechanism
- Emergency withdrawals
- State recovery procedures