diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f940cbd6..e5e2602e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixes +- program: skip liq perp oracle twap check if market is in settlement ([#1406](https://github.com/drift-labs/protocol-v2/pull/1406)) + ### Breaking ## [2.104.0] - 2024-12-23 diff --git a/programs/drift/src/controller/liquidation.rs b/programs/drift/src/controller/liquidation.rs index ada188f5b..95a24005d 100644 --- a/programs/drift/src/controller/liquidation.rs +++ b/programs/drift/src/controller/liquidation.rs @@ -309,20 +309,25 @@ pub fn liquidate_perp( "liquidator_max_base_asset_amount must be greater or equal to the step size", )?; - let oracle_price_too_divergent = is_oracle_too_divergent_with_twap_5min( - oracle_price, - perp_market_map - .get_ref(&market_index)? - .amm - .historical_oracle_data - .last_oracle_price_twap_5min, - state - .oracle_guard_rails - .max_oracle_twap_5min_percent_divergence() - .cast()?, - )?; + { + let perp_market = perp_market_map.get_ref(&market_index)?; + + if perp_market.status != MarketStatus::Settlement { + let oracle_price_too_divergent = is_oracle_too_divergent_with_twap_5min( + oracle_price, + perp_market + .amm + .historical_oracle_data + .last_oracle_price_twap_5min, + state + .oracle_guard_rails + .max_oracle_twap_5min_percent_divergence() + .cast()?, + )?; - validate!(!oracle_price_too_divergent, ErrorCode::PriceBandsBreached)?; + validate!(!oracle_price_too_divergent, ErrorCode::PriceBandsBreached)?; + } + } let user_base_asset_amount = user.perp_positions[position_index] .base_asset_amount