Skip to content

Commit 76e2f2f

Browse files
committed
Merge branch 'master' into wphan/builder_codes
2 parents e3db97b + 14c4843 commit 76e2f2f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2379
-327
lines changed

CHANGELOG.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Features
1111

12+
### Fixes
13+
14+
### Breaking
15+
16+
## [2.138.0] - 2025-09-22
17+
18+
### Features
19+
20+
- program: support scaled ui extension ([#1894](https://github.com/drift-labs/protocol-v2/pull/1894))
21+
- Revert "Crispeaney/revert swift max margin ratio ([#1877](https://github.com/drift-labs/protocol-v2/pull/1877))
22+
23+
### Fixes
24+
25+
### Breaking
26+
27+
## [2.137.0] - 2025-09-15
28+
29+
### Features
30+
31+
- program: post only respects reduce only ([#1878](https://github.com/drift-labs/protocol-v2/pull/1878))
32+
- program: add sequence id to exchange/mm oracle ([#1834](https://github.com/drift-labs/protocol-v2/pull/1834))
33+
- program: perp position max margin ratio ([#1847](https://github.com/drift-labs/protocol-v2/pull/1847))
34+
- program: add padding to swift messages ([#1845](https://github.com/drift-labs/protocol-v2/pull/1845))
1235
- program: rm lp ([#1755](https://github.com/drift-labs/protocol-v2/pull/1755))
1336

1437
### Fixes
1538

39+
- program: make it easier to fill step size orders ([#1799](https://github.com/drift-labs/protocol-v2/pull/1799))
40+
- program: relax fee tier constraints for maker ([#1876](https://github.com/drift-labs/protocol-v2/pull/1876))
41+
1642
### Breaking
1743

1844
## [2.136.0] - 2025-09-03

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,51 @@
4848
"prepare": "husky install",
4949
"prettify": "prettier --check './sdk/src/**/*.ts' './tests/**.ts' './cli/**.ts'",
5050
"prettify:fix": "prettier --write './sdk/src/**/*.ts' './tests/**.ts' './cli/**.ts'",
51-
"lint": "eslint . --ext ts --quiet",
51+
"lint": "eslint . --ext ts --quiet --format unix",
5252
"lint:fix": "eslint . --ext ts --fix",
53-
"update-idl": "cp target/idl/drift.json sdk/src/idl/drift.json"
53+
"update-idl": "anchor build -- --features anchor-test && cp target/idl/drift.json sdk/src/idl/drift.json"
5454
},
5555
"engines": {
5656
"node": ">=12"
57+
},
58+
"resolutions": {
59+
"chalk": "4.1.2",
60+
"debug": "<4.4.2",
61+
"ansi-styles": "4.3.0",
62+
"supports-color": "7.2.0",
63+
"strip-ansi": "6.0.1",
64+
"ansi-regex": "5.0.1",
65+
"wrap-ansi": "7.0.0",
66+
"color-convert": "<3.1.1",
67+
"color-name": "<2.0.1",
68+
"color-string": "<2.1.1",
69+
"simple-swizzle": "<0.2.3",
70+
"is-arrayish": "<0.3.3",
71+
"slice-ansi": "3.0.0",
72+
"error-ex": "<1.3.3",
73+
"backslash": "<0.2.1",
74+
"chalk-template": "<1.1.1",
75+
"supports-hyperlinks": "<4.1.1",
76+
"has-ansi": "<6.0.1"
77+
},
78+
"overrides": {
79+
"chalk": "4.1.2",
80+
"debug": "<4.4.2",
81+
"ansi-styles": "4.3.0",
82+
"supports-color": "7.2.0",
83+
"strip-ansi": "6.0.1",
84+
"ansi-regex": "5.0.1",
85+
"wrap-ansi": "7.0.0",
86+
"color-convert": "<3.1.1",
87+
"color-name": "<2.0.1",
88+
"color-string": "<2.1.1",
89+
"simple-swizzle": "<0.2.3",
90+
"is-arrayish": "<0.3.3",
91+
"slice-ansi": "3.0.0",
92+
"error-ex": "<1.3.3",
93+
"backslash": "<0.2.1",
94+
"chalk-template": "<1.1.1",
95+
"supports-hyperlinks": "<4.1.1",
96+
"has-ansi": "<6.0.1"
5797
}
5898
}

programs/drift/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "drift"
3-
version = "2.136.0"
3+
version = "2.138.0"
44
description = "Created with Anchor"
55
edition = "2018"
66

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/amm/tests.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ fn formualic_k_tests() {
133133
confidence: 0,
134134
delay: 2,
135135
has_sufficient_number_of_data_points: true,
136+
sequence_id: None,
136137
};
137138

138139
// zero funding cost
@@ -192,6 +193,7 @@ fn iterative_bounds_formualic_k_tests() {
192193
confidence: 0,
193194
delay: 2,
194195
has_sufficient_number_of_data_points: true,
196+
sequence_id: None,
195197
};
196198

197199
// negative funding cost
@@ -236,6 +238,7 @@ fn iterative_no_bounds_formualic_k_tests() {
236238
confidence: 0,
237239
delay: 2,
238240
has_sufficient_number_of_data_points: true,
241+
sequence_id: None,
239242
};
240243

241244
// negative funding cost

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: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,7 @@ use crate::math::spot_balance::{get_signed_token_amount, get_token_amount};
5151
use crate::math::spot_swap::select_margin_type_for_swap;
5252
use crate::math::{amm, fees, margin::*, orders::*};
5353
use crate::print_error;
54-
use crate::state::events::{
55-
emit_stack, get_order_action_record, LPAction, LPRecord, OrderActionRecord, OrderRecord,
56-
};
54+
use crate::state::events::{emit_stack, get_order_action_record, OrderActionRecord, OrderRecord};
5755
use crate::state::events::{OrderAction, OrderActionExplanation};
5856
use crate::state::fill_mode::FillMode;
5957
use crate::state::fulfillment::{PerpFulfillmentMethod, SpotFulfillmentMethod};
@@ -1001,23 +999,12 @@ pub fn fill_perp_order(
1001999
.position(|order| order.order_id == order_id && order.status == OrderStatus::Open)
10021000
.ok_or_else(print_error!(ErrorCode::OrderDoesNotExist))?;
10031001

1004-
let (
1005-
order_status,
1006-
market_index,
1007-
order_market_type,
1008-
order_price,
1009-
order_oracle_price_offset,
1010-
order_direction,
1011-
order_auction_duration,
1012-
) = get_struct_values!(
1002+
let (order_status, market_index, order_market_type, order_direction) = get_struct_values!(
10131003
user.orders[order_index],
10141004
status,
10151005
market_index,
10161006
market_type,
1017-
price,
1018-
oracle_price_offset,
1019-
direction,
1020-
auction_duration
1007+
direction
10211008
);
10221009

10231010
validate!(
@@ -2229,12 +2216,13 @@ pub fn fulfill_perp_order_with_amm(
22292216
};
22302217

22312218
// if user position is less than min order size, step size is the threshold
2232-
let amm_size_threshold =
2233-
if existing_base_asset_amount.unsigned_abs() > market.amm.min_order_size {
2234-
market.amm.min_order_size
2235-
} else {
2236-
market.amm.order_step_size
2237-
};
2219+
let amm_size_threshold = if !user.orders[order_index].reduce_only
2220+
&& existing_base_asset_amount.unsigned_abs() > market.amm.min_order_size
2221+
{
2222+
market.amm.min_order_size
2223+
} else {
2224+
market.amm.order_step_size
2225+
};
22382226

22392227
if base_asset_amount < amm_size_threshold {
22402228
// if is an actual swap (and not amm jit order) then msg!
@@ -2316,7 +2304,7 @@ pub fn fulfill_perp_order_with_amm(
23162304
filler_reward,
23172305
referee_discount,
23182306
referrer_reward,
2319-
fee_to_market_for_lp,
2307+
fee_to_market_for_lp: _fee_to_market_for_lp,
23202308
maker_rebate,
23212309
builder_fee,
23222310
} = fees::calculate_fee_for_fulfillment_with_amm(
@@ -2340,9 +2328,6 @@ pub fn fulfill_perp_order_with_amm(
23402328
order.fees_accrued = order.fees_accrued.safe_add(builder_fee)?;
23412329
}
23422330

2343-
let user_position_delta =
2344-
get_position_delta_for_fill(base_asset_amount, quote_asset_amount, order_direction)?;
2345-
23462331
// Increment the protocol's total fee variables
23472332
market.amm.total_fee = market.amm.total_fee.safe_add(fee_to_market.cast()?)?;
23482333
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};

0 commit comments

Comments
 (0)