@drift-labs/sdk 2.74.0-beta.10 → 2.74.0-beta.11

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 CHANGED
@@ -1 +1 @@
1
- 2.74.0-beta.10
1
+ 2.74.0-beta.11
@@ -1,5 +1,5 @@
1
1
  /// <reference types="bn.js" />
2
- import { PublicKey, TransactionSignature } from '@solana/web3.js';
2
+ import { PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js';
3
3
  import { FeeStructure, OracleGuardRails, OracleSource, ExchangeStatus, MarketStatus, ContractTier, AssetTier, SpotFulfillmentConfigStatus } from './types';
4
4
  import { BN } from '@coral-xyz/anchor';
5
5
  import { DriftClient } from './driftClient';
@@ -8,9 +8,15 @@ export declare class AdminClient extends DriftClient {
8
8
  initializeSpotMarket(mint: PublicKey, optimalUtilization: number, optimalRate: number, maxRate: number, oracle: PublicKey, oracleSource: OracleSource, initialAssetWeight: number, maintenanceAssetWeight: number, initialLiabilityWeight: number, maintenanceLiabilityWeight: number, imfFactor?: number, liquidatorFee?: number, ifLiquidationFee?: number, activeStatus?: boolean, assetTier?: {
9
9
  collateral: {};
10
10
  }, scaleInitialAssetWeightStart?: BN, withdrawGuardThreshold?: BN, orderTickSize?: BN, orderStepSize?: BN, ifTotalFactor?: number, name?: string): Promise<TransactionSignature>;
11
+ getInitializeSpotMarketIx(admin: PublicKey, mint: PublicKey, optimalUtilization: number, optimalRate: number, maxRate: number, oracle: PublicKey, oracleSource: OracleSource, initialAssetWeight: number, maintenanceAssetWeight: number, initialLiabilityWeight: number, maintenanceLiabilityWeight: number, imfFactor?: number, liquidatorFee?: number, ifLiquidationFee?: number, activeStatus?: boolean, assetTier?: {
12
+ collateral: {};
13
+ }, scaleInitialAssetWeightStart?: BN, withdrawGuardThreshold?: BN, orderTickSize?: BN, orderStepSize?: BN, ifTotalFactor?: number, name?: string): Promise<TransactionInstruction>;
11
14
  initializeSerumFulfillmentConfig(marketIndex: number, serumMarket: PublicKey, serumProgram: PublicKey): Promise<TransactionSignature>;
15
+ getInitializeSerumFulfillmentConfigIx(admin: PublicKey, marketIndex: number, serumMarket: PublicKey, serumProgram: PublicKey): Promise<TransactionInstruction>;
12
16
  initializePhoenixFulfillmentConfig(marketIndex: number, phoenixMarket: PublicKey): Promise<TransactionSignature>;
17
+ getInitializePhoenixFulfillmentConfigIx(admin: PublicKey, marketIndex: number, phoenixMarket: PublicKey): Promise<TransactionInstruction>;
13
18
  initializePerpMarket(marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, 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): Promise<TransactionSignature>;
19
+ getInitializePerpMarketIx(admin: PublicKey, marketIndex: number, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN, oracleSource?: OracleSource, 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): Promise<TransactionInstruction>;
14
20
  deleteInitializedPerpMarket(marketIndex: number): Promise<TransactionSignature>;
15
21
  moveAmmPrice(perpMarketIndex: number, baseAssetReserve: BN, quoteAssetReserve: BN, sqrtK?: BN): Promise<TransactionSignature>;
16
22
  updateK(perpMarketIndex: number, sqrtK: BN): Promise<TransactionSignature>;
@@ -60,6 +60,20 @@ class AdminClient extends driftClient_1.DriftClient {
60
60
  return [txSig];
61
61
  }
62
62
  async initializeSpotMarket(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0, liquidatorFee = 0, ifLiquidationFee = 0, activeStatus = true, assetTier = types_1.AssetTier.COLLATERAL, scaleInitialAssetWeightStart = numericConstants_1.ZERO, withdrawGuardThreshold = numericConstants_1.ZERO, orderTickSize = numericConstants_1.ONE, orderStepSize = numericConstants_1.ONE, ifTotalFactor = 0, name = userName_1.DEFAULT_MARKET_NAME) {
63
+ const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
64
+ const initializeIx = await this.getInitializeSpotMarketIx(this.wallet.publicKey, mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, name);
65
+ const tx = await this.buildTransaction(initializeIx);
66
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
67
+ // const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
68
+ await this.accountSubscriber.addSpotMarket(spotMarketIndex);
69
+ await this.accountSubscriber.addOracle({
70
+ source: oracleSource,
71
+ publicKey: oracle,
72
+ });
73
+ await this.accountSubscriber.setSpotOracleMap();
74
+ return txSig;
75
+ }
76
+ async getInitializeSpotMarketIx(admin, mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0, liquidatorFee = 0, ifLiquidationFee = 0, activeStatus = true, assetTier = types_1.AssetTier.COLLATERAL, scaleInitialAssetWeightStart = numericConstants_1.ZERO, withdrawGuardThreshold = numericConstants_1.ZERO, orderTickSize = numericConstants_1.ONE, orderStepSize = numericConstants_1.ONE, ifTotalFactor = 0, name = userName_1.DEFAULT_MARKET_NAME) {
63
77
  const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
64
78
  const spotMarket = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex);
65
79
  const spotMarketVault = await (0, pda_1.getSpotMarketVaultPublicKey)(this.program.programId, spotMarketIndex);
@@ -67,7 +81,7 @@ class AdminClient extends driftClient_1.DriftClient {
67
81
  const nameBuffer = (0, userName_1.encodeName)(name);
68
82
  const initializeIx = await this.program.instruction.initializeSpotMarket(optimalUtilization, optimalRate, maxRate, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, liquidatorFee, ifLiquidationFee, activeStatus, assetTier, scaleInitialAssetWeightStart, withdrawGuardThreshold, orderTickSize, orderStepSize, ifTotalFactor, nameBuffer, {
69
83
  accounts: {
70
- admin: this.wallet.publicKey,
84
+ admin,
71
85
  state: await this.getStatePublicKey(),
72
86
  spotMarket,
73
87
  spotMarketVault,
@@ -80,23 +94,20 @@ class AdminClient extends driftClient_1.DriftClient {
80
94
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
81
95
  },
82
96
  });
97
+ return initializeIx;
98
+ }
99
+ async initializeSerumFulfillmentConfig(marketIndex, serumMarket, serumProgram) {
100
+ const initializeIx = await this.getInitializeSerumFulfillmentConfigIx(this.wallet.publicKey, marketIndex, serumMarket, serumProgram);
83
101
  const tx = await this.buildTransaction(initializeIx);
84
102
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
85
- // const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
86
- await this.accountSubscriber.addSpotMarket(spotMarketIndex);
87
- await this.accountSubscriber.addOracle({
88
- source: oracleSource,
89
- publicKey: oracle,
90
- });
91
- await this.accountSubscriber.setSpotOracleMap();
92
103
  return txSig;
93
104
  }
94
- async initializeSerumFulfillmentConfig(marketIndex, serumMarket, serumProgram) {
105
+ async getInitializeSerumFulfillmentConfigIx(admin, marketIndex, serumMarket, serumProgram) {
95
106
  const serumOpenOrders = (0, pda_1.getSerumOpenOrdersPublicKey)(this.program.programId, serumMarket);
96
107
  const serumFulfillmentConfig = (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
97
- const initializeIx = await this.program.instruction.initializeSerumFulfillmentConfig(marketIndex, {
108
+ return await this.program.instruction.initializeSerumFulfillmentConfig(marketIndex, {
98
109
  accounts: {
99
- admin: this.wallet.publicKey,
110
+ admin,
100
111
  state: await this.getStatePublicKey(),
101
112
  baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
102
113
  quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
@@ -109,15 +120,18 @@ class AdminClient extends driftClient_1.DriftClient {
109
120
  serumFulfillmentConfig,
110
121
  },
111
122
  });
123
+ }
124
+ async initializePhoenixFulfillmentConfig(marketIndex, phoenixMarket) {
125
+ const initializeIx = await this.getInitializePhoenixFulfillmentConfigIx(this.wallet.publicKey, marketIndex, phoenixMarket);
112
126
  const tx = await this.buildTransaction(initializeIx);
113
127
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
114
128
  return txSig;
115
129
  }
116
- async initializePhoenixFulfillmentConfig(marketIndex, phoenixMarket) {
130
+ async getInitializePhoenixFulfillmentConfigIx(admin, marketIndex, phoenixMarket) {
117
131
  const phoenixFulfillmentConfig = (0, pda_1.getPhoenixFulfillmentConfigPublicKey)(this.program.programId, phoenixMarket);
118
- const initializeIx = await this.program.instruction.initializePhoenixFulfillmentConfig(marketIndex, {
132
+ return await this.program.instruction.initializePhoenixFulfillmentConfig(marketIndex, {
119
133
  accounts: {
120
- admin: this.wallet.publicKey,
134
+ admin,
121
135
  state: await this.getStatePublicKey(),
122
136
  baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
123
137
  quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
@@ -129,24 +143,10 @@ class AdminClient extends driftClient_1.DriftClient {
129
143
  phoenixFulfillmentConfig,
130
144
  },
131
145
  });
132
- const tx = await this.buildTransaction(initializeIx);
133
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
134
- return txSig;
135
146
  }
136
147
  async initializePerpMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, 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) {
137
148
  const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
138
- const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, currentPerpMarketIndex);
139
- const nameBuffer = (0, userName_1.encodeName)(name);
140
- const initializeMarketIx = await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, {
141
- accounts: {
142
- state: await this.getStatePublicKey(),
143
- admin: this.wallet.publicKey,
144
- oracle: priceOracle,
145
- perpMarket: perpMarketPublicKey,
146
- rent: web3_js_1.SYSVAR_RENT_PUBKEY,
147
- systemProgram: anchor.web3.SystemProgram.programId,
148
- },
149
- });
149
+ const initializeMarketIx = await this.getInitializePerpMarketIx(this.wallet.publicKey, marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, name);
150
150
  const tx = await this.buildTransaction(initializeMarketIx);
151
151
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
152
152
  while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
@@ -160,6 +160,21 @@ class AdminClient extends driftClient_1.DriftClient {
160
160
  await this.accountSubscriber.setPerpOracleMap();
161
161
  return txSig;
162
162
  }
163
+ async getInitializePerpMarketIx(admin, marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, 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) {
164
+ const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
165
+ const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, currentPerpMarketIndex);
166
+ const nameBuffer = (0, userName_1.encodeName)(name);
167
+ return await this.program.instruction.initializePerpMarket(marketIndex, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidatorFee, ifLiquidatorFee, imfFactor, activeStatus, baseSpread, maxSpread, maxOpenInterest, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, orderStepSize, orderTickSize, minOrderSize, concentrationCoefScale, curveUpdateIntensity, ammJitIntensity, nameBuffer, {
168
+ accounts: {
169
+ state: await this.getStatePublicKey(),
170
+ admin,
171
+ oracle: priceOracle,
172
+ perpMarket: perpMarketPublicKey,
173
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY,
174
+ systemProgram: anchor.web3.SystemProgram.programId,
175
+ },
176
+ });
177
+ }
163
178
  async deleteInitializedPerpMarket(marketIndex) {
164
179
  const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
165
180
  const deleteInitializeMarketIx = await this.program.instruction.deleteInitializedPerpMarket(marketIndex, {
@@ -3023,11 +3023,11 @@
3023
3023
  },
3024
3024
  {
3025
3025
  "name": "curveUpdateIntensity",
3026
- "type": "u16"
3026
+ "type": "u8"
3027
3027
  },
3028
3028
  {
3029
- "name": "ammJitUpdateIntensity",
3030
- "type": "u16"
3029
+ "name": "ammJitIntensity",
3030
+ "type": "u8"
3031
3031
  },
3032
3032
  {
3033
3033
  "name": "name",
@@ -11711,8 +11711,5 @@
11711
11711
  "name": "CantReclaimRent",
11712
11712
  "msg": "CantReclaimRent"
11713
11713
  }
11714
- ],
11715
- "metadata": {
11716
- "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
11717
- }
11714
+ ]
11718
11715
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.74.0-beta.10",
3
+ "version": "2.74.0-beta.11",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "author": "crispheaney",
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  PublicKey,
3
3
  SYSVAR_RENT_PUBKEY,
4
+ TransactionInstruction,
4
5
  TransactionSignature,
5
6
  } from '@solana/web3.js';
6
7
  import {
@@ -101,6 +102,73 @@ export class AdminClient extends DriftClient {
101
102
  name = DEFAULT_MARKET_NAME
102
103
  ): Promise<TransactionSignature> {
103
104
  const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
105
+
106
+ const initializeIx = await this.getInitializeSpotMarketIx(
107
+ this.wallet.publicKey,
108
+ mint,
109
+ optimalUtilization,
110
+ optimalRate,
111
+ maxRate,
112
+ oracle,
113
+ oracleSource,
114
+ initialAssetWeight,
115
+ maintenanceAssetWeight,
116
+ initialLiabilityWeight,
117
+ maintenanceLiabilityWeight,
118
+ imfFactor,
119
+ liquidatorFee,
120
+ ifLiquidationFee,
121
+ activeStatus,
122
+ assetTier,
123
+ scaleInitialAssetWeightStart,
124
+ withdrawGuardThreshold,
125
+ orderTickSize,
126
+ orderStepSize,
127
+ ifTotalFactor,
128
+ name
129
+ );
130
+
131
+ const tx = await this.buildTransaction(initializeIx);
132
+
133
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
134
+
135
+ // const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
136
+
137
+ await this.accountSubscriber.addSpotMarket(spotMarketIndex);
138
+ await this.accountSubscriber.addOracle({
139
+ source: oracleSource,
140
+ publicKey: oracle,
141
+ });
142
+ await this.accountSubscriber.setSpotOracleMap();
143
+
144
+ return txSig;
145
+ }
146
+
147
+ public async getInitializeSpotMarketIx(
148
+ admin: PublicKey,
149
+ mint: PublicKey,
150
+ optimalUtilization: number,
151
+ optimalRate: number,
152
+ maxRate: number,
153
+ oracle: PublicKey,
154
+ oracleSource: OracleSource,
155
+ initialAssetWeight: number,
156
+ maintenanceAssetWeight: number,
157
+ initialLiabilityWeight: number,
158
+ maintenanceLiabilityWeight: number,
159
+ imfFactor = 0,
160
+ liquidatorFee = 0,
161
+ ifLiquidationFee = 0,
162
+ activeStatus = true,
163
+ assetTier = AssetTier.COLLATERAL,
164
+ scaleInitialAssetWeightStart = ZERO,
165
+ withdrawGuardThreshold = ZERO,
166
+ orderTickSize = ONE,
167
+ orderStepSize = ONE,
168
+ ifTotalFactor = 0,
169
+ name = DEFAULT_MARKET_NAME
170
+ ): Promise<TransactionInstruction> {
171
+ const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
104
172
  const spotMarket = await getSpotMarketPublicKey(
105
173
  this.program.programId,
106
174
  spotMarketIndex
@@ -139,7 +207,7 @@ export class AdminClient extends DriftClient {
139
207
  nameBuffer,
140
208
  {
141
209
  accounts: {
142
- admin: this.wallet.publicKey,
210
+ admin,
143
211
  state: await this.getStatePublicKey(),
144
212
  spotMarket,
145
213
  spotMarketVault,
@@ -154,27 +222,34 @@ export class AdminClient extends DriftClient {
154
222
  }
155
223
  );
156
224
 
157
- const tx = await this.buildTransaction(initializeIx);
225
+ return initializeIx;
226
+ }
158
227
 
159
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
228
+ public async initializeSerumFulfillmentConfig(
229
+ marketIndex: number,
230
+ serumMarket: PublicKey,
231
+ serumProgram: PublicKey
232
+ ): Promise<TransactionSignature> {
233
+ const initializeIx = await this.getInitializeSerumFulfillmentConfigIx(
234
+ this.wallet.publicKey,
235
+ marketIndex,
236
+ serumMarket,
237
+ serumProgram
238
+ );
160
239
 
161
- // const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
240
+ const tx = await this.buildTransaction(initializeIx);
162
241
 
163
- await this.accountSubscriber.addSpotMarket(spotMarketIndex);
164
- await this.accountSubscriber.addOracle({
165
- source: oracleSource,
166
- publicKey: oracle,
167
- });
168
- await this.accountSubscriber.setSpotOracleMap();
242
+ const { txSig } = await this.sendTransaction(tx, [], this.opts);
169
243
 
170
244
  return txSig;
171
245
  }
172
246
 
173
- public async initializeSerumFulfillmentConfig(
247
+ public async getInitializeSerumFulfillmentConfigIx(
248
+ admin: PublicKey,
174
249
  marketIndex: number,
175
250
  serumMarket: PublicKey,
176
251
  serumProgram: PublicKey
177
- ): Promise<TransactionSignature> {
252
+ ): Promise<TransactionInstruction> {
178
253
  const serumOpenOrders = getSerumOpenOrdersPublicKey(
179
254
  this.program.programId,
180
255
  serumMarket
@@ -185,25 +260,35 @@ export class AdminClient extends DriftClient {
185
260
  serumMarket
186
261
  );
187
262
 
188
- const initializeIx =
189
- await this.program.instruction.initializeSerumFulfillmentConfig(
190
- marketIndex,
191
- {
192
- accounts: {
193
- admin: this.wallet.publicKey,
194
- state: await this.getStatePublicKey(),
195
- baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
196
- quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
197
- driftSigner: this.getSignerPublicKey(),
198
- serumProgram,
199
- serumMarket,
200
- serumOpenOrders,
201
- rent: SYSVAR_RENT_PUBKEY,
202
- systemProgram: anchor.web3.SystemProgram.programId,
203
- serumFulfillmentConfig,
204
- },
205
- }
206
- );
263
+ return await this.program.instruction.initializeSerumFulfillmentConfig(
264
+ marketIndex,
265
+ {
266
+ accounts: {
267
+ admin,
268
+ state: await this.getStatePublicKey(),
269
+ baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
270
+ quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
271
+ driftSigner: this.getSignerPublicKey(),
272
+ serumProgram,
273
+ serumMarket,
274
+ serumOpenOrders,
275
+ rent: SYSVAR_RENT_PUBKEY,
276
+ systemProgram: anchor.web3.SystemProgram.programId,
277
+ serumFulfillmentConfig,
278
+ },
279
+ }
280
+ );
281
+ }
282
+
283
+ public async initializePhoenixFulfillmentConfig(
284
+ marketIndex: number,
285
+ phoenixMarket: PublicKey
286
+ ): Promise<TransactionSignature> {
287
+ const initializeIx = await this.getInitializePhoenixFulfillmentConfigIx(
288
+ this.wallet.publicKey,
289
+ marketIndex,
290
+ phoenixMarket
291
+ );
207
292
 
208
293
  const tx = await this.buildTransaction(initializeIx);
209
294
 
@@ -212,39 +297,33 @@ export class AdminClient extends DriftClient {
212
297
  return txSig;
213
298
  }
214
299
 
215
- public async initializePhoenixFulfillmentConfig(
300
+ public async getInitializePhoenixFulfillmentConfigIx(
301
+ admin: PublicKey,
216
302
  marketIndex: number,
217
303
  phoenixMarket: PublicKey
218
- ): Promise<TransactionSignature> {
304
+ ): Promise<TransactionInstruction> {
219
305
  const phoenixFulfillmentConfig = getPhoenixFulfillmentConfigPublicKey(
220
306
  this.program.programId,
221
307
  phoenixMarket
222
308
  );
223
309
 
224
- const initializeIx =
225
- await this.program.instruction.initializePhoenixFulfillmentConfig(
226
- marketIndex,
227
- {
228
- accounts: {
229
- admin: this.wallet.publicKey,
230
- state: await this.getStatePublicKey(),
231
- baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
232
- quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
233
- driftSigner: this.getSignerPublicKey(),
234
- phoenixMarket: phoenixMarket,
235
- phoenixProgram: PHOENIX_PROGRAM_ID,
236
- rent: SYSVAR_RENT_PUBKEY,
237
- systemProgram: anchor.web3.SystemProgram.programId,
238
- phoenixFulfillmentConfig,
239
- },
240
- }
241
- );
242
-
243
- const tx = await this.buildTransaction(initializeIx);
244
-
245
- const { txSig } = await this.sendTransaction(tx, [], this.opts);
246
-
247
- return txSig;
310
+ return await this.program.instruction.initializePhoenixFulfillmentConfig(
311
+ marketIndex,
312
+ {
313
+ accounts: {
314
+ admin,
315
+ state: await this.getStatePublicKey(),
316
+ baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
317
+ quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
318
+ driftSigner: this.getSignerPublicKey(),
319
+ phoenixMarket: phoenixMarket,
320
+ phoenixProgram: PHOENIX_PROGRAM_ID,
321
+ rent: SYSVAR_RENT_PUBKEY,
322
+ systemProgram: anchor.web3.SystemProgram.programId,
323
+ phoenixFulfillmentConfig,
324
+ },
325
+ }
326
+ );
248
327
  }
249
328
 
250
329
  public async initializePerpMarket(
@@ -275,49 +354,35 @@ export class AdminClient extends DriftClient {
275
354
  name = DEFAULT_MARKET_NAME
276
355
  ): Promise<TransactionSignature> {
277
356
  const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
278
- const perpMarketPublicKey = await getPerpMarketPublicKey(
279
- this.program.programId,
280
- currentPerpMarketIndex
281
- );
282
357
 
283
- const nameBuffer = encodeName(name);
284
- const initializeMarketIx =
285
- await this.program.instruction.initializePerpMarket(
286
- marketIndex,
287
- baseAssetReserve,
288
- quoteAssetReserve,
289
- periodicity,
290
- pegMultiplier,
291
- oracleSource,
292
- marginRatioInitial,
293
- marginRatioMaintenance,
294
- liquidatorFee,
295
- ifLiquidatorFee,
296
- imfFactor,
297
- activeStatus,
298
- baseSpread,
299
- maxSpread,
300
- maxOpenInterest,
301
- maxRevenueWithdrawPerPeriod,
302
- quoteMaxInsurance,
303
- orderStepSize,
304
- orderTickSize,
305
- minOrderSize,
306
- concentrationCoefScale,
307
- curveUpdateIntensity,
308
- ammJitIntensity,
309
- nameBuffer,
310
- {
311
- accounts: {
312
- state: await this.getStatePublicKey(),
313
- admin: this.wallet.publicKey,
314
- oracle: priceOracle,
315
- perpMarket: perpMarketPublicKey,
316
- rent: SYSVAR_RENT_PUBKEY,
317
- systemProgram: anchor.web3.SystemProgram.programId,
318
- },
319
- }
320
- );
358
+ const initializeMarketIx = await this.getInitializePerpMarketIx(
359
+ this.wallet.publicKey,
360
+ marketIndex,
361
+ priceOracle,
362
+ baseAssetReserve,
363
+ quoteAssetReserve,
364
+ periodicity,
365
+ pegMultiplier,
366
+ oracleSource,
367
+ marginRatioInitial,
368
+ marginRatioMaintenance,
369
+ liquidatorFee,
370
+ ifLiquidatorFee,
371
+ imfFactor,
372
+ activeStatus,
373
+ baseSpread,
374
+ maxSpread,
375
+ maxOpenInterest,
376
+ maxRevenueWithdrawPerPeriod,
377
+ quoteMaxInsurance,
378
+ orderStepSize,
379
+ orderTickSize,
380
+ minOrderSize,
381
+ concentrationCoefScale,
382
+ curveUpdateIntensity,
383
+ ammJitIntensity,
384
+ name
385
+ );
321
386
  const tx = await this.buildTransaction(initializeMarketIx);
322
387
 
323
388
  const { txSig } = await this.sendTransaction(tx, [], this.opts);
@@ -336,6 +401,79 @@ export class AdminClient extends DriftClient {
336
401
  return txSig;
337
402
  }
338
403
 
404
+ public async getInitializePerpMarketIx(
405
+ admin: PublicKey,
406
+ marketIndex: number,
407
+ priceOracle: PublicKey,
408
+ baseAssetReserve: BN,
409
+ quoteAssetReserve: BN,
410
+ periodicity: BN,
411
+ pegMultiplier: BN = PEG_PRECISION,
412
+ oracleSource: OracleSource = OracleSource.PYTH,
413
+ marginRatioInitial = 2000,
414
+ marginRatioMaintenance = 500,
415
+ liquidatorFee = 0,
416
+ ifLiquidatorFee = 10000,
417
+ imfFactor = 0,
418
+ activeStatus = true,
419
+ baseSpread = 0,
420
+ maxSpread = 142500,
421
+ maxOpenInterest = ZERO,
422
+ maxRevenueWithdrawPerPeriod = ZERO,
423
+ quoteMaxInsurance = ZERO,
424
+ orderStepSize = BASE_PRECISION.divn(10000),
425
+ orderTickSize = PRICE_PRECISION.divn(100000),
426
+ minOrderSize = BASE_PRECISION.divn(10000),
427
+ concentrationCoefScale = ONE,
428
+ curveUpdateIntensity = 0,
429
+ ammJitIntensity = 0,
430
+ name = DEFAULT_MARKET_NAME
431
+ ): Promise<TransactionInstruction> {
432
+ const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
433
+ const perpMarketPublicKey = await getPerpMarketPublicKey(
434
+ this.program.programId,
435
+ currentPerpMarketIndex
436
+ );
437
+
438
+ const nameBuffer = encodeName(name);
439
+ return await this.program.instruction.initializePerpMarket(
440
+ marketIndex,
441
+ baseAssetReserve,
442
+ quoteAssetReserve,
443
+ periodicity,
444
+ pegMultiplier,
445
+ oracleSource,
446
+ marginRatioInitial,
447
+ marginRatioMaintenance,
448
+ liquidatorFee,
449
+ ifLiquidatorFee,
450
+ imfFactor,
451
+ activeStatus,
452
+ baseSpread,
453
+ maxSpread,
454
+ maxOpenInterest,
455
+ maxRevenueWithdrawPerPeriod,
456
+ quoteMaxInsurance,
457
+ orderStepSize,
458
+ orderTickSize,
459
+ minOrderSize,
460
+ concentrationCoefScale,
461
+ curveUpdateIntensity,
462
+ ammJitIntensity,
463
+ nameBuffer,
464
+ {
465
+ accounts: {
466
+ state: await this.getStatePublicKey(),
467
+ admin,
468
+ oracle: priceOracle,
469
+ perpMarket: perpMarketPublicKey,
470
+ rent: SYSVAR_RENT_PUBKEY,
471
+ systemProgram: anchor.web3.SystemProgram.programId,
472
+ },
473
+ }
474
+ );
475
+ }
476
+
339
477
  public async deleteInitializedPerpMarket(
340
478
  marketIndex: number
341
479
  ): Promise<TransactionSignature> {
@@ -3023,11 +3023,11 @@
3023
3023
  },
3024
3024
  {
3025
3025
  "name": "curveUpdateIntensity",
3026
- "type": "u16"
3026
+ "type": "u8"
3027
3027
  },
3028
3028
  {
3029
- "name": "ammJitUpdateIntensity",
3030
- "type": "u16"
3029
+ "name": "ammJitIntensity",
3030
+ "type": "u8"
3031
3031
  },
3032
3032
  {
3033
3033
  "name": "name",
@@ -11711,8 +11711,5 @@
11711
11711
  "name": "CantReclaimRent",
11712
11712
  "msg": "CantReclaimRent"
11713
11713
  }
11714
- ],
11715
- "metadata": {
11716
- "address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
11717
- }
11714
+ ]
11718
11715
  }