pub fn pack(&self) -> Vec<u8> {
        let mut buf = Vec::with_capacity(size_of::<Self>());
        match *self {
            Self::InitLendingMarket { market_owner } => {
                buf.push(0);
                buf.extend_from_slice(market_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,
                                host_fee_percentage,
                            },
                    },
            } => {
                buf.push(1);
                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(&host_fee_percentage.to_le_bytes());
            }
            Self::InitObligation => {
                buf.push(2);
            }
            Self::DepositReserveLiquidity { liquidity_amount } => {
                buf.push(3);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::WithdrawReserveLiquidity { collateral_amount } => {
                buf.push(4);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::BorrowReserveLiquidity {
                amount,
                amount_type,
            } => {
                buf.push(5);
                buf.extend_from_slice(&amount.to_le_bytes());
                buf.extend_from_slice(&amount_type.to_u8().unwrap().to_le_bytes());
            }
            Self::RepayReserveLiquidity { liquidity_amount } => {
                buf.push(6);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::LiquidateObligation { liquidity_amount } => {
                buf.push(7);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::AccrueReserveInterest => {
                buf.push(8);
            }
            Self::DepositObligationCollateral { collateral_amount } => {
                buf.push(9);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::WithdrawObligationCollateral { collateral_amount } => {
                buf.push(10);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::SetLendingMarketOwner { new_owner } => {
                buf.push(11);
                buf.extend_from_slice(new_owner.as_ref());
            }
        }
        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 { market_owner } => {
                buf.push(0);
                buf.extend_from_slice(market_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,
                                host_fee_percentage,
                            },
                    },
            } => {
                buf.push(1);
                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(&host_fee_percentage.to_le_bytes());
            }
            Self::InitObligation => {
                buf.push(2);
            }
            Self::DepositReserveLiquidity { liquidity_amount } => {
                buf.push(3);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::WithdrawReserveLiquidity { collateral_amount } => {
                buf.push(4);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::BorrowReserveLiquidity {
                amount,
                amount_type,
            } => {
                buf.push(5);
                buf.extend_from_slice(&amount.to_le_bytes());
                buf.extend_from_slice(&amount_type.to_u8().unwrap().to_le_bytes());
            }
            Self::RepayReserveLiquidity { liquidity_amount } => {
                buf.push(6);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::LiquidateObligation { liquidity_amount } => {
                buf.push(7);
                buf.extend_from_slice(&liquidity_amount.to_le_bytes());
            }
            Self::AccrueReserveInterest => {
                buf.push(8);
            }
            Self::DepositObligationCollateral { collateral_amount } => {
                buf.push(9);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::WithdrawObligationCollateral { collateral_amount } => {
                buf.push(10);
                buf.extend_from_slice(&collateral_amount.to_le_bytes());
            }
            Self::SetLendingMarketOwner { new_owner } => {
                buf.push(11);
                buf.extend_from_slice(new_owner.as_ref());
            }
        }
        buf
    }
pub fn pack ( & self ) -> Vec < u8 > { let mut buf = Vec :: with_capacity ( size_of :: < Self > ( ) ) ; match * self { Self :: InitLendingMarket { market_owner } => { buf . push ( 0 ) ; buf . extend_from_slice ( market_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 , host_fee_percentage , } , } , } => { buf . push ( 1 ) ; 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 ( & host_fee_percentage . to_le_bytes ( ) ) ; } Self :: InitObligation => { buf . push ( 2 ) ; } Self :: DepositReserveLiquidity { liquidity_amount } => { buf . push ( 3 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; } Self :: WithdrawReserveLiquidity { collateral_amount } => { buf . push ( 4 ) ; buf . extend_from_slice ( & collateral_amount . to_le_bytes ( ) ) ; } Self :: BorrowReserveLiquidity { amount , amount_type , } => { buf . push ( 5 ) ; buf . extend_from_slice ( & amount . to_le_bytes ( ) ) ; buf . extend_from_slice ( & amount_type . to_u8 ( ) . unwrap ( ) . to_le_bytes ( ) ) ; } Self :: RepayReserveLiquidity { liquidity_amount } => { buf . push ( 6 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; } Self :: LiquidateObligation { liquidity_amount } => { buf . push ( 7 ) ; buf . extend_from_slice ( & liquidity_amount . to_le_bytes ( ) ) ; } Self :: AccrueReserveInterest => { buf . push ( 8 ) ; } Self :: DepositObligationCollateral { collateral_amount } => { buf . push ( 9 ) ; buf . extend_from_slice ( & collateral_amount . to_le_bytes ( ) ) ; } Self :: WithdrawObligationCollateral { collateral_amount } => { buf . push ( 10 ) ; buf . extend_from_slice ( & collateral_amount . to_le_bytes ( ) ) ; } Self :: SetLendingMarketOwner { new_owner } => { buf . push ( 11 ) ; buf . extend_from_slice ( new_owner . as_ref ( ) ) ; } } buf }
Packs a [LendingInstruction](enum.LendingInstruction.html) into a byte buffer.
Packs a [ LendingInstruction ] ( enum . LendingInstruction . html ) into a byte buffer .
&self