From 8a346283506be240da2d809fd805d99b5f546d98 Mon Sep 17 00:00:00 2001 From: Jon Gurary Date: Mon, 12 Aug 2024 14:38:57 -0400 Subject: [PATCH] Comment fixes, linting --- programs/marginfi/src/state/marginfi_account.rs | 6 ------ programs/marginfi/src/state/price.rs | 4 ++-- programs/marginfi/src/utils.rs | 2 +- test-utils/src/test.rs | 4 +++- test-utils/src/utils.rs | 2 +- 5 files changed, 7 insertions(+), 11 deletions(-) diff --git a/programs/marginfi/src/state/marginfi_account.rs b/programs/marginfi/src/state/marginfi_account.rs index ceb6b8f67..978612c7d 100644 --- a/programs/marginfi/src/state/marginfi_account.rs +++ b/programs/marginfi/src/state/marginfi_account.rs @@ -490,12 +490,6 @@ impl<'info> RiskEngine<'_, 'info> { a.balance.bank_pk, assets, liabilities ); - // TODO remove - msg!( - "BALS Balance {}, assets: {}, liabilities: {}", - a.balance.bank_pk, assets, liabilities - ); - total_assets = total_assets.checked_add(assets).ok_or_else(math_error!())?; total_liabilities = total_liabilities .checked_add(liabilities) diff --git a/programs/marginfi/src/state/price.rs b/programs/marginfi/src/state/price.rs index 6562dfc93..ff4477bc5 100644 --- a/programs/marginfi/src/state/price.rs +++ b/programs/marginfi/src/state/price.rs @@ -329,7 +329,7 @@ impl SwitchboardPullPriceFeed { // Check staleness let last_updated = feed.last_update_timestamp; - if current_timestamp - last_updated > max_age as i64 { + if current_timestamp.saturating_sub(last_updated) > max_age as i64 { return err!(MarginfiError::StaleOracle); } @@ -354,7 +354,7 @@ impl SwitchboardPullPriceFeed { fn get_price(&self) -> MarginfiResult { let sw_result = self.feed.result; // Note: Pull oracles support mean (result.mean) or median (result.value) - let price: I80F48 = I80F48::from_num(sw_result.value) + let price: I80F48 = I80F48::from_num(sw_result.mean) .checked_div(EXP_10_I80F48[switchboard_on_demand::PRECISION as usize]) .ok_or_else(math_error!())?; diff --git a/programs/marginfi/src/utils.rs b/programs/marginfi/src/utils.rs index f3cf94577..fc79d68b7 100644 --- a/programs/marginfi/src/utils.rs +++ b/programs/marginfi/src/utils.rs @@ -191,4 +191,4 @@ pub fn hex_to_bytes(hex: &str) -> Vec { (high << 4) | low }) .collect() -} \ No newline at end of file +} diff --git a/test-utils/src/test.rs b/test-utils/src/test.rs index b70c760e5..4db3aefd6 100644 --- a/test-utils/src/test.rs +++ b/test-utils/src/test.rs @@ -607,7 +607,9 @@ impl TestFixture { BankMint::UsdcSwb => (&usdc_mint_f, *DEFAULT_USDC_TEST_SW_BANK_CONFIG), BankMint::Sol => (&sol_mint_f, *DEFAULT_SOL_TEST_BANK_CONFIG), BankMint::SolSwb => (&sol_mint_f, *DEFAULT_SOL_TEST_SW_BANK_CONFIG), - BankMint::SolSwbPull => (&sol_mint_f, *DEFAULT_SB_PULL_SOL_TEST_REAL_BANK_CONFIG), + BankMint::SolSwbPull => { + (&sol_mint_f, *DEFAULT_SB_PULL_SOL_TEST_REAL_BANK_CONFIG) + } BankMint::SolEquivalent => ( &sol_equivalent_mint_f, *DEFAULT_SOL_EQUIVALENT_TEST_BANK_CONFIG, diff --git a/test-utils/src/utils.rs b/test-utils/src/utils.rs index 1318657b2..c95446b95 100644 --- a/test-utils/src/utils.rs +++ b/test-utils/src/utils.rs @@ -709,4 +709,4 @@ pub mod lip { &liquidity_incentive_program::id(), ) } -} \ No newline at end of file +}