UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

152 lines (145 loc) 15.3 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 { LB_CLMM_PROGRAM_ADDRESS } from '../programs'; /** InvalidStartBinIndex: Invalid start bin index */ export const LB_CLMM_ERROR__INVALID_START_BIN_INDEX = 0x1770; // 6000 /** InvalidBinId: Invalid bin id */ export const LB_CLMM_ERROR__INVALID_BIN_ID = 0x1771; // 6001 /** InvalidInput: Invalid input data */ export const LB_CLMM_ERROR__INVALID_INPUT = 0x1772; // 6002 /** ExceededAmountSlippageTolerance: Exceeded amount slippage tolerance */ export const LB_CLMM_ERROR__EXCEEDED_AMOUNT_SLIPPAGE_TOLERANCE = 0x1773; // 6003 /** ExceededBinSlippageTolerance: Exceeded bin slippage tolerance */ export const LB_CLMM_ERROR__EXCEEDED_BIN_SLIPPAGE_TOLERANCE = 0x1774; // 6004 /** CompositionFactorFlawed: Composition factor flawed */ export const LB_CLMM_ERROR__COMPOSITION_FACTOR_FLAWED = 0x1775; // 6005 /** NonPresetBinStep: Non preset bin step */ export const LB_CLMM_ERROR__NON_PRESET_BIN_STEP = 0x1776; // 6006 /** ZeroLiquidity: Zero liquidity */ export const LB_CLMM_ERROR__ZERO_LIQUIDITY = 0x1777; // 6007 /** InvalidPosition: Invalid position */ export const LB_CLMM_ERROR__INVALID_POSITION = 0x1778; // 6008 /** BinArrayNotFound: Bin array not found */ export const LB_CLMM_ERROR__BIN_ARRAY_NOT_FOUND = 0x1779; // 6009 /** InvalidTokenMint: Invalid token mint */ export const LB_CLMM_ERROR__INVALID_TOKEN_MINT = 0x177a; // 6010 /** InvalidAccountForSingleDeposit: Invalid account for single deposit */ export const LB_CLMM_ERROR__INVALID_ACCOUNT_FOR_SINGLE_DEPOSIT = 0x177b; // 6011 /** PairInsufficientLiquidity: Pair insufficient liquidity */ export const LB_CLMM_ERROR__PAIR_INSUFFICIENT_LIQUIDITY = 0x177c; // 6012 /** InvalidFeeOwner: Invalid fee owner */ export const LB_CLMM_ERROR__INVALID_FEE_OWNER = 0x177d; // 6013 /** InvalidFeeWithdrawAmount: Invalid fee withdraw amount */ export const LB_CLMM_ERROR__INVALID_FEE_WITHDRAW_AMOUNT = 0x177e; // 6014 /** InvalidAdmin: Invalid admin */ export const LB_CLMM_ERROR__INVALID_ADMIN = 0x177f; // 6015 /** IdenticalFeeOwner: Identical fee owner */ export const LB_CLMM_ERROR__IDENTICAL_FEE_OWNER = 0x1780; // 6016 /** InvalidBps: Invalid basis point */ export const LB_CLMM_ERROR__INVALID_BPS = 0x1781; // 6017 /** MathOverflow: Math operation overflow */ export const LB_CLMM_ERROR__MATH_OVERFLOW = 0x1782; // 6018 /** TypeCastFailed: Type cast error */ export const LB_CLMM_ERROR__TYPE_CAST_FAILED = 0x1783; // 6019 /** InvalidRewardIndex: Invalid reward index */ export const LB_CLMM_ERROR__INVALID_REWARD_INDEX = 0x1784; // 6020 /** InvalidRewardDuration: Invalid reward duration */ export const LB_CLMM_ERROR__INVALID_REWARD_DURATION = 0x1785; // 6021 /** RewardInitialized: Reward already initialized */ export const LB_CLMM_ERROR__REWARD_INITIALIZED = 0x1786; // 6022 /** RewardUninitialized: Reward not initialized */ export const LB_CLMM_ERROR__REWARD_UNINITIALIZED = 0x1787; // 6023 /** IdenticalFunder: Identical funder */ export const LB_CLMM_ERROR__IDENTICAL_FUNDER = 0x1788; // 6024 /** RewardCampaignInProgress: Reward campaign in progress */ export const LB_CLMM_ERROR__REWARD_CAMPAIGN_IN_PROGRESS = 0x1789; // 6025 /** IdenticalRewardDuration: Reward duration is the same */ export const LB_CLMM_ERROR__IDENTICAL_REWARD_DURATION = 0x178a; // 6026 /** InvalidBinArray: Invalid bin array */ export const LB_CLMM_ERROR__INVALID_BIN_ARRAY = 0x178b; // 6027 /** NonContinuousBinArrays: Bin arrays must be continuous */ export const LB_CLMM_ERROR__NON_CONTINUOUS_BIN_ARRAYS = 0x178c; // 6028 /** InvalidRewardVault: Invalid reward vault */ export const LB_CLMM_ERROR__INVALID_REWARD_VAULT = 0x178d; // 6029 /** NonEmptyPosition: Position is not empty */ export const LB_CLMM_ERROR__NON_EMPTY_POSITION = 0x178e; // 6030 /** UnauthorizedAccess: Unauthorized access */ export const LB_CLMM_ERROR__UNAUTHORIZED_ACCESS = 0x178f; // 6031 /** InvalidFeeParameter: Invalid fee parameter */ export const LB_CLMM_ERROR__INVALID_FEE_PARAMETER = 0x1790; // 6032 /** MissingOracle: Missing oracle account */ export const LB_CLMM_ERROR__MISSING_ORACLE = 0x1791; // 6033 /** InsufficientSample: Insufficient observation sample */ export const LB_CLMM_ERROR__INSUFFICIENT_SAMPLE = 0x1792; // 6034 /** InvalidLookupTimestamp: Invalid lookup timestamp */ export const LB_CLMM_ERROR__INVALID_LOOKUP_TIMESTAMP = 0x1793; // 6035 /** BitmapExtensionAccountIsNotProvided: Bitmap extension account is not provided */ export const LB_CLMM_ERROR__BITMAP_EXTENSION_ACCOUNT_IS_NOT_PROVIDED = 0x1794; // 6036 /** CannotFindNonZeroLiquidityBinArrayId: Cannot find non-zero liquidity binArrayId */ export const LB_CLMM_ERROR__CANNOT_FIND_NON_ZERO_LIQUIDITY_BIN_ARRAY_ID = 0x1795; // 6037 /** BinIdOutOfBound: Bin id out of bound */ export const LB_CLMM_ERROR__BIN_ID_OUT_OF_BOUND = 0x1796; // 6038 /** InsufficientOutAmount: Insufficient amount in for minimum out */ export const LB_CLMM_ERROR__INSUFFICIENT_OUT_AMOUNT = 0x1797; // 6039 /** InvalidPositionWidth: Invalid position width */ export const LB_CLMM_ERROR__INVALID_POSITION_WIDTH = 0x1798; // 6040 /** ExcessiveFeeUpdate: Excessive fee update */ export const LB_CLMM_ERROR__EXCESSIVE_FEE_UPDATE = 0x1799; // 6041 /** PoolDisabled: Pool disabled */ export const LB_CLMM_ERROR__POOL_DISABLED = 0x179a; // 6042 /** InvalidPoolType: Invalid pool type */ export const LB_CLMM_ERROR__INVALID_POOL_TYPE = 0x179b; // 6043 /** ExceedMaxWhitelist: Whitelist for wallet is full */ export const LB_CLMM_ERROR__EXCEED_MAX_WHITELIST = 0x179c; // 6044 /** InvalidIndex: Invalid index */ export const LB_CLMM_ERROR__INVALID_INDEX = 0x179d; // 6045 /** RewardNotEnded: Reward not ended */ export const LB_CLMM_ERROR__REWARD_NOT_ENDED = 0x179e; // 6046 /** MustWithdrawnIneligibleReward: Must withdraw ineligible reward */ export const LB_CLMM_ERROR__MUST_WITHDRAWN_INELIGIBLE_REWARD = 0x179f; // 6047 /** UnauthorizedAddress: Unauthorized address */ export const LB_CLMM_ERROR__UNAUTHORIZED_ADDRESS = 0x17a0; // 6048 /** OperatorsAreTheSame: Cannot update because operators are the same */ export const LB_CLMM_ERROR__OPERATORS_ARE_THE_SAME = 0x17a1; // 6049 /** WithdrawToWrongTokenAccount: Withdraw to wrong token account */ export const LB_CLMM_ERROR__WITHDRAW_TO_WRONG_TOKEN_ACCOUNT = 0x17a2; // 6050 /** WrongRentReceiver: Wrong rent receiver */ export const LB_CLMM_ERROR__WRONG_RENT_RECEIVER = 0x17a3; // 6051 /** AlreadyPassActivationSlot: Already activated */ export const LB_CLMM_ERROR__ALREADY_PASS_ACTIVATION_SLOT = 0x17a4; // 6052 /** LastSlotCannotBeSmallerThanActivateSlot: Last slot cannot be smaller than activate slot */ export const LB_CLMM_ERROR__LAST_SLOT_CANNOT_BE_SMALLER_THAN_ACTIVATE_SLOT = 0x17a5; // 6053 /** ExceedMaxSwappedAmount: Swapped amount is exceeded max swapped amount */ export const LB_CLMM_ERROR__EXCEED_MAX_SWAPPED_AMOUNT = 0x17a6; // 6054 /** InvalidStrategyParameters: Invalid strategy parameters */ export const LB_CLMM_ERROR__INVALID_STRATEGY_PARAMETERS = 0x17a7; // 6055 /** LiquidityLocked: Liquidity locked */ export const LB_CLMM_ERROR__LIQUIDITY_LOCKED = 0x17a8; // 6056 /** InvalidLockReleaseSlot: Invalid lock release slot */ export const LB_CLMM_ERROR__INVALID_LOCK_RELEASE_SLOT = 0x17a9; // 6057 /** BinRangeIsNotEmpty: Bin range is not empty */ export const LB_CLMM_ERROR__BIN_RANGE_IS_NOT_EMPTY = 0x17aa; // 6058 export type LbClmmError = typeof LB_CLMM_ERROR__ALREADY_PASS_ACTIVATION_SLOT | typeof LB_CLMM_ERROR__BIN_ARRAY_NOT_FOUND | typeof LB_CLMM_ERROR__BIN_ID_OUT_OF_BOUND | typeof LB_CLMM_ERROR__BIN_RANGE_IS_NOT_EMPTY | typeof LB_CLMM_ERROR__BITMAP_EXTENSION_ACCOUNT_IS_NOT_PROVIDED | typeof LB_CLMM_ERROR__CANNOT_FIND_NON_ZERO_LIQUIDITY_BIN_ARRAY_ID | typeof LB_CLMM_ERROR__COMPOSITION_FACTOR_FLAWED | typeof LB_CLMM_ERROR__EXCEEDED_AMOUNT_SLIPPAGE_TOLERANCE | typeof LB_CLMM_ERROR__EXCEEDED_BIN_SLIPPAGE_TOLERANCE | typeof LB_CLMM_ERROR__EXCEED_MAX_SWAPPED_AMOUNT | typeof LB_CLMM_ERROR__EXCEED_MAX_WHITELIST | typeof LB_CLMM_ERROR__EXCESSIVE_FEE_UPDATE | typeof LB_CLMM_ERROR__IDENTICAL_FEE_OWNER | typeof LB_CLMM_ERROR__IDENTICAL_FUNDER | typeof LB_CLMM_ERROR__IDENTICAL_REWARD_DURATION | typeof LB_CLMM_ERROR__INSUFFICIENT_OUT_AMOUNT | typeof LB_CLMM_ERROR__INSUFFICIENT_SAMPLE | typeof LB_CLMM_ERROR__INVALID_ACCOUNT_FOR_SINGLE_DEPOSIT | typeof LB_CLMM_ERROR__INVALID_ADMIN | typeof LB_CLMM_ERROR__INVALID_BIN_ARRAY | typeof LB_CLMM_ERROR__INVALID_BIN_ID | typeof LB_CLMM_ERROR__INVALID_BPS | typeof LB_CLMM_ERROR__INVALID_FEE_OWNER | typeof LB_CLMM_ERROR__INVALID_FEE_PARAMETER | typeof LB_CLMM_ERROR__INVALID_FEE_WITHDRAW_AMOUNT | typeof LB_CLMM_ERROR__INVALID_INDEX | typeof LB_CLMM_ERROR__INVALID_INPUT | typeof LB_CLMM_ERROR__INVALID_LOCK_RELEASE_SLOT | typeof LB_CLMM_ERROR__INVALID_LOOKUP_TIMESTAMP | typeof LB_CLMM_ERROR__INVALID_POOL_TYPE | typeof LB_CLMM_ERROR__INVALID_POSITION | typeof LB_CLMM_ERROR__INVALID_POSITION_WIDTH | typeof LB_CLMM_ERROR__INVALID_REWARD_DURATION | typeof LB_CLMM_ERROR__INVALID_REWARD_INDEX | typeof LB_CLMM_ERROR__INVALID_REWARD_VAULT | typeof LB_CLMM_ERROR__INVALID_START_BIN_INDEX | typeof LB_CLMM_ERROR__INVALID_STRATEGY_PARAMETERS | typeof LB_CLMM_ERROR__INVALID_TOKEN_MINT | typeof LB_CLMM_ERROR__LAST_SLOT_CANNOT_BE_SMALLER_THAN_ACTIVATE_SLOT | typeof LB_CLMM_ERROR__LIQUIDITY_LOCKED | typeof LB_CLMM_ERROR__MATH_OVERFLOW | typeof LB_CLMM_ERROR__MISSING_ORACLE | typeof LB_CLMM_ERROR__MUST_WITHDRAWN_INELIGIBLE_REWARD | typeof LB_CLMM_ERROR__NON_CONTINUOUS_BIN_ARRAYS | typeof LB_CLMM_ERROR__NON_EMPTY_POSITION | typeof LB_CLMM_ERROR__NON_PRESET_BIN_STEP | typeof LB_CLMM_ERROR__OPERATORS_ARE_THE_SAME | typeof LB_CLMM_ERROR__PAIR_INSUFFICIENT_LIQUIDITY | typeof LB_CLMM_ERROR__POOL_DISABLED | typeof LB_CLMM_ERROR__REWARD_CAMPAIGN_IN_PROGRESS | typeof LB_CLMM_ERROR__REWARD_INITIALIZED | typeof LB_CLMM_ERROR__REWARD_NOT_ENDED | typeof LB_CLMM_ERROR__REWARD_UNINITIALIZED | typeof LB_CLMM_ERROR__TYPE_CAST_FAILED | typeof LB_CLMM_ERROR__UNAUTHORIZED_ACCESS | typeof LB_CLMM_ERROR__UNAUTHORIZED_ADDRESS | typeof LB_CLMM_ERROR__WITHDRAW_TO_WRONG_TOKEN_ACCOUNT | typeof LB_CLMM_ERROR__WRONG_RENT_RECEIVER | typeof LB_CLMM_ERROR__ZERO_LIQUIDITY; let lbClmmErrorMessages: Record<LbClmmError, string> | undefined; if (process.env.NODE_ENV !== 'production') { lbClmmErrorMessages = { [LB_CLMM_ERROR__ALREADY_PASS_ACTIVATION_SLOT]: `Already activated`, [LB_CLMM_ERROR__BIN_ARRAY_NOT_FOUND]: `Bin array not found`, [LB_CLMM_ERROR__BIN_ID_OUT_OF_BOUND]: `Bin id out of bound`, [LB_CLMM_ERROR__BIN_RANGE_IS_NOT_EMPTY]: `Bin range is not empty`, [LB_CLMM_ERROR__BITMAP_EXTENSION_ACCOUNT_IS_NOT_PROVIDED]: `Bitmap extension account is not provided`, [LB_CLMM_ERROR__CANNOT_FIND_NON_ZERO_LIQUIDITY_BIN_ARRAY_ID]: `Cannot find non-zero liquidity binArrayId`, [LB_CLMM_ERROR__COMPOSITION_FACTOR_FLAWED]: `Composition factor flawed`, [LB_CLMM_ERROR__EXCEEDED_AMOUNT_SLIPPAGE_TOLERANCE]: `Exceeded amount slippage tolerance`, [LB_CLMM_ERROR__EXCEEDED_BIN_SLIPPAGE_TOLERANCE]: `Exceeded bin slippage tolerance`, [LB_CLMM_ERROR__EXCEED_MAX_SWAPPED_AMOUNT]: `Swapped amount is exceeded max swapped amount`, [LB_CLMM_ERROR__EXCEED_MAX_WHITELIST]: `Whitelist for wallet is full`, [LB_CLMM_ERROR__EXCESSIVE_FEE_UPDATE]: `Excessive fee update`, [LB_CLMM_ERROR__IDENTICAL_FEE_OWNER]: `Identical fee owner`, [LB_CLMM_ERROR__IDENTICAL_FUNDER]: `Identical funder`, [LB_CLMM_ERROR__IDENTICAL_REWARD_DURATION]: `Reward duration is the same`, [LB_CLMM_ERROR__INSUFFICIENT_OUT_AMOUNT]: `Insufficient amount in for minimum out`, [LB_CLMM_ERROR__INSUFFICIENT_SAMPLE]: `Insufficient observation sample`, [LB_CLMM_ERROR__INVALID_ACCOUNT_FOR_SINGLE_DEPOSIT]: `Invalid account for single deposit`, [LB_CLMM_ERROR__INVALID_ADMIN]: `Invalid admin`, [LB_CLMM_ERROR__INVALID_BIN_ARRAY]: `Invalid bin array`, [LB_CLMM_ERROR__INVALID_BIN_ID]: `Invalid bin id`, [LB_CLMM_ERROR__INVALID_BPS]: `Invalid basis point`, [LB_CLMM_ERROR__INVALID_FEE_OWNER]: `Invalid fee owner`, [LB_CLMM_ERROR__INVALID_FEE_PARAMETER]: `Invalid fee parameter`, [LB_CLMM_ERROR__INVALID_FEE_WITHDRAW_AMOUNT]: `Invalid fee withdraw amount`, [LB_CLMM_ERROR__INVALID_INDEX]: `Invalid index`, [LB_CLMM_ERROR__INVALID_INPUT]: `Invalid input data`, [LB_CLMM_ERROR__INVALID_LOCK_RELEASE_SLOT]: `Invalid lock release slot`, [LB_CLMM_ERROR__INVALID_LOOKUP_TIMESTAMP]: `Invalid lookup timestamp`, [LB_CLMM_ERROR__INVALID_POOL_TYPE]: `Invalid pool type`, [LB_CLMM_ERROR__INVALID_POSITION]: `Invalid position`, [LB_CLMM_ERROR__INVALID_POSITION_WIDTH]: `Invalid position width`, [LB_CLMM_ERROR__INVALID_REWARD_DURATION]: `Invalid reward duration`, [LB_CLMM_ERROR__INVALID_REWARD_INDEX]: `Invalid reward index`, [LB_CLMM_ERROR__INVALID_REWARD_VAULT]: `Invalid reward vault`, [LB_CLMM_ERROR__INVALID_START_BIN_INDEX]: `Invalid start bin index`, [LB_CLMM_ERROR__INVALID_STRATEGY_PARAMETERS]: `Invalid strategy parameters`, [LB_CLMM_ERROR__INVALID_TOKEN_MINT]: `Invalid token mint`, [LB_CLMM_ERROR__LAST_SLOT_CANNOT_BE_SMALLER_THAN_ACTIVATE_SLOT]: `Last slot cannot be smaller than activate slot`, [LB_CLMM_ERROR__LIQUIDITY_LOCKED]: `Liquidity locked`, [LB_CLMM_ERROR__MATH_OVERFLOW]: `Math operation overflow`, [LB_CLMM_ERROR__MISSING_ORACLE]: `Missing oracle account`, [LB_CLMM_ERROR__MUST_WITHDRAWN_INELIGIBLE_REWARD]: `Must withdraw ineligible reward`, [LB_CLMM_ERROR__NON_CONTINUOUS_BIN_ARRAYS]: `Bin arrays must be continuous`, [LB_CLMM_ERROR__NON_EMPTY_POSITION]: `Position is not empty`, [LB_CLMM_ERROR__NON_PRESET_BIN_STEP]: `Non preset bin step`, [LB_CLMM_ERROR__OPERATORS_ARE_THE_SAME]: `Cannot update because operators are the same`, [LB_CLMM_ERROR__PAIR_INSUFFICIENT_LIQUIDITY]: `Pair insufficient liquidity`, [LB_CLMM_ERROR__POOL_DISABLED]: `Pool disabled`, [LB_CLMM_ERROR__REWARD_CAMPAIGN_IN_PROGRESS]: `Reward campaign in progress`, [LB_CLMM_ERROR__REWARD_INITIALIZED]: `Reward already initialized`, [LB_CLMM_ERROR__REWARD_NOT_ENDED]: `Reward not ended`, [LB_CLMM_ERROR__REWARD_UNINITIALIZED]: `Reward not initialized`, [LB_CLMM_ERROR__TYPE_CAST_FAILED]: `Type cast error`, [LB_CLMM_ERROR__UNAUTHORIZED_ACCESS]: `Unauthorized access`, [LB_CLMM_ERROR__UNAUTHORIZED_ADDRESS]: `Unauthorized address`, [LB_CLMM_ERROR__WITHDRAW_TO_WRONG_TOKEN_ACCOUNT]: `Withdraw to wrong token account`, [LB_CLMM_ERROR__WRONG_RENT_RECEIVER]: `Wrong rent receiver`, [LB_CLMM_ERROR__ZERO_LIQUIDITY]: `Zero liquidity` }; } export function getLbClmmErrorMessage(code: LbClmmError): string { if (process.env.NODE_ENV !== 'production') { return (lbClmmErrorMessages as Record<LbClmmError, string>)[code]; } return 'Error message not available in production bundles.'; } export function isLbClmmError<TProgramErrorCode extends LbClmmError>( 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, LB_CLMM_PROGRAM_ADDRESS, code); }