LendingInstruction

Enum LendingInstruction 

Source
pub enum LendingInstruction {
Show 21 variants InitLendingMarket { owner: Pubkey, quote_currency: [u8; 32], }, SetLendingMarketOwner { new_owner: Pubkey, }, InitReserve { liquidity_amount: u64, config: ReserveConfig, }, RefreshReserve, DepositReserveLiquidity { liquidity_amount: u64, }, RedeemReserveCollateral { collateral_amount: u64, }, InitObligation, RefreshObligation, DepositObligationCollateral { collateral_amount: u64, }, WithdrawObligationCollateral { collateral_amount: u64, }, BorrowObligationLiquidity { liquidity_amount: u64, }, RepayObligationLiquidity { liquidity_amount: u64, }, LiquidateObligation { liquidity_amount: u64, }, FlashLoan { amount: u64, }, DepositReserveLiquidityAndObligationCollateral { liquidity_amount: u64, }, WithdrawObligationCollateralAndRedeemReserveCollateral { collateral_amount: u64, }, UpdateReserveConfig { config: ReserveConfig, }, LiquidateObligationAndRedeemReserveCollateral { liquidity_amount: u64, }, RedeemFees, FlashBorrowReserveLiquidity { liquidity_amount: u64, }, FlashRepayReserveLiquidity { liquidity_amount: u64, borrow_instruction_index: u8, },
}
Expand description

Instructions supported by the lending program.

Variants§

§

InitLendingMarket

Initializes a new lending market.

Accounts expected by this instruction:

  1. [writable] Lending market account - uninitialized.
  2. [] Rent sysvar.
  3. [] Token program id.
  4. [] Oracle program id.
  5. [] Switchboard Oracle program id.

Fields

§owner: Pubkey

Owner authority which can add new reserves

§quote_currency: [u8; 32]

Currency market prices are quoted in e.g. “USD” null padded (*b"USD\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0") or SPL token mint pubkey

§

SetLendingMarketOwner

Sets the new owner of a lending market.

Accounts expected by this instruction:

  1. [writable] Lending market account.
  2. [signer] Current owner.

Fields

§new_owner: Pubkey

The new owner

§

InitReserve

Initializes a new lending market reserve.

Accounts expected by this instruction:

  1. [writable] Source liquidity token account. $authority can transfer $liquidity_amount.
  2. [writable] Destination collateral token account - uninitialized.
  3. [writable] Reserve account - uninitialized.
  4. [] Reserve liquidity SPL Token mint.
  5. [writable] Reserve liquidity supply SPL Token account - uninitialized.
  6. [writable] Reserve liquidity fee receiver - uninitialized.
  7. [writable] Reserve collateral SPL Token mint - uninitialized. 7 [writable] Reserve collateral token supply - uninitialized.
  8. [] Pyth product account.
  9. [] Pyth price account. This will be used as the reserve liquidity oracle account.
  10. [] Switchboard price feed account. used as a backup oracle 11 [] Lending market account. 12 [] Derived lending market authority. 13 [signer] Lending market owner. 14 [signer] User transfer authority ($authority). 15 [] Clock sysvar (optional, will be removed soon). 16 [] Rent sysvar. 17 [] Token program id.

Fields

§liquidity_amount: u64

Initial amount of liquidity to deposit into the new reserve

§config: ReserveConfig

Reserve configuration values

§

RefreshReserve

Accrue interest and update market price of liquidity on a reserve.

Accounts expected by this instruction:

  1. [writable] Reserve account.
  2. [] Pyth Reserve liquidity oracle account. Must be the Pyth price account specified at InitReserve.
  3. [] Switchboard Reserve liquidity oracle account. Must be the Switchboard price feed account specified at InitReserve.
  4. [] Clock sysvar (optional, will be removed soon).
§

DepositReserveLiquidity

Deposit liquidity into a reserve in exchange for collateral. Collateral represents a share of the reserve liquidity pool.

Accounts expected by this instruction:

  1. [writable] Source liquidity token account. $authority can transfer $liquidity_amount.
  2. [writable] Destination collateral token account.
  3. [writable] Reserve account.
  4. [writable] Reserve liquidity supply SPL Token account.
  5. [writable] Reserve collateral SPL Token mint.
  6. [] Lending market account.
  7. [] Derived lending market authority.
  8. [signer] User transfer authority ($authority).
  9. [] Clock sysvar (optional, will be removed soon).
  10. [] Token program id.

Fields

§liquidity_amount: u64

Amount of liquidity to deposit in exchange for collateral tokens

§

RedeemReserveCollateral

Redeem collateral from a reserve in exchange for liquidity.

Accounts expected by this instruction:

  1. [writable] Source collateral token account. $authority can transfer $collateral_amount.
  2. [writable] Destination liquidity token account.
  3. [writable] Reserve account.
  4. [writable] Reserve collateral SPL Token mint.
  5. [writable] Reserve liquidity supply SPL Token account.
  6. [] Lending market account.
  7. [] Derived lending market authority.
  8. [signer] User transfer authority ($authority).
  9. [] Clock sysvar (optional, will be removed soon).
  10. [] Token program id.

Fields

§collateral_amount: u64

Amount of collateral tokens to redeem in exchange for liquidity

§

InitObligation

Initializes a new lending market obligation.

Accounts expected by this instruction:

  1. [writable] Obligation account - uninitialized.
  2. [] Lending market account.
  3. [signer] Obligation owner.
  4. [] Clock sysvar (optional, will be removed soon).
  5. [] Rent sysvar.
  6. [] Token program id.
§

RefreshObligation

Refresh an obligation’s accrued interest and collateral and liquidity prices. Requires refreshed reserves, as all obligation collateral deposit reserves in order, followed by all liquidity borrow reserves in order.

Accounts expected by this instruction:

  1. [writable] Obligation account.
  2. [] Clock sysvar (optional, will be removed soon). .. [] Collateral deposit reserve accounts - refreshed, all, in order. .. [] Liquidity borrow reserve accounts - refreshed, all, in order.
§

DepositObligationCollateral

Deposit collateral to an obligation.

Accounts expected by this instruction:

  1. [writable] Source collateral token account. Minted by deposit reserve collateral mint. $authority can transfer $collateral_amount.
  2. [writable] Destination deposit reserve collateral supply SPL Token account.
  3. [writable] Deposit reserve account.
  4. [writable] Obligation account.
  5. [] Lending market account.
  6. [signer] Obligation owner.
  7. [signer] User transfer authority ($authority).
  8. [] Clock sysvar (optional, will be removed soon).
  9. [] Token program id.

Fields

§collateral_amount: u64

Amount of collateral tokens to deposit

§

WithdrawObligationCollateral

Withdraw collateral from an obligation. Requires a refreshed obligation and reserve.

Accounts expected by this instruction:

  1. [writable] Source withdraw reserve collateral supply SPL Token account.
  2. [writable] Destination collateral token account. Minted by withdraw reserve collateral mint.
  3. [] Withdraw reserve account - refreshed.
  4. [writable] Obligation account - refreshed.
  5. [] Lending market account.
  6. [] Derived lending market authority.
  7. [signer] Obligation owner.
  8. [] Clock sysvar (optional, will be removed soon).
  9. [] Token program id.

Fields

§collateral_amount: u64

Amount of collateral tokens to withdraw - u64::MAX for up to 100% of deposited amount

§

BorrowObligationLiquidity

Borrow liquidity from a reserve by depositing collateral tokens. Requires a refreshed obligation and reserve.

Accounts expected by this instruction:

  1. [writable] Source borrow reserve liquidity supply SPL Token account.
  2. [writable] Destination liquidity token account. Minted by borrow reserve liquidity mint.
  3. [writable] Borrow reserve account - refreshed.
  4. [writable] Borrow reserve liquidity fee receiver account. Must be the fee account specified at InitReserve.
  5. [writable] Obligation account - refreshed.
  6. [] Lending market account.
  7. [] Derived lending market authority.
  8. [signer] Obligation owner.
  9. [] Clock sysvar (optional, will be removed soon).
  10. [] Token program id. 10 [optional, writable] Host fee receiver account.

Fields

§liquidity_amount: u64

Amount of liquidity to borrow - u64::MAX for 100% of borrowing power

§

RepayObligationLiquidity

Repay borrowed liquidity to a reserve. Requires a refreshed obligation and reserve.

Accounts expected by this instruction:

  1. [writable] Source liquidity token account. Minted by repay reserve liquidity mint. $authority can transfer $liquidity_amount.
  2. [writable] Destination repay reserve liquidity supply SPL Token account.
  3. [writable] Repay reserve account - refreshed.
  4. [writable] Obligation account - refreshed.
  5. [] Lending market account.
  6. [signer] User transfer authority ($authority).
  7. [] Clock sysvar (optional, will be removed soon).
  8. [] Token program id.

Fields

§liquidity_amount: u64

Amount of liquidity to repay - u64::MAX for 100% of borrowed amount

§

LiquidateObligation

Repay borrowed liquidity to a reserve to receive collateral at a discount from an unhealthy obligation. Requires a refreshed obligation and reserves.

Accounts expected by this instruction:

  1. [writable] Source liquidity token account. Minted by repay reserve liquidity mint. $authority can transfer $liquidity_amount.
  2. [writable] Destination collateral token account. Minted by withdraw reserve collateral mint.
  3. [writable] Repay reserve account - refreshed.
  4. [writable] Repay reserve liquidity supply SPL Token account.
  5. [] Withdraw reserve account - refreshed.
  6. [writable] Withdraw reserve collateral supply SPL Token account.
  7. [writable] Obligation account - refreshed.
  8. [] Lending market account.
  9. [] Derived lending market authority.
  10. [signer] User transfer authority ($authority). 10 [] Clock sysvar (optional, will be removed soon). 11 [] Token program id.

Fields

§liquidity_amount: u64

Amount of liquidity to repay - u64::MAX for up to 100% of borrowed amount

§

FlashLoan

This instruction is now deprecated. Use FlashBorrowReserveLiquidity instead. Make a flash loan.

Accounts expected by this instruction:

  1. [writable] Source liquidity token account. Minted by reserve liquidity mint. Must match the reserve liquidity supply.
  2. [writable] Destination liquidity token account. Minted by reserve liquidity mint.
  3. [writable] Reserve account.
  4. [writable] Flash loan fee receiver account. Must match the reserve liquidity fee receiver.
  5. [writable] Host fee receiver.
  6. [] Lending market account.
  7. [] Derived lending market authority.
  8. [] Token program id.
  9. [] Flash loan receiver program id. Must implement an instruction that has tag of 0 and a signature of (amount: u64) This instruction must return the amount to the source liquidity account. .. [any] Additional accounts expected by the receiving program’s ReceiveFlashLoan instruction.

The flash loan receiver program that is to be invoked should contain an instruction with tag 0 and accept the total amount (including fee) that needs to be returned back after its execution has completed.

Flash loan receiver should have an instruction with the following signature:

  1. [writable] Source liquidity (matching the destination from above).
  2. [writable] Destination liquidity (matching the source from above).
  3. [] Token program id .. [any] Additional accounts provided to the lending program’s FlashLoan instruction above. ReceiveFlashLoan { // Amount that must be repaid by the receiver program amount: u64 }

Fields

§amount: u64

The amount that is to be borrowed - u64::MAX for up to 100% of available liquidity

§

DepositReserveLiquidityAndObligationCollateral

Combines DepositReserveLiquidity and DepositObligationCollateral

Accounts expected by this instruction:

  1. [writable] Source liquidity token account. $authority can transfer $liquidity_amount.
  2. [writable] Destination collateral token account.
  3. [writable] Reserve account.
  4. [writable] Reserve liquidity supply SPL Token account.
  5. [writable] Reserve collateral SPL Token mint.
  6. [] Lending market account.
  7. [] Derived lending market authority.
  8. [writable] Destination deposit reserve collateral supply SPL Token account.
  9. [writable] Obligation account.
  10. [signer] Obligation owner. 10 [] Pyth price oracle account. 11 [] Switchboard price feed oracle account. 12 [signer] User transfer authority ($authority). 13 [] Clock sysvar (optional, will be removed soon). 14 [] Token program id.

Fields

§liquidity_amount: u64

Amount of liquidity to deposit in exchange

§

WithdrawObligationCollateralAndRedeemReserveCollateral

Combines WithdrawObligationCollateral and RedeemReserveCollateral

Accounts expected by this instruction:

  1. [writable] Source withdraw reserve collateral supply SPL Token account.
  2. [writable] Destination collateral token account. Minted by withdraw reserve collateral mint.
  3. [writable] Withdraw reserve account - refreshed.
  4. [writable] Obligation account - refreshed.
  5. [] Lending market account.
  6. [] Derived lending market authority.
  7. [writable] User liquidity token account.
  8. [writable] Reserve collateral SPL Token mint.
  9. [writable] Reserve liquidity supply SPL Token account.
  10. [signer] Obligation owner 10 [signer] User transfer authority ($authority).
  11. [] Clock sysvar (optional, will be removed soon).
  12. [] Token program id.

Fields

§collateral_amount: u64

liquidity_amount is the amount of collateral tokens to withdraw

§

UpdateReserveConfig

Updates a reserves config and a reserve price oracle pubkeys

Accounts expected by this instruction:

  1. [writable] Reserve account - refreshed 2 [] Lending market account. 3 [] Derived lending market authority. 4 [signer] Lending market owner. 5 [] Pyth product key. 6 [] Pyth price key. 7 [] Switchboard key.

Fields

§config: ReserveConfig

Reserve config to update to

§

LiquidateObligationAndRedeemReserveCollateral

Repay borrowed liquidity to a reserve to receive collateral at a discount from an unhealthy obligation. Requires a refreshed obligation and reserves.

Accounts expected by this instruction:

  1. [writable] Source liquidity token account. Minted by repay reserve liquidity mint. $authority can transfer $liquidity_amount.
  2. [writable] Destination collateral token account. Minted by withdraw reserve collateral mint.
  3. [writable] Destination liquidity token account.
  4. [writable] Repay reserve account - refreshed.
  5. [writable] Repay reserve liquidity supply SPL Token account.
  6. [writable] Withdraw reserve account - refreshed.
  7. [writable] Withdraw reserve collateral SPL Token mint.
  8. [writable] Withdraw reserve collateral supply SPL Token account.
  9. [writable] Withdraw reserve liquidity supply SPL Token account.
  10. [writable] Withdraw reserve liquidity fee receiver account. 10 [writable] Obligation account - refreshed. 11 [] Lending market account. 12 [] Derived lending market authority. 13 [signer] User transfer authority ($authority). 14 [] Token program id.

Fields

§liquidity_amount: u64

Amount of liquidity to repay - u64::MAX for up to 100% of borrowed amount

§

RedeemFees

  1. [writable] Reserve account.
  2. [writable] Borrow reserve liquidity fee receiver account. Must be the fee account specified at InitReserve.
  3. [writable] Reserve liquidity supply SPL Token account.
  4. [] Lending market account.
  5. [] Derived lending market authority.
  6. [] Token program id.
§

FlashBorrowReserveLiquidity

Flash borrow reserve liquidity Accounts expected by this instruction:

  1. [writable] Source liquidity token account.
  2. [writable] Destination liquidity token account.
  3. [writable] Reserve account.
  4. [] Lending market account.
  5. [] Derived lending market authority.
  6. [] Instructions sysvar.
  7. [] Token program id.
  8. [] Clock sysvar (optional, will be removed soon).

Fields

§liquidity_amount: u64

Amount of liquidity to flash borrow

§

FlashRepayReserveLiquidity

Flash repay reserve liquidity Accounts expected by this instruction:

  1. [writable] Source liquidity token account. $authority can transfer $liquidity_amount.
  2. [writable] Destination liquidity token account.
  3. [writable] Flash loan fee receiver account. Must match the reserve liquidity fee receiver.
  4. [writable] Host fee receiver.
  5. [writable] Reserve account.
  6. [] Lending market account.
  7. [signer] User transfer authority ($authority).
  8. [] Instructions sysvar.
  9. [] Token program id.

Fields

§liquidity_amount: u64

Amount of liquidity to flash repay

§borrow_instruction_index: u8

Index of FlashBorrowReserveLiquidity instruction

Implementations§

Source§

impl LendingInstruction

Source

pub fn unpack(input: &[u8]) -> Result<Self, ProgramError>

Unpacks a byte buffer into a LendingInstruction.

Source

pub fn pack(&self) -> Vec<u8>

Packs a LendingInstruction into a byte buffer.

Trait Implementations§

Source§

impl Clone for LendingInstruction

Source§

fn clone(&self) -> LendingInstruction

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LendingInstruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for LendingInstruction

Source§

fn eq(&self, other: &LendingInstruction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for LendingInstruction

Source§

impl StructuralPartialEq for LendingInstruction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AbiExample for T

Source§

default fn example() -> T

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V