Skip to content

Commit

Permalink
program: flip auction flag when trigger order adds auction (#775)
Browse files Browse the repository at this point in the history
* program: flip auction flag when trigger order adds auction

* CHANGELOG
  • Loading branch information
crispheaney committed Dec 19, 2023
1 parent 556b2f2 commit 929251e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixes

- program: flip auction flag when trigger order adds auction ([#775](https://github.com/drift-labs/protocol-v2/pull/775))
- program: don't perform funding rate updates when slots_since_amm_update is stale ([#757](https://github.com/drift-labs/protocol-v2/pull/757))
- program: add update last slot for filler in pay_keeper_flat_reward_for_spot

Expand Down
8 changes: 8 additions & 0 deletions programs/drift/src/controller/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2579,6 +2579,10 @@ pub fn trigger_order(
state.min_perp_auction_duration,
)?;

if user.orders[order_index].has_auction() {
user.increment_open_auctions();
}

let direction = user.orders[order_index].direction;
let base_asset_amount = user.orders[order_index].base_asset_amount;

Expand Down Expand Up @@ -4570,6 +4574,10 @@ pub fn trigger_spot_order(
state.default_spot_auction_duration,
)?;

if user.orders[order_index].has_auction() {
user.increment_open_auctions();
}

let direction = user.orders[order_index].direction;
let base_asset_amount = user.orders[order_index].base_asset_amount;

Expand Down
8 changes: 6 additions & 2 deletions programs/drift/src/state/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,15 @@ impl User {
self.open_orders = self.open_orders.saturating_add(1);
self.has_open_order = self.open_orders > 0;
if is_auction {
self.open_auctions = self.open_auctions.saturating_add(1);
self.has_open_auction = self.open_auctions > 0;
self.increment_open_auctions();
}
}

pub fn increment_open_auctions(&mut self) {
self.open_auctions = self.open_auctions.saturating_add(1);
self.has_open_auction = self.open_auctions > 0;
}

pub fn decrement_open_orders(&mut self, is_auction: bool) {
self.open_orders = self.open_orders.saturating_sub(1);
self.has_open_order = self.open_orders > 0;
Expand Down

0 comments on commit 929251e

Please sign in to comment.