#[repr(C)]
pub struct Bank {
Show 45 fields pub group: Pubkey, pub name: [u8; 16], pub mint: Pubkey, pub vault: Pubkey, pub oracle: Pubkey, pub oracle_config: OracleConfig, pub stable_price_model: StablePriceModel, pub deposit_index: I80F48, pub borrow_index: I80F48, pub indexed_deposits: I80F48, pub indexed_borrows: I80F48, pub index_last_updated: u64, pub bank_rate_last_updated: u64, pub avg_utilization: I80F48, pub adjustment_factor: I80F48, pub util0: I80F48, pub rate0: I80F48, pub util1: I80F48, pub rate1: I80F48, pub max_rate: I80F48, pub collected_fees_native: I80F48, pub loan_origination_fee_rate: I80F48, pub loan_fee_rate: I80F48, pub maint_asset_weight: I80F48, pub init_asset_weight: I80F48, pub maint_liab_weight: I80F48, pub init_liab_weight: I80F48, pub liquidation_fee: I80F48, pub dust: I80F48, pub flash_loan_token_account_initial: u64, pub flash_loan_approved_amount: u64, pub token_index: TokenIndex, pub bump: u8, pub mint_decimals: u8, pub bank_num: u32, pub min_vault_to_deposits_ratio: f64, pub net_borrow_limit_window_size_ts: u64, pub last_net_borrows_window_start_ts: u64, pub net_borrow_limit_per_window_quote: i64, pub net_borrows_in_window: i64, pub borrow_weight_scale_start_quote: f64, pub deposit_weight_scale_start_quote: f64, pub reduce_only: u8, pub force_close: u8, pub reserved: [u8; 2118],
}

Fields

group: Pubkeyname: [u8; 16]mint: Pubkeyvault: Pubkeyoracle: Pubkeyoracle_config: OracleConfigstable_price_model: StablePriceModeldeposit_index: I80F48

the index used to scale the value of an IndexedPosition TODO: should always be >= 0, add checks?

borrow_index: I80F48indexed_deposits: I80F48

deposits/borrows for this bank

Note that these may become negative. It’s perfectly fine for users to borrow one one bank (increasing indexed_borrows there) and paying back on another (possibly decreasing indexed_borrows below zero).

The vault amount is not deducable from these values.

These become meaningful when summed over all banks (like in update_index_and_rate).

indexed_borrows: I80F48index_last_updated: u64bank_rate_last_updated: u64avg_utilization: I80F48adjustment_factor: I80F48util0: I80F48rate0: I80F48util1: I80F48rate1: I80F48max_rate: I80F48collected_fees_native: I80F48loan_origination_fee_rate: I80F48loan_fee_rate: I80F48maint_asset_weight: I80F48init_asset_weight: I80F48maint_liab_weight: I80F48init_liab_weight: I80F48liquidation_fee: I80F48dust: I80F48flash_loan_token_account_initial: u64flash_loan_approved_amount: u64token_index: TokenIndexbump: u8mint_decimals: u8bank_num: u32min_vault_to_deposits_ratio: f64

Min fraction of deposits that must remain in the vault when borrowing.

net_borrow_limit_window_size_ts: u64

Size in seconds of a net borrows window

last_net_borrows_window_start_ts: u64

Timestamp at which the last net borrows window started

net_borrow_limit_per_window_quote: i64

Net borrow limit per window in quote native; set to -1 to disable.

net_borrows_in_window: i64

Sum of all deposits and borrows in the last window, in native units.

borrow_weight_scale_start_quote: f64

Soft borrow limit in native quote

Once the borrows on the bank exceed this quote value, init_liab_weight is scaled up. Set to f64::MAX to disable.

See scaled_init_liab_weight().

deposit_weight_scale_start_quote: f64

Limit for collateral of deposits in native quote

Once the deposits in the bank exceed this quote value, init_asset_weight is scaled down to keep the total collateral value constant. Set to f64::MAX to disable.

See scaled_init_asset_weight().

reduce_only: u8force_close: u8reserved: [u8; 2118]

Implementations

Prevent borrowing away the full bank vault. Keep some in reserve to satisfy non-borrow withdraws.

Deposits native_amount.

If the token position ends up positive but below one native token and this token position isn’t marked as in-use, the token balance will be dusted, the position will be set to zero and this function returns Ok(false).

native_amount must be >= 0 fractional deposits can be relevant during liquidation, for example

Like deposit(), but allows dusting of in-use accounts.

Returns Ok(false) if the position was dusted and was not in-use.

Internal function to deposit funds

Withdraws native_amount without applying the loan origination fee.

If the token position ends up positive but below one native token and this token position isn’t marked as in-use, the token balance will be dusted, the position will be set to zero and this function returns Ok(false).

native_amount must be >= 0 fractional withdraws can be relevant during liquidation, for example

Like withdraw_without_fee() but allows dusting of in-use token accounts.

Returns Ok(false) on dusted positions that weren’t in-use.

Withdraws native_amount while applying the loan origination fee if a borrow is created.

If the token position ends up positive but below one native token and this token position isn’t marked as in-use, the token balance will be dusted, the position will be set to zero and this function returns Ok(false).

native_amount must be >= 0 fractional withdraws can be relevant during liquidation, for example

Change a position without applying the loan origination fee

Change a position, while taking the loan origination fee into account

Update the bank’s net_borrows fields.

If oracle_price is set, also do a net borrows check and error if the threshold is exceeded.

returns the current interest rate in APR

calcualtor function that can be used to compute an interest rate based on the given parameters

Returns the init asset weight, adjusted for the number of deposits on the bank.

If max_collateral is 0, then the scaled init weight will be 0. Otherwise the weight is unadjusted until max_collateral and then scaled down such that scaled_init_weight * deposits remains constant.

Trait Implementations

Deserializes previously initialized account data. Should fail for all uninitialized accounts, where the bytes are zeroed. Implementations should be unique to a particular account type so that one can never successfully deserialize the data of one account type into another. For example, if the SPL token program were to implement this trait, it should be impossible to deserialize a Mint account into a token Account. Read more
Deserializes account data without checking the account discriminator. This should only be used on account initialization, when the bytes of the account are zeroed. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Casts the value.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern. Read more
If this function returns true, then it must be valid to reinterpret bits as &Self. Read more
Casts the value.

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Performs the conversion.
Performs the conversion.
Casts the value.
Casts the value.
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
Casts the value.
Casts the value.
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.
Casts the value.
Casts the value.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Casts the value.
Casts the value.