Optimus Protocol Error Handling

Error Categories

Authorization Errors

  • Unauthorized: Thrown when an unauthorized account attempts a privileged operation
  • InvalidGlobal: Thrown when the global account is invalid or not initialized
  • InvalidBondingCurve: Thrown when the bonding curve account is invalid
  • InvalidReferral: Thrown when the referral account is invalid

State Errors

  • AlphaVaultClosed: Thrown when attempting to deposit to a closed alpha vault
  • InvalidVaultAccount: Thrown when the vault account is invalid
  • InvalidTreasury: Thrown when the treasury account is invalid
  • VaultHasAlreadyGraduated: Thrown when attempting to graduate an already graduated vault

Trading Errors

  • BuyNotReady: Thrown when attempting to buy before alpha phase completion
  • OverSlippage: Thrown when transaction would exceed allowed slippage
  • PriceMustNotBeZero: Thrown when price calculation results in zero
  • InvalidWsolAmountInput: Thrown when wSOL amount doesn't match ATA balance

Balance Errors

  • InsufficientLamport: Thrown when insufficient lamports for rent
  • TokenAmountMustNotBeZero: Thrown when token account has zero balance
  • AmountMustNotBeZero: Thrown when account has zero balance
  • FailSumMatch: Thrown when lamport sums don't match expected values

Protocol State Errors

  • ProtocolHalted: Thrown when protocol is in halted state
  • LamportTransferRequiredForSync: Thrown when sync attempted without transfer
  • InstructionAlreadyCalled: Thrown when instruction has already been called

Error Handling Flow

Pre-execution Validation

  1. Account validation

    • Check account existence
    • Verify account ownership
    • Validate account data
  2. State validation

    • Check protocol state
    • Verify trading conditions
    • Validate vault status
  3. 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

© 2025 PRIM3.AI. All rights reserved.