Skip to content

Commit 6c7185b

Browse files
committed
fix cargo build errors
1 parent 1e129e3 commit 6c7185b

File tree

15 files changed

+30
-70
lines changed

15 files changed

+30
-70
lines changed

programs/drift/src/controller/amm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::math::amm::calculate_quote_asset_amount_swapped;
1515
use crate::math::amm_spread::{calculate_spread_reserves, get_spread_reserves};
1616
use crate::math::casting::Cast;
1717
use crate::math::constants::{
18-
CONCENTRATION_PRECISION, FEE_ADJUSTMENT_MAX, FEE_POOL_TO_REVENUE_POOL_THRESHOLD,
19-
K_BPS_UPDATE_SCALE, MAX_CONCENTRATION_COEFFICIENT, MAX_K_BPS_INCREASE, MAX_SQRT_K,
18+
CONCENTRATION_PRECISION, FEE_POOL_TO_REVENUE_POOL_THRESHOLD, K_BPS_UPDATE_SCALE,
19+
MAX_CONCENTRATION_COEFFICIENT, MAX_K_BPS_INCREASE, MAX_SQRT_K,
2020
};
2121
use crate::math::cp_curve::get_update_k_result;
2222
use crate::math::repeg::get_total_fee_lower_bound;

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
@@ -50,10 +50,9 @@ use crate::math::safe_math::SafeMath;
5050

5151
use crate::math::spot_balance::get_token_value;
5252
use crate::state::events::{
53-
emit_stack, LPAction, LPRecord, LiquidateBorrowForPerpPnlRecord,
54-
LiquidatePerpPnlForDepositRecord, LiquidatePerpRecord, LiquidateSpotRecord, LiquidationRecord,
55-
LiquidationType, OrderAction, OrderActionExplanation, OrderActionRecord, OrderRecord,
56-
PerpBankruptcyRecord, SpotBankruptcyRecord,
53+
LiquidateBorrowForPerpPnlRecord, LiquidatePerpPnlForDepositRecord, LiquidatePerpRecord,
54+
LiquidateSpotRecord, LiquidationRecord, LiquidationType, OrderAction, OrderActionExplanation,
55+
OrderActionRecord, OrderRecord, PerpBankruptcyRecord, SpotBankruptcyRecord,
5756
};
5857
use crate::state::fill_mode::FillMode;
5958
use crate::state::margin_calculation::{MarginCalculation, MarginContext, MarketIdentifier};
@@ -65,7 +64,6 @@ use crate::state::perp_market_map::PerpMarketMap;
6564
use crate::state::spot_market::SpotBalanceType;
6665
use crate::state::spot_market_map::SpotMarketMap;
6766
use crate::state::state::State;
68-
use crate::state::traits::Size;
6967
use crate::state::user::{MarketType, Order, OrderStatus, OrderType, User, UserStats};
7068
use crate::state::user_map::{UserMap, UserStatsMap};
7169
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};
@@ -985,23 +983,12 @@ pub fn fill_perp_order(
985983
.position(|order| order.order_id == order_id && order.status == OrderStatus::Open)
986984
.ok_or_else(print_error!(ErrorCode::OrderDoesNotExist))?;
987985

988-
let (
989-
order_status,
990-
market_index,
991-
order_market_type,
992-
order_price,
993-
order_oracle_price_offset,
994-
order_direction,
995-
order_auction_duration,
996-
) = get_struct_values!(
986+
let (order_status, market_index, order_market_type, order_direction) = get_struct_values!(
997987
user.orders[order_index],
998988
status,
999989
market_index,
1000990
market_type,
1001-
price,
1002-
oracle_price_offset,
1003-
direction,
1004-
auction_duration
991+
direction
1005992
);
1006993

1007994
validate!(
@@ -2246,7 +2233,7 @@ pub fn fulfill_perp_order_with_amm(
22462233
filler_reward,
22472234
referee_discount,
22482235
referrer_reward,
2249-
fee_to_market_for_lp,
2236+
fee_to_market_for_lp: _fee_to_market_for_lp,
22502237
maker_rebate,
22512238
} = fees::calculate_fee_for_fulfillment_with_amm(
22522239
user_stats,
@@ -2263,9 +2250,6 @@ pub fn fulfill_perp_order_with_amm(
22632250
user.is_high_leverage_mode(MarginRequirementType::Initial),
22642251
)?;
22652252

2266-
let user_position_delta =
2267-
get_position_delta_for_fill(base_asset_amount, quote_asset_amount, order_direction)?;
2268-
22692253
// Increment the protocol's total fee variables
22702254
market.amm.total_fee = market.amm.total_fee.safe_add(fee_to_market.cast()?)?;
22712255
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ use crate::math::oracle::{is_oracle_valid_for_action, DriftAction};
1414

1515
use crate::math::casting::Cast;
1616
use crate::math::margin::{
17-
calculate_margin_requirement_and_total_collateral_and_liability_info,
1817
meets_maintenance_margin_requirement, meets_settle_pnl_maintenance_margin_requirement,
19-
MarginRequirementType,
2018
};
2119
use crate::math::position::calculate_base_asset_value_with_expiry_price;
2220
use crate::math::safe_math::SafeMath;
2321
use crate::math::spot_balance::get_token_amount;
24-
use crate::state::margin_calculation::MarginContext;
2522

2623
use crate::msg;
2724
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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use crate::math::margin::calculate_margin_requirement_and_total_collateral_and_l
3737
use crate::math::margin::meets_initial_margin_requirement;
3838
use crate::math::margin::{
3939
calculate_max_withdrawable_amount, meets_maintenance_margin_requirement,
40-
meets_place_order_margin_requirement, validate_spot_margin_trading, MarginRequirementType,
40+
validate_spot_margin_trading, MarginRequirementType,
4141
};
4242
use crate::math::oracle::is_oracle_valid_for_action;
4343
use crate::math::oracle::DriftAction;
@@ -61,7 +61,7 @@ use crate::state::events::OrderActionRecord;
6161
use crate::state::events::OrderRecord;
6262
use crate::state::events::{
6363
DepositDirection, DepositExplanation, DepositRecord, FuelSeasonRecord, FuelSweepRecord,
64-
LPAction, LPRecord, NewUserRecord, OrderActionExplanation, SwapRecord,
64+
NewUserRecord, OrderActionExplanation, SwapRecord,
6565
};
6666
use crate::state::fill_mode::FillMode;
6767
use crate::state::fulfillment_params::drift::MatchFulfillmentParams;
@@ -76,7 +76,6 @@ use crate::state::order_params::{
7676
PlaceOrderOptions, PostOnlyParam,
7777
};
7878
use crate::state::paused_operations::{PerpOperation, SpotOperation};
79-
use crate::state::perp_market::ContractType;
8079
use crate::state::perp_market::MarketStatus;
8180
use crate::state::perp_market_map::{get_writable_perp_market_set, MarketSet};
8281
use crate::state::protected_maker_mode_config::ProtectedMakerModeConfig;

0 commit comments

Comments
 (0)