UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

137 lines 16 kB
"use strict"; /** * 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 */ Object.defineProperty(exports, "__esModule", { value: true }); exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT = exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE = exports.WHIRLPOOL_ERROR__UNSUPPORTED_TOKEN_MINT = exports.WHIRLPOOL_ERROR__POSITION_BUNDLE_NOT_DELETABLE = exports.WHIRLPOOL_ERROR__BUNDLED_POSITION_ALREADY_CLOSED = exports.WHIRLPOOL_ERROR__BUNDLED_POSITION_ALREADY_OPENED = exports.WHIRLPOOL_ERROR__INVALID_BUNDLE_INDEX = exports.WHIRLPOOL_ERROR__DUPLICATE_TWO_HOP_POOL = exports.WHIRLPOOL_ERROR__INVALID_INTERMEDIARY_MINT = exports.WHIRLPOOL_ERROR__AMOUNT_REMAINING_OVERFLOW = exports.WHIRLPOOL_ERROR__AMOUNT_CALC_OVERFLOW = exports.WHIRLPOOL_ERROR__TICK_ARRAY_SEQUENCE_INVALID_INDEX = exports.WHIRLPOOL_ERROR__AMOUNT_IN_ABOVE_MAXIMUM = exports.WHIRLPOOL_ERROR__AMOUNT_OUT_BELOW_MINIMUM = exports.WHIRLPOOL_ERROR__ZERO_TRADABLE_AMOUNT = exports.WHIRLPOOL_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION = exports.WHIRLPOOL_ERROR__MULTIPLICATION_OVERFLOW = exports.WHIRLPOOL_ERROR__MUL_DIV_INVALID_INPUT = exports.WHIRLPOOL_ERROR__MUL_DIV_OVERFLOW = exports.WHIRLPOOL_ERROR__MULTIPLICATION_SHIFT_RIGHT_OVERFLOW = exports.WHIRLPOOL_ERROR__PROTOCOL_FEE_RATE_MAX_EXCEEDED = exports.WHIRLPOOL_ERROR__FEE_RATE_MAX_EXCEEDED = exports.WHIRLPOOL_ERROR__REWARD_VAULT_AMOUNT_INSUFFICIENT = exports.WHIRLPOOL_ERROR__INVALID_REWARD_INDEX = exports.WHIRLPOOL_ERROR__REWARD_NOT_INITIALIZED = exports.WHIRLPOOL_ERROR__INVALID_TOKEN_MINT_ORDER = exports.WHIRLPOOL_ERROR__INVALID_TICK_ARRAY_SEQUENCE = exports.WHIRLPOOL_ERROR__INVALID_TIMESTAMP = exports.WHIRLPOOL_ERROR__INVALID_TIMESTAMP_CONVERSION = exports.WHIRLPOOL_ERROR__INVALID_POSITION_TOKEN_AMOUNT = exports.WHIRLPOOL_ERROR__MISSING_OR_INVALID_DELEGATE = exports.WHIRLPOOL_ERROR__TOKEN_MIN_SUBCEEDED = exports.WHIRLPOOL_ERROR__TOKEN_MAX_EXCEEDED = exports.WHIRLPOOL_ERROR__LIQUIDITY_NET_ERROR = exports.WHIRLPOOL_ERROR__LIQUIDITY_UNDERFLOW = exports.WHIRLPOOL_ERROR__LIQUIDITY_OVERFLOW = exports.WHIRLPOOL_ERROR__LIQUIDITY_TOO_HIGH = exports.WHIRLPOOL_ERROR__LIQUIDITY_ZERO = exports.WHIRLPOOL_ERROR__SQRT_PRICE_OUT_OF_BOUNDS = exports.WHIRLPOOL_ERROR__INVALID_TICK_INDEX = exports.WHIRLPOOL_ERROR__TICK_NOT_FOUND = exports.WHIRLPOOL_ERROR__NUMBER_DOWN_CAST_ERROR = exports.WHIRLPOOL_ERROR__NUMBER_CAST_ERROR = exports.WHIRLPOOL_ERROR__DIVIDE_BY_ZERO = exports.WHIRLPOOL_ERROR__CLOSE_POSITION_NOT_EMPTY = exports.WHIRLPOOL_ERROR__INVALID_TICK_SPACING = exports.WHIRLPOOL_ERROR__TICK_ARRAY_INDEX_OUTOF_BOUNDS = exports.WHIRLPOOL_ERROR__TICK_ARRAY_EXIST_IN_POOL = exports.WHIRLPOOL_ERROR__INVALID_START_TICK = exports.WHIRLPOOL_ERROR__INVALID_ENUM = void 0; exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE = exports.WHIRLPOOL_ERROR__TRANSFER_FEE_CALCULATION_ERROR = exports.WHIRLPOOL_ERROR__INTERMEDIATE_TOKEN_AMOUNT_MISMATCH = exports.WHIRLPOOL_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK = void 0; exports.getWhirlpoolErrorMessage = getWhirlpoolErrorMessage; exports.isWhirlpoolError = isWhirlpoolError; const kit_1 = require("@solana/kit"); const programs_1 = require("../programs"); /** InvalidEnum: Enum value could not be converted */ exports.WHIRLPOOL_ERROR__INVALID_ENUM = 0x1770; // 6000 /** InvalidStartTick: Invalid start tick index provided. */ exports.WHIRLPOOL_ERROR__INVALID_START_TICK = 0x1771; // 6001 /** TickArrayExistInPool: Tick-array already exists in this whirlpool */ exports.WHIRLPOOL_ERROR__TICK_ARRAY_EXIST_IN_POOL = 0x1772; // 6002 /** TickArrayIndexOutofBounds: Attempt to search for a tick-array failed */ exports.WHIRLPOOL_ERROR__TICK_ARRAY_INDEX_OUTOF_BOUNDS = 0x1773; // 6003 /** InvalidTickSpacing: Tick-spacing is not supported */ exports.WHIRLPOOL_ERROR__INVALID_TICK_SPACING = 0x1774; // 6004 /** ClosePositionNotEmpty: Position is not empty It cannot be closed */ exports.WHIRLPOOL_ERROR__CLOSE_POSITION_NOT_EMPTY = 0x1775; // 6005 /** DivideByZero: Unable to divide by zero */ exports.WHIRLPOOL_ERROR__DIVIDE_BY_ZERO = 0x1776; // 6006 /** NumberCastError: Unable to cast number into BigInt */ exports.WHIRLPOOL_ERROR__NUMBER_CAST_ERROR = 0x1777; // 6007 /** NumberDownCastError: Unable to down cast number */ exports.WHIRLPOOL_ERROR__NUMBER_DOWN_CAST_ERROR = 0x1778; // 6008 /** TickNotFound: Tick not found within tick array */ exports.WHIRLPOOL_ERROR__TICK_NOT_FOUND = 0x1779; // 6009 /** InvalidTickIndex: Provided tick index is either out of bounds or uninitializable */ exports.WHIRLPOOL_ERROR__INVALID_TICK_INDEX = 0x177a; // 6010 /** SqrtPriceOutOfBounds: Provided sqrt price out of bounds */ exports.WHIRLPOOL_ERROR__SQRT_PRICE_OUT_OF_BOUNDS = 0x177b; // 6011 /** LiquidityZero: Liquidity amount must be greater than zero */ exports.WHIRLPOOL_ERROR__LIQUIDITY_ZERO = 0x177c; // 6012 /** LiquidityTooHigh: Liquidity amount must be less than i64::MAX */ exports.WHIRLPOOL_ERROR__LIQUIDITY_TOO_HIGH = 0x177d; // 6013 /** LiquidityOverflow: Liquidity overflow */ exports.WHIRLPOOL_ERROR__LIQUIDITY_OVERFLOW = 0x177e; // 6014 /** LiquidityUnderflow: Liquidity underflow */ exports.WHIRLPOOL_ERROR__LIQUIDITY_UNDERFLOW = 0x177f; // 6015 /** LiquidityNetError: Tick liquidity net underflowed or overflowed */ exports.WHIRLPOOL_ERROR__LIQUIDITY_NET_ERROR = 0x1780; // 6016 /** TokenMaxExceeded: Exceeded token max */ exports.WHIRLPOOL_ERROR__TOKEN_MAX_EXCEEDED = 0x1781; // 6017 /** TokenMinSubceeded: Did not meet token min */ exports.WHIRLPOOL_ERROR__TOKEN_MIN_SUBCEEDED = 0x1782; // 6018 /** MissingOrInvalidDelegate: Position token account has a missing or invalid delegate */ exports.WHIRLPOOL_ERROR__MISSING_OR_INVALID_DELEGATE = 0x1783; // 6019 /** InvalidPositionTokenAmount: Position token amount must be 1 */ exports.WHIRLPOOL_ERROR__INVALID_POSITION_TOKEN_AMOUNT = 0x1784; // 6020 /** InvalidTimestampConversion: Timestamp should be convertible from i64 to u64 */ exports.WHIRLPOOL_ERROR__INVALID_TIMESTAMP_CONVERSION = 0x1785; // 6021 /** InvalidTimestamp: Timestamp should be greater than the last updated timestamp */ exports.WHIRLPOOL_ERROR__INVALID_TIMESTAMP = 0x1786; // 6022 /** InvalidTickArraySequence: Invalid tick array sequence provided for instruction. */ exports.WHIRLPOOL_ERROR__INVALID_TICK_ARRAY_SEQUENCE = 0x1787; // 6023 /** InvalidTokenMintOrder: Token Mint in wrong order */ exports.WHIRLPOOL_ERROR__INVALID_TOKEN_MINT_ORDER = 0x1788; // 6024 /** RewardNotInitialized: Reward not initialized */ exports.WHIRLPOOL_ERROR__REWARD_NOT_INITIALIZED = 0x1789; // 6025 /** InvalidRewardIndex: Invalid reward index */ exports.WHIRLPOOL_ERROR__INVALID_REWARD_INDEX = 0x178a; // 6026 /** RewardVaultAmountInsufficient: Reward vault requires amount to support emissions for at least one day */ exports.WHIRLPOOL_ERROR__REWARD_VAULT_AMOUNT_INSUFFICIENT = 0x178b; // 6027 /** FeeRateMaxExceeded: Exceeded max fee rate */ exports.WHIRLPOOL_ERROR__FEE_RATE_MAX_EXCEEDED = 0x178c; // 6028 /** ProtocolFeeRateMaxExceeded: Exceeded max protocol fee rate */ exports.WHIRLPOOL_ERROR__PROTOCOL_FEE_RATE_MAX_EXCEEDED = 0x178d; // 6029 /** MultiplicationShiftRightOverflow: Multiplication with shift right overflow */ exports.WHIRLPOOL_ERROR__MULTIPLICATION_SHIFT_RIGHT_OVERFLOW = 0x178e; // 6030 /** MulDivOverflow: Muldiv overflow */ exports.WHIRLPOOL_ERROR__MUL_DIV_OVERFLOW = 0x178f; // 6031 /** MulDivInvalidInput: Invalid div_u256 input */ exports.WHIRLPOOL_ERROR__MUL_DIV_INVALID_INPUT = 0x1790; // 6032 /** MultiplicationOverflow: Multiplication overflow */ exports.WHIRLPOOL_ERROR__MULTIPLICATION_OVERFLOW = 0x1791; // 6033 /** InvalidSqrtPriceLimitDirection: Provided SqrtPriceLimit not in the same direction as the swap. */ exports.WHIRLPOOL_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION = 0x1792; // 6034 /** ZeroTradableAmount: There are no tradable amount to swap. */ exports.WHIRLPOOL_ERROR__ZERO_TRADABLE_AMOUNT = 0x1793; // 6035 /** AmountOutBelowMinimum: Amount out below minimum threshold */ exports.WHIRLPOOL_ERROR__AMOUNT_OUT_BELOW_MINIMUM = 0x1794; // 6036 /** AmountInAboveMaximum: Amount in above maximum threshold */ exports.WHIRLPOOL_ERROR__AMOUNT_IN_ABOVE_MAXIMUM = 0x1795; // 6037 /** TickArraySequenceInvalidIndex: Invalid index for tick array sequence */ exports.WHIRLPOOL_ERROR__TICK_ARRAY_SEQUENCE_INVALID_INDEX = 0x1796; // 6038 /** AmountCalcOverflow: Amount calculated overflows */ exports.WHIRLPOOL_ERROR__AMOUNT_CALC_OVERFLOW = 0x1797; // 6039 /** AmountRemainingOverflow: Amount remaining overflows */ exports.WHIRLPOOL_ERROR__AMOUNT_REMAINING_OVERFLOW = 0x1798; // 6040 /** InvalidIntermediaryMint: Invalid intermediary mint */ exports.WHIRLPOOL_ERROR__INVALID_INTERMEDIARY_MINT = 0x1799; // 6041 /** DuplicateTwoHopPool: Duplicate two hop pool */ exports.WHIRLPOOL_ERROR__DUPLICATE_TWO_HOP_POOL = 0x179a; // 6042 /** InvalidBundleIndex: Bundle index is out of bounds */ exports.WHIRLPOOL_ERROR__INVALID_BUNDLE_INDEX = 0x179b; // 6043 /** BundledPositionAlreadyOpened: Position has already been opened */ exports.WHIRLPOOL_ERROR__BUNDLED_POSITION_ALREADY_OPENED = 0x179c; // 6044 /** BundledPositionAlreadyClosed: Position has already been closed */ exports.WHIRLPOOL_ERROR__BUNDLED_POSITION_ALREADY_CLOSED = 0x179d; // 6045 /** PositionBundleNotDeletable: Unable to delete PositionBundle with open positions */ exports.WHIRLPOOL_ERROR__POSITION_BUNDLE_NOT_DELETABLE = 0x179e; // 6046 /** UnsupportedTokenMint: Token mint has unsupported attributes */ exports.WHIRLPOOL_ERROR__UNSUPPORTED_TOKEN_MINT = 0x179f; // 6047 /** RemainingAccountsInvalidSlice: Invalid remaining accounts */ exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE = 0x17a0; // 6048 /** RemainingAccountsInsufficient: Insufficient remaining accounts */ exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT = 0x17a1; // 6049 /** NoExtraAccountsForTransferHook: Unable to call transfer hook without extra accounts */ exports.WHIRLPOOL_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK = 0x17a2; // 6050 /** IntermediateTokenAmountMismatch: Output and input amount mismatch */ exports.WHIRLPOOL_ERROR__INTERMEDIATE_TOKEN_AMOUNT_MISMATCH = 0x17a3; // 6051 /** TransferFeeCalculationError: Transfer fee calculation failed */ exports.WHIRLPOOL_ERROR__TRANSFER_FEE_CALCULATION_ERROR = 0x17a4; // 6052 /** RemainingAccountsDuplicatedAccountsType: Same accounts type is provided more than once */ exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE = 0x17a5; // 6053 let whirlpoolErrorMessages; if (process.env.NODE_ENV !== 'production') { whirlpoolErrorMessages = { [exports.WHIRLPOOL_ERROR__AMOUNT_CALC_OVERFLOW]: `Amount calculated overflows`, [exports.WHIRLPOOL_ERROR__AMOUNT_IN_ABOVE_MAXIMUM]: `Amount in above maximum threshold`, [exports.WHIRLPOOL_ERROR__AMOUNT_OUT_BELOW_MINIMUM]: `Amount out below minimum threshold`, [exports.WHIRLPOOL_ERROR__AMOUNT_REMAINING_OVERFLOW]: `Amount remaining overflows`, [exports.WHIRLPOOL_ERROR__BUNDLED_POSITION_ALREADY_CLOSED]: `Position has already been closed`, [exports.WHIRLPOOL_ERROR__BUNDLED_POSITION_ALREADY_OPENED]: `Position has already been opened`, [exports.WHIRLPOOL_ERROR__CLOSE_POSITION_NOT_EMPTY]: `Position is not empty It cannot be closed`, [exports.WHIRLPOOL_ERROR__DIVIDE_BY_ZERO]: `Unable to divide by zero`, [exports.WHIRLPOOL_ERROR__DUPLICATE_TWO_HOP_POOL]: `Duplicate two hop pool`, [exports.WHIRLPOOL_ERROR__FEE_RATE_MAX_EXCEEDED]: `Exceeded max fee rate`, [exports.WHIRLPOOL_ERROR__INTERMEDIATE_TOKEN_AMOUNT_MISMATCH]: `Output and input amount mismatch`, [exports.WHIRLPOOL_ERROR__INVALID_BUNDLE_INDEX]: `Bundle index is out of bounds`, [exports.WHIRLPOOL_ERROR__INVALID_ENUM]: `Enum value could not be converted`, [exports.WHIRLPOOL_ERROR__INVALID_INTERMEDIARY_MINT]: `Invalid intermediary mint`, [exports.WHIRLPOOL_ERROR__INVALID_POSITION_TOKEN_AMOUNT]: `Position token amount must be 1`, [exports.WHIRLPOOL_ERROR__INVALID_REWARD_INDEX]: `Invalid reward index`, [exports.WHIRLPOOL_ERROR__INVALID_SQRT_PRICE_LIMIT_DIRECTION]: `Provided SqrtPriceLimit not in the same direction as the swap.`, [exports.WHIRLPOOL_ERROR__INVALID_START_TICK]: `Invalid start tick index provided.`, [exports.WHIRLPOOL_ERROR__INVALID_TICK_ARRAY_SEQUENCE]: `Invalid tick array sequence provided for instruction.`, [exports.WHIRLPOOL_ERROR__INVALID_TICK_INDEX]: `Provided tick index is either out of bounds or uninitializable`, [exports.WHIRLPOOL_ERROR__INVALID_TICK_SPACING]: `Tick-spacing is not supported`, [exports.WHIRLPOOL_ERROR__INVALID_TIMESTAMP]: `Timestamp should be greater than the last updated timestamp`, [exports.WHIRLPOOL_ERROR__INVALID_TIMESTAMP_CONVERSION]: `Timestamp should be convertible from i64 to u64`, [exports.WHIRLPOOL_ERROR__INVALID_TOKEN_MINT_ORDER]: `Token Mint in wrong order`, [exports.WHIRLPOOL_ERROR__LIQUIDITY_NET_ERROR]: `Tick liquidity net underflowed or overflowed`, [exports.WHIRLPOOL_ERROR__LIQUIDITY_OVERFLOW]: `Liquidity overflow`, [exports.WHIRLPOOL_ERROR__LIQUIDITY_TOO_HIGH]: `Liquidity amount must be less than i64::MAX`, [exports.WHIRLPOOL_ERROR__LIQUIDITY_UNDERFLOW]: `Liquidity underflow`, [exports.WHIRLPOOL_ERROR__LIQUIDITY_ZERO]: `Liquidity amount must be greater than zero`, [exports.WHIRLPOOL_ERROR__MISSING_OR_INVALID_DELEGATE]: `Position token account has a missing or invalid delegate`, [exports.WHIRLPOOL_ERROR__MUL_DIV_INVALID_INPUT]: `Invalid div_u256 input`, [exports.WHIRLPOOL_ERROR__MUL_DIV_OVERFLOW]: `Muldiv overflow`, [exports.WHIRLPOOL_ERROR__MULTIPLICATION_OVERFLOW]: `Multiplication overflow`, [exports.WHIRLPOOL_ERROR__MULTIPLICATION_SHIFT_RIGHT_OVERFLOW]: `Multiplication with shift right overflow`, [exports.WHIRLPOOL_ERROR__NO_EXTRA_ACCOUNTS_FOR_TRANSFER_HOOK]: `Unable to call transfer hook without extra accounts`, [exports.WHIRLPOOL_ERROR__NUMBER_CAST_ERROR]: `Unable to cast number into BigInt`, [exports.WHIRLPOOL_ERROR__NUMBER_DOWN_CAST_ERROR]: `Unable to down cast number`, [exports.WHIRLPOOL_ERROR__POSITION_BUNDLE_NOT_DELETABLE]: `Unable to delete PositionBundle with open positions`, [exports.WHIRLPOOL_ERROR__PROTOCOL_FEE_RATE_MAX_EXCEEDED]: `Exceeded max protocol fee rate`, [exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_DUPLICATED_ACCOUNTS_TYPE]: `Same accounts type is provided more than once`, [exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_INSUFFICIENT]: `Insufficient remaining accounts`, [exports.WHIRLPOOL_ERROR__REMAINING_ACCOUNTS_INVALID_SLICE]: `Invalid remaining accounts`, [exports.WHIRLPOOL_ERROR__REWARD_NOT_INITIALIZED]: `Reward not initialized`, [exports.WHIRLPOOL_ERROR__REWARD_VAULT_AMOUNT_INSUFFICIENT]: `Reward vault requires amount to support emissions for at least one day`, [exports.WHIRLPOOL_ERROR__SQRT_PRICE_OUT_OF_BOUNDS]: `Provided sqrt price out of bounds`, [exports.WHIRLPOOL_ERROR__TICK_ARRAY_EXIST_IN_POOL]: `Tick-array already exists in this whirlpool`, [exports.WHIRLPOOL_ERROR__TICK_ARRAY_INDEX_OUTOF_BOUNDS]: `Attempt to search for a tick-array failed`, [exports.WHIRLPOOL_ERROR__TICK_ARRAY_SEQUENCE_INVALID_INDEX]: `Invalid index for tick array sequence`, [exports.WHIRLPOOL_ERROR__TICK_NOT_FOUND]: `Tick not found within tick array`, [exports.WHIRLPOOL_ERROR__TOKEN_MAX_EXCEEDED]: `Exceeded token max`, [exports.WHIRLPOOL_ERROR__TOKEN_MIN_SUBCEEDED]: `Did not meet token min`, [exports.WHIRLPOOL_ERROR__TRANSFER_FEE_CALCULATION_ERROR]: `Transfer fee calculation failed`, [exports.WHIRLPOOL_ERROR__UNSUPPORTED_TOKEN_MINT]: `Token mint has unsupported attributes`, [exports.WHIRLPOOL_ERROR__ZERO_TRADABLE_AMOUNT]: `There are no tradable amount to swap.` }; } function getWhirlpoolErrorMessage(code) { if (process.env.NODE_ENV !== 'production') { return whirlpoolErrorMessages[code]; } return 'Error message not available in production bundles.'; } function isWhirlpoolError(error, transactionMessage, code) { return (0, kit_1.isProgramError)(error, transactionMessage, programs_1.WHIRLPOOL_PROGRAM_ADDRESS, code); } //# sourceMappingURL=whirlpool.js.map