Error Codes
Each program has its own #[error_code] enum starting at Anchor offset 6000. Enum type names in the IDL are AlphaFundError (Keystone Alpha), BasisFundError (Keystone Neutral), DefenseFundError (Keystone Defense), and CoreError (Keystone Core). Funds use FundPaused, FundAccountMismatch, InvalidFundParams, InsufficientFundBalance, and related names (replacing older Fund* spellings). Regenerate the IDL after pulling these changes; numeric codes stay the same only if variant order is unchanged.
Keystone Alpha
6000
OraclePriceUnavailable
Oracle price unavailable
6001
OraclePriceStale
Price feed older than 5 minutes
6002
OraclePriceUnreliable
Confidence interval too wide
6003
RebalanceTooSoon
Cooldown not elapsed
6004
NoRebalanceNeeded
Current ratio within band
6005
InsufficientFundBalance
Not enough USDC for withdrawal
6006
Unauthorized
Not the fund authority
6007
MathOverflow
Arithmetic overflow
6008
InvalidFundParams
Invalid configuration
6009
InsufficientShares
Not enough shares to burn
6010
InvalidShareCalculation
Divide by zero in share math
6011
TokenMintMismatch
Wrong token mint
6012
InvalidOracleAccount
Wrong oracle account
6013
FundAccountMismatch
Token account mismatch
6014
FundPaused
Fund is paused
6015
DepositCapExceeded
Would exceed TVL cap
6016
InvalidDepositCap
Cap must be > 0
6017
ManagementFeeTooHigh
Exceeds 5% max
6018
RebalanceStepTooLarge
Exceeds 10% max
6019
OracleFeedIdMismatch
Feed ID doesn't match
6020
InvalidRatioParams
high must be > low
6021
InvalidAllocationBounds
max must be > min
6022
InsufficientFunds
Not enough for swap
6023
SlippageExceeded
Swap worse than limit
6024
SwapFailed
Swap execution failed
6025
InvalidSwapPrice
Bad price for swap calc
6026
LendingOperationFailed
Marginfi CPI failed
6027
InvalidLendingAmount
Bad lending amount
6028
LendingNotEnabled
Lending not enabled
6029
InsufficientLendingBalance
Not enough in lending
6030
MarginfiAccountNotInitialized
Marginfi not set up
6031
InvalidFundAccount
Wrong fund token account
6032
PerformanceFeeTooHigh
Exceeds 30% max
6033
RebalancingFeeTooHigh
Exceeds 1% max
6034
CircuitBreakerSkipped
CB triggered, rebalance skipped
6035
InvalidVolConfig
Bad volatility config
6036
FundUpgradeRequired
Fund needs upgrade for vol features
Keystone Core
6000
PortfolioPaused
Portfolio is paused
6001
InvalidParams
Invalid portfolio configuration
6002
Unauthorized
Admin signature required
6003
MathOverflow
Arithmetic overflow
6004
InvalidShareCalculation
Divide by zero in share math
6005
InvalidAllocation
Allocation bps must sum to 10000
6006
AllocationOutOfBounds
Allocation exceeds profile bounds
6007
RebalanceNotDue
Interval not elapsed and no drift
6008
InsufficientLiquidity
Insufficient fund liquidity for withdrawal
6009
InsufficientShares
Not enough ksCORE to burn
6010
TokenMintMismatch
Wrong token mint
6011
AccountMismatch
Account doesn't match portfolio state
6012
FundCpiFailed
CPI into a sub-fund failed
6013
InvalidRiskProfile
risk_profile must be 0, 1, or 2
6014
ZeroAmount
Deposit amount must be > 0
6015
SwapFailed
Swap execution failed
6016
SlippageExceeded
Swap output below minimum
6017
PortfolioMismatch
User already has an active position in a different portfolio
6018
NeutralPositionDeployed
Neutral has capital deployed — Core withdraw reverts atomically rather than stranding the user's Neutral portion in a PendingWithdrawal they cannot claim
Keystone Neutral
6000
PositionAlreadyOpen
Position already exists
6001
PositionNotOpen
No position to operate on
6002
HealthFactorTooLow
Below minimum threshold
6003
HealthFactorAboveThreshold
No adjustment needed
6004
NegativeFundingDetected
Negative funding — reduce position
6005
InsufficientCollateral
Not enough collateral
6006
InsufficientUsdcBalance
Not enough USDC
6007
PositionSizeExceedsLimit
Exceeds max position
6008
SettlementTooSoon
Settle interval not elapsed
6009
JupiterPerpOperationFailed
Jupiter Perps CPI failed
6010
InvalidJupiterPerpAccount
Wrong Jupiter Perps account
6011
MathOverflow
Arithmetic overflow
6012
InvalidFundParams
Invalid configuration
6013
FundPaused
Fund is paused
6014
DepositCapExceeded
Would exceed TVL cap
6015
Unauthorized
Not the fund authority
6016
InvalidShareCalculation
Divide by zero in share math
6017
InsufficientShares
Not enough shares
6018
TokenMintMismatch
Wrong token mint
6019
FundAccountMismatch
Token account mismatch
6020
OraclePriceUnavailable
Oracle unavailable
6021
OraclePriceStale
Price older than 5 minutes
6022
OraclePriceUnreliable
Confidence too wide
6023
SlippageExceeded
Swap worse than limit
6024
SwapFailed
Swap execution failed
6025
InsufficientFundBalance
Not enough for withdrawal
6026
ManagementFeeTooHigh
Exceeds 5% max
6027
PerformanceFeeTooHigh
Exceeds 30% max
6028
OracleFeedIdMismatch
Feed ID doesn't match
6029
AutoDeployDisabled
auto_deploy_enabled is false
6030
InsufficientUsdcForDeployment
Below min_deploy_amount
6031
InsufficientJitosolBalance
No jitoSOL after swap
6032
NegativeFundingNotDetected
Conditions not met for emergency close
6033
NoPendingWithdrawals
Unwind requires pending withdrawals or admin; also thrown by deploy_capital / park_capital when total_pending_withdrawals > 0
6034
NoPendingWithdrawalFound
No pending withdrawal for this user
6035
FundingRateTooLow
Funding below min_funding_rate_to_deploy
6036
NavDrawdownExceeded
Reserved — NAV drawdown guard uses event-based alerting (NegativeFundingAlert); this error is not thrown directly
6037
LendingNotEnabled
Marginfi lending not enabled — call enable_basis_lending first
6038
LendingAlreadyEnabled
Marginfi lending already enabled for this fund
6039
LendingOperationFailed
Marginfi CPI failed
6040
InvalidLendingAmount
Lending amount must be > 0
6041
CapitalParkedInLending
USDC already in Marginfi — deploy_capital will auto-withdraw when Marginfi accounts are supplied
6042
FundingRateStillTooLow
Funding still too low after staleness bypass
6043
KaminoBorrowFailed
Kamino CPI failed during deploy_reverse
6044
KaminoRepayFailed
Kamino CPI failed during close_reverse
6045
ReversePositionAlreadyOpen
deploy_reverse called when reverse basis is already open
6046
ReversePositionNotOpen
close_reverse called with no reverse basis position
6047
NegativeFundingNotMet
Conditions for reverse basis not met
6048
KaminoNotConfigured
Call enable_reverse_basis before deploy_reverse
6049
JitoSolParkingNotEnabled
Set swap_to_jitosol_when_parking via update_fund_params first
6050
JitoSolAlreadyParked
Call deploy_capital (jupiter_account_count=0) to redeploy
6051
DirectDepositsDisabled
CoreGate is active — deposit via Keystone Core only
Handling
Last updated