diff --git a/contracts/vault/src/lib.rs b/contracts/vault/src/lib.rs index 383b39e4..29618060 100644 --- a/contracts/vault/src/lib.rs +++ b/contracts/vault/src/lib.rs @@ -274,6 +274,8 @@ pub enum DataKeyExt { // Issue #1174: gate for the contract telemetry / debugging hook DiagnosticsEnabled, + // Issue #1173 / #1231: nested to stay within DataKeyExt variant limits + Risk(RiskExtKey), // Issue #1230: Performance fee switch for strategy performance incentives PerformanceFeeBps, PerformanceIncentivePool, @@ -1375,12 +1377,22 @@ impl YieldVault { let token = Self::token(env.clone()); let price_data = oracle_client.get_price(&token, &token); let max_age = Self::oracle_heartbeat(env.clone()); + let last: Option = env + .storage() + .instance() + .get(&DataKeyExt::Risk(RiskExtKey::LastPx)); let last_price = Self::last_oracle_price(&env); oracle::OracleValidator::validate_price_data( &env, &price_data, max_age, Some(oracle::MAX_PRICE_DEVIATION_BPS), + last.as_ref(), + ) + .expect("OracleValidationFailed"); + env.storage() + .instance() + .set(&DataKeyExt::Risk(RiskExtKey::LastPx), &price_data); last_price.as_ref(), ) .map_err(|_| VaultError::OracleValidationFailed)?;