pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
        let (&tag, rest) = input
            .split_first()
            .ok_or(LendingError::InstructionUnpackError)?;
        Ok(match tag {
            0 => {
                let (owner, rest) = Self::unpack_pubkey(rest)?;
                let (quote_currency, _rest) = Self::unpack_bytes32(rest)?;
                Self::InitLendingMarket {
                    owner,
                    quote_currency: *quote_currency,
                }
            }
            1 => {
                let (new_owner, _rest) = Self::unpack_pubkey(rest)?;
                Self::SetLendingMarketOwner { new_owner }
            }
            2 => {
                let (liquidity_amount, rest) = Self::unpack_u64(rest)?;
                let (optimal_utilization_rate, rest) = Self::unpack_u8(rest)?;
                let (loan_to_value_ratio, rest) = Self::unpack_u8(rest)?;
                let (liquidation_bonus, rest) = Self::unpack_u8(rest)?;
                let (liquidation_threshold, rest) = Self::unpack_u8(rest)?;
                let (min_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (optimal_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (max_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (borrow_fee_wad, rest) = Self::unpack_u64(rest)?;
                let (flash_loan_fee_wad, rest) = Self::unpack_u64(rest)?;
                let (host_fee_percentage, rest) = Self::unpack_u8(rest)?;
                let (deposit_limit, rest) = Self::unpack_u64(rest)?;
                let (borrow_limit, rest) = Self::unpack_u64(rest)?;
                let (fee_receiver, _) = Self::unpack_pubkey(rest)?;
                Self::InitReserve {
                    liquidity_amount,
                    config: ReserveConfig {
                        optimal_utilization_rate,
                        loan_to_value_ratio,
                        liquidation_bonus,
                        liquidation_threshold,
                        min_borrow_rate,
                        optimal_borrow_rate,
                        max_borrow_rate,
                        fees: ReserveFees {
                            borrow_fee_wad,
                            flash_loan_fee_wad,
                            host_fee_percentage,
                        },
                        deposit_limit,
                        borrow_limit,
                        fee_receiver,
                    },
                }
            }
            3 => Self::RefreshReserve,
            4 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositReserveLiquidity { liquidity_amount }
            }
            5 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::RedeemReserveCollateral { collateral_amount }
            }
            6 => Self::InitObligation,
            7 => Self::RefreshObligation,
            8 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositObligationCollateral { collateral_amount }
            }
            9 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::WithdrawObligationCollateral { collateral_amount }
            }
            10 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::BorrowObligationLiquidity { liquidity_amount }
            }
            11 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::RepayObligationLiquidity { liquidity_amount }
            }
            12 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::LiquidateObligation { liquidity_amount }
            }
            13 => {
                let (amount, _rest) = Self::unpack_u64(rest)?;
                Self::FlashLoan { amount }
            }
            14 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositReserveLiquidityAndObligationCollateral { liquidity_amount }
            }
            15 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::WithdrawObligationCollateralAndRedeemReserveCollateral { collateral_amount }
            }
            16 => {
                let (optimal_utilization_rate, _rest) = Self::unpack_u8(rest)?;
                let (loan_to_value_ratio, _rest) = Self::unpack_u8(_rest)?;
                let (liquidation_bonus, _rest) = Self::unpack_u8(_rest)?;
                let (liquidation_threshold, _rest) = Self::unpack_u8(_rest)?;
                let (min_borrow_rate, _rest) = Self::unpack_u8(_rest)?;
                let (optimal_borrow_rate, _rest) = Self::unpack_u8(_rest)?;
                let (max_borrow_rate, _rest) = Self::unpack_u8(_rest)?;
                let (borrow_fee_wad, _rest) = Self::unpack_u64(_rest)?;
                let (flash_loan_fee_wad, _rest) = Self::unpack_u64(_rest)?;
                let (host_fee_percentage, _rest) = Self::unpack_u8(_rest)?;
                let (deposit_limit, _rest) = Self::unpack_u64(_rest)?;
                let (borrow_limit, _rest) = Self::unpack_u64(_rest)?;
                let (fee_receiver, _) = Self::unpack_pubkey(_rest)?;

                Self::UpdateReserveConfig {
                    config: ReserveConfig {
                        optimal_utilization_rate,
                        loan_to_value_ratio,
                        liquidation_bonus,
                        liquidation_threshold,
                        min_borrow_rate,
                        optimal_borrow_rate,
                        max_borrow_rate,
                        fees: ReserveFees {
                            borrow_fee_wad,
                            flash_loan_fee_wad,
                            host_fee_percentage,
                        },
                        deposit_limit,
                        borrow_limit,
                        fee_receiver,
                    },
                }
            }
            _ => {
                msg!("Instruction cannot be unpacked");
                return Err(LendingError::InstructionUnpackError.into());
            }
        })
    }
/// Unpacks a byte buffer into a [LendingInstruction](enum.LendingInstruction.html).
Unpacks a byte buffer into a [LendingInstruction](enum.LendingInstruction.html).
Unpacks a byte buffer into a [ LendingInstruction ] ( enum . LendingInstruction . html ) .
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
        let (&tag, rest) = input
            .split_first()
            .ok_or(LendingError::InstructionUnpackError)?;
        Ok(match tag {
            0 => {
                let (owner, rest) = Self::unpack_pubkey(rest)?;
                let (quote_currency, _rest) = Self::unpack_bytes32(rest)?;
                Self::InitLendingMarket {
                    owner,
                    quote_currency: *quote_currency,
                }
            }
            1 => {
                let (new_owner, _rest) = Self::unpack_pubkey(rest)?;
                Self::SetLendingMarketOwner { new_owner }
            }
            2 => {
                let (liquidity_amount, rest) = Self::unpack_u64(rest)?;
                let (optimal_utilization_rate, rest) = Self::unpack_u8(rest)?;
                let (loan_to_value_ratio, rest) = Self::unpack_u8(rest)?;
                let (liquidation_bonus, rest) = Self::unpack_u8(rest)?;
                let (liquidation_threshold, rest) = Self::unpack_u8(rest)?;
                let (min_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (optimal_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (max_borrow_rate, rest) = Self::unpack_u8(rest)?;
                let (borrow_fee_wad, rest) = Self::unpack_u64(rest)?;
                let (flash_loan_fee_wad, rest) = Self::unpack_u64(rest)?;
                let (host_fee_percentage, rest) = Self::unpack_u8(rest)?;
                let (deposit_limit, rest) = Self::unpack_u64(rest)?;
                let (borrow_limit, rest) = Self::unpack_u64(rest)?;
                let (fee_receiver, _) = Self::unpack_pubkey(rest)?;
                Self::InitReserve {
                    liquidity_amount,
                    config: ReserveConfig {
                        optimal_utilization_rate,
                        loan_to_value_ratio,
                        liquidation_bonus,
                        liquidation_threshold,
                        min_borrow_rate,
                        optimal_borrow_rate,
                        max_borrow_rate,
                        fees: ReserveFees {
                            borrow_fee_wad,
                            flash_loan_fee_wad,
                            host_fee_percentage,
                        },
                        deposit_limit,
                        borrow_limit,
                        fee_receiver,
                    },
                }
            }
            3 => Self::RefreshReserve,
            4 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositReserveLiquidity { liquidity_amount }
            }
            5 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::RedeemReserveCollateral { collateral_amount }
            }
            6 => Self::InitObligation,
            7 => Self::RefreshObligation,
            8 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositObligationCollateral { collateral_amount }
            }
            9 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::WithdrawObligationCollateral { collateral_amount }
            }
            10 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::BorrowObligationLiquidity { liquidity_amount }
            }
            11 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::RepayObligationLiquidity { liquidity_amount }
            }
            12 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::LiquidateObligation { liquidity_amount }
            }
            13 => {
                let (amount, _rest) = Self::unpack_u64(rest)?;
                Self::FlashLoan { amount }
            }
            14 => {
                let (liquidity_amount, _rest) = Self::unpack_u64(rest)?;
                Self::DepositReserveLiquidityAndObligationCollateral { liquidity_amount }
            }
            15 => {
                let (collateral_amount, _rest) = Self::unpack_u64(rest)?;
                Self::WithdrawObligationCollateralAndRedeemReserveCollateral { collateral_amount }
            }
            16 => {
                let (optimal_utilization_rate, _rest) = Self::unpack_u8(rest)?;
                let (loan_to_value_ratio, _rest) = Self::unpack_u8(_rest)?;
                let (liquidation_bonus, _rest) = Self::unpack_u8(_rest)?;
                let (liquidation_threshold, _rest) = Self::unpack_u8(_rest)?;
                let (min_borrow_rate, _rest) = Self::unpack_u8(_rest)?;
                let (optimal_borrow_rate, _rest) = Self::unpack_u8(_rest)?;
                let (max_borrow_rate, _rest) = Self::unpack_u8(_rest)?;
                let (borrow_fee_wad, _rest) = Self::unpack_u64(_rest)?;
                let (flash_loan_fee_wad, _rest) = Self::unpack_u64(_rest)?;
                let (host_fee_percentage, _rest) = Self::unpack_u8(_rest)?;
                let (deposit_limit, _rest) = Self::unpack_u64(_rest)?;
                let (borrow_limit, _rest) = Self::unpack_u64(_rest)?;
                let (fee_receiver, _) = Self::unpack_pubkey(_rest)?;
                Self::UpdateReserveConfig {
                    config: ReserveConfig {
                        optimal_utilization_rate,
                        loan_to_value_ratio,
                        liquidation_bonus,
                        liquidation_threshold,
                        min_borrow_rate,
                        optimal_borrow_rate,
                        max_borrow_rate,
                        fees: ReserveFees {
                            borrow_fee_wad,
                            flash_loan_fee_wad,
                            host_fee_percentage,
                        },
                        deposit_limit,
                        borrow_limit,
                        fee_receiver,
                    },
                }
            }
            _ => {
                msg!("Instruction cannot be unpacked");
                return Err(LendingError::InstructionUnpackError.into());
            }
        })
    }
pub fn unpack ( input : & [ u8 ] ) -> Result < Self , ProgramError > { let ( & tag , rest ) = input . split_first ( ) . ok_or ( LendingError :: InstructionUnpackError ) ? ; Ok ( match tag { 0 => { let ( owner , rest ) = Self :: unpack_pubkey ( rest ) ? ; let ( quote_currency , _rest ) = Self :: unpack_bytes32 ( rest ) ? ; Self :: InitLendingMarket { owner , quote_currency : * quote_currency , } } 1 => { let ( new_owner , _rest ) = Self :: unpack_pubkey ( rest ) ? ; Self :: SetLendingMarketOwner { new_owner } } 2 => { let ( liquidity_amount , rest ) = Self :: unpack_u64 ( rest ) ? ; let ( optimal_utilization_rate , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( loan_to_value_ratio , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( liquidation_bonus , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( liquidation_threshold , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( min_borrow_rate , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( optimal_borrow_rate , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( max_borrow_rate , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( borrow_fee_wad , rest ) = Self :: unpack_u64 ( rest ) ? ; let ( flash_loan_fee_wad , rest ) = Self :: unpack_u64 ( rest ) ? ; let ( host_fee_percentage , rest ) = Self :: unpack_u8 ( rest ) ? ; let ( deposit_limit , rest ) = Self :: unpack_u64 ( rest ) ? ; let ( borrow_limit , rest ) = Self :: unpack_u64 ( rest ) ? ; let ( fee_receiver , _ ) = Self :: unpack_pubkey ( rest ) ? ; Self :: InitReserve { liquidity_amount , config : ReserveConfig { optimal_utilization_rate , loan_to_value_ratio , liquidation_bonus , liquidation_threshold , min_borrow_rate , optimal_borrow_rate , max_borrow_rate , fees : ReserveFees { borrow_fee_wad , flash_loan_fee_wad , host_fee_percentage , } , deposit_limit , borrow_limit , fee_receiver , } , } } 3 => Self :: RefreshReserve , 4 => { let ( liquidity_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: DepositReserveLiquidity { liquidity_amount } } 5 => { let ( collateral_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: RedeemReserveCollateral { collateral_amount } } 6 => Self :: InitObligation , 7 => Self :: RefreshObligation , 8 => { let ( collateral_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: DepositObligationCollateral { collateral_amount } } 9 => { let ( collateral_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: WithdrawObligationCollateral { collateral_amount } } 10 => { let ( liquidity_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: BorrowObligationLiquidity { liquidity_amount } } 11 => { let ( liquidity_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: RepayObligationLiquidity { liquidity_amount } } 12 => { let ( liquidity_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: LiquidateObligation { liquidity_amount } } 13 => { let ( amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: FlashLoan { amount } } 14 => { let ( liquidity_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: DepositReserveLiquidityAndObligationCollateral { liquidity_amount } } 15 => { let ( collateral_amount , _rest ) = Self :: unpack_u64 ( rest ) ? ; Self :: WithdrawObligationCollateralAndRedeemReserveCollateral { collateral_amount } } 16 => { let ( optimal_utilization_rate , _rest ) = Self :: unpack_u8 ( rest ) ? ; let ( loan_to_value_ratio , _rest ) = Self :: unpack_u8 ( _rest ) ? ; let ( liquidation_bonus , _rest ) = Self :: unpack_u8 ( _rest ) ? ; let ( liquidation_threshold , _rest ) = Self :: unpack_u8 ( _rest ) ? ; let ( min_borrow_rate , _rest ) = Self :: unpack_u8 ( _rest ) ? ; let ( optimal_borrow_rate , _rest ) = Self :: unpack_u8 ( _rest ) ? ; let ( max_borrow_rate , _rest ) = Self :: unpack_u8 ( _rest ) ? ; let ( borrow_fee_wad , _rest ) = Self :: unpack_u64 ( _rest ) ? ; let ( flash_loan_fee_wad , _rest ) = Self :: unpack_u64 ( _rest ) ? ; let ( host_fee_percentage , _rest ) = Self :: unpack_u8 ( _rest ) ? ; let ( deposit_limit , _rest ) = Self :: unpack_u64 ( _rest ) ? ; let ( borrow_limit , _rest ) = Self :: unpack_u64 ( _rest ) ? ; let ( fee_receiver , _ ) = Self :: unpack_pubkey ( _rest ) ? ; Self :: UpdateReserveConfig { config : ReserveConfig { optimal_utilization_rate , loan_to_value_ratio , liquidation_bonus , liquidation_threshold , min_borrow_rate , optimal_borrow_rate , max_borrow_rate , fees : ReserveFees { borrow_fee_wad , flash_loan_fee_wad , host_fee_percentage , } , deposit_limit , borrow_limit , fee_receiver , } , } } _ => { msg ! ( " " ) ; return Err ( LendingError :: InstructionUnpackError . into ( ) ) ; } } ) }
Unpacks a byte buffer into a [LendingInstruction](enum.LendingInstruction.html).
Unpacks a byte buffer into a [ LendingInstruction ] ( enum . LendingInstruction . html ) .
input
&[u8]
input
&[u8]