@drift-labs/sdk 2.10.0-beta.0 → 2.10.0-beta.2
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/lib/accounts/pollingDriftClientAccountSubscriber.js +12 -3
- package/lib/accounts/types.d.ts +0 -1
- package/lib/adminClient.js +96 -34
- package/lib/driftClient.d.ts +3 -2
- package/lib/driftClient.js +99 -58
- package/lib/idl/drift.json +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/math/amm.js +15 -6
- package/lib/math/oracles.js +2 -2
- package/lib/math/repeg.d.ts +1 -1
- package/lib/math/repeg.js +46 -19
- package/lib/math/spotBalance.js +1 -1
- package/lib/testClient.d.ts +8 -0
- package/lib/testClient.js +22 -0
- package/lib/user.d.ts +1 -0
- package/lib/user.js +4 -0
- package/package.json +1 -1
- package/src/accounts/pollingDriftClientAccountSubscriber.ts +26 -3
- package/src/adminClient.ts +301 -169
- package/src/driftClient.ts +199 -118
- package/src/idl/drift.json +1 -1
- package/src/index.ts +1 -0
- package/src/math/amm.ts +27 -12
- package/src/math/oracles.ts +6 -4
- package/src/math/repeg.ts +54 -26
- package/src/math/spotBalance.ts +1 -5
- package/src/testClient.ts +40 -0
- package/src/user.ts +5 -0
|
@@ -214,19 +214,28 @@ class PollingDriftClientAccountSubscriber {
|
|
|
214
214
|
this.isSubscribed = false;
|
|
215
215
|
}
|
|
216
216
|
async addSpotMarket(marketIndex) {
|
|
217
|
+
const marketPublicKey = await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex);
|
|
218
|
+
if (this.accountsToPoll.has(marketPublicKey.toString())) {
|
|
219
|
+
return true;
|
|
220
|
+
}
|
|
217
221
|
await this.addSpotMarketAccountToPoll(marketIndex);
|
|
218
|
-
const accountToPoll = this.accountsToPoll.get(
|
|
222
|
+
const accountToPoll = this.accountsToPoll.get(marketPublicKey.toString());
|
|
219
223
|
await this.addAccountToAccountLoader(accountToPoll);
|
|
220
224
|
return true;
|
|
221
225
|
}
|
|
222
226
|
async addPerpMarket(marketIndex) {
|
|
227
|
+
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, marketIndex);
|
|
228
|
+
if (this.accountsToPoll.has(marketPublicKey.toString())) {
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
223
231
|
await this.addPerpMarketAccountToPoll(marketIndex);
|
|
224
|
-
const accountToPoll = this.accountsToPoll.get(
|
|
232
|
+
const accountToPoll = this.accountsToPoll.get(marketPublicKey.toString());
|
|
225
233
|
await this.addAccountToAccountLoader(accountToPoll);
|
|
226
234
|
return true;
|
|
227
235
|
}
|
|
228
236
|
async addOracle(oracleInfo) {
|
|
229
|
-
if (oracleInfo.publicKey.equals(web3_js_1.PublicKey.default)
|
|
237
|
+
if (oracleInfo.publicKey.equals(web3_js_1.PublicKey.default) ||
|
|
238
|
+
this.oraclesToPoll.has(oracleInfo.publicKey.toString())) {
|
|
230
239
|
return true;
|
|
231
240
|
}
|
|
232
241
|
this.addOracleToPoll(oracleInfo);
|
package/lib/accounts/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { SpotMarketAccount, PerpMarketAccount, OracleSource, StateAccount, UserAccount, UserStatsAccount } from '../types';
|
|
4
3
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
5
4
|
import { EventEmitter } from 'events';
|
package/lib/adminClient.js
CHANGED
|
@@ -54,7 +54,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
54
54
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
55
55
|
},
|
|
56
56
|
});
|
|
57
|
-
const { txSig: initializeTxSig } = await
|
|
57
|
+
const { txSig: initializeTxSig } = await super.sendTransaction(initializeTx, [], this.opts);
|
|
58
58
|
return [initializeTxSig];
|
|
59
59
|
}
|
|
60
60
|
async initializeSpotMarket(mint, optimalUtilization, optimalRate, maxRate, oracle, oracleSource, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0, liquidatorFee = 0, activeStatus = true, name = userName_1.DEFAULT_MARKET_NAME) {
|
|
@@ -78,7 +78,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
78
78
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
79
79
|
},
|
|
80
80
|
});
|
|
81
|
-
const { txSig } = await this.
|
|
81
|
+
const { txSig } = await this.sendTransaction(initializeTx, [], this.opts);
|
|
82
82
|
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
83
83
|
await this.accountSubscriber.addOracle({
|
|
84
84
|
source: oracleSource,
|
|
@@ -89,7 +89,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
89
89
|
async initializeSerumFulfillmentConfig(marketIndex, serumMarket, serumProgram) {
|
|
90
90
|
const serumOpenOrders = (0, pda_1.getSerumOpenOrdersPublicKey)(this.program.programId, serumMarket);
|
|
91
91
|
const serumFulfillmentConfig = (0, pda_1.getSerumFulfillmentConfigPublicKey)(this.program.programId, serumMarket);
|
|
92
|
-
|
|
92
|
+
const tx = await this.program.transaction.initializeSerumFulfillmentConfig(marketIndex, {
|
|
93
93
|
accounts: {
|
|
94
94
|
admin: this.wallet.publicKey,
|
|
95
95
|
state: await this.getStatePublicKey(),
|
|
@@ -104,9 +104,12 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
104
104
|
serumFulfillmentConfig,
|
|
105
105
|
},
|
|
106
106
|
});
|
|
107
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
108
|
+
return txSig;
|
|
107
109
|
}
|
|
108
110
|
async initializePerpMarket(priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidatorFee = 0, activeStatus = true, name = userName_1.DEFAULT_MARKET_NAME) {
|
|
109
|
-
const
|
|
111
|
+
const currentPerpMarketIndex = this.getStateAccount().numberOfMarkets;
|
|
112
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, currentPerpMarketIndex);
|
|
110
113
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
111
114
|
const initializeMarketTx = await this.program.transaction.initializePerpMarket(baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidatorFee, activeStatus, nameBuffer, {
|
|
112
115
|
accounts: {
|
|
@@ -118,8 +121,11 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
118
121
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
119
122
|
},
|
|
120
123
|
});
|
|
121
|
-
const { txSig } = await this.
|
|
122
|
-
|
|
124
|
+
const { txSig } = await this.sendTransaction(initializeMarketTx, [], this.opts);
|
|
125
|
+
while (this.getStateAccount().numberOfMarkets <= currentPerpMarketIndex) {
|
|
126
|
+
await this.fetchAccounts();
|
|
127
|
+
}
|
|
128
|
+
await this.accountSubscriber.addPerpMarket(currentPerpMarketIndex);
|
|
123
129
|
await this.accountSubscriber.addOracle({
|
|
124
130
|
source: oracleSource,
|
|
125
131
|
publicKey: priceOracle,
|
|
@@ -131,16 +137,18 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
131
137
|
if (sqrtK == undefined) {
|
|
132
138
|
sqrtK = (0, utils_1.squareRootBN)(baseAssetReserve.mul(quoteAssetReserve));
|
|
133
139
|
}
|
|
134
|
-
|
|
140
|
+
const tx = await this.program.transaction.moveAmmPrice(baseAssetReserve, quoteAssetReserve, sqrtK, {
|
|
135
141
|
accounts: {
|
|
136
142
|
state: await this.getStatePublicKey(),
|
|
137
143
|
admin: this.wallet.publicKey,
|
|
138
144
|
perpMarket: marketPublicKey,
|
|
139
145
|
},
|
|
140
146
|
});
|
|
147
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
148
|
+
return txSig;
|
|
141
149
|
}
|
|
142
150
|
async updateK(perpMarketIndex, sqrtK) {
|
|
143
|
-
|
|
151
|
+
const tx = await this.program.transaction.updateK(sqrtK, {
|
|
144
152
|
accounts: {
|
|
145
153
|
state: await this.getStatePublicKey(),
|
|
146
154
|
admin: this.wallet.publicKey,
|
|
@@ -148,6 +156,8 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
148
156
|
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
149
157
|
},
|
|
150
158
|
});
|
|
159
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
160
|
+
return txSig;
|
|
151
161
|
}
|
|
152
162
|
async updatePerpMarketConcentrationScale(perpMarketIndex, concentrationScale) {
|
|
153
163
|
return await this.program.rpc.updatePerpMarketConcentrationCoef(concentrationScale, {
|
|
@@ -164,18 +174,20 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
164
174
|
);
|
|
165
175
|
const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(perpMarket.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
|
|
166
176
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
167
|
-
|
|
177
|
+
const tx = await this.program.transaction.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, perpMarket.amm.sqrtK, {
|
|
168
178
|
accounts: {
|
|
169
179
|
state: await this.getStatePublicKey(),
|
|
170
180
|
admin: this.wallet.publicKey,
|
|
171
181
|
perpMarket: perpMarketPublicKey,
|
|
172
182
|
},
|
|
173
183
|
});
|
|
184
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
185
|
+
return txSig;
|
|
174
186
|
}
|
|
175
187
|
async repegAmmCurve(newPeg, perpMarketIndex) {
|
|
176
188
|
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
177
189
|
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
178
|
-
|
|
190
|
+
const tx = await this.program.transaction.repegAmmCurve(newPeg, {
|
|
179
191
|
accounts: {
|
|
180
192
|
state: await this.getStatePublicKey(),
|
|
181
193
|
admin: this.wallet.publicKey,
|
|
@@ -183,6 +195,8 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
183
195
|
perpMarket: perpMarketPublicKey,
|
|
184
196
|
},
|
|
185
197
|
});
|
|
198
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
199
|
+
return txSig;
|
|
186
200
|
}
|
|
187
201
|
async updatePerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
188
202
|
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
@@ -210,7 +224,7 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
210
224
|
}
|
|
211
225
|
async depositIntoPerpMarketFeePool(perpMarketIndex, amount, sourceVault) {
|
|
212
226
|
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
213
|
-
|
|
227
|
+
const tx = await this.program.transaction.depositIntoPerpMarketFeePool(amount, {
|
|
214
228
|
accounts: {
|
|
215
229
|
admin: this.wallet.publicKey,
|
|
216
230
|
state: await this.getStatePublicKey(),
|
|
@@ -222,14 +236,18 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
222
236
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
223
237
|
},
|
|
224
238
|
});
|
|
239
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
240
|
+
return txSig;
|
|
225
241
|
}
|
|
226
242
|
async updateAdmin(admin) {
|
|
227
|
-
|
|
243
|
+
const tx = await this.program.transaction.updateAdmin(admin, {
|
|
228
244
|
accounts: {
|
|
229
245
|
admin: this.wallet.publicKey,
|
|
230
246
|
state: await this.getStatePublicKey(),
|
|
231
247
|
},
|
|
232
248
|
});
|
|
249
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
250
|
+
return txSig;
|
|
233
251
|
}
|
|
234
252
|
async updatePerpMarketCurveUpdateIntensity(perpMarketIndex, curveUpdateIntensity) {
|
|
235
253
|
// assert(curveUpdateIntensity >= 0 && curveUpdateIntensity <= 100);
|
|
@@ -243,13 +261,15 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
243
261
|
});
|
|
244
262
|
}
|
|
245
263
|
async updatePerpMarketMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
246
|
-
|
|
264
|
+
const tx = await this.program.transaction.updatePerpMarketMarginRatio(marginRatioInitial, marginRatioMaintenance, {
|
|
247
265
|
accounts: {
|
|
248
266
|
admin: this.wallet.publicKey,
|
|
249
267
|
state: await this.getStatePublicKey(),
|
|
250
268
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
251
269
|
},
|
|
252
270
|
});
|
|
271
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
272
|
+
return txSig;
|
|
253
273
|
}
|
|
254
274
|
async updatePerpMarketImfFactor(perpMarketIndex, imfFactor, unrealizedPnlImfFactor) {
|
|
255
275
|
return await this.program.rpc.updatePerpMarketImfFactor(imfFactor, unrealizedPnlImfFactor, {
|
|
@@ -261,32 +281,38 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
261
281
|
});
|
|
262
282
|
}
|
|
263
283
|
async updatePerpMarketBaseSpread(perpMarketIndex, baseSpread) {
|
|
264
|
-
|
|
284
|
+
const tx = await this.program.transaction.updatePerpMarketBaseSpread(baseSpread, {
|
|
265
285
|
accounts: {
|
|
266
286
|
admin: this.wallet.publicKey,
|
|
267
287
|
state: await this.getStatePublicKey(),
|
|
268
288
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
269
289
|
},
|
|
270
290
|
});
|
|
291
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
292
|
+
return txSig;
|
|
271
293
|
}
|
|
272
294
|
async updateAmmJitIntensity(perpMarketIndex, ammJitIntensity) {
|
|
273
|
-
|
|
295
|
+
const tx = await this.program.transaction.updateAmmJitIntensity(ammJitIntensity, {
|
|
274
296
|
accounts: {
|
|
275
297
|
admin: this.wallet.publicKey,
|
|
276
298
|
state: await this.getStatePublicKey(),
|
|
277
299
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
278
300
|
},
|
|
279
301
|
});
|
|
302
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
303
|
+
return txSig;
|
|
280
304
|
}
|
|
281
305
|
async updatePerpMarketName(perpMarketIndex, name) {
|
|
282
306
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
283
|
-
|
|
307
|
+
const tx = await this.program.transaction.updatePerpMarketName(nameBuffer, {
|
|
284
308
|
accounts: {
|
|
285
309
|
admin: this.wallet.publicKey,
|
|
286
310
|
state: await this.getStatePublicKey(),
|
|
287
311
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
288
312
|
},
|
|
289
313
|
});
|
|
314
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
315
|
+
return txSig;
|
|
290
316
|
}
|
|
291
317
|
async updateSpotMarketName(spotMarketIndex, name) {
|
|
292
318
|
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
@@ -309,20 +335,24 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
309
335
|
});
|
|
310
336
|
}
|
|
311
337
|
async updatePerpFeeStructure(feeStructure) {
|
|
312
|
-
|
|
338
|
+
const tx = this.program.transaction.updatePerpFeeStructure(feeStructure, {
|
|
313
339
|
accounts: {
|
|
314
340
|
admin: this.wallet.publicKey,
|
|
315
341
|
state: await this.getStatePublicKey(),
|
|
316
342
|
},
|
|
317
343
|
});
|
|
344
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
345
|
+
return txSig;
|
|
318
346
|
}
|
|
319
347
|
async updateSpotFeeStructure(feeStructure) {
|
|
320
|
-
|
|
348
|
+
const tx = await this.program.transaction.updateSpotFeeStructure(feeStructure, {
|
|
321
349
|
accounts: {
|
|
322
350
|
admin: this.wallet.publicKey,
|
|
323
351
|
state: await this.getStatePublicKey(),
|
|
324
352
|
},
|
|
325
353
|
});
|
|
354
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
355
|
+
return txSig;
|
|
326
356
|
}
|
|
327
357
|
async updateInitialPctToLiquidate(initialPctToLiquidate) {
|
|
328
358
|
return await this.program.rpc.updateInitialPctToLiquidate(initialPctToLiquidate, {
|
|
@@ -341,12 +371,14 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
341
371
|
});
|
|
342
372
|
}
|
|
343
373
|
async updateOracleGuardRails(oracleGuardRails) {
|
|
344
|
-
|
|
374
|
+
const tx = await this.program.transaction.updateOracleGuardRails(oracleGuardRails, {
|
|
345
375
|
accounts: {
|
|
346
376
|
admin: this.wallet.publicKey,
|
|
347
377
|
state: await this.getStatePublicKey(),
|
|
348
378
|
},
|
|
349
379
|
});
|
|
380
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
381
|
+
return txSig;
|
|
350
382
|
}
|
|
351
383
|
async updateStateSettlementDuration(settlementDuration) {
|
|
352
384
|
return await this.program.rpc.updateStateSettlementDuration(settlementDuration, {
|
|
@@ -357,60 +389,72 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
357
389
|
});
|
|
358
390
|
}
|
|
359
391
|
async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold) {
|
|
360
|
-
|
|
392
|
+
const tx = await this.program.transaction.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
|
|
361
393
|
accounts: {
|
|
362
394
|
admin: this.wallet.publicKey,
|
|
363
395
|
state: await this.getStatePublicKey(),
|
|
364
396
|
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
365
397
|
},
|
|
366
398
|
});
|
|
399
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
400
|
+
return txSig;
|
|
367
401
|
}
|
|
368
402
|
async updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor) {
|
|
369
|
-
|
|
403
|
+
const tx = await this.program.transaction.updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor, {
|
|
370
404
|
accounts: {
|
|
371
405
|
admin: this.wallet.publicKey,
|
|
372
406
|
state: await this.getStatePublicKey(),
|
|
373
407
|
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
374
408
|
},
|
|
375
409
|
});
|
|
410
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
411
|
+
return txSig;
|
|
376
412
|
}
|
|
377
413
|
async updateSpotMarketRevenueSettlePeriod(spotMarketIndex, revenueSettlePeriod) {
|
|
378
|
-
|
|
414
|
+
const tx = await this.program.transaction.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
|
|
379
415
|
accounts: {
|
|
380
416
|
admin: this.wallet.publicKey,
|
|
381
417
|
state: await this.getStatePublicKey(),
|
|
382
418
|
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
383
419
|
},
|
|
384
420
|
});
|
|
421
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
422
|
+
return txSig;
|
|
385
423
|
}
|
|
386
424
|
async updateSpotMarketMaxTokenDeposits(spotMarketIndex, maxTokenDeposits) {
|
|
387
|
-
|
|
425
|
+
const tx = this.program.transaction.updateSpotMarketMaxTokenDeposits(maxTokenDeposits, {
|
|
388
426
|
accounts: {
|
|
389
427
|
admin: this.wallet.publicKey,
|
|
390
428
|
state: await this.getStatePublicKey(),
|
|
391
429
|
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
392
430
|
},
|
|
393
431
|
});
|
|
432
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
433
|
+
return txSig;
|
|
394
434
|
}
|
|
395
435
|
async updateInsuranceFundUnstakingPeriod(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
396
|
-
|
|
436
|
+
const tx = await this.program.transaction.updateInsuranceFundUnstakingPeriod(insuranceWithdrawEscrowPeriod, {
|
|
397
437
|
accounts: {
|
|
398
438
|
admin: this.wallet.publicKey,
|
|
399
439
|
state: await this.getStatePublicKey(),
|
|
400
440
|
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
401
441
|
},
|
|
402
442
|
});
|
|
443
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
444
|
+
return txSig;
|
|
403
445
|
}
|
|
404
446
|
async updateLpCooldownTime(cooldownTime) {
|
|
405
|
-
|
|
447
|
+
const tx = await this.program.transaction.updateLpCooldownTime(cooldownTime, {
|
|
406
448
|
accounts: {
|
|
407
449
|
admin: this.wallet.publicKey,
|
|
408
450
|
state: await this.getStatePublicKey(),
|
|
409
451
|
},
|
|
410
452
|
});
|
|
453
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
454
|
+
return txSig;
|
|
411
455
|
}
|
|
412
456
|
async updatePerpMarketOracle(perpMarketIndex, oracle, oracleSource) {
|
|
413
|
-
|
|
457
|
+
const tx = await this.program.transaction.updatePerpMarketOracle(oracle, oracleSource, {
|
|
414
458
|
accounts: {
|
|
415
459
|
admin: this.wallet.publicKey,
|
|
416
460
|
state: await this.getStatePublicKey(),
|
|
@@ -418,15 +462,19 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
418
462
|
oracle: oracle,
|
|
419
463
|
},
|
|
420
464
|
});
|
|
465
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
466
|
+
return txSig;
|
|
421
467
|
}
|
|
422
468
|
async updatePerpMarketStepSizeAndTickSize(perpMarketIndex, stepSize, tickSize) {
|
|
423
|
-
|
|
469
|
+
const tx = await this.program.transaction.updatePerpMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
424
470
|
accounts: {
|
|
425
471
|
admin: this.wallet.publicKey,
|
|
426
472
|
state: await this.getStatePublicKey(),
|
|
427
473
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
428
474
|
},
|
|
429
475
|
});
|
|
476
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
477
|
+
return txSig;
|
|
430
478
|
}
|
|
431
479
|
async updatePerpMarketMinOrderSize(perpMarketIndex, orderSize) {
|
|
432
480
|
return await this.program.rpc.updatePerpMarketMinOrderSize(orderSize, {
|
|
@@ -502,20 +550,24 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
502
550
|
});
|
|
503
551
|
}
|
|
504
552
|
async updateWhitelistMint(whitelistMint) {
|
|
505
|
-
|
|
553
|
+
const tx = await this.program.transaction.updateWhitelistMint(whitelistMint, {
|
|
506
554
|
accounts: {
|
|
507
555
|
admin: this.wallet.publicKey,
|
|
508
556
|
state: await this.getStatePublicKey(),
|
|
509
557
|
},
|
|
510
558
|
});
|
|
559
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
560
|
+
return txSig;
|
|
511
561
|
}
|
|
512
562
|
async updateDiscountMint(discountMint) {
|
|
513
|
-
|
|
563
|
+
const tx = await this.program.transaction.updateDiscountMint(discountMint, {
|
|
514
564
|
accounts: {
|
|
515
565
|
admin: this.wallet.publicKey,
|
|
516
566
|
state: await this.getStatePublicKey(),
|
|
517
567
|
},
|
|
518
568
|
});
|
|
569
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
570
|
+
return txSig;
|
|
519
571
|
}
|
|
520
572
|
async updateSpotMarketMarginWeights(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = 0) {
|
|
521
573
|
return await this.program.rpc.updateSpotMarketMarginWeights(initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, {
|
|
@@ -536,48 +588,58 @@ class AdminClient extends driftClient_1.DriftClient {
|
|
|
536
588
|
});
|
|
537
589
|
}
|
|
538
590
|
async updateSpotMarketAssetTier(spotMarketIndex, assetTier) {
|
|
539
|
-
|
|
591
|
+
const tx = await this.program.transaction.updateSpotMarketAssetTier(assetTier, {
|
|
540
592
|
accounts: {
|
|
541
593
|
admin: this.wallet.publicKey,
|
|
542
594
|
state: await this.getStatePublicKey(),
|
|
543
595
|
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
544
596
|
},
|
|
545
597
|
});
|
|
598
|
+
const { txSig } = await this.sendTransaction(tx);
|
|
599
|
+
return txSig;
|
|
546
600
|
}
|
|
547
601
|
async updateSpotMarketStatus(spotMarketIndex, marketStatus) {
|
|
548
|
-
|
|
602
|
+
const tx = await this.program.transaction.updateSpotMarketStatus(marketStatus, {
|
|
549
603
|
accounts: {
|
|
550
604
|
admin: this.wallet.publicKey,
|
|
551
605
|
state: await this.getStatePublicKey(),
|
|
552
606
|
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
553
607
|
},
|
|
554
608
|
});
|
|
609
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
610
|
+
return txSig;
|
|
555
611
|
}
|
|
556
612
|
async updatePerpMarketStatus(perpMarketIndex, marketStatus) {
|
|
557
|
-
|
|
613
|
+
const tx = await this.program.transaction.updatePerpMarketStatus(marketStatus, {
|
|
558
614
|
accounts: {
|
|
559
615
|
admin: this.wallet.publicKey,
|
|
560
616
|
state: await this.getStatePublicKey(),
|
|
561
617
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
562
618
|
},
|
|
563
619
|
});
|
|
620
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
621
|
+
return txSig;
|
|
564
622
|
}
|
|
565
623
|
async updatePerpMarketContractTier(perpMarketIndex, contractTier) {
|
|
566
|
-
|
|
624
|
+
const tx = await this.program.transaction.updatePerpMarketContractTier(contractTier, {
|
|
567
625
|
accounts: {
|
|
568
626
|
admin: this.wallet.publicKey,
|
|
569
627
|
state: await this.getStatePublicKey(),
|
|
570
628
|
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
571
629
|
},
|
|
572
630
|
});
|
|
631
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
632
|
+
return txSig;
|
|
573
633
|
}
|
|
574
634
|
async updateExchangeStatus(exchangeStatus) {
|
|
575
|
-
|
|
635
|
+
const tx = await this.program.transaction.updateExchangeStatus(exchangeStatus, {
|
|
576
636
|
accounts: {
|
|
577
637
|
admin: this.wallet.publicKey,
|
|
578
638
|
state: await this.getStatePublicKey(),
|
|
579
639
|
},
|
|
580
640
|
});
|
|
641
|
+
const { txSig } = await this.sendTransaction(tx, [], this.opts);
|
|
642
|
+
return txSig;
|
|
581
643
|
}
|
|
582
644
|
async updatePerpAuctionDuration(minDuration) {
|
|
583
645
|
return await this.program.rpc.updatePerpAuctionDuration(typeof minDuration === 'number' ? minDuration : minDuration.toNumber(), {
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
import { AnchorProvider, BN, Program } from '@project-serum/anchor';
|
|
4
4
|
import { StateAccount, IWallet, PositionDirection, UserAccount, PerpMarketAccount, OrderParams, Order, SpotMarketAccount, SpotPosition, MakerInfo, TakerInfo, OptionalOrderParams, ReferrerInfo, MarketType, SerumV3FulfillmentConfigAccount } from './types';
|
|
5
5
|
import * as anchor from '@project-serum/anchor';
|
|
6
|
-
import { Connection, PublicKey, TransactionSignature, ConfirmOptions, Transaction, TransactionInstruction, AccountMeta } from '@solana/web3.js';
|
|
6
|
+
import { Connection, PublicKey, TransactionSignature, ConfirmOptions, Transaction, TransactionInstruction, AccountMeta, Signer } from '@solana/web3.js';
|
|
7
7
|
import { TokenFaucet } from './tokenFaucet';
|
|
8
8
|
import { EventEmitter } from 'events';
|
|
9
9
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
10
10
|
import { DriftClientAccountSubscriber, DriftClientAccountEvents, DataAndSlot } from './accounts/types';
|
|
11
|
-
import { TxSender } from './tx/types';
|
|
11
|
+
import { TxSender, TxSigAndSlot } from './tx/types';
|
|
12
12
|
import { OraclePriceData } from './oracles/types';
|
|
13
13
|
import { DriftClientConfig } from './driftClientConfig';
|
|
14
14
|
import { User } from './user';
|
|
@@ -253,5 +253,6 @@ export declare class DriftClient {
|
|
|
253
253
|
settleRevenueToInsuranceFund(marketIndex: number): Promise<TransactionSignature>;
|
|
254
254
|
resolvePerpPnlDeficit(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionSignature>;
|
|
255
255
|
getResolvePerpPnlDeficitIx(spotMarketIndex: number, perpMarketIndex: number): Promise<TransactionInstruction>;
|
|
256
|
+
sendTransaction(tx: Transaction, additionalSigners?: Array<Signer>, opts?: ConfirmOptions, preSigned?: boolean): Promise<TxSigAndSlot>;
|
|
256
257
|
}
|
|
257
258
|
export {};
|