Skip to content

Commit

Permalink
pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nope-finance committed Jun 30, 2021
1 parent f5b5873 commit c21e4c0
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = &[
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -1852,12 +1850,10 @@ fn get_price(
clock: &Clock,
) -> Result<Decimal, ProgramError> {
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<Decimal, ProgramError> {
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit c21e4c0

Please sign in to comment.