2022-02-22 04:31:18 -08:00
|
|
|
use anchor_lang::prelude::*;
|
|
|
|
use fixed::types::I80F48;
|
|
|
|
|
2022-02-22 05:23:13 -08:00
|
|
|
use super::IndexedPosition;
|
|
|
|
|
2022-02-22 04:31:18 -08:00
|
|
|
#[account(zero_copy)]
|
|
|
|
pub struct TokenBank {
|
|
|
|
/// native tokens deposited into or borrowed from this bank
|
|
|
|
pub deposits: u64,
|
|
|
|
pub borrows: u64,
|
|
|
|
|
2022-02-22 05:23:13 -08:00
|
|
|
/// the index used to scale the value of an IndexedPosition
|
|
|
|
pub deposit_index: I80F48,
|
|
|
|
pub borrow_index: I80F48,
|
2022-02-22 04:31:18 -08:00
|
|
|
// todo: multi-leg interest
|
|
|
|
// pub optimal_util: I80F48,
|
|
|
|
// pub optimal_rate: I80F48,
|
|
|
|
// pub max_rate: I80F48,
|
2022-02-22 05:23:13 -08:00
|
|
|
}
|
2022-02-22 04:31:18 -08:00
|
|
|
|
2022-02-22 05:23:13 -08:00
|
|
|
impl TokenBank {
|
|
|
|
pub fn deposit(&mut self, position: &mut IndexedPosition, amount: u64) {
|
|
|
|
self.deposits = self.deposits.checked_add(amount).unwrap();
|
|
|
|
// TODO: adjust position.value according to the indexes
|
|
|
|
}
|
2022-02-22 04:31:18 -08:00
|
|
|
}
|