lending: validate pyth price trading status (#2618)
This commit is contained in:
parent
eaca634995
commit
0b8961597b
|
@ -1775,6 +1775,11 @@ fn get_pyth_price(pyth_price_info: &AccountInfo, clock: &Clock) -> Result<Decima
|
||||||
return Err(LendingError::InvalidOracleConfig.into());
|
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
|
let slots_elapsed = clock
|
||||||
.slot
|
.slot
|
||||||
.checked_sub(pyth_price.valid_slot)
|
.checked_sub(pyth_price.valid_slot)
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub struct AccKey {
|
||||||
pub val: [u8; 32],
|
pub val: [u8; 32],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub enum AccountType {
|
pub enum AccountType {
|
||||||
Unknown,
|
Unknown,
|
||||||
|
@ -29,7 +29,7 @@ pub enum AccountType {
|
||||||
Price,
|
Price,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub enum PriceStatus {
|
pub enum PriceStatus {
|
||||||
Unknown,
|
Unknown,
|
||||||
|
@ -38,7 +38,7 @@ pub enum PriceStatus {
|
||||||
Auction,
|
Auction,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub enum CorpAction {
|
pub enum CorpAction {
|
||||||
NoCorpAct,
|
NoCorpAct,
|
||||||
|
|
Loading…
Reference in New Issue