flash-sdk 2.45.4 → 2.46.0-alpha.0

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.
@@ -4756,22 +4756,92 @@ var PerpetualsClient = (function () {
4756
4756
  }
4757
4757
  });
4758
4758
  }); };
4759
+ this.migrateUnclaimedReward = function (rewardSymbol, poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4760
+ var rewardCustodyMint, rewardCustodyConfig, pool, feeDistributionTokenAccount, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, migrateUnclaimedRewardInstruction, err_16;
4761
+ return __generator(this, function (_c) {
4762
+ switch (_c.label) {
4763
+ case 0:
4764
+ _c.trys.push([0, 2, , 3]);
4765
+ rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
4766
+ rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4767
+ pool = poolConfig.poolAddress;
4768
+ feeDistributionTokenAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("custody_token_account"), pool.toBuffer(), rewardCustodyMint.toBuffer()], this.programId)[0];
4769
+ custodyAccountMetas = [];
4770
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
4771
+ custody = _a[_i];
4772
+ custodyAccountMetas.push({
4773
+ pubkey: custody.custodyAccount,
4774
+ isSigner: false,
4775
+ isWritable: false,
4776
+ });
4777
+ }
4778
+ maxFlpStakeAccountPkLength = 32 - 4 + custodyAccountMetas.length;
4779
+ if (flpStakeAccountPks.length > maxFlpStakeAccountPkLength) {
4780
+ throw new Error("Max of ".concat(maxFlpStakeAccountPkLength, " flpStakeAccountPks can be updated at a time."));
4781
+ }
4782
+ flpStakeAccountMetas = [];
4783
+ for (_b = 0, flpStakeAccountPks_2 = flpStakeAccountPks; _b < flpStakeAccountPks_2.length; _b++) {
4784
+ flpStakeAccountPk = flpStakeAccountPks_2[_b];
4785
+ flpStakeAccountMetas.push({
4786
+ pubkey: flpStakeAccountPk,
4787
+ isSigner: false,
4788
+ isWritable: true,
4789
+ });
4790
+ }
4791
+ return [4, this.program.methods
4792
+ .migrateUnclaimedRewards({})
4793
+ .accounts({
4794
+ perpetuals: this.perpetuals.publicKey,
4795
+ pool: pool,
4796
+ rewardCustody: rewardCustodyConfig.custodyAccount,
4797
+ eventAuthority: this.eventAuthority.publicKey,
4798
+ program: this.program.programId,
4799
+ })
4800
+ .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), flpStakeAccountMetas, true))
4801
+ .instruction()];
4802
+ case 1:
4803
+ migrateUnclaimedRewardInstruction = _c.sent();
4804
+ return [2, migrateUnclaimedRewardInstruction];
4805
+ case 2:
4806
+ err_16 = _c.sent();
4807
+ console.log("perpClient migrateUnclaimedReward error:: ", err_16);
4808
+ throw err_16;
4809
+ case 3: return [2];
4810
+ }
4811
+ });
4812
+ }); };
4759
4813
  this.unstakeInstant = function (rewardSymbol, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4760
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, unstakeInstantInstruction, err_16;
4761
- return __generator(this, function (_a) {
4762
- switch (_a.label) {
4814
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, pool, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _a, unstakeInstantInstruction, err_17;
4815
+ return __generator(this, function (_b) {
4816
+ switch (_b.label) {
4763
4817
  case 0:
4764
4818
  publicKey = this.provider.wallet.publicKey;
4765
4819
  preInstructions = [];
4766
4820
  instructions = [];
4767
4821
  postInstructions = [];
4768
4822
  additionalSigners = [];
4769
- _a.label = 1;
4823
+ _b.label = 1;
4770
4824
  case 1:
4771
- _a.trys.push([1, 3, , 4]);
4825
+ _b.trys.push([1, 5, , 6]);
4772
4826
  rewardCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
4773
4827
  pool = poolConfig.poolAddress;
4774
4828
  flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), pool.toBuffer()], this.programId)[0];
4829
+ tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
4830
+ tokenStakeAccounts = [];
4831
+ _a = tokenStakeAccount;
4832
+ if (!_a) return [3, 3];
4833
+ return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
4834
+ case 2:
4835
+ _a = (_b.sent());
4836
+ _b.label = 3;
4837
+ case 3:
4838
+ if (_a) {
4839
+ tokenStakeAccounts.push({
4840
+ pubkey: tokenStakeAccount,
4841
+ isSigner: false,
4842
+ isWritable: false,
4843
+ });
4844
+ }
4775
4845
  return [4, this.program.methods
4776
4846
  .unstakeInstant({
4777
4847
  unstakeAmount: unstakeAmount
@@ -4785,16 +4855,17 @@ var PerpetualsClient = (function () {
4785
4855
  eventAuthority: this.eventAuthority.publicKey,
4786
4856
  program: this.program.programId,
4787
4857
  })
4858
+ .remainingAccounts(__spreadArray([], tokenStakeAccounts, true))
4788
4859
  .instruction()];
4789
- case 2:
4790
- unstakeInstantInstruction = _a.sent();
4860
+ case 4:
4861
+ unstakeInstantInstruction = _b.sent();
4791
4862
  instructions.push(unstakeInstantInstruction);
4792
- return [3, 4];
4793
- case 3:
4794
- err_16 = _a.sent();
4795
- console.log("perpClient unstakeInstant error:: ", err_16);
4796
- throw err_16;
4797
- case 4: return [2, {
4863
+ return [3, 6];
4864
+ case 5:
4865
+ err_17 = _b.sent();
4866
+ console.log("perpClient unstakeInstant error:: ", err_17);
4867
+ throw err_17;
4868
+ case 6: return [2, {
4798
4869
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4799
4870
  additionalSigners: additionalSigners
4800
4871
  }];
@@ -4802,7 +4873,7 @@ var PerpetualsClient = (function () {
4802
4873
  });
4803
4874
  }); };
4804
4875
  this.setFeeShareBps = function (poolConfig, flpStakeAccountPks) { return __awaiter(_this, void 0, void 0, function () {
4805
- var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_2, flpStakeAccountPk, refreshStakeInstruction, err_17;
4876
+ var publicKey, pool, custodyAccountMetas, _i, _a, custody, maxFlpStakeAccountPkLength, flpStakeAccountMetas, _b, flpStakeAccountPks_3, flpStakeAccountPk, refreshStakeInstruction, err_18;
4806
4877
  return __generator(this, function (_c) {
4807
4878
  switch (_c.label) {
4808
4879
  case 0:
@@ -4823,8 +4894,8 @@ var PerpetualsClient = (function () {
4823
4894
  throw new Error("Max of ".concat(maxFlpStakeAccountPkLength, " flpStakeAccountPks can be updated at a time."));
4824
4895
  }
4825
4896
  flpStakeAccountMetas = [];
4826
- for (_b = 0, flpStakeAccountPks_2 = flpStakeAccountPks; _b < flpStakeAccountPks_2.length; _b++) {
4827
- flpStakeAccountPk = flpStakeAccountPks_2[_b];
4897
+ for (_b = 0, flpStakeAccountPks_3 = flpStakeAccountPks; _b < flpStakeAccountPks_3.length; _b++) {
4898
+ flpStakeAccountPk = flpStakeAccountPks_3[_b];
4828
4899
  flpStakeAccountMetas.push({
4829
4900
  pubkey: flpStakeAccountPk,
4830
4901
  isSigner: false,
@@ -4846,15 +4917,15 @@ var PerpetualsClient = (function () {
4846
4917
  refreshStakeInstruction = _c.sent();
4847
4918
  return [2, refreshStakeInstruction];
4848
4919
  case 2:
4849
- err_17 = _c.sent();
4850
- console.log("perpClient refreshStaking error:: ", err_17);
4851
- throw err_17;
4920
+ err_18 = _c.sent();
4921
+ console.log("perpClient refreshStaking error:: ", err_18);
4922
+ throw err_18;
4852
4923
  case 3: return [2];
4853
4924
  }
4854
4925
  });
4855
4926
  }); };
4856
4927
  this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4857
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_18;
4928
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_19;
4858
4929
  return __generator(this, function (_a) {
4859
4930
  switch (_a.label) {
4860
4931
  case 0:
@@ -4888,9 +4959,9 @@ var PerpetualsClient = (function () {
4888
4959
  instructions.push(unstakeRequestInstruction);
4889
4960
  return [3, 4];
4890
4961
  case 3:
4891
- err_18 = _a.sent();
4892
- console.log("perpClient unstakeRequest error:: ", err_18);
4893
- throw err_18;
4962
+ err_19 = _a.sent();
4963
+ console.log("perpClient unstakeRequest error:: ", err_19);
4964
+ throw err_19;
4894
4965
  case 4: return [2, {
4895
4966
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4896
4967
  additionalSigners: additionalSigners
@@ -4903,7 +4974,7 @@ var PerpetualsClient = (function () {
4903
4974
  if (deactivated === void 0) { deactivated = true; }
4904
4975
  if (createUserLPTA === void 0) { createUserLPTA = true; }
4905
4976
  return __awaiter(_this, void 0, void 0, function () {
4906
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_19;
4977
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, pool, poolStakedLpVault, flpStakeAccount, userLpTokenAccount, _a, withdrawStakeInstruction, err_20;
4907
4978
  return __generator(this, function (_b) {
4908
4979
  switch (_b.label) {
4909
4980
  case 0:
@@ -4954,9 +5025,9 @@ var PerpetualsClient = (function () {
4954
5025
  instructions.push(withdrawStakeInstruction);
4955
5026
  return [3, 6];
4956
5027
  case 5:
4957
- err_19 = _b.sent();
4958
- console.log("perpClient withdrawStake error:: ", err_19);
4959
- throw err_19;
5028
+ err_20 = _b.sent();
5029
+ console.log("perpClient withdrawStake error:: ", err_20);
5030
+ throw err_20;
4960
5031
  case 6: return [2, {
4961
5032
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
4962
5033
  additionalSigners: additionalSigners
@@ -4968,7 +5039,7 @@ var PerpetualsClient = (function () {
4968
5039
  this.collectStakeFees = function (rewardSymbol, poolConfig, tokenStakeAccount, createUserATA) {
4969
5040
  if (createUserATA === void 0) { createUserATA = true; }
4970
5041
  return __awaiter(_this, void 0, void 0, function () {
4971
- var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_20;
5042
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tokenStakeAccounts, withdrawStakeInstruction, err_21;
4972
5043
  return __generator(this, function (_b) {
4973
5044
  switch (_b.label) {
4974
5045
  case 0:
@@ -5027,9 +5098,9 @@ var PerpetualsClient = (function () {
5027
5098
  instructions.push(withdrawStakeInstruction);
5028
5099
  return [3, 6];
5029
5100
  case 5:
5030
- err_20 = _b.sent();
5031
- console.log("perpClient withdrawStake error:: ", err_20);
5032
- throw err_20;
5101
+ err_21 = _b.sent();
5102
+ console.log("perpClient withdrawStake error:: ", err_21);
5103
+ throw err_21;
5033
5104
  case 6: return [2, {
5034
5105
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5035
5106
  additionalSigners: additionalSigners
@@ -5039,7 +5110,7 @@ var PerpetualsClient = (function () {
5039
5110
  });
5040
5111
  };
5041
5112
  this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5042
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_21;
5113
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_22;
5043
5114
  return __generator(this, function (_a) {
5044
5115
  switch (_a.label) {
5045
5116
  case 0:
@@ -5080,9 +5151,9 @@ var PerpetualsClient = (function () {
5080
5151
  instructions.push(initTokenVaultInstruction);
5081
5152
  return [3, 4];
5082
5153
  case 3:
5083
- err_21 = _a.sent();
5084
- console.log("perpClient InitTokenVaultInstruction error:: ", err_21);
5085
- throw err_21;
5154
+ err_22 = _a.sent();
5155
+ console.log("perpClient InitTokenVaultInstruction error:: ", err_22);
5156
+ throw err_22;
5086
5157
  case 4: return [2, {
5087
5158
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5088
5159
  additionalSigners: additionalSigners
@@ -5091,7 +5162,7 @@ var PerpetualsClient = (function () {
5091
5162
  });
5092
5163
  }); };
5093
5164
  this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5094
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_22;
5165
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_23;
5095
5166
  return __generator(this, function (_a) {
5096
5167
  switch (_a.label) {
5097
5168
  case 0:
@@ -5121,9 +5192,9 @@ var PerpetualsClient = (function () {
5121
5192
  instructions.push(setTokenVaultConfigInstruction);
5122
5193
  return [3, 4];
5123
5194
  case 3:
5124
- err_22 = _a.sent();
5125
- console.log("perpClient setTokenVaultConfigInstruction error:: ", err_22);
5126
- throw err_22;
5195
+ err_23 = _a.sent();
5196
+ console.log("perpClient setTokenVaultConfigInstruction error:: ", err_23);
5197
+ throw err_23;
5127
5198
  case 4: return [2, {
5128
5199
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5129
5200
  additionalSigners: additionalSigners
@@ -5132,7 +5203,7 @@ var PerpetualsClient = (function () {
5132
5203
  });
5133
5204
  }); };
5134
5205
  this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5135
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_23;
5206
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_24;
5136
5207
  return __generator(this, function (_a) {
5137
5208
  switch (_a.label) {
5138
5209
  case 0:
@@ -5170,9 +5241,9 @@ var PerpetualsClient = (function () {
5170
5241
  instructions.push(withdrawInstantFeeInstruction);
5171
5242
  return [3, 6];
5172
5243
  case 5:
5173
- err_23 = _a.sent();
5174
- console.log("perpClient withdrawInstantFeeInstruction error:: ", err_23);
5175
- throw err_23;
5244
+ err_24 = _a.sent();
5245
+ console.log("perpClient withdrawInstantFeeInstruction error:: ", err_24);
5246
+ throw err_24;
5176
5247
  case 6: return [2, {
5177
5248
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5178
5249
  additionalSigners: additionalSigners
@@ -5181,7 +5252,7 @@ var PerpetualsClient = (function () {
5181
5252
  });
5182
5253
  }); };
5183
5254
  this.burnAndClaim = function (owner, nftMint, poolConfig, createAta) { return __awaiter(_this, void 0, void 0, function () {
5184
- var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_24;
5255
+ var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_25;
5185
5256
  return __generator(this, function (_b) {
5186
5257
  switch (_b.label) {
5187
5258
  case 0:
@@ -5245,9 +5316,9 @@ var PerpetualsClient = (function () {
5245
5316
  instructions.push(burnAndClaimInstruction);
5246
5317
  return [3, 8];
5247
5318
  case 7:
5248
- err_24 = _b.sent();
5249
- console.log("perpClient burnAndClaimInstruction error:: ", err_24);
5250
- throw err_24;
5319
+ err_25 = _b.sent();
5320
+ console.log("perpClient burnAndClaimInstruction error:: ", err_25);
5321
+ throw err_25;
5251
5322
  case 8: return [2, {
5252
5323
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5253
5324
  additionalSigners: additionalSigners
@@ -5256,7 +5327,7 @@ var PerpetualsClient = (function () {
5256
5327
  });
5257
5328
  }); };
5258
5329
  this.burnAndStake = function (owner, feePayer, nftMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5259
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_25;
5330
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_26;
5260
5331
  return __generator(this, function (_a) {
5261
5332
  switch (_a.label) {
5262
5333
  case 0:
@@ -5307,9 +5378,9 @@ var PerpetualsClient = (function () {
5307
5378
  instructions.push(burnAndStakeInstruction);
5308
5379
  return [3, 4];
5309
5380
  case 3:
5310
- err_25 = _a.sent();
5311
- console.log("perpClient burnAndStakeInstruction error:: ", err_25);
5312
- throw err_25;
5381
+ err_26 = _a.sent();
5382
+ console.log("perpClient burnAndStakeInstruction error:: ", err_26);
5383
+ throw err_26;
5313
5384
  case 4: return [2, {
5314
5385
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5315
5386
  additionalSigners: additionalSigners
@@ -5318,7 +5389,7 @@ var PerpetualsClient = (function () {
5318
5389
  });
5319
5390
  }); };
5320
5391
  this.depositTokenStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5321
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_26;
5392
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_27;
5322
5393
  return __generator(this, function (_a) {
5323
5394
  switch (_a.label) {
5324
5395
  case 0:
@@ -5359,9 +5430,9 @@ var PerpetualsClient = (function () {
5359
5430
  instructions.push(depositTokenStakeInstruction);
5360
5431
  return [3, 5];
5361
5432
  case 4:
5362
- err_26 = _a.sent();
5363
- console.log("perpClient depositStakingInstruction error:: ", err_26);
5364
- throw err_26;
5433
+ err_27 = _a.sent();
5434
+ console.log("perpClient depositStakingInstruction error:: ", err_27);
5435
+ throw err_27;
5365
5436
  case 5: return [2, {
5366
5437
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5367
5438
  additionalSigners: additionalSigners
@@ -5370,7 +5441,7 @@ var PerpetualsClient = (function () {
5370
5441
  });
5371
5442
  }); };
5372
5443
  this.unstakeTokenRequest = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5373
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_27;
5444
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_28;
5374
5445
  return __generator(this, function (_a) {
5375
5446
  switch (_a.label) {
5376
5447
  case 0:
@@ -5399,9 +5470,9 @@ var PerpetualsClient = (function () {
5399
5470
  instructions.push(unstakeTokenRequestInstruction);
5400
5471
  return [3, 4];
5401
5472
  case 3:
5402
- err_27 = _a.sent();
5403
- console.log("perpClient unstakeTokenRequestInstruction error:: ", err_27);
5404
- throw err_27;
5473
+ err_28 = _a.sent();
5474
+ console.log("perpClient unstakeTokenRequestInstruction error:: ", err_28);
5475
+ throw err_28;
5405
5476
  case 4: return [2, {
5406
5477
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5407
5478
  additionalSigners: additionalSigners
@@ -5410,7 +5481,7 @@ var PerpetualsClient = (function () {
5410
5481
  });
5411
5482
  }); };
5412
5483
  this.unstakeTokenInstant = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5413
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_28;
5484
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_29;
5414
5485
  return __generator(this, function (_a) {
5415
5486
  switch (_a.label) {
5416
5487
  case 0:
@@ -5450,9 +5521,9 @@ var PerpetualsClient = (function () {
5450
5521
  instructions.push(unstakeTokenInstantInstruction);
5451
5522
  return [3, 5];
5452
5523
  case 4:
5453
- err_28 = _a.sent();
5454
- console.log("perpClient unstakeTokenInstantInstruction error:: ", err_28);
5455
- throw err_28;
5524
+ err_29 = _a.sent();
5525
+ console.log("perpClient unstakeTokenInstantInstruction error:: ", err_29);
5526
+ throw err_29;
5456
5527
  case 5: return [2, {
5457
5528
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5458
5529
  additionalSigners: additionalSigners
@@ -5461,7 +5532,7 @@ var PerpetualsClient = (function () {
5461
5532
  });
5462
5533
  }); };
5463
5534
  this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5464
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_29;
5535
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_30;
5465
5536
  return __generator(this, function (_a) {
5466
5537
  switch (_a.label) {
5467
5538
  case 0:
@@ -5501,9 +5572,9 @@ var PerpetualsClient = (function () {
5501
5572
  instructions.push(withdrawTokenInstruction);
5502
5573
  return [3, 5];
5503
5574
  case 4:
5504
- err_29 = _a.sent();
5505
- console.log("perpClient withdrawTokenInstruction error:: ", err_29);
5506
- throw err_29;
5575
+ err_30 = _a.sent();
5576
+ console.log("perpClient withdrawTokenInstruction error:: ", err_30);
5577
+ throw err_30;
5507
5578
  case 5: return [2, {
5508
5579
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5509
5580
  additionalSigners: additionalSigners
@@ -5512,7 +5583,7 @@ var PerpetualsClient = (function () {
5512
5583
  });
5513
5584
  }); };
5514
5585
  this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5515
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_30;
5586
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_31;
5516
5587
  return __generator(this, function (_a) {
5517
5588
  switch (_a.label) {
5518
5589
  case 0:
@@ -5541,9 +5612,9 @@ var PerpetualsClient = (function () {
5541
5612
  instructions.push(cancelUnstakeRequestInstruction);
5542
5613
  return [3, 4];
5543
5614
  case 3:
5544
- err_30 = _a.sent();
5545
- console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_30);
5546
- throw err_30;
5615
+ err_31 = _a.sent();
5616
+ console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_31);
5617
+ throw err_31;
5547
5618
  case 4: return [2, {
5548
5619
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5549
5620
  additionalSigners: additionalSigners
@@ -5552,7 +5623,7 @@ var PerpetualsClient = (function () {
5552
5623
  });
5553
5624
  }); };
5554
5625
  this.distributeTokenReward = function (amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5555
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, fundingTokenAccount, distributeTokenRewardInstruction, err_31;
5626
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, fundingTokenAccount, distributeTokenRewardInstruction, err_32;
5556
5627
  return __generator(this, function (_a) {
5557
5628
  switch (_a.label) {
5558
5629
  case 0:
@@ -5588,9 +5659,9 @@ var PerpetualsClient = (function () {
5588
5659
  instructions.push(distributeTokenRewardInstruction);
5589
5660
  return [3, 4];
5590
5661
  case 3:
5591
- err_31 = _a.sent();
5592
- console.log("perpClient distributeTokenRewardInstruction error:: ", err_31);
5593
- throw err_31;
5662
+ err_32 = _a.sent();
5663
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_32);
5664
+ throw err_32;
5594
5665
  case 4: return [2, {
5595
5666
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5596
5667
  additionalSigners: additionalSigners
@@ -5599,7 +5670,7 @@ var PerpetualsClient = (function () {
5599
5670
  });
5600
5671
  }); };
5601
5672
  this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5602
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_32;
5673
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_33;
5603
5674
  return __generator(this, function (_a) {
5604
5675
  switch (_a.label) {
5605
5676
  case 0:
@@ -5631,9 +5702,9 @@ var PerpetualsClient = (function () {
5631
5702
  instructions.push(setTokenRewardInstruction);
5632
5703
  return [3, 4];
5633
5704
  case 3:
5634
- err_32 = _a.sent();
5635
- console.log("perpClient setTokenRewardInstruction error:: ", err_32);
5636
- throw err_32;
5705
+ err_33 = _a.sent();
5706
+ console.log("perpClient setTokenRewardInstruction error:: ", err_33);
5707
+ throw err_33;
5637
5708
  case 4: return [2, {
5638
5709
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5639
5710
  additionalSigners: additionalSigners
@@ -5644,7 +5715,7 @@ var PerpetualsClient = (function () {
5644
5715
  this.collectTokenReward = function (owner, poolConfig, createUserATA) {
5645
5716
  if (createUserATA === void 0) { createUserATA = true; }
5646
5717
  return __awaiter(_this, void 0, void 0, function () {
5647
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_33;
5718
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_34;
5648
5719
  return __generator(this, function (_b) {
5649
5720
  switch (_b.label) {
5650
5721
  case 0:
@@ -5688,9 +5759,9 @@ var PerpetualsClient = (function () {
5688
5759
  instructions.push(collectTokenRewardInstruction);
5689
5760
  return [3, 6];
5690
5761
  case 5:
5691
- err_33 = _b.sent();
5692
- console.log("perpClient collectTokenRewardInstruction error:: ", err_33);
5693
- throw err_33;
5762
+ err_34 = _b.sent();
5763
+ console.log("perpClient collectTokenRewardInstruction error:: ", err_34);
5764
+ throw err_34;
5694
5765
  case 6: return [2, {
5695
5766
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5696
5767
  additionalSigners: additionalSigners
@@ -5700,7 +5771,7 @@ var PerpetualsClient = (function () {
5700
5771
  });
5701
5772
  };
5702
5773
  this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5703
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_34;
5774
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_35;
5704
5775
  return __generator(this, function (_a) {
5705
5776
  switch (_a.label) {
5706
5777
  case 0:
@@ -5737,9 +5808,9 @@ var PerpetualsClient = (function () {
5737
5808
  instructions.push(initRewardVault);
5738
5809
  return [3, 4];
5739
5810
  case 3:
5740
- err_34 = _a.sent();
5741
- console.log("perpClient InitRewardVault error:: ", err_34);
5742
- throw err_34;
5811
+ err_35 = _a.sent();
5812
+ console.log("perpClient InitRewardVault error:: ", err_35);
5813
+ throw err_35;
5743
5814
  case 4: return [2, {
5744
5815
  instructions: __spreadArray([], instructions, true),
5745
5816
  additionalSigners: additionalSigners
@@ -5748,7 +5819,7 @@ var PerpetualsClient = (function () {
5748
5819
  });
5749
5820
  }); };
5750
5821
  this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5751
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_35;
5822
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_36;
5752
5823
  return __generator(this, function (_a) {
5753
5824
  switch (_a.label) {
5754
5825
  case 0:
@@ -5779,9 +5850,9 @@ var PerpetualsClient = (function () {
5779
5850
  instructions.push(distributeReward);
5780
5851
  return [3, 4];
5781
5852
  case 3:
5782
- err_35 = _a.sent();
5783
- console.log("perpClient distributeReward error:: ", err_35);
5784
- throw err_35;
5853
+ err_36 = _a.sent();
5854
+ console.log("perpClient distributeReward error:: ", err_36);
5855
+ throw err_36;
5785
5856
  case 4: return [2, {
5786
5857
  instructions: __spreadArray([], instructions, true),
5787
5858
  additionalSigners: additionalSigners
@@ -5792,7 +5863,7 @@ var PerpetualsClient = (function () {
5792
5863
  this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5793
5864
  if (createUserATA === void 0) { createUserATA = true; }
5794
5865
  return __awaiter(_this, void 0, void 0, function () {
5795
- var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_36;
5866
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_37;
5796
5867
  return __generator(this, function (_b) {
5797
5868
  switch (_b.label) {
5798
5869
  case 0:
@@ -5842,8 +5913,8 @@ var PerpetualsClient = (function () {
5842
5913
  instructions.push(collectNftReward);
5843
5914
  return [3, 6];
5844
5915
  case 5:
5845
- err_36 = _b.sent();
5846
- throw err_36;
5916
+ err_37 = _b.sent();
5917
+ throw err_37;
5847
5918
  case 6: return [2, {
5848
5919
  instructions: __spreadArray([], instructions, true),
5849
5920
  additionalSigners: additionalSigners
@@ -5855,7 +5926,7 @@ var PerpetualsClient = (function () {
5855
5926
  this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
5856
5927
  if (createUserATA === void 0) { createUserATA = true; }
5857
5928
  return __awaiter(_this, void 0, void 0, function () {
5858
- var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_37;
5929
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_38;
5859
5930
  return __generator(this, function (_b) {
5860
5931
  switch (_b.label) {
5861
5932
  case 0:
@@ -5919,9 +5990,9 @@ var PerpetualsClient = (function () {
5919
5990
  instructions.push(withdrawStakeInstruction);
5920
5991
  return [3, 6];
5921
5992
  case 5:
5922
- err_37 = _b.sent();
5923
- console.log("perpClient withdrawStake error:: ", err_37);
5924
- throw err_37;
5993
+ err_38 = _b.sent();
5994
+ console.log("perpClient withdrawStake error:: ", err_38);
5995
+ throw err_38;
5925
5996
  case 6: return [2, {
5926
5997
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5927
5998
  additionalSigners: additionalSigners
@@ -5931,7 +6002,7 @@ var PerpetualsClient = (function () {
5931
6002
  });
5932
6003
  };
5933
6004
  this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5934
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_38;
6005
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_39;
5935
6006
  return __generator(this, function (_a) {
5936
6007
  switch (_a.label) {
5937
6008
  case 0:
@@ -5970,9 +6041,9 @@ var PerpetualsClient = (function () {
5970
6041
  instructions.push(setTriggerPrice);
5971
6042
  return [3, 4];
5972
6043
  case 3:
5973
- err_38 = _a.sent();
5974
- console.log("perpClient setTriggerPrice error:: ", err_38);
5975
- throw err_38;
6044
+ err_39 = _a.sent();
6045
+ console.log("perpClient setTriggerPrice error:: ", err_39);
6046
+ throw err_39;
5976
6047
  case 4: return [2, {
5977
6048
  instructions: __spreadArray([], instructions, true),
5978
6049
  additionalSigners: additionalSigners
@@ -5985,7 +6056,7 @@ var PerpetualsClient = (function () {
5985
6056
  if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
5986
6057
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5987
6058
  return __awaiter(_this, void 0, void 0, function () {
5988
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_39;
6059
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_40;
5989
6060
  return __generator(this, function (_b) {
5990
6061
  switch (_b.label) {
5991
6062
  case 0:
@@ -6046,9 +6117,9 @@ var PerpetualsClient = (function () {
6046
6117
  }
6047
6118
  return [3, 7];
6048
6119
  case 6:
6049
- err_39 = _b.sent();
6050
- console.log("perpClient forceClosePosition error:: ", err_39);
6051
- throw err_39;
6120
+ err_40 = _b.sent();
6121
+ console.log("perpClient forceClosePosition error:: ", err_40);
6122
+ throw err_40;
6052
6123
  case 7: return [2, {
6053
6124
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6054
6125
  additionalSigners: additionalSigners
@@ -6061,7 +6132,7 @@ var PerpetualsClient = (function () {
6061
6132
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6062
6133
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6063
6134
  return __awaiter(_this, void 0, void 0, function () {
6064
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_40;
6135
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_41;
6065
6136
  return __generator(this, function (_c) {
6066
6137
  switch (_c.label) {
6067
6138
  case 0:
@@ -6166,9 +6237,9 @@ var PerpetualsClient = (function () {
6166
6237
  instructions.push(placeLimitOrder);
6167
6238
  return [3, 11];
6168
6239
  case 10:
6169
- err_40 = _c.sent();
6170
- console.log("perpClient placeLimitOrder error:: ", err_40);
6171
- throw err_40;
6240
+ err_41 = _c.sent();
6241
+ console.log("perpClient placeLimitOrder error:: ", err_41);
6242
+ throw err_41;
6172
6243
  case 11: return [2, {
6173
6244
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6174
6245
  additionalSigners: additionalSigners
@@ -6181,7 +6252,7 @@ var PerpetualsClient = (function () {
6181
6252
  if (createUserATA === void 0) { createUserATA = true; }
6182
6253
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6183
6254
  return __awaiter(_this, void 0, void 0, function () {
6184
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_41;
6255
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_42;
6185
6256
  return __generator(this, function (_b) {
6186
6257
  switch (_b.label) {
6187
6258
  case 0:
@@ -6269,9 +6340,9 @@ var PerpetualsClient = (function () {
6269
6340
  instructions.push(editLimitOrder);
6270
6341
  return [3, 8];
6271
6342
  case 7:
6272
- err_41 = _b.sent();
6273
- console.log("perpClient editLimitOrder error:: ", err_41);
6274
- throw err_41;
6343
+ err_42 = _b.sent();
6344
+ console.log("perpClient editLimitOrder error:: ", err_42);
6345
+ throw err_42;
6275
6346
  case 8: return [2, {
6276
6347
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6277
6348
  additionalSigners: additionalSigners
@@ -6285,7 +6356,7 @@ var PerpetualsClient = (function () {
6285
6356
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6286
6357
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6287
6358
  return __awaiter(_this, void 0, void 0, function () {
6288
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_42;
6359
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_43;
6289
6360
  return __generator(this, function (_a) {
6290
6361
  switch (_a.label) {
6291
6362
  case 0:
@@ -6334,9 +6405,9 @@ var PerpetualsClient = (function () {
6334
6405
  instructions.push(executeLimitOrder);
6335
6406
  return [3, 4];
6336
6407
  case 3:
6337
- err_42 = _a.sent();
6338
- console.log("perpClient executeLimitOrder error:: ", err_42);
6339
- throw err_42;
6408
+ err_43 = _a.sent();
6409
+ console.log("perpClient executeLimitOrder error:: ", err_43);
6410
+ throw err_43;
6340
6411
  case 4: return [2, {
6341
6412
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6342
6413
  additionalSigners: additionalSigners
@@ -6350,7 +6421,7 @@ var PerpetualsClient = (function () {
6350
6421
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6351
6422
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6352
6423
  return __awaiter(_this, void 0, void 0, function () {
6353
- var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_43;
6424
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_44;
6354
6425
  return __generator(this, function (_a) {
6355
6426
  switch (_a.label) {
6356
6427
  case 0:
@@ -6402,9 +6473,9 @@ var PerpetualsClient = (function () {
6402
6473
  instructions.push(executeLimitWithSwap);
6403
6474
  return [3, 4];
6404
6475
  case 3:
6405
- err_43 = _a.sent();
6406
- console.log("perpClient executeLimitWithSwap error:: ", err_43);
6407
- throw err_43;
6476
+ err_44 = _a.sent();
6477
+ console.log("perpClient executeLimitWithSwap error:: ", err_44);
6478
+ throw err_44;
6408
6479
  case 4: return [2, {
6409
6480
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6410
6481
  additionalSigners: additionalSigners
@@ -6414,7 +6485,7 @@ var PerpetualsClient = (function () {
6414
6485
  });
6415
6486
  };
6416
6487
  this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6417
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_44;
6488
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_45;
6418
6489
  return __generator(this, function (_a) {
6419
6490
  switch (_a.label) {
6420
6491
  case 0:
@@ -6462,9 +6533,9 @@ var PerpetualsClient = (function () {
6462
6533
  instructions.push(placeTriggerOrder);
6463
6534
  return [3, 4];
6464
6535
  case 3:
6465
- err_44 = _a.sent();
6466
- console.log("perpClient placeTriggerOrder error:: ", err_44);
6467
- throw err_44;
6536
+ err_45 = _a.sent();
6537
+ console.log("perpClient placeTriggerOrder error:: ", err_45);
6538
+ throw err_45;
6468
6539
  case 4: return [2, {
6469
6540
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6470
6541
  additionalSigners: additionalSigners
@@ -6473,7 +6544,7 @@ var PerpetualsClient = (function () {
6473
6544
  });
6474
6545
  }); };
6475
6546
  this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6476
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_45;
6547
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_46;
6477
6548
  return __generator(this, function (_a) {
6478
6549
  switch (_a.label) {
6479
6550
  case 0:
@@ -6520,9 +6591,9 @@ var PerpetualsClient = (function () {
6520
6591
  instructions.push(editTriggerOrder);
6521
6592
  return [3, 4];
6522
6593
  case 3:
6523
- err_45 = _a.sent();
6524
- console.log("perpClient editTriggerOrder error:: ", err_45);
6525
- throw err_45;
6594
+ err_46 = _a.sent();
6595
+ console.log("perpClient editTriggerOrder error:: ", err_46);
6596
+ throw err_46;
6526
6597
  case 4: return [2, {
6527
6598
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6528
6599
  additionalSigners: additionalSigners
@@ -6531,7 +6602,7 @@ var PerpetualsClient = (function () {
6531
6602
  });
6532
6603
  }); };
6533
6604
  this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6534
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_46;
6605
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_47;
6535
6606
  return __generator(this, function (_a) {
6536
6607
  switch (_a.label) {
6537
6608
  case 0:
@@ -6564,9 +6635,51 @@ var PerpetualsClient = (function () {
6564
6635
  instructions.push(cancelTriggerOrder);
6565
6636
  return [3, 4];
6566
6637
  case 3:
6567
- err_46 = _a.sent();
6568
- console.log("perpClient cancelTriggerOrder error:: ", err_46);
6569
- throw err_46;
6638
+ err_47 = _a.sent();
6639
+ console.log("perpClient cancelTriggerOrder error:: ", err_47);
6640
+ throw err_47;
6641
+ case 4: return [2, {
6642
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6643
+ additionalSigners: additionalSigners
6644
+ }];
6645
+ }
6646
+ });
6647
+ }); };
6648
+ this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6649
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_48;
6650
+ return __generator(this, function (_a) {
6651
+ switch (_a.label) {
6652
+ case 0:
6653
+ publicKey = this.provider.wallet.publicKey;
6654
+ targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
6655
+ collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
6656
+ marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
6657
+ preInstructions = [];
6658
+ instructions = [];
6659
+ postInstructions = [];
6660
+ additionalSigners = [];
6661
+ _a.label = 1;
6662
+ case 1:
6663
+ _a.trys.push([1, 3, , 4]);
6664
+ orderAccount = poolConfig.getOrderFromMarketPk(publicKey, marketAccount);
6665
+ positionAccount = poolConfig.getPositionFromMarketPk(publicKey, marketAccount);
6666
+ return [4, this.program.methods
6667
+ .cancelAllTriggerOrders()
6668
+ .accounts({
6669
+ position: positionAccount,
6670
+ order: orderAccount,
6671
+ eventAuthority: this.eventAuthority.publicKey,
6672
+ program: this.programId,
6673
+ })
6674
+ .instruction()];
6675
+ case 2:
6676
+ cancelAllTriggerOrders = _a.sent();
6677
+ instructions.push(cancelAllTriggerOrders);
6678
+ return [3, 4];
6679
+ case 3:
6680
+ err_48 = _a.sent();
6681
+ console.log("perpClient cancelAllTriggerOrders error:: ", err_48);
6682
+ throw err_48;
6570
6683
  case 4: return [2, {
6571
6684
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6572
6685
  additionalSigners: additionalSigners
@@ -6581,7 +6694,7 @@ var PerpetualsClient = (function () {
6581
6694
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6582
6695
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6583
6696
  return __awaiter(_this, void 0, void 0, function () {
6584
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_47;
6697
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_49;
6585
6698
  return __generator(this, function (_d) {
6586
6699
  switch (_d.label) {
6587
6700
  case 0:
@@ -6678,9 +6791,9 @@ var PerpetualsClient = (function () {
6678
6791
  instructions.push(executeTriggerWithSwap);
6679
6792
  return [3, 10];
6680
6793
  case 9:
6681
- err_47 = _d.sent();
6682
- console.log("perpClient executeTriggerWithSwap error:: ", err_47);
6683
- throw err_47;
6794
+ err_49 = _d.sent();
6795
+ console.log("perpClient executeTriggerWithSwap error:: ", err_49);
6796
+ throw err_49;
6684
6797
  case 10: return [2, {
6685
6798
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6686
6799
  additionalSigners: additionalSigners
@@ -6696,7 +6809,7 @@ var PerpetualsClient = (function () {
6696
6809
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6697
6810
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6698
6811
  return __awaiter(_this, void 0, void 0, function () {
6699
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_48;
6812
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_50;
6700
6813
  return __generator(this, function (_b) {
6701
6814
  switch (_b.label) {
6702
6815
  case 0:
@@ -6762,9 +6875,9 @@ var PerpetualsClient = (function () {
6762
6875
  instructions.push(executeTriggerOrder);
6763
6876
  return [3, 8];
6764
6877
  case 7:
6765
- err_48 = _b.sent();
6766
- console.log("perpClient executeTriggerOrder error:: ", err_48);
6767
- throw err_48;
6878
+ err_50 = _b.sent();
6879
+ console.log("perpClient executeTriggerOrder error:: ", err_50);
6880
+ throw err_50;
6768
6881
  case 8: return [2, {
6769
6882
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6770
6883
  additionalSigners: additionalSigners
@@ -6774,7 +6887,7 @@ var PerpetualsClient = (function () {
6774
6887
  });
6775
6888
  };
6776
6889
  this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6777
- var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_49;
6890
+ var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_51;
6778
6891
  return __generator(this, function (_a) {
6779
6892
  switch (_a.label) {
6780
6893
  case 0:
@@ -6804,9 +6917,9 @@ var PerpetualsClient = (function () {
6804
6917
  instructions.push(migrateTriggerOrder);
6805
6918
  return [3, 4];
6806
6919
  case 3:
6807
- err_49 = _a.sent();
6808
- console.log("perpClient migrateTriggerOrder error:: ", err_49);
6809
- throw err_49;
6920
+ err_51 = _a.sent();
6921
+ console.log("perpClient migrateTriggerOrder error:: ", err_51);
6922
+ throw err_51;
6810
6923
  case 4: return [2, {
6811
6924
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6812
6925
  additionalSigners: additionalSigners
@@ -6815,7 +6928,7 @@ var PerpetualsClient = (function () {
6815
6928
  });
6816
6929
  }); };
6817
6930
  this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6818
- var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_50;
6931
+ var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_52;
6819
6932
  return __generator(this, function (_a) {
6820
6933
  switch (_a.label) {
6821
6934
  case 0:
@@ -6844,15 +6957,15 @@ var PerpetualsClient = (function () {
6844
6957
  console.log(getPositionData);
6845
6958
  return [2, getPositionData];
6846
6959
  case 3:
6847
- err_50 = _a.sent();
6848
- console.log("perpClient setPool error:: ", err_50);
6849
- throw err_50;
6960
+ err_52 = _a.sent();
6961
+ console.log("perpClient setPool error:: ", err_52);
6962
+ throw err_52;
6850
6963
  case 4: return [2];
6851
6964
  }
6852
6965
  });
6853
6966
  }); };
6854
6967
  this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6855
- var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_51;
6968
+ var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_53;
6856
6969
  return __generator(this, function (_a) {
6857
6970
  switch (_a.label) {
6858
6971
  case 0:
@@ -6885,9 +6998,9 @@ var PerpetualsClient = (function () {
6885
6998
  instructions.push(withdrawFeesIx);
6886
6999
  return [3, 5];
6887
7000
  case 4:
6888
- err_51 = _a.sent();
6889
- console.log("perpClient setPool error:: ", err_51);
6890
- throw err_51;
7001
+ err_53 = _a.sent();
7002
+ console.log("perpClient setPool error:: ", err_53);
7003
+ throw err_53;
6891
7004
  case 5: return [2, {
6892
7005
  instructions: __spreadArray([], instructions, true),
6893
7006
  additionalSigners: additionalSigners
@@ -6896,7 +7009,7 @@ var PerpetualsClient = (function () {
6896
7009
  });
6897
7010
  }); };
6898
7011
  this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
6899
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_52;
7012
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_54;
6900
7013
  return __generator(this, function (_a) {
6901
7014
  switch (_a.label) {
6902
7015
  case 0:
@@ -6923,9 +7036,9 @@ var PerpetualsClient = (function () {
6923
7036
  instructions.push(setPermissionsInstruction);
6924
7037
  return [3, 4];
6925
7038
  case 3:
6926
- err_52 = _a.sent();
6927
- console.log("perpClient setPool error:: ", err_52);
6928
- throw err_52;
7039
+ err_54 = _a.sent();
7040
+ console.log("perpClient setPool error:: ", err_54);
7041
+ throw err_54;
6929
7042
  case 4: return [2, {
6930
7043
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6931
7044
  additionalSigners: additionalSigners
@@ -6934,7 +7047,7 @@ var PerpetualsClient = (function () {
6934
7047
  });
6935
7048
  }); };
6936
7049
  this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6937
- var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_53;
7050
+ var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_55;
6938
7051
  var _f;
6939
7052
  return __generator(this, function (_g) {
6940
7053
  switch (_g.label) {
@@ -6994,9 +7107,9 @@ var PerpetualsClient = (function () {
6994
7107
  instructions.push(reimburse);
6995
7108
  return [3, 5];
6996
7109
  case 4:
6997
- err_53 = _g.sent();
6998
- console.log("perpClient setPool error:: ", err_53);
6999
- throw err_53;
7110
+ err_55 = _g.sent();
7111
+ console.log("perpClient setPool error:: ", err_55);
7112
+ throw err_55;
7000
7113
  case 5: return [2, {
7001
7114
  instructions: __spreadArray([], instructions, true),
7002
7115
  additionalSigners: additionalSigners
@@ -7005,7 +7118,7 @@ var PerpetualsClient = (function () {
7005
7118
  });
7006
7119
  }); };
7007
7120
  this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7008
- var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_54;
7121
+ var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_56;
7009
7122
  return __generator(this, function (_a) {
7010
7123
  switch (_a.label) {
7011
7124
  case 0:
@@ -7038,9 +7151,9 @@ var PerpetualsClient = (function () {
7038
7151
  instructions.push(setInternalOraclePrice);
7039
7152
  return [3, 4];
7040
7153
  case 3:
7041
- err_54 = _a.sent();
7042
- console.log("perpClient setInternalOracleAccount error:: ", err_54);
7043
- throw err_54;
7154
+ err_56 = _a.sent();
7155
+ console.log("perpClient setInternalOracleAccount error:: ", err_56);
7156
+ throw err_56;
7044
7157
  case 4: return [2, {
7045
7158
  instructions: __spreadArray([], instructions, true),
7046
7159
  additionalSigners: additionalSigners
@@ -7052,7 +7165,7 @@ var PerpetualsClient = (function () {
7052
7165
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
7053
7166
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7054
7167
  return __awaiter(_this, void 0, void 0, function () {
7055
- var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, unWrappedSolBalance, _d, addCompoundingLiquidity, err_55;
7168
+ var publicKey, preInstructions, instructions, additionalSigners, postInstructions, rewardCustody, inCustodyConfig, lpTokenMint, compoundingTokenMint, wrappedSolAccount, lpTokenAccount, compoundingTokenAccount, fundingAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, lamports, unWrappedSolBalance, _d, addCompoundingLiquidity, err_57;
7056
7169
  return __generator(this, function (_e) {
7057
7170
  switch (_e.label) {
7058
7171
  case 0:
@@ -7175,8 +7288,8 @@ var PerpetualsClient = (function () {
7175
7288
  instructions.push(addCompoundingLiquidity);
7176
7289
  return [3, 10];
7177
7290
  case 9:
7178
- err_55 = _e.sent();
7179
- console.log("perpClient addCompoundingLiquidity error:: ", err_55);
7291
+ err_57 = _e.sent();
7292
+ console.log("perpClient addCompoundingLiquidity error:: ", err_57);
7180
7293
  return [3, 10];
7181
7294
  case 10: return [2, {
7182
7295
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7190,7 +7303,7 @@ var PerpetualsClient = (function () {
7190
7303
  if (createUserATA === void 0) { createUserATA = true; }
7191
7304
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7192
7305
  return __awaiter(_this, void 0, void 0, function () {
7193
- var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, compoundingTokenAccount, removeCompoundingLiquidity, err_56;
7306
+ var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, outCustodyConfig, lpTokenMint, compoundingTokenMint, lamports, _a, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, compoundingTokenAccount, removeCompoundingLiquidity, err_58;
7194
7307
  return __generator(this, function (_e) {
7195
7308
  switch (_e.label) {
7196
7309
  case 0:
@@ -7297,8 +7410,8 @@ var PerpetualsClient = (function () {
7297
7410
  instructions.push(removeCompoundingLiquidity);
7298
7411
  return [3, 8];
7299
7412
  case 7:
7300
- err_56 = _e.sent();
7301
- console.log("perpClient removeCompoundingLiquidity error:: ", err_56);
7413
+ err_58 = _e.sent();
7414
+ console.log("perpClient removeCompoundingLiquidity error:: ", err_58);
7302
7415
  return [3, 8];
7303
7416
  case 8: return [2, {
7304
7417
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7311,9 +7424,9 @@ var PerpetualsClient = (function () {
7311
7424
  this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
7312
7425
  if (createUserATA === void 0) { createUserATA = true; }
7313
7426
  return __awaiter(_this, void 0, void 0, function () {
7314
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, migrateStake, err_57;
7315
- return __generator(this, function (_e) {
7316
- switch (_e.label) {
7427
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _c, custody, _d, _e, market, migrateStake, err_59;
7428
+ return __generator(this, function (_f) {
7429
+ switch (_f.label) {
7317
7430
  case 0:
7318
7431
  publicKey = this.provider.wallet.publicKey;
7319
7432
  preInstructions = [];
@@ -7328,19 +7441,35 @@ var PerpetualsClient = (function () {
7328
7441
  if (!_a) return [3, 2];
7329
7442
  return [4, (0, utils_1.checkIfAccountExists)(compoudingTokenAccount, this.provider.connection)];
7330
7443
  case 1:
7331
- _a = !(_e.sent());
7332
- _e.label = 2;
7444
+ _a = !(_f.sent());
7445
+ _f.label = 2;
7333
7446
  case 2:
7334
7447
  if (_a) {
7335
7448
  preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, compoudingTokenAccount, publicKey, compoundingTokenMint));
7336
7449
  }
7337
7450
  flpStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("stake"), publicKey.toBuffer(), poolConfig.poolAddress.toBuffer()], this.programId)[0];
7451
+ tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), publicKey.toBuffer()], this.programId)[0];
7452
+ tokenStakeAccounts = [];
7453
+ _b = tokenStakeAccount;
7454
+ if (!_b) return [3, 4];
7455
+ return [4, (0, utils_1.checkIfAccountExists)(tokenStakeAccount, this.provider.connection)];
7456
+ case 3:
7457
+ _b = (_f.sent());
7458
+ _f.label = 4;
7459
+ case 4:
7460
+ if (_b) {
7461
+ tokenStakeAccounts.push({
7462
+ pubkey: tokenStakeAccount,
7463
+ isSigner: false,
7464
+ isWritable: true,
7465
+ });
7466
+ }
7338
7467
  poolStakedLpVault = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("staked_lp_token_account"), poolConfig.poolAddress.toBuffer(), lpTokenMint.toBuffer()], this.programId)[0];
7339
7468
  custodyAccountMetas = [];
7340
7469
  custodyOracleAccountMetas = [];
7341
7470
  markets = [];
7342
- for (_i = 0, _b = poolConfig.custodies; _i < _b.length; _i++) {
7343
- custody = _b[_i];
7471
+ for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
7472
+ custody = _c[_i];
7344
7473
  custodyAccountMetas.push({
7345
7474
  pubkey: custody.custodyAccount,
7346
7475
  isSigner: false,
@@ -7352,17 +7481,17 @@ var PerpetualsClient = (function () {
7352
7481
  isWritable: false,
7353
7482
  });
7354
7483
  }
7355
- for (_c = 0, _d = poolConfig.markets; _c < _d.length; _c++) {
7356
- market = _d[_c];
7484
+ for (_d = 0, _e = poolConfig.markets; _d < _e.length; _d++) {
7485
+ market = _e[_d];
7357
7486
  markets.push({
7358
7487
  pubkey: market.marketAccount,
7359
7488
  isSigner: false,
7360
7489
  isWritable: false,
7361
7490
  });
7362
7491
  }
7363
- _e.label = 3;
7364
- case 3:
7365
- _e.trys.push([3, 5, , 6]);
7492
+ _f.label = 5;
7493
+ case 5:
7494
+ _f.trys.push([5, 7, , 8]);
7366
7495
  return [4, this.program.methods
7367
7496
  .migrateStake({
7368
7497
  amount: amount
@@ -7385,17 +7514,17 @@ var PerpetualsClient = (function () {
7385
7514
  program: this.program.programId,
7386
7515
  ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
7387
7516
  })
7388
- .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true))
7517
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true), markets, true), tokenStakeAccounts, true))
7389
7518
  .instruction()];
7390
- case 4:
7391
- migrateStake = _e.sent();
7519
+ case 6:
7520
+ migrateStake = _f.sent();
7392
7521
  instructions.push(migrateStake);
7393
- return [3, 6];
7394
- case 5:
7395
- err_57 = _e.sent();
7396
- console.log("perpClient migrateStake error:: ", err_57);
7397
- return [3, 6];
7398
- case 6: return [2, {
7522
+ return [3, 8];
7523
+ case 7:
7524
+ err_59 = _f.sent();
7525
+ console.log("perpClient migrateStake error:: ", err_59);
7526
+ return [3, 8];
7527
+ case 8: return [2, {
7399
7528
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7400
7529
  additionalSigners: additionalSigners
7401
7530
  }];
@@ -7404,7 +7533,7 @@ var PerpetualsClient = (function () {
7404
7533
  });
7405
7534
  };
7406
7535
  this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7407
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_58;
7536
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_60;
7408
7537
  return __generator(this, function (_d) {
7409
7538
  switch (_d.label) {
7410
7539
  case 0:
@@ -7476,8 +7605,8 @@ var PerpetualsClient = (function () {
7476
7605
  instructions.push(migrateFlp);
7477
7606
  return [3, 4];
7478
7607
  case 3:
7479
- err_58 = _d.sent();
7480
- console.log("perpClient migrateFlp error:: ", err_58);
7608
+ err_60 = _d.sent();
7609
+ console.log("perpClient migrateFlp error:: ", err_60);
7481
7610
  return [3, 4];
7482
7611
  case 4: return [2, {
7483
7612
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7489,7 +7618,7 @@ var PerpetualsClient = (function () {
7489
7618
  this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
7490
7619
  if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7491
7620
  return __awaiter(_this, void 0, void 0, function () {
7492
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_59;
7621
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_61;
7493
7622
  return __generator(this, function (_d) {
7494
7623
  switch (_d.label) {
7495
7624
  case 0:
@@ -7546,8 +7675,8 @@ var PerpetualsClient = (function () {
7546
7675
  instructions.push(compoundingFee);
7547
7676
  return [3, 4];
7548
7677
  case 3:
7549
- err_59 = _d.sent();
7550
- console.log("perpClient compoundingFee error:: ", err_59);
7678
+ err_61 = _d.sent();
7679
+ console.log("perpClient compoundingFee error:: ", err_61);
7551
7680
  return [3, 4];
7552
7681
  case 4: return [2, {
7553
7682
  instructions: __spreadArray([], instructions, true),
@@ -7558,7 +7687,7 @@ var PerpetualsClient = (function () {
7558
7687
  });
7559
7688
  };
7560
7689
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7561
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_60;
7690
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_62;
7562
7691
  return __generator(this, function (_a) {
7563
7692
  switch (_a.label) {
7564
7693
  case 0:
@@ -7596,8 +7725,8 @@ var PerpetualsClient = (function () {
7596
7725
  instructions.push(renameFlp);
7597
7726
  return [3, 4];
7598
7727
  case 3:
7599
- err_60 = _a.sent();
7600
- console.log("perpClient renameFlp error:: ", err_60);
7728
+ err_62 = _a.sent();
7729
+ console.log("perpClient renameFlp error:: ", err_62);
7601
7730
  return [3, 4];
7602
7731
  case 4: return [2, {
7603
7732
  instructions: __spreadArray([], instructions, true),