flash-sdk 10.0.0-alpha.0 → 10.0.0-alpha.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.
@@ -1887,7 +1887,7 @@ var PerpetualsClient = (function () {
1887
1887
  });
1888
1888
  };
1889
1889
  this.getStakedLpTokenPrice = function (poolKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
1890
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_1, token, _a, custodies_2, custody, _b, _c, market, transaction, backUpOracleInstruction, result, index, res;
1890
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_1, token, _a, custodies_2, custody, _b, _c, market, transaction, backUpOracleInstruction, setCULimitIx, result, index, res;
1891
1891
  var _d;
1892
1892
  return __generator(this, function (_e) {
1893
1893
  switch (_e.label) {
@@ -1935,6 +1935,8 @@ var PerpetualsClient = (function () {
1935
1935
  return [4, backUpOracleInstructionPromise];
1936
1936
  case 2:
1937
1937
  backUpOracleInstruction = _e.sent();
1938
+ setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
1939
+ transaction.instructions.unshift(setCULimitIx);
1938
1940
  (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
1939
1941
  return [4, this.viewHelper.simulateTransaction(transaction)];
1940
1942
  case 3:
@@ -2001,7 +2003,7 @@ var PerpetualsClient = (function () {
2001
2003
  args_1[_i - 4] = arguments[_i];
2002
2004
  }
2003
2005
  return __awaiter(_this, __spreadArray([amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle) {
2004
- var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2006
+ var custodies, custodyMetas, marketMetas, _a, custodies_5, token, _b, custodies_6, custody, _c, _d, market, depositCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2005
2007
  var _e;
2006
2008
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2007
2009
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
@@ -2052,6 +2054,8 @@ var PerpetualsClient = (function () {
2052
2054
  .transaction()];
2053
2055
  case 1:
2054
2056
  transaction = _f.sent();
2057
+ setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
2058
+ transaction.instructions.unshift(setCULimitIx);
2055
2059
  if (!enableBackupOracle) return [3, 3];
2056
2060
  return [4, (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true)];
2057
2061
  case 2:
@@ -2077,7 +2081,7 @@ var PerpetualsClient = (function () {
2077
2081
  args_1[_i - 4] = arguments[_i];
2078
2082
  }
2079
2083
  return __awaiter(_this, __spreadArray([amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle) {
2080
- var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, backUpOracleInstruction, result, index, res;
2084
+ var custodies, custodyMetas, marketMetas, _a, custodies_7, token, _b, custodies_8, custody, _c, _d, market, removeCustodyConfig, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2081
2085
  var _e;
2082
2086
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2083
2087
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
@@ -2128,6 +2132,8 @@ var PerpetualsClient = (function () {
2128
2132
  .transaction()];
2129
2133
  case 1:
2130
2134
  transaction = _f.sent();
2135
+ setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
2136
+ transaction.instructions.unshift(setCULimitIx);
2131
2137
  if (!enableBackupOracle) return [3, 3];
2132
2138
  return [4, (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true)];
2133
2139
  case 2:
@@ -2154,7 +2160,7 @@ var PerpetualsClient = (function () {
2154
2160
  });
2155
2161
  };
2156
2162
  this.getCompoundingLPTokenPrice = function (poolKey, POOL_CONFIG) { return __awaiter(_this, void 0, void 0, function () {
2157
- var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_9, token, _a, custodies_10, custody, _b, _c, market, backUpOracleInstruction, transaction, result, index, res;
2163
+ var backUpOracleInstructionPromise, custodies, custodyMetas, marketMetas, _i, custodies_9, token, _a, custodies_10, custody, _b, _c, market, backUpOracleInstruction, transaction, setCULimitIx, result, index, res;
2158
2164
  var _d;
2159
2165
  return __generator(this, function (_e) {
2160
2166
  switch (_e.label) {
@@ -2202,6 +2208,8 @@ var PerpetualsClient = (function () {
2202
2208
  .transaction()];
2203
2209
  case 2:
2204
2210
  transaction = _e.sent();
2211
+ setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
2212
+ transaction.instructions.unshift(setCULimitIx);
2205
2213
  (_d = transaction.instructions).unshift.apply(_d, backUpOracleInstruction);
2206
2214
  return [4, this.viewHelper.simulateTransaction(transaction)];
2207
2215
  case 3:
@@ -2218,7 +2226,7 @@ var PerpetualsClient = (function () {
2218
2226
  args_1[_i - 4] = arguments[_i];
2219
2227
  }
2220
2228
  return __awaiter(_this, __spreadArray([amount_1, poolKey_1, depositCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, depositCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle) {
2221
- var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, transaction, backUpOracleInstruction, result, index, res;
2229
+ var custodies, custodyMetas, marketMetas, _a, custodies_11, token, _b, custodies_12, custody, _c, _d, market, depositCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2222
2230
  var _e;
2223
2231
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2224
2232
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
@@ -2273,6 +2281,8 @@ var PerpetualsClient = (function () {
2273
2281
  .transaction()];
2274
2282
  case 1:
2275
2283
  transaction = _f.sent();
2284
+ setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
2285
+ transaction.instructions.unshift(setCULimitIx);
2276
2286
  if (!enableBackupOracle) return [3, 3];
2277
2287
  return [4, (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true)];
2278
2288
  case 2:
@@ -2298,7 +2308,7 @@ var PerpetualsClient = (function () {
2298
2308
  args_1[_i - 4] = arguments[_i];
2299
2309
  }
2300
2310
  return __awaiter(_this, __spreadArray([amount_1, poolKey_1, removeTokenCustodyKey_1, POOL_CONFIG_1], args_1, true), void 0, function (amount, poolKey, removeTokenCustodyKey, POOL_CONFIG, userPublicKey, enableBackupOracle) {
2301
- var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, transaction, backUpOracleInstruction, result, index, res;
2311
+ var custodies, custodyMetas, marketMetas, _a, custodies_13, token, _b, custodies_14, custody, _c, _d, market, removeCustodyConfig, rewardCustody, transaction, setCULimitIx, backUpOracleInstruction, result, index, res;
2302
2312
  var _e;
2303
2313
  if (userPublicKey === void 0) { userPublicKey = undefined; }
2304
2314
  if (enableBackupOracle === void 0) { enableBackupOracle = false; }
@@ -2353,6 +2363,8 @@ var PerpetualsClient = (function () {
2353
2363
  .transaction()];
2354
2364
  case 1:
2355
2365
  transaction = _f.sent();
2366
+ setCULimitIx = web3_js_1.ComputeBudgetProgram.setComputeUnitLimit({ units: 450000 });
2367
+ transaction.instructions.unshift(setCULimitIx);
2356
2368
  if (!enableBackupOracle) return [3, 3];
2357
2369
  return [4, (0, backupOracle_1.createBackupOracleInstruction)(POOL_CONFIG.poolAddress.toBase58(), true)];
2358
2370
  case 2:
@@ -4084,119 +4096,8 @@ var PerpetualsClient = (function () {
4084
4096
  }
4085
4097
  });
4086
4098
  }); };
4087
- this.updateNftAccount = function (nftMint, updateReferer, updateBooster, flpStakeAccounts) { return __awaiter(_this, void 0, void 0, function () {
4088
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, nftReferralAccount, nftTokenAccount, flpStakeAccountMetas, _i, flpStakeAccounts_1, flpStakeAccountPk, updateNftTradingAccountInstruction, err_8;
4089
- return __generator(this, function (_a) {
4090
- switch (_a.label) {
4091
- case 0:
4092
- publicKey = this.provider.wallet.publicKey;
4093
- preInstructions = [];
4094
- instructions = [];
4095
- postInstructions = [];
4096
- additionalSigners = [];
4097
- _a.label = 1;
4098
- case 1:
4099
- _a.trys.push([1, 4, , 5]);
4100
- nftTradingAccount = web3_js_1.PublicKey.findProgramAddressSync([
4101
- Buffer.from("trading"),
4102
- nftMint.toBuffer(),
4103
- ], this.programId)[0];
4104
- nftReferralAccount = web3_js_1.PublicKey.findProgramAddressSync([
4105
- Buffer.from("referral"),
4106
- publicKey.toBuffer(),
4107
- ], this.programId)[0];
4108
- return [4, (0, spl_token_1.getAssociatedTokenAddress)(nftMint, publicKey, true)];
4109
- case 2:
4110
- nftTokenAccount = _a.sent();
4111
- flpStakeAccountMetas = [];
4112
- for (_i = 0, flpStakeAccounts_1 = flpStakeAccounts; _i < flpStakeAccounts_1.length; _i++) {
4113
- flpStakeAccountPk = flpStakeAccounts_1[_i];
4114
- flpStakeAccountMetas.push({
4115
- pubkey: flpStakeAccountPk,
4116
- isSigner: false,
4117
- isWritable: true,
4118
- });
4119
- }
4120
- return [4, this.program.methods
4121
- .updateTradingAccount({
4122
- updateReferer: updateReferer,
4123
- updateBooster: updateBooster
4124
- })
4125
- .accounts({
4126
- owner: publicKey,
4127
- feePayer: publicKey,
4128
- nftTokenAccount: nftTokenAccount,
4129
- referralAccount: nftReferralAccount,
4130
- tradingAccount: nftTradingAccount
4131
- })
4132
- .instruction()];
4133
- case 3:
4134
- updateNftTradingAccountInstruction = _a.sent();
4135
- instructions.push(updateNftTradingAccountInstruction);
4136
- return [3, 5];
4137
- case 4:
4138
- err_8 = _a.sent();
4139
- console.log("perpClient updateNftAccount error:: ", err_8);
4140
- throw err_8;
4141
- case 5: return [2, {
4142
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4143
- additionalSigners: additionalSigners
4144
- }];
4145
- }
4146
- });
4147
- }); };
4148
- this.levelUp = function (poolConfig, nftMint, authorizationRulesAccount) { return __awaiter(_this, void 0, void 0, function () {
4149
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, nftTradingAccount, metadataAccount, levelUpInstruction, err_9;
4150
- return __generator(this, function (_a) {
4151
- switch (_a.label) {
4152
- case 0:
4153
- publicKey = this.provider.wallet.publicKey;
4154
- preInstructions = [];
4155
- instructions = [];
4156
- postInstructions = [];
4157
- additionalSigners = [];
4158
- _a.label = 1;
4159
- case 1:
4160
- _a.trys.push([1, 3, , 4]);
4161
- nftTradingAccount = web3_js_1.PublicKey.findProgramAddressSync([
4162
- Buffer.from("trading"),
4163
- nftMint.toBuffer(),
4164
- ], this.programId)[0];
4165
- metadataAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), nftMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
4166
- return [4, this.program.methods
4167
- .levelUp({})
4168
- .accounts({
4169
- owner: publicKey,
4170
- perpetuals: this.perpetuals.publicKey,
4171
- pool: poolConfig.poolAddress,
4172
- metadataAccount: metadataAccount,
4173
- nftMint: nftMint,
4174
- metadataProgram: constants_1.METAPLEX_PROGRAM_ID,
4175
- tradingAccount: nftTradingAccount,
4176
- transferAuthority: this.authority.publicKey,
4177
- authorizationRulesAccount: authorizationRulesAccount,
4178
- authorizationRulesProgram: new web3_js_1.PublicKey('auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'),
4179
- systemProgram: web3_js_1.SystemProgram.programId,
4180
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
4181
- })
4182
- .instruction()];
4183
- case 2:
4184
- levelUpInstruction = _a.sent();
4185
- instructions.push(levelUpInstruction);
4186
- return [3, 4];
4187
- case 3:
4188
- err_9 = _a.sent();
4189
- console.log("perpClient levelUp error:: ", err_9);
4190
- throw err_9;
4191
- case 4: return [2, {
4192
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4193
- additionalSigners: additionalSigners
4194
- }];
4195
- }
4196
- });
4197
- }); };
4198
4099
  this.depositStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4199
- var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, depositStakeInstruction, err_10;
4100
+ var preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, depositStakeInstruction, err_8;
4200
4101
  return __generator(this, function (_a) {
4201
4102
  switch (_a.label) {
4202
4103
  case 0:
@@ -4238,9 +4139,9 @@ var PerpetualsClient = (function () {
4238
4139
  instructions.push(depositStakeInstruction);
4239
4140
  return [3, 5];
4240
4141
  case 4:
4241
- err_10 = _a.sent();
4242
- console.log("perpClient depositStaking error:: ", err_10);
4243
- throw err_10;
4142
+ err_8 = _a.sent();
4143
+ console.log("perpClient depositStaking error:: ", err_8);
4144
+ throw err_8;
4244
4145
  case 5: return [2, {
4245
4146
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4246
4147
  additionalSigners: additionalSigners
@@ -4249,7 +4150,7 @@ var PerpetualsClient = (function () {
4249
4150
  });
4250
4151
  }); };
4251
4152
  this.refreshStakeWithAllFlpStakeAccounts = function (rewardSymbol, poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4252
- var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_11;
4153
+ var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_1, flpStakeAccountPk, refreshStakeInstruction, err_9;
4253
4154
  return __generator(this, function (_c) {
4254
4155
  switch (_c.label) {
4255
4156
  case 0:
@@ -4296,9 +4197,9 @@ var PerpetualsClient = (function () {
4296
4197
  refreshStakeInstruction = _c.sent();
4297
4198
  return [2, refreshStakeInstruction];
4298
4199
  case 2:
4299
- err_11 = _c.sent();
4300
- console.log("perpClient refreshStaking error:: ", err_11);
4301
- throw err_11;
4200
+ err_9 = _c.sent();
4201
+ console.log("perpClient refreshStaking error:: ", err_9);
4202
+ throw err_9;
4302
4203
  case 3: return [2];
4303
4204
  }
4304
4205
  });
@@ -4309,7 +4210,7 @@ var PerpetualsClient = (function () {
4309
4210
  args_1[_i - 3] = arguments[_i];
4310
4211
  }
4311
4212
  return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, flpStakeAccountPk_1], args_1, true), void 0, function (rewardSymbol, poolConfig, flpStakeAccountPk, userPublicKey) {
4312
- var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _a, _b, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_12;
4213
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _a, _b, custody, stakeAccountMetas, tokenStakeAccount, refreshStakeInstruction, err_10;
4313
4214
  if (userPublicKey === void 0) { userPublicKey = undefined; }
4314
4215
  return __generator(this, function (_c) {
4315
4216
  switch (_c.label) {
@@ -4357,9 +4258,9 @@ var PerpetualsClient = (function () {
4357
4258
  refreshStakeInstruction = _c.sent();
4358
4259
  return [2, refreshStakeInstruction];
4359
4260
  case 2:
4360
- err_12 = _c.sent();
4361
- console.log("perpClient refreshStaking error:: ", err_12);
4362
- throw err_12;
4261
+ err_10 = _c.sent();
4262
+ console.log("perpClient refreshStaking error:: ", err_10);
4263
+ throw err_10;
4363
4264
  case 3: return [2];
4364
4265
  }
4365
4266
  });
@@ -4371,7 +4272,7 @@ var PerpetualsClient = (function () {
4371
4272
  args_1[_i - 3] = arguments[_i];
4372
4273
  }
4373
4274
  return __awaiter(_this, __spreadArray([rewardSymbol_1, unstakeAmount_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, unstakeAmount, poolConfig, userPublicKey) {
4374
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_13;
4275
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_11;
4375
4276
  if (userPublicKey === void 0) { userPublicKey = undefined; }
4376
4277
  return __generator(this, function (_b) {
4377
4278
  switch (_b.label) {
@@ -4423,9 +4324,9 @@ var PerpetualsClient = (function () {
4423
4324
  instructions.push(unstakeInstantInstruction);
4424
4325
  return [3, 6];
4425
4326
  case 5:
4426
- err_13 = _b.sent();
4427
- console.log("perpClient unstakeInstant error:: ", err_13);
4428
- throw err_13;
4327
+ err_11 = _b.sent();
4328
+ console.log("perpClient unstakeInstant error:: ", err_11);
4329
+ throw err_11;
4429
4330
  case 6: return [2, {
4430
4331
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4431
4332
  additionalSigners: additionalSigners
@@ -4435,7 +4336,7 @@ var PerpetualsClient = (function () {
4435
4336
  });
4436
4337
  };
4437
4338
  this.setFeeShareBps = function (poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4438
- var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_14;
4339
+ var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_12;
4439
4340
  return __generator(this, function (_c) {
4440
4341
  switch (_c.label) {
4441
4342
  case 0:
@@ -4479,15 +4380,15 @@ var PerpetualsClient = (function () {
4479
4380
  refreshStakeInstruction = _c.sent();
4480
4381
  return [2, refreshStakeInstruction];
4481
4382
  case 2:
4482
- err_14 = _c.sent();
4483
- console.log("perpClient refreshStaking error:: ", err_14);
4484
- throw err_14;
4383
+ err_12 = _c.sent();
4384
+ console.log("perpClient refreshStaking error:: ", err_12);
4385
+ throw err_12;
4485
4386
  case 3: return [2];
4486
4387
  }
4487
4388
  });
4488
4389
  }); };
4489
4390
  this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4490
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_15;
4391
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_13;
4491
4392
  return __generator(this, function (_a) {
4492
4393
  switch (_a.label) {
4493
4394
  case 0:
@@ -4521,9 +4422,9 @@ var PerpetualsClient = (function () {
4521
4422
  instructions.push(unstakeRequestInstruction);
4522
4423
  return [3, 4];
4523
4424
  case 3:
4524
- err_15 = _a.sent();
4525
- console.log("perpClient unstakeRequest error:: ", err_15);
4526
- throw err_15;
4425
+ err_13 = _a.sent();
4426
+ console.log("perpClient unstakeRequest error:: ", err_13);
4427
+ throw err_13;
4527
4428
  case 4: return [2, {
4528
4429
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4529
4430
  additionalSigners: additionalSigners
@@ -4537,7 +4438,7 @@ var PerpetualsClient = (function () {
4537
4438
  args_1[_i - 1] = arguments[_i];
4538
4439
  }
4539
4440
  return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, pendingActivation, deactivated, createUserLPTA, userPublicKey) {
4540
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_16;
4441
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_14;
4541
4442
  if (pendingActivation === void 0) { pendingActivation = true; }
4542
4443
  if (deactivated === void 0) { deactivated = true; }
4543
4444
  if (createUserLPTA === void 0) { createUserLPTA = true; }
@@ -4593,9 +4494,9 @@ var PerpetualsClient = (function () {
4593
4494
  instructions.push(withdrawStakeInstruction);
4594
4495
  return [3, 6];
4595
4496
  case 5:
4596
- err_16 = _b.sent();
4597
- console.log("perpClient withdrawStake error:: ", err_16);
4598
- throw err_16;
4497
+ err_14 = _b.sent();
4498
+ console.log("perpClient withdrawStake error:: ", err_14);
4499
+ throw err_14;
4599
4500
  case 6: return [2, {
4600
4501
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4601
4502
  additionalSigners: additionalSigners
@@ -4610,7 +4511,7 @@ var PerpetualsClient = (function () {
4610
4511
  args_1[_i - 3] = arguments[_i];
4611
4512
  }
4612
4513
  return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, tokenStakeAccount_1], args_1, true), void 0, function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
4613
- var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_17;
4514
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_15;
4614
4515
  if (createUserATA === void 0) { createUserATA = true; }
4615
4516
  return __generator(this, function (_b) {
4616
4517
  switch (_b.label) {
@@ -4671,9 +4572,9 @@ var PerpetualsClient = (function () {
4671
4572
  instructions.push(withdrawStakeInstruction);
4672
4573
  return [3, 6];
4673
4574
  case 5:
4674
- err_17 = _b.sent();
4675
- console.log("perpClient withdrawStake error:: ", err_17);
4676
- throw err_17;
4575
+ err_15 = _b.sent();
4576
+ console.log("perpClient withdrawStake error:: ", err_15);
4577
+ throw err_15;
4677
4578
  case 6: return [2, {
4678
4579
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4679
4580
  additionalSigners: additionalSigners
@@ -4688,7 +4589,7 @@ var PerpetualsClient = (function () {
4688
4589
  args_1[_i - 5] = arguments[_i];
4689
4590
  }
4690
4591
  return __awaiter(_this, __spreadArray([amountIn_1, minCompoundingAmountOut_1, inTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amountIn, minCompoundingAmountOut, inTokenSymbol, rewardTokenMint, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
4691
- var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, addCompoundingLiquidity, err_18;
4592
+ var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, addCompoundingLiquidity, err_16;
4692
4593
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
4693
4594
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4694
4595
  if (userPublicKey === void 0) { userPublicKey = undefined; }
@@ -4816,8 +4717,8 @@ var PerpetualsClient = (function () {
4816
4717
  instructions.push(addCompoundingLiquidity);
4817
4718
  return [3, 10];
4818
4719
  case 9:
4819
- err_18 = _f.sent();
4820
- console.log("perpClient addCompoundingLiquidity error:: ", err_18);
4720
+ err_16 = _f.sent();
4721
+ console.log("perpClient addCompoundingLiquidity error:: ", err_16);
4821
4722
  return [3, 10];
4822
4723
  case 10: return [2, {
4823
4724
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -4833,7 +4734,7 @@ var PerpetualsClient = (function () {
4833
4734
  args_1[_i - 5] = arguments[_i];
4834
4735
  }
4835
4736
  return __awaiter(_this, __spreadArray([compoundingAmountIn_1, minAmountOut_1, outTokenSymbol_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (compoundingAmountIn, minAmountOut, outTokenSymbol, rewardTokenMint, poolConfig, createUserATA, ephemeralSignerPubkey, userPublicKey) {
4836
- var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, removeCompoundingLiquidity, err_19;
4737
+ var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _b, _c, custody, _d, _e, market, compoundingTokenAccount, removeCompoundingLiquidity, err_17;
4837
4738
  if (createUserATA === void 0) { createUserATA = true; }
4838
4739
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
4839
4740
  if (userPublicKey === void 0) { userPublicKey = undefined; }
@@ -4945,8 +4846,8 @@ var PerpetualsClient = (function () {
4945
4846
  instructions.push(removeCompoundingLiquidity);
4946
4847
  return [3, 8];
4947
4848
  case 7:
4948
- err_19 = _f.sent();
4949
- console.log("perpClient removeCompoundingLiquidity error:: ", err_19);
4849
+ err_17 = _f.sent();
4850
+ console.log("perpClient removeCompoundingLiquidity error:: ", err_17);
4950
4851
  return [3, 8];
4951
4852
  case 8: return [2, {
4952
4853
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -4962,7 +4863,7 @@ var PerpetualsClient = (function () {
4962
4863
  args_1[_i - 3] = arguments[_i];
4963
4864
  }
4964
4865
  return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
4965
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, migrateStake, err_20;
4866
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, migrateStake, err_18;
4966
4867
  if (createUserATA === void 0) { createUserATA = true; }
4967
4868
  return __generator(this, function (_g) {
4968
4869
  switch (_g.label) {
@@ -5060,8 +4961,8 @@ var PerpetualsClient = (function () {
5060
4961
  instructions.push(migrateStake);
5061
4962
  return [3, 8];
5062
4963
  case 7:
5063
- err_20 = _g.sent();
5064
- console.log("perpClient migrateStake error:: ", err_20);
4964
+ err_18 = _g.sent();
4965
+ console.log("perpClient migrateStake error:: ", err_18);
5065
4966
  return [3, 8];
5066
4967
  case 8: return [2, {
5067
4968
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -5072,7 +4973,7 @@ var PerpetualsClient = (function () {
5072
4973
  });
5073
4974
  };
5074
4975
  this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5075
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_21;
4976
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_19;
5076
4977
  return __generator(this, function (_d) {
5077
4978
  switch (_d.label) {
5078
4979
  case 0:
@@ -5144,8 +5045,8 @@ var PerpetualsClient = (function () {
5144
5045
  instructions.push(migrateFlp);
5145
5046
  return [3, 4];
5146
5047
  case 3:
5147
- err_21 = _d.sent();
5148
- console.log("perpClient migrateFlp error:: ", err_21);
5048
+ err_19 = _d.sent();
5049
+ console.log("perpClient migrateFlp error:: ", err_19);
5149
5050
  return [3, 4];
5150
5051
  case 4: return [2, {
5151
5052
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -5160,7 +5061,7 @@ var PerpetualsClient = (function () {
5160
5061
  args_1[_i - 1] = arguments[_i];
5161
5062
  }
5162
5063
  return __awaiter(_this, __spreadArray([poolConfig_1], args_1, true), void 0, function (poolConfig, rewardTokenSymbol) {
5163
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_22;
5064
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, compoundingFee, err_20;
5164
5065
  if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
5165
5066
  return __generator(this, function (_e) {
5166
5067
  switch (_e.label) {
@@ -5218,8 +5119,8 @@ var PerpetualsClient = (function () {
5218
5119
  instructions.push(compoundingFee);
5219
5120
  return [3, 4];
5220
5121
  case 3:
5221
- err_22 = _e.sent();
5222
- console.log("perpClient compoundingFee error:: ", err_22);
5122
+ err_20 = _e.sent();
5123
+ console.log("perpClient compoundingFee error:: ", err_20);
5223
5124
  return [3, 4];
5224
5125
  case 4: return [2, {
5225
5126
  instructions: __spreadArray([], instructions, true),
@@ -5229,146 +5130,8 @@ var PerpetualsClient = (function () {
5229
5130
  });
5230
5131
  });
5231
5132
  };
5232
- this.burnAndClaim = function (owner, nftMint, poolConfig, createAta) { return __awaiter(_this, void 0, void 0, function () {
5233
- var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_23;
5234
- return __generator(this, function (_b) {
5235
- switch (_b.label) {
5236
- case 0:
5237
- preInstructions = [];
5238
- instructions = [];
5239
- postInstructions = [];
5240
- additionalSigners = [];
5241
- _b.label = 1;
5242
- case 1:
5243
- _b.trys.push([1, 7, , 8]);
5244
- return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.tokenMint, owner, true)];
5245
- case 2:
5246
- userTokenAccount = _b.sent();
5247
- _a = createAta;
5248
- if (!_a) return [3, 4];
5249
- return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
5250
- case 3:
5251
- _a = !(_b.sent());
5252
- _b.label = 4;
5253
- case 4:
5254
- if (_a) {
5255
- preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(owner, userTokenAccount, owner, poolConfig.tokenMint));
5256
- }
5257
- return [4, (0, spl_token_1.getAssociatedTokenAddress)(nftMint, owner, true)];
5258
- case 5:
5259
- nftTokenAccount = _b.sent();
5260
- nftTradingAccount = web3_js_1.PublicKey.findProgramAddressSync([
5261
- Buffer.from("trading"),
5262
- nftMint.toBuffer(),
5263
- ], this.programId)[0];
5264
- metadataAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), nftMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
5265
- collectionMetadata = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), poolConfig.nftCollectionAddress.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
5266
- edition = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), nftMint.toBuffer(), Buffer.from("edition")], constants_1.METAPLEX_PROGRAM_ID)[0];
5267
- tokenRecord = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), nftMint.toBuffer(), Buffer.from("token_record"), nftTokenAccount.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
5268
- return [4, this.program.methods
5269
- .burnAndClaim({})
5270
- .accounts({
5271
- owner: owner,
5272
- receivingTokenAccount: userTokenAccount,
5273
- perpetuals: this.perpetuals.publicKey,
5274
- tokenVault: poolConfig.tokenVault,
5275
- tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
5276
- metadataAccount: metadataAccount,
5277
- collectionMetadata: collectionMetadata,
5278
- edition: edition,
5279
- tokenRecord: tokenRecord,
5280
- tradingAccount: nftTradingAccount,
5281
- transferAuthority: poolConfig.transferAuthority,
5282
- metadataProgram: constants_1.METAPLEX_PROGRAM_ID,
5283
- nftMint: nftMint,
5284
- nftTokenAccount: nftTokenAccount,
5285
- systemProgram: web3_js_1.SystemProgram.programId,
5286
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5287
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
5288
- eventAuthority: this.eventAuthority.publicKey,
5289
- program: this.programId,
5290
- receivingTokenMint: poolConfig.tokenMint,
5291
- })
5292
- .instruction()];
5293
- case 6:
5294
- burnAndClaimInstruction = _b.sent();
5295
- instructions.push(burnAndClaimInstruction);
5296
- return [3, 8];
5297
- case 7:
5298
- err_23 = _b.sent();
5299
- console.log("perpClient burnAndClaimInstruction error:: ", err_23);
5300
- throw err_23;
5301
- case 8: return [2, {
5302
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5303
- additionalSigners: additionalSigners
5304
- }];
5305
- }
5306
- });
5307
- }); };
5308
- this.burnAndStake = function (owner, feePayer, nftMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5309
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_24;
5310
- return __generator(this, function (_a) {
5311
- switch (_a.label) {
5312
- case 0:
5313
- preInstructions = [];
5314
- instructions = [];
5315
- postInstructions = [];
5316
- additionalSigners = [];
5317
- _a.label = 1;
5318
- case 1:
5319
- _a.trys.push([1, 3, , 4]);
5320
- tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
5321
- nftTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(nftMint, owner, true);
5322
- nftTradingAccount = web3_js_1.PublicKey.findProgramAddressSync([
5323
- Buffer.from("trading"),
5324
- nftMint.toBuffer(),
5325
- ], this.programId)[0];
5326
- metadataAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), nftMint.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
5327
- collectionMetadata = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), poolConfig.nftCollectionAddress.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
5328
- edition = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), nftMint.toBuffer(), Buffer.from("edition")], constants_1.METAPLEX_PROGRAM_ID)[0];
5329
- tokenRecord = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("metadata"), constants_1.METAPLEX_PROGRAM_ID.toBuffer(), nftMint.toBuffer(), Buffer.from("token_record"), nftTokenAccount.toBuffer()], constants_1.METAPLEX_PROGRAM_ID)[0];
5330
- return [4, this.program.methods
5331
- .burnAndStake({})
5332
- .accounts({
5333
- owner: owner,
5334
- feePayer: feePayer,
5335
- perpetuals: this.perpetuals.publicKey,
5336
- tokenVault: poolConfig.tokenVault,
5337
- tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
5338
- tokenStakeAccount: tokenStakeAccount,
5339
- metadataAccount: metadataAccount,
5340
- collectionMetadata: collectionMetadata,
5341
- edition: edition,
5342
- tokenRecord: tokenRecord,
5343
- tradingAccount: nftTradingAccount,
5344
- transferAuthority: poolConfig.transferAuthority,
5345
- metadataProgram: constants_1.METAPLEX_PROGRAM_ID,
5346
- nftMint: nftMint,
5347
- nftTokenAccount: nftTokenAccount,
5348
- systemProgram: web3_js_1.SystemProgram.programId,
5349
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5350
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
5351
- eventAuthority: this.eventAuthority.publicKey,
5352
- program: this.programId
5353
- })
5354
- .instruction()];
5355
- case 2:
5356
- burnAndStakeInstruction = _a.sent();
5357
- instructions.push(burnAndStakeInstruction);
5358
- return [3, 4];
5359
- case 3:
5360
- err_24 = _a.sent();
5361
- console.log("perpClient burnAndStakeInstruction error:: ", err_24);
5362
- throw err_24;
5363
- case 4: return [2, {
5364
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5365
- additionalSigners: additionalSigners
5366
- }];
5367
- }
5368
- });
5369
- }); };
5370
5133
  this.depositTokenStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5371
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_25;
5134
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_21;
5372
5135
  return __generator(this, function (_a) {
5373
5136
  switch (_a.label) {
5374
5137
  case 0:
@@ -5410,9 +5173,9 @@ var PerpetualsClient = (function () {
5410
5173
  instructions.push(depositTokenStakeInstruction);
5411
5174
  return [3, 5];
5412
5175
  case 4:
5413
- err_25 = _a.sent();
5414
- console.log("perpClient depositStakingInstruction error:: ", err_25);
5415
- throw err_25;
5176
+ err_21 = _a.sent();
5177
+ console.log("perpClient depositStakingInstruction error:: ", err_21);
5178
+ throw err_21;
5416
5179
  case 5: return [2, {
5417
5180
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5418
5181
  additionalSigners: additionalSigners
@@ -5421,7 +5184,7 @@ var PerpetualsClient = (function () {
5421
5184
  });
5422
5185
  }); };
5423
5186
  this.unstakeTokenRequest = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5424
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_26;
5187
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_22;
5425
5188
  return __generator(this, function (_a) {
5426
5189
  switch (_a.label) {
5427
5190
  case 0:
@@ -5450,9 +5213,9 @@ var PerpetualsClient = (function () {
5450
5213
  instructions.push(unstakeTokenRequestInstruction);
5451
5214
  return [3, 4];
5452
5215
  case 3:
5453
- err_26 = _a.sent();
5454
- console.log("perpClient unstakeTokenRequestInstruction error:: ", err_26);
5455
- throw err_26;
5216
+ err_22 = _a.sent();
5217
+ console.log("perpClient unstakeTokenRequestInstruction error:: ", err_22);
5218
+ throw err_22;
5456
5219
  case 4: return [2, {
5457
5220
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5458
5221
  additionalSigners: additionalSigners
@@ -5461,7 +5224,7 @@ var PerpetualsClient = (function () {
5461
5224
  });
5462
5225
  }); };
5463
5226
  this.unstakeTokenInstant = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5464
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_27;
5227
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_23;
5465
5228
  return __generator(this, function (_a) {
5466
5229
  switch (_a.label) {
5467
5230
  case 0:
@@ -5502,9 +5265,9 @@ var PerpetualsClient = (function () {
5502
5265
  instructions.push(unstakeTokenInstantInstruction);
5503
5266
  return [3, 5];
5504
5267
  case 4:
5505
- err_27 = _a.sent();
5506
- console.log("perpClient unstakeTokenInstantInstruction error:: ", err_27);
5507
- throw err_27;
5268
+ err_23 = _a.sent();
5269
+ console.log("perpClient unstakeTokenInstantInstruction error:: ", err_23);
5270
+ throw err_23;
5508
5271
  case 5: return [2, {
5509
5272
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5510
5273
  additionalSigners: additionalSigners
@@ -5513,7 +5276,7 @@ var PerpetualsClient = (function () {
5513
5276
  });
5514
5277
  }); };
5515
5278
  this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5516
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_28;
5279
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_24;
5517
5280
  return __generator(this, function (_a) {
5518
5281
  switch (_a.label) {
5519
5282
  case 0:
@@ -5554,9 +5317,9 @@ var PerpetualsClient = (function () {
5554
5317
  instructions.push(withdrawTokenInstruction);
5555
5318
  return [3, 5];
5556
5319
  case 4:
5557
- err_28 = _a.sent();
5558
- console.log("perpClient withdrawTokenInstruction error:: ", err_28);
5559
- throw err_28;
5320
+ err_24 = _a.sent();
5321
+ console.log("perpClient withdrawTokenInstruction error:: ", err_24);
5322
+ throw err_24;
5560
5323
  case 5: return [2, {
5561
5324
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5562
5325
  additionalSigners: additionalSigners
@@ -5565,7 +5328,7 @@ var PerpetualsClient = (function () {
5565
5328
  });
5566
5329
  }); };
5567
5330
  this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5568
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_29;
5331
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_25;
5569
5332
  return __generator(this, function (_a) {
5570
5333
  switch (_a.label) {
5571
5334
  case 0:
@@ -5594,9 +5357,9 @@ var PerpetualsClient = (function () {
5594
5357
  instructions.push(cancelUnstakeRequestInstruction);
5595
5358
  return [3, 4];
5596
5359
  case 3:
5597
- err_29 = _a.sent();
5598
- console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_29);
5599
- throw err_29;
5360
+ err_25 = _a.sent();
5361
+ console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_25);
5362
+ throw err_25;
5600
5363
  case 4: return [2, {
5601
5364
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5602
5365
  additionalSigners: additionalSigners
@@ -5610,7 +5373,7 @@ var PerpetualsClient = (function () {
5610
5373
  args_1[_i - 2] = arguments[_i];
5611
5374
  }
5612
5375
  return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
5613
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_30;
5376
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_26;
5614
5377
  if (createUserATA === void 0) { createUserATA = true; }
5615
5378
  return __generator(this, function (_b) {
5616
5379
  switch (_b.label) {
@@ -5656,9 +5419,9 @@ var PerpetualsClient = (function () {
5656
5419
  instructions.push(collectTokenRewardInstruction);
5657
5420
  return [3, 6];
5658
5421
  case 5:
5659
- err_30 = _b.sent();
5660
- console.log("perpClient collectTokenRewardInstruction error:: ", err_30);
5661
- throw err_30;
5422
+ err_26 = _b.sent();
5423
+ console.log("perpClient collectTokenRewardInstruction error:: ", err_26);
5424
+ throw err_26;
5662
5425
  case 6: return [2, {
5663
5426
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5664
5427
  additionalSigners: additionalSigners
@@ -5673,7 +5436,7 @@ var PerpetualsClient = (function () {
5673
5436
  args_1[_i - 3] = arguments[_i];
5674
5437
  }
5675
5438
  return __awaiter(_this, __spreadArray([owner_1, rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (owner, rewardSymbol, poolConfig, createUserATA) {
5676
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_31;
5439
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_27;
5677
5440
  if (createUserATA === void 0) { createUserATA = true; }
5678
5441
  return __generator(this, function (_b) {
5679
5442
  switch (_b.label) {
@@ -5720,9 +5483,9 @@ var PerpetualsClient = (function () {
5720
5483
  instructions.push(collectRevenueInstruction);
5721
5484
  return [3, 6];
5722
5485
  case 5:
5723
- err_31 = _b.sent();
5724
- console.log("perpClient collectRevenueInstruction error:: ", err_31);
5725
- throw err_31;
5486
+ err_27 = _b.sent();
5487
+ console.log("perpClient collectRevenueInstruction error:: ", err_27);
5488
+ throw err_27;
5726
5489
  case 6: return [2, {
5727
5490
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5728
5491
  additionalSigners: additionalSigners
@@ -5732,7 +5495,7 @@ var PerpetualsClient = (function () {
5732
5495
  });
5733
5496
  };
5734
5497
  this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5735
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_32;
5498
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_28;
5736
5499
  return __generator(this, function (_a) {
5737
5500
  switch (_a.label) {
5738
5501
  case 0:
@@ -5769,9 +5532,9 @@ var PerpetualsClient = (function () {
5769
5532
  instructions.push(initRewardVault);
5770
5533
  return [3, 4];
5771
5534
  case 3:
5772
- err_32 = _a.sent();
5773
- console.log("perpClient InitRewardVault error:: ", err_32);
5774
- throw err_32;
5535
+ err_28 = _a.sent();
5536
+ console.log("perpClient InitRewardVault error:: ", err_28);
5537
+ throw err_28;
5775
5538
  case 4: return [2, {
5776
5539
  instructions: __spreadArray([], instructions, true),
5777
5540
  additionalSigners: additionalSigners
@@ -5780,7 +5543,7 @@ var PerpetualsClient = (function () {
5780
5543
  });
5781
5544
  }); };
5782
5545
  this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5783
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_33;
5546
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_29;
5784
5547
  return __generator(this, function (_a) {
5785
5548
  switch (_a.label) {
5786
5549
  case 0:
@@ -5811,9 +5574,9 @@ var PerpetualsClient = (function () {
5811
5574
  instructions.push(distributeReward);
5812
5575
  return [3, 4];
5813
5576
  case 3:
5814
- err_33 = _a.sent();
5815
- console.log("perpClient distributeReward error:: ", err_33);
5816
- throw err_33;
5577
+ err_29 = _a.sent();
5578
+ console.log("perpClient distributeReward error:: ", err_29);
5579
+ throw err_29;
5817
5580
  case 4: return [2, {
5818
5581
  instructions: __spreadArray([], instructions, true),
5819
5582
  additionalSigners: additionalSigners
@@ -5827,7 +5590,7 @@ var PerpetualsClient = (function () {
5827
5590
  args_1[_i - 3] = arguments[_i];
5828
5591
  }
5829
5592
  return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1, nftMint_1], args_1, true), void 0, function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5830
- var publicKey, rewardToken, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_34;
5593
+ var publicKey, rewardToken, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_30;
5831
5594
  if (createUserATA === void 0) { createUserATA = true; }
5832
5595
  return __generator(this, function (_b) {
5833
5596
  switch (_b.label) {
@@ -5879,8 +5642,8 @@ var PerpetualsClient = (function () {
5879
5642
  instructions.push(collectNftReward);
5880
5643
  return [3, 6];
5881
5644
  case 5:
5882
- err_34 = _b.sent();
5883
- throw err_34;
5645
+ err_30 = _b.sent();
5646
+ throw err_30;
5884
5647
  case 6: return [2, {
5885
5648
  instructions: __spreadArray([], instructions, true),
5886
5649
  additionalSigners: additionalSigners
@@ -5895,7 +5658,7 @@ var PerpetualsClient = (function () {
5895
5658
  args_1[_i - 2] = arguments[_i];
5896
5659
  }
5897
5660
  return __awaiter(_this, __spreadArray([rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
5898
- var publicKey, rewardToken, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_35;
5661
+ var publicKey, rewardToken, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_31;
5899
5662
  if (createUserATA === void 0) { createUserATA = true; }
5900
5663
  return __generator(this, function (_b) {
5901
5664
  switch (_b.label) {
@@ -5961,9 +5724,9 @@ var PerpetualsClient = (function () {
5961
5724
  instructions.push(withdrawStakeInstruction);
5962
5725
  return [3, 6];
5963
5726
  case 5:
5964
- err_35 = _b.sent();
5965
- console.log("perpClient withdrawStake error:: ", err_35);
5966
- throw err_35;
5727
+ err_31 = _b.sent();
5728
+ console.log("perpClient withdrawStake error:: ", err_31);
5729
+ throw err_31;
5967
5730
  case 6: return [2, {
5968
5731
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5969
5732
  additionalSigners: additionalSigners
@@ -5978,7 +5741,7 @@ var PerpetualsClient = (function () {
5978
5741
  args_1[_i - 11] = arguments[_i];
5979
5742
  }
5980
5743
  return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
5981
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_36;
5744
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_32;
5982
5745
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
5983
5746
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5984
5747
  return __generator(this, function (_c) {
@@ -6084,9 +5847,9 @@ var PerpetualsClient = (function () {
6084
5847
  instructions.push(placeLimitOrder);
6085
5848
  return [3, 10];
6086
5849
  case 9:
6087
- err_36 = _c.sent();
6088
- console.log("perpClient placeLimitOrder error:: ", err_36);
6089
- throw err_36;
5850
+ err_32 = _c.sent();
5851
+ console.log("perpClient placeLimitOrder error:: ", err_32);
5852
+ throw err_32;
6090
5853
  case 10: return [2, {
6091
5854
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6092
5855
  additionalSigners: additionalSigners
@@ -6101,7 +5864,7 @@ var PerpetualsClient = (function () {
6101
5864
  args_1[_i - 11] = arguments[_i];
6102
5865
  }
6103
5866
  return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
6104
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_37;
5867
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_33;
6105
5868
  if (createUserATA === void 0) { createUserATA = true; }
6106
5869
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6107
5870
  return __generator(this, function (_b) {
@@ -6192,9 +5955,9 @@ var PerpetualsClient = (function () {
6192
5955
  instructions.push(editLimitOrder);
6193
5956
  return [3, 8];
6194
5957
  case 7:
6195
- err_37 = _b.sent();
6196
- console.log("perpClient editLimitOrder error:: ", err_37);
6197
- throw err_37;
5958
+ err_33 = _b.sent();
5959
+ console.log("perpClient editLimitOrder error:: ", err_33);
5960
+ throw err_33;
6198
5961
  case 8: return [2, {
6199
5962
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6200
5963
  additionalSigners: additionalSigners
@@ -6209,7 +5972,7 @@ var PerpetualsClient = (function () {
6209
5972
  args_1[_i - 7] = arguments[_i];
6210
5973
  }
6211
5974
  return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6212
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_38;
5975
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_34;
6213
5976
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6214
5977
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6215
5978
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
@@ -6262,9 +6025,9 @@ var PerpetualsClient = (function () {
6262
6025
  instructions.push(executeLimitOrder);
6263
6026
  return [3, 4];
6264
6027
  case 3:
6265
- err_38 = _a.sent();
6266
- console.log("perpClient executeLimitOrder error:: ", err_38);
6267
- throw err_38;
6028
+ err_34 = _a.sent();
6029
+ console.log("perpClient executeLimitOrder error:: ", err_34);
6030
+ throw err_34;
6268
6031
  case 4: return [2, {
6269
6032
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6270
6033
  additionalSigners: additionalSigners
@@ -6279,7 +6042,7 @@ var PerpetualsClient = (function () {
6279
6042
  args_1[_i - 8] = arguments[_i];
6280
6043
  }
6281
6044
  return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6282
- var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_39;
6045
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_35;
6283
6046
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6284
6047
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6285
6048
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
@@ -6335,9 +6098,9 @@ var PerpetualsClient = (function () {
6335
6098
  instructions.push(executeLimitWithSwap);
6336
6099
  return [3, 4];
6337
6100
  case 3:
6338
- err_39 = _a.sent();
6339
- console.log("perpClient executeLimitWithSwap error:: ", err_39);
6340
- throw err_39;
6101
+ err_35 = _a.sent();
6102
+ console.log("perpClient executeLimitWithSwap error:: ", err_35);
6103
+ throw err_35;
6341
6104
  case 4: return [2, {
6342
6105
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6343
6106
  additionalSigners: additionalSigners
@@ -6347,7 +6110,7 @@ var PerpetualsClient = (function () {
6347
6110
  });
6348
6111
  };
6349
6112
  this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6350
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_40;
6113
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_36;
6351
6114
  return __generator(this, function (_a) {
6352
6115
  switch (_a.label) {
6353
6116
  case 0:
@@ -6395,9 +6158,9 @@ var PerpetualsClient = (function () {
6395
6158
  instructions.push(placeTriggerOrder);
6396
6159
  return [3, 4];
6397
6160
  case 3:
6398
- err_40 = _a.sent();
6399
- console.log("perpClient placeTriggerOrder error:: ", err_40);
6400
- throw err_40;
6161
+ err_36 = _a.sent();
6162
+ console.log("perpClient placeTriggerOrder error:: ", err_36);
6163
+ throw err_36;
6401
6164
  case 4: return [2, {
6402
6165
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6403
6166
  additionalSigners: additionalSigners
@@ -6406,7 +6169,7 @@ var PerpetualsClient = (function () {
6406
6169
  });
6407
6170
  }); };
6408
6171
  this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6409
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_41;
6172
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_37;
6410
6173
  return __generator(this, function (_a) {
6411
6174
  switch (_a.label) {
6412
6175
  case 0:
@@ -6453,9 +6216,9 @@ var PerpetualsClient = (function () {
6453
6216
  instructions.push(editTriggerOrder);
6454
6217
  return [3, 4];
6455
6218
  case 3:
6456
- err_41 = _a.sent();
6457
- console.log("perpClient editTriggerOrder error:: ", err_41);
6458
- throw err_41;
6219
+ err_37 = _a.sent();
6220
+ console.log("perpClient editTriggerOrder error:: ", err_37);
6221
+ throw err_37;
6459
6222
  case 4: return [2, {
6460
6223
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6461
6224
  additionalSigners: additionalSigners
@@ -6464,7 +6227,7 @@ var PerpetualsClient = (function () {
6464
6227
  });
6465
6228
  }); };
6466
6229
  this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6467
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_42;
6230
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_38;
6468
6231
  return __generator(this, function (_a) {
6469
6232
  switch (_a.label) {
6470
6233
  case 0:
@@ -6497,9 +6260,9 @@ var PerpetualsClient = (function () {
6497
6260
  instructions.push(cancelTriggerOrder);
6498
6261
  return [3, 4];
6499
6262
  case 3:
6500
- err_42 = _a.sent();
6501
- console.log("perpClient cancelTriggerOrder error:: ", err_42);
6502
- throw err_42;
6263
+ err_38 = _a.sent();
6264
+ console.log("perpClient cancelTriggerOrder error:: ", err_38);
6265
+ throw err_38;
6503
6266
  case 4: return [2, {
6504
6267
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6505
6268
  additionalSigners: additionalSigners
@@ -6508,7 +6271,7 @@ var PerpetualsClient = (function () {
6508
6271
  });
6509
6272
  }); };
6510
6273
  this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6511
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_43;
6274
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_39;
6512
6275
  return __generator(this, function (_a) {
6513
6276
  switch (_a.label) {
6514
6277
  case 0:
@@ -6539,9 +6302,9 @@ var PerpetualsClient = (function () {
6539
6302
  instructions.push(cancelAllTriggerOrders);
6540
6303
  return [3, 4];
6541
6304
  case 3:
6542
- err_43 = _a.sent();
6543
- console.log("perpClient cancelAllTriggerOrders error:: ", err_43);
6544
- throw err_43;
6305
+ err_39 = _a.sent();
6306
+ console.log("perpClient cancelAllTriggerOrders error:: ", err_39);
6307
+ throw err_39;
6545
6308
  case 4: return [2, {
6546
6309
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6547
6310
  additionalSigners: additionalSigners
@@ -6555,7 +6318,7 @@ var PerpetualsClient = (function () {
6555
6318
  args_1[_i - 9] = arguments[_i];
6556
6319
  }
6557
6320
  return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6558
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, collateralToken, receivingToken, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_44;
6321
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, collateralToken, receivingToken, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_40;
6559
6322
  if (createUserATA === void 0) { createUserATA = true; }
6560
6323
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6561
6324
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
@@ -6662,9 +6425,9 @@ var PerpetualsClient = (function () {
6662
6425
  instructions.push(executeTriggerWithSwap);
6663
6426
  return [3, 10];
6664
6427
  case 9:
6665
- err_44 = _e.sent();
6666
- console.log("perpClient executeTriggerWithSwap error:: ", err_44);
6667
- throw err_44;
6428
+ err_40 = _e.sent();
6429
+ console.log("perpClient executeTriggerWithSwap error:: ", err_40);
6430
+ throw err_40;
6668
6431
  case 10: return [2, {
6669
6432
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6670
6433
  additionalSigners: additionalSigners
@@ -6679,7 +6442,7 @@ var PerpetualsClient = (function () {
6679
6442
  args_1[_i - 8] = arguments[_i];
6680
6443
  }
6681
6444
  return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6682
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_45;
6445
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_41;
6683
6446
  if (createUserATA === void 0) { createUserATA = true; }
6684
6447
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6685
6448
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
@@ -6751,9 +6514,9 @@ var PerpetualsClient = (function () {
6751
6514
  instructions.push(executeTriggerOrder);
6752
6515
  return [3, 8];
6753
6516
  case 7:
6754
- err_45 = _b.sent();
6755
- console.log("perpClient executeTriggerOrder error:: ", err_45);
6756
- throw err_45;
6517
+ err_41 = _b.sent();
6518
+ console.log("perpClient executeTriggerOrder error:: ", err_41);
6519
+ throw err_41;
6757
6520
  case 8: return [2, {
6758
6521
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6759
6522
  additionalSigners: additionalSigners
@@ -6768,7 +6531,7 @@ var PerpetualsClient = (function () {
6768
6531
  args_1[_i - 5] = arguments[_i];
6769
6532
  }
6770
6533
  return __awaiter(_this, __spreadArray([userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1], args_1, true), void 0, function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey) {
6771
- var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _e, _f, custody, params, inx, closeWsolATAIns, err_46;
6534
+ var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _e, _f, custody, params, inx, closeWsolATAIns, err_42;
6772
6535
  if (useFeesPool === void 0) { useFeesPool = false; }
6773
6536
  if (createUserATA === void 0) { createUserATA = true; }
6774
6537
  if (unWrapSol === void 0) { unWrapSol = false; }
@@ -6973,9 +6736,9 @@ var PerpetualsClient = (function () {
6973
6736
  }
6974
6737
  return [3, 20];
6975
6738
  case 19:
6976
- err_46 = _g.sent();
6977
- console.error("perpClient Swap error:: ", err_46);
6978
- throw err_46;
6739
+ err_42 = _g.sent();
6740
+ console.error("perpClient Swap error:: ", err_42);
6741
+ throw err_42;
6979
6742
  case 20: return [2, {
6980
6743
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6981
6744
  additionalSigners: additionalSigners
@@ -6985,7 +6748,7 @@ var PerpetualsClient = (function () {
6985
6748
  });
6986
6749
  };
6987
6750
  this.swapFeeInternal = function (rewardTokenSymbol, swapTokenSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6988
- var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_47;
6751
+ var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_43;
6989
6752
  return __generator(this, function (_b) {
6990
6753
  switch (_b.label) {
6991
6754
  case 0:
@@ -7045,9 +6808,9 @@ var PerpetualsClient = (function () {
7045
6808
  instructions.push(inx);
7046
6809
  return [3, 4];
7047
6810
  case 3:
7048
- err_47 = _b.sent();
7049
- console.error("perpClient Swap error:: ", err_47);
7050
- throw err_47;
6811
+ err_43 = _b.sent();
6812
+ console.error("perpClient Swap error:: ", err_43);
6813
+ throw err_43;
7051
6814
  case 4: return [2, {
7052
6815
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7053
6816
  additionalSigners: additionalSigners
@@ -7056,7 +6819,7 @@ var PerpetualsClient = (function () {
7056
6819
  });
7057
6820
  }); };
7058
6821
  this.setLpTokenPrice = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7059
- var instructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, setLpTokenPriceInstruction, err_48;
6822
+ var instructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, setLpTokenPriceInstruction, err_44;
7060
6823
  return __generator(this, function (_d) {
7061
6824
  switch (_d.label) {
7062
6825
  case 0:
@@ -7104,9 +6867,9 @@ var PerpetualsClient = (function () {
7104
6867
  instructions.push(setLpTokenPriceInstruction);
7105
6868
  return [3, 4];
7106
6869
  case 3:
7107
- err_48 = _d.sent();
7108
- console.log("perpClient setLpTokenPriceInstruction error:: ", err_48);
7109
- throw err_48;
6870
+ err_44 = _d.sent();
6871
+ console.log("perpClient setLpTokenPriceInstruction error:: ", err_44);
6872
+ throw err_44;
7110
6873
  case 4: return [2, {
7111
6874
  instructions: __spreadArray([], instructions, true),
7112
6875
  additionalSigners: additionalSigners
@@ -7154,7 +6917,7 @@ var PerpetualsClient = (function () {
7154
6917
  });
7155
6918
  }); };
7156
6919
  this.setAdminSigners = function (admins, minSignatures) { return __awaiter(_this, void 0, void 0, function () {
7157
- var adminMetas, _i, admins_2, admin, err_49;
6920
+ var adminMetas, _i, admins_2, admin, err_45;
7158
6921
  return __generator(this, function (_a) {
7159
6922
  switch (_a.label) {
7160
6923
  case 0:
@@ -7184,11 +6947,11 @@ var PerpetualsClient = (function () {
7184
6947
  _a.sent();
7185
6948
  return [3, 4];
7186
6949
  case 3:
7187
- err_49 = _a.sent();
6950
+ err_45 = _a.sent();
7188
6951
  if (this.printErrors) {
7189
- console.error("setAdminSigners err:", err_49);
6952
+ console.error("setAdminSigners err:", err_45);
7190
6953
  }
7191
- throw err_49;
6954
+ throw err_45;
7192
6955
  case 4: return [2];
7193
6956
  }
7194
6957
  });
@@ -7377,7 +7140,7 @@ var PerpetualsClient = (function () {
7377
7140
  });
7378
7141
  }); };
7379
7142
  this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7380
- var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_50;
7143
+ var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_46;
7381
7144
  return __generator(this, function (_a) {
7382
7145
  switch (_a.label) {
7383
7146
  case 0:
@@ -7410,9 +7173,9 @@ var PerpetualsClient = (function () {
7410
7173
  instructions.push(withdrawFeesIx);
7411
7174
  return [3, 5];
7412
7175
  case 4:
7413
- err_50 = _a.sent();
7414
- console.log("perpClient setPool error:: ", err_50);
7415
- throw err_50;
7176
+ err_46 = _a.sent();
7177
+ console.log("perpClient setPool error:: ", err_46);
7178
+ throw err_46;
7416
7179
  case 5: return [2, {
7417
7180
  instructions: __spreadArray([], instructions, true),
7418
7181
  additionalSigners: additionalSigners
@@ -7421,7 +7184,7 @@ var PerpetualsClient = (function () {
7421
7184
  });
7422
7185
  }); };
7423
7186
  this.moveProtocolFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7424
- var publicKey, custodyConfig, instructions, additionalSigners, moveProtocolFeesIx, err_51;
7187
+ var publicKey, custodyConfig, instructions, additionalSigners, moveProtocolFeesIx, err_47;
7425
7188
  return __generator(this, function (_a) {
7426
7189
  switch (_a.label) {
7427
7190
  case 0:
@@ -7455,9 +7218,9 @@ var PerpetualsClient = (function () {
7455
7218
  instructions.push(moveProtocolFeesIx);
7456
7219
  return [3, 4];
7457
7220
  case 3:
7458
- err_51 = _a.sent();
7459
- console.log("perpClient setPool error:: ", err_51);
7460
- throw err_51;
7221
+ err_47 = _a.sent();
7222
+ console.log("perpClient setPool error:: ", err_47);
7223
+ throw err_47;
7461
7224
  case 4: return [2, {
7462
7225
  instructions: __spreadArray([], instructions, true),
7463
7226
  additionalSigners: additionalSigners
@@ -7466,7 +7229,7 @@ var PerpetualsClient = (function () {
7466
7229
  });
7467
7230
  }); };
7468
7231
  this.setProtocolFeeShareBps = function (feeShareBps, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7469
- var publicKey, setProtocolFeeShareBpsIx, err_52;
7232
+ var publicKey, setProtocolFeeShareBpsIx, err_48;
7470
7233
  return __generator(this, function (_a) {
7471
7234
  switch (_a.label) {
7472
7235
  case 0:
@@ -7486,15 +7249,15 @@ var PerpetualsClient = (function () {
7486
7249
  setProtocolFeeShareBpsIx = _a.sent();
7487
7250
  return [2, setProtocolFeeShareBpsIx];
7488
7251
  case 2:
7489
- err_52 = _a.sent();
7490
- console.log("perpClient setProtocolFeeShareBpsIx error:: ", err_52);
7491
- throw err_52;
7252
+ err_48 = _a.sent();
7253
+ console.log("perpClient setProtocolFeeShareBpsIx error:: ", err_48);
7254
+ throw err_48;
7492
7255
  case 3: return [2];
7493
7256
  }
7494
7257
  });
7495
7258
  }); };
7496
7259
  this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
7497
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_53;
7260
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_49;
7498
7261
  return __generator(this, function (_a) {
7499
7262
  switch (_a.label) {
7500
7263
  case 0:
@@ -7521,9 +7284,9 @@ var PerpetualsClient = (function () {
7521
7284
  instructions.push(setPermissionsInstruction);
7522
7285
  return [3, 4];
7523
7286
  case 3:
7524
- err_53 = _a.sent();
7525
- console.log("perpClient setPool error:: ", err_53);
7526
- throw err_53;
7287
+ err_49 = _a.sent();
7288
+ console.log("perpClient setPool error:: ", err_49);
7289
+ throw err_49;
7527
7290
  case 4: return [2, {
7528
7291
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7529
7292
  additionalSigners: additionalSigners
@@ -7532,7 +7295,7 @@ var PerpetualsClient = (function () {
7532
7295
  });
7533
7296
  }); };
7534
7297
  this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7535
- var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_54;
7298
+ var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_50;
7536
7299
  var _f;
7537
7300
  return __generator(this, function (_g) {
7538
7301
  switch (_g.label) {
@@ -7593,9 +7356,9 @@ var PerpetualsClient = (function () {
7593
7356
  instructions.push(reimburse);
7594
7357
  return [3, 5];
7595
7358
  case 4:
7596
- err_54 = _g.sent();
7597
- console.log("perpClient setPool error:: ", err_54);
7598
- throw err_54;
7359
+ err_50 = _g.sent();
7360
+ console.log("perpClient setPool error:: ", err_50);
7361
+ throw err_50;
7599
7362
  case 5: return [2, {
7600
7363
  instructions: __spreadArray([], instructions, true),
7601
7364
  additionalSigners: additionalSigners
@@ -7603,8 +7366,8 @@ var PerpetualsClient = (function () {
7603
7366
  }
7604
7367
  });
7605
7368
  }); };
7606
- this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7607
- var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_55;
7369
+ this.setInternalOraclePrice = function (tokenMint, useCurrentTime, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7370
+ var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_51;
7608
7371
  return __generator(this, function (_a) {
7609
7372
  switch (_a.label) {
7610
7373
  case 0:
@@ -7616,6 +7379,7 @@ var PerpetualsClient = (function () {
7616
7379
  _a.trys.push([1, 3, , 4]);
7617
7380
  return [4, this.program.methods
7618
7381
  .setInternalOraclePrice({
7382
+ useCurrentTime: useCurrentTime,
7619
7383
  price: price,
7620
7384
  expo: expo,
7621
7385
  conf: conf,
@@ -7637,9 +7401,9 @@ var PerpetualsClient = (function () {
7637
7401
  instructions.push(setInternalOraclePrice);
7638
7402
  return [3, 4];
7639
7403
  case 3:
7640
- err_55 = _a.sent();
7641
- console.log("perpClient setInternalOracleAccount error:: ", err_55);
7642
- throw err_55;
7404
+ err_51 = _a.sent();
7405
+ console.log("perpClient setInternalOracleAccount error:: ", err_51);
7406
+ throw err_51;
7643
7407
  case 4: return [2, {
7644
7408
  instructions: __spreadArray([], instructions, true),
7645
7409
  additionalSigners: additionalSigners
@@ -7647,8 +7411,8 @@ var PerpetualsClient = (function () {
7647
7411
  }
7648
7412
  });
7649
7413
  }); };
7650
- this.setInternalOraclePriceBatch = function (tokenMintList, tokenInternalPrices, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
7651
- var ALL_CUSTODY_CONFIGS, accountMetas, _loop_1, _i, tokenMintList_1, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_56;
7414
+ this.setInternalOraclePriceBatch = function (useCurrentTime, tokenMintList, tokenInternalPrices, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
7415
+ var ALL_CUSTODY_CONFIGS, accountMetas, _loop_1, _i, tokenMintList_1, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_52;
7652
7416
  return __generator(this, function (_a) {
7653
7417
  switch (_a.label) {
7654
7418
  case 0:
@@ -7681,6 +7445,7 @@ var PerpetualsClient = (function () {
7681
7445
  _a.trys.push([1, 3, , 4]);
7682
7446
  return [4, this.program.methods
7683
7447
  .setInternalCurrentPrice({
7448
+ useCurrentTime: useCurrentTime,
7684
7449
  prices: tokenInternalPrices
7685
7450
  })
7686
7451
  .accounts({
@@ -7693,9 +7458,9 @@ var PerpetualsClient = (function () {
7693
7458
  instructions.push(setInternalOraclePrice);
7694
7459
  return [3, 4];
7695
7460
  case 3:
7696
- err_56 = _a.sent();
7697
- console.log("perpClient setInternalOracleAccount error:: ", err_56);
7698
- throw err_56;
7461
+ err_52 = _a.sent();
7462
+ console.log("perpClient setInternalOracleAccount error:: ", err_52);
7463
+ throw err_52;
7699
7464
  case 4: return [2, {
7700
7465
  instructions: __spreadArray([], instructions, true),
7701
7466
  additionalSigners: additionalSigners
@@ -7704,7 +7469,7 @@ var PerpetualsClient = (function () {
7704
7469
  });
7705
7470
  }); };
7706
7471
  this.setInternalOracleEmaPriceBatch = function (tokenMintList, tokenInternalEmaPrices, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
7707
- var ALL_CUSTODY_CONFIGS, accountMetas, _loop_2, _i, tokenMintList_2, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_57;
7472
+ var ALL_CUSTODY_CONFIGS, accountMetas, _loop_2, _i, tokenMintList_2, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_53;
7708
7473
  return __generator(this, function (_a) {
7709
7474
  switch (_a.label) {
7710
7475
  case 0:
@@ -7720,11 +7485,6 @@ var PerpetualsClient = (function () {
7720
7485
  isSigner: false,
7721
7486
  isWritable: true,
7722
7487
  });
7723
- accountMetas.push({
7724
- pubkey: custody.extOracleAccount,
7725
- isSigner: false,
7726
- isWritable: false,
7727
- });
7728
7488
  };
7729
7489
  for (_i = 0, tokenMintList_2 = tokenMintList; _i < tokenMintList_2.length; _i++) {
7730
7490
  tokenMint = tokenMintList_2[_i];
@@ -7749,9 +7509,9 @@ var PerpetualsClient = (function () {
7749
7509
  instructions.push(setInternalOraclePrice);
7750
7510
  return [3, 4];
7751
7511
  case 3:
7752
- err_57 = _a.sent();
7753
- console.log("perpClient setInternalOracleAccount error:: ", err_57);
7754
- throw err_57;
7512
+ err_53 = _a.sent();
7513
+ console.log("perpClient setInternalOracleAccount error:: ", err_53);
7514
+ throw err_53;
7755
7515
  case 4: return [2, {
7756
7516
  instructions: __spreadArray([], instructions, true),
7757
7517
  additionalSigners: additionalSigners
@@ -7760,7 +7520,7 @@ var PerpetualsClient = (function () {
7760
7520
  });
7761
7521
  }); };
7762
7522
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7763
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_58;
7523
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_54;
7764
7524
  return __generator(this, function (_a) {
7765
7525
  switch (_a.label) {
7766
7526
  case 0:
@@ -7798,8 +7558,8 @@ var PerpetualsClient = (function () {
7798
7558
  instructions.push(renameFlp);
7799
7559
  return [3, 4];
7800
7560
  case 3:
7801
- err_58 = _a.sent();
7802
- console.log("perpClient renameFlp error:: ", err_58);
7561
+ err_54 = _a.sent();
7562
+ console.log("perpClient renameFlp error:: ", err_54);
7803
7563
  return [3, 4];
7804
7564
  case 4: return [2, {
7805
7565
  instructions: __spreadArray([], instructions, true),
@@ -7809,7 +7569,7 @@ var PerpetualsClient = (function () {
7809
7569
  });
7810
7570
  }); };
7811
7571
  this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7812
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_59;
7572
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_55;
7813
7573
  return __generator(this, function (_a) {
7814
7574
  switch (_a.label) {
7815
7575
  case 0:
@@ -7847,9 +7607,9 @@ var PerpetualsClient = (function () {
7847
7607
  instructions.push(initStakeInstruction);
7848
7608
  return [3, 4];
7849
7609
  case 3:
7850
- err_59 = _a.sent();
7851
- console.log("perpClient InitStaking error:: ", err_59);
7852
- throw err_59;
7610
+ err_55 = _a.sent();
7611
+ console.log("perpClient InitStaking error:: ", err_55);
7612
+ throw err_55;
7853
7613
  case 4: return [2, {
7854
7614
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7855
7615
  additionalSigners: additionalSigners
@@ -7858,7 +7618,7 @@ var PerpetualsClient = (function () {
7858
7618
  });
7859
7619
  }); };
7860
7620
  this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7861
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_60;
7621
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_56;
7862
7622
  return __generator(this, function (_a) {
7863
7623
  switch (_a.label) {
7864
7624
  case 0:
@@ -7887,7 +7647,6 @@ var PerpetualsClient = (function () {
7887
7647
  transferAuthority: poolConfig.transferAuthority,
7888
7648
  perpetuals: this.perpetuals.publicKey,
7889
7649
  pool: poolConfig.poolAddress,
7890
- custody: rewardCustodyConfig.custodyAccount,
7891
7650
  lpTokenMint: poolConfig.stakedLpTokenMint,
7892
7651
  compoundingVault: compoundingVault,
7893
7652
  compoundingTokenMint: compoundingTokenMint,
@@ -7903,9 +7662,9 @@ var PerpetualsClient = (function () {
7903
7662
  instructions.push(initCompoundingInstruction);
7904
7663
  return [3, 4];
7905
7664
  case 3:
7906
- err_60 = _a.sent();
7907
- console.log("perpClient initCompounding error:: ", err_60);
7908
- throw err_60;
7665
+ err_56 = _a.sent();
7666
+ console.log("perpClient initCompounding error:: ", err_56);
7667
+ throw err_56;
7909
7668
  case 4: return [2, {
7910
7669
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7911
7670
  additionalSigners: additionalSigners
@@ -7914,7 +7673,7 @@ var PerpetualsClient = (function () {
7914
7673
  });
7915
7674
  }); };
7916
7675
  this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7917
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_61;
7676
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_57;
7918
7677
  return __generator(this, function (_a) {
7919
7678
  switch (_a.label) {
7920
7679
  case 0:
@@ -7955,9 +7714,9 @@ var PerpetualsClient = (function () {
7955
7714
  instructions.push(initTokenVaultInstruction);
7956
7715
  return [3, 4];
7957
7716
  case 3:
7958
- err_61 = _a.sent();
7959
- console.log("perpClient InitTokenVaultInstruction error:: ", err_61);
7960
- throw err_61;
7717
+ err_57 = _a.sent();
7718
+ console.log("perpClient InitTokenVaultInstruction error:: ", err_57);
7719
+ throw err_57;
7961
7720
  case 4: return [2, {
7962
7721
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7963
7722
  additionalSigners: additionalSigners
@@ -7966,7 +7725,7 @@ var PerpetualsClient = (function () {
7966
7725
  });
7967
7726
  }); };
7968
7727
  this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7969
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_62;
7728
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_58;
7970
7729
  return __generator(this, function (_a) {
7971
7730
  switch (_a.label) {
7972
7731
  case 0:
@@ -7997,9 +7756,9 @@ var PerpetualsClient = (function () {
7997
7756
  instructions.push(setTokenVaultConfigInstruction);
7998
7757
  return [3, 4];
7999
7758
  case 3:
8000
- err_62 = _a.sent();
8001
- console.log("perpClient setTokenVaultConfigInstruction error:: ", err_62);
8002
- throw err_62;
7759
+ err_58 = _a.sent();
7760
+ console.log("perpClient setTokenVaultConfigInstruction error:: ", err_58);
7761
+ throw err_58;
8003
7762
  case 4: return [2, {
8004
7763
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8005
7764
  additionalSigners: additionalSigners
@@ -8008,7 +7767,7 @@ var PerpetualsClient = (function () {
8008
7767
  });
8009
7768
  }); };
8010
7769
  this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8011
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_63;
7770
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_59;
8012
7771
  return __generator(this, function (_a) {
8013
7772
  switch (_a.label) {
8014
7773
  case 0:
@@ -8047,9 +7806,59 @@ var PerpetualsClient = (function () {
8047
7806
  instructions.push(withdrawInstantFeeInstruction);
8048
7807
  return [3, 6];
8049
7808
  case 5:
8050
- err_63 = _a.sent();
8051
- console.log("perpClient withdrawInstantFeeInstruction error:: ", err_63);
8052
- throw err_63;
7809
+ err_59 = _a.sent();
7810
+ console.log("perpClient withdrawInstantFeeInstruction error:: ", err_59);
7811
+ throw err_59;
7812
+ case 6: return [2, {
7813
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7814
+ additionalSigners: additionalSigners
7815
+ }];
7816
+ }
7817
+ });
7818
+ }); };
7819
+ this.withdrawUnclaimedTokens = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7820
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawUnclaimedTokensInstruction, err_60;
7821
+ return __generator(this, function (_a) {
7822
+ switch (_a.label) {
7823
+ case 0:
7824
+ publicKey = this.provider.wallet.publicKey;
7825
+ preInstructions = [];
7826
+ instructions = [];
7827
+ postInstructions = [];
7828
+ additionalSigners = [];
7829
+ _a.label = 1;
7830
+ case 1:
7831
+ _a.trys.push([1, 5, , 6]);
7832
+ return [4, (0, spl_token_1.getAssociatedTokenAddress)(poolConfig.tokenMint, publicKey, true)];
7833
+ case 2:
7834
+ receivingTokenAccount = _a.sent();
7835
+ return [4, (0, utils_1.checkIfAccountExists)(receivingTokenAccount, this.provider.connection)];
7836
+ case 3:
7837
+ if (!(_a.sent())) {
7838
+ preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, receivingTokenAccount, publicKey, poolConfig.tokenMint));
7839
+ }
7840
+ return [4, this.program.methods
7841
+ .withdrawUnclaimedTokens({})
7842
+ .accounts({
7843
+ admin: publicKey,
7844
+ multisig: this.multisig.publicKey,
7845
+ perpetuals: this.perpetuals.publicKey,
7846
+ transferAuthority: poolConfig.transferAuthority,
7847
+ tokenVault: poolConfig.tokenVault,
7848
+ tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
7849
+ receivingTokenAccount: receivingTokenAccount,
7850
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
7851
+ receivingTokenMint: poolConfig.tokenMint,
7852
+ })
7853
+ .instruction()];
7854
+ case 4:
7855
+ withdrawUnclaimedTokensInstruction = _a.sent();
7856
+ instructions.push(withdrawUnclaimedTokensInstruction);
7857
+ return [3, 6];
7858
+ case 5:
7859
+ err_60 = _a.sent();
7860
+ console.log("perpClient withdrawUnclaimedTokensInstruction error:: ", err_60);
7861
+ throw err_60;
8053
7862
  case 6: return [2, {
8054
7863
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8055
7864
  additionalSigners: additionalSigners
@@ -8058,7 +7867,7 @@ var PerpetualsClient = (function () {
8058
7867
  });
8059
7868
  }); };
8060
7869
  this.initRevenueTokenAccount = function (feeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8061
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_64;
7870
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_61;
8062
7871
  return __generator(this, function (_a) {
8063
7872
  switch (_a.label) {
8064
7873
  case 0:
@@ -8095,9 +7904,9 @@ var PerpetualsClient = (function () {
8095
7904
  instructions.push(initRevenueTokenAccountInstruction);
8096
7905
  return [3, 4];
8097
7906
  case 3:
8098
- err_64 = _a.sent();
8099
- console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_64);
8100
- throw err_64;
7907
+ err_61 = _a.sent();
7908
+ console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_61);
7909
+ throw err_61;
8101
7910
  case 4: return [2, {
8102
7911
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8103
7912
  additionalSigners: additionalSigners
@@ -8106,7 +7915,7 @@ var PerpetualsClient = (function () {
8106
7915
  });
8107
7916
  }); };
8108
7917
  this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8109
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_65;
7918
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_62;
8110
7919
  return __generator(this, function (_a) {
8111
7920
  switch (_a.label) {
8112
7921
  case 0:
@@ -8145,9 +7954,9 @@ var PerpetualsClient = (function () {
8145
7954
  instructions.push(distributeTokenRewardInstruction);
8146
7955
  return [3, 4];
8147
7956
  case 3:
8148
- err_65 = _a.sent();
8149
- console.log("perpClient distributeTokenRewardInstruction error:: ", err_65);
8150
- throw err_65;
7957
+ err_62 = _a.sent();
7958
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_62);
7959
+ throw err_62;
8151
7960
  case 4: return [2, {
8152
7961
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8153
7962
  additionalSigners: additionalSigners
@@ -8156,7 +7965,7 @@ var PerpetualsClient = (function () {
8156
7965
  });
8157
7966
  }); };
8158
7967
  this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
8159
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_66;
7968
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_63;
8160
7969
  return __generator(this, function (_a) {
8161
7970
  switch (_a.label) {
8162
7971
  case 0:
@@ -8184,9 +7993,9 @@ var PerpetualsClient = (function () {
8184
7993
  instructions.push(setTokenStakeLevelInstruction);
8185
7994
  return [3, 4];
8186
7995
  case 3:
8187
- err_66 = _a.sent();
8188
- console.log("perpClient setTokenStakeLevelInstruction error:: ", err_66);
8189
- throw err_66;
7996
+ err_63 = _a.sent();
7997
+ console.log("perpClient setTokenStakeLevelInstruction error:: ", err_63);
7998
+ throw err_63;
8190
7999
  case 4: return [2, {
8191
8000
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8192
8001
  additionalSigners: additionalSigners
@@ -8195,7 +8004,7 @@ var PerpetualsClient = (function () {
8195
8004
  });
8196
8005
  }); };
8197
8006
  this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8198
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_67;
8007
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_64;
8199
8008
  return __generator(this, function (_a) {
8200
8009
  switch (_a.label) {
8201
8010
  case 0:
@@ -8227,9 +8036,9 @@ var PerpetualsClient = (function () {
8227
8036
  instructions.push(setTokenRewardInstruction);
8228
8037
  return [3, 4];
8229
8038
  case 3:
8230
- err_67 = _a.sent();
8231
- console.log("perpClient setTokenRewardInstruction error:: ", err_67);
8232
- throw err_67;
8039
+ err_64 = _a.sent();
8040
+ console.log("perpClient setTokenRewardInstruction error:: ", err_64);
8041
+ throw err_64;
8233
8042
  case 4: return [2, {
8234
8043
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8235
8044
  additionalSigners: additionalSigners
@@ -8238,7 +8047,7 @@ var PerpetualsClient = (function () {
8238
8047
  });
8239
8048
  }); };
8240
8049
  this.resizeInternalOracle = function (extOracle, tokenMint, intOracleAccount) { return __awaiter(_this, void 0, void 0, function () {
8241
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_68;
8050
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_65;
8242
8051
  return __generator(this, function (_a) {
8243
8052
  switch (_a.label) {
8244
8053
  case 0:
@@ -8267,9 +8076,9 @@ var PerpetualsClient = (function () {
8267
8076
  instructions.push(resizeInternalOracleInstruction);
8268
8077
  return [3, 4];
8269
8078
  case 3:
8270
- err_68 = _a.sent();
8271
- console.log("perpClient resizeInternalOracleInstruction error:: ", err_68);
8272
- throw err_68;
8079
+ err_65 = _a.sent();
8080
+ console.log("perpClient resizeInternalOracleInstruction error:: ", err_65);
8081
+ throw err_65;
8273
8082
  case 4: return [2, {
8274
8083
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8275
8084
  additionalSigners: additionalSigners