Skip to content

Commit

Permalink
lending: validate pyth price trading status (solana-labs#2618)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordaaash authored Dec 4, 2021
1 parent eaca634 commit 0b89615
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions token-lending/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,11 @@ fn get_pyth_price(pyth_price_info: &AccountInfo, clock: &Clock) -> Result<Decima
return Err(LendingError::InvalidOracleConfig.into());
}

if pyth_price.agg.status != pyth::PriceStatus::Trading {
msg!("Oracle price status is invalid");
return Err(LendingError::InvalidOracleConfig.into());
}

let slots_elapsed = clock
.slot
.checked_sub(pyth_price.valid_slot)
Expand Down
6 changes: 3 additions & 3 deletions token-lending/program/src/pyth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct AccKey {
pub val: [u8; 32],
}

#[derive(Copy, Clone)]
#[derive(PartialEq, Copy, Clone)]
#[repr(C)]
pub enum AccountType {
Unknown,
Expand All @@ -29,7 +29,7 @@ pub enum AccountType {
Price,
}

#[derive(Copy, Clone)]
#[derive(PartialEq, Copy, Clone)]
#[repr(C)]
pub enum PriceStatus {
Unknown,
Expand All @@ -38,7 +38,7 @@ pub enum PriceStatus {
Auction,
}

#[derive(Copy, Clone)]
#[derive(PartialEq, Copy, Clone)]
#[repr(C)]
pub enum CorpAction {
NoCorpAct,
Expand Down

0 comments on commit 0b89615

Please sign in to comment.