flash-sdk 5.0.2 → 6.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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;
24
- return g = { next: verb(0), "throw": verb(1), "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 = 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;
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.");
@@ -659,8 +659,8 @@ var PerpetualsClient = (function () {
659
659
  finalCollateralAmount = swapAmountOut;
660
660
  }
661
661
  }
662
- var lockedUsd = targetTokenPrice.getAssetAmountUsd(sizeDeltaAmount, targetTokenCustodyAccount.decimals);
663
- var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetTokenPrice, targetTokenEmaPrice, targetTokenCustodyAccount, lockedUsd);
662
+ var sizeUsd = targetTokenPrice.getAssetAmountUsd(sizeDeltaAmount, targetTokenCustodyAccount.decimals);
663
+ var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetTokenPrice, targetTokenEmaPrice, targetTokenCustodyAccount, sizeUsd);
664
664
  var openFeeUsd = constants_1.BN_ZERO;
665
665
  if (sizeDeltaAmount != constants_1.BN_ZERO) {
666
666
  var sizeDeltaUsd = entryOraclePrice.getAssetAmountUsd(sizeDeltaAmount, targetTokenCustodyAccount.decimals);
@@ -698,13 +698,13 @@ var PerpetualsClient = (function () {
698
698
  if (collateralDeltaAmount.isNeg() || sizeDeltaAmount.isNeg()) {
699
699
  throw new Error("Delta Amounts cannot be negative.");
700
700
  }
701
- var lockedUsd = targetPrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
702
- var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, lockedUsd);
701
+ var sizeUsd = targetPrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
702
+ var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, sizeUsd);
703
703
  if (positionAccount === null) {
704
704
  var data = __assign({}, types_1.DEFAULT_POSITION);
705
705
  positionAccount = PositionAccount_1.PositionAccount.from(web3_js_1.PublicKey.default, data);
706
- var sizeUsd = entryOraclePrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
707
- positionAccount.sizeUsd = sizeUsd;
706
+ var sizeUsd_1 = entryOraclePrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
707
+ positionAccount.sizeUsd = sizeUsd_1;
708
708
  positionAccount.sizeDecimals = targetCustodyAccount.decimals;
709
709
  positionAccount.collateralDecimals = collateralCustodyAccount.decimals;
710
710
  positionAccount.lockedDecimals = collateralCustodyAccount.decimals;
@@ -761,13 +761,13 @@ var PerpetualsClient = (function () {
761
761
  if (collateralDeltaAmount.isNeg() || sizeDeltaAmount.isNeg()) {
762
762
  throw new Error("Delta Amounts cannot be negative.");
763
763
  }
764
- var lockedUsd = targetPrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
765
- var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, lockedUsd);
764
+ var sizeUsd = targetPrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
765
+ var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, sizeUsd);
766
766
  if (positionAccount === null) {
767
767
  var data = __assign({}, types_1.DEFAULT_POSITION);
768
768
  positionAccount = PositionAccount_1.PositionAccount.from(web3_js_1.PublicKey.default, data);
769
- var sizeUsd = entryOraclePrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
770
- positionAccount.sizeUsd = sizeUsd;
769
+ var sizeUsd_2 = entryOraclePrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
770
+ positionAccount.sizeUsd = sizeUsd_2;
771
771
  positionAccount.sizeDecimals = targetCustodyAccount.decimals;
772
772
  positionAccount.collateralDecimals = collateralCustodyAccount.decimals;
773
773
  positionAccount.lockedDecimals = collateralCustodyAccount.decimals;
@@ -831,9 +831,9 @@ var PerpetualsClient = (function () {
831
831
  liquidationPrice: liquidationPrice
832
832
  };
833
833
  };
834
- this.getEntryPriceUsdSync = function (side, targetPrice, targetEmaPrice, targetCustodyAccount, lockedUsd) {
834
+ this.getEntryPriceUsdSync = function (side, targetPrice, targetEmaPrice, targetCustodyAccount, sizeUsd) {
835
835
  var _a = _this.getMinAndMaxOraclePriceSync(targetPrice, targetEmaPrice, targetCustodyAccount), minPrice = _a.min, maxPrice = _a.max;
836
- var spread = _this.getTradeSpread(targetCustodyAccount, lockedUsd);
836
+ var spread = _this.getTradeSpread(targetCustodyAccount, sizeUsd);
837
837
  var USD_POWER = (new anchor_1.BN(10)).pow(new anchor_1.BN(constants_1.USD_DECIMALS));
838
838
  var entryPriceBN = (0, types_1.isVariant)(side, 'long') ?
839
839
  maxPrice.price.add(maxPrice.price.mul(spread).div(USD_POWER)) :
@@ -866,8 +866,8 @@ var PerpetualsClient = (function () {
866
866
  if (resultingPositionAccount.collateralAmount.isNeg() || resultingPositionAccount.sizeAmount.isNeg()) {
867
867
  throw new Error("cannot remove/close more than collateral/Size");
868
868
  }
869
- var lockedUsd = targetPrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
870
- var exitOraclePrice = _this.getExitOraclePriceSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, lockedUsd);
869
+ var sizeUsd = targetPrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
870
+ var exitOraclePrice = _this.getExitOraclePriceSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, sizeUsd);
871
871
  var _a = _this.getMinAndMaxOraclePriceSync(collateralPrice, collateralEmaPrice, collateralCustodyAccount), collateralTokenMinOraclePrice = _a.min, collateralTokenMaxOraclePrice = _a.max;
872
872
  var lockAndUnsettledFeeUsd = _this.getLockFeeAndUnsettledUsdForPosition(resultingPositionAccount, collateralCustodyAccount, currentTimestamp);
873
873
  var lockAndUnsettledFee = collateralTokenMinOraclePrice.getTokenAmount(lockAndUnsettledFeeUsd, collateralCustodyAccount.decimals);
@@ -901,21 +901,21 @@ var PerpetualsClient = (function () {
901
901
  liquidationPrice: liquidationPrice
902
902
  };
903
903
  };
904
- this.getTradeSpread = function (targetCustodyAccount, lockedUsd) {
904
+ this.getTradeSpread = function (targetCustodyAccount, sizeUsd) {
905
905
  if (targetCustodyAccount.pricing.tradeSpreadMax.sub(targetCustodyAccount.pricing.tradeSpreadMin).isZero()
906
906
  ||
907
- lockedUsd.isZero()) {
907
+ sizeUsd.isZero()) {
908
908
  return constants_1.BN_ZERO;
909
909
  }
910
910
  var slope = ((targetCustodyAccount.pricing.tradeSpreadMax.sub(targetCustodyAccount.pricing.tradeSpreadMin)).mul(new anchor_1.BN(Math.pow(10, (constants_1.RATE_DECIMALS + constants_1.BPS_DECIMALS)))))
911
911
  .div(targetCustodyAccount.pricing.maxPositionLockedUsd);
912
- var variable = (slope.mul(lockedUsd)).div(new anchor_1.BN(Math.pow(10, (constants_1.RATE_DECIMALS + constants_1.BPS_DECIMALS))));
912
+ var variable = (slope.mul(sizeUsd)).div(new anchor_1.BN(Math.pow(10, (constants_1.RATE_DECIMALS + constants_1.BPS_DECIMALS))));
913
913
  var finalSpread = targetCustodyAccount.pricing.tradeSpreadMin.add(variable);
914
914
  return finalSpread;
915
915
  };
916
- this.getExitOraclePriceSync = function (side, targetPrice, targetEmaPrice, targetCustodyAccount, lockedUsd) {
916
+ this.getExitOraclePriceSync = function (side, targetPrice, targetEmaPrice, targetCustodyAccount, sizeUsd) {
917
917
  var _a = _this.getMinAndMaxOraclePriceSync(targetPrice, targetEmaPrice, targetCustodyAccount), minPrice = _a.min, maxPrice = _a.max;
918
- var spread = _this.getTradeSpread(targetCustodyAccount, lockedUsd);
918
+ var spread = _this.getTradeSpread(targetCustodyAccount, sizeUsd);
919
919
  var USD_POWER = (new anchor_1.BN(10)).pow(new anchor_1.BN(constants_1.USD_DECIMALS));
920
920
  var exitPriceBN = (0, types_1.isVariant)(side, 'long') ?
921
921
  maxPrice.price.sub(maxPrice.price.mul(spread).div(USD_POWER)) :
@@ -944,7 +944,7 @@ var PerpetualsClient = (function () {
944
944
  openPosFeeRateUi = openPosFeeRateUi.multipliedBy(new bignumber_js_1.default(1).minus(discountBpsUi));
945
945
  }
946
946
  var sizeUsdUi = collateralAmtMinUsdUi.multipliedBy(leverage)
947
- .dividedBy(new bignumber_js_1.default(1).plus(openPosFeeRateUi.multipliedBy(leverage)));
947
+ .dividedBy(new bignumber_js_1.default(1).plus((new bignumber_js_1.default(2).multipliedBy(openPosFeeRateUi)).multipliedBy(leverage)));
948
948
  var lockedUsd = (0, utils_1.uiDecimalsToNative)(sizeUsdUi.toString(), constants_1.USD_DECIMALS);
949
949
  var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, lockedUsd);
950
950
  var entryPriceUsdUi = new bignumber_js_1.default(entryOraclePrice.toUiPrice(constants_1.ORACLE_EXPONENT));
@@ -971,7 +971,7 @@ var PerpetualsClient = (function () {
971
971
  openPosFeeRateUi = openPosFeeRateUi.multipliedBy(new bignumber_js_1.default(1).minus(discountBpsUi));
972
972
  }
973
973
  var sizeUsdUi = collateralAmtMinUsdUi.multipliedBy(leverage)
974
- .dividedBy(new bignumber_js_1.default(1).plus(openPosFeeRateUi.multipliedBy(leverage)));
974
+ .dividedBy(new bignumber_js_1.default(1).plus((new bignumber_js_1.default(2).multipliedBy(openPosFeeRateUi)).multipliedBy(leverage)));
975
975
  var lockedUsd = (0, utils_1.uiDecimalsToNative)(sizeUsdUi.toFixed(constants_1.USD_DECIMALS), constants_1.USD_DECIMALS);
976
976
  var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetTokenPrice, targetTokenEmaPrice, targetTokenCustodyAccount, lockedUsd);
977
977
  var entryPriceUsdUi = new bignumber_js_1.default(entryOraclePrice.toUiPrice(constants_1.ORACLE_EXPONENT));
@@ -982,8 +982,8 @@ var PerpetualsClient = (function () {
982
982
  if (discountBps === void 0) { discountBps = constants_1.BN_ZERO; }
983
983
  var collateralTokenMinPrice = _this.getMinAndMaxPriceSync(collateralPrice, collateralEmaPrice, collateralCustodyAccount).min;
984
984
  var collateralTokenMinPriceUi = new bignumber_js_1.default(collateralTokenMinPrice.toString()).dividedBy(Math.pow(10, constants_1.USD_DECIMALS));
985
- var lockedUsd = targetPrice.getAssetAmountUsd(sizeAmount, targetCustodyAccount.decimals);
986
- var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, lockedUsd);
985
+ var sizeUsd = targetPrice.getAssetAmountUsd(sizeAmount, targetCustodyAccount.decimals);
986
+ var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetPrice, targetEmaPrice, targetCustodyAccount, sizeUsd);
987
987
  var entryPriceUsdUi = new bignumber_js_1.default(entryOraclePrice.toUiPrice(constants_1.ORACLE_EXPONENT));
988
988
  var openPosFeeRateUi = new bignumber_js_1.default(targetCustodyAccount.fees.openPosition.toString()).dividedBy(Math.pow(10, constants_1.RATE_DECIMALS));
989
989
  if (!discountBps.isZero()) {
@@ -992,20 +992,20 @@ var PerpetualsClient = (function () {
992
992
  }
993
993
  var sizeAmountUi = new bignumber_js_1.default(sizeAmount.toString()).dividedBy(Math.pow(10, marketToken.decimals));
994
994
  var sizeUsdUi = entryPriceUsdUi.multipliedBy(sizeAmountUi);
995
- var collateralWithFeeUsdUi = sizeUsdUi.multipliedBy(new bignumber_js_1.default(1).plus(openPosFeeRateUi.multipliedBy(leverage))).dividedBy(leverage);
995
+ var collateralWithFeeUsdUi = sizeUsdUi.multipliedBy(new bignumber_js_1.default(1).plus((new bignumber_js_1.default(2).multipliedBy(openPosFeeRateUi)).multipliedBy(leverage))).dividedBy(leverage);
996
996
  var collateralAmtWithFeeUi = collateralWithFeeUsdUi.dividedBy(collateralTokenMinPriceUi);
997
997
  return (0, utils_1.uiDecimalsToNative)(collateralAmtWithFeeUi.toFixed(collateralToken.decimals, bignumber_js_1.default.ROUND_DOWN), collateralToken.decimals);
998
998
  };
999
999
  this.getCollateralAmountWithSwapSync = function (sizeAmount, leverage, side, poolAccount, inputTokenPrice, inputTokenEmaPrice, inputTokenCustodyAccount, swapOutTokenPrice, swapOutTokenEmaPrice, swapOutTokenCustodyAccount, collateralTokenPrice, collateralTokenEmaPrice, collateralTokenCustodyAccount, targetTokenPrice, targetTokenEmaPrice, targetTokenCustodyAccount, swapPoolAumUsdMax, poolConfigPosition, poolConfigSwap) {
1000
1000
  var collateralTokenMinPrice = _this.getMinAndMaxPriceSync(collateralTokenPrice, collateralTokenEmaPrice, collateralTokenCustodyAccount).min;
1001
1001
  var collateralTokenMinPriceUi = new bignumber_js_1.default(collateralTokenMinPrice.toString()).dividedBy(Math.pow(10, constants_1.USD_DECIMALS));
1002
- var lockedUsd = targetTokenPrice.getAssetAmountUsd(sizeAmount, targetTokenCustodyAccount.decimals);
1003
- var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetTokenPrice, targetTokenEmaPrice, targetTokenCustodyAccount, lockedUsd);
1002
+ var sizeUsd = targetTokenPrice.getAssetAmountUsd(sizeAmount, targetTokenCustodyAccount.decimals);
1003
+ var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetTokenPrice, targetTokenEmaPrice, targetTokenCustodyAccount, sizeUsd);
1004
1004
  var entryPriceUsdUi = new bignumber_js_1.default(entryOraclePrice.toUiPrice(constants_1.ORACLE_EXPONENT));
1005
1005
  var openPosFeeRateUi = new bignumber_js_1.default(targetTokenCustodyAccount.fees.openPosition.toString()).dividedBy(Math.pow(10, constants_1.RATE_DECIMALS));
1006
1006
  var sizeAmountUi = new bignumber_js_1.default(sizeAmount.toString()).dividedBy(Math.pow(10, targetTokenCustodyAccount.decimals));
1007
1007
  var sizeUsdUi = entryPriceUsdUi.multipliedBy(sizeAmountUi);
1008
- var collateralWithFeeUsdUi = sizeUsdUi.multipliedBy(new bignumber_js_1.default(1).plus(openPosFeeRateUi.multipliedBy(leverage))).dividedBy(leverage);
1008
+ var collateralWithFeeUsdUi = sizeUsdUi.multipliedBy(new bignumber_js_1.default(1).plus((new bignumber_js_1.default(2).multipliedBy(openPosFeeRateUi)).multipliedBy(leverage))).dividedBy(leverage);
1009
1009
  var collateralAmtWithFeeUi = collateralWithFeeUsdUi.dividedBy(collateralTokenMinPriceUi);
1010
1010
  var collateralAmountWithFee = (0, utils_1.uiDecimalsToNative)(collateralAmtWithFeeUi.toFixed(collateralTokenCustodyAccount.decimals, bignumber_js_1.default.ROUND_DOWN), collateralTokenCustodyAccount.decimals);
1011
1011
  var collateralInInputToken;
@@ -1043,6 +1043,7 @@ var PerpetualsClient = (function () {
1043
1043
  positionDelta.lockedAmount = (positionAccount.lockedAmount.mul(closeRatio)).div(decimalPower);
1044
1044
  positionDelta.lockedUsd = (positionAccount.lockedUsd.mul(closeRatio)).div(decimalPower);
1045
1045
  positionDelta.collateralAmount = (positionAccount.collateralAmount.mul(closeRatio)).div(decimalPower);
1046
+ positionDelta.degenSizeUsd = positionAccount.degenSizeUsd.mul(closeRatio).div(decimalPower);
1046
1047
  var newPnl = _this.getPnlSync(positionDelta, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, targetCustodyAccount.pricing.delaySeconds, poolConfig);
1047
1048
  var exitFeeUsd = positionDelta.sizeUsd.mul(targetCustodyAccount.fees.closePosition).div(new anchor_1.BN(constants_1.RATE_POWER));
1048
1049
  if (discountBps.gt(constants_1.BN_ZERO)) {
@@ -1074,6 +1075,7 @@ var PerpetualsClient = (function () {
1074
1075
  newPosition.collateralAmount = positionAccount.collateralAmount.sub(positionDelta.collateralAmount);
1075
1076
  newPosition.unsettledFeesUsd = positionAccount.unsettledFeesUsd.sub(positionDelta.unsettledFeesUsd);
1076
1077
  newPosition.collateralUsd = collateralMinMaxPrice.min.getAssetAmountUsd(newPosition.collateralAmount, collateralCustodyAccount.decimals);
1078
+ newPosition.degenSizeUsd = positionAccount.degenSizeUsd.sub(positionDelta.degenSizeUsd);
1077
1079
  var feeUsdWithDiscount = constants_1.BN_ZERO;
1078
1080
  var feeUsd = sizeDeltaUsd.mul(targetCustodyAccount.fees.closePosition).div(new anchor_1.BN(constants_1.RATE_POWER));
1079
1081
  if (discountBps.gt(constants_1.BN_ZERO)) {
@@ -1088,7 +1090,7 @@ var PerpetualsClient = (function () {
1088
1090
  if (keepLevSame) {
1089
1091
  var collateralAmountReceived = closeAmount;
1090
1092
  var collateralAmountRecievedUsd = collateralMinMaxPrice.min.getAssetAmountUsd(collateralAmountReceived, collateralCustodyAccount.decimals);
1091
- var maxWithdrawableAmount = _this.getMaxWithdrawableAmountSyncInternal(newPosition, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, poolConfig, closeAmount);
1093
+ var _a = _this.getMaxWithdrawableAmountSyncInternal(newPosition, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, poolConfig, closeAmount), maxWithdrawableAmount = _a.maxWithdrawableAmount, diff = _a.diff;
1092
1094
  if (debugLogs) {
1093
1095
  console.log("maxWithdrawableAmount ", maxWithdrawableAmount.toString(), keepLevSame);
1094
1096
  console.log("collateralAmountReceived ", collateralAmountReceived.toString(), keepLevSame);
@@ -1118,7 +1120,7 @@ var PerpetualsClient = (function () {
1118
1120
  newLev: newLev,
1119
1121
  liquidationPrice: finalLiquidationPrice,
1120
1122
  collateralAmountRecieved: collateralAmountReceived,
1121
- newCollateralAmount: newPosition.collateralAmount,
1123
+ newCollateralAmount: newPosition.collateralAmount.add(diff),
1122
1124
  newPnl: finalPnlUsd
1123
1125
  };
1124
1126
  }
@@ -1132,29 +1134,36 @@ var PerpetualsClient = (function () {
1132
1134
  if (errorBandwidthPercentageUi > 100 || errorBandwidthPercentageUi < 0) {
1133
1135
  throw new Error("errorBandwidthPercentageUi cannot be >100 or <0");
1134
1136
  }
1135
- var MAX_INIT_LEVERAGE = targetCustodyAccount.pricing.maxInitialLeverage.mul(new anchor_1.BN(100 - errorBandwidthPercentageUi)).div(new anchor_1.BN(100));
1137
+ var MAX_INIT_LEVERAGE = positionAccount.isDegenMode() ?
1138
+ (new anchor_1.BN(targetCustodyAccount.pricing.maxInitDegenLeverage)).mul(new anchor_1.BN(100 - errorBandwidthPercentageUi)).div(new anchor_1.BN(100))
1139
+ : (new anchor_1.BN(targetCustodyAccount.pricing.maxInitLeverage)).mul(new anchor_1.BN(100 - errorBandwidthPercentageUi)).div(new anchor_1.BN(100));
1136
1140
  var profitLoss = _this.getPnlSync(positionAccount, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, targetCustodyAccount.pricing.delaySeconds, poolConfig);
1137
1141
  var _a = _this.getMinAndMaxOraclePriceSync(collateralPrice, collateralEmaPrice, collateralCustodyAccount), collateralMinPrice = _a.min, collateralMaxPrice = _a.max;
1142
+ var exitFeeUsd = positionAccount.sizeUsd.mul(targetCustodyAccount.fees.closePosition).div(new anchor_1.BN(constants_1.RATE_POWER));
1143
+ var lockAndUnsettledFeeUsd = _this.getLockFeeAndUnsettledUsdForPosition(positionAccount, collateralCustodyAccount, currentTimestamp);
1144
+ var lossUsd = profitLoss.lossUsd.add(exitFeeUsd).add(lockAndUnsettledFeeUsd);
1138
1145
  var currentCollateralUsd = collateralMinPrice.getAssetAmountUsd(positionAccount.collateralAmount.add(closeAmount), collateralCustodyAccount.decimals);
1139
1146
  var availableInitMarginUsd = constants_1.BN_ZERO;
1140
1147
  if (profitLoss.lossUsd.lt(currentCollateralUsd)) {
1141
- availableInitMarginUsd = currentCollateralUsd.sub(profitLoss.lossUsd);
1148
+ availableInitMarginUsd = currentCollateralUsd.sub(lossUsd);
1142
1149
  }
1143
1150
  else {
1144
1151
  console.log("profitLoss.lossUsd > coll :: should have been liquidated");
1145
- return constants_1.BN_ZERO;
1152
+ return { maxWithdrawableAmount: constants_1.BN_ZERO, diff: constants_1.BN_ZERO };
1146
1153
  }
1147
1154
  var maxRemovableCollateralUsd = availableInitMarginUsd.sub(positionAccount.sizeUsd.muln(constants_1.BPS_POWER).div(MAX_INIT_LEVERAGE));
1148
1155
  if (maxRemovableCollateralUsd.isNeg()) {
1149
- return constants_1.BN_ZERO;
1156
+ return { maxWithdrawableAmount: constants_1.BN_ZERO, diff: constants_1.BN_ZERO };
1150
1157
  }
1151
- var maxWithdrawableAmount;
1158
+ var maxWithdrawableAmount = constants_1.BN_ZERO;
1159
+ var diff = constants_1.BN_ZERO;
1152
1160
  var remainingCollateralUsd = availableInitMarginUsd.sub(maxRemovableCollateralUsd);
1153
- if (remainingCollateralUsd < targetCustodyAccount.pricing.minCollateralUsd) {
1154
- var diff = targetCustodyAccount.pricing.minCollateralUsd.sub(remainingCollateralUsd);
1161
+ var isDegenMode = positionAccount.isDegenMode();
1162
+ if (remainingCollateralUsd.lt(new anchor_1.BN(isDegenMode ? targetCustodyAccount.pricing.minDegenCollateralUsd : targetCustodyAccount.pricing.minCollateralUsd))) {
1163
+ diff = (new anchor_1.BN(isDegenMode ? targetCustodyAccount.pricing.minDegenCollateralUsd : targetCustodyAccount.pricing.minCollateralUsd)).sub(remainingCollateralUsd);
1155
1164
  var updatedMaxRemovableCollateralUsd = maxRemovableCollateralUsd.sub(diff);
1156
1165
  if (updatedMaxRemovableCollateralUsd.isNeg()) {
1157
- return constants_1.BN_ZERO;
1166
+ return { maxWithdrawableAmount: constants_1.BN_ZERO, diff: constants_1.BN_ZERO };
1158
1167
  }
1159
1168
  else {
1160
1169
  maxWithdrawableAmount = collateralMaxPrice.getTokenAmount(updatedMaxRemovableCollateralUsd, collateralCustodyAccount.decimals);
@@ -1163,7 +1172,7 @@ var PerpetualsClient = (function () {
1163
1172
  else {
1164
1173
  maxWithdrawableAmount = collateralMaxPrice.getTokenAmount(maxRemovableCollateralUsd, collateralCustodyAccount.decimals);
1165
1174
  }
1166
- return maxWithdrawableAmount;
1175
+ return { maxWithdrawableAmount: maxWithdrawableAmount, diff: diff };
1167
1176
  };
1168
1177
  this.getFinalCloseAmountSync = function (positionAccount, marketCorrelation, side, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, poolConfig) {
1169
1178
  var position = PositionAccount_1.PositionAccount.from(positionAccount.publicKey, __assign({}, positionAccount));
@@ -1190,18 +1199,23 @@ var PerpetualsClient = (function () {
1190
1199
  if (errorBandwidthPercentageUi > 100 || errorBandwidthPercentageUi < 0) {
1191
1200
  throw new Error("errorBandwidthPercentageUi cannot be >100 or <0");
1192
1201
  }
1193
- var MAX_INIT_LEVERAGE = targetCustodyAccount.pricing.maxInitialLeverage.mul(new anchor_1.BN(100 - errorBandwidthPercentageUi)).div(new anchor_1.BN(100));
1194
- var maxRemoveableCollateralUsdAfterMinRequired = positionAccount.collateralUsd.sub(targetCustodyAccount.pricing.minCollateralUsd.mul(new anchor_1.BN(100 + errorBandwidthPercentageUi)).div(new anchor_1.BN(100)));
1202
+ var MAX_INIT_LEVERAGE = positionAccount.isDegenMode() ?
1203
+ (new anchor_1.BN(targetCustodyAccount.pricing.maxInitDegenLeverage)).mul(new anchor_1.BN(100 - errorBandwidthPercentageUi)).div(new anchor_1.BN(100))
1204
+ : (new anchor_1.BN(targetCustodyAccount.pricing.maxInitLeverage)).mul(new anchor_1.BN(100 - errorBandwidthPercentageUi)).div(new anchor_1.BN(100));
1205
+ var maxRemoveableCollateralUsdAfterMinRequired = positionAccount.collateralUsd.sub((positionAccount.isDegenMode() ? new anchor_1.BN(targetCustodyAccount.pricing.minDegenCollateralUsd) : new anchor_1.BN(targetCustodyAccount.pricing.minCollateralUsd)).mul(new anchor_1.BN(100 + errorBandwidthPercentageUi)).div(new anchor_1.BN(100)));
1195
1206
  if (maxRemoveableCollateralUsdAfterMinRequired.isNeg()) {
1196
1207
  console.log("THIS cannot happen but still");
1197
1208
  return constants_1.BN_ZERO;
1198
1209
  }
1199
1210
  var profitLoss = _this.getPnlSync(positionAccount, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, targetCustodyAccount.pricing.delaySeconds, poolConfig);
1200
1211
  var _a = _this.getMinAndMaxOraclePriceSync(collateralPrice, collateralEmaPrice, collateralCustodyAccount), collateralMinPrice = _a.min, collateralMaxPrice = _a.max;
1212
+ var exitFeeUsd = positionAccount.sizeUsd.mul(targetCustodyAccount.fees.closePosition).div(new anchor_1.BN(constants_1.RATE_POWER));
1213
+ var lockAndUnsettledFeeUsd = _this.getLockFeeAndUnsettledUsdForPosition(positionAccount, collateralCustodyAccount, currentTimestamp);
1214
+ var lossUsd = profitLoss.lossUsd.add(exitFeeUsd).add(lockAndUnsettledFeeUsd);
1201
1215
  var currentCollateralUsd = collateralMinPrice.getAssetAmountUsd(positionAccount.collateralAmount, collateralCustodyAccount.decimals);
1202
1216
  var availableInitMarginUsd = constants_1.BN_ZERO;
1203
1217
  if (profitLoss.lossUsd.lt(currentCollateralUsd)) {
1204
- availableInitMarginUsd = currentCollateralUsd.sub(profitLoss.lossUsd);
1218
+ availableInitMarginUsd = currentCollateralUsd.sub(lossUsd);
1205
1219
  }
1206
1220
  else {
1207
1221
  console.log("profitLoss.lossUsd > coll :: should have been liquidated");
@@ -1241,11 +1255,11 @@ var PerpetualsClient = (function () {
1241
1255
  borrowRate = (currentUtilization.mul(custodyAccount.borrowRate.slope1))
1242
1256
  .div(custodyAccount.borrowRate.optimalUtilization);
1243
1257
  }
1244
- else if (currentUtilization.lt(custodyAccount.pricing.maxUtilization)) {
1258
+ else if (currentUtilization.lt((new anchor_1.BN(custodyAccount.pricing.maxUtilization)))) {
1245
1259
  borrowRate = custodyAccount.borrowRate.slope1
1246
1260
  .add(currentUtilization.sub(custodyAccount.borrowRate.optimalUtilization)
1247
1261
  .mul(custodyAccount.borrowRate.slope2)
1248
- .div(custodyAccount.pricing.maxUtilization.sub(custodyAccount.borrowRate.optimalUtilization)));
1262
+ .div((new anchor_1.BN(custodyAccount.pricing.maxUtilization)).sub(custodyAccount.borrowRate.optimalUtilization)));
1249
1263
  }
1250
1264
  else {
1251
1265
  borrowRate = custodyAccount.borrowRate.slope1.add(custodyAccount.borrowRate.slope2);
@@ -1287,7 +1301,7 @@ var PerpetualsClient = (function () {
1287
1301
  }
1288
1302
  var exitFeeUsd = positionAccount.sizeUsd.mul(targetCustodyAccount.fees.closePosition).div(new anchor_1.BN(constants_1.RATE_POWER));
1289
1303
  var unsettledLossUsd = exitFeeUsd.add(lockAndUnsettledFeeUsd);
1290
- var liablitiesUsd = positionAccount.sizeUsd.mul(new anchor_1.BN(constants_1.BPS_POWER)).div(targetCustodyAccount.pricing.maxLeverage).add(unsettledLossUsd);
1304
+ var liablitiesUsd = positionAccount.sizeUsd.mul(new anchor_1.BN(constants_1.BPS_POWER)).div(new anchor_1.BN(targetCustodyAccount.pricing.maxLeverage)).add(unsettledLossUsd);
1291
1305
  var targetMinMaxPriceOracle = _this.getMinAndMaxOraclePriceSync(targetPrice, targetEmaPrice, targetCustodyAccount);
1292
1306
  var collateralMinMaxPriceOracle = _this.getMinAndMaxOraclePriceSync(collateralPrice, collateralEmaPrice, collateralCustodyAccount);
1293
1307
  var liquidationPrice;
@@ -1377,7 +1391,7 @@ var PerpetualsClient = (function () {
1377
1391
  }
1378
1392
  var exitFeeUsd = sizeUsd.mul(targetCustodyAccount.fees.closePosition).div(new anchor_1.BN(constants_1.RATE_POWER));
1379
1393
  var unsettledLossUsd = exitFeeUsd;
1380
- var liablitiesUsd = sizeUsd.mul(new anchor_1.BN(constants_1.BPS_POWER)).div(targetCustodyAccount.pricing.maxLeverage).add(unsettledLossUsd);
1394
+ var liablitiesUsd = sizeUsd.mul(new anchor_1.BN(constants_1.BPS_POWER)).div(new anchor_1.BN(targetCustodyAccount.pricing.maxLeverage)).add(unsettledLossUsd);
1381
1395
  var targetMinMaxPriceOracle = _this.getMinAndMaxOraclePriceSync(targetPrice, targetEmaPrice, targetCustodyAccount);
1382
1396
  var collateralMinMaxPriceOracle = _this.getMinAndMaxOraclePriceSync(collateralPrice, collateralEmaPrice, collateralCustodyAccount);
1383
1397
  var liquidationPrice;
@@ -1498,8 +1512,8 @@ var PerpetualsClient = (function () {
1498
1512
  if (collateralDeltaAmount.isNeg() || sizeDeltaAmount.isNeg()) {
1499
1513
  throw new Error("Delta Amounts cannot be negative.");
1500
1514
  }
1501
- var lockedUsd = targetTokenEmaPrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
1502
- var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetTokenPrice, targetTokenEmaPrice, targetCustodyAccount, lockedUsd);
1515
+ var sizeUsd = targetTokenEmaPrice.getAssetAmountUsd(sizeDeltaAmount, targetCustodyAccount.decimals);
1516
+ var entryOraclePrice = _this.getEntryPriceUsdSync(side, targetTokenPrice, targetTokenEmaPrice, targetCustodyAccount, sizeUsd);
1503
1517
  if (positionAccount === null) {
1504
1518
  var data = __assign({}, types_1.DEFAULT_POSITION);
1505
1519
  positionAccount = PositionAccount_1.PositionAccount.from(web3_js_1.PublicKey.default, data);
@@ -1606,8 +1620,8 @@ var PerpetualsClient = (function () {
1606
1620
  };
1607
1621
  }
1608
1622
  var side = poolConfig.getMarketConfigByPk(positionAccount.market).side;
1609
- var lockedUsd = targetTokenPrice.getAssetAmountUsd(positionAccount.sizeAmount, targetCustodyAccount.decimals);
1610
- var exitOraclePrice = _this.getExitOraclePriceSync(side, targetTokenPrice, targetTokenEmaPrice, targetCustodyAccount, lockedUsd);
1623
+ var sizeUsd = targetTokenPrice.getAssetAmountUsd(positionAccount.sizeAmount, targetCustodyAccount.decimals);
1624
+ var exitOraclePrice = _this.getExitOraclePriceSync(side, targetTokenPrice, targetTokenEmaPrice, targetCustodyAccount, sizeUsd);
1611
1625
  var collateralMinPrice = _this.getMinAndMaxOraclePriceSync(collateralPrice, collateralEmaPrice, collateralCustodyAccount).min;
1612
1626
  var priceDiffProfit, priceDiffLoss;
1613
1627
  var positionEntryPrice = OraclePrice_1.OraclePrice.from({
@@ -5958,143 +5972,13 @@ var PerpetualsClient = (function () {
5958
5972
  });
5959
5973
  });
5960
5974
  };
5961
- this.setTriggerPrice = function (targetSymbol, collateralSymbol, side, triggerPrice, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5962
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, positionAccount, instructions, additionalSigners, setTriggerPrice, err_36;
5963
- return __generator(this, function (_a) {
5964
- switch (_a.label) {
5965
- case 0:
5966
- publicKey = this.provider.wallet.publicKey;
5967
- targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
5968
- collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
5969
- marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
5970
- positionAccount = poolConfig.getPositionFromMarketPk(publicKey, marketAccount);
5971
- instructions = [];
5972
- additionalSigners = [];
5973
- _a.label = 1;
5974
- case 1:
5975
- _a.trys.push([1, 3, , 4]);
5976
- return [4, this.program.methods
5977
- .setTriggerPrice({
5978
- triggerPrice: triggerPrice,
5979
- isStopLoss: isStopLoss
5980
- })
5981
- .accounts({
5982
- owner: publicKey,
5983
- perpetuals: this.perpetuals.publicKey,
5984
- pool: poolConfig.poolAddress,
5985
- position: positionAccount,
5986
- market: marketAccount,
5987
- targetCustody: targetCustodyConfig.custodyAccount,
5988
- targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
5989
- collateralCustody: collateralCustodyConfig.custodyAccount,
5990
- collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
5991
- eventAuthority: this.eventAuthority.publicKey,
5992
- program: this.programId,
5993
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
5994
- })
5995
- .instruction()];
5996
- case 2:
5997
- setTriggerPrice = _a.sent();
5998
- instructions.push(setTriggerPrice);
5999
- return [3, 4];
6000
- case 3:
6001
- err_36 = _a.sent();
6002
- console.log("perpClient setTriggerPrice error:: ", err_36);
6003
- throw err_36;
6004
- case 4: return [2, {
6005
- instructions: __spreadArray([], instructions, true),
6006
- additionalSigners: additionalSigners
6007
- }];
6008
- }
6009
- });
6010
- }); };
6011
- this.forceClosePosition = function (positionAccount_2, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1) {
6012
- var args_1 = [];
6013
- for (var _i = 6; _i < arguments.length; _i++) {
6014
- args_1[_i - 6] = arguments[_i];
6015
- }
6016
- return __awaiter(_this, __spreadArray([positionAccount_2, targetSymbol_1, collateralSymbol_1, side_1, isStopLoss_1, poolConfig_1], args_1, true), void 0, function (positionAccount, targetSymbol, collateralSymbol, side, isStopLoss, poolConfig, createUserATA, closeUsersWSOLATA, ephemeralSignerPubkey) {
6017
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, forceClosePosition, closeWsolATAIns, err_37;
6018
- if (createUserATA === void 0) { createUserATA = true; }
6019
- if (closeUsersWSOLATA === void 0) { closeUsersWSOLATA = false; }
6020
- if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6021
- return __generator(this, function (_b) {
6022
- switch (_b.label) {
6023
- case 0:
6024
- payerPubkey = this.provider.wallet.publicKey;
6025
- targetCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(targetSymbol).mintKey); });
6026
- collateralCustodyConfig = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey); });
6027
- marketAccount = poolConfig.getMarketPk(targetCustodyConfig.custodyAccount, collateralCustodyConfig.custodyAccount, side);
6028
- preInstructions = [];
6029
- instructions = [];
6030
- postInstructions = [];
6031
- additionalSigners = [];
6032
- _b.label = 1;
6033
- case 1:
6034
- _b.trys.push([1, 5, , 6]);
6035
- userReceivingTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, positionAccount.owner, false, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID);
6036
- _a = createUserATA;
6037
- if (!_a) return [3, 3];
6038
- return [4, (0, utils_1.checkIfAccountExists)(userReceivingTokenAccount, this.provider.connection)];
6039
- case 2:
6040
- _a = !(_b.sent());
6041
- _b.label = 3;
6042
- case 3:
6043
- if (_a) {
6044
- preInstructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(payerPubkey, userReceivingTokenAccount, positionAccount.owner, poolConfig.getTokenFromSymbol(collateralSymbol).mintKey, poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID));
6045
- }
6046
- return [4, this.program.methods
6047
- .forceClosePosition({
6048
- privilege: types_1.Privilege.None,
6049
- isStopLoss: isStopLoss
6050
- })
6051
- .accounts({
6052
- owner: positionAccount.owner,
6053
- receivingAccount: userReceivingTokenAccount,
6054
- transferAuthority: poolConfig.transferAuthority,
6055
- perpetuals: this.perpetuals.publicKey,
6056
- pool: poolConfig.poolAddress,
6057
- position: positionAccount.publicKey,
6058
- market: marketAccount,
6059
- targetCustody: targetCustodyConfig.custodyAccount,
6060
- targetOracleAccount: this.useExtOracleAccount ? targetCustodyConfig.extOracleAccount : targetCustodyConfig.intOracleAccount,
6061
- collateralCustody: collateralCustodyConfig.custodyAccount,
6062
- collateralOracleAccount: this.useExtOracleAccount ? collateralCustodyConfig.extOracleAccount : collateralCustodyConfig.intOracleAccount,
6063
- collateralCustodyTokenAccount: collateralCustodyConfig.tokenAccount,
6064
- tokenProgram: poolConfig.getTokenFromSymbol(collateralSymbol).isToken2022 ? spl_token_1.TOKEN_2022_PROGRAM_ID : spl_token_1.TOKEN_PROGRAM_ID,
6065
- eventAuthority: this.eventAuthority.publicKey,
6066
- program: this.programId,
6067
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY,
6068
- receivingMint: collateralCustodyConfig.mintKey
6069
- })
6070
- .instruction()];
6071
- case 4:
6072
- forceClosePosition = _b.sent();
6073
- instructions.push(forceClosePosition);
6074
- if (collateralSymbol == 'WSOL' && closeUsersWSOLATA) {
6075
- closeWsolATAIns = (0, spl_token_1.createCloseAccountInstruction)(userReceivingTokenAccount, positionAccount.owner, positionAccount.owner);
6076
- postInstructions.push(closeWsolATAIns);
6077
- }
6078
- return [3, 6];
6079
- case 5:
6080
- err_37 = _b.sent();
6081
- console.log("perpClient forceClosePosition error:: ", err_37);
6082
- throw err_37;
6083
- case 6: return [2, {
6084
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6085
- additionalSigners: additionalSigners
6086
- }];
6087
- }
6088
- });
6089
- });
6090
- };
6091
5975
  this.placeLimitOrder = function (targetSymbol_1, collateralSymbol_1, reserveSymbol_1, receiveSymbol_1, side_1, limitPrice_1, reserveAmount_1, sizeAmount_1, stopLossPrice_1, takeProfitPrice_1, poolConfig_1) {
6092
5976
  var args_1 = [];
6093
5977
  for (var _i = 11; _i < arguments.length; _i++) {
6094
5978
  args_1[_i - 11] = arguments[_i];
6095
5979
  }
6096
5980
  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) {
6097
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_38;
5981
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, userReserveTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, accCreationLamports, lamports, unWrappedSolBalance, _a, tokenAccountBalance, _b, positionAccount, orderAccount, placeLimitOrder, err_36;
6098
5982
  if (skipBalanceChecks === void 0) { skipBalanceChecks = false; }
6099
5983
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6100
5984
  return __generator(this, function (_c) {
@@ -6200,9 +6084,9 @@ var PerpetualsClient = (function () {
6200
6084
  instructions.push(placeLimitOrder);
6201
6085
  return [3, 10];
6202
6086
  case 9:
6203
- err_38 = _c.sent();
6204
- console.log("perpClient placeLimitOrder error:: ", err_38);
6205
- throw err_38;
6087
+ err_36 = _c.sent();
6088
+ console.log("perpClient placeLimitOrder error:: ", err_36);
6089
+ throw err_36;
6206
6090
  case 10: return [2, {
6207
6091
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6208
6092
  additionalSigners: additionalSigners
@@ -6217,7 +6101,7 @@ var PerpetualsClient = (function () {
6217
6101
  args_1[_i - 11] = arguments[_i];
6218
6102
  }
6219
6103
  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) {
6220
- var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_39;
6104
+ var publicKey, targetCustodyConfig, reserveCustodyConfig, collateralCustodyConfig, receiveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, wrappedSolAccount, userReceivingTokenAccount, lamports, _a, positionAccount, orderAccount, editLimitOrder, err_37;
6221
6105
  if (createUserATA === void 0) { createUserATA = true; }
6222
6106
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6223
6107
  return __generator(this, function (_b) {
@@ -6308,9 +6192,9 @@ var PerpetualsClient = (function () {
6308
6192
  instructions.push(editLimitOrder);
6309
6193
  return [3, 8];
6310
6194
  case 7:
6311
- err_39 = _b.sent();
6312
- console.log("perpClient editLimitOrder error:: ", err_39);
6313
- throw err_39;
6195
+ err_37 = _b.sent();
6196
+ console.log("perpClient editLimitOrder error:: ", err_37);
6197
+ throw err_37;
6314
6198
  case 8: return [2, {
6315
6199
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6316
6200
  additionalSigners: additionalSigners
@@ -6325,7 +6209,7 @@ var PerpetualsClient = (function () {
6325
6209
  args_1[_i - 7] = arguments[_i];
6326
6210
  }
6327
6211
  return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6328
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_40;
6212
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitOrder, err_38;
6329
6213
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6330
6214
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6331
6215
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
@@ -6378,9 +6262,9 @@ var PerpetualsClient = (function () {
6378
6262
  instructions.push(executeLimitOrder);
6379
6263
  return [3, 4];
6380
6264
  case 3:
6381
- err_40 = _a.sent();
6382
- console.log("perpClient executeLimitOrder error:: ", err_40);
6383
- throw err_40;
6265
+ err_38 = _a.sent();
6266
+ console.log("perpClient executeLimitOrder error:: ", err_38);
6267
+ throw err_38;
6384
6268
  case 4: return [2, {
6385
6269
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6386
6270
  additionalSigners: additionalSigners
@@ -6395,7 +6279,7 @@ var PerpetualsClient = (function () {
6395
6279
  args_1[_i - 8] = arguments[_i];
6396
6280
  }
6397
6281
  return __awaiter(_this, __spreadArray([userPubkey_1, targetSymbol_1, collateralSymbol_1, reserveSymbol_1, side_1, orderId_1, poolConfig_1, privilege_1], args_1, true), void 0, function (userPubkey, targetSymbol, collateralSymbol, reserveSymbol, side, orderId, poolConfig, privilege, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6398
- var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_41;
6282
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, reserveCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, executeLimitWithSwap, err_39;
6399
6283
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
6400
6284
  if (userReferralAccount === void 0) { userReferralAccount = web3_js_1.PublicKey.default; }
6401
6285
  if (rebateTokenAccount === void 0) { rebateTokenAccount = web3_js_1.PublicKey.default; }
@@ -6451,9 +6335,9 @@ var PerpetualsClient = (function () {
6451
6335
  instructions.push(executeLimitWithSwap);
6452
6336
  return [3, 4];
6453
6337
  case 3:
6454
- err_41 = _a.sent();
6455
- console.log("perpClient executeLimitWithSwap error:: ", err_41);
6456
- throw err_41;
6338
+ err_39 = _a.sent();
6339
+ console.log("perpClient executeLimitWithSwap error:: ", err_39);
6340
+ throw err_39;
6457
6341
  case 4: return [2, {
6458
6342
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6459
6343
  additionalSigners: additionalSigners
@@ -6463,7 +6347,7 @@ var PerpetualsClient = (function () {
6463
6347
  });
6464
6348
  };
6465
6349
  this.placeTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6466
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_42;
6350
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, placeTriggerOrder, err_40;
6467
6351
  return __generator(this, function (_a) {
6468
6352
  switch (_a.label) {
6469
6353
  case 0:
@@ -6511,9 +6395,9 @@ var PerpetualsClient = (function () {
6511
6395
  instructions.push(placeTriggerOrder);
6512
6396
  return [3, 4];
6513
6397
  case 3:
6514
- err_42 = _a.sent();
6515
- console.log("perpClient placeTriggerOrder error:: ", err_42);
6516
- throw err_42;
6398
+ err_40 = _a.sent();
6399
+ console.log("perpClient placeTriggerOrder error:: ", err_40);
6400
+ throw err_40;
6517
6401
  case 4: return [2, {
6518
6402
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6519
6403
  additionalSigners: additionalSigners
@@ -6522,7 +6406,7 @@ var PerpetualsClient = (function () {
6522
6406
  });
6523
6407
  }); };
6524
6408
  this.editTriggerOrder = function (targetSymbol, collateralSymbol, receiveSymbol, side, orderId, triggerPrice, deltaSizeAmount, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6525
- var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_43;
6409
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, editTriggerOrder, err_41;
6526
6410
  return __generator(this, function (_a) {
6527
6411
  switch (_a.label) {
6528
6412
  case 0:
@@ -6569,9 +6453,9 @@ var PerpetualsClient = (function () {
6569
6453
  instructions.push(editTriggerOrder);
6570
6454
  return [3, 4];
6571
6455
  case 3:
6572
- err_43 = _a.sent();
6573
- console.log("perpClient editTriggerOrder error:: ", err_43);
6574
- throw err_43;
6456
+ err_41 = _a.sent();
6457
+ console.log("perpClient editTriggerOrder error:: ", err_41);
6458
+ throw err_41;
6575
6459
  case 4: return [2, {
6576
6460
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6577
6461
  additionalSigners: additionalSigners
@@ -6580,7 +6464,7 @@ var PerpetualsClient = (function () {
6580
6464
  });
6581
6465
  }); };
6582
6466
  this.cancelTriggerOrder = function (targetSymbol, collateralSymbol, side, orderId, isStopLoss, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6583
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_44;
6467
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, cancelTriggerOrder, err_42;
6584
6468
  return __generator(this, function (_a) {
6585
6469
  switch (_a.label) {
6586
6470
  case 0:
@@ -6613,9 +6497,9 @@ var PerpetualsClient = (function () {
6613
6497
  instructions.push(cancelTriggerOrder);
6614
6498
  return [3, 4];
6615
6499
  case 3:
6616
- err_44 = _a.sent();
6617
- console.log("perpClient cancelTriggerOrder error:: ", err_44);
6618
- throw err_44;
6500
+ err_42 = _a.sent();
6501
+ console.log("perpClient cancelTriggerOrder error:: ", err_42);
6502
+ throw err_42;
6619
6503
  case 4: return [2, {
6620
6504
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6621
6505
  additionalSigners: additionalSigners
@@ -6624,7 +6508,7 @@ var PerpetualsClient = (function () {
6624
6508
  });
6625
6509
  }); };
6626
6510
  this.cancelAllTriggerOrders = function (targetSymbol, collateralSymbol, side, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6627
- var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_45;
6511
+ var publicKey, targetCustodyConfig, collateralCustodyConfig, marketAccount, preInstructions, instructions, postInstructions, additionalSigners, orderAccount, positionAccount, cancelAllTriggerOrders, err_43;
6628
6512
  return __generator(this, function (_a) {
6629
6513
  switch (_a.label) {
6630
6514
  case 0:
@@ -6655,9 +6539,9 @@ var PerpetualsClient = (function () {
6655
6539
  instructions.push(cancelAllTriggerOrders);
6656
6540
  return [3, 4];
6657
6541
  case 3:
6658
- err_45 = _a.sent();
6659
- console.log("perpClient cancelAllTriggerOrders error:: ", err_45);
6660
- throw err_45;
6542
+ err_43 = _a.sent();
6543
+ console.log("perpClient cancelAllTriggerOrders error:: ", err_43);
6544
+ throw err_43;
6661
6545
  case 4: return [2, {
6662
6546
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6663
6547
  additionalSigners: additionalSigners
@@ -6671,7 +6555,7 @@ var PerpetualsClient = (function () {
6671
6555
  args_1[_i - 9] = arguments[_i];
6672
6556
  }
6673
6557
  return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, receivingSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, receivingSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6674
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, collateralToken, receivingToken, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_46;
6558
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, receivingCustodyConfig, marketAccount, userReceivingTokenAccount, userReceivingTokenAccountCollateral, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, collateralToken, receivingToken, _a, _b, positionAccount, orderAccount, custodyAccountMetas, custodyOracleAccountMetas, _c, _d, custody, executeTriggerWithSwap, err_44;
6675
6559
  if (createUserATA === void 0) { createUserATA = true; }
6676
6560
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6677
6561
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
@@ -6778,9 +6662,9 @@ var PerpetualsClient = (function () {
6778
6662
  instructions.push(executeTriggerWithSwap);
6779
6663
  return [3, 10];
6780
6664
  case 9:
6781
- err_46 = _e.sent();
6782
- console.log("perpClient executeTriggerWithSwap error:: ", err_46);
6783
- throw err_46;
6665
+ err_44 = _e.sent();
6666
+ console.log("perpClient executeTriggerWithSwap error:: ", err_44);
6667
+ throw err_44;
6784
6668
  case 10: return [2, {
6785
6669
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6786
6670
  additionalSigners: additionalSigners
@@ -6795,7 +6679,7 @@ var PerpetualsClient = (function () {
6795
6679
  args_1[_i - 8] = arguments[_i];
6796
6680
  }
6797
6681
  return __awaiter(_this, __spreadArray([owner_1, targetSymbol_1, collateralSymbol_1, side_1, orderId_1, isStopLoss_1, privilege_1, poolConfig_1], args_1, true), void 0, function (owner, targetSymbol, collateralSymbol, side, orderId, isStopLoss, privilege, poolConfig, createUserATA, ephemeralSignerPubkey, tokenStakeAccount, userReferralAccount, rebateTokenAccount) {
6798
- var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_47;
6682
+ var payerPubkey, targetCustodyConfig, collateralCustodyConfig, marketAccount, userReceivingTokenAccount, wrappedSolAccount, preInstructions, instructions, postInstructions, additionalSigners, _a, positionAccount, orderAccount, executeTriggerOrder, err_45;
6799
6683
  if (createUserATA === void 0) { createUserATA = true; }
6800
6684
  if (ephemeralSignerPubkey === void 0) { ephemeralSignerPubkey = undefined; }
6801
6685
  if (tokenStakeAccount === void 0) { tokenStakeAccount = web3_js_1.PublicKey.default; }
@@ -6867,9 +6751,9 @@ var PerpetualsClient = (function () {
6867
6751
  instructions.push(executeTriggerOrder);
6868
6752
  return [3, 8];
6869
6753
  case 7:
6870
- err_47 = _b.sent();
6871
- console.log("perpClient executeTriggerOrder error:: ", err_47);
6872
- throw err_47;
6754
+ err_45 = _b.sent();
6755
+ console.log("perpClient executeTriggerOrder error:: ", err_45);
6756
+ throw err_45;
6873
6757
  case 8: return [2, {
6874
6758
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6875
6759
  additionalSigners: additionalSigners
@@ -6878,54 +6762,13 @@ var PerpetualsClient = (function () {
6878
6762
  });
6879
6763
  });
6880
6764
  };
6881
- this.migrateTriggerOrder = function (owner, marketAccount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
6882
- var payerPubkey, preInstructions, instructions, postInstructions, additionalSigners, positionAccount, orderAccount, migrateTriggerOrder, err_48;
6883
- return __generator(this, function (_a) {
6884
- switch (_a.label) {
6885
- case 0:
6886
- payerPubkey = this.provider.wallet.publicKey;
6887
- preInstructions = [];
6888
- instructions = [];
6889
- postInstructions = [];
6890
- additionalSigners = [];
6891
- _a.label = 1;
6892
- case 1:
6893
- _a.trys.push([1, 3, , 4]);
6894
- positionAccount = poolConfig.getPositionFromMarketPk(owner, marketAccount);
6895
- orderAccount = poolConfig.getOrderFromMarketPk(owner, marketAccount);
6896
- return [4, this.program.methods
6897
- .migrateTriggerOrder()
6898
- .accounts({
6899
- owner: owner,
6900
- feePayer: payerPubkey,
6901
- position: positionAccount,
6902
- order: orderAccount,
6903
- market: marketAccount,
6904
- systemProgram: web3_js_1.SystemProgram.programId,
6905
- })
6906
- .instruction()];
6907
- case 2:
6908
- migrateTriggerOrder = _a.sent();
6909
- instructions.push(migrateTriggerOrder);
6910
- return [3, 4];
6911
- case 3:
6912
- err_48 = _a.sent();
6913
- console.log("perpClient migrateTriggerOrder error:: ", err_48);
6914
- throw err_48;
6915
- case 4: return [2, {
6916
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
6917
- additionalSigners: additionalSigners
6918
- }];
6919
- }
6920
- });
6921
- }); };
6922
6765
  this.swap = function (userInputTokenSymbol_1, userOutputTokenSymbol_1, amountIn_1, minAmountOut_1, poolConfig_1) {
6923
6766
  var args_1 = [];
6924
6767
  for (var _i = 5; _i < arguments.length; _i++) {
6925
6768
  args_1[_i - 5] = arguments[_i];
6926
6769
  }
6927
6770
  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) {
6928
- 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, params, inx, closeWsolATAIns, err_49;
6771
+ 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, params, inx, closeWsolATAIns, err_46;
6929
6772
  if (useFeesPool === void 0) { useFeesPool = false; }
6930
6773
  if (createUserATA === void 0) { createUserATA = true; }
6931
6774
  if (unWrapSol === void 0) { unWrapSol = false; }
@@ -7130,9 +6973,9 @@ var PerpetualsClient = (function () {
7130
6973
  }
7131
6974
  return [3, 20];
7132
6975
  case 19:
7133
- err_49 = _g.sent();
7134
- console.error("perpClient Swap error:: ", err_49);
7135
- throw err_49;
6976
+ err_46 = _g.sent();
6977
+ console.error("perpClient Swap error:: ", err_46);
6978
+ throw err_46;
7136
6979
  case 20: return [2, {
7137
6980
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7138
6981
  additionalSigners: additionalSigners
@@ -7142,7 +6985,7 @@ var PerpetualsClient = (function () {
7142
6985
  });
7143
6986
  };
7144
6987
  this.swapFeeInternal = function (rewardTokenSymbol, swapTokenSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7145
- var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_50;
6988
+ var rewardCustody, custody, publicKey, preInstructions, instructions, postInstructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, _i, _a, custody_1, params, inx, err_47;
7146
6989
  return __generator(this, function (_b) {
7147
6990
  switch (_b.label) {
7148
6991
  case 0:
@@ -7202,9 +7045,9 @@ var PerpetualsClient = (function () {
7202
7045
  instructions.push(inx);
7203
7046
  return [3, 4];
7204
7047
  case 3:
7205
- err_50 = _b.sent();
7206
- console.error("perpClient Swap error:: ", err_50);
7207
- throw err_50;
7048
+ err_47 = _b.sent();
7049
+ console.error("perpClient Swap error:: ", err_47);
7050
+ throw err_47;
7208
7051
  case 4: return [2, {
7209
7052
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7210
7053
  additionalSigners: additionalSigners
@@ -7213,7 +7056,7 @@ var PerpetualsClient = (function () {
7213
7056
  });
7214
7057
  }); };
7215
7058
  this.setLpTokenPrice = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7216
- var instructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, setLpTokenPriceInstruction, err_51;
7059
+ var instructions, additionalSigners, custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, setLpTokenPriceInstruction, err_48;
7217
7060
  return __generator(this, function (_d) {
7218
7061
  switch (_d.label) {
7219
7062
  case 0:
@@ -7261,9 +7104,9 @@ var PerpetualsClient = (function () {
7261
7104
  instructions.push(setLpTokenPriceInstruction);
7262
7105
  return [3, 4];
7263
7106
  case 3:
7264
- err_51 = _d.sent();
7265
- console.log("perpClient setLpTokenPriceInstruction error:: ", err_51);
7266
- throw err_51;
7107
+ err_48 = _d.sent();
7108
+ console.log("perpClient setLpTokenPriceInstruction error:: ", err_48);
7109
+ throw err_48;
7267
7110
  case 4: return [2, {
7268
7111
  instructions: __spreadArray([], instructions, true),
7269
7112
  additionalSigners: additionalSigners
@@ -7311,7 +7154,7 @@ var PerpetualsClient = (function () {
7311
7154
  });
7312
7155
  }); };
7313
7156
  this.setAdminSigners = function (admins, minSignatures) { return __awaiter(_this, void 0, void 0, function () {
7314
- var adminMetas, _i, admins_2, admin, err_52;
7157
+ var adminMetas, _i, admins_2, admin, err_49;
7315
7158
  return __generator(this, function (_a) {
7316
7159
  switch (_a.label) {
7317
7160
  case 0:
@@ -7341,11 +7184,11 @@ var PerpetualsClient = (function () {
7341
7184
  _a.sent();
7342
7185
  return [3, 4];
7343
7186
  case 3:
7344
- err_52 = _a.sent();
7187
+ err_49 = _a.sent();
7345
7188
  if (this.printErrors) {
7346
- console.error("setAdminSigners err:", err_52);
7189
+ console.error("setAdminSigners err:", err_49);
7347
7190
  }
7348
- throw err_52;
7191
+ throw err_49;
7349
7192
  case 4: return [2];
7350
7193
  }
7351
7194
  });
@@ -7534,7 +7377,7 @@ var PerpetualsClient = (function () {
7534
7377
  });
7535
7378
  }); };
7536
7379
  this.protocolWithdrawFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7537
- var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_53;
7380
+ var publicKey, custodyConfig, receivingTokenAccount, instructions, additionalSigners, withdrawFeesIx, err_50;
7538
7381
  return __generator(this, function (_a) {
7539
7382
  switch (_a.label) {
7540
7383
  case 0:
@@ -7567,9 +7410,9 @@ var PerpetualsClient = (function () {
7567
7410
  instructions.push(withdrawFeesIx);
7568
7411
  return [3, 5];
7569
7412
  case 4:
7570
- err_53 = _a.sent();
7571
- console.log("perpClient setPool error:: ", err_53);
7572
- throw err_53;
7413
+ err_50 = _a.sent();
7414
+ console.log("perpClient setPool error:: ", err_50);
7415
+ throw err_50;
7573
7416
  case 5: return [2, {
7574
7417
  instructions: __spreadArray([], instructions, true),
7575
7418
  additionalSigners: additionalSigners
@@ -7578,7 +7421,7 @@ var PerpetualsClient = (function () {
7578
7421
  });
7579
7422
  }); };
7580
7423
  this.moveProtocolFees = function (rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7581
- var publicKey, custodyConfig, instructions, additionalSigners, moveProtocolFeesIx, err_54;
7424
+ var publicKey, custodyConfig, instructions, additionalSigners, moveProtocolFeesIx, err_51;
7582
7425
  return __generator(this, function (_a) {
7583
7426
  switch (_a.label) {
7584
7427
  case 0:
@@ -7612,9 +7455,9 @@ var PerpetualsClient = (function () {
7612
7455
  instructions.push(moveProtocolFeesIx);
7613
7456
  return [3, 4];
7614
7457
  case 3:
7615
- err_54 = _a.sent();
7616
- console.log("perpClient setPool error:: ", err_54);
7617
- throw err_54;
7458
+ err_51 = _a.sent();
7459
+ console.log("perpClient setPool error:: ", err_51);
7460
+ throw err_51;
7618
7461
  case 4: return [2, {
7619
7462
  instructions: __spreadArray([], instructions, true),
7620
7463
  additionalSigners: additionalSigners
@@ -7623,7 +7466,7 @@ var PerpetualsClient = (function () {
7623
7466
  });
7624
7467
  }); };
7625
7468
  this.setProtocolFeeShareBps = function (feeShareBps, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7626
- var publicKey, setProtocolFeeShareBpsIx, err_55;
7469
+ var publicKey, setProtocolFeeShareBpsIx, err_52;
7627
7470
  return __generator(this, function (_a) {
7628
7471
  switch (_a.label) {
7629
7472
  case 0:
@@ -7643,15 +7486,15 @@ var PerpetualsClient = (function () {
7643
7486
  setProtocolFeeShareBpsIx = _a.sent();
7644
7487
  return [2, setProtocolFeeShareBpsIx];
7645
7488
  case 2:
7646
- err_55 = _a.sent();
7647
- console.log("perpClient setProtocolFeeShareBpsIx error:: ", err_55);
7648
- throw err_55;
7489
+ err_52 = _a.sent();
7490
+ console.log("perpClient setProtocolFeeShareBpsIx error:: ", err_52);
7491
+ throw err_52;
7649
7492
  case 3: return [2];
7650
7493
  }
7651
7494
  });
7652
7495
  }); };
7653
7496
  this.setPermissions = function (permissions) { return __awaiter(_this, void 0, void 0, function () {
7654
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_56;
7497
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setPermissionsInstruction, err_53;
7655
7498
  return __generator(this, function (_a) {
7656
7499
  switch (_a.label) {
7657
7500
  case 0:
@@ -7678,9 +7521,9 @@ var PerpetualsClient = (function () {
7678
7521
  instructions.push(setPermissionsInstruction);
7679
7522
  return [3, 4];
7680
7523
  case 3:
7681
- err_56 = _a.sent();
7682
- console.log("perpClient setPool error:: ", err_56);
7683
- throw err_56;
7524
+ err_53 = _a.sent();
7525
+ console.log("perpClient setPool error:: ", err_53);
7526
+ throw err_53;
7684
7527
  case 4: return [2, {
7685
7528
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7686
7529
  additionalSigners: additionalSigners
@@ -7689,7 +7532,7 @@ var PerpetualsClient = (function () {
7689
7532
  });
7690
7533
  }); };
7691
7534
  this.reimburse = function (tokenMint, amountIn, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7692
- var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_57;
7535
+ var custodyAccountMetas, custodyOracleAccountMetas, markets, _i, _a, custody, _b, _c, market, instructions, additionalSigners, custodyConfig, reimburse, _d, _e, err_54;
7693
7536
  var _f;
7694
7537
  return __generator(this, function (_g) {
7695
7538
  switch (_g.label) {
@@ -7750,9 +7593,9 @@ var PerpetualsClient = (function () {
7750
7593
  instructions.push(reimburse);
7751
7594
  return [3, 5];
7752
7595
  case 4:
7753
- err_57 = _g.sent();
7754
- console.log("perpClient setPool error:: ", err_57);
7755
- throw err_57;
7596
+ err_54 = _g.sent();
7597
+ console.log("perpClient setPool error:: ", err_54);
7598
+ throw err_54;
7756
7599
  case 5: return [2, {
7757
7600
  instructions: __spreadArray([], instructions, true),
7758
7601
  additionalSigners: additionalSigners
@@ -7761,7 +7604,7 @@ var PerpetualsClient = (function () {
7761
7604
  });
7762
7605
  }); };
7763
7606
  this.setInternalOraclePrice = function (tokenMint, price, expo, conf, ema, publishTime, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7764
- var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_58;
7607
+ var instructions, additionalSigners, custodyConfig, setInternalOraclePrice, err_55;
7765
7608
  return __generator(this, function (_a) {
7766
7609
  switch (_a.label) {
7767
7610
  case 0:
@@ -7794,9 +7637,9 @@ var PerpetualsClient = (function () {
7794
7637
  instructions.push(setInternalOraclePrice);
7795
7638
  return [3, 4];
7796
7639
  case 3:
7797
- err_58 = _a.sent();
7798
- console.log("perpClient setInternalOracleAccount error:: ", err_58);
7799
- throw err_58;
7640
+ err_55 = _a.sent();
7641
+ console.log("perpClient setInternalOracleAccount error:: ", err_55);
7642
+ throw err_55;
7800
7643
  case 4: return [2, {
7801
7644
  instructions: __spreadArray([], instructions, true),
7802
7645
  additionalSigners: additionalSigners
@@ -7805,7 +7648,7 @@ var PerpetualsClient = (function () {
7805
7648
  });
7806
7649
  }); };
7807
7650
  this.setInternalOraclePriceBatch = function (tokenMintList, tokenInternalPrices, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
7808
- var ALL_CUSTODY_CONFIGS, accountMetas, _loop_1, _i, tokenMintList_1, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_59;
7651
+ var ALL_CUSTODY_CONFIGS, accountMetas, _loop_1, _i, tokenMintList_1, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_56;
7809
7652
  return __generator(this, function (_a) {
7810
7653
  switch (_a.label) {
7811
7654
  case 0:
@@ -7855,9 +7698,9 @@ var PerpetualsClient = (function () {
7855
7698
  instructions.push(setInternalOraclePrice);
7856
7699
  return [3, 4];
7857
7700
  case 3:
7858
- err_59 = _a.sent();
7859
- console.log("perpClient setInternalOracleAccount error:: ", err_59);
7860
- throw err_59;
7701
+ err_56 = _a.sent();
7702
+ console.log("perpClient setInternalOracleAccount error:: ", err_56);
7703
+ throw err_56;
7861
7704
  case 4: return [2, {
7862
7705
  instructions: __spreadArray([], instructions, true),
7863
7706
  additionalSigners: additionalSigners
@@ -7866,7 +7709,7 @@ var PerpetualsClient = (function () {
7866
7709
  });
7867
7710
  }); };
7868
7711
  this.setInternalOracleEmaPriceBatch = function (tokenMintList, tokenInternalEmaPrices, POOL_CONFIGS) { return __awaiter(_this, void 0, void 0, function () {
7869
- var ALL_CUSTODY_CONFIGS, accountMetas, _loop_2, _i, tokenMintList_2, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_60;
7712
+ var ALL_CUSTODY_CONFIGS, accountMetas, _loop_2, _i, tokenMintList_2, tokenMint, instructions, additionalSigners, setInternalOraclePrice, err_57;
7870
7713
  return __generator(this, function (_a) {
7871
7714
  switch (_a.label) {
7872
7715
  case 0:
@@ -7916,9 +7759,9 @@ var PerpetualsClient = (function () {
7916
7759
  instructions.push(setInternalOraclePrice);
7917
7760
  return [3, 4];
7918
7761
  case 3:
7919
- err_60 = _a.sent();
7920
- console.log("perpClient setInternalOracleAccount error:: ", err_60);
7921
- throw err_60;
7762
+ err_57 = _a.sent();
7763
+ console.log("perpClient setInternalOracleAccount error:: ", err_57);
7764
+ throw err_57;
7922
7765
  case 4: return [2, {
7923
7766
  instructions: __spreadArray([], instructions, true),
7924
7767
  additionalSigners: additionalSigners
@@ -7927,7 +7770,7 @@ var PerpetualsClient = (function () {
7927
7770
  });
7928
7771
  }); };
7929
7772
  this.renameFlp = function (flag, lpTokenName, lpTokenSymbol, lpTokenUri, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7930
- var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_61;
7773
+ var publicKey, instructions, additionalSigners, lpTokenMint, lpMetadataAccount, renameFlp, err_58;
7931
7774
  return __generator(this, function (_a) {
7932
7775
  switch (_a.label) {
7933
7776
  case 0:
@@ -7965,8 +7808,8 @@ var PerpetualsClient = (function () {
7965
7808
  instructions.push(renameFlp);
7966
7809
  return [3, 4];
7967
7810
  case 3:
7968
- err_61 = _a.sent();
7969
- console.log("perpClient renameFlp error:: ", err_61);
7811
+ err_58 = _a.sent();
7812
+ console.log("perpClient renameFlp error:: ", err_58);
7970
7813
  return [3, 4];
7971
7814
  case 4: return [2, {
7972
7815
  instructions: __spreadArray([], instructions, true),
@@ -7976,7 +7819,7 @@ var PerpetualsClient = (function () {
7976
7819
  });
7977
7820
  }); };
7978
7821
  this.initStake = function (stakingFeeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7979
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_62;
7822
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, lpTokenMint, stakedLpTokenAccount, rewardCustodyConfig, initStakeInstruction, err_59;
7980
7823
  return __generator(this, function (_a) {
7981
7824
  switch (_a.label) {
7982
7825
  case 0:
@@ -8014,9 +7857,9 @@ var PerpetualsClient = (function () {
8014
7857
  instructions.push(initStakeInstruction);
8015
7858
  return [3, 4];
8016
7859
  case 3:
8017
- err_62 = _a.sent();
8018
- console.log("perpClient InitStaking error:: ", err_62);
8019
- throw err_62;
7860
+ err_59 = _a.sent();
7861
+ console.log("perpClient InitStaking error:: ", err_59);
7862
+ throw err_59;
8020
7863
  case 4: return [2, {
8021
7864
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8022
7865
  additionalSigners: additionalSigners
@@ -8025,7 +7868,7 @@ var PerpetualsClient = (function () {
8025
7868
  });
8026
7869
  }); };
8027
7870
  this.initCompounding = function (feeShareBps, metadataTitle, metadataSymbol, metadataUri, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8028
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_63;
7871
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyConfig, compoundingTokenMint, compoundingVault, metadataAccount, initCompoundingInstruction, err_60;
8029
7872
  return __generator(this, function (_a) {
8030
7873
  switch (_a.label) {
8031
7874
  case 0:
@@ -8070,9 +7913,9 @@ var PerpetualsClient = (function () {
8070
7913
  instructions.push(initCompoundingInstruction);
8071
7914
  return [3, 4];
8072
7915
  case 3:
8073
- err_63 = _a.sent();
8074
- console.log("perpClient initCompounding error:: ", err_63);
8075
- throw err_63;
7916
+ err_60 = _a.sent();
7917
+ console.log("perpClient initCompounding error:: ", err_60);
7918
+ throw err_60;
8076
7919
  case 4: return [2, {
8077
7920
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8078
7921
  additionalSigners: additionalSigners
@@ -8081,7 +7924,7 @@ var PerpetualsClient = (function () {
8081
7924
  });
8082
7925
  }); };
8083
7926
  this.initTokenVault = function (token_permissions, tokens_to_distribute, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8084
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_64;
7927
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenMint, fundingTokenAccount, initTokenVaultInstruction, err_61;
8085
7928
  return __generator(this, function (_a) {
8086
7929
  switch (_a.label) {
8087
7930
  case 0:
@@ -8122,9 +7965,9 @@ var PerpetualsClient = (function () {
8122
7965
  instructions.push(initTokenVaultInstruction);
8123
7966
  return [3, 4];
8124
7967
  case 3:
8125
- err_64 = _a.sent();
8126
- console.log("perpClient InitTokenVaultInstruction error:: ", err_64);
8127
- throw err_64;
7968
+ err_61 = _a.sent();
7969
+ console.log("perpClient InitTokenVaultInstruction error:: ", err_61);
7970
+ throw err_61;
8128
7971
  case 4: return [2, {
8129
7972
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8130
7973
  additionalSigners: additionalSigners
@@ -8133,7 +7976,7 @@ var PerpetualsClient = (function () {
8133
7976
  });
8134
7977
  }); };
8135
7978
  this.setTokenVaultConfig = function (token_permissions, withdrawTimeLimit, withdrawInstantFee, stakeLevel, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8136
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_65;
7979
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, setTokenVaultConfigInstruction, err_62;
8137
7980
  return __generator(this, function (_a) {
8138
7981
  switch (_a.label) {
8139
7982
  case 0:
@@ -8164,9 +8007,9 @@ var PerpetualsClient = (function () {
8164
8007
  instructions.push(setTokenVaultConfigInstruction);
8165
8008
  return [3, 4];
8166
8009
  case 3:
8167
- err_65 = _a.sent();
8168
- console.log("perpClient setTokenVaultConfigInstruction error:: ", err_65);
8169
- throw err_65;
8010
+ err_62 = _a.sent();
8011
+ console.log("perpClient setTokenVaultConfigInstruction error:: ", err_62);
8012
+ throw err_62;
8170
8013
  case 4: return [2, {
8171
8014
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8172
8015
  additionalSigners: additionalSigners
@@ -8175,7 +8018,7 @@ var PerpetualsClient = (function () {
8175
8018
  });
8176
8019
  }); };
8177
8020
  this.withdrawInstantFee = function (poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8178
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_66;
8021
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, receivingTokenAccount, withdrawInstantFeeInstruction, err_63;
8179
8022
  return __generator(this, function (_a) {
8180
8023
  switch (_a.label) {
8181
8024
  case 0:
@@ -8214,9 +8057,9 @@ var PerpetualsClient = (function () {
8214
8057
  instructions.push(withdrawInstantFeeInstruction);
8215
8058
  return [3, 6];
8216
8059
  case 5:
8217
- err_66 = _a.sent();
8218
- console.log("perpClient withdrawInstantFeeInstruction error:: ", err_66);
8219
- throw err_66;
8060
+ err_63 = _a.sent();
8061
+ console.log("perpClient withdrawInstantFeeInstruction error:: ", err_63);
8062
+ throw err_63;
8220
8063
  case 6: return [2, {
8221
8064
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8222
8065
  additionalSigners: additionalSigners
@@ -8225,7 +8068,7 @@ var PerpetualsClient = (function () {
8225
8068
  });
8226
8069
  }); };
8227
8070
  this.initRevenueTokenAccount = function (feeShareBps, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8228
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_67;
8071
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, initRevenueTokenAccountInstruction, err_64;
8229
8072
  return __generator(this, function (_a) {
8230
8073
  switch (_a.label) {
8231
8074
  case 0:
@@ -8262,9 +8105,9 @@ var PerpetualsClient = (function () {
8262
8105
  instructions.push(initRevenueTokenAccountInstruction);
8263
8106
  return [3, 4];
8264
8107
  case 3:
8265
- err_67 = _a.sent();
8266
- console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_67);
8267
- throw err_67;
8108
+ err_64 = _a.sent();
8109
+ console.log("perpClient initRevenueTokenAccountInstruction error:: ", err_64);
8110
+ throw err_64;
8268
8111
  case 4: return [2, {
8269
8112
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8270
8113
  additionalSigners: additionalSigners
@@ -8273,7 +8116,7 @@ var PerpetualsClient = (function () {
8273
8116
  });
8274
8117
  }); };
8275
8118
  this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8276
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_68;
8119
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_65;
8277
8120
  return __generator(this, function (_a) {
8278
8121
  switch (_a.label) {
8279
8122
  case 0:
@@ -8312,9 +8155,9 @@ var PerpetualsClient = (function () {
8312
8155
  instructions.push(distributeTokenRewardInstruction);
8313
8156
  return [3, 4];
8314
8157
  case 3:
8315
- err_68 = _a.sent();
8316
- console.log("perpClient distributeTokenRewardInstruction error:: ", err_68);
8317
- throw err_68;
8158
+ err_65 = _a.sent();
8159
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_65);
8160
+ throw err_65;
8318
8161
  case 4: return [2, {
8319
8162
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8320
8163
  additionalSigners: additionalSigners
@@ -8323,7 +8166,7 @@ var PerpetualsClient = (function () {
8323
8166
  });
8324
8167
  }); };
8325
8168
  this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
8326
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_69;
8169
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_66;
8327
8170
  return __generator(this, function (_a) {
8328
8171
  switch (_a.label) {
8329
8172
  case 0:
@@ -8351,9 +8194,9 @@ var PerpetualsClient = (function () {
8351
8194
  instructions.push(setTokenStakeLevelInstruction);
8352
8195
  return [3, 4];
8353
8196
  case 3:
8354
- err_69 = _a.sent();
8355
- console.log("perpClient setTokenStakeLevelInstruction error:: ", err_69);
8356
- throw err_69;
8197
+ err_66 = _a.sent();
8198
+ console.log("perpClient setTokenStakeLevelInstruction error:: ", err_66);
8199
+ throw err_66;
8357
8200
  case 4: return [2, {
8358
8201
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8359
8202
  additionalSigners: additionalSigners
@@ -8362,7 +8205,7 @@ var PerpetualsClient = (function () {
8362
8205
  });
8363
8206
  }); };
8364
8207
  this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
8365
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_70;
8208
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_67;
8366
8209
  return __generator(this, function (_a) {
8367
8210
  switch (_a.label) {
8368
8211
  case 0:
@@ -8394,9 +8237,9 @@ var PerpetualsClient = (function () {
8394
8237
  instructions.push(setTokenRewardInstruction);
8395
8238
  return [3, 4];
8396
8239
  case 3:
8397
- err_70 = _a.sent();
8398
- console.log("perpClient setTokenRewardInstruction error:: ", err_70);
8399
- throw err_70;
8240
+ err_67 = _a.sent();
8241
+ console.log("perpClient setTokenRewardInstruction error:: ", err_67);
8242
+ throw err_67;
8400
8243
  case 4: return [2, {
8401
8244
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
8402
8245
  additionalSigners: additionalSigners