Skip to content

program: allow-auction-start-buffer-on-tail-mkt #1641

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
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
13 changes: 8 additions & 5 deletions programs/drift/src/state/order_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,14 +363,17 @@ impl OrderParams {
)?;
let current_start_price_offset = self.get_auction_start_price_offset(oracle_price)?;
let current_end_price_offset = self.get_auction_end_price_offset(oracle_price)?;

let is_tail_mkt = !perp_market.contract_tier.is_as_safe_as_contract(&ContractTier::B);

match self.direction {
PositionDirection::Long => {
let long_start_threshold = if is_signed_msg {
let long_start_threshold = if is_signed_msg || is_tail_mkt {
new_start_price_offset.safe_add(oracle_price.abs().safe_div(1000)?)?
} else {
new_start_price_offset
};
let long_end_threshold = if is_signed_msg {
let long_end_threshold = if is_signed_msg || is_tail_mkt {
new_end_price_offset.safe_add(oracle_price.abs().safe_div(1000)?)?
} else {
new_end_price_offset
Expand Down Expand Up @@ -400,12 +403,12 @@ impl OrderParams {
}
}
PositionDirection::Short => {
let short_start_threshold = if is_signed_msg {
let short_start_threshold = if is_signed_msg || is_tail_mkt {
new_start_price_offset.safe_sub(oracle_price.abs().safe_div(1000)?)?
} else {
new_start_price_offset
};
let short_end_threshold = if is_signed_msg {
let short_end_threshold = if is_signed_msg || is_tail_mkt {
new_end_price_offset.safe_sub(oracle_price.abs().safe_div(1000)?)?
} else {
new_end_price_offset
Expand Down Expand Up @@ -859,7 +862,7 @@ fn get_auction_duration(
Ok(percent_diff
.safe_mul(slots_per_bp)?
.safe_div_ceil(PERCENTAGE_PRECISION_U64 / 100)? // 1% = 60 slots
.clamp(10, 180) as u8) // 180 slots max
.clamp(1, 180) as u8) // 180 slots max
}

#[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq, Default)]
Expand Down
Loading