跳轉到主要內容

Documentation Index

Fetch the complete documentation index at: https://docs.raydium.io/llms.txt

Use this file to discover all available pages before exploring further.

本頁內容由 AI 自動翻譯,所有內容以英文版本為準。查看英文版 →
資料來源。 下方表格是從各程式公開 Raydium 儲存庫中的 error.rs 自動產生。當程式升級並新增變體時,請重新執行擷取腳本(每個表格底部附有連結),並將新列附加到表格末尾,而非重新排列——Anchor 錯誤代碼是依原始碼順序指派,而非依名稱,重新排列會破壞整合者的錯誤處理邏輯。

Anchor 錯誤代碼的運作方式

Anchor 會為程式的 ErrorCode 列舉中每個變體指派從 6000 開始的數字代碼。交易失敗時,會顯示以下資訊:
  • 數字錯誤代碼(例如 0x1771 = 6001)出現在交易日誌中。
  • 錯誤名稱(例如 InvalidOwner)來自 IDL。
  • #[msg(...)] 字串由 Anchor 輸出至 log_messages
整合者應以數字代碼進行匹配,而非訊息字串(訊息字串可能在不升級版本的情況下被改寫)。
// Example: detect the CPMM slippage error and surface a clean UX message.
const CPMM_EXCEEDED_SLIPPAGE = 6005;

try {
  await sdk.cpmm.swap({ ... });
} catch (err: any) {
  const code = err?.error?.errorCode?.number ?? err?.code;
  if (code === CPMM_EXCEEDED_SLIPPAGE) {
    showToast("Price moved past your slippage tolerance. Increase slippage or retry.");
    return;
  }
  throw err;
}

CPMM(標準 AMM)錯誤

程式 ID:請參閱 reference/program-addresses。來源:raydium-cp-swap/programs/cp-swap/src/error.rs
代碼變體#[msg] 字串典型原因建議的使用者介面訊息
6000NotApprovedNot approved呼叫者不是管理員指令所設定的授權身分。「只有資金池管理員才能執行此操作。」
6001InvalidOwnerInput account owner is not the program address傳入的帳戶由錯誤的程式所擁有(通常是錯誤的 token 程式或錯誤程式的 PDA)。「內部錯誤:帳戶擁有者不符——請重新整理後再試。」
6002EmptySupplyInput token account emptyLP 或 token 帳戶餘額為零,但當前步驟需要正數金額。「沒有可提領的金額。」
6003InvalidInputInvalidInput通用的錯誤參數(金額超出範圍、錯誤旗標)。「輸入無效——請檢查金額後再試。」
6004IncorrectLpMintAddress of the provided lp token mint is incorrect傳入的 LP mint 帳戶與 pool_state.lp_mint 不符。「內部錯誤:LP mint 錯誤——請重新整理資金池資料。」
6005ExceededSlippageExceeds desired slippage limit執行價格比使用者設定的 minAmountOut / maxAmountIn 更差。「價格超出你的滑點容忍範圍,請提高滑點設定或重試。」
6006ZeroTradingTokensGiven pool token amount results in zero trading tokens存款/提款計算將其中一側四捨五入為零(倉位過小)。「金額低於此資金池的最小限制。」
6007NotSupportMintNot support token_2022 mint extension (原始碼語法有誤)資金池遇到無法安全處理的 Token-2022 擴充功能(例如 TransferHookDefaultAccountState=Frozen)。「此 token 包含 Raydium CPMM 不支援的擴充功能。」
6008InvalidVaultinvaild vault (原始碼有拼字錯誤)傳入的 vault 帳戶與 pool_state 中記錄的不符。「內部錯誤:vault 錯誤——請重新整理後再試。」
6009InitLpAmountTooLessInit lp amount is too less(Because 100 amount lp will be locked) (原始碼語法有誤)初始化資金池時,計算出的 LP 供應量低於永久鎖倉金額。「初始流動性不足,請增加存款金額。」
6010TransferFeeCalculateNotMatchTransferFee calculate not matchToken-2022 收費 mint 的轉帳後實際金額與預先計算的預期不符。「Token 轉帳費用在交易過程中發生變動,請重試。」
6011MathOverflowMath overflowswap/存款/手續費的中間計算發生溢位。「金額對此資金池而言過大。」
6012InsufficientVaultInsufficient vault資金池 vault 餘額不足以支付請求的輸出金額。「此資金池的流動性不足以完成此筆交易。」
6013InvalidFeeModelInvalid fee model管理員設定了被鏈上拒絕的 AmmConfig 參數組合。不適用——僅限管理員路徑。
6014NoFeeCollectFee is zero呼叫 collect_protocol_fee / collect_fund_fee 時可收集的手續費為零。不適用——管理員路徑;工具應忽略此錯誤。
產生來源:github.com/raydium-io/raydium-cp-swap — error.rs

CLMM 錯誤

程式 ID:請參閱 reference/program-addresses。來源:raydium-clmm/programs/amm/src/error.rs
代碼變體#[msg] 字串典型原因建議的使用者介面訊息
6000NotApprovedNot approved呼叫者不是此指令所設定的管理員。「只有資金池管理員才能執行此操作。」
6001InvalidUpdateConfigFlaginvalid update amm config flag管理員傳入了無法識別的 param 值給 update_amm_config不適用——僅限管理員路徑。
6002AccountLackAccount lack交易中缺少必要的剩餘帳戶(通常是 tick-array 或 oracle 擴充)。「內部錯誤:帳戶缺失——請重新整理資金池資料。」
6003ClosePositionErrRemove liquidity, collect fees owed and reward then you can close position account試圖關閉一個仍有流動性、未收取手續費或未領取獎勵的倉位。「請先提取所有流動性並領取手續費/獎勵,再關閉倉位。」
6004InvalidTickIndexTick out of rangetick_lowertick_upper 超出 [-443636, 443636] 範圍。「此資金池的價格範圍超出界限。」
6005TickInvalidOrderThe lower tick must be below the upper ticktick_lower >= tick_upper「下限價格必須低於上限價格。」
6006TickLowerOverflowThe tick must be greater, or equal to the minimum tick(-443636)下限 tick 下溢。「下限價格過低。」
6007TickUpperOverflowThe tick must be lesser than, or equal to the maximum tick(443636)上限 tick 上溢。「上限價格過高。」
6008TickAndSpacingNotMatchtick % tick_spacing must be zero提交的 tick 不是資金池 tick_spacing 的整數倍。「請將價格對齊至最近的有效刻度。」
6009InvalidTickArrayInvalid tick array account傳入的 tick-array 槽位 PDA 錯誤。「內部錯誤:tick array 錯誤——請重新整理資金池資料。」
6010InvalidTickArrayBoundaryInvalid tick array boundarytick-array 索引發生差一錯誤。「內部錯誤:tick-array 邊界錯誤。」
6011SqrtPriceLimitOverflowSquare root price limit overflow呼叫者提供的 sqrt_price_limit 超出有效範圍。「價格限制超出範圍。」
6012SqrtPriceX64sqrt_price_x64 out of range資金池的當前 sqrt 價格在 swap 過程中偏移超出範圍。「請重試 swap。」
6013LiquiditySubValueErrLiquidity sub delta L must be smaller than before減少流動性時發生內部不變量違規。「內部錯誤:流動性計算異常。」
6014LiquidityAddValueErrLiquidity add delta L must be greater, or equal to before增加流動性時發生內部不變量違規。「內部錯誤:流動性計算異常。」
6015ForbidBothZeroForSupplyLiquidityBoth token amount must not be zero while supply liquidity增加流動性時 amount_0_maxamount_1_max 均為零。「請至少提供一種 token 的金額。」
6016LiquidityInsufficientLiquidity insufficient倉位的流動性不足以滿足提款需求。「提款金額超過倉位的流動性。」
6017PriceSlippageCheckPrice slippage check執行價格未通過呼叫者的滑點保護檢查。「價格超出你的滑點容忍範圍,請提高滑點設定或重試。」
6018TooLittleOutputReceivedToo little output receivedSwapBaseInput:輸出金額低於 other_amount_threshold「滑點超限——未達到最小輸出金額。」
6019TooMuchInputPaidToo much input paidSwapBaseOutput:輸入金額超過 other_amount_threshold「滑點超限——超過最大輸入金額。」
6020ZeroAmountSpecifiedSwap special amount can not be zeroswap 指令的 amount 為零。「請輸入大於零的金額。」
6021InvalidInputPoolVaultInput pool vault is invalidswap 的輸入 vault 帳戶與資金池記錄的 vault 不符。「內部錯誤:輸入 vault 錯誤——請重新整理資金池資料。」
6022TooSmallInputOrOutputAmountSwap input or output amount is too smallswap 計算結果四捨五入為零,通常是極小的零碎金額。「金額過小,無法在此資金池進行 swap。」
6023NotEnoughTickArrayAccountNot enough tick array accountswap 範圍所需的 tick-array 剩餘帳戶數量不足。「內部錯誤:tick-array 不足——請重新整理資金池資料。」
6024InvalidFirstTickArrayAccountInvalid first tick array account傳入的第一個 tick-array 帳戶未涵蓋當前 tick。「內部錯誤:第一個 tick array 錯誤——請重新整理資金池資料。」
6025InvalidRewardIndexInvalid reward indexreward_index 超出 [0, 2] 範圍。不適用——管理員路徑。
6026FullRewardInfoThe init reward token reach to the max資金池已設定了最多(3 個)獎勵 mint。不適用——管理員路徑。
6027RewardTokenAlreadyInUseThe init reward token already in use獎勵 mint 與現有的重複。不適用——管理員路徑。
6028ExceptRewardMintThe reward tokens must contain one of pool vault mint except the last reward在第 2 個槽位之前,獎勵 mint 必須等於資金池其中一個 vault mint。不適用——管理員路徑。
6029InvalidRewardInitParamInvalid reward init param獎勵排放的開始/結束時間或每秒速率設定有誤。不適用——管理員路徑。
6030InvalidRewardInputAccountNumberInvalid collect reward input account number傳入 CollectReward 的剩餘帳戶數量有誤。「內部錯誤:帳戶數量錯誤——請重新整理後再試。」
6031InvalidRewardPeriodInvalid reward period獎勵排放期間無效(end <= start 或持續時間為零)。不適用——管理員路徑。
6032NotApproveUpdateRewardEmissionsModification of emissions is allowed within 72 hours from the end of the previous cycle管理員試圖在週期邊界前後 72 小時視窗以外修改排放設定。不適用——管理員路徑。
6033UnInitializedRewardInfouninitialized reward info獎勵槽位尚未初始化但被引用。不適用——管理員路徑。
6034NotSupportMintNot support token_2022 mint extensionCLMM 遇到無法處理的 Token-2022 擴充功能。「此 token 包含 Raydium CLMM 不支援的擴充功能。」
6035MissingTickArrayBitmapExtensionAccountMissing tickarray bitmap extension accountswap 跨越了基礎 bitmap 未涵蓋的 tick 範圍,需要擴充 bitmap 帳戶。「內部錯誤:缺少 tick-array 擴充——請重新整理資金池資料。」
6036InsufficientLiquidityForDirectionInsufficient liquidity for this directionswap 方向上的流動性不足。「此 swap 規模的流動性不足。」
6037MaxTokenOverflowMax token overflow輸入/輸出金額超過 u64 上限。「金額對此資金池而言過大。」
6038CalculateOverflowCalculate overflow手續費/流動性算術溢位。「金額對此資金池而言過大。」
6039TransferFeeCalculateNotMatchTransferFee calculate not matchToken-2022 轉帳手續費的實際觀察金額與預期不符。「Token 轉帳費用在交易過程中發生變動,請重試。」
6040OrderAlreadyFilledOrder already fully filled, cannot modifyIncreaseLimitOrder / DecreaseLimitOrder 被呼叫於未成交部分為零的訂單。「此限價單已全部成交——請結算以領取輸出。」
6041InvalidOrderPhaseInvalid order phase試圖修改一個 FIFO 批次階段已不再符合該 tick 當前批次的訂單。「無法在訂單的當前狀態執行此操作。」
6042InvalidLimitOrderAmountInvalid limit order amount訂單金額在開倉/增加/減少時低於資金池最小值(或為零)。「訂單規模低於資金池最小限制。」
6043OrderPhaseSaturatedTick order phase saturated該 tick 上批次的 order_phase 計數器已達上限,在現有批次結算並輪換之前,無法在該 tick 繼續開單。「此價格的活躍訂單過多,請嘗試鄰近的 tick 或等待訂單結算。」
6044InvalidDynamicFeeConfigParamsInvalid dynamic fee config paramsCreateDynamicFeeConfig / UpdateDynamicFeeConfig 被拒絕;或 CreateCustomizablePool 在沒有有效設定的情況下啟用了動態手續費。管理員路徑不適用;使用者路徑顯示「動態手續費設定無效」。
6045InvalidFeeOnInvalid fee on which token (must be 0, 1, or 2)CreateCustomizablePool 傳入的 collect_fee_on 值超出 {0, 1, 2} 範圍。「內部錯誤:手續費模式無效。」
6046ZeroSqrtPricesqrt_price_x64 must be greater than 0CreateCustomizablePool(或其他接受自訂初始 sqrt 價格的路徑)以 sqrt_price_x64 == 0 被呼叫。「初始價格必須大於零。」
6047ZeroLiquidityliquidity must be greater than 0提供流動性的路徑以 liquidity == 0 且無補償金額被呼叫。「流動性金額必須大於零。」
6048MissingBaseFlagbase_flag is required when liquidity is zero以金額開倉的路徑計算出 liquidity == 0,且呼叫者未提供 base_flag 以區分哪一側為基礎資產。「請提供非零的流動性,或指定哪個 token 為基礎資產。」
6049MissingMintAccountMint account is required but not provided一個具備 Token-2022 感知能力的路徑被呼叫時,缺少用於驗證擴充功能及轉帳手續費所需的輸入/輸出 mint 帳戶。「內部錯誤:缺少 mint 帳戶——請重新整理資金池資料。」
6050MissingTokenProgram2022Token-2022 program is required but not provided同上,缺少 SPL-Token-2022 程式帳戶。「內部錯誤:缺少 Token-2022 程式——請重新整理後再試。」
關於重新編號的說明。 此版本中,CLMM ErrorCode 列舉已重新編號:五個舊版變體(LOKZeroMintAmountInvalidLiquidityTransactionTooOldInvalidRewardDesiredAmount)及數個拼字錯誤(Liquitityenoughtemissiones)已被移除或修正,並新增了十一個新變體。由於 Anchor 按原始碼順序編號錯誤,6000 及之後的所有代碼相對於預發布版本均已偏移。已將數字代碼硬編碼到舊版本的客戶端需要重新對應。
產生來源:github.com/raydium-io/raydium-clmm — error.rs

AMM v4、Farm v3 / v5 / v6、LaunchLab 錯誤

這些程式的說明文件位於各自的章節(請參閱 products/amm-v4/instructionsproducts/farm-staking/instructionsproducts/launchlab/instructions)。由於這些程式混用了 Anchor 與原生 Solana 的錯誤介面,其錯誤表格放置於指令參考旁,而非此處。以下代碼由各章節保留:
程式代碼範圍(僅限 Anchor)參考
AMM v4自訂 u32 代碼,非 Anchor 風格products/amm-v4/instructions
Farm v3 / v5自訂 u32 代碼products/farm-staking/instructions
Farm v66000+(Anchor)products/farm-staking/instructions
LaunchLab6000+(Anchor)products/launchlab/instructions

將 SDK 錯誤對應至程式錯誤

官方 TypeScript SDK 會將鏈上錯誤封裝成 SendTransactionError,對於 Anchor 程式則封裝成 AnchorError
import { AnchorError } from "@coral-xyz/anchor";

try {
  await sdk.cpmm.swap({ ... });
} catch (err) {
  if (err instanceof AnchorError) {
    console.log(err.error.errorCode.number, err.error.errorCode.code, err.error.errorMessage);
    // 6005 ExceededSlippage "Exceeds desired slippage limit"
  } else {
    // Raw SendTransactionError — inspect err.logs for the "custom program error: 0x..." line.
  }
}
如果你沒有在客戶端使用 Anchor,可以解析交易日誌:
Program <ProgramID> invoke [1]
Program log: AnchorError caused by account: pool_state. Error Code: ExceededSlippage. Error Number: 6005. Error Message: Exceeds desired slippage limit.
Error Number: (\d+) 這個模式在所有 Anchor 版本中保持穩定,可安全使用於匹配。

重新產生這些表格

當程式升級並新增錯誤時,請從原始碼重新擷取:
# Clone and grep the error enum in order.
git clone --depth=1 https://github.com/raydium-io/raydium-cp-swap
awk '/#\[msg\(/{ gsub(/^[ \t]*#\[msg\("|"\)\][ \t]*/,""); m=$0; getline; gsub(/,/,""); gsub(/^[ \t]+/,""); print "6000+++\t" $0 "\t" m }' \
  raydium-cp-swap/programs/cp-swap/src/error.rs
# Replace 6000+++ with monotonically-increasing 6000,6001,... Append new rows to the table above.
每次新增變體時,請務必更新 reference/changelog,讓正在升級 SDK 的整合者知道需要更新其錯誤處理邏輯。 來源: