pub struct ReserveLiquidity {
pub mint_pubkey: Pubkey,
pub mint_decimals: u8,
pub supply_pubkey: Pubkey,
pub pyth_oracle_pubkey: Pubkey,
pub switchboard_oracle_pubkey: Pubkey,
pub available_amount: u64,
pub borrowed_amount_wads: Decimal,
pub cumulative_borrow_rate_wads: Decimal,
pub accumulated_protocol_fees_wads: Decimal,
pub market_price: Decimal,
}Expand description
Reserve liquidity
Fields§
§mint_pubkey: PubkeyReserve liquidity mint address
mint_decimals: u8Reserve liquidity mint decimals
supply_pubkey: PubkeyReserve liquidity supply address
pyth_oracle_pubkey: PubkeyReserve liquidity pyth oracle account
switchboard_oracle_pubkey: PubkeyReserve liquidity switchboard oracle account
available_amount: u64Reserve liquidity available
borrowed_amount_wads: DecimalReserve liquidity borrowed
cumulative_borrow_rate_wads: DecimalReserve liquidity cumulative borrow rate
accumulated_protocol_fees_wads: DecimalReserve cumulative protocol fees
market_price: DecimalReserve liquidity market price in quote currency
Implementations§
Source§impl ReserveLiquidity
impl ReserveLiquidity
Sourcepub fn new(params: NewReserveLiquidityParams) -> Self
pub fn new(params: NewReserveLiquidityParams) -> Self
Create a new reserve liquidity
Sourcepub fn total_supply(&self) -> Result<Decimal, ProgramError>
pub fn total_supply(&self) -> Result<Decimal, ProgramError>
Calculate the total reserve supply including active loans
Sourcepub fn deposit(&mut self, liquidity_amount: u64) -> ProgramResult
pub fn deposit(&mut self, liquidity_amount: u64) -> ProgramResult
Add liquidity to available amount
Sourcepub fn withdraw(&mut self, liquidity_amount: u64) -> ProgramResult
pub fn withdraw(&mut self, liquidity_amount: u64) -> ProgramResult
Remove liquidity from available amount
Sourcepub fn borrow(&mut self, borrow_decimal: Decimal) -> ProgramResult
pub fn borrow(&mut self, borrow_decimal: Decimal) -> ProgramResult
Subtract borrow amount from available liquidity and add to borrows
Sourcepub fn repay(
&mut self,
repay_amount: u64,
settle_amount: Decimal,
) -> ProgramResult
pub fn repay( &mut self, repay_amount: u64, settle_amount: Decimal, ) -> ProgramResult
Add repay amount to available liquidity and subtract settle amount from total borrows
Sourcepub fn redeem_fees(&mut self, withdraw_amount: u64) -> ProgramResult
pub fn redeem_fees(&mut self, withdraw_amount: u64) -> ProgramResult
Subtract settle amount from accumulated_protocol_fees_wads and withdraw_amount from available liquidity
Sourcepub fn utilization_rate(&self) -> Result<Rate, ProgramError>
pub fn utilization_rate(&self) -> Result<Rate, ProgramError>
Calculate the liquidity utilization rate of the reserve
Trait Implementations§
Source§impl Clone for ReserveLiquidity
impl Clone for ReserveLiquidity
Source§fn clone(&self) -> ReserveLiquidity
fn clone(&self) -> ReserveLiquidity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReserveLiquidity
impl Debug for ReserveLiquidity
Source§impl Default for ReserveLiquidity
impl Default for ReserveLiquidity
Source§fn default() -> ReserveLiquidity
fn default() -> ReserveLiquidity
Source§impl PartialEq for ReserveLiquidity
impl PartialEq for ReserveLiquidity
impl Eq for ReserveLiquidity
impl StructuralPartialEq for ReserveLiquidity
Auto Trait Implementations§
impl Freeze for ReserveLiquidity
impl RefUnwindSafe for ReserveLiquidity
impl Send for ReserveLiquidity
impl Sync for ReserveLiquidity
impl Unpin for ReserveLiquidity
impl UnwindSafe for ReserveLiquidity
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