flash-sdk 2.21.0 → 2.22.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.
@@ -5420,7 +5420,7 @@ var PerpetualsClient = (function () {
5420
5420
  });
5421
5421
  });
5422
5422
  };
5423
- this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
5423
+ this.editLimitOrder = function (targetSymbol, collateralSymbol, reserveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, receiveCustodyId, poolConfig, createUserATA, ephemeralSignerPubkey) {
5424
5424
  if (createUserATA === void 0) { createUserATA = true; }
5425
5425
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5426
5426
  return __awaiter(_this, void 0, void 0, function () {
@@ -5440,7 +5440,7 @@ var PerpetualsClient = (function () {
5440
5440
  _b.label = 1;
5441
5441
  case 1:
5442
5442
  _b.trys.push([1, 7, , 8]);
5443
- if (!(collateralSymbol == 'SOL')) return [3, 2];
5443
+ if (!(reserveSymbol == 'SOL')) return [3, 2];
5444
5444
  lamports = (this.minimumBalanceForRentExemptAccountLamports);
5445
5445
  if (!ephemeralSignerPubkey) {
5446
5446
  wrappedSolAccount = new web3_js_1.Keypair();
@@ -5461,7 +5461,7 @@ var PerpetualsClient = (function () {
5461
5461
  ];
5462
5462
  return [3, 5];
5463
5463
  case 2:
5464
- userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, publicKey, true);
5464
+ userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey, publicKey, true);
5465
5465
  _a = createUserATA;
5466
5466
  if (!_a) return [3, 4];
5467
5467
  return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
@@ -5470,7 +5470,7 @@ var PerpetualsClient = (function () {
5470
5470
  _b.label = 4;
5471
5471
  case 4:
5472
5472
  if (_a) {
5473
- preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
5473
+ preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userReceivingTokenAccount, publicKey, poolConfig.getTokenFromSymbol(reserveSymbol).mintKey));
5474
5474
  }
5475
5475
  _b.label = 5;
5476
5476
  case 5:
@@ -5482,7 +5482,8 @@ var PerpetualsClient = (function () {
5482
5482
  limitPrice: limitPrice,
5483
5483
  sizeAmount: sizeAmount,
5484
5484
  stopLossPrice: stopLossPrice,
5485
- takeProfitPrice: takeProfitPrice
5485
+ takeProfitPrice: takeProfitPrice,
5486
+ receiveCustodyId: receiveCustodyId
5486
5487
  })
5487
5488
  .accounts({
5488
5489
  owner: publicKey,
@@ -5498,7 +5499,7 @@ var PerpetualsClient = (function () {
5498
5499
  reserveCustody: reserveCustodyConfig.custodyAccount,
5499
5500
  reserveOracleAccount: this.useExtOracleAccount ? reserveCustodyConfig.extOracleAccount : reserveCustodyConfig.intOracleAccount,
5500
5501
  reserveCustodyTokenAccount: reserveCustodyConfig.tokenAccount,
5501
- receivingAccount: collateralSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
5502
+ receivingAccount: reserveSymbol == 'SOL' ? (ephemeralSignerPubkey ? ephemeralSignerPubkey : wrappedSolAccount.publicKey) : userReceivingTokenAccount,
5502
5503
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5503
5504
  eventAuthority: this.eventAuthority.publicKey,
5504
5505
  program: this.programId,
@@ -5583,8 +5584,88 @@ var PerpetualsClient = (function () {
5583
5584
  });
5584
5585
  });
5585
5586
  };
5587
+ this.executeLimitWithSwap = function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, nftTradingAccount, nftReferralAccount, nftRebateTokenAccount) {
5588
+ if (nftTradingAccount === void 0) { nftTradingAccount = web3_js_1.PublicKey.default; }
5589
+ if (nftReferralAccount === void 0) { nftReferralAccount = web3_js_1.PublicKey.default; }
5590
+ if (nftRebateTokenAccount === void 0) { nftRebateTokenAccount = web3_js_1.PublicKey.default; }
5591
+ return __awaiter(_this, void 0, void 0, function () {
5592
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody, positionAccount, orderAccount, executeLimitWithSwap, err_28;
5593
+ return __generator(this, function (_b) {
5594
+ switch (_b.label) {
5595
+ case 0:
5596
+ publicKey = this.provider.wallet.publicKey;
5597
+ targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
5598
+ collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
5599
+ reserveCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey); });
5600
+ marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
5601
+ preInstructions = [];
5602
+ instructions = [];
5603
+ postInstructions = [];
5604
+ additionalSigners = [];
5605
+ custodyAccountMetas = [];
5606
+ custodyOracleAccountMetas = [];
5607
+ for (_i = 0, _a = poolConfig.custodies; _i < _a.length; _i++) {
5608
+ custody = _a[_i];
5609
+ custodyAccountMetas.push({
5610
+ pubkey: custody.custodyAccount,
5611
+ isSigner: false,
5612
+ isWritable: false,
5613
+ });
5614
+ custodyOracleAccountMetas.push({
5615
+ pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
5616
+ isSigner: false,
5617
+ isWritable: false,
5618
+ });
5619
+ }
5620
+ _b.label = 1;
5621
+ case 1:
5622
+ _b.trys.push([1, 3, , 4]);
5623
+ positionAccount = poolConfig.getPositionFromMarketPk(userPubkey, marketAccount);
5624
+ orderAccount = poolConfig.getOrderFromMarketPk(userPubkey, marketAccount);
5625
+ return [4, this.program.methods
5626
+ .executeLimitWithSwap({
5627
+ orderId: orderId,
5628
+ privilege: privilege
5629
+ })
5630
+ .accounts({
5631
+ feePayer: publicKey,
5632
+ perpetuals: poolConfig.perpetuals,
5633
+ pool: poolConfig.poolAddress,
5634
+ reserveCustody: reserveCustodyConfig.custodyAccount,
5635
+ reserveCustodyOracleAccount: this.useExtOracleAccount ? reserveCustodyConfig.extOracleAccount : reserveCustodyConfig.intOracleAccount,
5636
+ position: positionAccount,
5637
+ order: orderAccount,
5638
+ market: marketAccount,
5639
+ targetCustody: targetCustodyConfig.custodyAccount,
5640
+ targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
5641
+ collateralCustody: collateralCustodyConfig.custodyAccount,
5642
+ collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
5643
+ systemProgram: web3_js_1.SystemProgram.programId,
5644
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5645
+ eventAuthority: this.eventAuthority.publicKey,
5646
+ program: this.programId,
5647
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
5648
+ })
5649
+ .remainingAccounts(__spreadArray(__spreadArray(__spreadArray([], (0, getNftAccounts_1.getNftAccounts)(nftTradingAccount, nftReferralAccount, nftRebateTokenAccount, privilege), true), custodyAccountMetas, true), custodyOracleAccountMetas, true))
5650
+ .instruction()];
5651
+ case 2:
5652
+ executeLimitWithSwap = _b.sent();
5653
+ instructions.push(executeLimitWithSwap);
5654
+ return [3, 4];
5655
+ case 3:
5656
+ err_28 = _b.sent();
5657
+ console.log("perpClient executeLimitWithSwap error:: ", err_28);
5658
+ throw err_28;
5659
+ case 4: return [2, {
5660
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5661
+ additionalSigners: additionalSigners
5662
+ }];
5663
+ }
5664
+ });
5665
+ });
5666
+ };
5586
5667
  this.placeTriggerOrder = function (targetSymbol, collateralSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, receiveCustodyId, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5587
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_28;
5668
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_29;
5588
5669
  return __generator(this, function (_a) {
5589
5670
  switch (_a.label) {
5590
5671
  case 0:
@@ -5631,9 +5712,9 @@ var PerpetualsClient = (function () {
5631
5712
  instructions.push(placeTriggerOrder);
5632
5713
  return [3, 4];
5633
5714
  case 3:
5634
- err_28 = _a.sent();
5635
- console.log("perpClient placeTriggerOrder error:: ", err_28);
5636
- throw err_28;
5715
+ err_29 = _a.sent();
5716
+ console.log("perpClient placeTriggerOrder error:: ", err_29);
5717
+ throw err_29;
5637
5718
  case 4: return [2, {
5638
5719
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5639
5720
  additionalSigners: additionalSigners
@@ -5642,7 +5723,7 @@ var PerpetualsClient = (function () {
5642
5723
  });
5643
5724
  }); };
5644
5725
  this.editTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5645
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_29;
5726
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_30;
5646
5727
  return __generator(this, function (_a) {
5647
5728
  switch (_a.label) {
5648
5729
  case 0:
@@ -5687,9 +5768,9 @@ var PerpetualsClient = (function () {
5687
5768
  instructions.push(editTriggerOrder);
5688
5769
  return [3, 4];
5689
5770
  case 3:
5690
- err_29 = _a.sent();
5691
- console.log("perpClient editTriggerOrder error:: ", err_29);
5692
- throw err_29;
5771
+ err_30 = _a.sent();
5772
+ console.log("perpClient editTriggerOrder error:: ", err_30);
5773
+ throw err_30;
5693
5774
  case 4: return [2, {
5694
5775
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5695
5776
  additionalSigners: additionalSigners
@@ -5698,7 +5779,7 @@ var PerpetualsClient = (function () {
5698
5779
  });
5699
5780
  }); };
5700
5781
  this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5701
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_30;
5782
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_31;
5702
5783
  return __generator(this, function (_a) {
5703
5784
  switch (_a.label) {
5704
5785
  case 0:
@@ -5731,9 +5812,9 @@ var PerpetualsClient = (function () {
5731
5812
  instructions.push(cancelTriggerOrder);
5732
5813
  return [3, 4];
5733
5814
  case 3:
5734
- err_30 = _a.sent();
5735
- console.log("perpClient cancelTriggerOrder error:: ", err_30);
5736
- throw err_30;
5815
+ err_31 = _a.sent();
5816
+ console.log("perpClient cancelTriggerOrder error:: ", err_31);
5817
+ throw err_31;
5737
5818
  case 4: return [2, {
5738
5819
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5739
5820
  additionalSigners: additionalSigners
@@ -5741,11 +5822,121 @@ var PerpetualsClient = (function () {
5741
5822
  }
5742
5823
  });
5743
5824
  }); };
5825
+ this.executeTriggerWithSwap = function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, poolConfig, createUserATA, ephemeralSignerPubkey) {
5826
+ if (createUserATA === void 0) { createUserATA = true; }
5827
+ if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5828
+ return __awaiter(_this, void 0, void 0, function () {
5829
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _i, _c, custody, executeTriggerWithSwap, err_32;
5830
+ return __generator(this, function (_d) {
5831
+ switch (_d.label) {
5832
+ case 0:
5833
+ payerPubkey = this.provider.wallet.publicKey;
5834
+ targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
5835
+ collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
5836
+ receivingCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(receivingSymbol).mintKey); });
5837
+ marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
5838
+ preInstructions = [];
5839
+ instructions = [];
5840
+ postInstructions = [];
5841
+ additionalSigners = [];
5842
+ _d.label = 1;
5843
+ case 1:
5844
+ _d.trys.push([1, 9, , 10]);
5845
+ if (!false) return [3, 2];
5846
+ return [3, 7];
5847
+ case 2:
5848
+ userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(receivingSymbol).mintKey, owner, true);
5849
+ _a = createUserATA;
5850
+ if (!_a) return [3, 4];
5851
+ return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
5852
+ case 3:
5853
+ _a = !(_d.sent());
5854
+ _d.label = 4;
5855
+ case 4:
5856
+ if (_a) {
5857
+ preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, owner, poolConfig.getTokenFromSymbol(receivingSymbol).mintKey));
5858
+ }
5859
+ userReceivingTokenAccountCollateral = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, owner, true);
5860
+ _b = createUserATA;
5861
+ if (!_b) return [3, 6];
5862
+ return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccountCollateral, this.provider.connection)];
5863
+ case 5:
5864
+ _b = !(_d.sent());
5865
+ _d.label = 6;
5866
+ case 6:
5867
+ if (_b) {
5868
+ preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccountCollateral, owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey));
5869
+ }
5870
+ _d.label = 7;
5871
+ case 7:
5872
+ positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
5873
+ orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
5874
+ custodyAccountMetas = [];
5875
+ custodyOracleAccountMetas = [];
5876
+ for (_i = 0, _c = poolConfig.custodies; _i < _c.length; _i++) {
5877
+ custody = _c[_i];
5878
+ custodyAccountMetas.push({
5879
+ pubkey: custody.custodyAccount,
5880
+ isSigner: false,
5881
+ isWritable: false,
5882
+ });
5883
+ custodyOracleAccountMetas.push({
5884
+ pubkey: this.useExtOracleAccount ? custody.extOracleAccount : custody.intOracleAccount,
5885
+ isSigner: false,
5886
+ isWritable: false,
5887
+ });
5888
+ }
5889
+ return [4, this.program.methods
5890
+ .executeTriggerWithSwap({
5891
+ isStopLoss: isStopLoss,
5892
+ orderId: orderId
5893
+ })
5894
+ .accounts({
5895
+ feePayer: payerPubkey,
5896
+ receivingAccount: userReceivingTokenAccount,
5897
+ collateralAccount: userReceivingTokenAccountCollateral,
5898
+ transferAuthority: poolConfig.transferAuthority,
5899
+ perpetuals: poolConfig.perpetuals,
5900
+ pool: poolConfig.poolAddress,
5901
+ position: positionAccount,
5902
+ order: orderAccount,
5903
+ market: marketAccount,
5904
+ targetCustody: targetCustodyConfig.custodyAccount,
5905
+ targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
5906
+ collateralCustody: collateralCustodyConfig.custodyAccount,
5907
+ collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
5908
+ collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
5909
+ dispensingCustody: receivingCustodyConfig.custodyAccount,
5910
+ dispensingOracleAccount: this.useExtOracleAccount ? receivingCustodyConfig.extOracleAccount : receivingCustodyConfig.intOracleAccount,
5911
+ dispensingCustodyTokenAccount: receivingCustodyConfig.tokenAccount,
5912
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5913
+ eventAuthority: this.eventAuthority.publicKey,
5914
+ program: this.programId,
5915
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
5916
+ })
5917
+ .remainingAccounts(__spreadArray(__spreadArray([], custodyAccountMetas, true), custodyOracleAccountMetas, true))
5918
+ .instruction()];
5919
+ case 8:
5920
+ executeTriggerWithSwap = _d.sent();
5921
+ instructions.push(executeTriggerWithSwap);
5922
+ return [3, 10];
5923
+ case 9:
5924
+ err_32 = _d.sent();
5925
+ console.log("perpClient executeTriggerWithSwap error:: ", err_32);
5926
+ throw err_32;
5927
+ case 10: return [2, {
5928
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5929
+ additionalSigners: additionalSigners
5930
+ }];
5931
+ }
5932
+ });
5933
+ });
5934
+ };
5744
5935
  this.executeTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig, createUserATA, ephemeralSignerPubkey) {
5745
5936
  if (createUserATA === void 0) { createUserATA = true; }
5746
5937
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5747
5938
  return __awaiter(_this, void 0, void 0, function () {
5748
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_31;
5939
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_33;
5749
5940
  return __generator(this, function (_b) {
5750
5941
  switch (_b.label) {
5751
5942
  case 0:
@@ -5808,9 +5999,9 @@ var PerpetualsClient = (function () {
5808
5999
  instructions.push(executeTriggerOrder);
5809
6000
  return [3, 8];
5810
6001
  case 7:
5811
- err_31 = _b.sent();
5812
- console.log("perpClient executeTriggerOrder error:: ", err_31);
5813
- throw err_31;
6002
+ err_33 = _b.sent();
6003
+ console.log("perpClient executeTriggerOrder error:: ", err_33);
6004
+ throw err_33;
5814
6005
  case 8: return [2, {
5815
6006
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5816
6007
  additionalSigners: additionalSigners
@@ -5819,15 +6010,12 @@ var PerpetualsClient = (function () {
5819
6010
  });
5820
6011
  });
5821
6012
  };
5822
- this.migrateTriggerOrder = function (owner, targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5823
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_32;
6013
+ this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6014
+ var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_34;
5824
6015
  return __generator(this, function (_a) {
5825
6016
  switch (_a.label) {
5826
6017
  case 0:
5827
6018
  payerPubkey = this.provider.wallet.publicKey;
5828
- targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
5829
- collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
5830
- marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
5831
6019
  preInstructions = [];
5832
6020
  instructions = [];
5833
6021
  postInstructions = [];
@@ -5853,9 +6041,9 @@ var PerpetualsClient = (function () {
5853
6041
  instructions.push(migrateTriggerOrder);
5854
6042
  return [3, 4];
5855
6043
  case 3:
5856
- err_32 = _a.sent();
5857
- console.log("perpClient migrateTriggerOrder error:: ", err_32);
5858
- throw err_32;
6044
+ err_34 = _a.sent();
6045
+ console.log("perpClient migrateTriggerOrder error:: ", err_34);
6046
+ throw err_34;
5859
6047
  case 4: return [2, {
5860
6048
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5861
6049
  additionalSigners: additionalSigners
@@ -5864,7 +6052,7 @@ var PerpetualsClient = (function () {
5864
6052
  });
5865
6053
  }); };
5866
6054
  this.getPositionData = function (position, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5867
- var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_33;
6055
+ var marketConfig, targetCustodyConfig, collateralCustodyConfig, getPositionData, err_35;
5868
6056
  return __generator(this, function (_a) {
5869
6057
  switch (_a.label) {
5870
6058
  case 0:
@@ -5893,15 +6081,15 @@ var PerpetualsClient = (function () {
5893
6081
  console.log(getPositionData);
5894
6082
  return [2, getPositionData];
5895
6083
  case 3:
5896
- err_33 = _a.sent();
5897
- console.log("perpClient setPool error:: ", err_33);
5898
- throw err_33;
6084
+ err_35 = _a.sent();
6085
+ console.log("perpClient setPool error:: ", err_35);
6086
+ throw err_35;
5899
6087
  case 4: return [2];
5900
6088
  }
5901
6089
  });
5902
6090
  }); };
5903
6091
  this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5904
- var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_34;
6092
+ var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_36;
5905
6093
  return __generator(this, function (_a) {
5906
6094
  switch (_a.label) {
5907
6095
  case 0:
@@ -5934,9 +6122,9 @@ var PerpetualsClient = (function () {
5934
6122
  instructions.push(withdrawFeesIx);
5935
6123
  return [3, 5];
5936
6124
  case 4:
5937
- err_34 = _a.sent();
5938
- console.log("perpClient setPool error:: ", err_34);
5939
- throw err_34;
6125
+ err_36 = _a.sent();
6126
+ console.log("perpClient setPool error:: ", err_36);
6127
+ throw err_36;
5940
6128
  case 5: return [2, {
5941
6129
  instructions: __spreadArray([], instructions, true),
5942
6130
  additionalSigners: additionalSigners
@@ -5945,7 +6133,7 @@ var PerpetualsClient = (function () {
5945
6133
  });
5946
6134
  }); };
5947
6135
  this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
5948
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_35;
6136
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_37;
5949
6137
  return __generator(this, function (_a) {
5950
6138
  switch (_a.label) {
5951
6139
  case 0:
@@ -5972,9 +6160,9 @@ var PerpetualsClient = (function () {
5972
6160
  instructions.push(setPermissionsInstruction);
5973
6161
  return [3, 4];
5974
6162
  case 3:
5975
- err_35 = _a.sent();
5976
- console.log("perpClient setPool error:: ", err_35);
5977
- throw err_35;
6163
+ err_37 = _a.sent();
6164
+ console.log("perpClient setPool error:: ", err_37);
6165
+ throw err_37;
5978
6166
  case 4: return [2, {
5979
6167
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5980
6168
  additionalSigners: additionalSigners
@@ -5983,7 +6171,7 @@ var PerpetualsClient = (function () {
5983
6171
  });
5984
6172
  }); };
5985
6173
  this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5986
- var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_36;
6174
+ var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_38;
5987
6175
  var _f;
5988
6176
  return __generator(this, function (_g) {
5989
6177
  switch (_g.label) {
@@ -6043,9 +6231,9 @@ var PerpetualsClient = (function () {
6043
6231
  instructions.push(reimburse);
6044
6232
  return [3, 5];
6045
6233
  case 4:
6046
- err_36 = _g.sent();
6047
- console.log("perpClient setPool error:: ", err_36);
6048
- throw err_36;
6234
+ err_38 = _g.sent();
6235
+ console.log("perpClient setPool error:: ", err_38);
6236
+ throw err_38;
6049
6237
  case 5: return [2, {
6050
6238
  instructions: __spreadArray([], instructions, true),
6051
6239
  additionalSigners: additionalSigners
@@ -6054,7 +6242,7 @@ var PerpetualsClient = (function () {
6054
6242
  });
6055
6243
  }); };
6056
6244
  this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6057
- var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_37;
6245
+ var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_39;
6058
6246
  return __generator(this, function (_a) {
6059
6247
  switch (_a.label) {
6060
6248
  case 0:
@@ -6087,9 +6275,9 @@ var PerpetualsClient = (function () {
6087
6275
  instructions.push(setInternalOraclePrice);
6088
6276
  return [3, 4];
6089
6277
  case 3:
6090
- err_37 = _a.sent();
6091
- console.log("perpClient setInternalOracleAccount error:: ", err_37);
6092
- throw err_37;
6278
+ err_39 = _a.sent();
6279
+ console.log("perpClient setInternalOracleAccount error:: ", err_39);
6280
+ throw err_39;
6093
6281
  case 4: return [2, {
6094
6282
  instructions: __spreadArray([], instructions, true),
6095
6283
  additionalSigners: additionalSigners
@@ -6101,7 +6289,7 @@ var PerpetualsClient = (function () {
6101
6289
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6102
6290
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6103
6291
  return __awaiter(_this, void 0, void 0, function () {
6104
- 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_38;
6292
+ 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_40;
6105
6293
  return __generator(this, function (_e) {
6106
6294
  switch (_e.label) {
6107
6295
  case 0:
@@ -6224,8 +6412,8 @@ var PerpetualsClient = (function () {
6224
6412
  instructions.push(addCompoundingLiquidity);
6225
6413
  return [3, 10];
6226
6414
  case 9:
6227
- err_38 = _e.sent();
6228
- console.log("perpClient addCompoundingLiquidity error:: ", err_38);
6415
+ err_40 = _e.sent();
6416
+ console.log("perpClient addCompoundingLiquidity error:: ", err_40);
6229
6417
  return [3, 10];
6230
6418
  case 10: return [2, {
6231
6419
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -6239,7 +6427,7 @@ var PerpetualsClient = (function () {
6239
6427
  if (createUserATA === void 0) { createUserATA = true; }
6240
6428
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6241
6429
  return __awaiter(_this, void 0, void 0, function () {
6242
- 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_39;
6430
+ 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_41;
6243
6431
  return __generator(this, function (_e) {
6244
6432
  switch (_e.label) {
6245
6433
  case 0:
@@ -6346,8 +6534,8 @@ var PerpetualsClient = (function () {
6346
6534
  instructions.push(removeCompoundingLiquidity);
6347
6535
  return [3, 8];
6348
6536
  case 7:
6349
- err_39 = _e.sent();
6350
- console.log("perpClient removeCompoundingLiquidity error:: ", err_39);
6537
+ err_41 = _e.sent();
6538
+ console.log("perpClient removeCompoundingLiquidity error:: ", err_41);
6351
6539
  return [3, 8];
6352
6540
  case 8: return [2, {
6353
6541
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -6360,7 +6548,7 @@ var PerpetualsClient = (function () {
6360
6548
  this.migrateStake = function (amount, rewardTokenMint, poolConfig, createUserATA) {
6361
6549
  if (createUserATA === void 0) { createUserATA = true; }
6362
6550
  return __awaiter(_this, void 0, void 0, function () {
6363
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, migrateStake, err_40;
6551
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _b, custody, _c, _d, market, migrateStake, err_42;
6364
6552
  return __generator(this, function (_e) {
6365
6553
  switch (_e.label) {
6366
6554
  case 0:
@@ -6441,8 +6629,8 @@ var PerpetualsClient = (function () {
6441
6629
  instructions.push(migrateStake);
6442
6630
  return [3, 6];
6443
6631
  case 5:
6444
- err_40 = _e.sent();
6445
- console.log("perpClient migrateStake error:: ", err_40);
6632
+ err_42 = _e.sent();
6633
+ console.log("perpClient migrateStake error:: ", err_42);
6446
6634
  return [3, 6];
6447
6635
  case 6: return [2, {
6448
6636
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -6453,7 +6641,7 @@ var PerpetualsClient = (function () {
6453
6641
  });
6454
6642
  };
6455
6643
  this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6456
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_41;
6644
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_43;
6457
6645
  return __generator(this, function (_d) {
6458
6646
  switch (_d.label) {
6459
6647
  case 0:
@@ -6525,8 +6713,8 @@ var PerpetualsClient = (function () {
6525
6713
  instructions.push(migrateFlp);
6526
6714
  return [3, 4];
6527
6715
  case 3:
6528
- err_41 = _d.sent();
6529
- console.log("perpClient migrateFlp error:: ", err_41);
6716
+ err_43 = _d.sent();
6717
+ console.log("perpClient migrateFlp error:: ", err_43);
6530
6718
  return [3, 4];
6531
6719
  case 4: return [2, {
6532
6720
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
@@ -6538,7 +6726,7 @@ var PerpetualsClient = (function () {
6538
6726
  this.compoundingFee = function (poolConfig, rewardTokenSymbol) {
6539
6727
  if (rewardTokenSymbol === void 0) { rewardTokenSymbol = 'USDC'; }
6540
6728
  return __awaiter(_this, void 0, void 0, function () {
6541
- var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_42;
6729
+ var instructions, additionalSigners, rewardCustody, lpTokenMint, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, compoundingFee, err_44;
6542
6730
  return __generator(this, function (_d) {
6543
6731
  switch (_d.label) {
6544
6732
  case 0:
@@ -6595,8 +6783,8 @@ var PerpetualsClient = (function () {
6595
6783
  instructions.push(compoundingFee);
6596
6784
  return [3, 4];
6597
6785
  case 3:
6598
- err_42 = _d.sent();
6599
- console.log("perpClient compoundingFee error:: ", err_42);
6786
+ err_44 = _d.sent();
6787
+ console.log("perpClient compoundingFee error:: ", err_44);
6600
6788
  return [3, 4];
6601
6789
  case 4: return [2, {
6602
6790
  instructions: __spreadArray([], instructions, true),
@@ -6607,7 +6795,7 @@ var PerpetualsClient = (function () {
6607
6795
  });
6608
6796
  };
6609
6797
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6610
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_43;
6798
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_45;
6611
6799
  return __generator(this, function (_a) {
6612
6800
  switch (_a.label) {
6613
6801
  case 0:
@@ -6645,8 +6833,8 @@ var PerpetualsClient = (function () {
6645
6833
  instructions.push(renameFlp);
6646
6834
  return [3, 4];
6647
6835
  case 3:
6648
- err_43 = _a.sent();
6649
- console.log("perpClient renameFlp error:: ", err_43);
6836
+ err_45 = _a.sent();
6837
+ console.log("perpClient renameFlp error:: ", err_45);
6650
6838
  return [3, 4];
6651
6839
  case 4: return [2, {
6652
6840
  instructions: __spreadArray([], instructions, true),
@@ -6656,7 +6844,7 @@ var PerpetualsClient = (function () {
6656
6844
  });
6657
6845
  }); };
6658
6846
  this.initRewardDistribution = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6659
- var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_44;
6847
+ var publicKey, rewardMint, instructions, additionalSigners, fbNftProgramData, rewardVault, rewardTokenAccount, transferAuthority, initRewardVault, err_46;
6660
6848
  return __generator(this, function (_a) {
6661
6849
  switch (_a.label) {
6662
6850
  case 0:
@@ -6690,9 +6878,9 @@ var PerpetualsClient = (function () {
6690
6878
  instructions.push(initRewardVault);
6691
6879
  return [3, 4];
6692
6880
  case 3:
6693
- err_44 = _a.sent();
6694
- console.log("rewardDistribution InitRewardVault error:: ", err_44);
6695
- throw err_44;
6881
+ err_46 = _a.sent();
6882
+ console.log("rewardDistribution InitRewardVault error:: ", err_46);
6883
+ throw err_46;
6696
6884
  case 4: return [2, {
6697
6885
  instructions: __spreadArray([], instructions, true),
6698
6886
  additionalSigners: additionalSigners
@@ -6701,7 +6889,7 @@ var PerpetualsClient = (function () {
6701
6889
  });
6702
6890
  }); };
6703
6891
  this.updateCounterReward = function () { return __awaiter(_this, void 0, void 0, function () {
6704
- var publicKey, instructions, additionalSigners, rewardVault, updateCounter, err_45;
6892
+ var publicKey, instructions, additionalSigners, rewardVault, updateCounter, err_47;
6705
6893
  return __generator(this, function (_a) {
6706
6894
  switch (_a.label) {
6707
6895
  case 0:
@@ -6724,9 +6912,9 @@ var PerpetualsClient = (function () {
6724
6912
  instructions.push(updateCounter);
6725
6913
  return [3, 4];
6726
6914
  case 3:
6727
- err_45 = _a.sent();
6728
- console.log("rewardDistribution updateCounter error:: ", err_45);
6729
- throw err_45;
6915
+ err_47 = _a.sent();
6916
+ console.log("rewardDistribution updateCounter error:: ", err_47);
6917
+ throw err_47;
6730
6918
  case 4: return [2, {
6731
6919
  instructions: __spreadArray([], instructions, true),
6732
6920
  additionalSigners: additionalSigners
@@ -6735,7 +6923,7 @@ var PerpetualsClient = (function () {
6735
6923
  });
6736
6924
  }); };
6737
6925
  this.rewardDistribution = function (counter, owner, rewardAmount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6738
- var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward, err_46;
6926
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, fundingAccount, rewardVault, rewardTokenAccount, rewardRecord, distributeReward, err_48;
6739
6927
  return __generator(this, function (_a) {
6740
6928
  switch (_a.label) {
6741
6929
  case 0:
@@ -6774,9 +6962,9 @@ var PerpetualsClient = (function () {
6774
6962
  instructions.push(distributeReward);
6775
6963
  return [3, 4];
6776
6964
  case 3:
6777
- err_46 = _a.sent();
6778
- console.log("rewardDistribution distributeReward error:: ", err_46);
6779
- throw err_46;
6965
+ err_48 = _a.sent();
6966
+ console.log("rewardDistribution distributeReward error:: ", err_48);
6967
+ throw err_48;
6780
6968
  case 4: return [2, {
6781
6969
  instructions: __spreadArray([], instructions, true),
6782
6970
  additionalSigners: additionalSigners
@@ -6787,7 +6975,7 @@ var PerpetualsClient = (function () {
6787
6975
  this.collectReward = function (counter, owner, rewardSymbol, poolConfig, createUserATA) {
6788
6976
  if (createUserATA === void 0) { createUserATA = true; }
6789
6977
  return __awaiter(_this, void 0, void 0, function () {
6790
- var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectRaffleReward, err_47;
6978
+ var publicKey, rewardCustodyMint, instructions, additionalSigners, receivingTokenAccount, _a, rewardVault, rewardTokenAccount, rewardRecord, transferAuthority, collectRaffleReward, err_49;
6791
6979
  return __generator(this, function (_b) {
6792
6980
  switch (_b.label) {
6793
6981
  case 0:
@@ -6835,8 +7023,8 @@ var PerpetualsClient = (function () {
6835
7023
  instructions.push(collectRaffleReward);
6836
7024
  return [3, 6];
6837
7025
  case 5:
6838
- err_47 = _b.sent();
6839
- throw err_47;
7026
+ err_49 = _b.sent();
7027
+ throw err_49;
6840
7028
  case 6: return [2, {
6841
7029
  instructions: __spreadArray([], instructions, true),
6842
7030
  additionalSigners: additionalSigners