Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

program: skip liq perp oracle twap check if market is in settlement #1406

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions programs/drift/src/controller/liquidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,20 +309,22 @@ 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()?,
)?;

validate!(!oracle_price_too_divergent, ErrorCode::PriceBandsBreached)?;
{
let perp_market = perp_market_map.get_ref(&market_index)?;

if perp_market.status != MarketStatus::Settlement {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include delisted just in case?

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)?;
}
}

let user_base_asset_amount = user.perp_positions[position_index]
.base_asset_amount
Expand Down
Loading