From c21e4c0cfb4b3158e1552d4e755fbe55f0ca3c70 Mon Sep 17 00:00:00 2001 From: NOPE finance Date: Tue, 29 Jun 2021 17:01:23 -0700 Subject: [PATCH] pr comments --- token-lending/program/src/processor.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/token-lending/program/src/processor.rs b/token-lending/program/src/processor.rs index ed3f9c56c4c..38b1ff47a13 100644 --- a/token-lending/program/src/processor.rs +++ b/token-lending/program/src/processor.rs @@ -304,7 +304,6 @@ fn process_init_reserve( return Err(LendingError::InvalidOracleConfig.into()); } - // let market_price = get_pyth_price(pyth_price_info, clock)?; let market_price = get_price(switchboard_feed_info, pyth_price_info, clock)?; let authority_signer_seeds = &[ @@ -431,7 +430,6 @@ fn process_refresh_reserve(program_id: &Pubkey, accounts: &[AccountInfo]) -> Pro return Err(LendingError::InvalidOracleConfig.into()); } - // reserve.liquidity.market_price = get_pyth_price(pyth_price_info, clock)?; reserve.liquidity.market_price = get_price(switchboard_feed_info, pyth_price_info, clock)?; reserve.accrue_interest(clock.slot)?; @@ -1852,12 +1850,10 @@ fn get_price( clock: &Clock, ) -> Result { let pyth_price = get_pyth_price(pyth_price_account_info, clock).unwrap_or_default(); - if pyth_price != Decimal::from(0u64) { + if pyth_price != Decimal::zero() { return Ok(pyth_price); } - let switchboard_price = get_switchboard_price(switchboard_feed_info, clock)?; - - Ok(switchboard_price) + get_switchboard_price(switchboard_feed_info, clock) } fn get_pyth_price(pyth_price_info: &AccountInfo, clock: &Clock) -> Result { @@ -1946,9 +1942,7 @@ fn get_switchboard_price( let price = ((price_quotient as f64) * price_float).round() as u128; - let decimal_price = Decimal::from(price).try_div(price_quotient)?; - - Ok(decimal_price) + Decimal::from(price).try_div(price_quotient) } /// Issue a spl_token `InitializeAccount` instruction.