Skip to content

Commit

Permalink
Comment fixes, linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jgur-psyops committed Aug 12, 2024
1 parent fca412e commit 8a34628
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
6 changes: 0 additions & 6 deletions programs/marginfi/src/state/marginfi_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions programs/marginfi/src/state/price.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -354,7 +354,7 @@ impl SwitchboardPullPriceFeed {
fn get_price(&self) -> MarginfiResult<I80F48> {
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!())?;

Expand Down
2 changes: 1 addition & 1 deletion programs/marginfi/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,4 @@ pub fn hex_to_bytes(hex: &str) -> Vec<u8> {
(high << 4) | low
})
.collect()
}
}
4 changes: 3 additions & 1 deletion test-utils/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test-utils/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,4 +709,4 @@ pub mod lip {
&liquidity_incentive_program::id(),
)
}
}
}

0 comments on commit 8a34628

Please sign in to comment.