@drift-labs/sdk 0.2.0-master.32 → 0.2.0-master.34
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/bulkAccountLoader.js +2 -1
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +2 -2
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +8 -8
- package/lib/accounts/types.d.ts +1 -0
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +2 -2
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +7 -7
- package/lib/addresses/marketAddresses.js +1 -1
- package/lib/addresses/pda.d.ts +4 -4
- package/lib/addresses/pda.js +23 -22
- package/lib/admin.d.ts +30 -32
- package/lib/admin.js +111 -119
- package/lib/clearingHouse.d.ts +43 -34
- package/lib/clearingHouse.js +353 -193
- package/lib/clearingHouseConfig.d.ts +2 -2
- package/lib/clearingHouseUser.d.ts +26 -5
- package/lib/clearingHouseUser.js +151 -51
- package/lib/config.d.ts +2 -0
- package/lib/config.js +5 -1
- package/lib/constants/numericConstants.d.ts +1 -0
- package/lib/constants/numericConstants.js +3 -2
- package/lib/dlob/DLOB.d.ts +18 -11
- package/lib/dlob/DLOB.js +179 -107
- package/lib/dlob/DLOBNode.js +2 -10
- package/lib/dlob/NodeList.js +1 -1
- package/lib/events/eventSubscriber.d.ts +1 -0
- package/lib/events/eventSubscriber.js +11 -4
- package/lib/events/fetchLogs.d.ts +3 -1
- package/lib/events/fetchLogs.js +13 -5
- package/lib/events/pollingLogProvider.js +1 -1
- package/lib/events/types.d.ts +1 -1
- package/lib/events/webSocketLogProvider.js +1 -1
- package/lib/factory/bigNum.d.ts +5 -4
- package/lib/factory/bigNum.js +36 -6
- package/lib/idl/clearing_house.json +1540 -1246
- package/lib/index.d.ts +3 -0
- package/lib/index.js +3 -0
- package/lib/math/amm.js +9 -9
- package/lib/math/exchangeStatus.d.ts +4 -0
- package/lib/math/exchangeStatus.js +18 -0
- package/lib/math/funding.js +10 -10
- package/lib/math/margin.js +6 -1
- package/lib/math/market.js +9 -9
- package/lib/math/orders.d.ts +7 -3
- package/lib/math/orders.js +39 -31
- package/lib/math/repeg.js +3 -3
- package/lib/math/spotBalance.js +3 -3
- package/lib/math/spotPosition.js +2 -2
- package/lib/serum/serumFulfillmentConfigMap.d.ts +10 -0
- package/lib/serum/serumFulfillmentConfigMap.js +17 -0
- package/lib/serum/serumSubscriber.d.ts +4 -0
- package/lib/serum/serumSubscriber.js +16 -1
- package/lib/types.d.ts +60 -75
- package/lib/types.js +2 -1
- package/lib/userMap/userMap.d.ts +17 -1
- package/lib/userMap/userMap.js +12 -0
- package/lib/userName.d.ts +1 -0
- package/lib/userName.js +3 -2
- package/package.json +1 -1
- package/src/accounts/bulkAccountLoader.ts +5 -1
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +9 -9
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +8 -8
- package/src/addresses/marketAddresses.ts +2 -2
- package/src/addresses/pda.ts +20 -20
- package/src/admin.ts +246 -221
- package/src/assert/assert.js +9 -0
- package/src/clearingHouse.ts +556 -236
- package/src/clearingHouseConfig.ts +2 -2
- package/src/clearingHouseUser.ts +237 -87
- package/src/config.ts +8 -1
- package/src/constants/numericConstants.ts +5 -1
- package/src/dlob/DLOB.ts +257 -120
- package/src/dlob/DLOBNode.ts +2 -14
- package/src/dlob/NodeList.ts +1 -1
- package/src/events/eventList.js +77 -0
- package/src/events/eventSubscriber.ts +18 -4
- package/src/events/fetchLogs.ts +20 -5
- package/src/events/pollingLogProvider.ts +1 -1
- package/src/events/types.ts +2 -1
- package/src/events/webSocketLogProvider.ts +1 -1
- package/src/examples/makeTradeExample.js +157 -0
- package/src/factory/bigNum.ts +59 -6
- package/src/idl/clearing_house.json +1540 -1246
- package/src/idl/pyth.json +98 -2
- package/src/index.ts +3 -0
- package/src/math/amm.ts +9 -9
- package/src/math/exchangeStatus.ts +31 -0
- package/src/math/funding.ts +20 -10
- package/src/math/margin.ts +7 -1
- package/src/math/market.ts +9 -9
- package/src/math/orders.ts +44 -29
- package/src/math/repeg.ts +3 -3
- package/src/math/spotBalance.ts +4 -4
- package/src/math/spotPosition.ts +2 -2
- package/src/serum/serumFulfillmentConfigMap.ts +26 -0
- package/src/serum/serumSubscriber.ts +20 -1
- package/src/token/index.js +38 -0
- package/src/tx/types.js +2 -0
- package/src/tx/utils.js +17 -0
- package/src/types.ts +65 -51
- package/src/userMap/userMap.ts +25 -1
- package/src/userName.ts +2 -1
- package/src/util/computeUnits.js +27 -0
- package/src/util/getTokenAddress.js +9 -0
- package/src/util/promiseTimeout.js +14 -0
- package/src/util/tps.js +27 -0
- package/tests/bn/test.ts +22 -1
- package/tests/dlob/helpers.ts +252 -81
- package/tests/dlob/test.ts +1040 -219
package/lib/admin.js
CHANGED
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.Admin = void 0;
|
|
27
27
|
const web3_js_1 = require("@solana/web3.js");
|
|
28
28
|
const types_1 = require("./types");
|
|
29
|
+
const userName_1 = require("./userName");
|
|
29
30
|
const anchor_1 = require("@project-serum/anchor");
|
|
30
31
|
const anchor = __importStar(require("@project-serum/anchor"));
|
|
31
32
|
const pda_1 = require("./addresses/pda");
|
|
@@ -103,14 +104,15 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
103
104
|
},
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
|
-
async
|
|
107
|
-
const
|
|
108
|
-
const
|
|
107
|
+
async initializePerpMarket(priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION, oracleSource = types_1.OracleSource.PYTH, marginRatioInitial = 2000, marginRatioMaintenance = 500, liquidationFee = numericConstants_1.ZERO, activeStatus = true, name = userName_1.DEFAULT_MARKET_NAME) {
|
|
108
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, this.getStateAccount().numberOfMarkets);
|
|
109
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
110
|
+
const initializeMarketTx = await this.program.transaction.initializePerpMarket(baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier, oracleSource, marginRatioInitial, marginRatioMaintenance, liquidationFee, activeStatus, nameBuffer, {
|
|
109
111
|
accounts: {
|
|
110
112
|
state: await this.getStatePublicKey(),
|
|
111
113
|
admin: this.wallet.publicKey,
|
|
112
114
|
oracle: priceOracle,
|
|
113
|
-
|
|
115
|
+
perpMarket: perpMarketPublicKey,
|
|
114
116
|
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
115
117
|
systemProgram: anchor.web3.SystemProgram.programId,
|
|
116
118
|
},
|
|
@@ -123,8 +125,8 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
123
125
|
});
|
|
124
126
|
return txSig;
|
|
125
127
|
}
|
|
126
|
-
async moveAmmPrice(
|
|
127
|
-
const marketPublicKey = await (0, pda_1.
|
|
128
|
+
async moveAmmPrice(perpMarketIndex, baseAssetReserve, quoteAssetReserve, sqrtK) {
|
|
129
|
+
const marketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
128
130
|
if (sqrtK == undefined) {
|
|
129
131
|
sqrtK = (0, utils_1.squareRootBN)(baseAssetReserve.mul(quoteAssetReserve));
|
|
130
132
|
}
|
|
@@ -136,82 +138,82 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
136
138
|
},
|
|
137
139
|
});
|
|
138
140
|
}
|
|
139
|
-
async updateK(
|
|
141
|
+
async updateK(perpMarketIndex, sqrtK) {
|
|
140
142
|
return await this.program.rpc.updateK(sqrtK, {
|
|
141
143
|
accounts: {
|
|
142
144
|
state: await this.getStatePublicKey(),
|
|
143
145
|
admin: this.wallet.publicKey,
|
|
144
|
-
|
|
145
|
-
oracle: this.getPerpMarketAccount(
|
|
146
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
147
|
+
oracle: this.getPerpMarketAccount(perpMarketIndex).amm.oracle,
|
|
146
148
|
},
|
|
147
149
|
});
|
|
148
150
|
}
|
|
149
|
-
async
|
|
150
|
-
return await this.program.rpc.
|
|
151
|
+
async updatePerpMarketConcentrationScale(perpMarketIndex, concentrationScale) {
|
|
152
|
+
return await this.program.rpc.updatePerpMarketConcentrationCoef(concentrationScale, {
|
|
151
153
|
accounts: {
|
|
152
154
|
state: await this.getStatePublicKey(),
|
|
153
155
|
admin: this.wallet.publicKey,
|
|
154
|
-
|
|
156
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
155
157
|
},
|
|
156
158
|
});
|
|
157
159
|
}
|
|
158
160
|
async moveAmmToPrice(perpMarketIndex, targetPrice) {
|
|
159
|
-
const
|
|
160
|
-
const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(
|
|
161
|
+
const perpMarket = this.getPerpMarketAccount(perpMarketIndex);
|
|
162
|
+
const [direction, tradeSize, _] = (0, trade_1.calculateTargetPriceTrade)(perpMarket, targetPrice, new anchor_1.BN(1000), 'quote', undefined //todo
|
|
161
163
|
);
|
|
162
|
-
const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(
|
|
163
|
-
const
|
|
164
|
-
return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount,
|
|
164
|
+
const [newQuoteAssetAmount, newBaseAssetAmount] = (0, amm_1.calculateAmmReservesAfterSwap)(perpMarket.amm, 'quote', tradeSize, (0, amm_1.getSwapDirection)('quote', direction));
|
|
165
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
166
|
+
return await this.program.rpc.moveAmmPrice(newBaseAssetAmount, newQuoteAssetAmount, perpMarket.amm.sqrtK, {
|
|
165
167
|
accounts: {
|
|
166
168
|
state: await this.getStatePublicKey(),
|
|
167
169
|
admin: this.wallet.publicKey,
|
|
168
|
-
perpMarket:
|
|
170
|
+
perpMarket: perpMarketPublicKey,
|
|
169
171
|
},
|
|
170
172
|
});
|
|
171
173
|
}
|
|
172
|
-
async repegAmmCurve(newPeg,
|
|
173
|
-
const
|
|
174
|
-
const ammData = this.getPerpMarketAccount(
|
|
174
|
+
async repegAmmCurve(newPeg, perpMarketIndex) {
|
|
175
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
176
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
175
177
|
return await this.program.rpc.repegAmmCurve(newPeg, {
|
|
176
178
|
accounts: {
|
|
177
179
|
state: await this.getStatePublicKey(),
|
|
178
180
|
admin: this.wallet.publicKey,
|
|
179
181
|
oracle: ammData.oracle,
|
|
180
|
-
|
|
182
|
+
perpMarket: perpMarketPublicKey,
|
|
181
183
|
},
|
|
182
184
|
});
|
|
183
185
|
}
|
|
184
|
-
async
|
|
185
|
-
const ammData = this.getPerpMarketAccount(
|
|
186
|
-
const
|
|
187
|
-
return await this.program.rpc.
|
|
186
|
+
async updatePerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
187
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
188
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
189
|
+
return await this.program.rpc.updatePerpMarketAmmOracleTwap({
|
|
188
190
|
accounts: {
|
|
189
191
|
state: await this.getStatePublicKey(),
|
|
190
192
|
admin: this.wallet.publicKey,
|
|
191
193
|
oracle: ammData.oracle,
|
|
192
|
-
|
|
194
|
+
perpMarket: perpMarketPublicKey,
|
|
193
195
|
},
|
|
194
196
|
});
|
|
195
197
|
}
|
|
196
|
-
async
|
|
197
|
-
const ammData = this.getPerpMarketAccount(
|
|
198
|
-
const
|
|
199
|
-
return await this.program.rpc.
|
|
198
|
+
async resetPerpMarketAmmOracleTwap(perpMarketIndex) {
|
|
199
|
+
const ammData = this.getPerpMarketAccount(perpMarketIndex).amm;
|
|
200
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
201
|
+
return await this.program.rpc.resetPerpMarketAmmOracleTwap({
|
|
200
202
|
accounts: {
|
|
201
203
|
state: await this.getStatePublicKey(),
|
|
202
204
|
admin: this.wallet.publicKey,
|
|
203
205
|
oracle: ammData.oracle,
|
|
204
|
-
|
|
206
|
+
perpMarket: perpMarketPublicKey,
|
|
205
207
|
},
|
|
206
208
|
});
|
|
207
209
|
}
|
|
208
|
-
async
|
|
210
|
+
async depositIntoPerpMarketFeePool(perpMarketIndex, amount, sourceVault) {
|
|
209
211
|
const spotMarket = this.getQuoteSpotMarketAccount();
|
|
210
|
-
return await this.program.rpc.
|
|
212
|
+
return await this.program.rpc.depositIntoPerpMarketFeePool(amount, {
|
|
211
213
|
accounts: {
|
|
212
214
|
admin: this.wallet.publicKey,
|
|
213
215
|
state: await this.getStatePublicKey(),
|
|
214
|
-
|
|
216
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
215
217
|
sourceVault,
|
|
216
218
|
clearingHouseSigner: this.getSignerPublicKey(),
|
|
217
219
|
quoteSpotMarket: spotMarket.pubkey,
|
|
@@ -228,204 +230,202 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
228
230
|
},
|
|
229
231
|
});
|
|
230
232
|
}
|
|
231
|
-
async
|
|
233
|
+
async updatePerpMarketCurveUpdateIntensity(perpMarketIndex, curveUpdateIntensity) {
|
|
232
234
|
// assert(curveUpdateIntensity >= 0 && curveUpdateIntensity <= 100);
|
|
233
235
|
// assert(Number.isInteger(curveUpdateIntensity));
|
|
234
|
-
return await this.program.rpc.
|
|
236
|
+
return await this.program.rpc.updatePerpMarketCurveUpdateIntensity(curveUpdateIntensity, {
|
|
235
237
|
accounts: {
|
|
236
238
|
admin: this.wallet.publicKey,
|
|
237
239
|
state: await this.getStatePublicKey(),
|
|
238
|
-
|
|
240
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
239
241
|
},
|
|
240
242
|
});
|
|
241
243
|
}
|
|
242
|
-
async
|
|
243
|
-
return await this.program.rpc.
|
|
244
|
+
async updatePerpMarketMarginRatio(perpMarketIndex, marginRatioInitial, marginRatioMaintenance) {
|
|
245
|
+
return await this.program.rpc.updatePerpMarketMarginRatio(marginRatioInitial, marginRatioMaintenance, {
|
|
244
246
|
accounts: {
|
|
245
247
|
admin: this.wallet.publicKey,
|
|
246
248
|
state: await this.getStatePublicKey(),
|
|
247
|
-
|
|
249
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
248
250
|
},
|
|
249
251
|
});
|
|
250
252
|
}
|
|
251
|
-
async
|
|
252
|
-
return await this.program.rpc.
|
|
253
|
+
async updatePerpMarketBaseSpread(perpMarketIndex, baseSpread) {
|
|
254
|
+
return await this.program.rpc.updatePerpMarketBaseSpread(baseSpread, {
|
|
253
255
|
accounts: {
|
|
254
256
|
admin: this.wallet.publicKey,
|
|
255
257
|
state: await this.getStatePublicKey(),
|
|
256
|
-
|
|
258
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
257
259
|
},
|
|
258
260
|
});
|
|
259
261
|
}
|
|
260
|
-
async updateAmmJitIntensity(
|
|
262
|
+
async updateAmmJitIntensity(perpMarketIndex, ammJitIntensity) {
|
|
261
263
|
return await this.program.rpc.updateAmmJitIntensity(ammJitIntensity, {
|
|
262
264
|
accounts: {
|
|
263
265
|
admin: this.wallet.publicKey,
|
|
264
266
|
state: await this.getStatePublicKey(),
|
|
265
|
-
|
|
266
|
-
},
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
async updateMarketMaxSpread(marketIndex, maxSpread) {
|
|
270
|
-
return await this.program.rpc.updateMarketMaxSpread(maxSpread, {
|
|
271
|
-
accounts: {
|
|
272
|
-
admin: this.wallet.publicKey,
|
|
273
|
-
state: await this.getStatePublicKey(),
|
|
274
|
-
market: await (0, pda_1.getMarketPublicKey)(this.program.programId, marketIndex),
|
|
267
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
275
268
|
},
|
|
276
269
|
});
|
|
277
270
|
}
|
|
278
|
-
async
|
|
279
|
-
|
|
271
|
+
async updatePerpMarketName(perpMarketIndex, name) {
|
|
272
|
+
const nameBuffer = (0, userName_1.encodeName)(name);
|
|
273
|
+
return await this.program.rpc.updatePerpMarketName(nameBuffer, {
|
|
280
274
|
accounts: {
|
|
281
275
|
admin: this.wallet.publicKey,
|
|
282
276
|
state: await this.getStatePublicKey(),
|
|
277
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
283
278
|
},
|
|
284
279
|
});
|
|
285
280
|
}
|
|
286
|
-
async
|
|
287
|
-
|
|
281
|
+
async updatePerpMarketMaxSpread(perpMarketIndex, maxSpread) {
|
|
282
|
+
const perpMarketPublicKey = await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex);
|
|
283
|
+
return await this.program.rpc.updatePerpMarketMaxSpread(maxSpread, {
|
|
288
284
|
accounts: {
|
|
289
285
|
admin: this.wallet.publicKey,
|
|
290
286
|
state: await this.getStatePublicKey(),
|
|
287
|
+
perpMarket: perpMarketPublicKey,
|
|
291
288
|
},
|
|
292
289
|
});
|
|
293
290
|
}
|
|
294
|
-
async
|
|
295
|
-
return await this.program.rpc.
|
|
291
|
+
async updatePerpFeeStructure(feeStructure) {
|
|
292
|
+
return await this.program.rpc.updatePerpFeeStructure(feeStructure, {
|
|
296
293
|
accounts: {
|
|
297
294
|
admin: this.wallet.publicKey,
|
|
298
295
|
state: await this.getStatePublicKey(),
|
|
299
296
|
},
|
|
300
297
|
});
|
|
301
298
|
}
|
|
302
|
-
async
|
|
303
|
-
return await this.program.rpc.
|
|
299
|
+
async updateSpotFeeStructure(feeStructure) {
|
|
300
|
+
return await this.program.rpc.updateSpotFeeStructure(feeStructure, {
|
|
304
301
|
accounts: {
|
|
305
302
|
admin: this.wallet.publicKey,
|
|
306
303
|
state: await this.getStatePublicKey(),
|
|
307
304
|
},
|
|
308
305
|
});
|
|
309
306
|
}
|
|
310
|
-
async
|
|
311
|
-
return await this.program.rpc.
|
|
307
|
+
async updateOracleGuardRails(oracleGuardRails) {
|
|
308
|
+
return await this.program.rpc.updateOracleGuardRails(oracleGuardRails, {
|
|
312
309
|
accounts: {
|
|
313
310
|
admin: this.wallet.publicKey,
|
|
314
311
|
state: await this.getStatePublicKey(),
|
|
315
312
|
},
|
|
316
313
|
});
|
|
317
314
|
}
|
|
318
|
-
async
|
|
319
|
-
return await this.program.rpc.
|
|
315
|
+
async updateStateSettlementDuration(settlementDuration) {
|
|
316
|
+
return await this.program.rpc.updateStateSettlementDuration(settlementDuration, {
|
|
320
317
|
accounts: {
|
|
321
318
|
admin: this.wallet.publicKey,
|
|
322
319
|
state: await this.getStatePublicKey(),
|
|
323
320
|
},
|
|
324
321
|
});
|
|
325
322
|
}
|
|
326
|
-
async
|
|
327
|
-
return await this.program.rpc.
|
|
323
|
+
async updateWithdrawGuardThreshold(spotMarketIndex, withdrawGuardThreshold) {
|
|
324
|
+
return await this.program.rpc.updateWithdrawGuardThreshold(withdrawGuardThreshold, {
|
|
328
325
|
accounts: {
|
|
329
326
|
admin: this.wallet.publicKey,
|
|
330
327
|
state: await this.getStatePublicKey(),
|
|
328
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
331
329
|
},
|
|
332
330
|
});
|
|
333
331
|
}
|
|
334
|
-
async
|
|
335
|
-
return await this.program.rpc.
|
|
332
|
+
async updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor) {
|
|
333
|
+
return await this.program.rpc.updateSpotMarketIfFactor(spotMarketIndex, userIfFactor, totalIfFactor, {
|
|
336
334
|
accounts: {
|
|
337
335
|
admin: this.wallet.publicKey,
|
|
338
336
|
state: await this.getStatePublicKey(),
|
|
337
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
339
338
|
},
|
|
340
339
|
});
|
|
341
340
|
}
|
|
342
|
-
async
|
|
343
|
-
return await this.program.rpc.
|
|
341
|
+
async updateSpotMarketRevenueSettlePeriod(spotMarketIndex, revenueSettlePeriod) {
|
|
342
|
+
return await this.program.rpc.updateSpotMarketRevenueSettlePeriod(revenueSettlePeriod, {
|
|
344
343
|
accounts: {
|
|
345
344
|
admin: this.wallet.publicKey,
|
|
346
345
|
state: await this.getStatePublicKey(),
|
|
347
|
-
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId,
|
|
346
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
348
347
|
},
|
|
349
348
|
});
|
|
350
349
|
}
|
|
351
|
-
async
|
|
352
|
-
return await this.program.rpc.
|
|
350
|
+
async updateSpotMarketMaxTokenDeposits(spotMarketIndex, maxTokenDeposits) {
|
|
351
|
+
return await this.program.rpc.updateSpotMarketMaxTokenDeposits(maxTokenDeposits, {
|
|
353
352
|
accounts: {
|
|
354
353
|
admin: this.wallet.publicKey,
|
|
355
354
|
state: await this.getStatePublicKey(),
|
|
356
|
-
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId,
|
|
355
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
357
356
|
},
|
|
358
357
|
});
|
|
359
358
|
}
|
|
360
|
-
async
|
|
361
|
-
return await this.program.rpc.
|
|
359
|
+
async updateInsuranceFundUnstakingPeriod(spotMarketIndex, insuranceWithdrawEscrowPeriod) {
|
|
360
|
+
return await this.program.rpc.updateInsuranceFundUnstakingPeriod(insuranceWithdrawEscrowPeriod, {
|
|
362
361
|
accounts: {
|
|
363
362
|
admin: this.wallet.publicKey,
|
|
364
363
|
state: await this.getStatePublicKey(),
|
|
365
|
-
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId,
|
|
364
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
366
365
|
},
|
|
367
366
|
});
|
|
368
367
|
}
|
|
369
|
-
async
|
|
370
|
-
return await this.program.rpc.
|
|
368
|
+
async updateLpCooldownTime(cooldownTime) {
|
|
369
|
+
return await this.program.rpc.updateLpCooldownTime(cooldownTime, {
|
|
371
370
|
accounts: {
|
|
372
371
|
admin: this.wallet.publicKey,
|
|
373
372
|
state: await this.getStatePublicKey(),
|
|
374
|
-
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, marketIndex),
|
|
375
373
|
},
|
|
376
374
|
});
|
|
377
375
|
}
|
|
378
|
-
async
|
|
379
|
-
return await this.program.rpc.
|
|
376
|
+
async updatePerpMarketOracle(perpMarketIndex, oracle, oracleSource) {
|
|
377
|
+
return await this.program.rpc.updatePerpMarketOracle(oracle, oracleSource, {
|
|
380
378
|
accounts: {
|
|
381
379
|
admin: this.wallet.publicKey,
|
|
382
380
|
state: await this.getStatePublicKey(),
|
|
383
|
-
|
|
381
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
382
|
+
oracle: oracle,
|
|
384
383
|
},
|
|
385
384
|
});
|
|
386
385
|
}
|
|
387
|
-
async
|
|
388
|
-
return await this.program.rpc.
|
|
386
|
+
async updatePerpMarketStepSizeAndTickSize(perpMarketIndex, stepSize, tickSize) {
|
|
387
|
+
return await this.program.rpc.updatePerpMarketStepSizeAndTickSize(stepSize, tickSize, {
|
|
389
388
|
accounts: {
|
|
390
389
|
admin: this.wallet.publicKey,
|
|
391
390
|
state: await this.getStatePublicKey(),
|
|
392
|
-
|
|
391
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
393
392
|
},
|
|
394
393
|
});
|
|
395
394
|
}
|
|
396
|
-
async
|
|
397
|
-
return await this.program.rpc.
|
|
395
|
+
async updatePerpMarketMinOrderSize(perpMarketIndex, orderSize) {
|
|
396
|
+
return await this.program.rpc.updatePerpMarketMinOrderSize(orderSize, {
|
|
398
397
|
accounts: {
|
|
399
398
|
admin: this.wallet.publicKey,
|
|
400
399
|
state: await this.getStatePublicKey(),
|
|
401
|
-
|
|
400
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
402
401
|
},
|
|
403
402
|
});
|
|
404
403
|
}
|
|
405
|
-
async
|
|
406
|
-
return await this.program.rpc.
|
|
404
|
+
async updatePerpMarketExpiry(perpMarketIndex, expiryTs) {
|
|
405
|
+
return await this.program.rpc.updatePerpMarketExpiry(expiryTs, {
|
|
407
406
|
accounts: {
|
|
408
407
|
admin: this.wallet.publicKey,
|
|
409
408
|
state: await this.getStatePublicKey(),
|
|
410
|
-
|
|
409
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
411
410
|
},
|
|
412
411
|
});
|
|
413
412
|
}
|
|
414
|
-
async
|
|
415
|
-
return await this.program.rpc.
|
|
413
|
+
async updateSpotMarketOracle(spotMarketIndex, oracle, oracleSource) {
|
|
414
|
+
return await this.program.rpc.updatePerpMarketOracle(oracle, oracleSource, {
|
|
416
415
|
accounts: {
|
|
417
416
|
admin: this.wallet.publicKey,
|
|
418
417
|
state: await this.getStatePublicKey(),
|
|
419
|
-
|
|
418
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
419
|
+
oracle: oracle,
|
|
420
420
|
},
|
|
421
421
|
});
|
|
422
422
|
}
|
|
423
|
-
async
|
|
424
|
-
return await this.program.rpc.
|
|
423
|
+
async updateSpotMarketExpiry(spotMarketIndex, expiryTs) {
|
|
424
|
+
return await this.program.rpc.updateSpotMarketExpiry(expiryTs, {
|
|
425
425
|
accounts: {
|
|
426
426
|
admin: this.wallet.publicKey,
|
|
427
427
|
state: await this.getStatePublicKey(),
|
|
428
|
-
|
|
428
|
+
spotMarket: await (0, pda_1.getSpotMarketPublicKey)(this.program.programId, spotMarketIndex),
|
|
429
429
|
},
|
|
430
430
|
});
|
|
431
431
|
}
|
|
@@ -445,14 +445,6 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
445
445
|
},
|
|
446
446
|
});
|
|
447
447
|
}
|
|
448
|
-
async updateMaxDeposit(maxDeposit) {
|
|
449
|
-
return await this.program.rpc.updateMaxDeposit(maxDeposit, {
|
|
450
|
-
accounts: {
|
|
451
|
-
admin: this.wallet.publicKey,
|
|
452
|
-
state: await this.getStatePublicKey(),
|
|
453
|
-
},
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
448
|
async updateSpotMarketMarginWeights(spotMarketIndex, initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor = new anchor_1.BN(0)) {
|
|
457
449
|
return await this.program.rpc.updateSpotMarketMarginWeights(initialAssetWeight, maintenanceAssetWeight, initialLiabilityWeight, maintenanceLiabilityWeight, imfFactor, {
|
|
458
450
|
accounts: {
|
|
@@ -485,7 +477,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
485
477
|
accounts: {
|
|
486
478
|
admin: this.wallet.publicKey,
|
|
487
479
|
state: await this.getStatePublicKey(),
|
|
488
|
-
|
|
480
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
489
481
|
},
|
|
490
482
|
});
|
|
491
483
|
}
|
|
@@ -494,7 +486,7 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
494
486
|
accounts: {
|
|
495
487
|
admin: this.wallet.publicKey,
|
|
496
488
|
state: await this.getStatePublicKey(),
|
|
497
|
-
|
|
489
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
498
490
|
},
|
|
499
491
|
});
|
|
500
492
|
}
|
|
@@ -522,30 +514,30 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
522
514
|
},
|
|
523
515
|
});
|
|
524
516
|
}
|
|
525
|
-
async
|
|
526
|
-
return await this.program.rpc.
|
|
517
|
+
async updatePerpMarketMaxFillReserveFraction(perpMarketIndex, maxBaseAssetAmountRatio) {
|
|
518
|
+
return await this.program.rpc.updatePerpMarketMaxFillReserveFraction(maxBaseAssetAmountRatio, {
|
|
527
519
|
accounts: {
|
|
528
520
|
admin: this.wallet.publicKey,
|
|
529
521
|
state: await this.getStatePublicKey(),
|
|
530
|
-
|
|
522
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
531
523
|
},
|
|
532
524
|
});
|
|
533
525
|
}
|
|
534
|
-
async updateMaxSlippageRatio(
|
|
526
|
+
async updateMaxSlippageRatio(perpMarketIndex, maxSlippageRatio) {
|
|
535
527
|
return await this.program.rpc.updateMaxSlippageRatio(maxSlippageRatio, {
|
|
536
528
|
accounts: {
|
|
537
529
|
admin: this.wallet.publicKey,
|
|
538
530
|
state: await this.getStatePublicKey(),
|
|
539
|
-
|
|
531
|
+
perpMarket: this.getPerpMarketAccount(perpMarketIndex).pubkey,
|
|
540
532
|
},
|
|
541
533
|
});
|
|
542
534
|
}
|
|
543
|
-
async
|
|
544
|
-
return await this.program.rpc.
|
|
535
|
+
async updatePerpMarketMaxImbalances(perpMarketIndex, unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance) {
|
|
536
|
+
return await this.program.rpc.updatePerpMarketMaxImbalances(unrealizedMaxImbalance, maxRevenueWithdrawPerPeriod, quoteMaxInsurance, {
|
|
545
537
|
accounts: {
|
|
546
538
|
admin: this.wallet.publicKey,
|
|
547
539
|
state: await this.getStatePublicKey(),
|
|
548
|
-
|
|
540
|
+
perpMarket: await (0, pda_1.getPerpMarketPublicKey)(this.program.programId, perpMarketIndex),
|
|
549
541
|
},
|
|
550
542
|
});
|
|
551
543
|
}
|