pub fn pack(&self) -> Vec<u8> {
        let mut buf = Vec::with_capacity(size_of::<Self>());
        match *self {
            Self::InitLendingMarket {
                owner,
                quote_currency,
            } => {
                buf.push(0);
                buf.extend_from_slice(owner.as_ref());
                buf.extend_from_slice(quote_currency.as_ref());
            }
            Self::SetLendingMarketOwner { new_owner } => {
                buf.push(1);
                buf.extend_from_slice(new_owner.as_ref());
            }
            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,
                    },
            } => {
                buf.push(2);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
                buf.extend_from_slice(&optimal_utilization_rate.to_le_bytes());
                buf.extend_from_slice(&loan_to_value_ratio.to_le_bytes());
                buf.extend_from_slice(&liquidation_bonus.to_le_bytes());
                buf.extend_from_slice(&liquidation_threshold.to_le_bytes());
                buf.extend_from_slice(&min_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&optimal_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&max_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&borrow_fee_wad.to_le_bytes());
                buf.extend_from_slice(&flash_loan_fee_wad.to_le_bytes());
                buf.extend_from_slice(&host_fee_percentage.to_le_bytes());
                buf.extend_from_slice(&deposit_limit.to_le_bytes());
                buf.extend_from_slice(&borrow_limit.to_le_bytes());
                buf.extend_from_slice(&fee_receiver.to_bytes());
            }
            Self::RefreshReserve => {
                buf.push(3);
            }
            Self::DepositReserveLiquidity { liquidity_amount } => {
                buf.push(4);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::RedeemReserveCollateral { collateral_amount } => {
                buf.push(5);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::InitObligation => {
                buf.push(6);
            }
            Self::RefreshObligation => {
                buf.push(7);
            }
            Self::DepositObligationCollateral { collateral_amount } => {
                buf.push(8);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::WithdrawObligationCollateral { collateral_amount } => {
                buf.push(9);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::BorrowObligationLiquidity { liquidity_amount } => {
                buf.push(10);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::RepayObligationLiquidity { liquidity_amount } => {
                buf.push(11);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::LiquidateObligation { liquidity_amount } => {
                buf.push(12);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::FlashLoan { amount } => {
                buf.push(13);
                buf.extend_from_slice(&amount.to_le_bytes());
            }
            Self::DepositReserveLiquidityAndObligationCollateral { liquidity_amount } => {
                buf.push(14);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::WithdrawObligationCollateralAndRedeemReserveCollateral { collateral_amount } => {
                buf.push(15);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::UpdateReserveConfig { config } => {
                buf.push(16);
                buf.extend_from_slice(&config.optimal_utilization_rate.to_le_bytes());
                buf.extend_from_slice(&config.loan_to_value_ratio.to_le_bytes());
                buf.extend_from_slice(&config.liquidation_bonus.to_le_bytes());
                buf.extend_from_slice(&config.liquidation_threshold.to_le_bytes());
                buf.extend_from_slice(&config.min_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&config.optimal_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&config.max_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&config.fees.borrow_fee_wad.to_le_bytes());
                buf.extend_from_slice(&config.fees.flash_loan_fee_wad.to_le_bytes());
                buf.extend_from_slice(&config.fees.host_fee_percentage.to_le_bytes());
                buf.extend_from_slice(&config.deposit_limit.to_le_bytes());
                buf.extend_from_slice(&config.borrow_limit.to_le_bytes());
                buf.extend_from_slice(&config.fee_receiver.to_bytes());
            }
        }
        buf
    }
/// Packs a [LendingInstruction](enum.LendingInstruction.html) into a byte buffer.
Packs a [LendingInstruction](enum.LendingInstruction.html) into a byte buffer.
Packs a [ LendingInstruction ] ( enum . LendingInstruction . html ) into a byte buffer .
pub fn pack(&self) -> Vec<u8> {
        let mut buf = Vec::with_capacity(size_of::<Self>());
        match *self {
            Self::InitLendingMarket {
                owner,
                quote_currency,
            } => {
                buf.push(0);
                buf.extend_from_slice(owner.as_ref());
                buf.extend_from_slice(quote_currency.as_ref());
            }
            Self::SetLendingMarketOwner { new_owner } => {
                buf.push(1);
                buf.extend_from_slice(new_owner.as_ref());
            }
            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,
                    },
            } => {
                buf.push(2);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
                buf.extend_from_slice(&optimal_utilization_rate.to_le_bytes());
                buf.extend_from_slice(&loan_to_value_ratio.to_le_bytes());
                buf.extend_from_slice(&liquidation_bonus.to_le_bytes());
                buf.extend_from_slice(&liquidation_threshold.to_le_bytes());
                buf.extend_from_slice(&min_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&optimal_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&max_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&borrow_fee_wad.to_le_bytes());
                buf.extend_from_slice(&flash_loan_fee_wad.to_le_bytes());
                buf.extend_from_slice(&host_fee_percentage.to_le_bytes());
                buf.extend_from_slice(&deposit_limit.to_le_bytes());
                buf.extend_from_slice(&borrow_limit.to_le_bytes());
                buf.extend_from_slice(&fee_receiver.to_bytes());
            }
            Self::RefreshReserve => {
                buf.push(3);
            }
            Self::DepositReserveLiquidity { liquidity_amount } => {
                buf.push(4);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::RedeemReserveCollateral { collateral_amount } => {
                buf.push(5);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::InitObligation => {
                buf.push(6);
            }
            Self::RefreshObligation => {
                buf.push(7);
            }
            Self::DepositObligationCollateral { collateral_amount } => {
                buf.push(8);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::WithdrawObligationCollateral { collateral_amount } => {
                buf.push(9);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::BorrowObligationLiquidity { liquidity_amount } => {
                buf.push(10);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::RepayObligationLiquidity { liquidity_amount } => {
                buf.push(11);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::LiquidateObligation { liquidity_amount } => {
                buf.push(12);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::FlashLoan { amount } => {
                buf.push(13);
                buf.extend_from_slice(&amount.to_le_bytes());
            }
            Self::DepositReserveLiquidityAndObligationCollateral { liquidity_amount } => {
                buf.push(14);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::WithdrawObligationCollateralAndRedeemReserveCollateral { collateral_amount } => {
                buf.push(15);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::UpdateReserveConfig { config } => {
                buf.push(16);
                buf.extend_from_slice(&config.optimal_utilization_rate.to_le_bytes());
                buf.extend_from_slice(&config.loan_to_value_ratio.to_le_bytes());
                buf.extend_from_slice(&config.liquidation_bonus.to_le_bytes());
                buf.extend_from_slice(&config.liquidation_threshold.to_le_bytes());
                buf.extend_from_slice(&config.min_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&config.optimal_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&config.max_borrow_rate.to_le_bytes());
                buf.extend_from_slice(&config.fees.borrow_fee_wad.to_le_bytes());
                buf.extend_from_slice(&config.fees.flash_loan_fee_wad.to_le_bytes());
                buf.extend_from_slice(&config.fees.host_fee_percentage.to_le_bytes());
                buf.extend_from_slice(&config.deposit_limit.to_le_bytes());
                buf.extend_from_slice(&config.borrow_limit.to_le_bytes());
                buf.extend_from_slice(&config.fee_receiver.to_bytes());
            }
        }
        buf
    }
pub fn pack ( & self ) -> Vec < u8 > { let mut buf = Vec :: with_capacity ( size_of :: < Self > ( ) ) ; match * self { Self :: InitLendingMarket { owner , quote_currency , } => { buf . push ( 0 ) ; buf . extend_from_slice ( owner . as_ref ( ) ) ; buf . extend_from_slice ( quote_currency . as_ref ( ) ) ; } Self :: SetLendingMarketOwner { new_owner } => { buf . push ( 1 ) ; buf . extend_from_slice ( new_owner . as_ref ( ) ) ; } 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 , } , } => { buf . push ( 2 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; buf . extend_from_slice ( & optimal_utilization_rate . to_le_bytes ( ) ) ; buf . extend_from_slice ( & loan_to_value_ratio . to_le_bytes ( ) ) ; buf . extend_from_slice ( & liquidation_bonus . to_le_bytes ( ) ) ; buf . extend_from_slice ( & liquidation_threshold . to_le_bytes ( ) ) ; buf . extend_from_slice ( & min_borrow_rate . to_le_bytes ( ) ) ; buf . extend_from_slice ( & optimal_borrow_rate . to_le_bytes ( ) ) ; buf . extend_from_slice ( & max_borrow_rate . to_le_bytes ( ) ) ; buf . extend_from_slice ( & borrow_fee_wad . to_le_bytes ( ) ) ; buf . extend_from_slice ( & flash_loan_fee_wad . to_le_bytes ( ) ) ; buf . extend_from_slice ( & host_fee_percentage . to_le_bytes ( ) ) ; buf . extend_from_slice ( & deposit_limit . to_le_bytes ( ) ) ; buf . extend_from_slice ( & borrow_limit . to_le_bytes ( ) ) ; buf . extend_from_slice ( & fee_receiver . to_bytes ( ) ) ; } Self :: RefreshReserve => { buf . push ( 3 ) ; } Self :: DepositReserveLiquidity { liquidity_amount } => { buf . push ( 4 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; } Self :: RedeemReserveCollateral { collateral_amount } => { buf . push ( 5 ) ; buf . extend_from_slice ( & collateral_amount . to_le_bytes ( ) ) ; } Self :: InitObligation => { buf . push ( 6 ) ; } Self :: RefreshObligation => { buf . push ( 7 ) ; } Self :: DepositObligationCollateral { collateral_amount } => { buf . push ( 8 ) ; buf . extend_from_slice ( & collateral_amount . to_le_bytes ( ) ) ; } Self :: WithdrawObligationCollateral { collateral_amount } => { buf . push ( 9 ) ; buf . extend_from_slice ( & collateral_amount . to_le_bytes ( ) ) ; } Self :: BorrowObligationLiquidity { liquidity_amount } => { buf . push ( 10 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; } Self :: RepayObligationLiquidity { liquidity_amount } => { buf . push ( 11 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; } Self :: LiquidateObligation { liquidity_amount } => { buf . push ( 12 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; } Self :: FlashLoan { amount } => { buf . push ( 13 ) ; buf . extend_from_slice ( & amount . to_le_bytes ( ) ) ; } Self :: DepositReserveLiquidityAndObligationCollateral { liquidity_amount } => { buf . push ( 14 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; } Self :: WithdrawObligationCollateralAndRedeemReserveCollateral { collateral_amount } => { buf . push ( 15 ) ; buf . extend_from_slice ( & collateral_amount . to_le_bytes ( ) ) ; } Self :: UpdateReserveConfig { config } => { buf . push ( 16 ) ; buf . extend_from_slice ( & config . optimal_utilization_rate . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . loan_to_value_ratio . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . liquidation_bonus . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . liquidation_threshold . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . min_borrow_rate . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . optimal_borrow_rate . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . max_borrow_rate . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . fees . borrow_fee_wad . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . fees . flash_loan_fee_wad . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . fees . host_fee_percentage . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . deposit_limit . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . borrow_limit . to_le_bytes ( ) ) ; buf . extend_from_slice ( & config . fee_receiver . to_bytes ( ) ) ; } } buf }
Packs a [LendingInstruction](enum.LendingInstruction.html) into a byte buffer.
Packs a [ LendingInstruction ] ( enum . LendingInstruction . html ) into a byte buffer .
&self
&self