diff --git a/CHANGELOG.md b/CHANGELOG.md index 955f490e8..cb6d00ac0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features -- program: add pause operation for liquidation ([#880](https://github.com/drift-labs/protocol-v2/pull/880)) - ### Fixes -- program: fix entry/breakeven price calculations for lp remainders ([#864](https://github.com/drift-labs/protocol-v2/pull/864)) -- program: handle derisk lp when orders array full ([#899](https://github.com/drift-labs/protocol-v2/pull/899)) -- program: invalid borrow in get_referrer_info when maker is refferer ([#900](https://github.com/drift-labs/protocol-v2/pull/900)) +- program: don't block oracle order prices when theres solely InsufficientDataPoints ([#919](https://github.com/drift-labs/protocol-v2/pull/919)) ### Breaking diff --git a/programs/drift/src/controller/orders.rs b/programs/drift/src/controller/orders.rs index e76ae07ab..820c68a85 100644 --- a/programs/drift/src/controller/orders.rs +++ b/programs/drift/src/controller/orders.rs @@ -997,11 +997,12 @@ pub fn fill_perp_order( } // allow oracle price to be used to calculate limit price if it's valid or stale for amm - let valid_oracle_price = if is_oracle_valid || oracle_validity == OracleValidity::StaleForAMM { - Some(oracle_price) - } else { - None - }; + let valid_oracle_price = + if is_oracle_valid_for_action(oracle_validity, Some(DriftAction::OracleOrderPrice))? { + Some(oracle_price) + } else { + None + }; let is_filler_taker = user_key == filler_key; let is_filler_maker = makers_and_referrer.0.contains_key(&filler_key); diff --git a/programs/drift/src/math/oracle.rs b/programs/drift/src/math/oracle.rs index 8b42b20cc..d70dd741a 100644 --- a/programs/drift/src/math/oracle.rs +++ b/programs/drift/src/math/oracle.rs @@ -46,6 +46,7 @@ pub enum DriftAction { MarginCalc, UpdateTwap, UpdateAMMCurve, + OracleOrderPrice, } pub fn is_oracle_valid_for_action( @@ -63,6 +64,14 @@ pub fn is_oracle_valid_for_action( OracleValidity::Valid | OracleValidity::StaleForAMM ) } + DriftAction::OracleOrderPrice => { + matches!( + oracle_validity, + OracleValidity::Valid + | OracleValidity::StaleForAMM + | OracleValidity::InsufficientDataPoints + ) + } DriftAction::MarginCalc => !matches!( oracle_validity, OracleValidity::Invalid