@drift-labs/sdk 0.2.0-master.25 → 0.2.0-master.26
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/pollingClearingHouseAccountSubscriber.d.ts +13 -13
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +27 -27
- package/lib/accounts/types.d.ts +8 -9
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +14 -14
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +35 -34
- package/lib/addresses/pda.d.ts +7 -6
- package/lib/addresses/pda.js +31 -27
- package/lib/admin.d.ts +9 -6
- package/lib/admin.js +83 -42
- package/lib/clearingHouse.d.ts +69 -42
- package/lib/clearingHouse.js +753 -277
- package/lib/clearingHouseConfig.d.ts +2 -2
- package/lib/clearingHouseUser.d.ts +16 -16
- package/lib/clearingHouseUser.js +139 -119
- package/lib/config.d.ts +7 -7
- package/lib/config.js +20 -20
- package/lib/constants/numericConstants.d.ts +12 -12
- package/lib/constants/numericConstants.js +13 -13
- package/lib/constants/{markets.d.ts → perpMarkets.d.ts} +5 -5
- package/{src/constants/markets.js → lib/constants/perpMarkets.js} +4 -4
- package/lib/constants/{banks.d.ts → spotMarkets.d.ts} +6 -6
- package/lib/constants/{banks.js → spotMarkets.js} +16 -16
- package/lib/events/types.d.ts +2 -1
- package/lib/events/types.js +1 -0
- package/lib/examples/makeTradeExample.js +7 -7
- package/lib/idl/clearing_house.json +1008 -279
- package/lib/index.d.ts +5 -3
- package/lib/index.js +5 -3
- package/lib/math/amm.d.ts +2 -2
- package/lib/math/amm.js +1 -1
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +2 -1
- package/lib/math/margin.d.ts +4 -4
- package/lib/math/margin.js +18 -11
- package/lib/math/market.d.ts +10 -9
- package/lib/math/market.js +29 -6
- package/lib/math/oracles.d.ts +2 -1
- package/lib/math/oracles.js +11 -1
- package/lib/math/orders.d.ts +5 -5
- package/lib/math/position.d.ts +13 -13
- package/lib/math/position.js +19 -19
- package/lib/math/spotBalance.d.ts +19 -0
- package/lib/math/spotBalance.js +176 -0
- package/lib/math/spotMarket.d.ts +4 -0
- package/lib/math/spotMarket.js +8 -0
- package/lib/math/spotPosition.d.ts +2 -0
- package/lib/math/spotPosition.js +8 -0
- package/lib/math/state.js +2 -2
- package/lib/math/trade.d.ts +4 -4
- package/lib/orderParams.d.ts +4 -4
- package/lib/orderParams.js +12 -4
- package/lib/serum/serumSubscriber.d.ts +23 -0
- package/lib/serum/serumSubscriber.js +41 -0
- package/lib/serum/types.d.ts +11 -0
- package/lib/serum/types.js +2 -0
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +4 -2
- package/lib/tx/types.d.ts +1 -1
- package/lib/types.d.ts +123 -33
- package/lib/types.js +31 -9
- package/my-script/.env +7 -0
- package/my-script/getUserStats.ts +106 -0
- package/my-script/multiConnections.ts +119 -0
- package/my-script/test-regex.ts +11 -0
- package/my-script/utils.ts +52 -0
- package/package.json +1 -1
- package/src/accounts/bulkAccountLoader.js +249 -0
- package/src/accounts/bulkUserStatsSubscription.js +75 -0
- package/src/accounts/bulkUserSubscription.js +75 -0
- package/src/accounts/fetch.js +92 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.js +465 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +38 -38
- package/src/accounts/pollingOracleSubscriber.js +156 -0
- package/src/accounts/pollingTokenAccountSubscriber.js +141 -0
- package/src/accounts/pollingUserAccountSubscriber.js +208 -0
- package/src/accounts/pollingUserStatsAccountSubscriber.js +208 -0
- package/src/accounts/types.js +28 -0
- package/src/accounts/types.ts +11 -9
- package/src/accounts/utils.js +7 -0
- package/src/accounts/webSocketAccountSubscriber.js +138 -0
- package/src/accounts/webSocketClearingHouseAccountSubscriber.js +433 -0
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +59 -52
- package/src/accounts/webSocketUserAccountSubscriber.js +113 -0
- package/src/accounts/webSocketUserStatsAccountSubsriber.js +113 -0
- package/src/addresses/pda.js +186 -0
- package/src/addresses/pda.ts +49 -44
- package/src/admin.js +1284 -0
- package/src/admin.ts +140 -47
- package/src/assert/assert.js +1 -1
- package/src/clearingHouse.js +3433 -0
- package/src/clearingHouse.ts +1083 -378
- package/src/clearingHouseConfig.js +2 -0
- package/src/clearingHouseConfig.ts +2 -2
- package/src/clearingHouseUser.js +874 -0
- package/src/clearingHouseUser.ts +232 -168
- package/src/clearingHouseUserConfig.js +2 -0
- package/src/clearingHouseUserStats.js +115 -0
- package/src/clearingHouseUserStatsConfig.js +2 -0
- package/src/config.js +80 -0
- package/src/config.ts +29 -29
- package/src/constants/numericConstants.js +18 -11
- package/src/constants/numericConstants.ts +17 -15
- package/{lib/constants/markets.js → src/constants/perpMarkets.js} +11 -11
- package/src/constants/{markets.ts → perpMarkets.ts} +5 -5
- package/src/constants/spotMarkets.js +51 -0
- package/src/constants/{banks.ts → spotMarkets.ts} +19 -19
- package/src/events/eventList.js +66 -23
- package/src/events/eventSubscriber.js +202 -0
- package/src/events/fetchLogs.js +117 -0
- package/src/events/pollingLogProvider.js +113 -0
- package/src/events/sort.js +41 -0
- package/src/events/txEventCache.js +22 -19
- package/src/events/types.js +25 -0
- package/src/events/types.ts +3 -0
- package/src/events/webSocketLogProvider.js +76 -0
- package/src/examples/makeTradeExample.ts +10 -8
- package/src/factory/bigNum.js +183 -180
- package/src/factory/oracleClient.js +9 -9
- package/src/idl/clearing_house.json +1008 -279
- package/src/index.js +75 -0
- package/src/index.ts +5 -3
- package/src/math/amm.js +422 -0
- package/src/math/amm.ts +6 -3
- package/src/math/auction.js +10 -10
- package/src/math/conversion.js +4 -3
- package/src/math/funding.js +223 -175
- package/src/math/funding.ts +7 -7
- package/src/math/insurance.js +27 -0
- package/src/math/margin.js +77 -0
- package/src/math/margin.ts +34 -23
- package/src/math/market.js +105 -0
- package/src/math/market.ts +71 -19
- package/src/math/oracles.js +40 -10
- package/src/math/oracles.ts +18 -1
- package/src/math/orders.js +153 -0
- package/src/math/orders.ts +5 -5
- package/src/math/position.js +172 -0
- package/src/math/position.ts +31 -31
- package/src/math/repeg.js +40 -40
- package/src/math/spotBalance.js +176 -0
- package/src/math/spotBalance.ts +290 -0
- package/src/math/spotMarket.js +8 -0
- package/src/math/spotMarket.ts +9 -0
- package/src/math/spotPosition.js +8 -0
- package/src/math/spotPosition.ts +6 -0
- package/src/math/state.ts +2 -2
- package/src/math/trade.js +81 -74
- package/src/math/trade.ts +4 -4
- package/src/math/utils.js +8 -7
- package/src/oracles/oracleClientCache.js +10 -9
- package/src/oracles/pythClient.js +52 -17
- package/src/oracles/quoteAssetOracleClient.js +44 -13
- package/src/oracles/switchboardClient.js +69 -37
- package/src/oracles/types.js +1 -1
- package/src/orderParams.js +14 -6
- package/src/orderParams.ts +16 -8
- package/src/serum/serumSubscriber.js +102 -0
- package/src/serum/serumSubscriber.ts +80 -0
- package/src/serum/types.js +2 -0
- package/src/serum/types.ts +13 -0
- package/src/slot/SlotSubscriber.js +67 -20
- package/src/token/index.js +4 -4
- package/src/tokenFaucet.js +288 -154
- package/src/tx/retryTxSender.js +280 -0
- package/src/tx/retryTxSender.ts +5 -2
- package/src/tx/types.js +1 -1
- package/src/tx/types.ts +2 -1
- package/src/tx/utils.js +7 -6
- package/src/types.js +216 -0
- package/src/types.ts +110 -33
- package/src/userName.js +5 -5
- package/src/util/computeUnits.js +46 -11
- package/src/util/promiseTimeout.js +5 -5
- package/src/util/tps.js +46 -12
- package/src/wallet.js +55 -18
- package/lib/math/bankBalance.d.ts +0 -15
- package/lib/math/bankBalance.js +0 -150
- package/src/addresses/marketAddresses.js +0 -26
- package/src/constants/banks.js +0 -42
- package/src/examples/makeTradeExample.js +0 -80
- package/src/math/bankBalance.ts +0 -258
- package/src/math/state.js +0 -15
- package/src/math/utils.js.map +0 -1
- package/src/util/getTokenAddress.js +0 -9
package/src/admin.ts
CHANGED
|
@@ -13,11 +13,14 @@ import { BN } from '@project-serum/anchor';
|
|
|
13
13
|
import * as anchor from '@project-serum/anchor';
|
|
14
14
|
import {
|
|
15
15
|
getClearingHouseStateAccountPublicKeyAndNonce,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
getSpotMarketPublicKey,
|
|
17
|
+
getSpotMarketVaultPublicKey,
|
|
18
18
|
getMarketPublicKey,
|
|
19
19
|
getInsuranceFundVaultPublicKey,
|
|
20
|
+
getSerumOpenOrdersPublicKey,
|
|
21
|
+
getSerumFulfillmentConfigPublicKey,
|
|
20
22
|
} from './addresses/pda';
|
|
23
|
+
import { squareRootBN } from './math/utils';
|
|
21
24
|
import { TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
|
22
25
|
import { ClearingHouse } from './clearingHouse';
|
|
23
26
|
import { PEG_PRECISION, ZERO } from './constants/numericConstants';
|
|
@@ -71,7 +74,7 @@ export class Admin extends ClearingHouse {
|
|
|
71
74
|
return [initializeTxSig];
|
|
72
75
|
}
|
|
73
76
|
|
|
74
|
-
public async
|
|
77
|
+
public async initializeSpotMarket(
|
|
75
78
|
mint: PublicKey,
|
|
76
79
|
optimalUtilization: BN,
|
|
77
80
|
optimalRate: BN,
|
|
@@ -85,20 +88,23 @@ export class Admin extends ClearingHouse {
|
|
|
85
88
|
imfFactor = new BN(0),
|
|
86
89
|
liquidationFee = ZERO
|
|
87
90
|
): Promise<TransactionSignature> {
|
|
88
|
-
const
|
|
89
|
-
const
|
|
91
|
+
const spotMarketIndex = this.getStateAccount().numberOfSpotMarkets;
|
|
92
|
+
const spotMarket = await getSpotMarketPublicKey(
|
|
93
|
+
this.program.programId,
|
|
94
|
+
spotMarketIndex
|
|
95
|
+
);
|
|
90
96
|
|
|
91
|
-
const
|
|
97
|
+
const spotMarketVault = await getSpotMarketVaultPublicKey(
|
|
92
98
|
this.program.programId,
|
|
93
|
-
|
|
99
|
+
spotMarketIndex
|
|
94
100
|
);
|
|
95
101
|
|
|
96
102
|
const insuranceFundVault = await getInsuranceFundVaultPublicKey(
|
|
97
103
|
this.program.programId,
|
|
98
|
-
|
|
104
|
+
spotMarketIndex
|
|
99
105
|
);
|
|
100
106
|
|
|
101
|
-
const initializeTx = await this.program.transaction.
|
|
107
|
+
const initializeTx = await this.program.transaction.initializeSpotMarket(
|
|
102
108
|
optimalUtilization,
|
|
103
109
|
optimalRate,
|
|
104
110
|
maxRate,
|
|
@@ -113,11 +119,11 @@ export class Admin extends ClearingHouse {
|
|
|
113
119
|
accounts: {
|
|
114
120
|
admin: this.wallet.publicKey,
|
|
115
121
|
state: await this.getStatePublicKey(),
|
|
116
|
-
|
|
117
|
-
|
|
122
|
+
spotMarket,
|
|
123
|
+
spotMarketVault,
|
|
118
124
|
insuranceFundVault,
|
|
119
125
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
120
|
-
|
|
126
|
+
spotMarketMint: mint,
|
|
121
127
|
oracle,
|
|
122
128
|
rent: SYSVAR_RENT_PUBKEY,
|
|
123
129
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
@@ -128,7 +134,7 @@ export class Admin extends ClearingHouse {
|
|
|
128
134
|
|
|
129
135
|
const { txSig } = await this.txSender.send(initializeTx, [], this.opts);
|
|
130
136
|
|
|
131
|
-
await this.accountSubscriber.
|
|
137
|
+
await this.accountSubscriber.addSpotMarket(spotMarketIndex);
|
|
132
138
|
await this.accountSubscriber.addOracle({
|
|
133
139
|
source: oracleSource,
|
|
134
140
|
publicKey: oracle,
|
|
@@ -137,6 +143,41 @@ export class Admin extends ClearingHouse {
|
|
|
137
143
|
return txSig;
|
|
138
144
|
}
|
|
139
145
|
|
|
146
|
+
public async initializeSerumFulfillmentConfig(
|
|
147
|
+
marketIndex: BN,
|
|
148
|
+
serumMarket: PublicKey,
|
|
149
|
+
serumProgram: PublicKey
|
|
150
|
+
): Promise<TransactionSignature> {
|
|
151
|
+
const serumOpenOrders = getSerumOpenOrdersPublicKey(
|
|
152
|
+
this.program.programId,
|
|
153
|
+
serumMarket
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
const serumFulfillmentConfig = getSerumFulfillmentConfigPublicKey(
|
|
157
|
+
this.program.programId,
|
|
158
|
+
serumMarket
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
return await this.program.rpc.initializeSerumFulfillmentConfig(
|
|
162
|
+
marketIndex,
|
|
163
|
+
{
|
|
164
|
+
accounts: {
|
|
165
|
+
admin: this.wallet.publicKey,
|
|
166
|
+
state: await this.getStatePublicKey(),
|
|
167
|
+
baseSpotMarket: this.getSpotMarketAccount(marketIndex).pubkey,
|
|
168
|
+
quoteSpotMarket: this.getQuoteSpotMarketAccount().pubkey,
|
|
169
|
+
clearingHouseSigner: this.getSignerPublicKey(),
|
|
170
|
+
serumProgram,
|
|
171
|
+
serumMarket,
|
|
172
|
+
serumOpenOrders,
|
|
173
|
+
rent: SYSVAR_RENT_PUBKEY,
|
|
174
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
175
|
+
serumFulfillmentConfig,
|
|
176
|
+
},
|
|
177
|
+
}
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
140
181
|
public async initializeMarket(
|
|
141
182
|
priceOracle: PublicKey,
|
|
142
183
|
baseAssetReserve: BN,
|
|
@@ -179,7 +220,7 @@ export class Admin extends ClearingHouse {
|
|
|
179
220
|
this.opts
|
|
180
221
|
);
|
|
181
222
|
|
|
182
|
-
await this.accountSubscriber.
|
|
223
|
+
await this.accountSubscriber.addPerpMarket(
|
|
183
224
|
this.getStateAccount().numberOfMarkets
|
|
184
225
|
);
|
|
185
226
|
await this.accountSubscriber.addOracle({
|
|
@@ -191,23 +232,29 @@ export class Admin extends ClearingHouse {
|
|
|
191
232
|
}
|
|
192
233
|
|
|
193
234
|
public async moveAmmPrice(
|
|
235
|
+
marketIndex: BN,
|
|
194
236
|
baseAssetReserve: BN,
|
|
195
237
|
quoteAssetReserve: BN,
|
|
196
|
-
|
|
238
|
+
sqrtK?: BN
|
|
197
239
|
): Promise<TransactionSignature> {
|
|
198
240
|
const marketPublicKey = await getMarketPublicKey(
|
|
199
241
|
this.program.programId,
|
|
200
242
|
marketIndex
|
|
201
243
|
);
|
|
202
244
|
|
|
245
|
+
if (sqrtK == undefined) {
|
|
246
|
+
sqrtK = squareRootBN(baseAssetReserve.mul(quoteAssetReserve));
|
|
247
|
+
}
|
|
248
|
+
|
|
203
249
|
return await this.program.rpc.moveAmmPrice(
|
|
204
250
|
baseAssetReserve,
|
|
205
251
|
quoteAssetReserve,
|
|
252
|
+
sqrtK,
|
|
206
253
|
{
|
|
207
254
|
accounts: {
|
|
208
255
|
state: await this.getStatePublicKey(),
|
|
209
256
|
admin: this.wallet.publicKey,
|
|
210
|
-
|
|
257
|
+
perpMarket: marketPublicKey,
|
|
211
258
|
},
|
|
212
259
|
}
|
|
213
260
|
);
|
|
@@ -222,16 +269,16 @@ export class Admin extends ClearingHouse {
|
|
|
222
269
|
state: await this.getStatePublicKey(),
|
|
223
270
|
admin: this.wallet.publicKey,
|
|
224
271
|
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
225
|
-
oracle: this.
|
|
272
|
+
oracle: this.getPerpMarketAccount(marketIndex).amm.oracle,
|
|
226
273
|
},
|
|
227
274
|
});
|
|
228
275
|
}
|
|
229
276
|
|
|
230
277
|
public async moveAmmToPrice(
|
|
231
|
-
|
|
278
|
+
perpMarketIndex: BN,
|
|
232
279
|
targetPrice: BN
|
|
233
280
|
): Promise<TransactionSignature> {
|
|
234
|
-
const market = this.
|
|
281
|
+
const market = this.getPerpMarketAccount(perpMarketIndex);
|
|
235
282
|
|
|
236
283
|
const [direction, tradeSize, _] = calculateTargetPriceTrade(
|
|
237
284
|
market,
|
|
@@ -251,17 +298,18 @@ export class Admin extends ClearingHouse {
|
|
|
251
298
|
|
|
252
299
|
const marketPublicKey = await getMarketPublicKey(
|
|
253
300
|
this.program.programId,
|
|
254
|
-
|
|
301
|
+
perpMarketIndex
|
|
255
302
|
);
|
|
256
303
|
|
|
257
304
|
return await this.program.rpc.moveAmmPrice(
|
|
258
305
|
newBaseAssetAmount,
|
|
259
306
|
newQuoteAssetAmount,
|
|
307
|
+
market.amm.sqrtK,
|
|
260
308
|
{
|
|
261
309
|
accounts: {
|
|
262
310
|
state: await this.getStatePublicKey(),
|
|
263
311
|
admin: this.wallet.publicKey,
|
|
264
|
-
|
|
312
|
+
perpMarket: marketPublicKey,
|
|
265
313
|
},
|
|
266
314
|
}
|
|
267
315
|
);
|
|
@@ -275,7 +323,7 @@ export class Admin extends ClearingHouse {
|
|
|
275
323
|
this.program.programId,
|
|
276
324
|
marketIndex
|
|
277
325
|
);
|
|
278
|
-
const ammData = this.
|
|
326
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
279
327
|
|
|
280
328
|
return await this.program.rpc.repegAmmCurve(newPeg, {
|
|
281
329
|
accounts: {
|
|
@@ -290,7 +338,7 @@ export class Admin extends ClearingHouse {
|
|
|
290
338
|
public async updateAmmOracleTwap(
|
|
291
339
|
marketIndex: BN
|
|
292
340
|
): Promise<TransactionSignature> {
|
|
293
|
-
const ammData = this.
|
|
341
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
294
342
|
const marketPublicKey = await getMarketPublicKey(
|
|
295
343
|
this.program.programId,
|
|
296
344
|
marketIndex
|
|
@@ -309,7 +357,7 @@ export class Admin extends ClearingHouse {
|
|
|
309
357
|
public async resetAmmOracleTwap(
|
|
310
358
|
marketIndex: BN
|
|
311
359
|
): Promise<TransactionSignature> {
|
|
312
|
-
const ammData = this.
|
|
360
|
+
const ammData = this.getPerpMarketAccount(marketIndex).amm;
|
|
313
361
|
const marketPublicKey = await getMarketPublicKey(
|
|
314
362
|
this.program.programId,
|
|
315
363
|
marketIndex
|
|
@@ -330,12 +378,12 @@ export class Admin extends ClearingHouse {
|
|
|
330
378
|
recipient: PublicKey
|
|
331
379
|
): Promise<TransactionSignature> {
|
|
332
380
|
const state = await this.getStateAccount();
|
|
333
|
-
const
|
|
381
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
334
382
|
return await this.program.rpc.withdrawFromInsuranceVault(amount, {
|
|
335
383
|
accounts: {
|
|
336
384
|
admin: this.wallet.publicKey,
|
|
337
385
|
state: await this.getStatePublicKey(),
|
|
338
|
-
|
|
386
|
+
spotMarket: spotMarket.pubkey,
|
|
339
387
|
insuranceVault: state.insuranceVault,
|
|
340
388
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
341
389
|
recipient: recipient,
|
|
@@ -353,14 +401,14 @@ export class Admin extends ClearingHouse {
|
|
|
353
401
|
this.program.programId,
|
|
354
402
|
marketIndex
|
|
355
403
|
);
|
|
356
|
-
const
|
|
404
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
357
405
|
return await this.program.rpc.withdrawFromMarketToInsuranceVault(amount, {
|
|
358
406
|
accounts: {
|
|
359
407
|
admin: this.wallet.publicKey,
|
|
360
408
|
state: await this.getStatePublicKey(),
|
|
361
409
|
market: marketPublicKey,
|
|
362
|
-
|
|
363
|
-
|
|
410
|
+
spotMarket: spotMarket.pubkey,
|
|
411
|
+
spotMarketVault: spotMarket.vault,
|
|
364
412
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
365
413
|
recipient: recipient,
|
|
366
414
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
@@ -373,7 +421,7 @@ export class Admin extends ClearingHouse {
|
|
|
373
421
|
amount: BN
|
|
374
422
|
): Promise<TransactionSignature> {
|
|
375
423
|
const state = await this.getStateAccount();
|
|
376
|
-
const
|
|
424
|
+
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
377
425
|
|
|
378
426
|
return await this.program.rpc.withdrawFromInsuranceVaultToMarket(amount, {
|
|
379
427
|
accounts: {
|
|
@@ -382,8 +430,8 @@ export class Admin extends ClearingHouse {
|
|
|
382
430
|
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
383
431
|
insuranceVault: state.insuranceVault,
|
|
384
432
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
385
|
-
|
|
386
|
-
|
|
433
|
+
quoteSpotMarket: spotMarket.pubkey,
|
|
434
|
+
spotMarketVault: spotMarket.vault,
|
|
387
435
|
tokenProgram: TOKEN_PROGRAM_ID,
|
|
388
436
|
},
|
|
389
437
|
});
|
|
@@ -584,30 +632,33 @@ export class Admin extends ClearingHouse {
|
|
|
584
632
|
});
|
|
585
633
|
}
|
|
586
634
|
|
|
587
|
-
public async
|
|
588
|
-
|
|
635
|
+
public async updateWithdrawGuardThreshold(
|
|
636
|
+
marketIndex: BN,
|
|
589
637
|
withdrawGuardThreshold: BN
|
|
590
638
|
): Promise<TransactionSignature> {
|
|
591
|
-
return await this.program.rpc.
|
|
639
|
+
return await this.program.rpc.updateWithdrawGuardThreshold(
|
|
592
640
|
withdrawGuardThreshold,
|
|
593
641
|
{
|
|
594
642
|
accounts: {
|
|
595
643
|
admin: this.wallet.publicKey,
|
|
596
644
|
state: await this.getStatePublicKey(),
|
|
597
|
-
|
|
645
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
646
|
+
this.program.programId,
|
|
647
|
+
marketIndex
|
|
648
|
+
),
|
|
598
649
|
},
|
|
599
650
|
}
|
|
600
651
|
);
|
|
601
652
|
}
|
|
602
653
|
|
|
603
|
-
public async
|
|
604
|
-
|
|
654
|
+
public async updateSpotMarketIfFactor(
|
|
655
|
+
marketIndex: BN,
|
|
605
656
|
userIfFactor: BN,
|
|
606
657
|
totalIfFactor: BN,
|
|
607
658
|
liquidationIfFactor: BN
|
|
608
659
|
): Promise<TransactionSignature> {
|
|
609
|
-
return await this.program.rpc.
|
|
610
|
-
|
|
660
|
+
return await this.program.rpc.updateSpotMarketIfFactor(
|
|
661
|
+
marketIndex,
|
|
611
662
|
userIfFactor,
|
|
612
663
|
totalIfFactor,
|
|
613
664
|
liquidationIfFactor,
|
|
@@ -615,23 +666,29 @@ export class Admin extends ClearingHouse {
|
|
|
615
666
|
accounts: {
|
|
616
667
|
admin: this.wallet.publicKey,
|
|
617
668
|
state: await this.getStatePublicKey(),
|
|
618
|
-
|
|
669
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
670
|
+
this.program.programId,
|
|
671
|
+
marketIndex
|
|
672
|
+
),
|
|
619
673
|
},
|
|
620
674
|
}
|
|
621
675
|
);
|
|
622
676
|
}
|
|
623
677
|
|
|
624
|
-
public async
|
|
625
|
-
|
|
678
|
+
public async updateInsuranceWithdrawEscrowPeriod(
|
|
679
|
+
marketIndex: BN,
|
|
626
680
|
insuranceWithdrawEscrowPeriod: BN
|
|
627
681
|
): Promise<TransactionSignature> {
|
|
628
|
-
return await this.program.rpc.
|
|
682
|
+
return await this.program.rpc.updateInsuranceWithdrawEscrowPeriod(
|
|
629
683
|
insuranceWithdrawEscrowPeriod,
|
|
630
684
|
{
|
|
631
685
|
accounts: {
|
|
632
686
|
admin: this.wallet.publicKey,
|
|
633
687
|
state: await this.getStatePublicKey(),
|
|
634
|
-
|
|
688
|
+
spotMarket: await getSpotMarketPublicKey(
|
|
689
|
+
this.program.programId,
|
|
690
|
+
marketIndex
|
|
691
|
+
),
|
|
635
692
|
},
|
|
636
693
|
}
|
|
637
694
|
);
|
|
@@ -696,6 +753,22 @@ export class Admin extends ClearingHouse {
|
|
|
696
753
|
);
|
|
697
754
|
}
|
|
698
755
|
|
|
756
|
+
public async updateMarketExpiry(
|
|
757
|
+
perpMarketIndex: BN,
|
|
758
|
+
expiryTs: BN
|
|
759
|
+
): Promise<TransactionSignature> {
|
|
760
|
+
return await this.program.rpc.updateMarketExpiry(expiryTs, {
|
|
761
|
+
accounts: {
|
|
762
|
+
admin: this.wallet.publicKey,
|
|
763
|
+
state: await this.getStatePublicKey(),
|
|
764
|
+
perpMarket: await getMarketPublicKey(
|
|
765
|
+
this.program.programId,
|
|
766
|
+
perpMarketIndex
|
|
767
|
+
),
|
|
768
|
+
},
|
|
769
|
+
});
|
|
770
|
+
}
|
|
771
|
+
|
|
699
772
|
public async updateWhitelistMint(
|
|
700
773
|
whitelistMint?: PublicKey
|
|
701
774
|
): Promise<TransactionSignature> {
|
|
@@ -783,7 +856,7 @@ export class Admin extends ClearingHouse {
|
|
|
783
856
|
accounts: {
|
|
784
857
|
admin: this.wallet.publicKey,
|
|
785
858
|
state: await this.getStatePublicKey(),
|
|
786
|
-
market: this.
|
|
859
|
+
market: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
787
860
|
},
|
|
788
861
|
}
|
|
789
862
|
);
|
|
@@ -797,8 +870,28 @@ export class Admin extends ClearingHouse {
|
|
|
797
870
|
accounts: {
|
|
798
871
|
admin: this.wallet.publicKey,
|
|
799
872
|
state: await this.getStatePublicKey(),
|
|
800
|
-
market: this.
|
|
873
|
+
market: this.getPerpMarketAccount(marketIndex).pubkey,
|
|
801
874
|
},
|
|
802
875
|
});
|
|
803
876
|
}
|
|
877
|
+
|
|
878
|
+
public async updateMarketMaxImbalances(
|
|
879
|
+
marketIndex: BN,
|
|
880
|
+
unrealizedMaxImbalance: BN,
|
|
881
|
+
maxRevenueWithdrawPerPeriod: BN,
|
|
882
|
+
quoteMaxInsurance: BN
|
|
883
|
+
): Promise<TransactionSignature> {
|
|
884
|
+
return await this.program.rpc.updateMarketMaxImbalances(
|
|
885
|
+
unrealizedMaxImbalance,
|
|
886
|
+
maxRevenueWithdrawPerPeriod,
|
|
887
|
+
quoteMaxInsurance,
|
|
888
|
+
{
|
|
889
|
+
accounts: {
|
|
890
|
+
admin: this.wallet.publicKey,
|
|
891
|
+
state: await this.getStatePublicKey(),
|
|
892
|
+
market: await getMarketPublicKey(this.program.programId, marketIndex),
|
|
893
|
+
},
|
|
894
|
+
}
|
|
895
|
+
);
|
|
896
|
+
}
|
|
804
897
|
}
|
package/src/assert/assert.js
CHANGED