From a550afdedad327a29fc98a81ce4680a4592a0612 Mon Sep 17 00:00:00 2001 From: 0xbigz <83473873+0xbigz@users.noreply.github.com> Date: Mon, 3 Nov 2025 18:13:04 -0500 Subject: [PATCH 1/3] program: add-market-settle-rev-pool-pause-operation --- programs/drift/src/controller/amm.rs | 5 +++++ programs/drift/src/instructions/admin.rs | 7 +++++++ programs/drift/src/state/paused_operations.rs | 1 + sdk/src/types.ts | 1 + 4 files changed, 14 insertions(+) diff --git a/programs/drift/src/controller/amm.rs b/programs/drift/src/controller/amm.rs index 7162e9d2dd..e25a578bf6 100644 --- a/programs/drift/src/controller/amm.rs +++ b/programs/drift/src/controller/amm.rs @@ -29,6 +29,7 @@ use crate::math::{amm, amm_spread, bn, cp_curve, quote_asset::*}; use crate::state::events::CurveRecord; use crate::state::oracle::OraclePriceData; +use crate::state::paused_operations::PerpOperation; use crate::state::perp_market::{PerpMarket, AMM}; use crate::state::spot_market::{SpotBalance, SpotBalanceType, SpotMarket}; use crate::state::user::{SpotPosition, User}; @@ -499,6 +500,10 @@ fn calculate_revenue_pool_transfer( // If the AMM budget is above `FEE_POOL_TO_REVENUE_POOL_THRESHOLD` (in surplus), settle fees collected to the revenue pool depending on the health of the AMM state // Otherwise, spull from the revenue pool (up to a constraint amount) + if market.is_operation_paused(PerpOperation::SettleRevPool) { + return Ok(0); + } + let amm_budget_surplus = terminal_state_surplus.saturating_sub(FEE_POOL_TO_REVENUE_POOL_THRESHOLD.cast()?); diff --git a/programs/drift/src/instructions/admin.rs b/programs/drift/src/instructions/admin.rs index 35d665c0f0..8c56028767 100644 --- a/programs/drift/src/instructions/admin.rs +++ b/programs/drift/src/instructions/admin.rs @@ -5154,6 +5154,13 @@ pub fn handle_update_delegate_user_gov_token_insurance_stake( Ok(()) } +pub fn handle_update_amm_fee_revenue_pool_withdraw( + ctx: Context, + enable: bool, +) -> Result<()> { + Ok(()) +} + pub fn handle_update_feature_bit_flags_builder_codes( ctx: Context, enable: bool, diff --git a/programs/drift/src/state/paused_operations.rs b/programs/drift/src/state/paused_operations.rs index 516470460a..8b8a34c2ad 100644 --- a/programs/drift/src/state/paused_operations.rs +++ b/programs/drift/src/state/paused_operations.rs @@ -12,6 +12,7 @@ pub enum PerpOperation { SettlePnlWithPosition = 0b00010000, Liquidation = 0b00100000, AmmImmediateFill = 0b01000000, + SettleRevPool = 0b10000000, } const ALL_PERP_OPERATIONS: [PerpOperation; 7] = [ diff --git a/sdk/src/types.ts b/sdk/src/types.ts index ee5ff35422..12c54d5ef4 100644 --- a/sdk/src/types.ts +++ b/sdk/src/types.ts @@ -54,6 +54,7 @@ export enum PerpOperation { SETTLE_PNL = 8, SETTLE_PNL_WITH_POSITION = 16, LIQUIDATION = 32, + SETTLE_REV_POOL = 64, } export enum SpotOperation { From de71bbf0147ba7b504ba99d8f08646409658b3fd Mon Sep 17 00:00:00 2001 From: 0xbigz <83473873+0xbigz@users.noreply.github.com> Date: Mon, 3 Nov 2025 18:14:03 -0500 Subject: [PATCH 2/3] rm old handle ix --- programs/drift/src/instructions/admin.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/programs/drift/src/instructions/admin.rs b/programs/drift/src/instructions/admin.rs index 8c56028767..35d665c0f0 100644 --- a/programs/drift/src/instructions/admin.rs +++ b/programs/drift/src/instructions/admin.rs @@ -5154,13 +5154,6 @@ pub fn handle_update_delegate_user_gov_token_insurance_stake( Ok(()) } -pub fn handle_update_amm_fee_revenue_pool_withdraw( - ctx: Context, - enable: bool, -) -> Result<()> { - Ok(()) -} - pub fn handle_update_feature_bit_flags_builder_codes( ctx: Context, enable: bool, From 4aedfb1bb85df08e250e622e84395372851f87de Mon Sep 17 00:00:00 2001 From: 0xbigz <83473873+0xbigz@users.noreply.github.com> Date: Mon, 3 Nov 2025 18:21:04 -0500 Subject: [PATCH 3/3] add logic to handle_update and logging --- programs/drift/src/instructions/admin.rs | 3 ++- programs/drift/src/state/paused_operations.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/programs/drift/src/instructions/admin.rs b/programs/drift/src/instructions/admin.rs index 35d665c0f0..6984caa71d 100644 --- a/programs/drift/src/instructions/admin.rs +++ b/programs/drift/src/instructions/admin.rs @@ -3357,7 +3357,8 @@ pub fn handle_update_perp_market_paused_operations( if *ctx.accounts.admin.key != ctx.accounts.state.admin { validate!( - paused_operations == PerpOperation::UpdateFunding as u8, + paused_operations == PerpOperation::UpdateFunding as u8 + || paused_operations == PerpOperation::SettleRevPool as u8, ErrorCode::DefaultError, "signer must be admin", )?; diff --git a/programs/drift/src/state/paused_operations.rs b/programs/drift/src/state/paused_operations.rs index 8b8a34c2ad..439dbcce6e 100644 --- a/programs/drift/src/state/paused_operations.rs +++ b/programs/drift/src/state/paused_operations.rs @@ -15,7 +15,7 @@ pub enum PerpOperation { SettleRevPool = 0b10000000, } -const ALL_PERP_OPERATIONS: [PerpOperation; 7] = [ +const ALL_PERP_OPERATIONS: [PerpOperation; 8] = [ PerpOperation::UpdateFunding, PerpOperation::AmmFill, PerpOperation::Fill, @@ -23,6 +23,7 @@ const ALL_PERP_OPERATIONS: [PerpOperation; 7] = [ PerpOperation::SettlePnlWithPosition, PerpOperation::Liquidation, PerpOperation::AmmImmediateFill, + PerpOperation::SettleRevPool, ]; impl PerpOperation {