From 1c1714d1b33612308b98273036fb2948f9720d92 Mon Sep 17 00:00:00 2001 From: Chris Heaney Date: Thu, 28 Dec 2023 20:58:09 -0600 Subject: [PATCH] Revert "program: derive auction for crossing limit with no duration (#801)" This reverts commit e7c1801d46b50887868ad274e4b9987d9cbe2de7. --- programs/drift/src/controller/orders.rs | 5 +-- programs/drift/src/state/order_params.rs | 57 ------------------------ 2 files changed, 1 insertion(+), 61 deletions(-) diff --git a/programs/drift/src/controller/orders.rs b/programs/drift/src/controller/orders.rs index 07697e5b2..a9183ab5b 100644 --- a/programs/drift/src/controller/orders.rs +++ b/programs/drift/src/controller/orders.rs @@ -98,7 +98,7 @@ pub fn place_perp_order( spot_market_map: &SpotMarketMap, oracle_map: &mut OracleMap, clock: &Clock, - mut params: OrderParams, + params: OrderParams, mut options: PlaceOrderOptions, ) -> DriftResult { let now = clock.unix_timestamp; @@ -219,9 +219,6 @@ pub fn place_perp_order( (existing_position_direction, base_asset_amount) }; - // updates auction params for crossing limit orders w/out auction duration - params.update_perp_auction_params(market)?; - let oracle_price_data = oracle_map.get_price_data(&market.amm.oracle)?; let (auction_start_price, auction_end_price, auction_duration) = get_auction_params( ¶ms, diff --git a/programs/drift/src/state/order_params.rs b/programs/drift/src/state/order_params.rs index 73da748ff..aad5cd36e 100644 --- a/programs/drift/src/state/order_params.rs +++ b/programs/drift/src/state/order_params.rs @@ -1,6 +1,4 @@ use crate::controller::position::PositionDirection; -use crate::error::DriftResult; -use crate::state::perp_market::PerpMarket; use crate::state::user::{MarketType, OrderTriggerCondition, OrderType}; use anchor_lang::prelude::*; use borsh::{BorshDeserialize, BorshSerialize}; @@ -26,61 +24,6 @@ pub struct OrderParams { pub auction_end_price: Option, } -impl OrderParams { - pub fn update_perp_auction_params(&mut self, perp_market: &PerpMarket) -> DriftResult { - if self.order_type != OrderType::Limit { - return Ok(()); - } - - if self.auction_duration.is_some() { - return Ok(()); - } - - if self.post_only != PostOnlyParam::None { - return Ok(()); - } - - if self.immediate_or_cancel { - return Ok(()); - } - - if self.oracle_price_offset.is_some() { - return Ok(()); - } - - match self.direction { - PositionDirection::Long => { - let reserve_price = perp_market.amm.reserve_price()?; - let ask_price = perp_market.amm.ask_price(reserve_price)?; - if self.price > ask_price { - let auction_duration = 60; - let auction_start_price = ask_price as i64; - let auction_end_price = self.price as i64; - msg!("derived auction params for limit order. duration = {} start_price = {} end_price = {}", auction_duration, auction_start_price, auction_end_price); - self.auction_duration = Some(auction_duration); - self.auction_start_price = Some(auction_start_price); - self.auction_end_price = Some(auction_end_price); - } - } - PositionDirection::Short => { - let reserve_price = perp_market.amm.reserve_price()?; - let bid_price = perp_market.amm.bid_price(reserve_price)?; - if self.price < bid_price { - let auction_duration = 60; - let auction_start_price = bid_price as i64; - let auction_end_price = self.price as i64; - msg!("derived auction params for limit order. duration = {} start_price = {} end_price = {}", auction_duration, auction_start_price, auction_end_price); - self.auction_duration = Some(auction_duration); - self.auction_start_price = Some(auction_start_price); - self.auction_end_price = Some(auction_end_price); - } - } - } - - Ok(()) - } -} - #[derive(Clone, Copy, BorshSerialize, BorshDeserialize, PartialEq, Debug, Eq)] pub enum PostOnlyParam { None,