pub struct Obligation {
Show 15 fields pub version: u8, pub last_update: LastUpdate, pub lending_market: Pubkey, pub owner: Pubkey, pub deposits: Vec<ObligationCollateral>, pub borrows: Vec<ObligationLiquidity>, pub borrowed_value: Decimal, pub vault_shares: u64, pub lp_tokens: u64, pub coin_deposits: u64, pub pc_deposits: u64, pub deposits_market_value: Decimal, pub lp_decimals: u8, pub coin_decimals: u8, pub pc_decimals: u8,
}
Expand description

Lending market obligation state

Fields

version: u8

Version of the struct

last_update: LastUpdate

Last update to collateral, liquidity, or their market values

lending_market: Pubkey

Lending market address

owner: Pubkey

Vault address the obligation is associated with Owner authority which can borrow liquidity

deposits: Vec<ObligationCollateral>

Deposited collateral for the obligation, unique by deposit reserve address

borrows: Vec<ObligationLiquidity>

Borrowed liquidity for the obligation, unique by borrow reserve address

borrowed_value: Decimal

Market value of deposits Market value of borrows

vault_shares: u64

The maximum borrow value at the weighted average loan to value ratio The dangerous borrow value at the weighted average liquidation threshold vault shares

lp_tokens: u64

the number of lp token shares owned by this obligation when calculating loan to value ratio for obligations which have been used to borrow lp tokens, we calculate LTV using the pseudo deposits value instead of collateral value

coin_deposits: u64

the number of coin tokens owned by this obligation coin is wrt the lp token for this obligation this is used for deposit value when calculating LTV

pc_deposits: u64

the number of pc tokens owned by this obligation pc is wrt the lp token for this obligation this is used for deposit value when calculating LTV

deposits_market_value: Decimal

the market value of the user deposits includes lp (pseudo deposits), coin and pc tokens

lp_decimals: u8

the lp token pyth price account address the pc / quote pyth price account address Decimals in lp token

coin_decimals: u8

Decimals in coin

pc_decimals: u8

Decimals in pc

Implementations

Create a new obligation

Initialize an obligation

Calculate the current ratio of borrowed value using their pseudo deposited value instead of deposited value, allowing us to measure LTV using lp token value instead

todo(bonedaddy): add a test for this function

Calculate the current ratio of borrowed value to deposited value

Repay liquidity and remove it from borrows if zeroed out

Withdraw collateral and remove it from deposits if zeroed out

Calculate the maximum collateral value that can be withdrawn

Calculate the maximum liquidity value that can be borrowed

Calculate the maximum liquidation amount for a given liquidity

Find collateral by deposit reserve

Find or add collateral by deposit reserve

Find liquidity by borrow reserve

Find or add liquidity by borrow reserve

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Is initialized
The length, in bytes, of the packed representation
Get the packed length
Unpack from slice and check if initialized
Unpack from slice without checking if initialized
Pack into slice
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.