Skip to content

Commit 54088e6

Browse files
committed
merge master
2 parents 3cab1fc + d7bc3ee commit 54088e6

File tree

21 files changed

+738
-253
lines changed

21 files changed

+738
-253
lines changed

CHANGELOG.md

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

1414
### Breaking
1515

16+
## [2.145.0] - 2025-10-28
17+
18+
### Features
19+
20+
- dlp ([#1885](https://github.com/drift-labs/protocol-v2/pull/1885))
21+
22+
### Fixes
23+
24+
### Breaking
25+
1626
## [2.144.0] - 2025-10-27
1727

1828
### Features

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.

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.144.0"
3+
version = "2.145.0"
44
description = "Created with Anchor"
55
edition = "2018"
66

programs/drift/src/instructions/admin.rs

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,15 +1135,37 @@ pub fn handle_initialize_perp_market(
11351135

11361136
pub fn handle_initialize_amm_cache(ctx: Context<InitializeAmmCache>) -> Result<()> {
11371137
let amm_cache = &mut ctx.accounts.amm_cache;
1138-
let state = &ctx.accounts.state;
1139-
amm_cache
1140-
.cache
1141-
.resize_with(state.number_of_markets as usize, CacheInfo::default);
11421138
amm_cache.bump = ctx.bumps.amm_cache;
11431139

11441140
Ok(())
11451141
}
11461142

1143+
pub fn handle_resize_amm_cache(ctx: Context<ResizeAmmCache>) -> Result<()> {
1144+
let amm_cache = &mut ctx.accounts.amm_cache;
1145+
let state = &ctx.accounts.state;
1146+
let current_size = amm_cache.cache.len();
1147+
let new_size = (state.number_of_markets as usize).min(current_size + 20_usize);
1148+
1149+
msg!(
1150+
"resizing amm cache from {} entries to {}",
1151+
current_size,
1152+
new_size
1153+
);
1154+
1155+
let growth = new_size.saturating_sub(current_size);
1156+
validate!(
1157+
growth <= 20,
1158+
ErrorCode::DefaultError,
1159+
"cannot grow amm_cache by more than 20 entries in a single resize (requested +{})",
1160+
growth
1161+
)?;
1162+
1163+
amm_cache.cache.resize_with(new_size, CacheInfo::default);
1164+
amm_cache.validate(state)?;
1165+
1166+
Ok(())
1167+
}
1168+
11471169
#[access_control(
11481170
perp_market_valid(&ctx.accounts.perp_market)
11491171
)]
@@ -5511,7 +5533,7 @@ pub struct InitializeAmmCache<'info> {
55115533
#[account(
55125534
init,
55135535
seeds = [AMM_POSITIONS_CACHE.as_ref()],
5514-
space = AmmCache::space(state.number_of_markets as usize),
5536+
space = AmmCache::init_space(),
55155537
bump,
55165538
payer = admin
55175539
)]
@@ -5520,6 +5542,27 @@ pub struct InitializeAmmCache<'info> {
55205542
pub system_program: Program<'info, System>,
55215543
}
55225544

5545+
#[derive(Accounts)]
5546+
pub struct ResizeAmmCache<'info> {
5547+
#[account(
5548+
mut,
5549+
constraint = admin.key() == admin_hot_wallet::id() || admin.key() == state.admin
5550+
)]
5551+
pub admin: Signer<'info>,
5552+
pub state: Box<Account<'info, State>>,
5553+
#[account(
5554+
mut,
5555+
seeds = [AMM_POSITIONS_CACHE.as_ref()],
5556+
bump,
5557+
realloc = AmmCache::space(amm_cache.cache.len() + (state.number_of_markets as usize - amm_cache.cache.len()).min(20_usize)),
5558+
realloc::payer = admin,
5559+
realloc::zero = false,
5560+
)]
5561+
pub amm_cache: Box<Account<'info, AmmCache>>,
5562+
pub rent: Sysvar<'info, Rent>,
5563+
pub system_program: Program<'info, System>,
5564+
}
5565+
55235566
#[derive(Accounts)]
55245567
pub struct DeleteInitializedPerpMarket<'info> {
55255568
#[account(mut)]

programs/drift/src/instructions/keeper.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,9 @@ pub fn place_signed_msg_taker_order<'c: 'info, 'info>(
849849
taker.update_perp_position_max_margin_ratio(market_index, max_margin_ratio)?;
850850
}
851851

852-
if let Some(isolated_position_deposit) = verified_message_and_signature.isolated_position_deposit {
852+
if let Some(isolated_position_deposit) =
853+
verified_message_and_signature.isolated_position_deposit
854+
{
853855
spot_market_map.update_writable_spot_market(0)?;
854856
transfer_isolated_perp_position_deposit(
855857
taker,

programs/drift/src/instructions/user.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,6 +3909,7 @@ pub fn handle_begin_swap<'c: 'info, 'info>(
39093909
)?;
39103910
}
39113911
} else {
3912+
let mut whitelisted_programs = WHITELISTED_SWAP_PROGRAMS.to_vec();
39123913
let mut whitelisted_programs = WHITELISTED_SWAP_PROGRAMS.to_vec();
39133914
if !delegate_is_signer {
39143915
whitelisted_programs.push(Token::id());

programs/drift/src/state/amm_cache.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,19 @@ impl HasLen for AmmCacheFixed {
175175
}
176176

177177
impl AmmCache {
178+
pub fn init_space() -> usize {
179+
8 + 8 + 4
180+
}
181+
178182
pub fn space(num_markets: usize) -> usize {
179183
8 + 8 + 4 + num_markets * CacheInfo::SIZE
180184
}
181185

182186
pub fn validate(&self, state: &State) -> DriftResult<()> {
183187
validate!(
184-
self.cache.len() == state.number_of_markets as usize,
188+
self.cache.len() <= state.number_of_markets as usize,
185189
ErrorCode::DefaultError,
186-
"Number of amm positions is different than number of markets"
190+
"Number of amm positions is no larger than number of markets"
187191
)?;
188192
Ok(())
189193
}

programs/drift/src/state/lp_pool.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::collections::BTreeMap;
2-
use std::f32::consts::E;
32

43
use crate::error::{DriftResult, ErrorCode};
54
use crate::math::casting::Cast;

sdk/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.145.0-beta.2
1+
2.146.0-beta.2

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@drift-labs/sdk",
3-
"version": "2.145.0-beta.2",
3+
"version": "2.146.0-beta.2",
44
"main": "lib/node/index.js",
55
"types": "lib/node/index.d.ts",
66
"module": "./lib/browser/index.js",

0 commit comments

Comments
 (0)