flash-sdk 11.4.7 → 11.4.9-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.
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { ContractOraclePrice } from "./types";
3
4
  export declare class OraclePrice {
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { PublicKey } from "@solana/web3.js";
3
4
  import { LimitOrder, Order, TriggerOrder } from "./types";
@@ -1,3 +1,5 @@
1
+ /// <reference types="bn.js" />
2
+ /// <reference types="node" />
1
3
  import { Program, AnchorProvider, BN } from "@coral-xyz/anchor";
2
4
  import { PublicKey, TransactionInstruction, Commitment, Signer, AddressLookupTableAccount, VersionedTransaction } from "@solana/web3.js";
3
5
  import { PoolAccount } from "./PoolAccount";
@@ -4861,47 +4863,47 @@ export declare class PerpetualsClient {
4861
4863
  getLiquidationStateView: (positionAccount: PublicKey, poolName: string, tokenMint: PublicKey, collateralMint: PublicKey, poolConfig: PoolConfig) => Promise<any>;
4862
4864
  getCompoundingTokenDataView: (poolConfig: PoolConfig) => Promise<any>;
4863
4865
  getLpTokenPriceView: (poolConfig: PoolConfig) => Promise<any>;
4864
- openPosition: (targetSymbol: string, collateralSymbol: string, priceWithSlippage: ContractOraclePrice, collateralWithfee: BN, size: BN, side: Side, poolConfig: PoolConfig, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: any) => Promise<{
4866
+ openPosition: (targetSymbol: string, collateralSymbol: string, priceWithSlippage: ContractOraclePrice, collateralWithfee: BN, size: BN, side: Side, poolConfig: PoolConfig, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
4865
4867
  instructions: TransactionInstruction[];
4866
4868
  additionalSigners: Signer[];
4867
4869
  }>;
4868
- closePosition: (marketSymbol: string, collateralSymbol: string, priceWithSlippage: ContractOraclePrice, side: Side, poolConfig: PoolConfig, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, createUserATA?: boolean, closeUsersWSOLATA?: boolean, ephemeralSignerPubkey?: any) => Promise<{
4870
+ closePosition: (marketSymbol: string, collateralSymbol: string, priceWithSlippage: ContractOraclePrice, side: Side, poolConfig: PoolConfig, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, createUserATA?: boolean, closeUsersWSOLATA?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
4869
4871
  instructions: TransactionInstruction[];
4870
4872
  additionalSigners: Signer[];
4871
4873
  }>;
4872
- swapAndOpen: (targetTokenSymbol: string, collateralTokenSymbol: string, userInputTokenSymbol: string, amountIn: BN, priceWithSlippage: ContractOraclePrice, sizeAmount: BN, side: Side, poolConfig: PoolConfig, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: any) => Promise<{
4874
+ swapAndOpen: (targetTokenSymbol: string, collateralTokenSymbol: string, userInputTokenSymbol: string, amountIn: BN, priceWithSlippage: ContractOraclePrice, sizeAmount: BN, side: Side, poolConfig: PoolConfig, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
4873
4875
  instructions: TransactionInstruction[];
4874
4876
  additionalSigners: Signer[];
4875
4877
  }>;
4876
- closeAndSwap: (targetTokenSymbol: string, userOutputTokenSymbol: string, collateralTokenSymbol: string, priceWithSlippage: ContractOraclePrice, side: Side, poolConfig: PoolConfig, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, ephemeralSignerPubkey?: any) => Promise<{
4878
+ closeAndSwap: (targetTokenSymbol: string, userOutputTokenSymbol: string, collateralTokenSymbol: string, priceWithSlippage: ContractOraclePrice, side: Side, poolConfig: PoolConfig, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
4877
4879
  instructions: TransactionInstruction[];
4878
4880
  additionalSigners: Signer[];
4879
4881
  }>;
4880
- addCollateral: (collateralWithFee: BN, targetSymbol: string, collateralSymbol: string, side: Side, positionPubKey: PublicKey, poolConfig: PoolConfig, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: any) => Promise<{
4882
+ addCollateral: (collateralWithFee: BN, targetSymbol: string, collateralSymbol: string, side: Side, positionPubKey: PublicKey, poolConfig: PoolConfig, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
4881
4883
  instructions: TransactionInstruction[];
4882
4884
  additionalSigners: Signer[];
4883
4885
  }>;
4884
- swapAndAddCollateral: (targetSymbol: string, inputSymbol: string, collateralSymbol: string, amountIn: BN, side: Side, positionPubKey: PublicKey, poolConfig: PoolConfig, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: any) => Promise<{
4886
+ swapAndAddCollateral: (targetSymbol: string, inputSymbol: string, collateralSymbol: string, amountIn: BN, side: Side, positionPubKey: PublicKey, poolConfig: PoolConfig, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
4885
4887
  instructions: TransactionInstruction[];
4886
4888
  additionalSigners: Signer[];
4887
4889
  }>;
4888
- removeCollateral: (collateralDeltaUsd: BN, marketSymbol: string, collateralSymbol: string, side: Side, positionPubKey: PublicKey, poolConfig: PoolConfig, createUserATA?: boolean, closeUsersWSOLATA?: boolean, ephemeralSignerPubkey?: any) => Promise<{
4890
+ removeCollateral: (collateralDeltaUsd: BN, marketSymbol: string, collateralSymbol: string, side: Side, positionPubKey: PublicKey, poolConfig: PoolConfig, createUserATA?: boolean, closeUsersWSOLATA?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
4889
4891
  instructions: TransactionInstruction[];
4890
4892
  additionalSigners: Signer[];
4891
4893
  }>;
4892
- removeCollateralAndSwap: (targetSymbol: string, collateralSymbol: string, outputSymbol: string, collateralDeltaUsd: BN, side: Side, poolConfig: PoolConfig, ephemeralSignerPubkey?: any) => Promise<{
4894
+ removeCollateralAndSwap: (targetSymbol: string, collateralSymbol: string, outputSymbol: string, collateralDeltaUsd: BN, side: Side, poolConfig: PoolConfig, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
4893
4895
  instructions: TransactionInstruction[];
4894
4896
  additionalSigners: Signer[];
4895
4897
  }>;
4896
- increaseSize: (targetSymbol: string, collateralSymbol: string, positionPubKey: PublicKey, side: Side, poolConfig: PoolConfig, priceWithSlippage: ContractOraclePrice, sizeDelta: BN, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey) => Promise<{
4898
+ increaseSize: (targetSymbol: string, collateralSymbol: string, positionPubKey: PublicKey, side: Side, poolConfig: PoolConfig, priceWithSlippage: ContractOraclePrice, sizeDelta: BN, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, userPublicKey?: PublicKey) => Promise<{
4897
4899
  instructions: TransactionInstruction[];
4898
4900
  additionalSigners: Signer[];
4899
4901
  }>;
4900
- decreaseSize: (targetSymbol: string, collateralSymbol: string, side: Side, positionPubKey: PublicKey, poolConfig: PoolConfig, priceWithSlippage: ContractOraclePrice, sizeDelta: BN, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey) => Promise<{
4902
+ decreaseSize: (targetSymbol: string, collateralSymbol: string, side: Side, positionPubKey: PublicKey, poolConfig: PoolConfig, priceWithSlippage: ContractOraclePrice, sizeDelta: BN, privilege: Privilege, tokenStakeAccount?: PublicKey, userReferralAccount?: PublicKey, userPublicKey?: PublicKey) => Promise<{
4901
4903
  instructions: TransactionInstruction[];
4902
4904
  additionalSigners: Signer[];
4903
4905
  }>;
4904
- addLiquidity: (payTokenSymbol: string, tokenAmountIn: BN, minLpAmountOut: BN, poolConfig: PoolConfig, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: any, isWhitelistedUser?: boolean) => Promise<{
4906
+ addLiquidity: (payTokenSymbol: string, tokenAmountIn: BN, minLpAmountOut: BN, poolConfig: PoolConfig, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, isWhitelistedUser?: boolean, userPublicKey?: PublicKey) => Promise<{
4905
4907
  instructions: TransactionInstruction[];
4906
4908
  additionalSigners: Signer[];
4907
4909
  }>;
@@ -4928,7 +4930,7 @@ export declare class PerpetualsClient {
4928
4930
  additionalSigners: Signer[];
4929
4931
  }>;
4930
4932
  setFeeShareBps: (poolConfig: PoolConfig, flpStakeAccountPks: PublicKey[]) => Promise<TransactionInstruction>;
4931
- unstakeRequest: (unstakeAmount: BN, poolConfig: PoolConfig) => Promise<{
4933
+ unstakeRequest: (unstakeAmount: BN, poolConfig: PoolConfig, userPublicKey?: PublicKey) => Promise<{
4932
4934
  instructions: TransactionInstruction[];
4933
4935
  additionalSigners: Signer[];
4934
4936
  }>;
@@ -4948,11 +4950,11 @@ export declare class PerpetualsClient {
4948
4950
  instructions: TransactionInstruction[];
4949
4951
  additionalSigners: Signer[];
4950
4952
  }>;
4951
- migrateStake: (amount: BN, rewardTokenMint: PublicKey, poolConfig: PoolConfig, createUserATA?: boolean) => Promise<{
4953
+ migrateStake: (amount: BN, rewardTokenMint: PublicKey, poolConfig: PoolConfig, createUserATA?: boolean, userPublicKey?: PublicKey) => Promise<{
4952
4954
  instructions: TransactionInstruction[];
4953
4955
  additionalSigners: Signer[];
4954
4956
  }>;
4955
- migrateFlp: (amount: BN, rewardTokenMint: PublicKey, poolConfig: PoolConfig) => Promise<{
4957
+ migrateFlp: (amount: BN, rewardTokenMint: PublicKey, poolConfig: PoolConfig, userPublicKey?: PublicKey) => Promise<{
4956
4958
  instructions: TransactionInstruction[];
4957
4959
  additionalSigners: Signer[];
4958
4960
  }>;
@@ -4980,7 +4982,7 @@ export declare class PerpetualsClient {
4980
4982
  instructions: TransactionInstruction[];
4981
4983
  additionalSigners: Signer[];
4982
4984
  }>;
4983
- collectTokenReward: (owner: PublicKey, poolConfig: PoolConfig, createUserATA?: boolean) => Promise<{
4985
+ collectTokenReward: (owner: PublicKey, poolConfig: PoolConfig, createUserATA?: boolean, userPublicKey?: PublicKey) => Promise<{
4984
4986
  instructions: TransactionInstruction[];
4985
4987
  additionalSigners: Signer[];
4986
4988
  }>;
@@ -4996,11 +4998,11 @@ export declare class PerpetualsClient {
4996
4998
  instructions: TransactionInstruction[];
4997
4999
  additionalSigners: Signer[];
4998
5000
  }>;
4999
- placeLimitOrder: (targetSymbol: string, collateralSymbol: string, reserveSymbol: string, receiveSymbol: string, side: Side, limitPrice: ContractOraclePrice, reserveAmount: BN, sizeAmount: BN, stopLossPrice: ContractOraclePrice, takeProfitPrice: ContractOraclePrice, poolConfig: PoolConfig, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: any) => Promise<{
5001
+ placeLimitOrder: (targetSymbol: string, collateralSymbol: string, reserveSymbol: string, receiveSymbol: string, side: Side, limitPrice: ContractOraclePrice, reserveAmount: BN, sizeAmount: BN, stopLossPrice: ContractOraclePrice, takeProfitPrice: ContractOraclePrice, poolConfig: PoolConfig, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
5000
5002
  instructions: TransactionInstruction[];
5001
5003
  additionalSigners: Signer[];
5002
5004
  }>;
5003
- editLimitOrder: (targetSymbol: string, collateralSymbol: string, reserveSymbol: string, receiveSymbol: string, side: Side, orderId: number, limitPrice: ContractOraclePrice, sizeAmount: BN, stopLossPrice: ContractOraclePrice, takeProfitPrice: ContractOraclePrice, poolConfig: PoolConfig, createUserATA?: boolean, ephemeralSignerPubkey?: any) => Promise<{
5005
+ editLimitOrder: (targetSymbol: string, collateralSymbol: string, reserveSymbol: string, receiveSymbol: string, side: Side, orderId: number, limitPrice: ContractOraclePrice, sizeAmount: BN, stopLossPrice: ContractOraclePrice, takeProfitPrice: ContractOraclePrice, poolConfig: PoolConfig, createUserATA?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, userPublicKey?: PublicKey) => Promise<{
5004
5006
  instructions: TransactionInstruction[];
5005
5007
  additionalSigners: Signer[];
5006
5008
  }>;
@@ -5012,19 +5014,19 @@ export declare class PerpetualsClient {
5012
5014
  instructions: TransactionInstruction[];
5013
5015
  additionalSigners: Signer[];
5014
5016
  }>;
5015
- placeTriggerOrder: (targetSymbol: string, collateralSymbol: string, receiveSymbol: string, side: Side, triggerPrice: ContractOraclePrice, deltaSizeAmount: BN, isStopLoss: boolean, poolConfig: PoolConfig) => Promise<{
5017
+ placeTriggerOrder: (targetSymbol: string, collateralSymbol: string, receiveSymbol: string, side: Side, triggerPrice: ContractOraclePrice, deltaSizeAmount: BN, isStopLoss: boolean, poolConfig: PoolConfig, userPublicKey?: PublicKey) => Promise<{
5016
5018
  instructions: TransactionInstruction[];
5017
5019
  additionalSigners: Signer[];
5018
5020
  }>;
5019
- editTriggerOrder: (targetSymbol: string, collateralSymbol: string, receiveSymbol: string, side: Side, orderId: number, triggerPrice: ContractOraclePrice, deltaSizeAmount: BN, isStopLoss: boolean, poolConfig: PoolConfig) => Promise<{
5021
+ editTriggerOrder: (targetSymbol: string, collateralSymbol: string, receiveSymbol: string, side: Side, orderId: number, triggerPrice: ContractOraclePrice, deltaSizeAmount: BN, isStopLoss: boolean, poolConfig: PoolConfig, userPublicKey?: PublicKey) => Promise<{
5020
5022
  instructions: TransactionInstruction[];
5021
5023
  additionalSigners: Signer[];
5022
5024
  }>;
5023
- cancelTriggerOrder: (targetSymbol: string, collateralSymbol: string, side: Side, orderId: number, isStopLoss: boolean, poolConfig: PoolConfig) => Promise<{
5025
+ cancelTriggerOrder: (targetSymbol: string, collateralSymbol: string, side: Side, orderId: number, isStopLoss: boolean, poolConfig: PoolConfig, userPublicKey?: PublicKey) => Promise<{
5024
5026
  instructions: TransactionInstruction[];
5025
5027
  additionalSigners: Signer[];
5026
5028
  }>;
5027
- cancelAllTriggerOrders: (targetSymbol: string, collateralSymbol: string, side: Side, poolConfig: PoolConfig) => Promise<{
5029
+ cancelAllTriggerOrders: (targetSymbol: string, collateralSymbol: string, side: Side, poolConfig: PoolConfig, userPublicKey?: PublicKey) => Promise<{
5028
5030
  instructions: TransactionInstruction[];
5029
5031
  additionalSigners: Signer[];
5030
5032
  }>;
@@ -5041,7 +5043,7 @@ export declare class PerpetualsClient {
5041
5043
  signature: string;
5042
5044
  versionedTransaction: VersionedTransaction;
5043
5045
  }>;
5044
- swap: (userInputTokenSymbol: string, userOutputTokenSymbol: string, amountIn: BN, minAmountOut: BN, poolConfig: PoolConfig, useFeesPool?: boolean, createUserATA?: boolean, unWrapSol?: boolean, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: any, isWhitelistedUser?: boolean) => Promise<{
5046
+ swap: (userInputTokenSymbol: string, userOutputTokenSymbol: string, amountIn: BN, minAmountOut: BN, poolConfig: PoolConfig, useFeesPool?: boolean, createUserATA?: boolean, unWrapSol?: boolean, skipBalanceChecks?: boolean, ephemeralSignerPubkey?: PublicKey | undefined, isWhitelistedUser?: boolean, userPublicKey?: PublicKey) => Promise<{
5045
5047
  instructions: TransactionInstruction[];
5046
5048
  additionalSigners: Signer[];
5047
5049
  }>;
@@ -20,8 +20,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
20
20
  });
21
21
  };
22
22
  var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
24
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
25
  function verb(n) { return function (v) { return step([n, v]); }; }
26
26
  function step(op) {
27
27
  if (f) throw new TypeError("Generator is already executing.");
@@ -2592,7 +2592,7 @@ var PerpetualsClient = (function () {
2592
2592
  for (var _i = 8; _i < arguments.length; _i++) {
2593
2593
  args_1[_i - 8] = arguments[_i];
2594
2594
  }
2595
- return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2595
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, priceWithSlippage_1, collateralWithfee_1, size_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, priceWithSlippage, collateralWithfee, size, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
2596
2596
  var publicKey, targetCustodyConfig, collateralCustodyConfig, collateralToken, marketAccount, userCollateralTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, params, instruction;
2597
2597
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2598
2598
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
@@ -2601,7 +2601,7 @@ var PerpetualsClient = (function () {
2601
2601
  return __generator(this, function (_c) {
2602
2602
  switch (_c.label) {
2603
2603
  case 0:
2604
- publicKey = this.provider.wallet.publicKey;
2604
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
2605
2605
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
2606
2606
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
2607
2607
  collateralToken = poolConfig.getTokenFromSymbol(collateralSymbol);
@@ -2706,7 +2706,7 @@ var PerpetualsClient = (function () {
2706
2706
  for (var _i = 6; _i < arguments.length; _i++) {
2707
2707
  args_1[_i - 6] = arguments[_i];
2708
2708
  }
2709
- return __awaiter(_this, __spreadArray([marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
2709
+ return __awaiter(_this, __spreadArray([marketSymbol_1, collateralSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (marketSymbol, collateralSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey, userPublicKey) {
2710
2710
  var publicKey, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, instruction, closeWsolATAIns, error_1;
2711
2711
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2712
2712
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
@@ -2717,7 +2717,7 @@ var PerpetualsClient = (function () {
2717
2717
  switch (_b.label) {
2718
2718
  case 0:
2719
2719
  console.log("close position :::", marketSymbol, poolConfig.getTokenFromSymbol(marketSymbol).mintKey.toBase58());
2720
- publicKey = this.provider.wallet.publicKey;
2720
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
2721
2721
  preInstructions = [];
2722
2722
  instructions = [];
2723
2723
  postInstructions = [];
@@ -2815,7 +2815,7 @@ var PerpetualsClient = (function () {
2815
2815
  for (var _i = 9; _i < arguments.length; _i++) {
2816
2816
  args_1[_i - 9] = arguments[_i];
2817
2817
  }
2818
- return __awaiter(_this, __spreadArray([targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, skipBalanceChecks, ephemeralSignerPubkey) {
2818
+ return __awaiter(_this, __spreadArray([targetTokenSymbol_1, collateralTokenSymbol_1, userInputTokenSymbol_1, amountIn_1, priceWithSlippage_1, sizeAmount_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, collateralTokenSymbol, userInputTokenSymbol, amountIn, priceWithSlippage, sizeAmount, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
2819
2819
  var publicKey, userInputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, targetToken, userInputTokenAccount, userInputToken, lamports, unWrappedSolBalance, _a, userOutputTokenAccount, tokenAccountBalance, _b, userOutputTokenAccount, inx, err_3;
2820
2820
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2821
2821
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
@@ -2824,7 +2824,7 @@ var PerpetualsClient = (function () {
2824
2824
  return __generator(this, function (_c) {
2825
2825
  switch (_c.label) {
2826
2826
  case 0:
2827
- publicKey = this.provider.wallet.publicKey;
2827
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
2828
2828
  userInputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userInputTokenSymbol).mintKey); });
2829
2829
  if (!userInputCustodyConfig) {
2830
2830
  throw "userInputCustodyConfig not found";
@@ -2969,7 +2969,7 @@ var PerpetualsClient = (function () {
2969
2969
  for (var _i = 7; _i < arguments.length; _i++) {
2970
2970
  args_1[_i - 7] = arguments[_i];
2971
2971
  }
2972
- return __awaiter(_this, __spreadArray([targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, ephemeralSignerPubkey) {
2972
+ return __awaiter(_this, __spreadArray([targetTokenSymbol_1, userOutputTokenSymbol_1, collateralTokenSymbol_1, priceWithSlippage_1, side_1, poolConfig_1, privilege_1], args_1, true), void 0, function (targetTokenSymbol, userOutputTokenSymbol, collateralTokenSymbol, priceWithSlippage, side, poolConfig, privilege, tokenStakeAccount, userReferralAccount, ephemeralSignerPubkey, userPublicKey) {
2973
2973
  var publicKey, userOutputCustodyConfig, collateralCustodyConfig, targetCustodyConfig, marketAccount, positionAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, collateralToken, userOutputToken, lamports, userCollateralTokenAccount, inx, err_4;
2974
2974
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
2975
2975
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
@@ -2977,7 +2977,7 @@ var PerpetualsClient = (function () {
2977
2977
  return __generator(this, function (_a) {
2978
2978
  switch (_a.label) {
2979
2979
  case 0:
2980
- publicKey = this.provider.wallet.publicKey;
2980
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
2981
2981
  userOutputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(userOutputTokenSymbol).mintKey); });
2982
2982
  if (!userOutputCustodyConfig) {
2983
2983
  throw "userOutputCustodyConfig not found";
@@ -3095,14 +3095,14 @@ var PerpetualsClient = (function () {
3095
3095
  for (var _i = 6; _i < arguments.length; _i++) {
3096
3096
  args_1[_i - 6] = arguments[_i];
3097
3097
  }
3098
- return __awaiter(_this, __spreadArray([collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3098
+ return __awaiter(_this, __spreadArray([collateralWithFee_1, targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralWithFee, targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
3099
3099
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, userPayingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, instruction;
3100
3100
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3101
3101
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3102
3102
  return __generator(this, function (_c) {
3103
3103
  switch (_c.label) {
3104
3104
  case 0:
3105
- publicKey = this.provider.wallet.publicKey;
3105
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
3106
3106
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
3107
3107
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
3108
3108
  marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
@@ -3198,14 +3198,14 @@ var PerpetualsClient = (function () {
3198
3198
  for (var _i = 7; _i < arguments.length; _i++) {
3199
3199
  args_1[_i - 7] = arguments[_i];
3200
3200
  }
3201
- return __awaiter(_this, __spreadArray([targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, inputSymbol, collateralSymbol, amountIn, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
3201
+ return __awaiter(_this, __spreadArray([targetSymbol_1, inputSymbol_1, collateralSymbol_1, amountIn_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, inputSymbol, collateralSymbol, amountIn, side, positionPubKey, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
3202
3202
  var publicKey, collateralCustodyConfig, targetCustodyConfig, inputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userInputTokenAccount, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, userCollateralTokenAccount, marketAccount, instruction;
3203
3203
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3204
3204
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3205
3205
  return __generator(this, function (_c) {
3206
3206
  switch (_c.label) {
3207
3207
  case 0:
3208
- publicKey = this.provider.wallet.publicKey;
3208
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
3209
3209
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
3210
3210
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
3211
3211
  inputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(inputSymbol).mintKey); });
@@ -3317,7 +3317,7 @@ var PerpetualsClient = (function () {
3317
3317
  for (var _i = 6; _i < arguments.length; _i++) {
3318
3318
  args_1[_i - 6] = arguments[_i];
3319
3319
  }
3320
- return __awaiter(_this, __spreadArray([collateralDeltaUsd_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralDeltaUsd, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
3320
+ return __awaiter(_this, __spreadArray([collateralDeltaUsd_1, marketSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1], args_1, true), void 0, function (collateralDeltaUsd, marketSymbol, collateralSymbol, side, positionPubKey, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey, userPublicKey) {
3321
3321
  var publicKey, collateralCustodyConfig, targetCustodyConfig, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, lamports, _a, marketAccount, instruction, closeWsolATAIns, error_2;
3322
3322
  if (createUserATA === void 0) { createUserATA = true; }
3323
3323
  if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
@@ -3325,7 +3325,7 @@ var PerpetualsClient = (function () {
3325
3325
  return __generator(this, function (_b) {
3326
3326
  switch (_b.label) {
3327
3327
  case 0:
3328
- publicKey = this.provider.wallet.publicKey;
3328
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
3329
3329
  collateralCustodyConfig = poolConfig.custodies.find(function (i) {
3330
3330
  return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
3331
3331
  });
@@ -3428,13 +3428,13 @@ var PerpetualsClient = (function () {
3428
3428
  for (var _i = 6; _i < arguments.length; _i++) {
3429
3429
  args_1[_i - 6] = arguments[_i];
3430
3430
  }
3431
- return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, outputSymbol_1, collateralDeltaUsd_1, side_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, outputSymbol, collateralDeltaUsd, side, poolConfig, ephemeralSignerPubkey) {
3431
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, outputSymbol_1, collateralDeltaUsd_1, side_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, outputSymbol, collateralDeltaUsd, side, poolConfig, ephemeralSignerPubkey, userPublicKey) {
3432
3432
  var publicKey, targetCustodyConfig, collateralCustodyConfig, outputCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userReceivingTokenAccount, lamports, userCollateralTokenAccount, marketAccount, positionAccount, instruction;
3433
3433
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
3434
3434
  return __generator(this, function (_a) {
3435
3435
  switch (_a.label) {
3436
3436
  case 0:
3437
- publicKey = this.provider.wallet.publicKey;
3437
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
3438
3438
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
3439
3439
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
3440
3440
  outputCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(outputSymbol).mintKey); });
@@ -3530,14 +3530,14 @@ var PerpetualsClient = (function () {
3530
3530
  for (var _i = 8; _i < arguments.length; _i++) {
3531
3531
  args_1[_i - 8] = arguments[_i];
3532
3532
  }
3533
- return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount) {
3533
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, positionPubKey_1, side_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, positionPubKey, side, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, userPublicKey) {
3534
3534
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3535
3535
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3536
3536
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3537
3537
  return __generator(this, function (_a) {
3538
3538
  switch (_a.label) {
3539
3539
  case 0:
3540
- publicKey = this.provider.wallet.publicKey;
3540
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
3541
3541
  collateralCustodyConfig = poolConfig.custodies.find(function (i) {
3542
3542
  return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
3543
3543
  });
@@ -3594,14 +3594,14 @@ var PerpetualsClient = (function () {
3594
3594
  for (var _i = 8; _i < arguments.length; _i++) {
3595
3595
  args_1[_i - 8] = arguments[_i];
3596
3596
  }
3597
- return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount) {
3597
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, side_1, positionPubKey_1, poolConfig_1, priceWithSlippage_1, sizeDelta_1, privilege_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, side, positionPubKey, poolConfig, priceWithSlippage, sizeDelta, privilege, tokenStakeAccount, userReferralAccount, userPublicKey) {
3598
3598
  var publicKey, collateralCustodyConfig, targetCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, instruction;
3599
3599
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
3600
3600
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
3601
3601
  return __generator(this, function (_a) {
3602
3602
  switch (_a.label) {
3603
3603
  case 0:
3604
- publicKey = this.provider.wallet.publicKey;
3604
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
3605
3605
  collateralCustodyConfig = poolConfig.custodies.find(function (i) {
3606
3606
  return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey);
3607
3607
  });
@@ -3658,7 +3658,7 @@ var PerpetualsClient = (function () {
3658
3658
  for (var _i = 4; _i < arguments.length; _i++) {
3659
3659
  args_1[_i - 4] = arguments[_i];
3660
3660
  }
3661
- return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, isWhitelistedUser) {
3661
+ return __awaiter(_this, __spreadArray([payTokenSymbol_1, tokenAmountIn_1, minLpAmountOut_1, poolConfig_1], args_1, true), void 0, function (payTokenSymbol, tokenAmountIn, minLpAmountOut, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, isWhitelistedUser, userPublicKey) {
3662
3662
  var publicKey, payTokenCustodyConfig, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, payToken, userPayingTokenAccount, lpTokenAccount, custodyAccountMetas, custodyOracleAccountMetas, markets, _a, _b, custody, _c, _d, market, lamports, unWrappedSolBalance, _e, tokenAccountBalance, _f, whitelistPda, whitelistMeta, instruction, err_5;
3663
3663
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
3664
3664
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
@@ -3666,7 +3666,7 @@ var PerpetualsClient = (function () {
3666
3666
  return __generator(this, function (_g) {
3667
3667
  switch (_g.label) {
3668
3668
  case 0:
3669
- publicKey = this.provider.wallet.publicKey;
3669
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
3670
3670
  payTokenCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(payTokenSymbol).mintKey); });
3671
3671
  if (!payTokenCustodyConfig) {
3672
3672
  throw "payTokenCustodyConfig not found";
@@ -4421,12 +4421,12 @@ var PerpetualsClient = (function () {
4421
4421
  }
4422
4422
  });
4423
4423
  }); };
4424
- this.unstakeRequest = function (unstakeAmount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
4424
+ this.unstakeRequest = function (unstakeAmount, poolConfig, userPublicKey) { return __awaiter(_this, void 0, void 0, function () {
4425
4425
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, pool, flpStakeAccount, unstakeRequestInstruction, err_13;
4426
4426
  return __generator(this, function (_a) {
4427
4427
  switch (_a.label) {
4428
4428
  case 0:
4429
- publicKey = this.provider.wallet.publicKey;
4429
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4430
4430
  preInstructions = [];
4431
4431
  instructions = [];
4432
4432
  postInstructions = [];
@@ -4924,13 +4924,13 @@ var PerpetualsClient = (function () {
4924
4924
  for (var _i = 3; _i < arguments.length; _i++) {
4925
4925
  args_1[_i - 3] = arguments[_i];
4926
4926
  }
4927
- return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA) {
4927
+ return __awaiter(_this, __spreadArray([amount_1, rewardTokenMint_1, poolConfig_1], args_1, true), void 0, function (amount, rewardTokenMint, poolConfig, createUserATA, userPublicKey) {
4928
4928
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, _a, flpStakeAccount, tokenStakeAccount, tokenStakeAccounts, _b, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _c, _d, custody, _e, _f, market, migrateStake, err_18;
4929
4929
  if (createUserATA === void 0) { createUserATA = true; }
4930
4930
  return __generator(this, function (_g) {
4931
4931
  switch (_g.label) {
4932
4932
  case 0:
4933
- publicKey = this.provider.wallet.publicKey;
4933
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
4934
4934
  preInstructions = [];
4935
4935
  instructions = [];
4936
4936
  postInstructions = [];
@@ -5034,12 +5034,12 @@ var PerpetualsClient = (function () {
5034
5034
  });
5035
5035
  });
5036
5036
  };
5037
- this.migrateFlp = function (amount, rewardTokenMint, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5037
+ this.migrateFlp = function (amount, rewardTokenMint, poolConfig, userPublicKey) { return __awaiter(_this, void 0, void 0, function () {
5038
5038
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, lpTokenMint, compoundingTokenMint, compoudingTokenAccount, flpStakeAccount, poolStakedLpVault, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, migrateFlp, err_19;
5039
5039
  return __generator(this, function (_d) {
5040
5040
  switch (_d.label) {
5041
5041
  case 0:
5042
- publicKey = this.provider.wallet.publicKey;
5042
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
5043
5043
  preInstructions = [];
5044
5044
  instructions = [];
5045
5045
  postInstructions = [];
@@ -5434,13 +5434,13 @@ var PerpetualsClient = (function () {
5434
5434
  for (var _i = 2; _i < arguments.length; _i++) {
5435
5435
  args_1[_i - 2] = arguments[_i];
5436
5436
  }
5437
- return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA) {
5437
+ return __awaiter(_this, __spreadArray([owner_1, poolConfig_1], args_1, true), void 0, function (owner, poolConfig, createUserATA, userPublicKey) {
5438
5438
  var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, userTokenAccount, _a, collectTokenRewardInstruction, err_26;
5439
5439
  if (createUserATA === void 0) { createUserATA = true; }
5440
5440
  return __generator(this, function (_b) {
5441
5441
  switch (_b.label) {
5442
5442
  case 0:
5443
- publicKey = this.provider.wallet.publicKey;
5443
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
5444
5444
  preInstructions = [];
5445
5445
  instructions = [];
5446
5446
  postInstructions = [];
@@ -5672,14 +5672,14 @@ var PerpetualsClient = (function () {
5672
5672
  for (var _i = 11; _i < arguments.length; _i++) {
5673
5673
  args_1[_i - 11] = arguments[_i];
5674
5674
  }
5675
- return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey) {
5675
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, limitPrice, reserveAmount, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, skipBalanceChecks, ephemeralSignerPubkey, userPublicKey) {
5676
5676
  var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_30;
5677
5677
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
5678
5678
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5679
5679
  return __generator(this, function (_c) {
5680
5680
  switch (_c.label) {
5681
5681
  case 0:
5682
- publicKey = this.provider.wallet.publicKey;
5682
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
5683
5683
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
5684
5684
  reserveCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey); });
5685
5685
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
@@ -5795,14 +5795,14 @@ var PerpetualsClient = (function () {
5795
5795
  for (var _i = 11; _i < arguments.length; _i++) {
5796
5796
  args_1[_i - 11] = arguments[_i];
5797
5797
  }
5798
- return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey) {
5798
+ return __awaiter(_this, __spreadArray([targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, orderId_1, limitPrice_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1], args_1, true), void 0, function (targetSymbol, collateralSymbol, reserveSymbol, receiveSymbol, side, orderId, limitPrice, sizeAmount, stopLossPrice, takeProfitPrice, poolConfig, createUserATA, ephemeralSignerPubkey, userPublicKey) {
5799
5799
  var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_31;
5800
5800
  if (createUserATA === void 0) { createUserATA = true; }
5801
5801
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
5802
5802
  return __generator(this, function (_b) {
5803
5803
  switch (_b.label) {
5804
5804
  case 0:
5805
- publicKey = this.provider.wallet.publicKey;
5805
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
5806
5806
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
5807
5807
  reserveCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(reserveSymbol).mintKey); });
5808
5808
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
@@ -6039,12 +6039,12 @@ var PerpetualsClient = (function () {
6039
6039
  });
6040
6040
  });
6041
6041
  };
6042
- this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6042
+ this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig, userPublicKey) { return __awaiter(_this, void 0, void 0, function () {
6043
6043
  var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_34;
6044
6044
  return __generator(this, function (_a) {
6045
6045
  switch (_a.label) {
6046
6046
  case 0:
6047
- publicKey = this.provider.wallet.publicKey;
6047
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
6048
6048
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
6049
6049
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
6050
6050
  receivingCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(receiveSymbol).mintKey); });
@@ -6098,12 +6098,12 @@ var PerpetualsClient = (function () {
6098
6098
  }
6099
6099
  });
6100
6100
  }); };
6101
- this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6101
+ this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig, userPublicKey) { return __awaiter(_this, void 0, void 0, function () {
6102
6102
  var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_35;
6103
6103
  return __generator(this, function (_a) {
6104
6104
  switch (_a.label) {
6105
6105
  case 0:
6106
- publicKey = this.provider.wallet.publicKey;
6106
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
6107
6107
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
6108
6108
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
6109
6109
  receivingCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(receiveSymbol).mintKey); });
@@ -6156,12 +6156,12 @@ var PerpetualsClient = (function () {
6156
6156
  }
6157
6157
  });
6158
6158
  }); };
6159
- this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6159
+ this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig, userPublicKey) { return __awaiter(_this, void 0, void 0, function () {
6160
6160
  var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_36;
6161
6161
  return __generator(this, function (_a) {
6162
6162
  switch (_a.label) {
6163
6163
  case 0:
6164
- publicKey = this.provider.wallet.publicKey;
6164
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
6165
6165
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
6166
6166
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
6167
6167
  marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
@@ -6200,12 +6200,12 @@ var PerpetualsClient = (function () {
6200
6200
  }
6201
6201
  });
6202
6202
  }); };
6203
- this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6203
+ this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig, userPublicKey) { return __awaiter(_this, void 0, void 0, function () {
6204
6204
  var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_37;
6205
6205
  return __generator(this, function (_a) {
6206
6206
  switch (_a.label) {
6207
6207
  case 0:
6208
- publicKey = this.provider.wallet.publicKey;
6208
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
6209
6209
  targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
6210
6210
  collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
6211
6211
  marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
@@ -6458,7 +6458,7 @@ var PerpetualsClient = (function () {
6458
6458
  for (var _i = 5; _i < arguments.length; _i++) {
6459
6459
  args_1[_i - 5] = arguments[_i];
6460
6460
  }
6461
- return __awaiter(_this, __spreadArray([userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1], args_1, true), void 0, function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey, isWhitelistedUser) {
6461
+ return __awaiter(_this, __spreadArray([userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1], args_1, true), void 0, function (userInputTokenSymbol, userOutputTokenSymbol, amountIn, minAmountOut, poolConfig, useFeesPool, createUserATA, unWrapSol, skipBalanceChecks, ephemeralSignerPubkey, isWhitelistedUser, userPublicKey) {
6462
6462
  var userInputCustodyConfig, userOutputCustodyConfig, publicKey, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, userOutputTokenAccount, userInputTokenAccount, wsolAssociatedTokenAccount, wsolATAExist, unWrappedSolBalance, _a, wsolAssociatedTokenAccount, closeWsolATAIns, accCreationLamports, lamports, unWrappedSolBalance, _b, tokenAccountBalance, _c, lamports, _d, custodyAccountMetas, custodyOracleAccountMetas, _e, _f, custody, whitelistPda, whitelistMeta, params, inx, closeWsolATAIns, err_40;
6463
6463
  if (useFeesPool === void 0) { useFeesPool = false; }
6464
6464
  if (createUserATA === void 0) { createUserATA = true; }
@@ -6477,7 +6477,7 @@ var PerpetualsClient = (function () {
6477
6477
  if (!userOutputCustodyConfig) {
6478
6478
  throw "userOutputCustodyConfig not found";
6479
6479
  }
6480
- publicKey = this.provider.wallet.publicKey;
6480
+ publicKey = userPublicKey !== null && userPublicKey !== void 0 ? userPublicKey : this.provider.wallet.publicKey;
6481
6481
  preInstructions = [];
6482
6482
  instructions = [];
6483
6483
  postInstructions = [];
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { Pool, TokenRatios, StakeStats, CompoundingStats, Permissions } from "./types";
3
4
  import { PublicKey } from "@solana/web3.js";
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { Mint } from "@solana/spl-token";
3
4
  import { CustodyAccount } from "./CustodyAccount";
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { PublicKey } from "@solana/web3.js";
3
4
  import { ContractOraclePrice, Position } from "./types";
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { TokenStake, WithdrawStakeLog } from "./types";
2
3
  import { BN } from "@coral-xyz/anchor";
3
4
  import { PublicKey } from "@solana/web3.js";
@@ -1,3 +1,4 @@
1
+ /// <reference types="bn.js" />
1
2
  import { BN } from "@coral-xyz/anchor";
2
3
  import { PublicKey } from "@solana/web3.js";
3
4
  import { TokenVault } from "./types";
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");