Skip to content

Commit

Permalink
program: check FillOrderAmm for amm is available (#1107)
Browse files Browse the repository at this point in the history
* program: is-amm-available-action-validity

* CHANGELOG

* cargo fmt

---------

Co-authored-by: Chris Heaney <[email protected]>
  • Loading branch information
0xbigz and crispheaney committed Jun 23, 2024
1 parent 23877e2 commit 3f2b654
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- program: check FillOrderAmm for amm is available ([#1107](https://github.com/drift-labs/protocol-v2/pull/1107))
- program: add spot borrow insurance limits ([#1080](https://github.com/drift-labs/protocol-v2/pull/1080))
- program: maker can be rewarded filler returns when amm gets fill ([#1093](https://github.com/drift-labs/protocol-v2/pull/1093))
- program: avoid overwriting 0 duration auction ([#1097](https://github.com/drift-labs/protocol-v2/pull/1097))
Expand Down
7 changes: 5 additions & 2 deletions programs/drift/src/controller/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,6 @@ pub fn fill_perp_order(
let mut amm_is_available = !state.amm_paused()?;
{
let market = &mut perp_market_map.get_ref_mut(&market_index)?;
amm_is_available &= !market.is_operation_paused(PerpOperation::AmmFill);
amm_is_available &= !market.has_too_much_drawdown()?;
validation::perp_market::validate_perp_market(market)?;
validate!(
!market.is_in_settlement(now),
Expand All @@ -983,6 +981,11 @@ pub fn fill_perp_order(
market.get_max_confidence_interval_multiplier()?,
)?;

amm_is_available &=
is_oracle_valid_for_action(_oracle_validity, Some(DriftAction::FillOrderAmm))?;
amm_is_available &= !market.is_operation_paused(PerpOperation::AmmFill);
amm_is_available &= !market.has_too_much_drawdown()?;

reserve_price_before = market.amm.reserve_price()?;
oracle_price = oracle_price_data.price;
oracle_twap_5min = market
Expand Down

0 comments on commit 3f2b654

Please sign in to comment.