flash-sdk 2.47.3-alpha.0 → 2.48.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.
@@ -1605,7 +1605,7 @@ var PerpetualsClient = (function () {
1605
1605
  var targetMinMaxPriceOracle = _this.getMinAndMaxOraclePriceSync(targetPrice, targetEmaPrice, targetCustodyAccount);
1606
1606
  var collateralMinMaxPriceOracle = _this.getMinAndMaxOraclePriceSync(collateralPrice, collateralEmaPrice, collateralCustodyAccount);
1607
1607
  var liquidationPrice;
1608
- if (marketCorrelation && (0, types_1.isVariant)(side, 'long') && !targetCustodyAccount.isVirtual) {
1608
+ if (marketCorrelation && (0, types_1.isVariant)(side, 'long')) {
1609
1609
  var newCollateralAmount = void 0;
1610
1610
  if (targetCustodyAccount.mint == collateralCustodyAccount.mint) {
1611
1611
  newCollateralAmount = collateralAmount;
@@ -5235,8 +5235,54 @@ var PerpetualsClient = (function () {
5235
5235
  }
5236
5236
  });
5237
5237
  }); };
5238
+ this.initRevenueTokenAccount = function (feeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5239
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_25;
5240
+ return __generator(this, function (_a) {
5241
+ switch (_a.label) {
5242
+ case 0:
5243
+ publicKey = this.provider.wallet.publicKey;
5244
+ preInstructions = [];
5245
+ instructions = [];
5246
+ postInstructions = [];
5247
+ additionalSigners = [];
5248
+ _a.label = 1;
5249
+ case 1:
5250
+ _a.trys.push([1, 3, , 4]);
5251
+ rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
5252
+ return [4, this.program.methods
5253
+ .initRevenueTokenAccount({
5254
+ feeShareBps: feeShareBps
5255
+ })
5256
+ .accounts({
5257
+ admin: publicKey,
5258
+ multisig: this.multisig.publicKey,
5259
+ perpetuals: this.perpetuals.publicKey,
5260
+ transferAuthority: poolConfig.transferAuthority,
5261
+ tokenVault: poolConfig.tokenVault,
5262
+ rewardMint: rewardCustodyMint,
5263
+ revenueTokenAccount: poolConfig.revenueTokenAccount,
5264
+ systemProgram: web3_js_1.SystemProgram.programId,
5265
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5266
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY
5267
+ })
5268
+ .instruction()];
5269
+ case 2:
5270
+ initRevenueTokenAccountInstruction = _a.sent();
5271
+ instructions.push(initRevenueTokenAccountInstruction);
5272
+ return [3, 4];
5273
+ case 3:
5274
+ err_25 = _a.sent();
5275
+ console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_25);
5276
+ throw err_25;
5277
+ case 4: return [2, {
5278
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5279
+ additionalSigners: additionalSigners
5280
+ }];
5281
+ }
5282
+ });
5283
+ }); };
5238
5284
  this.burnAndClaim = function (owner, nftMint, poolConfig, createAta) { return __awaiter(_this, void 0, void 0, function () {
5239
- var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_25;
5285
+ var preInstructions, instructions, postInstructions, additionalSigners, userTokenAccount, _a, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndClaimInstruction, err_26;
5240
5286
  return __generator(this, function (_b) {
5241
5287
  switch (_b.label) {
5242
5288
  case 0:
@@ -5300,9 +5346,9 @@ var PerpetualsClient = (function () {
5300
5346
  instructions.push(burnAndClaimInstruction);
5301
5347
  return [3, 8];
5302
5348
  case 7:
5303
- err_25 = _b.sent();
5304
- console.log("perpClient burnAndClaimInstruction error:: ", err_25);
5305
- throw err_25;
5349
+ err_26 = _b.sent();
5350
+ console.log("perpClient burnAndClaimInstruction error:: ", err_26);
5351
+ throw err_26;
5306
5352
  case 8: return [2, {
5307
5353
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5308
5354
  additionalSigners: additionalSigners
@@ -5311,7 +5357,7 @@ var PerpetualsClient = (function () {
5311
5357
  });
5312
5358
  }); };
5313
5359
  this.burnAndStake = function (owner, feePayer, nftMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5314
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_26;
5360
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, nftTokenAccount, nftTradingAccount, metadataAccount, collectionMetadata, edition, tokenRecord, burnAndStakeInstruction, err_27;
5315
5361
  return __generator(this, function (_a) {
5316
5362
  switch (_a.label) {
5317
5363
  case 0:
@@ -5362,9 +5408,9 @@ var PerpetualsClient = (function () {
5362
5408
  instructions.push(burnAndStakeInstruction);
5363
5409
  return [3, 4];
5364
5410
  case 3:
5365
- err_26 = _a.sent();
5366
- console.log("perpClient burnAndStakeInstruction error:: ", err_26);
5367
- throw err_26;
5411
+ err_27 = _a.sent();
5412
+ console.log("perpClient burnAndStakeInstruction error:: ", err_27);
5413
+ throw err_27;
5368
5414
  case 4: return [2, {
5369
5415
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5370
5416
  additionalSigners: additionalSigners
@@ -5373,7 +5419,7 @@ var PerpetualsClient = (function () {
5373
5419
  });
5374
5420
  }); };
5375
5421
  this.depositTokenStake = function (owner, feePayer, depositAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5376
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_27;
5422
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, depositTokenStakeInstruction, err_28;
5377
5423
  return __generator(this, function (_a) {
5378
5424
  switch (_a.label) {
5379
5425
  case 0:
@@ -5414,9 +5460,9 @@ var PerpetualsClient = (function () {
5414
5460
  instructions.push(depositTokenStakeInstruction);
5415
5461
  return [3, 5];
5416
5462
  case 4:
5417
- err_27 = _a.sent();
5418
- console.log("perpClient depositStakingInstruction error:: ", err_27);
5419
- throw err_27;
5463
+ err_28 = _a.sent();
5464
+ console.log("perpClient depositStakingInstruction error:: ", err_28);
5465
+ throw err_28;
5420
5466
  case 5: return [2, {
5421
5467
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5422
5468
  additionalSigners: additionalSigners
@@ -5425,7 +5471,7 @@ var PerpetualsClient = (function () {
5425
5471
  });
5426
5472
  }); };
5427
5473
  this.unstakeTokenRequest = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5428
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_28;
5474
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, unstakeTokenRequestInstruction, err_29;
5429
5475
  return __generator(this, function (_a) {
5430
5476
  switch (_a.label) {
5431
5477
  case 0:
@@ -5454,9 +5500,9 @@ var PerpetualsClient = (function () {
5454
5500
  instructions.push(unstakeTokenRequestInstruction);
5455
5501
  return [3, 4];
5456
5502
  case 3:
5457
- err_28 = _a.sent();
5458
- console.log("perpClient unstakeTokenRequestInstruction error:: ", err_28);
5459
- throw err_28;
5503
+ err_29 = _a.sent();
5504
+ console.log("perpClient unstakeTokenRequestInstruction error:: ", err_29);
5505
+ throw err_29;
5460
5506
  case 4: return [2, {
5461
5507
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5462
5508
  additionalSigners: additionalSigners
@@ -5465,7 +5511,7 @@ var PerpetualsClient = (function () {
5465
5511
  });
5466
5512
  }); };
5467
5513
  this.unstakeTokenInstant = function (owner, unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5468
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_29;
5514
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, unstakeTokenInstantInstruction, err_30;
5469
5515
  return __generator(this, function (_a) {
5470
5516
  switch (_a.label) {
5471
5517
  case 0:
@@ -5505,9 +5551,9 @@ var PerpetualsClient = (function () {
5505
5551
  instructions.push(unstakeTokenInstantInstruction);
5506
5552
  return [3, 5];
5507
5553
  case 4:
5508
- err_29 = _a.sent();
5509
- console.log("perpClient unstakeTokenInstantInstruction error:: ", err_29);
5510
- throw err_29;
5554
+ err_30 = _a.sent();
5555
+ console.log("perpClient unstakeTokenInstantInstruction error:: ", err_30);
5556
+ throw err_30;
5511
5557
  case 5: return [2, {
5512
5558
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5513
5559
  additionalSigners: additionalSigners
@@ -5516,7 +5562,7 @@ var PerpetualsClient = (function () {
5516
5562
  });
5517
5563
  }); };
5518
5564
  this.withdrawToken = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5519
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_30;
5565
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, withdrawTokenInstruction, err_31;
5520
5566
  return __generator(this, function (_a) {
5521
5567
  switch (_a.label) {
5522
5568
  case 0:
@@ -5556,9 +5602,9 @@ var PerpetualsClient = (function () {
5556
5602
  instructions.push(withdrawTokenInstruction);
5557
5603
  return [3, 5];
5558
5604
  case 4:
5559
- err_30 = _a.sent();
5560
- console.log("perpClient withdrawTokenInstruction error:: ", err_30);
5561
- throw err_30;
5605
+ err_31 = _a.sent();
5606
+ console.log("perpClient withdrawTokenInstruction error:: ", err_31);
5607
+ throw err_31;
5562
5608
  case 5: return [2, {
5563
5609
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5564
5610
  additionalSigners: additionalSigners
@@ -5567,7 +5613,7 @@ var PerpetualsClient = (function () {
5567
5613
  });
5568
5614
  }); };
5569
5615
  this.cancelUnstakeRequest = function (owner, withdrawRequestId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5570
- var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_31;
5616
+ var preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, cancelUnstakeRequestInstruction, err_32;
5571
5617
  return __generator(this, function (_a) {
5572
5618
  switch (_a.label) {
5573
5619
  case 0:
@@ -5596,9 +5642,9 @@ var PerpetualsClient = (function () {
5596
5642
  instructions.push(cancelUnstakeRequestInstruction);
5597
5643
  return [3, 4];
5598
5644
  case 3:
5599
- err_31 = _a.sent();
5600
- console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_31);
5601
- throw err_31;
5645
+ err_32 = _a.sent();
5646
+ console.log("perpClient cancelUnstakeRequestInstruction error:: ", err_32);
5647
+ throw err_32;
5602
5648
  case 4: return [2, {
5603
5649
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5604
5650
  additionalSigners: additionalSigners
@@ -5606,8 +5652,8 @@ var PerpetualsClient = (function () {
5606
5652
  }
5607
5653
  });
5608
5654
  }); };
5609
- this.distributeTokenReward = function (amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5610
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, fundingTokenAccount, distributeTokenRewardInstruction, err_32;
5655
+ this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5656
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_33;
5611
5657
  return __generator(this, function (_a) {
5612
5658
  switch (_a.label) {
5613
5659
  case 0:
@@ -5619,7 +5665,9 @@ var PerpetualsClient = (function () {
5619
5665
  _a.label = 1;
5620
5666
  case 1:
5621
5667
  _a.trys.push([1, 3, , 4]);
5668
+ rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
5622
5669
  fundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.tokenMint, publicKey, true);
5670
+ revenueFundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(rewardCustodyMint, publicKey, true);
5623
5671
  return [4, this.program.methods
5624
5672
  .distributeTokenReward({
5625
5673
  amount: amount,
@@ -5643,9 +5691,9 @@ var PerpetualsClient = (function () {
5643
5691
  instructions.push(distributeTokenRewardInstruction);
5644
5692
  return [3, 4];
5645
5693
  case 3:
5646
- err_32 = _a.sent();
5647
- console.log("perpClient distributeTokenRewardInstruction error:: ", err_32);
5648
- throw err_32;
5694
+ err_33 = _a.sent();
5695
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_33);
5696
+ throw err_33;
5649
5697
  case 4: return [2, {
5650
5698
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5651
5699
  additionalSigners: additionalSigners
@@ -5654,7 +5702,7 @@ var PerpetualsClient = (function () {
5654
5702
  });
5655
5703
  }); };
5656
5704
  this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5657
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_33;
5705
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_34;
5658
5706
  return __generator(this, function (_a) {
5659
5707
  switch (_a.label) {
5660
5708
  case 0:
@@ -5686,9 +5734,9 @@ var PerpetualsClient = (function () {
5686
5734
  instructions.push(setTokenRewardInstruction);
5687
5735
  return [3, 4];
5688
5736
  case 3:
5689
- err_33 = _a.sent();
5690
- console.log("perpClient setTokenRewardInstruction error:: ", err_33);
5691
- throw err_33;
5737
+ err_34 = _a.sent();
5738
+ console.log("perpClient setTokenRewardInstruction error:: ", err_34);
5739
+ throw err_34;
5692
5740
  case 4: return [2, {
5693
5741
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5694
5742
  additionalSigners: additionalSigners
@@ -5699,7 +5747,7 @@ var PerpetualsClient = (function () {
5699
5747
  this.collectTokenReward = function (owner, poolConfig, createUserATA) {
5700
5748
  if (createUserATA === void 0) { createUserATA = true; }
5701
5749
  return __awaiter(_this, void 0, void 0, function () {
5702
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_34;
5750
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_35;
5703
5751
  return __generator(this, function (_b) {
5704
5752
  switch (_b.label) {
5705
5753
  case 0:
@@ -5743,9 +5791,68 @@ var PerpetualsClient = (function () {
5743
5791
  instructions.push(collectTokenRewardInstruction);
5744
5792
  return [3, 6];
5745
5793
  case 5:
5746
- err_34 = _b.sent();
5747
- console.log("perpClient collectTokenRewardInstruction error:: ", err_34);
5748
- throw err_34;
5794
+ err_35 = _b.sent();
5795
+ console.log("perpClient collectTokenRewardInstruction error:: ", err_35);
5796
+ throw err_35;
5797
+ case 6: return [2, {
5798
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5799
+ additionalSigners: additionalSigners
5800
+ }];
5801
+ }
5802
+ });
5803
+ });
5804
+ };
5805
+ this.collectRevenue = function (owner, rewardSymbol, poolConfig, createUserATA) {
5806
+ if (createUserATA === void 0) { createUserATA = true; }
5807
+ return __awaiter(_this, void 0, void 0, function () {
5808
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, tokenStakeAccount, userTokenAccount, _a, collectRevenueInstruction, err_36;
5809
+ return __generator(this, function (_b) {
5810
+ switch (_b.label) {
5811
+ case 0:
5812
+ publicKey = this.provider.wallet.publicKey;
5813
+ preInstructions = [];
5814
+ instructions = [];
5815
+ postInstructions = [];
5816
+ additionalSigners = [];
5817
+ _b.label = 1;
5818
+ case 1:
5819
+ _b.trys.push([1, 5, , 6]);
5820
+ rewardCustodyMint = poolConfig.getTokenFromSymbol(rewardSymbol).mintKey;
5821
+ tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
5822
+ userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(rewardCustodyMint, owner, true);
5823
+ _a = createUserATA;
5824
+ if (!_a) return [3, 3];
5825
+ return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
5826
+ case 2:
5827
+ _a = !(_b.sent());
5828
+ _b.label = 3;
5829
+ case 3:
5830
+ if (_a) {
5831
+ instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userTokenAccount, publicKey, poolConfig.tokenMint));
5832
+ }
5833
+ return [4, this.program.methods
5834
+ .collectRevenue({})
5835
+ .accounts({
5836
+ owner: owner,
5837
+ receivingRevenueAccount: userTokenAccount,
5838
+ perpetuals: this.perpetuals.publicKey,
5839
+ transferAuthority: poolConfig.transferAuthority,
5840
+ tokenVault: poolConfig.tokenVault,
5841
+ revenueTokenAccount: poolConfig.revenueTokenAccount,
5842
+ tokenStakeAccount: tokenStakeAccount,
5843
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5844
+ eventAuthority: this.eventAuthority.publicKey,
5845
+ program: this.programId
5846
+ })
5847
+ .instruction()];
5848
+ case 4:
5849
+ collectRevenueInstruction = _b.sent();
5850
+ instructions.push(collectRevenueInstruction);
5851
+ return [3, 6];
5852
+ case 5:
5853
+ err_36 = _b.sent();
5854
+ console.log("perpClient collectRevenueInstruction error:: ", err_36);
5855
+ throw err_36;
5749
5856
  case 6: return [2, {
5750
5857
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5751
5858
  additionalSigners: additionalSigners
@@ -5755,7 +5862,7 @@ var PerpetualsClient = (function () {
5755
5862
  });
5756
5863
  };
5757
5864
  this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
5758
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_35;
5865
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_37;
5759
5866
  return __generator(this, function (_a) {
5760
5867
  switch (_a.label) {
5761
5868
  case 0:
@@ -5783,9 +5890,9 @@ var PerpetualsClient = (function () {
5783
5890
  instructions.push(setTokenStakeLevelInstruction);
5784
5891
  return [3, 4];
5785
5892
  case 3:
5786
- err_35 = _a.sent();
5787
- console.log("perpClient setTokenStakeLevelInstruction error:: ", err_35);
5788
- throw err_35;
5893
+ err_37 = _a.sent();
5894
+ console.log("perpClient setTokenStakeLevelInstruction error:: ", err_37);
5895
+ throw err_37;
5789
5896
  case 4: return [2, {
5790
5897
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5791
5898
  additionalSigners: additionalSigners
@@ -5794,7 +5901,7 @@ var PerpetualsClient = (function () {
5794
5901
  });
5795
5902
  }); };
5796
5903
  this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5797
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_36;
5904
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_38;
5798
5905
  return __generator(this, function (_a) {
5799
5906
  switch (_a.label) {
5800
5907
  case 0:
@@ -5831,9 +5938,9 @@ var PerpetualsClient = (function () {
5831
5938
  instructions.push(initRewardVault);
5832
5939
  return [3, 4];
5833
5940
  case 3:
5834
- err_36 = _a.sent();
5835
- console.log("perpClient InitRewardVault error:: ", err_36);
5836
- throw err_36;
5941
+ err_38 = _a.sent();
5942
+ console.log("perpClient InitRewardVault error:: ", err_38);
5943
+ throw err_38;
5837
5944
  case 4: return [2, {
5838
5945
  instructions: __spreadArray([], instructions, true),
5839
5946
  additionalSigners: additionalSigners
@@ -5842,7 +5949,7 @@ var PerpetualsClient = (function () {
5842
5949
  });
5843
5950
  }); };
5844
5951
  this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5845
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_37;
5952
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_39;
5846
5953
  return __generator(this, function (_a) {
5847
5954
  switch (_a.label) {
5848
5955
  case 0:
@@ -5873,9 +5980,9 @@ var PerpetualsClient = (function () {
5873
5980
  instructions.push(distributeReward);
5874
5981
  return [3, 4];
5875
5982
  case 3:
5876
- err_37 = _a.sent();
5877
- console.log("perpClient distributeReward error:: ", err_37);
5878
- throw err_37;
5983
+ err_39 = _a.sent();
5984
+ console.log("perpClient distributeReward error:: ", err_39);
5985
+ throw err_39;
5879
5986
  case 4: return [2, {
5880
5987
  instructions: __spreadArray([], instructions, true),
5881
5988
  additionalSigners: additionalSigners
@@ -5886,7 +5993,7 @@ var PerpetualsClient = (function () {
5886
5993
  this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5887
5994
  if (createUserATA === void 0) { createUserATA = true; }
5888
5995
  return __awaiter(_this, void 0, void 0, function () {
5889
- var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_38;
5996
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_40;
5890
5997
  return __generator(this, function (_b) {
5891
5998
  switch (_b.label) {
5892
5999
  case 0:
@@ -5936,8 +6043,8 @@ var PerpetualsClient = (function () {
5936
6043
  instructions.push(collectNftReward);
5937
6044
  return [3, 6];
5938
6045
  case 5:
5939
- err_38 = _b.sent();
5940
- throw err_38;
6046
+ err_40 = _b.sent();
6047
+ throw err_40;
5941
6048
  case 6: return [2, {
5942
6049
  instructions: __spreadArray([], instructions, true),
5943
6050
  additionalSigners: additionalSigners
@@ -5949,7 +6056,7 @@ var PerpetualsClient = (function () {
5949
6056
  this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
5950
6057
  if (createUserATA === void 0) { createUserATA = true; }
5951
6058
  return __awaiter(_this, void 0, void 0, function () {
5952
- var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_39;
6059
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_41;
5953
6060
  return __generator(this, function (_b) {
5954
6061
  switch (_b.label) {
5955
6062
  case 0:
@@ -6013,9 +6120,9 @@ var PerpetualsClient = (function () {
6013
6120
  instructions.push(withdrawStakeInstruction);
6014
6121
  return [3, 6];
6015
6122
  case 5:
6016
- err_39 = _b.sent();
6017
- console.log("perpClient withdrawStake error:: ", err_39);
6018
- throw err_39;
6123
+ err_41 = _b.sent();
6124
+ console.log("perpClient withdrawStake error:: ", err_41);
6125
+ throw err_41;
6019
6126
  case 6: return [2, {
6020
6127
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6021
6128
  additionalSigners: additionalSigners
@@ -6025,7 +6132,7 @@ var PerpetualsClient = (function () {
6025
6132
  });
6026
6133
  };
6027
6134
  this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6028
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_40;
6135
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_42;
6029
6136
  return __generator(this, function (_a) {
6030
6137
  switch (_a.label) {
6031
6138
  case 0:
@@ -6064,9 +6171,9 @@ var PerpetualsClient = (function () {
6064
6171
  instructions.push(setTriggerPrice);
6065
6172
  return [3, 4];
6066
6173
  case 3:
6067
- err_40 = _a.sent();
6068
- console.log("perpClient setTriggerPrice error:: ", err_40);
6069
- throw err_40;
6174
+ err_42 = _a.sent();
6175
+ console.log("perpClient setTriggerPrice error:: ", err_42);
6176
+ throw err_42;
6070
6177
  case 4: return [2, {
6071
6178
  instructions: __spreadArray([], instructions, true),
6072
6179
  additionalSigners: additionalSigners
@@ -6079,7 +6186,7 @@ var PerpetualsClient = (function () {
6079
6186
  if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6080
6187
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6081
6188
  return __awaiter(_this, void 0, void 0, function () {
6082
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_41;
6189
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_43;
6083
6190
  return __generator(this, function (_b) {
6084
6191
  switch (_b.label) {
6085
6192
  case 0:
@@ -6140,9 +6247,9 @@ var PerpetualsClient = (function () {
6140
6247
  }
6141
6248
  return [3, 7];
6142
6249
  case 6:
6143
- err_41 = _b.sent();
6144
- console.log("perpClient forceClosePosition error:: ", err_41);
6145
- throw err_41;
6250
+ err_43 = _b.sent();
6251
+ console.log("perpClient forceClosePosition error:: ", err_43);
6252
+ throw err_43;
6146
6253
  case 7: return [2, {
6147
6254
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6148
6255
  additionalSigners: additionalSigners
@@ -6155,7 +6262,7 @@ var PerpetualsClient = (function () {
6155
6262
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6156
6263
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6157
6264
  return __awaiter(_this, void 0, void 0, function () {
6158
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_42;
6265
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_44;
6159
6266
  return __generator(this, function (_c) {
6160
6267
  switch (_c.label) {
6161
6268
  case 0:
@@ -6260,9 +6367,9 @@ var PerpetualsClient = (function () {
6260
6367
  instructions.push(placeLimitOrder);
6261
6368
  return [3, 11];
6262
6369
  case 10:
6263
- err_42 = _c.sent();
6264
- console.log("perpClient placeLimitOrder error:: ", err_42);
6265
- throw err_42;
6370
+ err_44 = _c.sent();
6371
+ console.log("perpClient placeLimitOrder error:: ", err_44);
6372
+ throw err_44;
6266
6373
  case 11: return [2, {
6267
6374
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6268
6375
  additionalSigners: additionalSigners
@@ -6275,7 +6382,7 @@ var PerpetualsClient = (function () {
6275
6382
  if (createUserATA === void 0) { createUserATA = true; }
6276
6383
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6277
6384
  return __awaiter(_this, void 0, void 0, function () {
6278
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_43;
6385
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_45;
6279
6386
  return __generator(this, function (_b) {
6280
6387
  switch (_b.label) {
6281
6388
  case 0:
@@ -6363,9 +6470,9 @@ var PerpetualsClient = (function () {
6363
6470
  instructions.push(editLimitOrder);
6364
6471
  return [3, 8];
6365
6472
  case 7:
6366
- err_43 = _b.sent();
6367
- console.log("perpClient editLimitOrder error:: ", err_43);
6368
- throw err_43;
6473
+ err_45 = _b.sent();
6474
+ console.log("perpClient editLimitOrder error:: ", err_45);
6475
+ throw err_45;
6369
6476
  case 8: return [2, {
6370
6477
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6371
6478
  additionalSigners: additionalSigners
@@ -6379,7 +6486,7 @@ var PerpetualsClient = (function () {
6379
6486
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6380
6487
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6381
6488
  return __awaiter(_this, void 0, void 0, function () {
6382
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_44;
6489
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_46;
6383
6490
  return __generator(this, function (_a) {
6384
6491
  switch (_a.label) {
6385
6492
  case 0:
@@ -6428,9 +6535,9 @@ var PerpetualsClient = (function () {
6428
6535
  instructions.push(executeLimitOrder);
6429
6536
  return [3, 4];
6430
6537
  case 3:
6431
- err_44 = _a.sent();
6432
- console.log("perpClient executeLimitOrder error:: ", err_44);
6433
- throw err_44;
6538
+ err_46 = _a.sent();
6539
+ console.log("perpClient executeLimitOrder error:: ", err_46);
6540
+ throw err_46;
6434
6541
  case 4: return [2, {
6435
6542
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6436
6543
  additionalSigners: additionalSigners
@@ -6444,7 +6551,7 @@ var PerpetualsClient = (function () {
6444
6551
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6445
6552
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6446
6553
  return __awaiter(_this, void 0, void 0, function () {
6447
- var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_45;
6554
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_47;
6448
6555
  return __generator(this, function (_a) {
6449
6556
  switch (_a.label) {
6450
6557
  case 0:
@@ -6496,9 +6603,9 @@ var PerpetualsClient = (function () {
6496
6603
  instructions.push(executeLimitWithSwap);
6497
6604
  return [3, 4];
6498
6605
  case 3:
6499
- err_45 = _a.sent();
6500
- console.log("perpClient executeLimitWithSwap error:: ", err_45);
6501
- throw err_45;
6606
+ err_47 = _a.sent();
6607
+ console.log("perpClient executeLimitWithSwap error:: ", err_47);
6608
+ throw err_47;
6502
6609
  case 4: return [2, {
6503
6610
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6504
6611
  additionalSigners: additionalSigners
@@ -6508,7 +6615,7 @@ var PerpetualsClient = (function () {
6508
6615
  });
6509
6616
  };
6510
6617
  this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6511
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_46;
6618
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_48;
6512
6619
  return __generator(this, function (_a) {
6513
6620
  switch (_a.label) {
6514
6621
  case 0:
@@ -6556,9 +6663,9 @@ var PerpetualsClient = (function () {
6556
6663
  instructions.push(placeTriggerOrder);
6557
6664
  return [3, 4];
6558
6665
  case 3:
6559
- err_46 = _a.sent();
6560
- console.log("perpClient placeTriggerOrder error:: ", err_46);
6561
- throw err_46;
6666
+ err_48 = _a.sent();
6667
+ console.log("perpClient placeTriggerOrder error:: ", err_48);
6668
+ throw err_48;
6562
6669
  case 4: return [2, {
6563
6670
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6564
6671
  additionalSigners: additionalSigners
@@ -6567,7 +6674,7 @@ var PerpetualsClient = (function () {
6567
6674
  });
6568
6675
  }); };
6569
6676
  this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6570
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_47;
6677
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_49;
6571
6678
  return __generator(this, function (_a) {
6572
6679
  switch (_a.label) {
6573
6680
  case 0:
@@ -6614,9 +6721,9 @@ var PerpetualsClient = (function () {
6614
6721
  instructions.push(editTriggerOrder);
6615
6722
  return [3, 4];
6616
6723
  case 3:
6617
- err_47 = _a.sent();
6618
- console.log("perpClient editTriggerOrder error:: ", err_47);
6619
- throw err_47;
6724
+ err_49 = _a.sent();
6725
+ console.log("perpClient editTriggerOrder error:: ", err_49);
6726
+ throw err_49;
6620
6727
  case 4: return [2, {
6621
6728
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6622
6729
  additionalSigners: additionalSigners
@@ -6625,7 +6732,7 @@ var PerpetualsClient = (function () {
6625
6732
  });
6626
6733
  }); };
6627
6734
  this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6628
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_48;
6735
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_50;
6629
6736
  return __generator(this, function (_a) {
6630
6737
  switch (_a.label) {
6631
6738
  case 0:
@@ -6658,9 +6765,9 @@ var PerpetualsClient = (function () {
6658
6765
  instructions.push(cancelTriggerOrder);
6659
6766
  return [3, 4];
6660
6767
  case 3:
6661
- err_48 = _a.sent();
6662
- console.log("perpClient cancelTriggerOrder error:: ", err_48);
6663
- throw err_48;
6768
+ err_50 = _a.sent();
6769
+ console.log("perpClient cancelTriggerOrder error:: ", err_50);
6770
+ throw err_50;
6664
6771
  case 4: return [2, {
6665
6772
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6666
6773
  additionalSigners: additionalSigners
@@ -6669,7 +6776,7 @@ var PerpetualsClient = (function () {
6669
6776
  });
6670
6777
  }); };
6671
6778
  this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6672
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_49;
6779
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_51;
6673
6780
  return __generator(this, function (_a) {
6674
6781
  switch (_a.label) {
6675
6782
  case 0:
@@ -6700,9 +6807,9 @@ var PerpetualsClient = (function () {
6700
6807
  instructions.push(cancelAllTriggerOrders);
6701
6808
  return [3, 4];
6702
6809
  case 3:
6703
- err_49 = _a.sent();
6704
- console.log("perpClient cancelAllTriggerOrders error:: ", err_49);
6705
- throw err_49;
6810
+ err_51 = _a.sent();
6811
+ console.log("perpClient cancelAllTriggerOrders error:: ", err_51);
6812
+ throw err_51;
6706
6813
  case 4: return [2, {
6707
6814
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6708
6815
  additionalSigners: additionalSigners
@@ -6717,7 +6824,7 @@ var PerpetualsClient = (function () {
6717
6824
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6718
6825
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6719
6826
  return __awaiter(_this, void 0, void 0, function () {
6720
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_50;
6827
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_52;
6721
6828
  return __generator(this, function (_d) {
6722
6829
  switch (_d.label) {
6723
6830
  case 0:
@@ -6814,9 +6921,9 @@ var PerpetualsClient = (function () {
6814
6921
  instructions.push(executeTriggerWithSwap);
6815
6922
  return [3, 10];
6816
6923
  case 9:
6817
- err_50 = _d.sent();
6818
- console.log("perpClient executeTriggerWithSwap error:: ", err_50);
6819
- throw err_50;
6924
+ err_52 = _d.sent();
6925
+ console.log("perpClient executeTriggerWithSwap error:: ", err_52);
6926
+ throw err_52;
6820
6927
  case 10: return [2, {
6821
6928
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6822
6929
  additionalSigners: additionalSigners
@@ -6832,7 +6939,7 @@ var PerpetualsClient = (function () {
6832
6939
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6833
6940
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6834
6941
  return __awaiter(_this, void 0, void 0, function () {
6835
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_51;
6942
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_53;
6836
6943
  return __generator(this, function (_b) {
6837
6944
  switch (_b.label) {
6838
6945
  case 0:
@@ -6898,9 +7005,9 @@ var PerpetualsClient = (function () {
6898
7005
  instructions.push(executeTriggerOrder);
6899
7006
  return [3, 8];
6900
7007
  case 7:
6901
- err_51 = _b.sent();
6902
- console.log("perpClient executeTriggerOrder error:: ", err_51);
6903
- throw err_51;
7008
+ err_53 = _b.sent();
7009
+ console.log("perpClient executeTriggerOrder error:: ", err_53);
7010
+ throw err_53;
6904
7011
  case 8: return [2, {
6905
7012
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6906
7013
  additionalSigners: additionalSigners
@@ -6910,7 +7017,7 @@ var PerpetualsClient = (function () {
6910
7017
  });
6911
7018
  };
6912
7019
  this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6913
- var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_52;
7020
+ var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_54;
6914
7021
  return __generator(this, function (_a) {
6915
7022
  switch (_a.label) {
6916
7023
  case 0:
@@ -6940,9 +7047,9 @@ var PerpetualsClient = (function () {
6940
7047
  instructions.push(migrateTriggerOrder);
6941
7048
  return [3, 4];
6942
7049
  case 3:
6943
- err_52 = _a.sent();
6944
- console.log("perpClient migrateTriggerOrder error:: ", err_52);
6945
- throw err_52;
7050
+ err_54 = _a.sent();
7051
+ console.log("perpClient migrateTriggerOrder error:: ", err_54);
7052
+ throw err_54;
6946
7053
  case 4: return [2, {
6947
7054
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6948
7055
  additionalSigners: additionalSigners
@@ -6951,7 +7058,7 @@ var PerpetualsClient = (function () {
6951
7058
  });
6952
7059
  }); };
6953
7060
  this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6954
- var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_53;
7061
+ var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_55;
6955
7062
  return __generator(this, function (_a) {
6956
7063
  switch (_a.label) {
6957
7064
  case 0:
@@ -6980,15 +7087,15 @@ var PerpetualsClient = (function () {
6980
7087
  console.log(getPositionData);
6981
7088
  return [2, getPositionData];
6982
7089
  case 3:
6983
- err_53 = _a.sent();
6984
- console.log("perpClient setPool error:: ", err_53);
6985
- throw err_53;
7090
+ err_55 = _a.sent();
7091
+ console.log("perpClient setPool error:: ", err_55);
7092
+ throw err_55;
6986
7093
  case 4: return [2];
6987
7094
  }
6988
7095
  });
6989
7096
  }); };
6990
7097
  this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6991
- var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_54;
7098
+ var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_56;
6992
7099
  return __generator(this, function (_a) {
6993
7100
  switch (_a.label) {
6994
7101
  case 0:
@@ -7009,9 +7116,8 @@ var PerpetualsClient = (function () {
7009
7116
  multisig: this.multisig.publicKey,
7010
7117
  transferAuthority: this.authority.publicKey,
7011
7118
  perpetuals: this.perpetuals.publicKey,
7012
- pool: poolConfig.poolAddress,
7013
- custody: custodyConfig.custodyAccount,
7014
- custodyTokenAccount: custodyConfig.tokenAccount,
7119
+ protocol: poolConfig.protocol,
7120
+ protocolTokenAccount: poolConfig.protocolTokenAccount,
7015
7121
  receivingTokenAccount: receivingTokenAccount,
7016
7122
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
7017
7123
  })
@@ -7021,9 +7127,9 @@ var PerpetualsClient = (function () {
7021
7127
  instructions.push(withdrawFeesIx);
7022
7128
  return [3, 5];
7023
7129
  case 4:
7024
- err_54 = _a.sent();
7025
- console.log("perpClient setPool error:: ", err_54);
7026
- throw err_54;
7130
+ err_56 = _a.sent();
7131
+ console.log("perpClient setPool error:: ", err_56);
7132
+ throw err_56;
7027
7133
  case 5: return [2, {
7028
7134
  instructions: __spreadArray([], instructions, true),
7029
7135
  additionalSigners: additionalSigners
@@ -7031,8 +7137,80 @@ var PerpetualsClient = (function () {
7031
7137
  }
7032
7138
  });
7033
7139
  }); };
7140
+ this.moveProtocolFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7141
+ var publicKey, custodyConfig, instructions, additionalSigners, moveProtocolFeesIx, err_57;
7142
+ return __generator(this, function (_a) {
7143
+ switch (_a.label) {
7144
+ case 0:
7145
+ publicKey = this.provider.wallet.publicKey;
7146
+ custodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
7147
+ instructions = [];
7148
+ additionalSigners = [];
7149
+ _a.label = 1;
7150
+ case 1:
7151
+ _a.trys.push([1, 3, , 4]);
7152
+ return [4, this.program.methods
7153
+ .moveProtocolFees({})
7154
+ .accounts({
7155
+ admin: publicKey,
7156
+ multisig: this.multisig.publicKey,
7157
+ transferAuthority: this.authority.publicKey,
7158
+ perpetuals: this.perpetuals.publicKey,
7159
+ tokenVault: poolConfig.tokenVault,
7160
+ pool: poolConfig.poolAddress,
7161
+ custody: custodyConfig.custodyAccount,
7162
+ custodyTokenAccount: custodyConfig.tokenAccount,
7163
+ revenueTokenAccount: poolConfig.revenueTokenAccount,
7164
+ protocol: poolConfig.protocol,
7165
+ protocolTokenAccount: poolConfig.protocolTokenAccount,
7166
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID
7167
+ })
7168
+ .instruction()];
7169
+ case 2:
7170
+ moveProtocolFeesIx = _a.sent();
7171
+ instructions.push(moveProtocolFeesIx);
7172
+ return [3, 4];
7173
+ case 3:
7174
+ err_57 = _a.sent();
7175
+ console.log("perpClient setPool error:: ", err_57);
7176
+ throw err_57;
7177
+ case 4: return [2, {
7178
+ instructions: __spreadArray([], instructions, true),
7179
+ additionalSigners: additionalSigners
7180
+ }];
7181
+ }
7182
+ });
7183
+ }); };
7184
+ this.setProtocolFeeShareBps = function (feeShareBps, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7185
+ var publicKey, setProtocolFeeShareBpsIx, err_58;
7186
+ return __generator(this, function (_a) {
7187
+ switch (_a.label) {
7188
+ case 0:
7189
+ _a.trys.push([0, 2, , 3]);
7190
+ publicKey = this.provider.wallet.publicKey;
7191
+ return [4, this.program.methods
7192
+ .setProtocolFeeShare({
7193
+ feeShareBps: feeShareBps
7194
+ })
7195
+ .accounts({
7196
+ admin: publicKey,
7197
+ multisig: this.multisig.publicKey,
7198
+ protocol: poolConfig.protocol,
7199
+ })
7200
+ .instruction()];
7201
+ case 1:
7202
+ setProtocolFeeShareBpsIx = _a.sent();
7203
+ return [2, setProtocolFeeShareBpsIx];
7204
+ case 2:
7205
+ err_58 = _a.sent();
7206
+ console.log("perpClient setProtocolFeeShareBpsIx error:: ", err_58);
7207
+ throw err_58;
7208
+ case 3: return [2];
7209
+ }
7210
+ });
7211
+ }); };
7034
7212
  this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
7035
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_55;
7213
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_59;
7036
7214
  return __generator(this, function (_a) {
7037
7215
  switch (_a.label) {
7038
7216
  case 0:
@@ -7059,9 +7237,9 @@ var PerpetualsClient = (function () {
7059
7237
  instructions.push(setPermissionsInstruction);
7060
7238
  return [3, 4];
7061
7239
  case 3:
7062
- err_55 = _a.sent();
7063
- console.log("perpClient setPool error:: ", err_55);
7064
- throw err_55;
7240
+ err_59 = _a.sent();
7241
+ console.log("perpClient setPool error:: ", err_59);
7242
+ throw err_59;
7065
7243
  case 4: return [2, {
7066
7244
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7067
7245
  additionalSigners: additionalSigners
@@ -7070,7 +7248,7 @@ var PerpetualsClient = (function () {
7070
7248
  });
7071
7249
  }); };
7072
7250
  this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7073
- var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_56;
7251
+ var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_60;
7074
7252
  var _f;
7075
7253
  return __generator(this, function (_g) {
7076
7254
  switch (_g.label) {
@@ -7130,9 +7308,9 @@ var PerpetualsClient = (function () {
7130
7308
  instructions.push(reimburse);
7131
7309
  return [3, 5];
7132
7310
  case 4:
7133
- err_56 = _g.sent();
7134
- console.log("perpClient setPool error:: ", err_56);
7135
- throw err_56;
7311
+ err_60 = _g.sent();
7312
+ console.log("perpClient setPool error:: ", err_60);
7313
+ throw err_60;
7136
7314
  case 5: return [2, {
7137
7315
  instructions: __spreadArray([], instructions, true),
7138
7316
  additionalSigners: additionalSigners
@@ -7141,7 +7319,7 @@ var PerpetualsClient = (function () {
7141
7319
  });
7142
7320
  }); };
7143
7321
  this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7144
- var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_57;
7322
+ var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_61;
7145
7323
  return __generator(this, function (_a) {
7146
7324
  switch (_a.label) {
7147
7325
  case 0:
@@ -7174,9 +7352,9 @@ var PerpetualsClient = (function () {
7174
7352
  instructions.push(setInternalOraclePrice);
7175
7353
  return [3, 4];
7176
7354
  case 3:
7177
- err_57 = _a.sent();
7178
- console.log("perpClient setInternalOracleAccount error:: ", err_57);
7179
- throw err_57;
7355
+ err_61 = _a.sent();
7356
+ console.log("perpClient setInternalOracleAccount error:: ", err_61);
7357
+ throw err_61;
7180
7358
  case 4: return [2, {
7181
7359
  instructions: __spreadArray([], instructions, true),
7182
7360
  additionalSigners: additionalSigners
@@ -7189,7 +7367,7 @@ var PerpetualsClient = (function () {
7189
7367
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7190
7368
  if (userPublicKey === void 0) { userPublicKey = undefined; }
7191
7369
  return __awaiter(_this, void 0, void 0, function () {
7192
- 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_58;
7370
+ 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_62;
7193
7371
  return __generator(this, function (_e) {
7194
7372
  switch (_e.label) {
7195
7373
  case 0:
@@ -7312,8 +7490,8 @@ var PerpetualsClient = (function () {
7312
7490
  instructions.push(addCompoundingLiquidity);
7313
7491
  return [3, 10];
7314
7492
  case 9:
7315
- err_58 = _e.sent();
7316
- console.log("perpClient addCompoundingLiquidity error:: ", err_58);
7493
+ err_62 = _e.sent();
7494
+ console.log("perpClient addCompoundingLiquidity error:: ", err_62);
7317
7495
  return [3, 10];
7318
7496
  case 10: return [2, {
7319
7497
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7328,7 +7506,7 @@ var PerpetualsClient = (function () {
7328
7506
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
7329
7507
  if (userPublicKey === void 0) { userPublicKey = undefined; }
7330
7508
  return __awaiter(_this, void 0, void 0, function () {
7331
- 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_59;
7509
+ 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_63;
7332
7510
  return __generator(this, function (_e) {
7333
7511
  switch (_e.label) {
7334
7512
  case 0:
@@ -7435,8 +7613,8 @@ var PerpetualsClient = (function () {
7435
7613
  instructions.push(removeCompoundingLiquidity);
7436
7614
  return [3, 8];
7437
7615
  case 7:
7438
- err_59 = _e.sent();
7439
- console.log("perpClient removeCompoundingLiquidity error:: ", err_59);
7616
+ err_63 = _e.sent();
7617
+ console.log("perpClient removeCompoundingLiquidity error:: ", err_63);
7440
7618
  return [3, 8];
7441
7619
  case 8: return [2, {
7442
7620
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7449,7 +7627,7 @@ var PerpetualsClient = (function () {
7449
7627
  this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
7450
7628
  if (createUserATA === void 0) { createUserATA = true; }
7451
7629
  return __awaiter(_this, void 0, void 0, function () {
7452
- 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_60;
7630
+ 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_64;
7453
7631
  return __generator(this, function (_f) {
7454
7632
  switch (_f.label) {
7455
7633
  case 0:
@@ -7546,8 +7724,8 @@ var PerpetualsClient = (function () {
7546
7724
  instructions.push(migrateStake);
7547
7725
  return [3, 8];
7548
7726
  case 7:
7549
- err_60 = _f.sent();
7550
- console.log("perpClient migrateStake error:: ", err_60);
7727
+ err_64 = _f.sent();
7728
+ console.log("perpClient migrateStake error:: ", err_64);
7551
7729
  return [3, 8];
7552
7730
  case 8: return [2, {
7553
7731
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7558,7 +7736,7 @@ var PerpetualsClient = (function () {
7558
7736
  });
7559
7737
  };
7560
7738
  this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7561
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_61;
7739
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_65;
7562
7740
  return __generator(this, function (_d) {
7563
7741
  switch (_d.label) {
7564
7742
  case 0:
@@ -7630,8 +7808,8 @@ var PerpetualsClient = (function () {
7630
7808
  instructions.push(migrateFlp);
7631
7809
  return [3, 4];
7632
7810
  case 3:
7633
- err_61 = _d.sent();
7634
- console.log("perpClient migrateFlp error:: ", err_61);
7811
+ err_65 = _d.sent();
7812
+ console.log("perpClient migrateFlp error:: ", err_65);
7635
7813
  return [3, 4];
7636
7814
  case 4: return [2, {
7637
7815
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7643,7 +7821,7 @@ var PerpetualsClient = (function () {
7643
7821
  this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
7644
7822
  if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7645
7823
  return __awaiter(_this, void 0, void 0, function () {
7646
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_62;
7824
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_66;
7647
7825
  return __generator(this, function (_d) {
7648
7826
  switch (_d.label) {
7649
7827
  case 0:
@@ -7700,8 +7878,8 @@ var PerpetualsClient = (function () {
7700
7878
  instructions.push(compoundingFee);
7701
7879
  return [3, 4];
7702
7880
  case 3:
7703
- err_62 = _d.sent();
7704
- console.log("perpClient compoundingFee error:: ", err_62);
7881
+ err_66 = _d.sent();
7882
+ console.log("perpClient compoundingFee error:: ", err_66);
7705
7883
  return [3, 4];
7706
7884
  case 4: return [2, {
7707
7885
  instructions: __spreadArray([], instructions, true),
@@ -7712,7 +7890,7 @@ var PerpetualsClient = (function () {
7712
7890
  });
7713
7891
  };
7714
7892
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7715
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_63;
7893
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_67;
7716
7894
  return __generator(this, function (_a) {
7717
7895
  switch (_a.label) {
7718
7896
  case 0:
@@ -7750,8 +7928,8 @@ var PerpetualsClient = (function () {
7750
7928
  instructions.push(renameFlp);
7751
7929
  return [3, 4];
7752
7930
  case 3:
7753
- err_63 = _a.sent();
7754
- console.log("perpClient renameFlp error:: ", err_63);
7931
+ err_67 = _a.sent();
7932
+ console.log("perpClient renameFlp error:: ", err_67);
7755
7933
  return [3, 4];
7756
7934
  case 4: return [2, {
7757
7935
  instructions: __spreadArray([], instructions, true),