reflect-sdk 1.0.0

Rust SDK for minting and redeeming USDC+ on Reflect
Documentation
//! 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.
//!
//! <https://github.com/codama-idl/codama>
//!

use num_derive::FromPrimitive;
use thiserror::Error;

#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum ReflectMainError {
    /// 6000 - Number of recipients wrong
    #[error("Number of recipients wrong")]
    MissingRecipient = 0x1770,
    /// 6001 - Number of recipients can't be zero
    #[error("Number of recipients can't be zero")]
    NoRecipients = 0x1771,
    /// 6002 - Recipients can't exceed limit
    #[error("Recipients can't exceed limit")]
    TooManyRecipients = 0x1772,
    /// 6003 - Provided wrong recipient or in incorrect order
    #[error("Provided wrong recipient or in incorrect order")]
    IncorrectRecipient = 0x1773,
    /// 6004 - Component does not exist in this account
    #[error("Component does not exist in this account")]
    ComponentNotFound = 0x1774,
    /// 6005 - Invalid component type
    #[error("Invalid component type")]
    InvalidComponentType = 0x1775,
    /// 6006 - Component registry is full
    #[error("Component registry is full")]
    ComponentRegistryFull = 0x1776,
    /// 6007 - Component size exceeds maximum allowed
    #[error("Component size exceeds maximum allowed")]
    ComponentTooLarge = 0x1777,
    /// 6008 - No more space for component data
    #[error("No more space for component data")]
    ComponentDataExhausted = 0x1778,
    /// 6009 - Component exists already
    #[error("Component exists already")]
    ComponentAlreadyExists = 0x1779,
    /// 6010 - Cap can't be lower than what has been minted
    #[error("Cap can't be lower than what has been minted")]
    TooLowCap = 0x177A,
    /// 6011 - No more stable can be minted under this cap settings
    #[error("No more stable can be minted under this cap settings")]
    CapExceeded = 0x177B,
    /// 6012 - Out of bounds access
    #[error("Out of bounds access")]
    OutOfBounds = 0x177C,
    /// 6013 - Invalid data length
    #[error("Invalid data length")]
    BadLen = 0x177D,
    /// 6014 - This strategy already supports this SPL
    #[error("This strategy already supports this SPL")]
    StrategyAlreadySupportsSpl = 0x177E,
    /// 6015 - Protocol already supports this SPL
    #[error("Protocol already supports this SPL")]
    ProtocolAlreadySupportsSpl = 0x177F,
    /// 6016 - Not enough funds for this transaction
    #[error("Not enough funds for this transaction")]
    NotEnoughSplInput = 0x1780,
    /// 6017 - SPL not found
    #[error("SPL not found")]
    SplNotFound = 0x1781,
    /// 6018 - Provided SPL mint is not supported at the strategy
    #[error("Provided SPL mint is not supported at the strategy")]
    StrategyDoesNotSupportSpl = 0x1782,
    /// 6019 - Provided wrong mint account
    #[error("Provided wrong mint account")]
    IncorrectMint = 0x1783,
    /// 6020 - Need the correct number of the accounts in the remaining
    #[error("Need the correct number of the accounts in the remaining")]
    IncorrectNumberOfAccounts = 0x1784,
    /// 6021 - Incorrect mint address for this strategy
    #[error("Incorrect mint address for this strategy")]
    IncorrectReflectStrategyMint = 0x1785,
    /// 6022 - Incorrect token address for reflect token account
    #[error("Incorrect token address for reflect token account")]
    IncorrectReflectTokenAccount = 0x1786,
    /// 6023 - Slippage protection triggered for SPL redeem
    #[error("Slippage protection triggered for SPL redeem")]
    OutputAmountTooLow = 0x1787,
    /// 6024 - Cannot mint stable using this SPL at this strategy
    #[error("Cannot mint stable using this SPL at this strategy")]
    SplMintFrozen = 0x1788,
    /// 6025 - Token account of a different accoutn is needed for withdraw
    #[error("Token account of a different accoutn is needed for withdraw")]
    IncorrectWithdrawMint = 0x1789,
    /// 6026 - Provided wrong token account
    #[error("Provided wrong token account")]
    InvalidTokenAccount = 0x178A,
    /// 6027 - Provided permissions account does not match the caller
    #[error("Provided permissions account does not match the caller")]
    IncorrectAdminAccount = 0x178B,
    /// 6028 - Caller does not have the privilege for this action
    #[error("Caller does not have the privilege for this action")]
    MissingAdminPrivallages = 0x178C,
    /// 6029 - Can't remove the last admin
    #[error("Can't remove the last admin")]
    LastAdmin = 0x178D,
    /// 6030 - Special call for supremo removal
    #[error("Special call for supremo removal")]
    SupremoOnly = 0x178E,
    /// 6031 - You've provided same admin account
    #[error("You've provided same admin account")]
    SameAdmin = 0x178F,
    /// 6032 - User does not have such role
    #[error("User does not have such role")]
    UserLacksRole = 0x1790,
    /// 6033 - User already has requested role
    #[error("User already has requested role")]
    UserAlreadyHasRole = 0x1791,
    /// 6034 - This action lacks specified role
    #[error("This action lacks specified role")]
    RoleNotUnderAction = 0x1792,
    /// 6035 - Action not found
    #[error("Action not found")]
    ActionNotFound = 0x1793,
    /// 6036 - This action can already be performed by this role
    #[error("This action can already be performed by this role")]
    ActionHasAssignedRole = 0x1794,
    /// 6037 - This action can only be performed by a supreme authority
    #[error("This action can only be performed by a supreme authority")]
    SupremoOnlyAction = 0x1795,
    /// 6038 - Only supreme authorities can assign supreme authority roles
    #[error("Only supreme authorities can assign supreme authority roles")]
    CannotAssignSupremo = 0x1796,
    /// 6039 - Desired state is already on
    #[error("Desired state is already on")]
    AlreadyThere = 0x1797,
    /// 6040 - Action already frozen
    #[error("Action already frozen")]
    AlreadyFrozen = 0x1798,
    /// 6041 - Action already unfrozen
    #[error("Action already unfrozen")]
    AlreadyUnfrozen = 0x1799,
    /// 6042 - Program already registered
    #[error("Program already registered")]
    ProgramAlreadyExists = 0x179A,
    /// 6043 - Supplied program can not be used
    #[error("Supplied program can not be used")]
    InvalidProgram = 0x179B,
    /// 6044 - Supplied program account can not be used
    #[error("Supplied program account can not be used")]
    InvalidProgramAccount = 0x179C,
    /// 6045 - Neceessary account not provided
    #[error("Neceessary account not provided")]
    MissingAccount = 0x179D,
    /// 6046 - Math error
    #[error("Math error")]
    MathError = 0x179E,
    /// 6047 - Can't transmute
    #[error("Can't transmute")]
    ConversionFailed = 0x179F,
    /// 6048 - Mathematical operation overflow
    #[error("Mathematical operation overflow")]
    MathOverflow = 0x17A0,
    /// 6049 - Can't divide by zero
    #[error("Can't divide by zero")]
    DivisionByZero = 0x17A1,
    /// 6050 - Invalid data provided
    #[error("Invalid data provided")]
    InvalidData = 0x17A2,
    /// 6051 - Invalid state
    #[error("Invalid state")]
    InvalidState = 0x17A3,
    /// 6052 - Invalid input
    #[error("Invalid input")]
    InvalidInput = 0x17A4,
    /// 6053 - Could not load the price account
    #[error("Could not load the price account")]
    PythError = 0x17A5,
    /// 6054 - Failed unwrap
    #[error("Failed unwrap")]
    FailedUnwrap = 0x17A6,
    /// 6055 - Difference is too small to capture
    #[error("Difference is too small to capture")]
    SpreadTooSmall = 0x17A7,
    /// 6056 - Serialisation failed
    #[error("Serialisation failed")]
    SerialisationFailed = 0x17A8,
    /// 6057 - Deserialisation failed
    #[error("Deserialisation failed")]
    DeserialisationFailed = 0x17A9,
    /// 6058 - Item could not be added
    #[error("Item could not be added")]
    NoEntriesLeft = 0x17AA,
    /// 6059 - Provided wrong controller
    #[error("Provided wrong controller")]
    InvalidController = 0x17AB,
    /// 6060 - This action is suspended
    #[error("This action is suspended")]
    ActionFrozen = 0x17AC,
    /// 6061 - This configuration leads to an impossibility
    #[error("This configuration leads to an impossibility")]
    AttenuationExceedsMaximum = 0x17AD,
    /// 6062 - At least one parameter must be provided
    #[error("At least one parameter must be provided")]
    InvalidAttenuationParameters = 0x17AE,
    /// 6063 - Capture failed
    #[error("Capture failed")]
    CaptureProblem = 0x17AF,
    /// 6064 - All payout parties must add up to 100.0%
    #[error("All payout parties must add up to 100.0%")]
    InvalidRatios = 0x17B0,
    /// 6065 - PerpMarketNotFound
    #[error("PerpMarketNotFound")]
    PerpMarketNotFound = 0x17B1,
    /// 6066 - UnableToLoadMarketAccount
    #[error("UnableToLoadMarketAccount")]
    UnableToLoadPerpMarketAccount = 0x17B2,
    /// 6067 - InvalidMarketAccount
    #[error("InvalidMarketAccount")]
    InvalidMarketAccount = 0x17B3,
    /// 6068 - CouldNotLoadMarketData
    #[error("CouldNotLoadMarketData")]
    CouldNotLoadMarketData = 0x17B4,
    /// 6069 - MarketWrongMutability
    #[error("MarketWrongMutability")]
    MarketWrongMutability = 0x17B5,
    /// 6070 - SpotMarketWrongMutability
    #[error("SpotMarketWrongMutability")]
    SpotMarketWrongMutability = 0x17B6,
    /// 6071 - UnableToLoadSpotMarketAccount
    #[error("UnableToLoadSpotMarketAccount")]
    UnableToLoadSpotMarketAccount = 0x17B7,
    /// 6072 - InvalidSpotMarketAccount
    #[error("InvalidSpotMarketAccount")]
    InvalidSpotMarketAccount = 0x17B8,
    /// 6073 - CouldNotLoadSpotMarketData
    #[error("CouldNotLoadSpotMarketData")]
    CouldNotLoadSpotMarketData = 0x17B9,
    /// 6074 - Position has unsettled PnL and must be settled first
    #[error("Position has unsettled PnL and must be settled first")]
    UnsettledPnl = 0x17BA,
    /// 6075 - Unable To Load Oracles
    #[error("Unable To Load Oracles")]
    UnableToLoadOracle = 0x17BB,
    /// 6076 - OracleNotFound
    #[error("OracleNotFound")]
    OracleNotFound = 0x17BC,
    /// 6077 - InvalidOracle
    #[error("InvalidOracle")]
    InvalidOracle = 0x17BD,
    /// 6078 - SpotMarketNotFound
    #[error("SpotMarketNotFound")]
    SpotMarketNotFound = 0x17BE,
    /// 6079 - InvalidOracle
    #[error("InvalidOracle")]
    InvalidOracleSource = 0x17BF,
    /// 6080 - Position does not exist.
    #[error("Position does not exist.")]
    MissingPositon = 0x17C0,
    /// 6081 - SPL input is less than the minimum position change.
    #[error("SPL input is less than the minimum position change.")]
    BelowMinPositionChange = 0x17C1,
    /// 6082 - SPL input is less than the minimum position.
    #[error("SPL input is less than the minimum position.")]
    BelowMinPosition = 0x17C2,
    /// 6083 - Drift only supports 8 spot accounts
    #[error("Drift only supports 8 spot accounts")]
    DriftMaxSpots = 0x17C3,
    /// 6084 - My main man is to suffer no sneaky haircuts
    #[error("My main man is to suffer no sneaky haircuts")]
    DriftWithdrawlFee = 0x17C4,
    /// 6085 - SPL not supported
    #[error("SPL not supported")]
    SplNotSupported = 0x17C5,
    /// 6086 - Provided spot account does not match the expected spot account
    #[error("Provided spot account does not match the expected spot account")]
    IncorrectSpot = 0x17C6,
    /// 6087 - Market index not supported
    #[error("Market index not supported")]
    DriftMarketIndexNotSupported = 0x17C7,
    /// 6088 - Provided drift state account is incorrect
    #[error("Provided drift state account is incorrect")]
    IncorrectReflectState = 0x17C8,
    /// 6089 - Drift post CPI state of orders and/or base asset amount didn't show decrease
    #[error("Drift post CPI state of orders and/or base asset amount didn't show decrease")]
    IncorrectReduction = 0x17C9,
    /// 6090 - Drift post CPI state of orders and/or base asset amount didn't show increase
    #[error("Drift post CPI state of orders and/or base asset amount didn't show increase")]
    IncorrectIncrease = 0x17CA,
    /// 6091 - Can't create a new subaccount
    #[error("Can't create a new subaccount")]
    SubAccountNotFull = 0x17CB,
    /// 6092 - Not enough USDC for this deposit
    #[error("Not enough USDC for this deposit")]
    UsdcSplTooLow = 0x17CC,
    /// 6093 - Specified perp position not found
    #[error("Specified perp position not found")]
    PerpPositionNotFound = 0x17CD,
    /// 6094 - InvalidJlpOracle
    #[error("InvalidJlpOracle")]
    InvalidJlpOracle = 0x17CE,
    /// 6095 - Mint of this custody is not hedged
    #[error("Mint of this custody is not hedged")]
    CustodyNotHedged = 0x17CF,
    /// 6096 - Incorrect JLP account supplied
    #[error("Incorrect JLP account supplied")]
    IncorrectJlpAccount = 0x17D0,
    /// 6097 - TODO
    #[error("TODO")]
    ToDo = 0x17D1,
}

impl From<ReflectMainError> for solana_program_error::ProgramError {
    fn from(e: ReflectMainError) -> Self {
        solana_program_error::ProgramError::Custom(e as u32)
    }
}