@drift-labs/sdk
Advanced tools
Comparing version 2.12.0-beta.1 to 2.12.0-beta.2
@@ -6,7 +6,8 @@ "use strict"; | ||
function exchangePaused(state) { | ||
return (0, types_1.isVariant)(state.exchangeStatus, 'paused'); | ||
return state.exchangeStatus !== types_1.ExchangeStatus.ACTIVE; | ||
} | ||
exports.exchangePaused = exchangePaused; | ||
function fillPaused(state, market) { | ||
return ((0, types_1.isOneOfVariant)(state.exchangeStatus, ['paused', 'fillPaused']) || | ||
return ((state.exchangeStatus & types_1.ExchangeStatus.FILL_PAUSED) === | ||
types_1.ExchangeStatus.FILL_PAUSED || | ||
(0, types_1.isOneOfVariant)(market.status, ['paused', 'fillPaused'])); | ||
@@ -16,5 +17,6 @@ } | ||
function ammPaused(state, market) { | ||
return ((0, types_1.isOneOfVariant)(state.exchangeStatus, ['paused', 'ammPaused']) || | ||
return ((state.exchangeStatus & types_1.ExchangeStatus.AMM_PAUSED) === | ||
types_1.ExchangeStatus.AMM_PAUSED || | ||
(0, types_1.isOneOfVariant)(market.status, ['paused', 'ammPaused'])); | ||
} | ||
exports.ammPaused = ammPaused; |
/// <reference types="bn.js" /> | ||
import { PublicKey, Transaction } from '@solana/web3.js'; | ||
import { BN } from '.'; | ||
export declare class ExchangeStatus { | ||
static readonly ACTIVE: { | ||
active: {}; | ||
}; | ||
static readonly FUNDING_PAUSED: { | ||
fundingPaused: {}; | ||
}; | ||
static readonly AMM_PAUSED: { | ||
ammPaused: {}; | ||
}; | ||
static readonly FILL_PAUSED: { | ||
fillPaused: {}; | ||
}; | ||
static readonly LIQ_PAUSED: { | ||
liqPaused: {}; | ||
}; | ||
static readonly WITHDRAW_PAUSED: { | ||
withdrawPaused: {}; | ||
}; | ||
static readonly PAUSED: { | ||
paused: {}; | ||
}; | ||
export declare enum ExchangeStatus { | ||
ACTIVE = 0, | ||
DEPOSIT_PAUSED = 1, | ||
WITHDRAW_PAUSED = 2, | ||
AMM_PAUSED = 4, | ||
FILL_PAUSED = 8, | ||
LIQ_PAUSED = 16, | ||
FUNDING_PAUSED = 32, | ||
SETTLE_PNL_PAUSED = 64, | ||
PAUSED = 127 | ||
} | ||
@@ -590,3 +578,3 @@ export declare class MarketStatus { | ||
admin: PublicKey; | ||
exchangeStatus: ExchangeStatus; | ||
exchangeStatus: number; | ||
whitelistMint: PublicKey; | ||
@@ -593,0 +581,0 @@ discountMint: PublicKey; |
@@ -6,12 +6,14 @@ "use strict"; | ||
// # Utility Types / Enums / Constants | ||
class ExchangeStatus { | ||
} | ||
exports.ExchangeStatus = ExchangeStatus; | ||
ExchangeStatus.ACTIVE = { active: {} }; | ||
ExchangeStatus.FUNDING_PAUSED = { fundingPaused: {} }; | ||
ExchangeStatus.AMM_PAUSED = { ammPaused: {} }; | ||
ExchangeStatus.FILL_PAUSED = { fillPaused: {} }; | ||
ExchangeStatus.LIQ_PAUSED = { liqPaused: {} }; | ||
ExchangeStatus.WITHDRAW_PAUSED = { withdrawPaused: {} }; | ||
ExchangeStatus.PAUSED = { paused: {} }; | ||
var ExchangeStatus; | ||
(function (ExchangeStatus) { | ||
ExchangeStatus[ExchangeStatus["ACTIVE"] = 0] = "ACTIVE"; | ||
ExchangeStatus[ExchangeStatus["DEPOSIT_PAUSED"] = 1] = "DEPOSIT_PAUSED"; | ||
ExchangeStatus[ExchangeStatus["WITHDRAW_PAUSED"] = 2] = "WITHDRAW_PAUSED"; | ||
ExchangeStatus[ExchangeStatus["AMM_PAUSED"] = 4] = "AMM_PAUSED"; | ||
ExchangeStatus[ExchangeStatus["FILL_PAUSED"] = 8] = "FILL_PAUSED"; | ||
ExchangeStatus[ExchangeStatus["LIQ_PAUSED"] = 16] = "LIQ_PAUSED"; | ||
ExchangeStatus[ExchangeStatus["FUNDING_PAUSED"] = 32] = "FUNDING_PAUSED"; | ||
ExchangeStatus[ExchangeStatus["SETTLE_PNL_PAUSED"] = 64] = "SETTLE_PNL_PAUSED"; | ||
ExchangeStatus[ExchangeStatus["PAUSED"] = 127] = "PAUSED"; | ||
})(ExchangeStatus = exports.ExchangeStatus || (exports.ExchangeStatus = {})); | ||
class MarketStatus { | ||
@@ -18,0 +20,0 @@ } |
@@ -800,3 +800,3 @@ "use strict"; | ||
if (totalPositionValueAfterTrade.lte(freeCollateralExcludingTargetMarket) && | ||
proposedPerpPosition.baseAssetAmount.abs().gt(numericConstants_1.ZERO)) { | ||
proposedPerpPosition.baseAssetAmount.gt(numericConstants_1.ZERO)) { | ||
return new _1.BN(-1); | ||
@@ -803,0 +803,0 @@ } |
{ | ||
"name": "@drift-labs/sdk", | ||
"version": "2.12.0-beta.1", | ||
"version": "2.12.0-beta.2", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "types": "lib/index.d.ts", |
import { | ||
ExchangeStatus, | ||
isOneOfVariant, | ||
isVariant, | ||
PerpMarketAccount, | ||
@@ -10,3 +10,3 @@ SpotMarketAccount, | ||
export function exchangePaused(state: StateAccount): boolean { | ||
return isVariant(state.exchangeStatus, 'paused'); | ||
return state.exchangeStatus !== ExchangeStatus.ACTIVE; | ||
} | ||
@@ -19,3 +19,4 @@ | ||
return ( | ||
isOneOfVariant(state.exchangeStatus, ['paused', 'fillPaused']) || | ||
(state.exchangeStatus & ExchangeStatus.FILL_PAUSED) === | ||
ExchangeStatus.FILL_PAUSED || | ||
isOneOfVariant(market.status, ['paused', 'fillPaused']) | ||
@@ -30,5 +31,6 @@ ); | ||
return ( | ||
isOneOfVariant(state.exchangeStatus, ['paused', 'ammPaused']) || | ||
(state.exchangeStatus & ExchangeStatus.AMM_PAUSED) === | ||
ExchangeStatus.AMM_PAUSED || | ||
isOneOfVariant(market.status, ['paused', 'ammPaused']) | ||
); | ||
} |
@@ -6,10 +6,12 @@ import { PublicKey, Transaction } from '@solana/web3.js'; | ||
export class ExchangeStatus { | ||
static readonly ACTIVE = { active: {} }; | ||
static readonly FUNDING_PAUSED = { fundingPaused: {} }; | ||
static readonly AMM_PAUSED = { ammPaused: {} }; | ||
static readonly FILL_PAUSED = { fillPaused: {} }; | ||
static readonly LIQ_PAUSED = { liqPaused: {} }; | ||
static readonly WITHDRAW_PAUSED = { withdrawPaused: {} }; | ||
static readonly PAUSED = { paused: {} }; | ||
export enum ExchangeStatus { | ||
ACTIVE = 0, | ||
DEPOSIT_PAUSED = 1, | ||
WITHDRAW_PAUSED = 2, | ||
AMM_PAUSED = 4, | ||
FILL_PAUSED = 8, | ||
LIQ_PAUSED = 16, | ||
FUNDING_PAUSED = 32, | ||
SETTLE_PNL_PAUSED = 64, | ||
PAUSED = 127, | ||
} | ||
@@ -505,3 +507,3 @@ | ||
admin: PublicKey; | ||
exchangeStatus: ExchangeStatus; | ||
exchangeStatus: number; | ||
whitelistMint: PublicKey; | ||
@@ -508,0 +510,0 @@ discountMint: PublicKey; |
@@ -1338,3 +1338,3 @@ import { PublicKey } from '@solana/web3.js'; | ||
totalPositionValueAfterTrade.lte(freeCollateralExcludingTargetMarket) && | ||
proposedPerpPosition.baseAssetAmount.abs().gt(ZERO) | ||
proposedPerpPosition.baseAssetAmount.gt(ZERO) | ||
) { | ||
@@ -1341,0 +1341,0 @@ return new BN(-1); |
@@ -22,3 +22,2 @@ import { Connection, Keypair, PublicKey } from '@solana/web3.js'; | ||
OrderRecord, | ||
ExchangeStatus, | ||
ZERO, | ||
@@ -482,3 +481,3 @@ ContractTier, | ||
discountMint: PublicKey.default, | ||
exchangeStatus: ExchangeStatus.ACTIVE, | ||
exchangeStatus: 0, | ||
liquidationMarginBufferRatio: 0, | ||
@@ -485,0 +484,0 @@ lpCooldownTime: new BN(0), |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1802268
56169