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: update-trigger-auction-runtime-param #1562

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions programs/drift/src/controller/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2959,7 +2959,7 @@ pub fn trigger_order(
&mut user.orders[order_index],
oracle_price_data,
slot,
30,
10,
Some(&perp_market),
)?;

Expand Down Expand Up @@ -5305,7 +5305,7 @@ pub fn trigger_spot_order(
&mut user.orders[order_index],
oracle_price_data,
slot,
30,
10,
None,
)?;

Expand Down
22 changes: 11 additions & 11 deletions programs/drift/src/controller/position/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ fn amm_pool_balance_liq_fees_example() {
let perp_market_loader: AccountLoader<PerpMarket> =
AccountLoader::try_from(&perp_market_account_info).unwrap();

let perp_market_map = PerpMarketMap::load_one(&perp_market_account_info, true).unwrap();
let _perp_market_map = PerpMarketMap::load_one(&perp_market_account_info, true).unwrap();

let now = 1725948560;
let clock_slot = 326319440;
let clock = Clock {
unix_timestamp: now,
slot: clock_slot,
..Clock::default()
};
// let clock = Clock {
// unix_timestamp: now,
// slot: clock_slot,
// ..Clock::default()
// };

let mut state = State::default();
let state = State::default();

let mut prelaunch_oracle_price = PrelaunchOracle {
price: PRICE_PRECISION_I64,
Expand All @@ -112,7 +112,7 @@ fn amm_pool_balance_liq_fees_example() {
PrelaunchOracle,
oracle_account_info
);
let mut oracle_map = OracleMap::load_one(&oracle_account_info, clock_slot, None).unwrap();
let oracle_map = OracleMap::load_one(&oracle_account_info, clock_slot, None).unwrap();

let mut spot_market = SpotMarket {
cumulative_deposit_interest: 11425141382,
Expand Down Expand Up @@ -639,11 +639,11 @@ fn amm_perp_ref_offset() {

let signed_liquidity_ratio = liquidity_ratio
.checked_mul(
(perp_market
perp_market
.amm
.get_protocol_owned_position()
.unwrap()
.signum() as i128),
.signum() as i128,
)
.unwrap();

Expand Down Expand Up @@ -677,7 +677,7 @@ fn amm_perp_ref_offset() {
delay: 1,
has_sufficient_number_of_data_points: true,
};
let cost = _update_amm(
let _cost = _update_amm(
&mut perp_market,
&oracle_price_data,
&state,
Expand Down
13 changes: 12 additions & 1 deletion programs/drift/src/math/auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::math::orders::standardize_price;
use crate::math::safe_math::SafeMath;
use crate::msg;
use crate::state::oracle::OraclePriceData;
use crate::state::perp_market::ContractTier;
use crate::state::user::{Order, OrderType};

use crate::state::fill_mode::FillMode;
Expand Down Expand Up @@ -254,13 +255,23 @@ pub fn calculate_auction_params_for_trigger_order(
let auction_duration = min_auction_duration;

if let Some(perp_market) = perp_market {
// negative buffer is crossing
let auction_start_buffer = if perp_market
.contract_tier
.is_as_safe_as_contract(&ContractTier::B)
{
-500
} else {
-3_500
};

let (auction_start_price, auction_end_price, derived_auction_duration) =
OrderParams::derive_market_order_auction_params(
perp_market,
order.direction,
oracle_price_data.price,
order.price,
0,
auction_start_buffer,
)?;

let auction_duration = auction_duration.max(derived_auction_duration);
Expand Down
Loading