spl_token_lending/
error.rs1use num_derive::FromPrimitive;
4use solana_program::{decode_error::DecodeError, program_error::ProgramError};
5use thiserror::Error;
6
7#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
9pub enum LendingError {
10 #[error("Failed to unpack instruction data")]
13 InstructionUnpackError,
14 #[error("Account is already initialized")]
16 AlreadyInitialized,
17 #[error("Lamport balance below rent-exempt threshold")]
19 NotRentExempt,
20 #[error("Market authority is invalid")]
22 InvalidMarketAuthority,
23 #[error("Market owner is invalid")]
25 InvalidMarketOwner,
26
27 #[error("Input account owner is not the program address")]
30 InvalidAccountOwner,
31 #[error("Input token account is not owned by the correct token program id")]
33 InvalidTokenOwner,
34 #[error("Input token account is not valid")]
36 InvalidTokenAccount,
37 #[error("Input token mint account is not valid")]
39 InvalidTokenMint,
40 #[error("Input token program account is not valid")]
42 InvalidTokenProgram,
43
44 #[error("Input amount is invalid")]
47 InvalidAmount,
48 #[error("Input config value is invalid")]
50 InvalidConfig,
51 #[error("Input account must be a signer")]
53 InvalidSigner,
54 #[error("Invalid account input")]
56 InvalidAccountInput,
57 #[error("Math operation overflow")]
59 MathOverflow,
60
61 #[error("Token initialize mint failed")]
64 TokenInitializeMintFailed,
65 #[error("Token initialize account failed")]
67 TokenInitializeAccountFailed,
68 #[error("Token transfer failed")]
70 TokenTransferFailed,
71 #[error("Token mint to failed")]
73 TokenMintToFailed,
74 #[error("Token burn failed")]
76 TokenBurnFailed,
77
78 #[error("Insufficient liquidity available")]
81 InsufficientLiquidity,
82 #[error("Input reserve has collateral disabled")]
84 ReserveCollateralDisabled,
85 #[error("Reserve state needs to be refreshed")]
87 ReserveStale,
88 #[error("Withdraw amount too small")]
90 WithdrawTooSmall,
91 #[error("Withdraw amount too large")]
93 WithdrawTooLarge,
94
95 #[error("Borrow amount too small to receive liquidity after fees")]
98 BorrowTooSmall,
99 #[error("Borrow amount too large for deposited collateral")]
101 BorrowTooLarge,
102 #[error("Repay amount too small to transfer liquidity")]
104 RepayTooSmall,
105 #[error("Liquidation amount too small to receive collateral")]
107 LiquidationTooSmall,
108 #[error("Cannot liquidate healthy obligations")]
110 ObligationHealthy,
111
112 #[error("Obligation state needs to be refreshed")]
115 ObligationStale,
116 #[error("Obligation reserve limit exceeded")]
118 ObligationReserveLimit,
119 #[error("Obligation owner is invalid")]
121 InvalidObligationOwner,
122 #[error("Obligation deposits are empty")]
124 ObligationDepositsEmpty,
125 #[error("Obligation borrows are empty")]
127 ObligationBorrowsEmpty,
128
129 #[error("Obligation deposits have zero value")]
132 ObligationDepositsZero,
133 #[error("Obligation borrows have zero value")]
135 ObligationBorrowsZero,
136 #[error("Invalid obligation collateral")]
138 InvalidObligationCollateral,
139 #[error("Invalid obligation liquidity")]
141 InvalidObligationLiquidity,
142 #[error("Obligation collateral is empty")]
144 ObligationCollateralEmpty,
145
146 #[error("Obligation liquidity is empty")]
149 ObligationLiquidityEmpty,
150 #[error("Interest rate is negative")]
152 NegativeInterestRate,
153 #[error("Input oracle config is invalid")]
155 InvalidOracleConfig,
156 #[error("Input flash loan receiver program account is not valid")]
158 InvalidFlashLoanReceiverProgram,
159 #[error("Not enough liquidity after flash loan")]
161 NotEnoughLiquidityAfterFlashLoan,
162 #[error("Amount smaller than desired slippage limit")]
165 ExceededSlippage,
166}
167
168impl From<LendingError> for ProgramError {
169 fn from(e: LendingError) -> Self {
170 ProgramError::Custom(e as u32)
171 }
172}
173
174impl<T> DecodeError<T> for LendingError {
175 fn type_of() -> &'static str {
176 "Lending Error"
177 }
178}