flash-sdk 2.40.19 → 2.40.21

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.
@@ -5492,8 +5492,143 @@ var PerpetualsClient = (function () {
5492
5492
  }
5493
5493
  });
5494
5494
  }); };
5495
+ this.distributeTokenReward = function (amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5496
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, fundingTokenAccount, distributeTokenRewardInstruction, err_31;
5497
+ return __generator(this, function (_a) {
5498
+ switch (_a.label) {
5499
+ case 0:
5500
+ publicKey = this.provider.wallet.publicKey;
5501
+ preInstructions = [];
5502
+ instructions = [];
5503
+ postInstructions = [];
5504
+ additionalSigners = [];
5505
+ _a.label = 1;
5506
+ case 1:
5507
+ _a.trys.push([1, 3, , 4]);
5508
+ fundingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.tokenMint, publicKey, true);
5509
+ return [4, this.program.methods
5510
+ .distributeTokenReward({
5511
+ amount: amount,
5512
+ epochCount: epochCount,
5513
+ })
5514
+ .accounts({
5515
+ admin: publicKey,
5516
+ multisig: this.multisig.publicKey,
5517
+ perpetuals: this.perpetuals.publicKey,
5518
+ transferAuthority: poolConfig.transferAuthority,
5519
+ fundingTokenAccount: fundingTokenAccount,
5520
+ tokenVault: poolConfig.tokenVault,
5521
+ tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
5522
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5523
+ eventAuthority: this.eventAuthority.publicKey,
5524
+ program: this.programId
5525
+ })
5526
+ .instruction()];
5527
+ case 2:
5528
+ distributeTokenRewardInstruction = _a.sent();
5529
+ instructions.push(distributeTokenRewardInstruction);
5530
+ return [3, 4];
5531
+ case 3:
5532
+ err_31 = _a.sent();
5533
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_31);
5534
+ throw err_31;
5535
+ case 4: return [2, {
5536
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5537
+ additionalSigners: additionalSigners
5538
+ }];
5539
+ }
5540
+ });
5541
+ }); };
5542
+ this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5543
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_32;
5544
+ return __generator(this, function (_a) {
5545
+ switch (_a.label) {
5546
+ case 0:
5547
+ publicKey = this.provider.wallet.publicKey;
5548
+ preInstructions = [];
5549
+ instructions = [];
5550
+ postInstructions = [];
5551
+ additionalSigners = [];
5552
+ _a.label = 1;
5553
+ case 1:
5554
+ _a.trys.push([1, 3, , 4]);
5555
+ tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
5556
+ return [4, this.program.methods
5557
+ .setTokenReward({
5558
+ amount: amount,
5559
+ epochCount: epochCount,
5560
+ })
5561
+ .accounts({
5562
+ admin: publicKey,
5563
+ multisig: this.multisig.publicKey,
5564
+ tokenVault: poolConfig.tokenVault,
5565
+ tokenStakeAccount: tokenStakeAccount,
5566
+ eventAuthority: this.eventAuthority.publicKey,
5567
+ program: this.programId
5568
+ })
5569
+ .instruction()];
5570
+ case 2:
5571
+ setTokenRewardInstruction = _a.sent();
5572
+ instructions.push(setTokenRewardInstruction);
5573
+ return [3, 4];
5574
+ case 3:
5575
+ err_32 = _a.sent();
5576
+ console.log("perpClient setTokenRewardInstruction error:: ", err_32);
5577
+ throw err_32;
5578
+ case 4: return [2, {
5579
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5580
+ additionalSigners: additionalSigners
5581
+ }];
5582
+ }
5583
+ });
5584
+ }); };
5585
+ this.collectTokenReward = function (owner, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5586
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, collectTokenRewardInstruction, err_33;
5587
+ return __generator(this, function (_a) {
5588
+ switch (_a.label) {
5589
+ case 0:
5590
+ publicKey = this.provider.wallet.publicKey;
5591
+ preInstructions = [];
5592
+ instructions = [];
5593
+ postInstructions = [];
5594
+ additionalSigners = [];
5595
+ _a.label = 1;
5596
+ case 1:
5597
+ _a.trys.push([1, 3, , 4]);
5598
+ tokenStakeAccount = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from("token_stake"), owner.toBuffer()], this.programId)[0];
5599
+ userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.tokenMint, owner, true);
5600
+ return [4, this.program.methods
5601
+ .collectTokenReward({})
5602
+ .accounts({
5603
+ owner: owner,
5604
+ receivingTokenAccount: userTokenAccount,
5605
+ perpetuals: this.perpetuals.publicKey,
5606
+ transferAuthority: poolConfig.transferAuthority,
5607
+ tokenVault: poolConfig.tokenVault,
5608
+ tokenVaultTokenAccount: poolConfig.tokenVaultTokenAccount,
5609
+ tokenStakeAccount: tokenStakeAccount,
5610
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5611
+ eventAuthority: this.eventAuthority.publicKey,
5612
+ program: this.programId
5613
+ })
5614
+ .instruction()];
5615
+ case 2:
5616
+ collectTokenRewardInstruction = _a.sent();
5617
+ instructions.push(collectTokenRewardInstruction);
5618
+ return [3, 4];
5619
+ case 3:
5620
+ err_33 = _a.sent();
5621
+ console.log("perpClient collectTokenRewardInstruction error:: ", err_33);
5622
+ throw err_33;
5623
+ case 4: return [2, {
5624
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5625
+ additionalSigners: additionalSigners
5626
+ }];
5627
+ }
5628
+ });
5629
+ }); };
5495
5630
  this.initRewardVault = function (nftCount, rewardSymbol, collectionMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5496
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_31;
5631
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, nftTransferAuthority, initRewardVault, err_34;
5497
5632
  return __generator(this, function (_a) {
5498
5633
  switch (_a.label) {
5499
5634
  case 0:
@@ -5530,9 +5665,9 @@ var PerpetualsClient = (function () {
5530
5665
  instructions.push(initRewardVault);
5531
5666
  return [3, 4];
5532
5667
  case 3:
5533
- err_31 = _a.sent();
5534
- console.log("perpClient InitRewardVault error:: ", err_31);
5535
- throw err_31;
5668
+ err_34 = _a.sent();
5669
+ console.log("perpClient InitRewardVault error:: ", err_34);
5670
+ throw err_34;
5536
5671
  case 4: return [2, {
5537
5672
  instructions: __spreadArray([], instructions, true),
5538
5673
  additionalSigners: additionalSigners
@@ -5541,7 +5676,7 @@ var PerpetualsClient = (function () {
5541
5676
  });
5542
5677
  }); };
5543
5678
  this.distributeReward = function (rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5544
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_32;
5679
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, distributeReward, err_35;
5545
5680
  return __generator(this, function (_a) {
5546
5681
  switch (_a.label) {
5547
5682
  case 0:
@@ -5572,9 +5707,9 @@ var PerpetualsClient = (function () {
5572
5707
  instructions.push(distributeReward);
5573
5708
  return [3, 4];
5574
5709
  case 3:
5575
- err_32 = _a.sent();
5576
- console.log("perpClient distributeReward error:: ", err_32);
5577
- throw err_32;
5710
+ err_35 = _a.sent();
5711
+ console.log("perpClient distributeReward error:: ", err_35);
5712
+ throw err_35;
5578
5713
  case 4: return [2, {
5579
5714
  instructions: __spreadArray([], instructions, true),
5580
5715
  additionalSigners: additionalSigners
@@ -5585,7 +5720,7 @@ var PerpetualsClient = (function () {
5585
5720
  this.collectNftReward = function (rewardSymbol, poolConfig, nftMint, createUserATA) {
5586
5721
  if (createUserATA === void 0) { createUserATA = true; }
5587
5722
  return __awaiter(_this, void 0, void 0, function () {
5588
- var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_33;
5723
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, nftTokenAccount, metadataAccount, receivingTokenAccount, _a, rewardRecord, rewardVault, rewardTokenAccount, nftTransferAuthority, collectNftReward, err_36;
5589
5724
  return __generator(this, function (_b) {
5590
5725
  switch (_b.label) {
5591
5726
  case 0:
@@ -5635,8 +5770,8 @@ var PerpetualsClient = (function () {
5635
5770
  instructions.push(collectNftReward);
5636
5771
  return [3, 6];
5637
5772
  case 5:
5638
- err_33 = _b.sent();
5639
- throw err_33;
5773
+ err_36 = _b.sent();
5774
+ throw err_36;
5640
5775
  case 6: return [2, {
5641
5776
  instructions: __spreadArray([], instructions, true),
5642
5777
  additionalSigners: additionalSigners
@@ -5648,7 +5783,7 @@ var PerpetualsClient = (function () {
5648
5783
  this.collectAndDistributeFee = function (rewardSymbol, poolConfig, createUserATA, nftTradingAccount) {
5649
5784
  if (createUserATA === void 0) { createUserATA = true; }
5650
5785
  return __awaiter(_this, void 0, void 0, function () {
5651
- var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_34;
5786
+ var publicKey, rewardCustodyMint, rewardCustodyConfig, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, receivingTokenAccount, _a, tradingAccount, rewardVault, rewardTokenAccount, withdrawStakeInstruction, err_37;
5652
5787
  return __generator(this, function (_b) {
5653
5788
  switch (_b.label) {
5654
5789
  case 0:
@@ -5712,9 +5847,9 @@ var PerpetualsClient = (function () {
5712
5847
  instructions.push(withdrawStakeInstruction);
5713
5848
  return [3, 6];
5714
5849
  case 5:
5715
- err_34 = _b.sent();
5716
- console.log("perpClient withdrawStake error:: ", err_34);
5717
- throw err_34;
5850
+ err_37 = _b.sent();
5851
+ console.log("perpClient withdrawStake error:: ", err_37);
5852
+ throw err_37;
5718
5853
  case 6: return [2, {
5719
5854
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5720
5855
  additionalSigners: additionalSigners
@@ -5724,7 +5859,7 @@ var PerpetualsClient = (function () {
5724
5859
  });
5725
5860
  };
5726
5861
  this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5727
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_35;
5862
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_38;
5728
5863
  return __generator(this, function (_a) {
5729
5864
  switch (_a.label) {
5730
5865
  case 0:
@@ -5763,9 +5898,9 @@ var PerpetualsClient = (function () {
5763
5898
  instructions.push(setTriggerPrice);
5764
5899
  return [3, 4];
5765
5900
  case 3:
5766
- err_35 = _a.sent();
5767
- console.log("perpClient setTriggerPrice error:: ", err_35);
5768
- throw err_35;
5901
+ err_38 = _a.sent();
5902
+ console.log("perpClient setTriggerPrice error:: ", err_38);
5903
+ throw err_38;
5769
5904
  case 4: return [2, {
5770
5905
  instructions: __spreadArray([], instructions, true),
5771
5906
  additionalSigners: additionalSigners
@@ -5778,7 +5913,7 @@ var PerpetualsClient = (function () {
5778
5913
  if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
5779
5914
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5780
5915
  return __awaiter(_this, void 0, void 0, function () {
5781
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_36;
5916
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_39;
5782
5917
  return __generator(this, function (_b) {
5783
5918
  switch (_b.label) {
5784
5919
  case 0:
@@ -5839,9 +5974,9 @@ var PerpetualsClient = (function () {
5839
5974
  }
5840
5975
  return [3, 7];
5841
5976
  case 6:
5842
- err_36 = _b.sent();
5843
- console.log("perpClient forceClosePosition error:: ", err_36);
5844
- throw err_36;
5977
+ err_39 = _b.sent();
5978
+ console.log("perpClient forceClosePosition error:: ", err_39);
5979
+ throw err_39;
5845
5980
  case 7: return [2, {
5846
5981
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5847
5982
  additionalSigners: additionalSigners
@@ -5854,7 +5989,7 @@ var PerpetualsClient = (function () {
5854
5989
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
5855
5990
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5856
5991
  return __awaiter(_this, void 0, void 0, function () {
5857
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_37;
5992
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_40;
5858
5993
  return __generator(this, function (_c) {
5859
5994
  switch (_c.label) {
5860
5995
  case 0:
@@ -5958,9 +6093,9 @@ var PerpetualsClient = (function () {
5958
6093
  instructions.push(placeLimitOrder);
5959
6094
  return [3, 11];
5960
6095
  case 10:
5961
- err_37 = _c.sent();
5962
- console.log("perpClient placeLimitOrder error:: ", err_37);
5963
- throw err_37;
6096
+ err_40 = _c.sent();
6097
+ console.log("perpClient placeLimitOrder error:: ", err_40);
6098
+ throw err_40;
5964
6099
  case 11: return [2, {
5965
6100
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5966
6101
  additionalSigners: additionalSigners
@@ -5973,7 +6108,7 @@ var PerpetualsClient = (function () {
5973
6108
  if (createUserATA === void 0) { createUserATA = true; }
5974
6109
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5975
6110
  return __awaiter(_this, void 0, void 0, function () {
5976
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_38;
6111
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_41;
5977
6112
  return __generator(this, function (_b) {
5978
6113
  switch (_b.label) {
5979
6114
  case 0:
@@ -6060,9 +6195,9 @@ var PerpetualsClient = (function () {
6060
6195
  instructions.push(editLimitOrder);
6061
6196
  return [3, 8];
6062
6197
  case 7:
6063
- err_38 = _b.sent();
6064
- console.log("perpClient editLimitOrder error:: ", err_38);
6065
- throw err_38;
6198
+ err_41 = _b.sent();
6199
+ console.log("perpClient editLimitOrder error:: ", err_41);
6200
+ throw err_41;
6066
6201
  case 8: return [2, {
6067
6202
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6068
6203
  additionalSigners: additionalSigners
@@ -6076,7 +6211,7 @@ var PerpetualsClient = (function () {
6076
6211
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6077
6212
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6078
6213
  return __awaiter(_this, void 0, void 0, function () {
6079
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_39;
6214
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_42;
6080
6215
  return __generator(this, function (_a) {
6081
6216
  switch (_a.label) {
6082
6217
  case 0:
@@ -6125,9 +6260,9 @@ var PerpetualsClient = (function () {
6125
6260
  instructions.push(executeLimitOrder);
6126
6261
  return [3, 4];
6127
6262
  case 3:
6128
- err_39 = _a.sent();
6129
- console.log("perpClient executeLimitOrder error:: ", err_39);
6130
- throw err_39;
6263
+ err_42 = _a.sent();
6264
+ console.log("perpClient executeLimitOrder error:: ", err_42);
6265
+ throw err_42;
6131
6266
  case 4: return [2, {
6132
6267
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6133
6268
  additionalSigners: additionalSigners
@@ -6141,7 +6276,7 @@ var PerpetualsClient = (function () {
6141
6276
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6142
6277
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6143
6278
  return __awaiter(_this, void 0, void 0, function () {
6144
- var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_40;
6279
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_43;
6145
6280
  return __generator(this, function (_a) {
6146
6281
  switch (_a.label) {
6147
6282
  case 0:
@@ -6193,9 +6328,9 @@ var PerpetualsClient = (function () {
6193
6328
  instructions.push(executeLimitWithSwap);
6194
6329
  return [3, 4];
6195
6330
  case 3:
6196
- err_40 = _a.sent();
6197
- console.log("perpClient executeLimitWithSwap error:: ", err_40);
6198
- throw err_40;
6331
+ err_43 = _a.sent();
6332
+ console.log("perpClient executeLimitWithSwap error:: ", err_43);
6333
+ throw err_43;
6199
6334
  case 4: return [2, {
6200
6335
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6201
6336
  additionalSigners: additionalSigners
@@ -6205,7 +6340,7 @@ var PerpetualsClient = (function () {
6205
6340
  });
6206
6341
  };
6207
6342
  this.placeTriggerOrder = function (targetSymbol, collateralSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, receiveCustodyId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6208
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_41;
6343
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_44;
6209
6344
  return __generator(this, function (_a) {
6210
6345
  switch (_a.label) {
6211
6346
  case 0:
@@ -6252,9 +6387,9 @@ var PerpetualsClient = (function () {
6252
6387
  instructions.push(placeTriggerOrder);
6253
6388
  return [3, 4];
6254
6389
  case 3:
6255
- err_41 = _a.sent();
6256
- console.log("perpClient placeTriggerOrder error:: ", err_41);
6257
- throw err_41;
6390
+ err_44 = _a.sent();
6391
+ console.log("perpClient placeTriggerOrder error:: ", err_44);
6392
+ throw err_44;
6258
6393
  case 4: return [2, {
6259
6394
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6260
6395
  additionalSigners: additionalSigners
@@ -6263,7 +6398,7 @@ var PerpetualsClient = (function () {
6263
6398
  });
6264
6399
  }); };
6265
6400
  this.editTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6266
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_42;
6401
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_45;
6267
6402
  return __generator(this, function (_a) {
6268
6403
  switch (_a.label) {
6269
6404
  case 0:
@@ -6308,9 +6443,9 @@ var PerpetualsClient = (function () {
6308
6443
  instructions.push(editTriggerOrder);
6309
6444
  return [3, 4];
6310
6445
  case 3:
6311
- err_42 = _a.sent();
6312
- console.log("perpClient editTriggerOrder error:: ", err_42);
6313
- throw err_42;
6446
+ err_45 = _a.sent();
6447
+ console.log("perpClient editTriggerOrder error:: ", err_45);
6448
+ throw err_45;
6314
6449
  case 4: return [2, {
6315
6450
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6316
6451
  additionalSigners: additionalSigners
@@ -6319,7 +6454,7 @@ var PerpetualsClient = (function () {
6319
6454
  });
6320
6455
  }); };
6321
6456
  this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6322
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_43;
6457
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_46;
6323
6458
  return __generator(this, function (_a) {
6324
6459
  switch (_a.label) {
6325
6460
  case 0:
@@ -6352,9 +6487,9 @@ var PerpetualsClient = (function () {
6352
6487
  instructions.push(cancelTriggerOrder);
6353
6488
  return [3, 4];
6354
6489
  case 3:
6355
- err_43 = _a.sent();
6356
- console.log("perpClient cancelTriggerOrder error:: ", err_43);
6357
- throw err_43;
6490
+ err_46 = _a.sent();
6491
+ console.log("perpClient cancelTriggerOrder error:: ", err_46);
6492
+ throw err_46;
6358
6493
  case 4: return [2, {
6359
6494
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6360
6495
  additionalSigners: additionalSigners
@@ -6369,7 +6504,7 @@ var PerpetualsClient = (function () {
6369
6504
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6370
6505
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6371
6506
  return __awaiter(_this, void 0, void 0, function () {
6372
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_44;
6507
+ 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;
6373
6508
  return __generator(this, function (_d) {
6374
6509
  switch (_d.label) {
6375
6510
  case 0:
@@ -6466,9 +6601,9 @@ var PerpetualsClient = (function () {
6466
6601
  instructions.push(executeTriggerWithSwap);
6467
6602
  return [3, 10];
6468
6603
  case 9:
6469
- err_44 = _d.sent();
6470
- console.log("perpClient executeTriggerWithSwap error:: ", err_44);
6471
- throw err_44;
6604
+ err_47 = _d.sent();
6605
+ console.log("perpClient executeTriggerWithSwap error:: ", err_47);
6606
+ throw err_47;
6472
6607
  case 10: return [2, {
6473
6608
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6474
6609
  additionalSigners: additionalSigners
@@ -6484,7 +6619,7 @@ var PerpetualsClient = (function () {
6484
6619
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6485
6620
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
6486
6621
  return __awaiter(_this, void 0, void 0, function () {
6487
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_45;
6622
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_48;
6488
6623
  return __generator(this, function (_b) {
6489
6624
  switch (_b.label) {
6490
6625
  case 0:
@@ -6550,9 +6685,9 @@ var PerpetualsClient = (function () {
6550
6685
  instructions.push(executeTriggerOrder);
6551
6686
  return [3, 8];
6552
6687
  case 7:
6553
- err_45 = _b.sent();
6554
- console.log("perpClient executeTriggerOrder error:: ", err_45);
6555
- throw err_45;
6688
+ err_48 = _b.sent();
6689
+ console.log("perpClient executeTriggerOrder error:: ", err_48);
6690
+ throw err_48;
6556
6691
  case 8: return [2, {
6557
6692
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6558
6693
  additionalSigners: additionalSigners
@@ -6562,7 +6697,7 @@ var PerpetualsClient = (function () {
6562
6697
  });
6563
6698
  };
6564
6699
  this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6565
- var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_46;
6700
+ var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_49;
6566
6701
  return __generator(this, function (_a) {
6567
6702
  switch (_a.label) {
6568
6703
  case 0:
@@ -6592,9 +6727,9 @@ var PerpetualsClient = (function () {
6592
6727
  instructions.push(migrateTriggerOrder);
6593
6728
  return [3, 4];
6594
6729
  case 3:
6595
- err_46 = _a.sent();
6596
- console.log("perpClient migrateTriggerOrder error:: ", err_46);
6597
- throw err_46;
6730
+ err_49 = _a.sent();
6731
+ console.log("perpClient migrateTriggerOrder error:: ", err_49);
6732
+ throw err_49;
6598
6733
  case 4: return [2, {
6599
6734
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6600
6735
  additionalSigners: additionalSigners
@@ -6603,7 +6738,7 @@ var PerpetualsClient = (function () {
6603
6738
  });
6604
6739
  }); };
6605
6740
  this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6606
- var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_47;
6741
+ var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_50;
6607
6742
  return __generator(this, function (_a) {
6608
6743
  switch (_a.label) {
6609
6744
  case 0:
@@ -6632,15 +6767,15 @@ var PerpetualsClient = (function () {
6632
6767
  console.log(getPositionData);
6633
6768
  return [2, getPositionData];
6634
6769
  case 3:
6635
- err_47 = _a.sent();
6636
- console.log("perpClient setPool error:: ", err_47);
6637
- throw err_47;
6770
+ err_50 = _a.sent();
6771
+ console.log("perpClient setPool error:: ", err_50);
6772
+ throw err_50;
6638
6773
  case 4: return [2];
6639
6774
  }
6640
6775
  });
6641
6776
  }); };
6642
6777
  this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6643
- var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_48;
6778
+ var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_51;
6644
6779
  return __generator(this, function (_a) {
6645
6780
  switch (_a.label) {
6646
6781
  case 0:
@@ -6673,9 +6808,9 @@ var PerpetualsClient = (function () {
6673
6808
  instructions.push(withdrawFeesIx);
6674
6809
  return [3, 5];
6675
6810
  case 4:
6676
- err_48 = _a.sent();
6677
- console.log("perpClient setPool error:: ", err_48);
6678
- throw err_48;
6811
+ err_51 = _a.sent();
6812
+ console.log("perpClient setPool error:: ", err_51);
6813
+ throw err_51;
6679
6814
  case 5: return [2, {
6680
6815
  instructions: __spreadArray([], instructions, true),
6681
6816
  additionalSigners: additionalSigners
@@ -6684,7 +6819,7 @@ var PerpetualsClient = (function () {
6684
6819
  });
6685
6820
  }); };
6686
6821
  this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
6687
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_49;
6822
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_52;
6688
6823
  return __generator(this, function (_a) {
6689
6824
  switch (_a.label) {
6690
6825
  case 0:
@@ -6711,9 +6846,9 @@ var PerpetualsClient = (function () {
6711
6846
  instructions.push(setPermissionsInstruction);
6712
6847
  return [3, 4];
6713
6848
  case 3:
6714
- err_49 = _a.sent();
6715
- console.log("perpClient setPool error:: ", err_49);
6716
- throw err_49;
6849
+ err_52 = _a.sent();
6850
+ console.log("perpClient setPool error:: ", err_52);
6851
+ throw err_52;
6717
6852
  case 4: return [2, {
6718
6853
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6719
6854
  additionalSigners: additionalSigners
@@ -6722,7 +6857,7 @@ var PerpetualsClient = (function () {
6722
6857
  });
6723
6858
  }); };
6724
6859
  this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6725
- var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_50;
6860
+ var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_53;
6726
6861
  var _f;
6727
6862
  return __generator(this, function (_g) {
6728
6863
  switch (_g.label) {
@@ -6782,9 +6917,9 @@ var PerpetualsClient = (function () {
6782
6917
  instructions.push(reimburse);
6783
6918
  return [3, 5];
6784
6919
  case 4:
6785
- err_50 = _g.sent();
6786
- console.log("perpClient setPool error:: ", err_50);
6787
- throw err_50;
6920
+ err_53 = _g.sent();
6921
+ console.log("perpClient setPool error:: ", err_53);
6922
+ throw err_53;
6788
6923
  case 5: return [2, {
6789
6924
  instructions: __spreadArray([], instructions, true),
6790
6925
  additionalSigners: additionalSigners
@@ -6793,7 +6928,7 @@ var PerpetualsClient = (function () {
6793
6928
  });
6794
6929
  }); };
6795
6930
  this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6796
- var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_51;
6931
+ var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_54;
6797
6932
  return __generator(this, function (_a) {
6798
6933
  switch (_a.label) {
6799
6934
  case 0:
@@ -6826,9 +6961,9 @@ var PerpetualsClient = (function () {
6826
6961
  instructions.push(setInternalOraclePrice);
6827
6962
  return [3, 4];
6828
6963
  case 3:
6829
- err_51 = _a.sent();
6830
- console.log("perpClient setInternalOracleAccount error:: ", err_51);
6831
- throw err_51;
6964
+ err_54 = _a.sent();
6965
+ console.log("perpClient setInternalOracleAccount error:: ", err_54);
6966
+ throw err_54;
6832
6967
  case 4: return [2, {
6833
6968
  instructions: __spreadArray([], instructions, true),
6834
6969
  additionalSigners: additionalSigners
@@ -6840,7 +6975,7 @@ var PerpetualsClient = (function () {
6840
6975
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6841
6976
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6842
6977
  return __awaiter(_this, void 0, void 0, function () {
6843
- 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_52;
6978
+ 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;
6844
6979
  return __generator(this, function (_e) {
6845
6980
  switch (_e.label) {
6846
6981
  case 0:
@@ -6963,8 +7098,8 @@ var PerpetualsClient = (function () {
6963
7098
  instructions.push(addCompoundingLiquidity);
6964
7099
  return [3, 10];
6965
7100
  case 9:
6966
- err_52 = _e.sent();
6967
- console.log("perpClient addCompoundingLiquidity error:: ", err_52);
7101
+ err_55 = _e.sent();
7102
+ console.log("perpClient addCompoundingLiquidity error:: ", err_55);
6968
7103
  return [3, 10];
6969
7104
  case 10: return [2, {
6970
7105
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -6978,7 +7113,7 @@ var PerpetualsClient = (function () {
6978
7113
  if (createUserATA === void 0) { createUserATA = true; }
6979
7114
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6980
7115
  return __awaiter(_this, void 0, void 0, function () {
6981
- 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_53;
7116
+ 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;
6982
7117
  return __generator(this, function (_e) {
6983
7118
  switch (_e.label) {
6984
7119
  case 0:
@@ -7085,8 +7220,8 @@ var PerpetualsClient = (function () {
7085
7220
  instructions.push(removeCompoundingLiquidity);
7086
7221
  return [3, 8];
7087
7222
  case 7:
7088
- err_53 = _e.sent();
7089
- console.log("perpClient removeCompoundingLiquidity error:: ", err_53);
7223
+ err_56 = _e.sent();
7224
+ console.log("perpClient removeCompoundingLiquidity error:: ", err_56);
7090
7225
  return [3, 8];
7091
7226
  case 8: return [2, {
7092
7227
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7099,7 +7234,7 @@ var PerpetualsClient = (function () {
7099
7234
  this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
7100
7235
  if (createUserATA === void 0) { createUserATA = true; }
7101
7236
  return __awaiter(_this, void 0, void 0, function () {
7102
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, migrateStake, err_54;
7237
+ 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;
7103
7238
  return __generator(this, function (_e) {
7104
7239
  switch (_e.label) {
7105
7240
  case 0:
@@ -7180,8 +7315,8 @@ var PerpetualsClient = (function () {
7180
7315
  instructions.push(migrateStake);
7181
7316
  return [3, 6];
7182
7317
  case 5:
7183
- err_54 = _e.sent();
7184
- console.log("perpClient migrateStake error:: ", err_54);
7318
+ err_57 = _e.sent();
7319
+ console.log("perpClient migrateStake error:: ", err_57);
7185
7320
  return [3, 6];
7186
7321
  case 6: return [2, {
7187
7322
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7192,7 +7327,7 @@ var PerpetualsClient = (function () {
7192
7327
  });
7193
7328
  };
7194
7329
  this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7195
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_55;
7330
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_58;
7196
7331
  return __generator(this, function (_d) {
7197
7332
  switch (_d.label) {
7198
7333
  case 0:
@@ -7264,8 +7399,8 @@ var PerpetualsClient = (function () {
7264
7399
  instructions.push(migrateFlp);
7265
7400
  return [3, 4];
7266
7401
  case 3:
7267
- err_55 = _d.sent();
7268
- console.log("perpClient migrateFlp error:: ", err_55);
7402
+ err_58 = _d.sent();
7403
+ console.log("perpClient migrateFlp error:: ", err_58);
7269
7404
  return [3, 4];
7270
7405
  case 4: return [2, {
7271
7406
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -7277,7 +7412,7 @@ var PerpetualsClient = (function () {
7277
7412
  this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
7278
7413
  if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
7279
7414
  return __awaiter(_this, void 0, void 0, function () {
7280
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_56;
7415
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_59;
7281
7416
  return __generator(this, function (_d) {
7282
7417
  switch (_d.label) {
7283
7418
  case 0:
@@ -7334,8 +7469,8 @@ var PerpetualsClient = (function () {
7334
7469
  instructions.push(compoundingFee);
7335
7470
  return [3, 4];
7336
7471
  case 3:
7337
- err_56 = _d.sent();
7338
- console.log("perpClient compoundingFee error:: ", err_56);
7472
+ err_59 = _d.sent();
7473
+ console.log("perpClient compoundingFee error:: ", err_59);
7339
7474
  return [3, 4];
7340
7475
  case 4: return [2, {
7341
7476
  instructions: __spreadArray([], instructions, true),
@@ -7346,7 +7481,7 @@ var PerpetualsClient = (function () {
7346
7481
  });
7347
7482
  };
7348
7483
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7349
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_57;
7484
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_60;
7350
7485
  return __generator(this, function (_a) {
7351
7486
  switch (_a.label) {
7352
7487
  case 0:
@@ -7384,8 +7519,8 @@ var PerpetualsClient = (function () {
7384
7519
  instructions.push(renameFlp);
7385
7520
  return [3, 4];
7386
7521
  case 3:
7387
- err_57 = _a.sent();
7388
- console.log("perpClient renameFlp error:: ", err_57);
7522
+ err_60 = _a.sent();
7523
+ console.log("perpClient renameFlp error:: ", err_60);
7389
7524
  return [3, 4];
7390
7525
  case 4: return [2, {
7391
7526
  instructions: __spreadArray([], instructions, true),