/** * 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 { VOLTR_VAULT_PROGRAM_ADDRESS } from "../programs"; /** InvalidAmount: Invalid amount provided. */ export const VOLTR_VAULT_ERROR__INVALID_AMOUNT = 0x1770; // 6000 /** InvalidTokenMint: Invalid token mint. */ export const VOLTR_VAULT_ERROR__INVALID_TOKEN_MINT = 0x1771; // 6001 /** InvalidTokenAccount: Invalid token account. */ export const VOLTR_VAULT_ERROR__INVALID_TOKEN_ACCOUNT = 0x1772; // 6002 /** InvalidAccountInput: Invalid account input. */ export const VOLTR_VAULT_ERROR__INVALID_ACCOUNT_INPUT = 0x1773; // 6003 /** MathOverflow: Math overflow. */ export const VOLTR_VAULT_ERROR__MATH_OVERFLOW = 0x1774; // 6004 /** FeeExceedsTotalAssetValue: Fee exceeds total asset value. */ export const VOLTR_VAULT_ERROR__FEE_EXCEEDS_TOTAL_ASSET_VALUE = 0x1775; // 6005 /** MaxCapExceeded: Max cap exceeded. */ export const VOLTR_VAULT_ERROR__MAX_CAP_EXCEEDED = 0x1776; // 6006 /** VaultNotActive: Vault not active. */ export const VOLTR_VAULT_ERROR__VAULT_NOT_ACTIVE = 0x1777; // 6007 /** ManagerNotAllowed: Manager not allowed in remaining. */ export const VOLTR_VAULT_ERROR__MANAGER_NOT_ALLOWED = 0x1778; // 6008 /** OperationNotAllowed: Operation not allowed. */ export const VOLTR_VAULT_ERROR__OPERATION_NOT_ALLOWED = 0x1779; // 6009 /** AdaptorEpochInvalid: Adaptor epoch invalid. */ export const VOLTR_VAULT_ERROR__ADAPTOR_EPOCH_INVALID = 0x177a; // 6010 /** InvalidFeeConfiguration: Fee configuration invalid. */ export const VOLTR_VAULT_ERROR__INVALID_FEE_CONFIGURATION = 0x177b; // 6011 /** WithdrawalNotYetAvailable: Withdrawal not yet available. */ export const VOLTR_VAULT_ERROR__WITHDRAWAL_NOT_YET_AVAILABLE = 0x177c; // 6012 /** InvalidInput: Invalid input. */ export const VOLTR_VAULT_ERROR__INVALID_INPUT = 0x177d; // 6013 /** DivisionByZero: Division by zero. */ export const VOLTR_VAULT_ERROR__DIVISION_BY_ZERO = 0x177e; // 6014 /** InstantWithdrawNotAllowed: Instant withdraw not allowed. */ export const VOLTR_VAULT_ERROR__INSTANT_WITHDRAW_NOT_ALLOWED = 0x177f; // 6015 /** AdaptorProgramNotWhitelisted: Adaptor program not whitelisted. */ export const VOLTR_VAULT_ERROR__ADAPTOR_PROGRAM_NOT_WHITELISTED = 0x1780; // 6016 /** InvalidAdaptorPolicy: Invalid adaptor policy. */ export const VOLTR_VAULT_ERROR__INVALID_ADAPTOR_POLICY = 0x1781; // 6017 export type VoltrVaultError = | typeof VOLTR_VAULT_ERROR__ADAPTOR_EPOCH_INVALID | typeof VOLTR_VAULT_ERROR__ADAPTOR_PROGRAM_NOT_WHITELISTED | typeof VOLTR_VAULT_ERROR__DIVISION_BY_ZERO | typeof VOLTR_VAULT_ERROR__FEE_EXCEEDS_TOTAL_ASSET_VALUE | typeof VOLTR_VAULT_ERROR__INSTANT_WITHDRAW_NOT_ALLOWED | typeof VOLTR_VAULT_ERROR__INVALID_ACCOUNT_INPUT | typeof VOLTR_VAULT_ERROR__INVALID_ADAPTOR_POLICY | typeof VOLTR_VAULT_ERROR__INVALID_AMOUNT | typeof VOLTR_VAULT_ERROR__INVALID_FEE_CONFIGURATION | typeof VOLTR_VAULT_ERROR__INVALID_INPUT | typeof VOLTR_VAULT_ERROR__INVALID_TOKEN_ACCOUNT | typeof VOLTR_VAULT_ERROR__INVALID_TOKEN_MINT | typeof VOLTR_VAULT_ERROR__MANAGER_NOT_ALLOWED | typeof VOLTR_VAULT_ERROR__MATH_OVERFLOW | typeof VOLTR_VAULT_ERROR__MAX_CAP_EXCEEDED | typeof VOLTR_VAULT_ERROR__OPERATION_NOT_ALLOWED | typeof VOLTR_VAULT_ERROR__VAULT_NOT_ACTIVE | typeof VOLTR_VAULT_ERROR__WITHDRAWAL_NOT_YET_AVAILABLE; let voltrVaultErrorMessages: Record | undefined; if (process.env.NODE_ENV !== "production") { voltrVaultErrorMessages = { [VOLTR_VAULT_ERROR__ADAPTOR_EPOCH_INVALID]: `Adaptor epoch invalid.`, [VOLTR_VAULT_ERROR__ADAPTOR_PROGRAM_NOT_WHITELISTED]: `Adaptor program not whitelisted.`, [VOLTR_VAULT_ERROR__DIVISION_BY_ZERO]: `Division by zero.`, [VOLTR_VAULT_ERROR__FEE_EXCEEDS_TOTAL_ASSET_VALUE]: `Fee exceeds total asset value.`, [VOLTR_VAULT_ERROR__INSTANT_WITHDRAW_NOT_ALLOWED]: `Instant withdraw not allowed.`, [VOLTR_VAULT_ERROR__INVALID_ACCOUNT_INPUT]: `Invalid account input.`, [VOLTR_VAULT_ERROR__INVALID_ADAPTOR_POLICY]: `Invalid adaptor policy.`, [VOLTR_VAULT_ERROR__INVALID_AMOUNT]: `Invalid amount provided.`, [VOLTR_VAULT_ERROR__INVALID_FEE_CONFIGURATION]: `Fee configuration invalid.`, [VOLTR_VAULT_ERROR__INVALID_INPUT]: `Invalid input.`, [VOLTR_VAULT_ERROR__INVALID_TOKEN_ACCOUNT]: `Invalid token account.`, [VOLTR_VAULT_ERROR__INVALID_TOKEN_MINT]: `Invalid token mint.`, [VOLTR_VAULT_ERROR__MANAGER_NOT_ALLOWED]: `Manager not allowed in remaining.`, [VOLTR_VAULT_ERROR__MATH_OVERFLOW]: `Math overflow.`, [VOLTR_VAULT_ERROR__MAX_CAP_EXCEEDED]: `Max cap exceeded.`, [VOLTR_VAULT_ERROR__OPERATION_NOT_ALLOWED]: `Operation not allowed.`, [VOLTR_VAULT_ERROR__VAULT_NOT_ACTIVE]: `Vault not active.`, [VOLTR_VAULT_ERROR__WITHDRAWAL_NOT_YET_AVAILABLE]: `Withdrawal not yet available.`, }; } export function getVoltrVaultErrorMessage(code: VoltrVaultError): string { if (process.env.NODE_ENV !== "production") { return (voltrVaultErrorMessages as Record)[code]; } return "Error message not available in production bundles."; } export function isVoltrVaultError( error: unknown, transactionMessage: { instructions: Record; }, code?: TProgramErrorCode, ): error is SolanaError & Readonly<{ context: Readonly<{ code: TProgramErrorCode }> }> { return isProgramError( error, transactionMessage, VOLTR_VAULT_PROGRAM_ADDRESS, code, ); }