Skip to content

Commit

Permalink
sdk: add support for paused operations in dlob
Browse files Browse the repository at this point in the history
  • Loading branch information
crispheaney committed Feb 8, 2024
1 parent 5760a30 commit adb90df
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
30 changes: 22 additions & 8 deletions sdk/src/math/exchangeStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,36 @@ export function fillPaused(
state: StateAccount,
market: PerpMarketAccount | SpotMarketAccount
): boolean {
return (
if (
(state.exchangeStatus & ExchangeStatus.FILL_PAUSED) ===
ExchangeStatus.FILL_PAUSED ||
isOneOfVariant(market.status, ['paused', 'fillPaused'])
);
ExchangeStatus.FILL_PAUSED
) {
return true;
}

if (market.hasOwnProperty('amm')) {
return isOperationPaused(market.pausedOperations, PerpOperation.FILL);
} else {
return isOperationPaused(market.pausedOperations, SpotOperation.FILL);
}
}

export function ammPaused(
state: StateAccount,
market: PerpMarketAccount | SpotMarketAccount
): boolean {
return (
if (
(state.exchangeStatus & ExchangeStatus.AMM_PAUSED) ===
ExchangeStatus.AMM_PAUSED ||
isOneOfVariant(market.status, ['paused', 'ammPaused'])
);
ExchangeStatus.AMM_PAUSED
) {
return true;
}

if (market.hasOwnProperty('amm')) {
return isOperationPaused(market.pausedOperations, PerpOperation.AMM_FILL);
} else {
return false;
}
}

export function isOperationPaused(
Expand Down
3 changes: 3 additions & 0 deletions sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ export type PerpMarketAccount = {
};
quoteSpotMarketIndex: number;
feeAdjustment: number;
pausedOperations: number;
};

export type HistoricalOracleData = {
Expand Down Expand Up @@ -700,6 +701,8 @@ export type SpotMarketAccount = {
flashLoanInitialTokenAmount: BN;

ordersEnabled: boolean;

pausedOperations: number;
};

export type PoolBalance = {
Expand Down

0 comments on commit adb90df

Please sign in to comment.