Skip to content

Commit a3e3551

Browse files
authored
program: add-market-settle-rev-pool-pause-operation (#2013)
* program: add-market-settle-rev-pool-pause-operation * rm old handle ix * add logic to handle_update and logging
1 parent da2bd97 commit a3e3551

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

programs/drift/src/controller/amm.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::math::{amm, amm_spread, bn, cp_curve, quote_asset::*};
2929

3030
use crate::state::events::CurveRecord;
3131
use crate::state::oracle::OraclePriceData;
32+
use crate::state::paused_operations::PerpOperation;
3233
use crate::state::perp_market::{PerpMarket, AMM};
3334
use crate::state::spot_market::{SpotBalance, SpotBalanceType, SpotMarket};
3435
use crate::state::user::{SpotPosition, User};
@@ -499,6 +500,10 @@ fn calculate_revenue_pool_transfer(
499500
// 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
500501
// Otherwise, spull from the revenue pool (up to a constraint amount)
501502

503+
if market.is_operation_paused(PerpOperation::SettleRevPool) {
504+
return Ok(0);
505+
}
506+
502507
let amm_budget_surplus =
503508
terminal_state_surplus.saturating_sub(FEE_POOL_TO_REVENUE_POOL_THRESHOLD.cast()?);
504509

programs/drift/src/instructions/admin.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3357,7 +3357,8 @@ pub fn handle_update_perp_market_paused_operations(
33573357

33583358
if *ctx.accounts.admin.key != ctx.accounts.state.admin {
33593359
validate!(
3360-
paused_operations == PerpOperation::UpdateFunding as u8,
3360+
paused_operations == PerpOperation::UpdateFunding as u8
3361+
|| paused_operations == PerpOperation::SettleRevPool as u8,
33613362
ErrorCode::DefaultError,
33623363
"signer must be admin",
33633364
)?;

programs/drift/src/state/paused_operations.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ pub enum PerpOperation {
1212
SettlePnlWithPosition = 0b00010000,
1313
Liquidation = 0b00100000,
1414
AmmImmediateFill = 0b01000000,
15+
SettleRevPool = 0b10000000,
1516
}
1617

17-
const ALL_PERP_OPERATIONS: [PerpOperation; 7] = [
18+
const ALL_PERP_OPERATIONS: [PerpOperation; 8] = [
1819
PerpOperation::UpdateFunding,
1920
PerpOperation::AmmFill,
2021
PerpOperation::Fill,
2122
PerpOperation::SettlePnl,
2223
PerpOperation::SettlePnlWithPosition,
2324
PerpOperation::Liquidation,
2425
PerpOperation::AmmImmediateFill,
26+
PerpOperation::SettleRevPool,
2527
];
2628

2729
impl PerpOperation {

sdk/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export enum PerpOperation {
5454
SETTLE_PNL = 8,
5555
SETTLE_PNL_WITH_POSITION = 16,
5656
LIQUIDATION = 32,
57+
SETTLE_REV_POOL = 64,
5758
}
5859

5960
export enum SpotOperation {

0 commit comments

Comments
 (0)