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:
[writable]Lending market account - uninitialized.[]Rent sysvar.[]Token program id.[]Oracle program id.[]Switchboard Oracle program id.
Fields
SetLendingMarketOwner
Sets the new owner of a lending market.
Accounts expected by this instruction:
[writable]Lending market account.[signer]Current owner.
InitReserve
Initializes a new lending market reserve.
Accounts expected by this instruction:
[writable]Source liquidity token account. $authority can transfer $liquidity_amount.[writable]Destination collateral token account - uninitialized.[writable]Reserve account - uninitialized.[]Reserve liquidity SPL Token mint.[writable]Reserve liquidity supply SPL Token account - uninitialized.[writable]Reserve liquidity fee receiver - uninitialized.[writable]Reserve collateral SPL Token mint - uninitialized. 7[writable]Reserve collateral token supply - uninitialized.[]Pyth product account.[]Pyth price account. This will be used as the reserve liquidity oracle account.[]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
config: ReserveConfigReserve configuration values
RefreshReserve
Accrue interest and update market price of liquidity on a reserve.
Accounts expected by this instruction:
[writable]Reserve account.[]Pyth Reserve liquidity oracle account. Must be the Pyth price account specified at InitReserve.[]Switchboard Reserve liquidity oracle account. Must be the Switchboard price feed account specified at InitReserve.[]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:
[writable]Source liquidity token account. $authority can transfer $liquidity_amount.[writable]Destination collateral token account.[writable]Reserve account.[writable]Reserve liquidity supply SPL Token account.[writable]Reserve collateral SPL Token mint.[]Lending market account.[]Derived lending market authority.[signer]User transfer authority ($authority).[]Clock sysvar (optional, will be removed soon).[]Token program id.
RedeemReserveCollateral
Redeem collateral from a reserve in exchange for liquidity.
Accounts expected by this instruction:
[writable]Source collateral token account. $authority can transfer $collateral_amount.[writable]Destination liquidity token account.[writable]Reserve account.[writable]Reserve collateral SPL Token mint.[writable]Reserve liquidity supply SPL Token account.[]Lending market account.[]Derived lending market authority.[signer]User transfer authority ($authority).[]Clock sysvar (optional, will be removed soon).[]Token program id.
InitObligation
Initializes a new lending market obligation.
Accounts expected by this instruction:
[writable]Obligation account - uninitialized.[]Lending market account.[signer]Obligation owner.[]Clock sysvar (optional, will be removed soon).[]Rent sysvar.[]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:
[writable]Obligation account.[]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:
[writable]Source collateral token account. Minted by deposit reserve collateral mint. $authority can transfer $collateral_amount.[writable]Destination deposit reserve collateral supply SPL Token account.[writable]Deposit reserve account.[writable]Obligation account.[]Lending market account.[signer]Obligation owner.[signer]User transfer authority ($authority).[]Clock sysvar (optional, will be removed soon).[]Token program id.
WithdrawObligationCollateral
Withdraw collateral from an obligation. Requires a refreshed obligation and reserve.
Accounts expected by this instruction:
[writable]Source withdraw reserve collateral supply SPL Token account.[writable]Destination collateral token account. Minted by withdraw reserve collateral mint.[]Withdraw reserve account - refreshed.[writable]Obligation account - refreshed.[]Lending market account.[]Derived lending market authority.[signer]Obligation owner.[]Clock sysvar (optional, will be removed soon).[]Token program id.
Fields
BorrowObligationLiquidity
Borrow liquidity from a reserve by depositing collateral tokens. Requires a refreshed obligation and reserve.
Accounts expected by this instruction:
[writable]Source borrow reserve liquidity supply SPL Token account.[writable]Destination liquidity token account. Minted by borrow reserve liquidity mint.[writable]Borrow reserve account - refreshed.[writable]Borrow reserve liquidity fee receiver account. Must be the fee account specified at InitReserve.[writable]Obligation account - refreshed.[]Lending market account.[]Derived lending market authority.[signer]Obligation owner.[]Clock sysvar (optional, will be removed soon).[]Token program id. 10[optional, writable]Host fee receiver account.
RepayObligationLiquidity
Repay borrowed liquidity to a reserve. Requires a refreshed obligation and reserve.
Accounts expected by this instruction:
[writable]Source liquidity token account. Minted by repay reserve liquidity mint. $authority can transfer $liquidity_amount.[writable]Destination repay reserve liquidity supply SPL Token account.[writable]Repay reserve account - refreshed.[writable]Obligation account - refreshed.[]Lending market account.[signer]User transfer authority ($authority).[]Clock sysvar (optional, will be removed soon).[]Token program id.
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:
[writable]Source liquidity token account. Minted by repay reserve liquidity mint. $authority can transfer $liquidity_amount.[writable]Destination collateral token account. Minted by withdraw reserve collateral mint.[writable]Repay reserve account - refreshed.[writable]Repay reserve liquidity supply SPL Token account.[]Withdraw reserve account - refreshed.[writable]Withdraw reserve collateral supply SPL Token account.[writable]Obligation account - refreshed.[]Lending market account.[]Derived lending market authority.[signer]User transfer authority ($authority). 10[]Clock sysvar (optional, will be removed soon). 11[]Token program id.
Fields
FlashLoan
This instruction is now deprecated. Use FlashBorrowReserveLiquidity instead. Make a flash loan.
Accounts expected by this instruction:
[writable]Source liquidity token account. Minted by reserve liquidity mint. Must match the reserve liquidity supply.[writable]Destination liquidity token account. Minted by reserve liquidity mint.[writable]Reserve account.[writable]Flash loan fee receiver account. Must match the reserve liquidity fee receiver.[writable]Host fee receiver.[]Lending market account.[]Derived lending market authority.[]Token program id.[]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’sReceiveFlashLoaninstruction.
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:
[writable]Source liquidity (matching the destination from above).[writable]Destination liquidity (matching the source from above).[]Token program id ..[any]Additional accounts provided to the lending program’sFlashLoaninstruction above. ReceiveFlashLoan { // Amount that must be repaid by the receiver program amount: u64 }
Fields
DepositReserveLiquidityAndObligationCollateral
Combines DepositReserveLiquidity and DepositObligationCollateral
Accounts expected by this instruction:
[writable]Source liquidity token account. $authority can transfer $liquidity_amount.[writable]Destination collateral token account.[writable]Reserve account.[writable]Reserve liquidity supply SPL Token account.[writable]Reserve collateral SPL Token mint.[]Lending market account.[]Derived lending market authority.[writable]Destination deposit reserve collateral supply SPL Token account.[writable]Obligation account.[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.
WithdrawObligationCollateralAndRedeemReserveCollateral
Combines WithdrawObligationCollateral and RedeemReserveCollateral
Accounts expected by this instruction:
[writable]Source withdraw reserve collateral supply SPL Token account.[writable]Destination collateral token account. Minted by withdraw reserve collateral mint.[writable]Withdraw reserve account - refreshed.[writable]Obligation account - refreshed.[]Lending market account.[]Derived lending market authority.[writable]User liquidity token account.[writable]Reserve collateral SPL Token mint.[writable]Reserve liquidity supply SPL Token account.[signer]Obligation owner 10[signer]User transfer authority ($authority).[]Clock sysvar (optional, will be removed soon).[]Token program id.
UpdateReserveConfig
Updates a reserves config and a reserve price oracle pubkeys
Accounts expected by this instruction:
[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: ReserveConfigReserve 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:
[writable]Source liquidity token account. Minted by repay reserve liquidity mint. $authority can transfer $liquidity_amount.[writable]Destination collateral token account. Minted by withdraw reserve collateral mint.[writable]Destination liquidity token account.[writable]Repay reserve account - refreshed.[writable]Repay reserve liquidity supply SPL Token account.[writable]Withdraw reserve account - refreshed.[writable]Withdraw reserve collateral SPL Token mint.[writable]Withdraw reserve collateral supply SPL Token account.[writable]Withdraw reserve liquidity supply SPL Token account.[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
RedeemFees
[writable]Reserve account.[writable]Borrow reserve liquidity fee receiver account. Must be the fee account specified at InitReserve.[writable]Reserve liquidity supply SPL Token account.[]Lending market account.[]Derived lending market authority.[]Token program id.
FlashBorrowReserveLiquidity
Flash borrow reserve liquidity Accounts expected by this instruction:
[writable]Source liquidity token account.[writable]Destination liquidity token account.[writable]Reserve account.[]Lending market account.[]Derived lending market authority.[]Instructions sysvar.[]Token program id.[]Clock sysvar (optional, will be removed soon).
FlashRepayReserveLiquidity
Flash repay reserve liquidity Accounts expected by this instruction:
[writable]Source liquidity token account. $authority can transfer $liquidity_amount.[writable]Destination liquidity token account.[writable]Flash loan fee receiver account. Must match the reserve liquidity fee receiver.[writable]Host fee receiver.[writable]Reserve account.[]Lending market account.[signer]User transfer authority ($authority).[]Instructions sysvar.[]Token program id.
Implementations§
Source§impl LendingInstruction
impl LendingInstruction
Sourcepub fn unpack(input: &[u8]) -> Result<Self, ProgramError>
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError>
Unpacks a byte buffer into a LendingInstruction.
Trait Implementations§
Source§impl Clone for LendingInstruction
impl Clone for LendingInstruction
Source§fn clone(&self) -> LendingInstruction
fn clone(&self) -> LendingInstruction
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LendingInstruction
impl Debug for LendingInstruction
Source§impl PartialEq for LendingInstruction
impl PartialEq for LendingInstruction
impl Eq for LendingInstruction
impl StructuralPartialEq for LendingInstruction
Auto Trait Implementations§
impl Freeze for LendingInstruction
impl RefUnwindSafe for LendingInstruction
impl Send for LendingInstruction
impl Sync for LendingInstruction
impl Unpin for LendingInstruction
impl UnwindSafe for LendingInstruction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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