UNPKG

@kamino-finance/kliquidity-sdk

Version:

Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol

118 lines (111 loc) 12.4 kB
/** * This code was AUTOGENERATED using the Codama library. * Please DO NOT EDIT THIS FILE, instead use visitors * to add features, then rerun Codama to update it. * * @see https://github.com/codama-idl/codama */ import { isProgramError, type Address, type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM, type SolanaError } from '@solana/kit'; import { AMM_V3_PROGRAM_ADDRESS } from '../programs'; /** LOK: LOK */ export const AMM_V3_ERROR__L_O_K = 0x1770; // 6000 /** NotApproved: Not approved */ export const AMM_V3_ERROR__NOT_APPROVED = 0x1771; // 6001 /** InvalidUpdateConfigFlag: invalid update amm config flag */ export const AMM_V3_ERROR__INVALID_UPDATE_CONFIG_FLAG = 0x1772; // 6002 /** AccountLack: Account lack */ export const AMM_V3_ERROR__ACCOUNT_LACK = 0x1773; // 6003 /** ClosePositionErr: Remove liquitity, collect fees owed and reward then you can close position account */ export const AMM_V3_ERROR__CLOSE_POSITION_ERR = 0x1774; // 6004 /** ZeroMintAmount: Minting amount should be greater than 0 */ export const AMM_V3_ERROR__ZERO_MINT_AMOUNT = 0x1775; // 6005 /** InvaildTickIndex: Tick out of range */ export const AMM_V3_ERROR__INVAILD_TICK_INDEX = 0x1776; // 6006 /** TickInvaildOrder: The lower tick must be below the upper tick */ export const AMM_V3_ERROR__TICK_INVAILD_ORDER = 0x1777; // 6007 /** TickLowerOverflow: The tick must be greater, or equal to the minimum tick(-221818) */ export const AMM_V3_ERROR__TICK_LOWER_OVERFLOW = 0x1778; // 6008 /** TickUpperOverflow: The tick must be lesser than, or equal to the maximum tick(221818) */ export const AMM_V3_ERROR__TICK_UPPER_OVERFLOW = 0x1779; // 6009 /** TickAndSpacingNotMatch: tick % tick_spacing must be zero */ export const AMM_V3_ERROR__TICK_AND_SPACING_NOT_MATCH = 0x177a; // 6010 /** InvalidTickArray: Invaild tick array account */ export const AMM_V3_ERROR__INVALID_TICK_ARRAY = 0x177b; // 6011 /** InvalidTickArrayBoundary: Invaild tick array boundary */ export const AMM_V3_ERROR__INVALID_TICK_ARRAY_BOUNDARY = 0x177c; // 6012 /** SqrtPriceLimitOverflow: Square root price limit overflow */ export const AMM_V3_ERROR__SQRT_PRICE_LIMIT_OVERFLOW = 0x177d; // 6013 /** SqrtPriceX64: sqrt_price_x64 out of range */ export const AMM_V3_ERROR__SQRT_PRICE_X64 = 0x177e; // 6014 /** LiquiditySubValueErr: Liquidity sub delta L must be smaller than before */ export const AMM_V3_ERROR__LIQUIDITY_SUB_VALUE_ERR = 0x177f; // 6015 /** LiquidityAddValueErr: Liquidity add delta L must be greater, or equal to before */ export const AMM_V3_ERROR__LIQUIDITY_ADD_VALUE_ERR = 0x1780; // 6016 /** InvaildLiquidity: Invaild liquidity when update position */ export const AMM_V3_ERROR__INVAILD_LIQUIDITY = 0x1781; // 6017 /** ForbidBothZeroForSupplyLiquidity: Both token amount must not be zero while supply liquidity */ export const AMM_V3_ERROR__FORBID_BOTH_ZERO_FOR_SUPPLY_LIQUIDITY = 0x1782; // 6018 /** LiquidityInsufficient: Liquidity insufficient */ export const AMM_V3_ERROR__LIQUIDITY_INSUFFICIENT = 0x1783; // 6019 /** TransactionTooOld: Transaction too old */ export const AMM_V3_ERROR__TRANSACTION_TOO_OLD = 0x1784; // 6020 /** PriceSlippageCheck: Price slippage check */ export const AMM_V3_ERROR__PRICE_SLIPPAGE_CHECK = 0x1785; // 6021 /** TooLittleOutputReceived: Too little output received */ export const AMM_V3_ERROR__TOO_LITTLE_OUTPUT_RECEIVED = 0x1786; // 6022 /** TooMuchInputPaid: Too much input paid */ export const AMM_V3_ERROR__TOO_MUCH_INPUT_PAID = 0x1787; // 6023 /** InvaildSwapAmountSpecified: Swap special amount can not be zero */ export const AMM_V3_ERROR__INVAILD_SWAP_AMOUNT_SPECIFIED = 0x1788; // 6024 /** InvalidInputPoolVault: Input pool vault is invalid */ export const AMM_V3_ERROR__INVALID_INPUT_POOL_VAULT = 0x1789; // 6025 /** TooSmallInputOrOutputAmount: Swap input or output amount is too small */ export const AMM_V3_ERROR__TOO_SMALL_INPUT_OR_OUTPUT_AMOUNT = 0x178a; // 6026 /** NotEnoughTickArrayAccount: Not enought tick array account */ export const AMM_V3_ERROR__NOT_ENOUGH_TICK_ARRAY_ACCOUNT = 0x178b; // 6027 /** InvalidFirstTickArrayAccount: Invaild first tick array account */ export const AMM_V3_ERROR__INVALID_FIRST_TICK_ARRAY_ACCOUNT = 0x178c; // 6028 /** InvalidRewardIndex: Invalid reward index */ export const AMM_V3_ERROR__INVALID_REWARD_INDEX = 0x178d; // 6029 /** FullRewardInfo: The init reward token reach to the max */ export const AMM_V3_ERROR__FULL_REWARD_INFO = 0x178e; // 6030 /** RewardTokenAlreadyInUse: The init reward token already in use */ export const AMM_V3_ERROR__REWARD_TOKEN_ALREADY_IN_USE = 0x178f; // 6031 /** ExceptPoolVaultMint: The reward tokens must contain one of pool vault mint except the last reward */ export const AMM_V3_ERROR__EXCEPT_POOL_VAULT_MINT = 0x1790; // 6032 /** InvalidRewardInitParam: Invalid reward init param */ export const AMM_V3_ERROR__INVALID_REWARD_INIT_PARAM = 0x1791; // 6033 /** InvalidRewardDesiredAmount: Invalid collect reward desired amount */ export const AMM_V3_ERROR__INVALID_REWARD_DESIRED_AMOUNT = 0x1792; // 6034 /** InvalidRewardInputAccountNumber: Invalid collect reward input account number */ export const AMM_V3_ERROR__INVALID_REWARD_INPUT_ACCOUNT_NUMBER = 0x1793; // 6035 /** InvalidRewardPeriod: Invalid reward period */ export const AMM_V3_ERROR__INVALID_REWARD_PERIOD = 0x1794; // 6036 /** NotApproveUpdateRewardEmissiones: Modification of emissiones is allowed within 72 hours from the end of the previous cycle */ export const AMM_V3_ERROR__NOT_APPROVE_UPDATE_REWARD_EMISSIONES = 0x1795; // 6037 /** UnInitializedRewardInfo: uninitialized reward info */ export const AMM_V3_ERROR__UN_INITIALIZED_REWARD_INFO = 0x1796; // 6038 /** NotSupportMint: Not support token_2022 mint extension */ export const AMM_V3_ERROR__NOT_SUPPORT_MINT = 0x1797; // 6039 /** MissingTickArrayBitmapExtensionAccount: Missing tickarray bitmap extension account */ export const AMM_V3_ERROR__MISSING_TICK_ARRAY_BITMAP_EXTENSION_ACCOUNT = 0x1798; // 6040 /** InsufficientLiquidityForDirection: Insufficient liquidity for this direction */ export const AMM_V3_ERROR__INSUFFICIENT_LIQUIDITY_FOR_DIRECTION = 0x1799; // 6041 export type AmmV3Error = typeof AMM_V3_ERROR__ACCOUNT_LACK | typeof AMM_V3_ERROR__CLOSE_POSITION_ERR | typeof AMM_V3_ERROR__EXCEPT_POOL_VAULT_MINT | typeof AMM_V3_ERROR__FORBID_BOTH_ZERO_FOR_SUPPLY_LIQUIDITY | typeof AMM_V3_ERROR__FULL_REWARD_INFO | typeof AMM_V3_ERROR__INSUFFICIENT_LIQUIDITY_FOR_DIRECTION | typeof AMM_V3_ERROR__INVAILD_LIQUIDITY | typeof AMM_V3_ERROR__INVAILD_SWAP_AMOUNT_SPECIFIED | typeof AMM_V3_ERROR__INVAILD_TICK_INDEX | typeof AMM_V3_ERROR__INVALID_FIRST_TICK_ARRAY_ACCOUNT | typeof AMM_V3_ERROR__INVALID_INPUT_POOL_VAULT | typeof AMM_V3_ERROR__INVALID_REWARD_DESIRED_AMOUNT | typeof AMM_V3_ERROR__INVALID_REWARD_INDEX | typeof AMM_V3_ERROR__INVALID_REWARD_INIT_PARAM | typeof AMM_V3_ERROR__INVALID_REWARD_INPUT_ACCOUNT_NUMBER | typeof AMM_V3_ERROR__INVALID_REWARD_PERIOD | typeof AMM_V3_ERROR__INVALID_TICK_ARRAY | typeof AMM_V3_ERROR__INVALID_TICK_ARRAY_BOUNDARY | typeof AMM_V3_ERROR__INVALID_UPDATE_CONFIG_FLAG | typeof AMM_V3_ERROR__LIQUIDITY_ADD_VALUE_ERR | typeof AMM_V3_ERROR__LIQUIDITY_INSUFFICIENT | typeof AMM_V3_ERROR__LIQUIDITY_SUB_VALUE_ERR | typeof AMM_V3_ERROR__L_O_K | typeof AMM_V3_ERROR__MISSING_TICK_ARRAY_BITMAP_EXTENSION_ACCOUNT | typeof AMM_V3_ERROR__NOT_APPROVED | typeof AMM_V3_ERROR__NOT_APPROVE_UPDATE_REWARD_EMISSIONES | typeof AMM_V3_ERROR__NOT_ENOUGH_TICK_ARRAY_ACCOUNT | typeof AMM_V3_ERROR__NOT_SUPPORT_MINT | typeof AMM_V3_ERROR__PRICE_SLIPPAGE_CHECK | typeof AMM_V3_ERROR__REWARD_TOKEN_ALREADY_IN_USE | typeof AMM_V3_ERROR__SQRT_PRICE_LIMIT_OVERFLOW | typeof AMM_V3_ERROR__SQRT_PRICE_X64 | typeof AMM_V3_ERROR__TICK_AND_SPACING_NOT_MATCH | typeof AMM_V3_ERROR__TICK_INVAILD_ORDER | typeof AMM_V3_ERROR__TICK_LOWER_OVERFLOW | typeof AMM_V3_ERROR__TICK_UPPER_OVERFLOW | typeof AMM_V3_ERROR__TOO_LITTLE_OUTPUT_RECEIVED | typeof AMM_V3_ERROR__TOO_MUCH_INPUT_PAID | typeof AMM_V3_ERROR__TOO_SMALL_INPUT_OR_OUTPUT_AMOUNT | typeof AMM_V3_ERROR__TRANSACTION_TOO_OLD | typeof AMM_V3_ERROR__UN_INITIALIZED_REWARD_INFO | typeof AMM_V3_ERROR__ZERO_MINT_AMOUNT; let ammV3ErrorMessages: Record<AmmV3Error, string> | undefined; if (process.env.NODE_ENV !== 'production') { ammV3ErrorMessages = { [AMM_V3_ERROR__ACCOUNT_LACK]: `Account lack`, [AMM_V3_ERROR__CLOSE_POSITION_ERR]: `Remove liquitity, collect fees owed and reward then you can close position account`, [AMM_V3_ERROR__EXCEPT_POOL_VAULT_MINT]: `The reward tokens must contain one of pool vault mint except the last reward`, [AMM_V3_ERROR__FORBID_BOTH_ZERO_FOR_SUPPLY_LIQUIDITY]: `Both token amount must not be zero while supply liquidity`, [AMM_V3_ERROR__FULL_REWARD_INFO]: `The init reward token reach to the max`, [AMM_V3_ERROR__INSUFFICIENT_LIQUIDITY_FOR_DIRECTION]: `Insufficient liquidity for this direction`, [AMM_V3_ERROR__INVAILD_LIQUIDITY]: `Invaild liquidity when update position`, [AMM_V3_ERROR__INVAILD_SWAP_AMOUNT_SPECIFIED]: `Swap special amount can not be zero`, [AMM_V3_ERROR__INVAILD_TICK_INDEX]: `Tick out of range`, [AMM_V3_ERROR__INVALID_FIRST_TICK_ARRAY_ACCOUNT]: `Invaild first tick array account`, [AMM_V3_ERROR__INVALID_INPUT_POOL_VAULT]: `Input pool vault is invalid`, [AMM_V3_ERROR__INVALID_REWARD_DESIRED_AMOUNT]: `Invalid collect reward desired amount`, [AMM_V3_ERROR__INVALID_REWARD_INDEX]: `Invalid reward index`, [AMM_V3_ERROR__INVALID_REWARD_INIT_PARAM]: `Invalid reward init param`, [AMM_V3_ERROR__INVALID_REWARD_INPUT_ACCOUNT_NUMBER]: `Invalid collect reward input account number`, [AMM_V3_ERROR__INVALID_REWARD_PERIOD]: `Invalid reward period`, [AMM_V3_ERROR__INVALID_TICK_ARRAY]: `Invaild tick array account`, [AMM_V3_ERROR__INVALID_TICK_ARRAY_BOUNDARY]: `Invaild tick array boundary`, [AMM_V3_ERROR__INVALID_UPDATE_CONFIG_FLAG]: `invalid update amm config flag`, [AMM_V3_ERROR__LIQUIDITY_ADD_VALUE_ERR]: `Liquidity add delta L must be greater, or equal to before`, [AMM_V3_ERROR__LIQUIDITY_INSUFFICIENT]: `Liquidity insufficient`, [AMM_V3_ERROR__LIQUIDITY_SUB_VALUE_ERR]: `Liquidity sub delta L must be smaller than before`, [AMM_V3_ERROR__L_O_K]: `LOK`, [AMM_V3_ERROR__MISSING_TICK_ARRAY_BITMAP_EXTENSION_ACCOUNT]: `Missing tickarray bitmap extension account`, [AMM_V3_ERROR__NOT_APPROVED]: `Not approved`, [AMM_V3_ERROR__NOT_APPROVE_UPDATE_REWARD_EMISSIONES]: `Modification of emissiones is allowed within 72 hours from the end of the previous cycle`, [AMM_V3_ERROR__NOT_ENOUGH_TICK_ARRAY_ACCOUNT]: `Not enought tick array account`, [AMM_V3_ERROR__NOT_SUPPORT_MINT]: `Not support token_2022 mint extension`, [AMM_V3_ERROR__PRICE_SLIPPAGE_CHECK]: `Price slippage check`, [AMM_V3_ERROR__REWARD_TOKEN_ALREADY_IN_USE]: `The init reward token already in use`, [AMM_V3_ERROR__SQRT_PRICE_LIMIT_OVERFLOW]: `Square root price limit overflow`, [AMM_V3_ERROR__SQRT_PRICE_X64]: `sqrt_price_x64 out of range`, [AMM_V3_ERROR__TICK_AND_SPACING_NOT_MATCH]: `tick % tick_spacing must be zero`, [AMM_V3_ERROR__TICK_INVAILD_ORDER]: `The lower tick must be below the upper tick`, [AMM_V3_ERROR__TICK_LOWER_OVERFLOW]: `The tick must be greater, or equal to the minimum tick(-221818)`, [AMM_V3_ERROR__TICK_UPPER_OVERFLOW]: `The tick must be lesser than, or equal to the maximum tick(221818)`, [AMM_V3_ERROR__TOO_LITTLE_OUTPUT_RECEIVED]: `Too little output received`, [AMM_V3_ERROR__TOO_MUCH_INPUT_PAID]: `Too much input paid`, [AMM_V3_ERROR__TOO_SMALL_INPUT_OR_OUTPUT_AMOUNT]: `Swap input or output amount is too small`, [AMM_V3_ERROR__TRANSACTION_TOO_OLD]: `Transaction too old`, [AMM_V3_ERROR__UN_INITIALIZED_REWARD_INFO]: `uninitialized reward info`, [AMM_V3_ERROR__ZERO_MINT_AMOUNT]: `Minting amount should be greater than 0` }; } export function getAmmV3ErrorMessage(code: AmmV3Error): string { if (process.env.NODE_ENV !== 'production') { return (ammV3ErrorMessages as Record<AmmV3Error, string>)[code]; } return 'Error message not available in production bundles.'; } export function isAmmV3Error<TProgramErrorCode extends AmmV3Error>( error: unknown, transactionMessage: { instructions: Record<number, { programAddress: Address }> }, code?: TProgramErrorCode, ): error is SolanaError<typeof SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM> & Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { return isProgramError<TProgramErrorCode>(error, transactionMessage, AMM_V3_PROGRAM_ADDRESS, code); }