@drift-labs/sdk 2.146.0-beta.8 → 2.147.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/VERSION +1 -1
- package/lib/browser/accounts/grpcMultiUserAccountSubscriber.js +8 -1
- package/lib/browser/adminClient.d.ts +3 -3
- package/lib/browser/adminClient.js +13 -17
- package/lib/browser/constants/numericConstants.d.ts +2 -0
- package/lib/browser/constants/numericConstants.js +5 -1
- package/lib/browser/constants/perpMarkets.d.ts +2 -1
- package/lib/browser/constants/perpMarkets.js +31 -2
- package/lib/browser/constants/spotMarkets.d.ts +2 -0
- package/lib/browser/driftClient.d.ts +22 -12
- package/lib/browser/driftClient.js +37 -25
- package/lib/browser/idl/drift.json +38 -251
- package/lib/browser/math/superStake.d.ts +1 -1
- package/lib/browser/math/superStake.js +1 -1
- package/lib/browser/swap/UnifiedSwapClient.d.ts +28 -3
- package/lib/browser/swap/UnifiedSwapClient.js +2 -2
- package/lib/browser/types.d.ts +3 -1
- package/lib/browser/types.js +1 -0
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.d.ts.map +1 -1
- package/lib/node/accounts/grpcMultiUserAccountSubscriber.js +8 -1
- package/lib/node/adminClient.d.ts +3 -3
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/adminClient.js +13 -17
- package/lib/node/constants/numericConstants.d.ts +2 -0
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +5 -1
- package/lib/node/constants/perpMarkets.d.ts +2 -1
- package/lib/node/constants/perpMarkets.d.ts.map +1 -1
- package/lib/node/constants/perpMarkets.js +31 -2
- package/lib/node/constants/spotMarkets.d.ts +2 -0
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/driftClient.d.ts +22 -12
- package/lib/node/driftClient.d.ts.map +1 -1
- package/lib/node/driftClient.js +37 -25
- package/lib/node/idl/drift.json +38 -251
- package/lib/node/math/superStake.d.ts +1 -1
- package/lib/node/math/superStake.js +1 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts +28 -3
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/swap/UnifiedSwapClient.js +2 -2
- package/lib/node/types.d.ts +3 -1
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/types.js +1 -0
- package/package.json +1 -1
- package/src/accounts/grpcMultiUserAccountSubscriber.ts +8 -1
- package/src/adminClient.ts +28 -30
- package/src/constants/numericConstants.ts +5 -0
- package/src/constants/perpMarkets.ts +33 -4
- package/src/constants/spotMarkets.ts +2 -0
- package/src/driftClient.ts +65 -36
- package/src/idl/drift.json +39 -252
- package/src/math/superStake.ts +1 -1
- package/src/swap/UnifiedSwapClient.ts +25 -3
- package/src/types.ts +2 -0
- package/tests/dlob/helpers.ts +3 -3
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
2.147.0-beta.0
|
|
@@ -76,7 +76,10 @@ class grpcMultiUserAccountSubscriber {
|
|
|
76
76
|
this.listeners.set(key, new Set());
|
|
77
77
|
this.keyToPk.set(key, userAccountPublicKey);
|
|
78
78
|
this.pendingAddKeys.add(key);
|
|
79
|
-
this.
|
|
79
|
+
if (this.isMultiSubscribed) {
|
|
80
|
+
// only schedule flush if already subscribed to the multi-subscriber
|
|
81
|
+
this.scheduleFlush();
|
|
82
|
+
}
|
|
80
83
|
}
|
|
81
84
|
};
|
|
82
85
|
const perUser = {
|
|
@@ -110,6 +113,10 @@ class grpcMultiUserAccountSubscriber {
|
|
|
110
113
|
this.updateData(account, 0);
|
|
111
114
|
},
|
|
112
115
|
updateData(userAccount, slot) {
|
|
116
|
+
const existingData = parent.userData.get(key);
|
|
117
|
+
if (existingData && existingData.slot > slot) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
113
120
|
parent.userData.set(key, { data: userAccount, slot });
|
|
114
121
|
perUserEmitter.emit('userAccountUpdate', userAccount);
|
|
115
122
|
perUserEmitter.emit('update');
|
|
@@ -22,11 +22,11 @@ export declare class AdminClient extends DriftClient {
|
|
|
22
22
|
initializeOpenbookV2FulfillmentConfig(marketIndex: number, openbookMarket: PublicKey): Promise<TransactionSignature>;
|
|
23
23
|
getInitializeOpenbookV2FulfillmentConfigIx(marketIndex: number, openbookMarket: PublicKey): Promise<TransactionInstruction>;
|
|
24
24
|
initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionSignature>;
|
|
25
|
-
getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number
|
|
25
|
+
getInitializePerpMarketIx(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, contractTier?: ContractTier, marginRatioInitial?: number, marginRatioMaintenance?: number, liquidatorFee?: number, ifLiquidatorFee?: number, imfFactor?: number, activeStatus?: boolean, baseSpread?: number, maxSpread?: number, maxOpenInterest?: BN, maxRevenueWithdrawPerPeriod?: BN, quoteMaxInsurance?: BN, orderStepSize?: BN, orderTickSize?: BN, minOrderSize?: BN, concentrationCoefScale?: BN, curveUpdateIntensity?: number, ammJitIntensity?: number, name?: string, lpPoolId?: number): Promise<TransactionInstruction[]>;
|
|
26
26
|
initializeAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
|
|
27
27
|
getInitializeAmmCacheIx(): Promise<TransactionInstruction>;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
addMarketToAmmCache(perpMarketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
|
|
29
|
+
getAddMarketToAmmCacheIx(perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
30
30
|
deleteAmmCache(txParams?: TxParams): Promise<TransactionSignature>;
|
|
31
31
|
getDeleteAmmCacheIx(): Promise<TransactionInstruction>;
|
|
32
32
|
updateInitialAmmCacheInfo(perpMarketIndexes: number[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
@@ -207,10 +207,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
207
207
|
}
|
|
208
208
|
async initializePerpMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0) {
|
|
209
209
|
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
210
|
-
const
|
|
211
|
-
const ammCacheAccount = await this.connection.getAccountInfo(ammCachePublicKey);
|
|
212
|
-
const mustInitializeAmmCache = (ammCacheAccount === null || ammCacheAccount === void 0 ? void 0 : ammCacheAccount.data) == null;
|
|
213
|
-
const initializeMarketIxs = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name, lpPoolId, mustInitializeAmmCache);
|
|
210
|
+
const initializeMarketIxs = await this.getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name, lpPoolId);
|
|
214
211
|
const tx = await this.buildTransaction(initializeMarketIxs);
|
|
215
212
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
216
213
|
while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
|
|
@@ -224,12 +221,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
224
221
|
await this.accountSubscriber.setPerpOracleMap();
|
|
225
222
|
return txSig;
|
|
226
223
|
}
|
|
227
|
-
async getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0
|
|
224
|
+
async getInitializePerpMarketIx(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, contractTier = types_1.ContractTier.SPECULATIVE, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, ifLiquidatorFee = 10000, imfFactor = 0, activeStatus = true, baseSpread = 0, maxSpread = 142500, maxOpenInterest = numericConstants_1.ZERO, maxRevenueWithdrawPerPeriod = numericConstants_1.ZERO, quoteMaxInsurance = numericConstants_1.ZERO, orderStepSize = numericConstants_1.BASE_PRECISION.divn(10000), orderTickSize = numericConstants_1.PRICE_PRECISION.divn(100000), minOrderSize = numericConstants_1.BASE_PRECISION.divn(10000), concentrationCoefScale = numericConstants_1.ONE, curveUpdateIntensity = 0, ammJitIntensity = 0, name = userName_1.DEFAULT_MARKET_NAME, lpPoolId = 0) {
|
|
228
225
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
229
226
|
const ixs = [];
|
|
230
|
-
if (includeInitAmmCacheIx) {
|
|
231
|
-
ixs.push(await this.getInitializeAmmCacheIx());
|
|
232
|
-
}
|
|
233
227
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
234
228
|
const initPerpIx = await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, contractTier, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, lpPoolId, {
|
|
235
229
|
accounts: {
|
|
@@ -239,7 +233,6 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
239
233
|
: this.wallet.publicKey,
|
|
240
234
|
oracle: priceOracle,
|
|
241
235
|
perpMarket: perpMarketPublicKey,
|
|
242
|
-
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
243
236
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
244
237
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
245
238
|
},
|
|
@@ -260,25 +253,26 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
260
253
|
admin: this.useHotWalletAdmin
|
|
261
254
|
? this.wallet.publicKey
|
|
262
255
|
: this.getStateAccount().admin,
|
|
263
|
-
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
264
256
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
257
|
+
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
265
258
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
266
259
|
},
|
|
267
260
|
});
|
|
268
261
|
}
|
|
269
|
-
async
|
|
270
|
-
const initializeAmmCacheIx = await this.
|
|
262
|
+
async addMarketToAmmCache(perpMarketIndex, txParams) {
|
|
263
|
+
const initializeAmmCacheIx = await this.getAddMarketToAmmCacheIx(perpMarketIndex);
|
|
271
264
|
const tx = await this.buildTransaction(initializeAmmCacheIx, txParams);
|
|
272
265
|
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
273
266
|
return txSig;
|
|
274
267
|
}
|
|
275
|
-
async
|
|
276
|
-
return await this.program.instruction.
|
|
268
|
+
async getAddMarketToAmmCacheIx(perpMarketIndex) {
|
|
269
|
+
return await this.program.instruction.addMarketToAmmCache({
|
|
277
270
|
accounts: {
|
|
278
271
|
state: await this.getStatePublicKey(),
|
|
279
272
|
admin: this.useHotWalletAdmin
|
|
280
273
|
? this.wallet.publicKey
|
|
281
274
|
: this.getStateAccount().admin,
|
|
275
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
282
276
|
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
283
277
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
284
278
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
@@ -295,7 +289,9 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
295
289
|
return await this.program.instruction.deleteAmmCache({
|
|
296
290
|
accounts: {
|
|
297
291
|
state: await this.getStatePublicKey(),
|
|
298
|
-
admin: this.
|
|
292
|
+
admin: this.useHotWalletAdmin
|
|
293
|
+
? this.wallet.publicKey
|
|
294
|
+
: this.getStateAccount().admin,
|
|
299
295
|
ammCache: (0, pda_1.getAmmCachePublicKey)(this.program.programId),
|
|
300
296
|
},
|
|
301
297
|
});
|
|
@@ -2857,7 +2853,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
2857
2853
|
quote = fetchedQuote;
|
|
2858
2854
|
}
|
|
2859
2855
|
if (!quote) {
|
|
2860
|
-
throw new Error(
|
|
2856
|
+
throw new Error('Could not fetch swap quote. Please try again.');
|
|
2861
2857
|
}
|
|
2862
2858
|
const isExactOut = swapMode === 'ExactOut' || quote.swapMode === 'ExactOut';
|
|
2863
2859
|
const amountIn = new anchor_1.BN(quote.inAmount);
|
|
@@ -2895,7 +2891,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
2895
2891
|
amountIn: isExactOut ? exactOutBufferedAmountIn : amountIn,
|
|
2896
2892
|
inTokenAccount: inAssociatedTokenAccount,
|
|
2897
2893
|
outTokenAccount: outAssociatedTokenAccount,
|
|
2898
|
-
});
|
|
2894
|
+
}, true);
|
|
2899
2895
|
const ixs = [
|
|
2900
2896
|
...preInstructions,
|
|
2901
2897
|
beginSwapIx,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MARGIN_PRECISION = exports.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO = exports.PRICE_TO_QUOTE_PRECISION = exports.PRICE_DIV_PEG = exports.AMM_TO_QUOTE_PRECISION_RATIO = exports.BASE_PRECISION_EXP = exports.BASE_PRECISION = exports.AMM_RESERVE_PRECISION = exports.PEG_PRECISION = exports.FUNDING_RATE_BUFFER_PRECISION = exports.FUNDING_RATE_PRECISION = exports.PRICE_PRECISION = exports.QUOTE_PRECISION = exports.LIQUIDATION_FEE_PRECISION = exports.SPOT_MARKET_IMF_PRECISION = exports.SPOT_MARKET_IMF_PRECISION_EXP = exports.SPOT_MARKET_BALANCE_PRECISION = exports.SPOT_MARKET_BALANCE_PRECISION_EXP = exports.SPOT_MARKET_WEIGHT_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION_EXP = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP = exports.SPOT_MARKET_RATE_PRECISION = exports.SPOT_MARKET_RATE_PRECISION_EXP = exports.AMM_RESERVE_PRECISION_EXP = exports.PEG_PRECISION_EXP = exports.FUNDING_RATE_PRECISION_EXP = exports.PRICE_PRECISION_EXP = exports.FUNDING_RATE_BUFFER_PRECISION_EXP = exports.QUOTE_PRECISION_EXP = exports.CONCENTRATION_PRECISION = exports.PERCENTAGE_PRECISION = exports.PERCENTAGE_PRECISION_EXP = exports.MAX_LEVERAGE_ORDER_SIZE = exports.MAX_LEVERAGE = exports.TEN_MILLION = exports.BN_MAX = exports.TEN_THOUSAND = exports.TEN = exports.NINE = exports.EIGHT = exports.SEVEN = exports.SIX = exports.FIVE = exports.FOUR = exports.THREE = exports.TWO = exports.ONE = exports.ZERO = void 0;
|
|
4
|
-
exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = exports.MAX_PREDICTION_PRICE = exports.FUEL_START_TS = exports.FUEL_WINDOW = exports.DUST_POSITION_SIZE = exports.SLOT_TIME_ESTIMATE_MS = exports.IDLE_TIME_SLOTS = exports.ACCOUNT_AGE_DELETION_CUTOFF_SECONDS = exports.DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT = exports.OPEN_ORDER_MARGIN_REQUIREMENT = exports.LAMPORTS_EXP = exports.LAMPORTS_PRECISION = exports.GOV_SPOT_MARKET_INDEX = exports.QUOTE_SPOT_MARKET_INDEX = exports.ONE_YEAR = exports.ONE_HOUR = exports.FIVE_MINUTE = exports.PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO = exports.FUNDING_RATE_OFFSET_DENOMINATOR = exports.LIQUIDATION_PCT_PRECISION = exports.BID_ASK_SPREAD_PRECISION = void 0;
|
|
4
|
+
exports.MIN_I64 = exports.MAX_I64 = exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = exports.MAX_PREDICTION_PRICE = exports.FUEL_START_TS = exports.FUEL_WINDOW = exports.DUST_POSITION_SIZE = exports.SLOT_TIME_ESTIMATE_MS = exports.IDLE_TIME_SLOTS = exports.ACCOUNT_AGE_DELETION_CUTOFF_SECONDS = exports.DEFAULT_REVENUE_SINCE_LAST_FUNDING_SPREAD_RETREAT = exports.OPEN_ORDER_MARGIN_REQUIREMENT = exports.LAMPORTS_EXP = exports.LAMPORTS_PRECISION = exports.GOV_SPOT_MARKET_INDEX = exports.QUOTE_SPOT_MARKET_INDEX = exports.ONE_YEAR = exports.ONE_HOUR = exports.FIVE_MINUTE = exports.PRICE_TIMES_AMM_TO_QUOTE_PRECISION_RATIO = exports.FUNDING_RATE_OFFSET_DENOMINATOR = exports.LIQUIDATION_PCT_PRECISION = exports.BID_ASK_SPREAD_PRECISION = void 0;
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
6
|
const anchor_1 = require("@coral-xyz/anchor");
|
|
7
|
+
const bigNum_1 = require("../factory/bigNum");
|
|
7
8
|
exports.ZERO = new anchor_1.BN(0);
|
|
8
9
|
exports.ONE = new anchor_1.BN(1);
|
|
9
10
|
exports.TWO = new anchor_1.BN(2);
|
|
@@ -75,3 +76,6 @@ exports.FUEL_WINDOW = new anchor_1.BN(60 * 60 * 24 * 28); // 28 days
|
|
|
75
76
|
exports.FUEL_START_TS = new anchor_1.BN(1723147200); // unix timestamp
|
|
76
77
|
exports.MAX_PREDICTION_PRICE = exports.PRICE_PRECISION;
|
|
77
78
|
exports.GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = 99;
|
|
79
|
+
// integer constants
|
|
80
|
+
exports.MAX_I64 = bigNum_1.BigNum.fromPrint('9223372036854775807').val;
|
|
81
|
+
exports.MIN_I64 = bigNum_1.BigNum.fromPrint('-9223372036854775808').val;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
-
import { OracleSource } from '../types';
|
|
2
|
+
import { MarketStatus, OracleSource } from '../types';
|
|
3
3
|
import { DriftEnv } from '../config';
|
|
4
4
|
export type PerpMarketConfig = {
|
|
5
5
|
fullName?: string;
|
|
@@ -12,6 +12,7 @@ export type PerpMarketConfig = {
|
|
|
12
12
|
oracleSource: OracleSource;
|
|
13
13
|
pythFeedId?: string;
|
|
14
14
|
pythLazerId?: number;
|
|
15
|
+
marketStatus?: MarketStatus;
|
|
15
16
|
};
|
|
16
17
|
export declare const DevnetPerpMarkets: PerpMarketConfig[];
|
|
17
18
|
export declare const MainnetPerpMarkets: PerpMarketConfig[];
|
|
@@ -558,6 +558,7 @@ exports.MainnetPerpMarkets = [
|
|
|
558
558
|
launchTs: 1699265968000,
|
|
559
559
|
oracleSource: types_1.OracleSource.PYTH_PULL,
|
|
560
560
|
pythFeedId: '0x2f2d17abbc1e781bd87b4a5d52c8b2856886f5c482fa3593cebf6795040ab0b6',
|
|
561
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
561
562
|
},
|
|
562
563
|
{
|
|
563
564
|
fullName: 'Pyth',
|
|
@@ -654,6 +655,7 @@ exports.MainnetPerpMarkets = [
|
|
|
654
655
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
655
656
|
pythFeedId: '0xa9f3b2a89c6f85a6c20a9518abde39b944e839ca49a0c92307c65974d3f14a57',
|
|
656
657
|
pythLazerId: 83,
|
|
658
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
657
659
|
},
|
|
658
660
|
{
|
|
659
661
|
fullName: 'BITTENSOR',
|
|
@@ -738,6 +740,7 @@ exports.MainnetPerpMarkets = [
|
|
|
738
740
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
739
741
|
pythFeedId: '0x82595d1509b770fa52681e260af4dda9752b87316d7c048535d8ead3fa856eb1',
|
|
740
742
|
pythLazerId: 90,
|
|
743
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
741
744
|
},
|
|
742
745
|
{
|
|
743
746
|
fullName: 'ZEX',
|
|
@@ -749,6 +752,7 @@ exports.MainnetPerpMarkets = [
|
|
|
749
752
|
launchTs: 1719415157000,
|
|
750
753
|
oracleSource: types_1.OracleSource.PYTH_PULL,
|
|
751
754
|
pythFeedId: '0x3d63be09d1b88f6dffe6585d0170670592124fd9fa4e0fe8a09ff18464f05e3a',
|
|
755
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
752
756
|
},
|
|
753
757
|
{
|
|
754
758
|
fullName: 'POPCAT',
|
|
@@ -772,6 +776,7 @@ exports.MainnetPerpMarkets = [
|
|
|
772
776
|
launchTs: 1720633344000,
|
|
773
777
|
oracleSource: types_1.OracleSource.PYTH_1K_PULL,
|
|
774
778
|
pythFeedId: '0x5169491cd7e2a44c98353b779d5eb612e4ac32e073f5cc534303d86307c2f1bc',
|
|
779
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
775
780
|
},
|
|
776
781
|
{
|
|
777
782
|
fullName: 'TRUMP-WIN-2024-BET',
|
|
@@ -782,6 +787,7 @@ exports.MainnetPerpMarkets = [
|
|
|
782
787
|
oracle: new web3_js_1.PublicKey('7YrQUxmxGdbk8pvns9KcL5ojbZSL2eHj62hxRqggtEUR'),
|
|
783
788
|
launchTs: 1723996800000,
|
|
784
789
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
790
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
785
791
|
},
|
|
786
792
|
{
|
|
787
793
|
fullName: 'KAMALA-POPULAR-VOTE-2024-BET',
|
|
@@ -792,6 +798,7 @@ exports.MainnetPerpMarkets = [
|
|
|
792
798
|
oracle: new web3_js_1.PublicKey('AowFw1dCVjS8kngvTCoT3oshiUyL69k7P1uxqXwteWH4'),
|
|
793
799
|
launchTs: 1723996800000,
|
|
794
800
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
801
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
795
802
|
},
|
|
796
803
|
{
|
|
797
804
|
fullName: 'FED-CUT-50-SEPT-2024-BET',
|
|
@@ -802,6 +809,7 @@ exports.MainnetPerpMarkets = [
|
|
|
802
809
|
oracle: new web3_js_1.PublicKey('5QzgqAbEhJ1cPnLX4tSZEXezmW7sz7PPVVg2VanGi8QQ'),
|
|
803
810
|
launchTs: 1724250126000,
|
|
804
811
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
812
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
805
813
|
},
|
|
806
814
|
{
|
|
807
815
|
fullName: 'REPUBLICAN-POPULAR-AND-WIN-BET',
|
|
@@ -812,6 +820,7 @@ exports.MainnetPerpMarkets = [
|
|
|
812
820
|
oracle: new web3_js_1.PublicKey('BtUUSUc9rZSzBmmKhQq4no65zHQTzMFeVYss7xcMRD53'),
|
|
813
821
|
launchTs: 1724250126000,
|
|
814
822
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
823
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
815
824
|
},
|
|
816
825
|
{
|
|
817
826
|
fullName: 'BREAKPOINT-IGGYERIC-BET',
|
|
@@ -822,6 +831,7 @@ exports.MainnetPerpMarkets = [
|
|
|
822
831
|
oracle: new web3_js_1.PublicKey('2ftYxoSupperd4ULxy9xyS2Az38wfAe7Lm8FCAPwjjVV'),
|
|
823
832
|
launchTs: 1724250126000,
|
|
824
833
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
834
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
825
835
|
},
|
|
826
836
|
{
|
|
827
837
|
fullName: 'DEMOCRATS-WIN-MICHIGAN-BET',
|
|
@@ -832,6 +842,7 @@ exports.MainnetPerpMarkets = [
|
|
|
832
842
|
oracle: new web3_js_1.PublicKey('8HTDLjhb2esGU5mu11v3pq3eWeFqmvKPkQNCnTTwKAyB'),
|
|
833
843
|
launchTs: 1725551484000,
|
|
834
844
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
845
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
835
846
|
},
|
|
836
847
|
{
|
|
837
848
|
fullName: 'TON',
|
|
@@ -854,6 +865,7 @@ exports.MainnetPerpMarkets = [
|
|
|
854
865
|
oracle: new web3_js_1.PublicKey('DpJz7rjTJLxxnuqrqZTUjMWtnaMFAEfZUv5ATdb9HTh1'),
|
|
855
866
|
launchTs: 1726646453000,
|
|
856
867
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
868
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
857
869
|
},
|
|
858
870
|
{
|
|
859
871
|
fullName: 'MOTHER',
|
|
@@ -866,6 +878,7 @@ exports.MainnetPerpMarkets = [
|
|
|
866
878
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
867
879
|
pythFeedId: '0x62742a997d01f7524f791fdb2dd43aaf0e567d765ebf8fd0406a994239e874d4',
|
|
868
880
|
pythLazerId: 501,
|
|
881
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
869
882
|
},
|
|
870
883
|
{
|
|
871
884
|
fullName: 'MOODENG',
|
|
@@ -878,6 +891,7 @@ exports.MainnetPerpMarkets = [
|
|
|
878
891
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
879
892
|
pythFeedId: '0xffff73128917a90950cd0473fd2551d7cd274fd5a6cc45641881bbcc6ee73417',
|
|
880
893
|
pythLazerId: 500,
|
|
894
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
881
895
|
},
|
|
882
896
|
{
|
|
883
897
|
fullName: 'WARWICK-FIGHT-WIN-BET',
|
|
@@ -888,6 +902,7 @@ exports.MainnetPerpMarkets = [
|
|
|
888
902
|
oracle: new web3_js_1.PublicKey('Dz5Nvxo1hv7Zfyu11hy8e97twLMRKk6heTWCDGXytj7N'),
|
|
889
903
|
launchTs: 1727965864000,
|
|
890
904
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
905
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
891
906
|
},
|
|
892
907
|
{
|
|
893
908
|
fullName: 'DeBridge',
|
|
@@ -899,6 +914,7 @@ exports.MainnetPerpMarkets = [
|
|
|
899
914
|
launchTs: 1728574493000,
|
|
900
915
|
oracleSource: types_1.OracleSource.PYTH_PULL,
|
|
901
916
|
pythFeedId: '0xf788488fe2df341b10a498e0a789f03209c0938d9ed04bc521f8224748d6d236',
|
|
917
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
902
918
|
},
|
|
903
919
|
{
|
|
904
920
|
fullName: 'WLF-5B-1W',
|
|
@@ -909,6 +925,7 @@ exports.MainnetPerpMarkets = [
|
|
|
909
925
|
oracle: new web3_js_1.PublicKey('7LpRfPaWR7cQqN7CMkCmZjEQpWyqso5LGuKCvDXH5ZAr'),
|
|
910
926
|
launchTs: 1728574493000,
|
|
911
927
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
928
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
912
929
|
},
|
|
913
930
|
{
|
|
914
931
|
fullName: 'VRSTPN-WIN-F1-24-DRVRS-CHMP',
|
|
@@ -919,6 +936,7 @@ exports.MainnetPerpMarkets = [
|
|
|
919
936
|
oracle: new web3_js_1.PublicKey('E36rvXEwysWeiToXCpWfHVADd8bzzyR4w83ZSSwxAxqG'),
|
|
920
937
|
launchTs: 1729209600000,
|
|
921
938
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
939
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
922
940
|
},
|
|
923
941
|
{
|
|
924
942
|
fullName: 'LNDO-WIN-F1-24-US-GP',
|
|
@@ -929,6 +947,7 @@ exports.MainnetPerpMarkets = [
|
|
|
929
947
|
oracle: new web3_js_1.PublicKey('6AVy1y9SnJECnosQaiK2uY1kcT4ZEBf1F4DMvhxgvhUo'),
|
|
930
948
|
launchTs: 1729209600000,
|
|
931
949
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
950
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
932
951
|
},
|
|
933
952
|
{
|
|
934
953
|
fullName: '1KMEW',
|
|
@@ -941,6 +960,7 @@ exports.MainnetPerpMarkets = [
|
|
|
941
960
|
oracleSource: types_1.OracleSource.PYTH_LAZER_1K,
|
|
942
961
|
pythFeedId: '0x514aed52ca5294177f20187ae883cec4a018619772ddce41efcc36a6448f5d5d',
|
|
943
962
|
pythLazerId: 137,
|
|
963
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
944
964
|
},
|
|
945
965
|
{
|
|
946
966
|
fullName: 'MICHI',
|
|
@@ -952,6 +972,7 @@ exports.MainnetPerpMarkets = [
|
|
|
952
972
|
launchTs: 1730402722000,
|
|
953
973
|
oracleSource: types_1.OracleSource.PYTH_PULL,
|
|
954
974
|
pythFeedId: '0x63a45218d6b13ffd28ca04748615511bf70eff80a3411c97d96b8ed74a6decab',
|
|
975
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
955
976
|
},
|
|
956
977
|
{
|
|
957
978
|
fullName: 'GOAT',
|
|
@@ -964,6 +985,7 @@ exports.MainnetPerpMarkets = [
|
|
|
964
985
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
965
986
|
pythFeedId: '0xf7731dc812590214d3eb4343bfb13d1b4cfa9b1d4e020644b5d5d8e07d60c66c',
|
|
966
987
|
pythLazerId: 437,
|
|
988
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
967
989
|
},
|
|
968
990
|
{
|
|
969
991
|
fullName: 'FWOG',
|
|
@@ -975,6 +997,7 @@ exports.MainnetPerpMarkets = [
|
|
|
975
997
|
launchTs: 1731443152000,
|
|
976
998
|
oracleSource: types_1.OracleSource.PYTH_PULL,
|
|
977
999
|
pythFeedId: '0x656cc2a39dd795bdecb59de810d4f4d1e74c25fe4c42d0bf1c65a38d74df48e9',
|
|
1000
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
978
1001
|
},
|
|
979
1002
|
{
|
|
980
1003
|
fullName: 'PNUT',
|
|
@@ -987,6 +1010,7 @@ exports.MainnetPerpMarkets = [
|
|
|
987
1010
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
988
1011
|
pythFeedId: '0x116da895807f81f6b5c5f01b109376e7f6834dc8b51365ab7cdfa66634340e54',
|
|
989
1012
|
pythLazerId: 77,
|
|
1013
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
990
1014
|
},
|
|
991
1015
|
{
|
|
992
1016
|
fullName: 'RAY',
|
|
@@ -1009,6 +1033,7 @@ exports.MainnetPerpMarkets = [
|
|
|
1009
1033
|
oracle: new web3_js_1.PublicKey('GfTeKKnBxeLSB1Hm24ArjduQM4yqaAgoGgiC99gq5E2P'),
|
|
1010
1034
|
launchTs: 1732721897000,
|
|
1011
1035
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
1036
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
1012
1037
|
},
|
|
1013
1038
|
{
|
|
1014
1039
|
fullName: 'SUPERBOWL-LIX-CHIEFS',
|
|
@@ -1019,6 +1044,7 @@ exports.MainnetPerpMarkets = [
|
|
|
1019
1044
|
oracle: new web3_js_1.PublicKey('EdB17Nyu4bnEBiSEfFrwvp4VCUvtq9eDJHc6Ujys3Jwd'),
|
|
1020
1045
|
launchTs: 1732721897000,
|
|
1021
1046
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
1047
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
1022
1048
|
},
|
|
1023
1049
|
{
|
|
1024
1050
|
fullName: 'Hyperliquid',
|
|
@@ -1079,6 +1105,7 @@ exports.MainnetPerpMarkets = [
|
|
|
1079
1105
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
1080
1106
|
pythFeedId: '0x2551eca7784671173def2c41e6f3e51e11cd87494863f1d208fdd8c64a1f85ae',
|
|
1081
1107
|
pythLazerId: 171,
|
|
1108
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
1082
1109
|
},
|
|
1083
1110
|
{
|
|
1084
1111
|
fullName: 'TRUMP',
|
|
@@ -1103,6 +1130,7 @@ exports.MainnetPerpMarkets = [
|
|
|
1103
1130
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
1104
1131
|
pythFeedId: '0x8fef7d52c7f4e3a6258d663f9d27e64a1b6fd95ab5f7d545dbf9a515353d0064',
|
|
1105
1132
|
pythLazerId: 145,
|
|
1133
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
1106
1134
|
},
|
|
1107
1135
|
{
|
|
1108
1136
|
fullName: 'BERA',
|
|
@@ -1125,6 +1153,7 @@ exports.MainnetPerpMarkets = [
|
|
|
1125
1153
|
oracle: new web3_js_1.PublicKey('HieNNSAy9tjtU2mLEcGtgCMViCeZ1881fX7tfezL7wdV'),
|
|
1126
1154
|
launchTs: 1739463226000,
|
|
1127
1155
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
1156
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
1128
1157
|
},
|
|
1129
1158
|
{
|
|
1130
1159
|
fullName: 'NBAFINALS25-BOS',
|
|
@@ -1135,6 +1164,7 @@ exports.MainnetPerpMarkets = [
|
|
|
1135
1164
|
oracle: new web3_js_1.PublicKey('HorrnsG8RBMv7dhzbgPX4wqcWbUTV5NwV8r59UwTu4CJ'),
|
|
1136
1165
|
launchTs: 1739463226000,
|
|
1137
1166
|
oracleSource: types_1.OracleSource.Prelaunch,
|
|
1167
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
1138
1168
|
},
|
|
1139
1169
|
{
|
|
1140
1170
|
fullName: 'KAITO',
|
|
@@ -1202,8 +1232,7 @@ exports.MainnetPerpMarkets = [
|
|
|
1202
1232
|
oracle: new web3_js_1.PublicKey('GAzR3C5cn7gGVvuqJB57wSYTPWP3n2Lw4mRJRxvTvqYy'),
|
|
1203
1233
|
launchTs: 1747318237000,
|
|
1204
1234
|
oracleSource: types_1.OracleSource.PYTH_LAZER,
|
|
1205
|
-
|
|
1206
|
-
pythLazerId: 1571,
|
|
1235
|
+
marketStatus: types_1.MarketStatus.DELISTED,
|
|
1207
1236
|
},
|
|
1208
1237
|
{
|
|
1209
1238
|
fullName: 'PUMP',
|
|
@@ -3,6 +3,7 @@ import { PublicKey } from '@solana/web3.js';
|
|
|
3
3
|
import { OracleSource } from '../types';
|
|
4
4
|
import { BN } from '@coral-xyz/anchor';
|
|
5
5
|
import { DriftEnv } from '../config';
|
|
6
|
+
import { MarketStatus } from '@ellipsis-labs/phoenix-sdk';
|
|
6
7
|
export type SpotMarketConfig = {
|
|
7
8
|
symbol: string;
|
|
8
9
|
marketIndex: number;
|
|
@@ -18,6 +19,7 @@ export type SpotMarketConfig = {
|
|
|
18
19
|
launchTs?: number;
|
|
19
20
|
pythFeedId?: string;
|
|
20
21
|
pythLazerId?: number;
|
|
22
|
+
marketStatus?: MarketStatus;
|
|
21
23
|
};
|
|
22
24
|
export declare const WRAPPED_SOL_MINT: PublicKey;
|
|
23
25
|
export declare const DevnetSpotMarkets: SpotMarketConfig[];
|
|
@@ -19,7 +19,7 @@ import { UserSubscriptionConfig } from './userConfig';
|
|
|
19
19
|
import { DriftEnv } from './config';
|
|
20
20
|
import { UserStats } from './userStats';
|
|
21
21
|
import { JupiterClient, QuoteResponse } from './jupiter/jupiterClient';
|
|
22
|
-
import { SwapMode } from './swap/UnifiedSwapClient';
|
|
22
|
+
import { SwapMode, UnifiedQuoteResponse } from './swap/UnifiedSwapClient';
|
|
23
23
|
import { UserStatsSubscriptionConfig } from './userStatsConfig';
|
|
24
24
|
import { TxHandler } from './tx/txHandler';
|
|
25
25
|
import { WormholeCoreBridgeSolana } from '@pythnetwork/pyth-solana-receiver/lib/idl/wormhole_core_bridge_solana';
|
|
@@ -234,7 +234,11 @@ export declare class DriftClient {
|
|
|
234
234
|
subAccountId: number;
|
|
235
235
|
}[], txParams?: TxParams): Promise<TransactionSignature>;
|
|
236
236
|
getUpdateUserCustomMarginRatioIx(marginRatio: number, subAccountId?: number): Promise<TransactionInstruction>;
|
|
237
|
-
getUpdateUserPerpPositionCustomMarginRatioIx(perpMarketIndex: number, marginRatio: number, subAccountId?: number
|
|
237
|
+
getUpdateUserPerpPositionCustomMarginRatioIx(perpMarketIndex: number, marginRatio: number, subAccountId?: number, overrides?: {
|
|
238
|
+
userAccountPublicKey?: PublicKey;
|
|
239
|
+
authority?: PublicKey;
|
|
240
|
+
signingAuthority?: PublicKey;
|
|
241
|
+
}): Promise<TransactionInstruction>;
|
|
238
242
|
updateUserPerpPositionCustomMarginRatio(perpMarketIndex: number, marginRatio: number, subAccountId?: number, txParams?: TxParams, enterHighLeverageMode?: boolean): Promise<TransactionSignature>;
|
|
239
243
|
getUpdateUserMarginTradingEnabledIx(marginTradingEnabled: boolean, subAccountId?: number, userAccountPublicKey?: PublicKey): Promise<TransactionInstruction>;
|
|
240
244
|
updateUserMarginTradingEnabled(updates: {
|
|
@@ -542,21 +546,24 @@ export declare class DriftClient {
|
|
|
542
546
|
/**
|
|
543
547
|
* Swap tokens in drift account using titan or jupiter
|
|
544
548
|
* @param swapClient swap client to find routes and instructions (Titan or Jupiter)
|
|
549
|
+
* @param jupiterClient @deprecated Use swapClient instead. Legacy parameter for backward compatibility
|
|
545
550
|
* @param outMarketIndex the market index of the token you're buying
|
|
546
551
|
* @param inMarketIndex the market index of the token you're selling
|
|
547
|
-
* @param outAssociatedTokenAccount the token account to receive the token being sold on
|
|
552
|
+
* @param outAssociatedTokenAccount the token account to receive the token being sold on the swap provider
|
|
548
553
|
* @param inAssociatedTokenAccount the token account to
|
|
549
554
|
* @param amount the amount of TokenIn, regardless of swapMode
|
|
550
|
-
* @param slippageBps the max slippage passed to
|
|
551
|
-
* @param swapMode
|
|
552
|
-
* @param route the
|
|
555
|
+
* @param slippageBps the max slippage passed to the swap provider api
|
|
556
|
+
* @param swapMode swap provider swapMode (ExactIn or ExactOut), default is ExactIn
|
|
557
|
+
* @param route the swap provider route to use for the swap
|
|
553
558
|
* @param reduceOnly specify if In or Out token on the drift account must reduceOnly, checked at end of swap
|
|
554
|
-
* @param v6 pass in the quote response from
|
|
555
|
-
* @param quote pass in the quote response from
|
|
559
|
+
* @param v6 pass in the quote response from swap provider quote's API (deprecated, use quote instead)
|
|
560
|
+
* @param quote pass in the quote response from swap provider quote's API
|
|
556
561
|
* @param txParams
|
|
557
562
|
*/
|
|
558
|
-
swap({ swapClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, reduceOnly, txParams, v6, quote, onlyDirectRoutes, }: {
|
|
559
|
-
swapClient
|
|
563
|
+
swap({ swapClient, jupiterClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, reduceOnly, txParams, v6, quote, onlyDirectRoutes, }: {
|
|
564
|
+
swapClient?: UnifiedSwapClient | SwapClient;
|
|
565
|
+
/** @deprecated Use swapClient instead. Legacy parameter for backward compatibility */
|
|
566
|
+
jupiterClient?: JupiterClient;
|
|
560
567
|
outMarketIndex: number;
|
|
561
568
|
inMarketIndex: number;
|
|
562
569
|
outAssociatedTokenAccount?: PublicKey;
|
|
@@ -570,7 +577,7 @@ export declare class DriftClient {
|
|
|
570
577
|
v6?: {
|
|
571
578
|
quote?: QuoteResponse;
|
|
572
579
|
};
|
|
573
|
-
quote?:
|
|
580
|
+
quote?: UnifiedQuoteResponse;
|
|
574
581
|
}): Promise<TransactionSignature>;
|
|
575
582
|
getTitanSwapIx({ titanClient, outMarketIndex, inMarketIndex, outAssociatedTokenAccount, inAssociatedTokenAccount, amount, slippageBps, swapMode, onlyDirectRoutes, reduceOnly, userAccountPublicKey, }: {
|
|
576
583
|
titanClient: TitanClient;
|
|
@@ -641,7 +648,7 @@ export declare class DriftClient {
|
|
|
641
648
|
swapMode?: SwapMode;
|
|
642
649
|
onlyDirectRoutes?: boolean;
|
|
643
650
|
reduceOnly?: SwapReduceOnly;
|
|
644
|
-
quote?:
|
|
651
|
+
quote?: UnifiedQuoteResponse;
|
|
645
652
|
v6?: {
|
|
646
653
|
quote?: QuoteResponse;
|
|
647
654
|
};
|
|
@@ -1086,6 +1093,9 @@ export declare class DriftClient {
|
|
|
1086
1093
|
isMakingNewAccount: boolean;
|
|
1087
1094
|
depositMarketIndex: number;
|
|
1088
1095
|
orderMarketIndex: number;
|
|
1096
|
+
}, overrides?: {
|
|
1097
|
+
user?: User;
|
|
1098
|
+
signingAuthority?: PublicKey;
|
|
1089
1099
|
}): Promise<TransactionInstruction>;
|
|
1090
1100
|
disableUserHighLeverageMode(user: PublicKey, userAccount?: UserAccount, txParams?: TxParams): Promise<TransactionSignature>;
|
|
1091
1101
|
getDisableHighLeverageModeIx(user: PublicKey, userAccount?: UserAccount, maintenance?: boolean): Promise<TransactionInstruction>;
|