Skip to content

Commit

Permalink
pr fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xripleys committed Dec 16, 2023
1 parent 68d64e0 commit 6f3445d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
10 changes: 4 additions & 6 deletions token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,14 +577,12 @@ fn _refresh_reserve<'a>(
return Err(LendingError::InvalidAccountInput.into());
}

let market_price = match get_oracle_type(extra_oracle_account_info)? {
OracleType::Pyth => get_pyth_price(extra_oracle_account_info, clock)?.0,
match get_oracle_type(extra_oracle_account_info)? {
OracleType::Pyth => Some(get_pyth_price(extra_oracle_account_info, clock)?.0),
OracleType::Switchboard => {
get_switchboard_price_v2(extra_oracle_account_info, clock)?
Some(get_switchboard_price_v2(extra_oracle_account_info, clock)?)
}
};

Some(market_price.try_mul(reserve.price_scale())?)
}
}
None => {
msg!("Reserve extra oracle account info missing");
Expand Down
4 changes: 2 additions & 2 deletions token-lending/program/tests/refresh_reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ async fn test_use_extra_oracle() {
liquidity: ReserveLiquidity {
market_price: Decimal::from(12u64),
smoothed_market_price: Decimal::from(12u64),
extra_market_price: Some(Decimal::from(6u64)),
extra_market_price: Some(Decimal::from(5u64)),
..msol_reserve.account.liquidity
},
..msol_reserve.account
Expand Down Expand Up @@ -559,7 +559,7 @@ async fn test_use_extra_oracle() {
stale: false
},
liquidity: ReserveLiquidity {
extra_market_price: Some(Decimal::from_percent(240)),
extra_market_price: Some(Decimal::from(2u64)),
..msol_reserve.account.liquidity
},
..msol_reserve.account
Expand Down
2 changes: 1 addition & 1 deletion token-lending/sdk/src/state/reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ pub struct ReserveConfig {
/// Type of the reserve (Regular, Isolated)
pub reserve_type: ReserveType,
/// scaled price offset in basis points. Exclusively used to calculate a more reliable asset price for
/// staked assets (mSOL, stETH).
/// staked assets (mSOL, stETH). Not used on extra oracle
pub scaled_price_offset_bps: i64,
/// Extra oracle. Only used to limit borrows and withdrawals.
pub extra_oracle_pubkey: Option<Pubkey>,
Expand Down

0 comments on commit 6f3445d

Please sign in to comment.