agg pub slot was recent even if price was not updated, switch to last slot which seems more relevant (#393)
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com> Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
9346c8e546
commit
be15f54225
|
@ -167,22 +167,19 @@ pub fn oracle_price(
|
||||||
return Err(MangoError::OracleConfidence.into());
|
return Err(MangoError::OracleConfidence.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
// The aggregation pub slot is the time that the aggregate was computed from published data
|
// The last_slot is when the price was actually updated
|
||||||
// that was at most 25 slots old. That means it underestimates the actual staleness, potentially
|
let last_slot = price_account.last_slot;
|
||||||
// significantly.
|
|
||||||
let agg_pub_slot = price_account.agg.pub_slot;
|
|
||||||
if config.max_staleness_slots >= 0
|
if config.max_staleness_slots >= 0
|
||||||
&& price_account
|
&& price_account
|
||||||
.agg
|
.last_slot
|
||||||
.pub_slot
|
|
||||||
.saturating_add(config.max_staleness_slots as u64)
|
.saturating_add(config.max_staleness_slots as u64)
|
||||||
< staleness_slot
|
< staleness_slot
|
||||||
{
|
{
|
||||||
msg!(
|
msg!(
|
||||||
"Pyth price too stale; pubkey {} price: {} pub slot: {}",
|
"Pyth price too stale; pubkey {} price: {} last slot: {}",
|
||||||
acc_info.key(),
|
acc_info.key(),
|
||||||
price.to_num::<f64>(),
|
price.to_num::<f64>(),
|
||||||
agg_pub_slot,
|
last_slot,
|
||||||
);
|
);
|
||||||
|
|
||||||
return Err(MangoError::OracleStale.into());
|
return Err(MangoError::OracleStale.into());
|
||||||
|
|
Loading…
Reference in New Issue