Skip to content

Commit 5d61bd3

Browse files
committed
Merge branch 'master' into crispheaney/isolated-position
2 parents 58df2ff + 6c7185b commit 5d61bd3

File tree

14 files changed

+27
-65
lines changed

14 files changed

+27
-65
lines changed

programs/drift/src/controller/insurance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -973,7 +973,7 @@ pub fn handle_if_begin_swap(
973973
out_insurance_fund_vault_amount: u64,
974974
in_spot_market: &mut SpotMarket,
975975
out_spot_market: &mut SpotMarket,
976-
in_amount: u64,
976+
_in_amount: u64,
977977
now: i64,
978978
) -> DriftResult<()> {
979979
if now

programs/drift/src/controller/liquidation.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ use crate::math::safe_math::SafeMath;
5353

5454
use crate::math::spot_balance::get_token_value;
5555
use crate::state::events::{
56-
emit_stack, LPAction, LPRecord, LiquidateBorrowForPerpPnlRecord,
57-
LiquidatePerpPnlForDepositRecord, LiquidatePerpRecord, LiquidateSpotRecord, LiquidationRecord,
58-
LiquidationType, OrderAction, OrderActionExplanation, OrderActionRecord, OrderRecord,
59-
PerpBankruptcyRecord, SpotBankruptcyRecord,
56+
LiquidateBorrowForPerpPnlRecord, LiquidatePerpPnlForDepositRecord, LiquidatePerpRecord,
57+
LiquidateSpotRecord, LiquidationRecord, LiquidationType, OrderAction, OrderActionExplanation,
58+
OrderActionRecord, OrderRecord, PerpBankruptcyRecord, SpotBankruptcyRecord,
6059
};
6160
use crate::state::fill_mode::FillMode;
6261
use crate::state::margin_calculation::{MarginCalculation, MarginContext, MarketIdentifier};
@@ -68,7 +67,6 @@ use crate::state::perp_market_map::PerpMarketMap;
6867
use crate::state::spot_market::SpotBalanceType;
6968
use crate::state::spot_market_map::SpotMarketMap;
7069
use crate::state::state::State;
71-
use crate::state::traits::Size;
7270
use crate::state::user::{MarketType, Order, OrderStatus, OrderType, User, UserStats};
7371
use crate::state::user_map::{UserMap, UserStatsMap};
7472
use crate::{get_then_update_id, load_mut, LST_POOL_ID};

programs/drift/src/controller/orders.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ use crate::math::spot_balance::{get_signed_token_amount, get_token_amount};
4848
use crate::math::spot_swap::select_margin_type_for_swap;
4949
use crate::math::{amm, fees, margin::*, orders::*};
5050
use crate::print_error;
51-
use crate::state::events::{
52-
emit_stack, get_order_action_record, LPAction, LPRecord, OrderActionRecord, OrderRecord,
53-
};
51+
use crate::state::events::{emit_stack, get_order_action_record, OrderActionRecord, OrderRecord};
5452
use crate::state::events::{OrderAction, OrderActionExplanation};
5553
use crate::state::fill_mode::FillMode;
5654
use crate::state::fulfillment::{PerpFulfillmentMethod, SpotFulfillmentMethod};
@@ -996,23 +994,12 @@ pub fn fill_perp_order(
996994
.position(|order| order.order_id == order_id && order.status == OrderStatus::Open)
997995
.ok_or_else(print_error!(ErrorCode::OrderDoesNotExist))?;
998996

999-
let (
1000-
order_status,
1001-
market_index,
1002-
order_market_type,
1003-
order_price,
1004-
order_oracle_price_offset,
1005-
order_direction,
1006-
order_auction_duration,
1007-
) = get_struct_values!(
997+
let (order_status, market_index, order_market_type, order_direction) = get_struct_values!(
1008998
user.orders[order_index],
1009999
status,
10101000
market_index,
10111001
market_type,
1012-
price,
1013-
oracle_price_offset,
1014-
direction,
1015-
auction_duration
1002+
direction
10161003
);
10171004

10181005
validate!(
@@ -2287,7 +2274,7 @@ pub fn fulfill_perp_order_with_amm(
22872274
filler_reward,
22882275
referee_discount,
22892276
referrer_reward,
2290-
fee_to_market_for_lp,
2277+
fee_to_market_for_lp: _fee_to_market_for_lp,
22912278
maker_rebate,
22922279
} = fees::calculate_fee_for_fulfillment_with_amm(
22932280
user_stats,
@@ -2304,9 +2291,6 @@ pub fn fulfill_perp_order_with_amm(
23042291
user.is_high_leverage_mode(MarginRequirementType::Initial),
23052292
)?;
23062293

2307-
let user_position_delta =
2308-
get_position_delta_for_fill(base_asset_amount, quote_asset_amount, order_direction)?;
2309-
23102294
// Increment the protocol's total fee variables
23112295
market.amm.total_fee = market.amm.total_fee.safe_add(fee_to_market.cast()?)?;
23122296
market.amm.total_exchange_fee = market.amm.total_exchange_fee.safe_add(user_fee.cast()?)?;

programs/drift/src/controller/pnl.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use crate::math::margin::{
1919
use crate::math::position::calculate_base_asset_value_with_expiry_price;
2020
use crate::math::safe_math::SafeMath;
2121
use crate::math::spot_balance::get_token_amount;
22-
use crate::state::margin_calculation::MarginContext;
2322

2423
use crate::msg;
2524
use crate::state::events::{OrderActionExplanation, SettlePnlExplanation, SettlePnlRecord};

programs/drift/src/controller/repeg.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use std::cmp::min;
33
use crate::math::oracle::LogMode;
44
use crate::msg;
55
use crate::state::oracle::MMOraclePriceData;
6-
use crate::state::oracle::OraclePriceData;
76
use anchor_lang::prelude::AccountInfo;
87
use anchor_lang::prelude::*;
98

programs/drift/src/instructions/admin.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,6 @@ pub fn handle_recenter_perp_market_amm_crank(
16011601
depth: Option<u128>,
16021602
) -> Result<()> {
16031603
let perp_market = &mut load_mut!(ctx.accounts.perp_market)?;
1604-
let spot_market = &mut load!(ctx.accounts.spot_market)?;
16051604

16061605
let clock = Clock::get()?;
16071606
let price_oracle = &ctx.accounts.oracle;
@@ -4780,9 +4779,6 @@ pub fn handle_initialize_if_rebalance_config(
47804779
ctx: Context<InitializeIfRebalanceConfig>,
47814780
params: IfRebalanceConfigParams,
47824781
) -> Result<()> {
4783-
let clock = Clock::get()?;
4784-
let now = clock.unix_timestamp;
4785-
47864782
let pubkey = ctx.accounts.if_rebalance_config.to_account_info().key;
47874783
let mut config = ctx.accounts.if_rebalance_config.load_init()?;
47884784

programs/drift/src/instructions/if_staker.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,7 @@ pub fn handle_begin_insurance_fund_swap<'c: 'info, 'info>(
375375

376376
let remaining_accounts_iter = &mut ctx.remaining_accounts.iter().peekable();
377377
let AccountMaps {
378-
perp_market_map,
379-
spot_market_map,
380-
mut oracle_map,
378+
spot_market_map, ..
381379
} = load_maps(
382380
remaining_accounts_iter,
383381
&MarketSet::new(),
@@ -602,14 +600,13 @@ pub fn handle_end_insurance_fund_swap<'c: 'info, 'info>(
602600
) -> Result<()> {
603601
let state = &ctx.accounts.state;
604602
let clock = Clock::get()?;
605-
let slot = clock.slot;
606603
let now = clock.unix_timestamp;
607604

608605
let remaining_accounts = &mut ctx.remaining_accounts.iter().peekable();
609606
let AccountMaps {
610-
perp_market_map,
611607
spot_market_map,
612608
mut oracle_map,
609+
..
613610
} = load_maps(
614611
remaining_accounts,
615612
&MarketSet::new(),

programs/drift/src/instructions/keeper.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::cell::RefMut;
2-
use std::collections::BTreeMap;
32
use std::convert::TryFrom;
43

54
use anchor_lang::prelude::*;
@@ -69,7 +68,6 @@ use crate::validation::sig_verification::verify_and_decode_ed25519_msg;
6968
use crate::validation::user::{validate_user_deletion, validate_user_is_idle};
7069
use crate::{
7170
controller, load, math, print_error, safe_decrement, OracleSource, GOV_SPOT_MARKET_INDEX,
72-
MARGIN_PRECISION,
7371
};
7472
use crate::{load_mut, QUOTE_PRECISION_U64};
7573
use crate::{math_error, ID};

programs/drift/src/instructions/user.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use crate::state::events::OrderActionRecord;
6363
use crate::state::events::OrderRecord;
6464
use crate::state::events::{
6565
DepositDirection, DepositExplanation, DepositRecord, FuelSeasonRecord, FuelSweepRecord,
66-
LPAction, LPRecord, NewUserRecord, OrderActionExplanation, SwapRecord,
66+
NewUserRecord, OrderActionExplanation, SwapRecord,
6767
};
6868
use crate::state::fill_mode::FillMode;
6969
use crate::state::fulfillment_params::drift::MatchFulfillmentParams;
@@ -78,7 +78,6 @@ use crate::state::order_params::{
7878
PlaceOrderOptions, PostOnlyParam,
7979
};
8080
use crate::state::paused_operations::{PerpOperation, SpotOperation};
81-
use crate::state::perp_market::ContractType;
8281
use crate::state::perp_market::MarketStatus;
8382
use crate::state::perp_market_map::{get_writable_perp_market_set, MarketSet};
8483
use crate::state::protected_maker_mode_config::ProtectedMakerModeConfig;

programs/drift/src/math/fees.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use crate::error::DriftResult;
66
use crate::math::casting::Cast;
77

88
use crate::math::constants::{
9-
FIFTY_MILLION_QUOTE, FIVE_MILLION_QUOTE, ONE_HUNDRED_MILLION_QUOTE, ONE_HUNDRED_THOUSAND_QUOTE,
10-
ONE_MILLION_QUOTE, ONE_THOUSAND_QUOTE, TEN_BPS, TEN_MILLION_QUOTE, TEN_THOUSAND_QUOTE,
11-
TWENTY_FIVE_THOUSAND_QUOTE, TWO_HUNDRED_FIFTY_THOUSAND_QUOTE,
9+
FIVE_MILLION_QUOTE, ONE_HUNDRED_MILLION_QUOTE, ONE_HUNDRED_THOUSAND_QUOTE, ONE_MILLION_QUOTE,
10+
ONE_THOUSAND_QUOTE, TEN_BPS, TEN_MILLION_QUOTE, TEN_THOUSAND_QUOTE, TWENTY_FIVE_THOUSAND_QUOTE,
11+
TWO_HUNDRED_FIFTY_THOUSAND_QUOTE,
1212
};
1313
use crate::math::helpers::get_proportion_u128;
1414
use crate::math::safe_math::SafeMath;

0 commit comments

Comments
 (0)