lending: validate pyth price trading status (#2618)

This commit is contained in:
Jordan Sexton 2021-12-04 17:59:20 -06:00 committed by GitHub
parent eaca634995
commit 0b8961597b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -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)

View File

@ -20,7 +20,7 @@ pub struct AccKey {
pub val: [u8; 32],
}
#[derive(Copy, Clone)]
#[derive(PartialEq, Copy, Clone)]
#[repr(C)]
pub enum AccountType {
Unknown,
@ -29,7 +29,7 @@ pub enum AccountType {
Price,
}
#[derive(Copy, Clone)]
#[derive(PartialEq, Copy, Clone)]
#[repr(C)]
pub enum PriceStatus {
Unknown,
@ -38,7 +38,7 @@ pub enum PriceStatus {
Auction,
}
#[derive(Copy, Clone)]
#[derive(PartialEq, Copy, Clone)]
#[repr(C)]
pub enum CorpAction {
NoCorpAct,