UNPKG

@kamino-finance/farms-sdk

Version:
358 lines (351 loc) 25.7 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 { FARMS_PROGRAM_ADDRESS } from "../programs"; /** StakeZero: Cannot stake 0 amount */ export const FARMS_ERROR__STAKE_ZERO = 0x1770; // 6000 /** UnstakeZero: Cannot unstake 0 amount */ export const FARMS_ERROR__UNSTAKE_ZERO = 0x1771; // 6001 /** NothingToUnstake: Nothing to unstake */ export const FARMS_ERROR__NOTHING_TO_UNSTAKE = 0x1772; // 6002 /** NoRewardToHarvest: No reward to harvest */ export const FARMS_ERROR__NO_REWARD_TO_HARVEST = 0x1773; // 6003 /** NoRewardInList: Reward not present in reward list */ export const FARMS_ERROR__NO_REWARD_IN_LIST = 0x1774; // 6004 /** RewardAlreadyInitialized: Reward already initialized */ export const FARMS_ERROR__REWARD_ALREADY_INITIALIZED = 0x1775; // 6005 /** MaxRewardNumberReached: Max number of reward tokens reached */ export const FARMS_ERROR__MAX_REWARD_NUMBER_REACHED = 0x1776; // 6006 /** RewardDoesNotExist: Reward does not exist */ export const FARMS_ERROR__REWARD_DOES_NOT_EXIST = 0x1777; // 6007 /** WrongRewardVaultAccount: Reward vault exists but the account is wrong */ export const FARMS_ERROR__WRONG_REWARD_VAULT_ACCOUNT = 0x1778; // 6008 /** RewardVaultMismatch: Reward vault pubkey does not match staking pool vault */ export const FARMS_ERROR__REWARD_VAULT_MISMATCH = 0x1779; // 6009 /** RewardVaultAuthorityMismatch: Reward vault authority pubkey does not match staking pool vault */ export const FARMS_ERROR__REWARD_VAULT_AUTHORITY_MISMATCH = 0x177a; // 6010 /** NothingStaked: Nothing staked, cannot collect any rewards */ export const FARMS_ERROR__NOTHING_STAKED = 0x177b; // 6011 /** IntegerOverflow: Integer overflow */ export const FARMS_ERROR__INTEGER_OVERFLOW = 0x177c; // 6012 /** ConversionFailure: Conversion failure */ export const FARMS_ERROR__CONVERSION_FAILURE = 0x177d; // 6013 /** UnexpectedAccount: Unexpected account in instruction */ export const FARMS_ERROR__UNEXPECTED_ACCOUNT = 0x177e; // 6014 /** OperationForbidden: Operation forbidden */ export const FARMS_ERROR__OPERATION_FORBIDDEN = 0x177f; // 6015 /** MathOverflow: Mathematical operation with overflow */ export const FARMS_ERROR__MATH_OVERFLOW = 0x1780; // 6016 /** MinClaimDurationNotReached: Minimum claim duration has not been reached */ export const FARMS_ERROR__MIN_CLAIM_DURATION_NOT_REACHED = 0x1781; // 6017 /** RewardsVaultHasDelegate: Reward vault has a delegate */ export const FARMS_ERROR__REWARDS_VAULT_HAS_DELEGATE = 0x1782; // 6018 /** RewardsVaultHasCloseAuthority: Reward vault has a close authority */ export const FARMS_ERROR__REWARDS_VAULT_HAS_CLOSE_AUTHORITY = 0x1783; // 6019 /** FarmVaultHasDelegate: Farm vault has a delegate */ export const FARMS_ERROR__FARM_VAULT_HAS_DELEGATE = 0x1784; // 6020 /** FarmVaultHasCloseAuthority: Farm vault has a close authority */ export const FARMS_ERROR__FARM_VAULT_HAS_CLOSE_AUTHORITY = 0x1785; // 6021 /** RewardsTreasuryVaultHasDelegate: Reward vault has a delegate */ export const FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_DELEGATE = 0x1786; // 6022 /** RewardsTreasuryVaultHasCloseAuthority: Reward vault has a close authority */ export const FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_CLOSE_AUTHORITY = 0x1787; // 6023 /** UserAtaRewardVaultMintMissmatch: User ata and reward vault have different mints */ export const FARMS_ERROR__USER_ATA_REWARD_VAULT_MINT_MISSMATCH = 0x1788; // 6024 /** UserAtaFarmTokenMintMissmatch: User ata and farm token have different mints */ export const FARMS_ERROR__USER_ATA_FARM_TOKEN_MINT_MISSMATCH = 0x1789; // 6025 /** TokenFarmTokenMintMissmatch: Token mint and farm token have different mints */ export const FARMS_ERROR__TOKEN_FARM_TOKEN_MINT_MISSMATCH = 0x178a; // 6026 /** RewardAtaRewardMintMissmatch: Reward ata mint is different than reward mint */ export const FARMS_ERROR__REWARD_ATA_REWARD_MINT_MISSMATCH = 0x178b; // 6027 /** RewardAtaOwnerNotPayer: Reward ata owner is different than payer */ export const FARMS_ERROR__REWARD_ATA_OWNER_NOT_PAYER = 0x178c; // 6028 /** InvalidGlobalConfigMode: Mode to update global_config is invalid */ export const FARMS_ERROR__INVALID_GLOBAL_CONFIG_MODE = 0x178d; // 6029 /** RewardIndexOutOfRange: Reward Index is higher than number of rewards */ export const FARMS_ERROR__REWARD_INDEX_OUT_OF_RANGE = 0x178e; // 6030 /** NothingToWithdraw: No tokens available to withdraw */ export const FARMS_ERROR__NOTHING_TO_WITHDRAW = 0x178f; // 6031 /** UserDelegatedFarmNonDelegatedMissmatch: user, user_ref, authority and payer must match for non-delegated farm */ export const FARMS_ERROR__USER_DELEGATED_FARM_NON_DELEGATED_MISSMATCH = 0x1790; // 6032 /** AuthorityFarmDelegateMissmatch: Authority must match farm delegate authority */ export const FARMS_ERROR__AUTHORITY_FARM_DELEGATE_MISSMATCH = 0x1791; // 6033 /** FarmNotDelegated: Farm not delegated, can not complete operation */ export const FARMS_ERROR__FARM_NOT_DELEGATED = 0x1792; // 6034 /** FarmDelegated: Operation not allowed for delegated farm */ export const FARMS_ERROR__FARM_DELEGATED = 0x1793; // 6035 /** UnstakeNotElapsed: Unstake lockup period is not elapsed. Deposit is locked until end of unstake period */ export const FARMS_ERROR__UNSTAKE_NOT_ELAPSED = 0x1794; // 6036 /** PendingWithdrawalNotWithdrawnYet: Pending withdrawal already exist and not withdrawn yet */ export const FARMS_ERROR__PENDING_WITHDRAWAL_NOT_WITHDRAWN_YET = 0x1795; // 6037 /** DepositZero: Cannot deposit zero amount directly to farm vault */ export const FARMS_ERROR__DEPOSIT_ZERO = 0x1796; // 6038 /** InvalidConfigValue: Invalid config value */ export const FARMS_ERROR__INVALID_CONFIG_VALUE = 0x1797; // 6039 /** InvalidPenaltyPercentage: Invalid penalty percentage */ export const FARMS_ERROR__INVALID_PENALTY_PERCENTAGE = 0x1798; // 6040 /** EarlyWithdrawalNotAllowed: Early withdrawal not allowed */ export const FARMS_ERROR__EARLY_WITHDRAWAL_NOT_ALLOWED = 0x1799; // 6041 /** InvalidLockingTimestamps: Invalid locking timestamps */ export const FARMS_ERROR__INVALID_LOCKING_TIMESTAMPS = 0x179a; // 6042 /** InvalidRpsCurvePoint: Invalid reward rate curve point */ export const FARMS_ERROR__INVALID_RPS_CURVE_POINT = 0x179b; // 6043 /** InvalidTimestamp: Invalid timestamp */ export const FARMS_ERROR__INVALID_TIMESTAMP = 0x179c; // 6044 /** DepositCapReached: Deposit cap reached */ export const FARMS_ERROR__DEPOSIT_CAP_REACHED = 0x179d; // 6045 /** MissingScopePrices: Missing Scope Prices */ export const FARMS_ERROR__MISSING_SCOPE_PRICES = 0x179e; // 6046 /** ScopeOraclePriceTooOld: Scope Oracle Price Too Old */ export const FARMS_ERROR__SCOPE_ORACLE_PRICE_TOO_OLD = 0x179f; // 6047 /** InvalidOracleConfig: Invalid Oracle Config */ export const FARMS_ERROR__INVALID_ORACLE_CONFIG = 0x17a0; // 6048 /** CouldNotDeserializeScope: Could not deserialize scope */ export const FARMS_ERROR__COULD_NOT_DESERIALIZE_SCOPE = 0x17a1; // 6049 /** RewardAtaOwnerNotAdmin: Reward ata owner is different than farm admin */ export const FARMS_ERROR__REWARD_ATA_OWNER_NOT_ADMIN = 0x17a2; // 6050 /** WithdrawRewardZeroAvailable: Cannot withdraw reward as available amount is zero */ export const FARMS_ERROR__WITHDRAW_REWARD_ZERO_AVAILABLE = 0x17a3; // 6051 /** RewardScheduleCurveSet: Cannot withdraw reward as reward schedule is set */ export const FARMS_ERROR__REWARD_SCHEDULE_CURVE_SET = 0x17a4; // 6052 /** UnsupportedTokenExtension: Cannot initialize farm while having a mint with token22 and requested extensions */ export const FARMS_ERROR__UNSUPPORTED_TOKEN_EXTENSION = 0x17a5; // 6053 /** InvalidFarmConfigUpdateAuthority: Invalid authority for updating farm config */ export const FARMS_ERROR__INVALID_FARM_CONFIG_UPDATE_AUTHORITY = 0x17a6; // 6054 /** InvalidTransferOwnershipOldOwner: Invalid authority for transfer ownersip new user state initialization */ export const FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_OLD_OWNER = 0x17a7; // 6055 /** InvalidTransferOwnershipFarmState: Invalid farm state for transfer ownership new user state initialization */ export const FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE = 0x17a8; // 6056 /** InvalidTransferOwnershipUserStateOwnerDelegatee: Invalid user state for transfer ownership, owner must match delegatee */ export const FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_USER_STATE_OWNER_DELEGATEE = 0x17a9; // 6057 /** InvalidTransferOwnershipFarmStateLockingMode: Invalid farm state locking mode for transfer ownership, must be 0 */ export const FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_LOCKING_MODE = 0x17aa; // 6058 /** InvalidTransferOwnershipFarmStateWithdrawCooldownPeriod: Invalid farm state withdrawal cooldown period for transfer ownership, must be 0 */ export const FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_WITHDRAW_COOLDOWN_PERIOD = 0x17ab; // 6059 /** InvalidTransferOwnershipStakeAmount: Invalid transfer ownership stake amount, must be equal to unstaked deposits */ export const FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_STAKE_AMOUNT = 0x17ac; // 6060 /** InvalidTransferOwnershipNewOwner: Invalid authority for transfer ownersip new user state initialization */ export const FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_NEW_OWNER = 0x17ad; // 6061 /** InvalidTransferOwnershipFarmStateDepositWarmupPeriod: Invalid farm state deposit warmup period for transfer ownership, must be 0 if old user has stake */ export const FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_DEPOSIT_WARMUP_PERIOD = 0x17ae; // 6062 /** RewardUserOnceFeatureDisabled: Reward User Once feature is disabled */ export const FARMS_ERROR__REWARD_USER_ONCE_FEATURE_DISABLED = 0x17af; // 6063 /** InvalidDelegatedAuthorityUpdate: Can not set delegate_authority to default pubkey - farm is delegated */ export const FARMS_ERROR__INVALID_DELEGATED_AUTHORITY_UPDATE = 0x17b0; // 6064 /** UserTokenAccountOwnerMismatch: User token account owner does not match user state owner */ export const FARMS_ERROR__USER_TOKEN_ACCOUNT_OWNER_MISMATCH = 0x17b1; // 6065 /** HarvestingNotPermissionlessPayerMismatch: Harvesting is not permissionless, payer does not match user state owner */ export const FARMS_ERROR__HARVESTING_NOT_PERMISSIONLESS_PAYER_MISMATCH = 0x17b2; // 6066 /** RewardsIssuedCumulativeMismatch: Rewards issued cumulative does not match expected value */ export const FARMS_ERROR__REWARDS_ISSUED_CUMULATIVE_MISMATCH = 0x17b3; // 6067 /** CannotCloseUserStateStakeNonZero: Cannot close user state because staked amount is non-zero */ export const FARMS_ERROR__CANNOT_CLOSE_USER_STATE_STAKE_NON_ZERO = 0x17b4; // 6068 /** CannotCloseUserStatePendingUnstakes: Cannot close user state because there are pending unstake requests */ export const FARMS_ERROR__CANNOT_CLOSE_USER_STATE_PENDING_UNSTAKES = 0x17b5; // 6069 /** CannotCloseUserStatePendingDeposits: Cannot close user state because there are pending deposit requests */ export const FARMS_ERROR__CANNOT_CLOSE_USER_STATE_PENDING_DEPOSITS = 0x17b6; // 6070 /** CannotCloseUserStateUnharvestedRewards: Cannot close user state because there are unharvested rewards */ export const FARMS_ERROR__CANNOT_CLOSE_USER_STATE_UNHARVESTED_REWARDS = 0x17b7; // 6071 /** CannotCloseUserStateSignerNotOwner: Cannot close user state because signer is not the owner */ export const FARMS_ERROR__CANNOT_CLOSE_USER_STATE_SIGNER_NOT_OWNER = 0x17b8; // 6072 /** CannotCloseUserStateDelegatedSignerNotDelegateAuthority: Cannot close user state (delegated) because signer is not the delegate authority */ export const FARMS_ERROR__CANNOT_CLOSE_USER_STATE_DELEGATED_SIGNER_NOT_DELEGATE_AUTHORITY = 0x17b9; // 6073 /** CannotCloseUserStateRentReceiverNotOwner: Cannot close user state because rent receiver is not the owner */ export const FARMS_ERROR__CANNOT_CLOSE_USER_STATE_RENT_RECEIVER_NOT_OWNER = 0x17ba; // 6074 /** CannotCloseUserStateDelegatedRentReceiverNotAdmin: Cannot close user state (delegated) because rent receiver is not the admin */ export const FARMS_ERROR__CANNOT_CLOSE_USER_STATE_DELEGATED_RENT_RECEIVER_NOT_ADMIN = 0x17bb; // 6075 /** UserRewardTokenAccountMustBeAta: User reward token account must be an ATA when payer is not the owner */ export const FARMS_ERROR__USER_REWARD_TOKEN_ACCOUNT_MUST_BE_ATA = 0x17bc; // 6076 /** RewardsIssuedCumulativeAtMax: Cannot reward user because rewards_issued_cumulative has reached maximum value */ export const FARMS_ERROR__REWARDS_ISSUED_CUMULATIVE_AT_MAX = 0x17bd; // 6077 /** UserStateIdMismatch: User state user id does not match expected value */ export const FARMS_ERROR__USER_STATE_ID_MISMATCH = 0x17be; // 6078 export type FarmsError = | typeof FARMS_ERROR__AUTHORITY_FARM_DELEGATE_MISSMATCH | typeof FARMS_ERROR__CANNOT_CLOSE_USER_STATE_DELEGATED_RENT_RECEIVER_NOT_ADMIN | typeof FARMS_ERROR__CANNOT_CLOSE_USER_STATE_DELEGATED_SIGNER_NOT_DELEGATE_AUTHORITY | typeof FARMS_ERROR__CANNOT_CLOSE_USER_STATE_PENDING_DEPOSITS | typeof FARMS_ERROR__CANNOT_CLOSE_USER_STATE_PENDING_UNSTAKES | typeof FARMS_ERROR__CANNOT_CLOSE_USER_STATE_RENT_RECEIVER_NOT_OWNER | typeof FARMS_ERROR__CANNOT_CLOSE_USER_STATE_SIGNER_NOT_OWNER | typeof FARMS_ERROR__CANNOT_CLOSE_USER_STATE_STAKE_NON_ZERO | typeof FARMS_ERROR__CANNOT_CLOSE_USER_STATE_UNHARVESTED_REWARDS | typeof FARMS_ERROR__CONVERSION_FAILURE | typeof FARMS_ERROR__COULD_NOT_DESERIALIZE_SCOPE | typeof FARMS_ERROR__DEPOSIT_CAP_REACHED | typeof FARMS_ERROR__DEPOSIT_ZERO | typeof FARMS_ERROR__EARLY_WITHDRAWAL_NOT_ALLOWED | typeof FARMS_ERROR__FARM_DELEGATED | typeof FARMS_ERROR__FARM_NOT_DELEGATED | typeof FARMS_ERROR__FARM_VAULT_HAS_CLOSE_AUTHORITY | typeof FARMS_ERROR__FARM_VAULT_HAS_DELEGATE | typeof FARMS_ERROR__HARVESTING_NOT_PERMISSIONLESS_PAYER_MISMATCH | typeof FARMS_ERROR__INTEGER_OVERFLOW | typeof FARMS_ERROR__INVALID_CONFIG_VALUE | typeof FARMS_ERROR__INVALID_DELEGATED_AUTHORITY_UPDATE | typeof FARMS_ERROR__INVALID_FARM_CONFIG_UPDATE_AUTHORITY | typeof FARMS_ERROR__INVALID_GLOBAL_CONFIG_MODE | typeof FARMS_ERROR__INVALID_LOCKING_TIMESTAMPS | typeof FARMS_ERROR__INVALID_ORACLE_CONFIG | typeof FARMS_ERROR__INVALID_PENALTY_PERCENTAGE | typeof FARMS_ERROR__INVALID_RPS_CURVE_POINT | typeof FARMS_ERROR__INVALID_TIMESTAMP | typeof FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE | typeof FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_DEPOSIT_WARMUP_PERIOD | typeof FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_LOCKING_MODE | typeof FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_WITHDRAW_COOLDOWN_PERIOD | typeof FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_NEW_OWNER | typeof FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_OLD_OWNER | typeof FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_STAKE_AMOUNT | typeof FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_USER_STATE_OWNER_DELEGATEE | typeof FARMS_ERROR__MATH_OVERFLOW | typeof FARMS_ERROR__MAX_REWARD_NUMBER_REACHED | typeof FARMS_ERROR__MIN_CLAIM_DURATION_NOT_REACHED | typeof FARMS_ERROR__MISSING_SCOPE_PRICES | typeof FARMS_ERROR__NO_REWARD_IN_LIST | typeof FARMS_ERROR__NO_REWARD_TO_HARVEST | typeof FARMS_ERROR__NOTHING_STAKED | typeof FARMS_ERROR__NOTHING_TO_UNSTAKE | typeof FARMS_ERROR__NOTHING_TO_WITHDRAW | typeof FARMS_ERROR__OPERATION_FORBIDDEN | typeof FARMS_ERROR__PENDING_WITHDRAWAL_NOT_WITHDRAWN_YET | typeof FARMS_ERROR__REWARD_ALREADY_INITIALIZED | typeof FARMS_ERROR__REWARD_ATA_OWNER_NOT_ADMIN | typeof FARMS_ERROR__REWARD_ATA_OWNER_NOT_PAYER | typeof FARMS_ERROR__REWARD_ATA_REWARD_MINT_MISSMATCH | typeof FARMS_ERROR__REWARD_DOES_NOT_EXIST | typeof FARMS_ERROR__REWARD_INDEX_OUT_OF_RANGE | typeof FARMS_ERROR__REWARD_SCHEDULE_CURVE_SET | typeof FARMS_ERROR__REWARDS_ISSUED_CUMULATIVE_AT_MAX | typeof FARMS_ERROR__REWARDS_ISSUED_CUMULATIVE_MISMATCH | typeof FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_CLOSE_AUTHORITY | typeof FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_DELEGATE | typeof FARMS_ERROR__REWARDS_VAULT_HAS_CLOSE_AUTHORITY | typeof FARMS_ERROR__REWARDS_VAULT_HAS_DELEGATE | typeof FARMS_ERROR__REWARD_USER_ONCE_FEATURE_DISABLED | typeof FARMS_ERROR__REWARD_VAULT_AUTHORITY_MISMATCH | typeof FARMS_ERROR__REWARD_VAULT_MISMATCH | typeof FARMS_ERROR__SCOPE_ORACLE_PRICE_TOO_OLD | typeof FARMS_ERROR__STAKE_ZERO | typeof FARMS_ERROR__TOKEN_FARM_TOKEN_MINT_MISSMATCH | typeof FARMS_ERROR__UNEXPECTED_ACCOUNT | typeof FARMS_ERROR__UNSTAKE_NOT_ELAPSED | typeof FARMS_ERROR__UNSTAKE_ZERO | typeof FARMS_ERROR__UNSUPPORTED_TOKEN_EXTENSION | typeof FARMS_ERROR__USER_ATA_FARM_TOKEN_MINT_MISSMATCH | typeof FARMS_ERROR__USER_ATA_REWARD_VAULT_MINT_MISSMATCH | typeof FARMS_ERROR__USER_DELEGATED_FARM_NON_DELEGATED_MISSMATCH | typeof FARMS_ERROR__USER_REWARD_TOKEN_ACCOUNT_MUST_BE_ATA | typeof FARMS_ERROR__USER_STATE_ID_MISMATCH | typeof FARMS_ERROR__USER_TOKEN_ACCOUNT_OWNER_MISMATCH | typeof FARMS_ERROR__WITHDRAW_REWARD_ZERO_AVAILABLE | typeof FARMS_ERROR__WRONG_REWARD_VAULT_ACCOUNT; const farmsErrorMessages: Record<FarmsError, string> = { [FARMS_ERROR__AUTHORITY_FARM_DELEGATE_MISSMATCH]: `Authority must match farm delegate authority`, [FARMS_ERROR__CANNOT_CLOSE_USER_STATE_DELEGATED_RENT_RECEIVER_NOT_ADMIN]: `Cannot close user state (delegated) because rent receiver is not the admin`, [FARMS_ERROR__CANNOT_CLOSE_USER_STATE_DELEGATED_SIGNER_NOT_DELEGATE_AUTHORITY]: `Cannot close user state (delegated) because signer is not the delegate authority`, [FARMS_ERROR__CANNOT_CLOSE_USER_STATE_PENDING_DEPOSITS]: `Cannot close user state because there are pending deposit requests`, [FARMS_ERROR__CANNOT_CLOSE_USER_STATE_PENDING_UNSTAKES]: `Cannot close user state because there are pending unstake requests`, [FARMS_ERROR__CANNOT_CLOSE_USER_STATE_RENT_RECEIVER_NOT_OWNER]: `Cannot close user state because rent receiver is not the owner`, [FARMS_ERROR__CANNOT_CLOSE_USER_STATE_SIGNER_NOT_OWNER]: `Cannot close user state because signer is not the owner`, [FARMS_ERROR__CANNOT_CLOSE_USER_STATE_STAKE_NON_ZERO]: `Cannot close user state because staked amount is non-zero`, [FARMS_ERROR__CANNOT_CLOSE_USER_STATE_UNHARVESTED_REWARDS]: `Cannot close user state because there are unharvested rewards`, [FARMS_ERROR__CONVERSION_FAILURE]: `Conversion failure`, [FARMS_ERROR__COULD_NOT_DESERIALIZE_SCOPE]: `Could not deserialize scope`, [FARMS_ERROR__DEPOSIT_CAP_REACHED]: `Deposit cap reached`, [FARMS_ERROR__DEPOSIT_ZERO]: `Cannot deposit zero amount directly to farm vault`, [FARMS_ERROR__EARLY_WITHDRAWAL_NOT_ALLOWED]: `Early withdrawal not allowed`, [FARMS_ERROR__FARM_DELEGATED]: `Operation not allowed for delegated farm`, [FARMS_ERROR__FARM_NOT_DELEGATED]: `Farm not delegated, can not complete operation`, [FARMS_ERROR__FARM_VAULT_HAS_CLOSE_AUTHORITY]: `Farm vault has a close authority`, [FARMS_ERROR__FARM_VAULT_HAS_DELEGATE]: `Farm vault has a delegate`, [FARMS_ERROR__HARVESTING_NOT_PERMISSIONLESS_PAYER_MISMATCH]: `Harvesting is not permissionless, payer does not match user state owner`, [FARMS_ERROR__INTEGER_OVERFLOW]: `Integer overflow`, [FARMS_ERROR__INVALID_CONFIG_VALUE]: `Invalid config value`, [FARMS_ERROR__INVALID_DELEGATED_AUTHORITY_UPDATE]: `Can not set delegate_authority to default pubkey - farm is delegated`, [FARMS_ERROR__INVALID_FARM_CONFIG_UPDATE_AUTHORITY]: `Invalid authority for updating farm config`, [FARMS_ERROR__INVALID_GLOBAL_CONFIG_MODE]: `Mode to update global_config is invalid`, [FARMS_ERROR__INVALID_LOCKING_TIMESTAMPS]: `Invalid locking timestamps`, [FARMS_ERROR__INVALID_ORACLE_CONFIG]: `Invalid Oracle Config`, [FARMS_ERROR__INVALID_PENALTY_PERCENTAGE]: `Invalid penalty percentage`, [FARMS_ERROR__INVALID_RPS_CURVE_POINT]: `Invalid reward rate curve point`, [FARMS_ERROR__INVALID_TIMESTAMP]: `Invalid timestamp`, [FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE]: `Invalid farm state for transfer ownership new user state initialization`, [FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_DEPOSIT_WARMUP_PERIOD]: `Invalid farm state deposit warmup period for transfer ownership, must be 0 if old user has stake`, [FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_LOCKING_MODE]: `Invalid farm state locking mode for transfer ownership, must be 0`, [FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_FARM_STATE_WITHDRAW_COOLDOWN_PERIOD]: `Invalid farm state withdrawal cooldown period for transfer ownership, must be 0`, [FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_NEW_OWNER]: `Invalid authority for transfer ownersip new user state initialization`, [FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_OLD_OWNER]: `Invalid authority for transfer ownersip new user state initialization`, [FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_STAKE_AMOUNT]: `Invalid transfer ownership stake amount, must be equal to unstaked deposits`, [FARMS_ERROR__INVALID_TRANSFER_OWNERSHIP_USER_STATE_OWNER_DELEGATEE]: `Invalid user state for transfer ownership, owner must match delegatee`, [FARMS_ERROR__MATH_OVERFLOW]: `Mathematical operation with overflow`, [FARMS_ERROR__MAX_REWARD_NUMBER_REACHED]: `Max number of reward tokens reached`, [FARMS_ERROR__MIN_CLAIM_DURATION_NOT_REACHED]: `Minimum claim duration has not been reached`, [FARMS_ERROR__MISSING_SCOPE_PRICES]: `Missing Scope Prices`, [FARMS_ERROR__NO_REWARD_IN_LIST]: `Reward not present in reward list`, [FARMS_ERROR__NO_REWARD_TO_HARVEST]: `No reward to harvest`, [FARMS_ERROR__NOTHING_STAKED]: `Nothing staked, cannot collect any rewards`, [FARMS_ERROR__NOTHING_TO_UNSTAKE]: `Nothing to unstake`, [FARMS_ERROR__NOTHING_TO_WITHDRAW]: `No tokens available to withdraw`, [FARMS_ERROR__OPERATION_FORBIDDEN]: `Operation forbidden`, [FARMS_ERROR__PENDING_WITHDRAWAL_NOT_WITHDRAWN_YET]: `Pending withdrawal already exist and not withdrawn yet`, [FARMS_ERROR__REWARD_ALREADY_INITIALIZED]: `Reward already initialized`, [FARMS_ERROR__REWARD_ATA_OWNER_NOT_ADMIN]: `Reward ata owner is different than farm admin`, [FARMS_ERROR__REWARD_ATA_OWNER_NOT_PAYER]: `Reward ata owner is different than payer`, [FARMS_ERROR__REWARD_ATA_REWARD_MINT_MISSMATCH]: `Reward ata mint is different than reward mint`, [FARMS_ERROR__REWARD_DOES_NOT_EXIST]: `Reward does not exist`, [FARMS_ERROR__REWARD_INDEX_OUT_OF_RANGE]: `Reward Index is higher than number of rewards`, [FARMS_ERROR__REWARD_SCHEDULE_CURVE_SET]: `Cannot withdraw reward as reward schedule is set`, [FARMS_ERROR__REWARDS_ISSUED_CUMULATIVE_AT_MAX]: `Cannot reward user because rewards_issued_cumulative has reached maximum value`, [FARMS_ERROR__REWARDS_ISSUED_CUMULATIVE_MISMATCH]: `Rewards issued cumulative does not match expected value`, [FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_CLOSE_AUTHORITY]: `Reward vault has a close authority`, [FARMS_ERROR__REWARDS_TREASURY_VAULT_HAS_DELEGATE]: `Reward vault has a delegate`, [FARMS_ERROR__REWARDS_VAULT_HAS_CLOSE_AUTHORITY]: `Reward vault has a close authority`, [FARMS_ERROR__REWARDS_VAULT_HAS_DELEGATE]: `Reward vault has a delegate`, [FARMS_ERROR__REWARD_USER_ONCE_FEATURE_DISABLED]: `Reward User Once feature is disabled`, [FARMS_ERROR__REWARD_VAULT_AUTHORITY_MISMATCH]: `Reward vault authority pubkey does not match staking pool vault`, [FARMS_ERROR__REWARD_VAULT_MISMATCH]: `Reward vault pubkey does not match staking pool vault`, [FARMS_ERROR__SCOPE_ORACLE_PRICE_TOO_OLD]: `Scope Oracle Price Too Old`, [FARMS_ERROR__STAKE_ZERO]: `Cannot stake 0 amount`, [FARMS_ERROR__TOKEN_FARM_TOKEN_MINT_MISSMATCH]: `Token mint and farm token have different mints`, [FARMS_ERROR__UNEXPECTED_ACCOUNT]: `Unexpected account in instruction`, [FARMS_ERROR__UNSTAKE_NOT_ELAPSED]: `Unstake lockup period is not elapsed. Deposit is locked until end of unstake period`, [FARMS_ERROR__UNSTAKE_ZERO]: `Cannot unstake 0 amount`, [FARMS_ERROR__UNSUPPORTED_TOKEN_EXTENSION]: `Cannot initialize farm while having a mint with token22 and requested extensions`, [FARMS_ERROR__USER_ATA_FARM_TOKEN_MINT_MISSMATCH]: `User ata and farm token have different mints`, [FARMS_ERROR__USER_ATA_REWARD_VAULT_MINT_MISSMATCH]: `User ata and reward vault have different mints`, [FARMS_ERROR__USER_DELEGATED_FARM_NON_DELEGATED_MISSMATCH]: `user, user_ref, authority and payer must match for non-delegated farm`, [FARMS_ERROR__USER_REWARD_TOKEN_ACCOUNT_MUST_BE_ATA]: `User reward token account must be an ATA when payer is not the owner`, [FARMS_ERROR__USER_STATE_ID_MISMATCH]: `User state user id does not match expected value`, [FARMS_ERROR__USER_TOKEN_ACCOUNT_OWNER_MISMATCH]: `User token account owner does not match user state owner`, [FARMS_ERROR__WITHDRAW_REWARD_ZERO_AVAILABLE]: `Cannot withdraw reward as available amount is zero`, [FARMS_ERROR__WRONG_REWARD_VAULT_ACCOUNT]: `Reward vault exists but the account is wrong`, }; export function getFarmsErrorMessage(code: FarmsError): string { return farmsErrorMessages[code]; } export function isFarmsError<TProgramErrorCode extends FarmsError>( 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, FARMS_PROGRAM_ADDRESS, code, ); }