Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions programs/drift/src/controller/amm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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()?);

Expand Down
3 changes: 2 additions & 1 deletion programs/drift/src/instructions/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)?;
Expand Down
4 changes: 3 additions & 1 deletion programs/drift/src/state/paused_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ pub enum PerpOperation {
SettlePnlWithPosition = 0b00010000,
Liquidation = 0b00100000,
AmmImmediateFill = 0b01000000,
SettleRevPool = 0b10000000,
}

const ALL_PERP_OPERATIONS: [PerpOperation; 7] = [
const ALL_PERP_OPERATIONS: [PerpOperation; 8] = [
PerpOperation::UpdateFunding,
PerpOperation::AmmFill,
PerpOperation::Fill,
PerpOperation::SettlePnl,
PerpOperation::SettlePnlWithPosition,
PerpOperation::Liquidation,
PerpOperation::AmmImmediateFill,
PerpOperation::SettleRevPool,
];

impl PerpOperation {
Expand Down
1 change: 1 addition & 0 deletions sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export enum PerpOperation {
SETTLE_PNL = 8,
SETTLE_PNL_WITH_POSITION = 16,
LIQUIDATION = 32,
SETTLE_REV_POOL = 64,
}

export enum SpotOperation {
Expand Down
Loading