flash-sdk 9.0.2-alpha.0 → 9.0.2-alpha.10

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,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import { BN } from "@coral-xyz/anchor";
3
2
  import { ContractOraclePrice } from "./types";
4
3
  export declare class OraclePrice {
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import { BN } from "@coral-xyz/anchor";
3
2
  import { PublicKey } from "@solana/web3.js";
4
3
  import { LimitOrder, Order, TriggerOrder } from "./types";
@@ -1,5 +1,3 @@
1
- /// <reference types="bn.js" />
2
- /// <reference types="node" />
3
1
  import { Program, AnchorProvider, BN } from "@coral-xyz/anchor";
4
2
  import { PublicKey, TransactionInstruction, Commitment, Signer, AddressLookupTableAccount, VersionedTransaction } from "@solana/web3.js";
5
3
  import { PoolAccount } from "./PoolAccount";
@@ -4745,8 +4743,8 @@ export declare class PerpetualsClient {
4745
4743
  getSizeAmountWithSwapSync: (amountIn: BN, leverage: string, side: Side, poolAccount: PoolAccount, inputTokenPrice: OraclePrice, inputTokenEmaPrice: OraclePrice, inputTokenCustodyAccount: CustodyAccount, collateralTokenPrice: OraclePrice, collateralTokenEmaPrice: OraclePrice, collateralTokenCustodyAccount: CustodyAccount, swapOutTokenPrice: OraclePrice, swapOutTokenEmaPrice: OraclePrice, swapOutTokenCustodyAccount: CustodyAccount, targetTokenPrice: OraclePrice, targetTokenEmaPrice: OraclePrice, targetTokenCustodyAccount: CustodyAccount, swapPoolAumUsdMax: BN, poolConfig: PoolConfig, discountBps?: BN) => BN;
4746
4744
  getCollateralAmountWithFeeFromLeverageAndSize: (sizeAmount: BN, leverage: string, marketToken: Token, collateralToken: Token, side: Side, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, discountBps?: BN) => BN;
4747
4745
  getCollateralAmountWithSwapSync: (sizeAmount: BN, leverage: string, side: Side, poolAccount: PoolAccount, inputTokenPrice: OraclePrice, inputTokenEmaPrice: OraclePrice, inputTokenCustodyAccount: CustodyAccount, swapOutTokenPrice: OraclePrice, swapOutTokenEmaPrice: OraclePrice, swapOutTokenCustodyAccount: CustodyAccount, collateralTokenPrice: OraclePrice, collateralTokenEmaPrice: OraclePrice, collateralTokenCustodyAccount: CustodyAccount, targetTokenPrice: OraclePrice, targetTokenEmaPrice: OraclePrice, targetTokenCustodyAccount: CustodyAccount, swapPoolAumUsdMax: BN, poolConfig: PoolConfig) => BN;
4748
- getDecreaseSizeCollateralAndFeeSync: (positionAccount: PositionAccount, marketCorrelation: boolean, sizeDeltaUsd: BN, keepLevSame: boolean, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, marketConfig: MarketConfig, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, side: Side, poolConfig: PoolConfig, discountBps?: BN, debugLogs?: boolean) => RemoveCollateralData;
4749
- getMaxWithdrawableAmountSyncInternal: (positionAccount: PositionAccount, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, poolConfig: PoolConfig, closeAmountUsd?: BN, errorBandwidthPercentageUi?: number) => {
4746
+ getDecreaseSizeCollateralAndFeeSync: (positionAccount: PositionAccount, marketCorrelation: boolean, maxPayOffBps: BN, sizeDeltaUsd: BN, keepLevSame: boolean, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, marketConfig: MarketConfig, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, side: Side, poolConfig: PoolConfig, discountBps?: BN, debugLogs?: boolean) => RemoveCollateralData;
4747
+ getMaxWithdrawableAmountSyncInternal: (positionAccount: PositionAccount, targetPrice: OraclePrice, targetEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN, poolConfig: PoolConfig, errorBandwidthPercentageUi?: number) => {
4750
4748
  maxWithdrawableAmount: BN;
4751
4749
  maxWithdrawableAmountUsd: BN;
4752
4750
  diffUsd: BN;
@@ -4762,12 +4760,12 @@ export declare class PerpetualsClient {
4762
4760
  getCumulativeLockFeeSync: (custodyAccount: CustodyAccount, currentTimestamp: BN) => BN;
4763
4761
  getBorrowRateSync: (custodyAccount: CustodyAccount, currentUtilization: BN) => BN;
4764
4762
  getLockFeeAndUnsettledUsdForPosition: (position: PositionAccount, collateralCustodyAccount: CustodyAccount, currentTimestamp: BN) => BN;
4765
- getLockedUsd: (sideUsd: BN, side: Side, marketCorrelation: boolean, maxPayOffBps: BN) => BN;
4763
+ getLockedUsd: (sizeUsd: BN, collateralUsd: BN, side: Side, marketCorrelation: boolean, maxPayOffBps: BN) => BN;
4766
4764
  getLiquidationPriceContractHelper: (entryOraclePrice: OraclePrice, lockAndUnsettledFeeUsd: BN, side: Side, targetCustodyAccount: CustodyAccount, positionAccount: PositionAccount) => OraclePrice;
4767
4765
  getLiquidationPriceSync: (collateralUsd: BN, sizeAmount: BN, entryOraclePrice: OraclePrice, lockAndUnsettledFeeUsd: BN, side: Side, targetPrice: OraclePrice, targetCustodyAccount: CustodyAccount, positionAccount: PositionAccount) => OraclePrice;
4768
4766
  getLiquidationPriceWithOrder: (collateralUsd: BN, sizeAmount: BN, sizeUsd: BN, sizeDecimals: number, limitOraclePrice: OraclePrice, side: Side, targetCustodyAccount: CustodyAccount) => OraclePrice;
4769
- getMaxProfitPriceSync: (entryPrice: OraclePrice, marketCorrelation: boolean, side: Side, positionAccount: PositionAccount) => OraclePrice;
4770
- getEstimateProfitLossforTpSlEntry: (positionAccount: PositionAccount | null, isTakeProfit: boolean, userEntrytpSlOraclePrice: OraclePrice, collateralDeltaAmount: BN, sizeDeltaAmount: BN, side: Side, marketAccountPk: PublicKey, targetTokenPrice: OraclePrice, targetTokenEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, poolConfig: PoolConfig) => {
4767
+ getMaxProfitPriceSync: (entryPrice: OraclePrice, marketCorrelation: boolean, side: Side, collateralPrice: OraclePrice, positionAccount: PositionAccount) => OraclePrice;
4768
+ getEstimateProfitLossforTpSlEntry: (positionAccount: PositionAccount | null, isTakeProfit: boolean, userEntrytpSlOraclePrice: OraclePrice, collateralDeltaAmount: BN, sizeDeltaAmount: BN, side: Side, marketCorrelation: boolean, maxPayOffBps: BN, marketAccountPk: PublicKey, targetTokenPrice: OraclePrice, targetTokenEmaPrice: OraclePrice, targetCustodyAccount: CustodyAccount, collateralPrice: OraclePrice, collateralEmaPrice: OraclePrice, collateralCustodyAccount: CustodyAccount, poolConfig: PoolConfig) => {
4771
4769
  pnlUsd: BN;
4772
4770
  pnlPercentage: BN;
4773
4771
  };
@@ -4956,7 +4954,7 @@ export declare class PerpetualsClient {
4956
4954
  instructions: TransactionInstruction[];
4957
4955
  additionalSigners: Signer[];
4958
4956
  }>;
4959
- settleRebates: (owner: PublicKey, rebateSymbol: string, rewardSymbol: string, poolConfig: PoolConfig, createUserATA?: boolean) => Promise<{
4957
+ settleRebates: (rebateSymbol: string, rewardSymbol: string, poolConfig: PoolConfig) => Promise<{
4960
4958
  instructions: TransactionInstruction[];
4961
4959
  additionalSigners: Signer[];
4962
4960
  }>;
@@ -5085,6 +5083,10 @@ export declare class PerpetualsClient {
5085
5083
  instructions: TransactionInstruction[];
5086
5084
  additionalSigners: Signer[];
5087
5085
  }>;
5086
+ initRebateVault: (allowRebatePayout: boolean, rebateSymbol: string, poolConfig: PoolConfig) => Promise<{
5087
+ instructions: TransactionInstruction[];
5088
+ additionalSigners: Signer[];
5089
+ }>;
5088
5090
  distributeTokenReward: (amount: BN, epochCount: number, rewardSymbol: string, poolConfig: PoolConfig) => Promise<{
5089
5091
  instructions: TransactionInstruction[];
5090
5092
  additionalSigners: Signer[];
@@ -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.");
@@ -961,7 +961,7 @@ var PerpetualsClient = (function () {
961
961
  }
962
962
  return collateralInInputToken;
963
963
  };
964
- this.getDecreaseSizeCollateralAndFeeSync = function (positionAccount, marketCorrelation, sizeDeltaUsd, keepLevSame, targetPrice, targetEmaPrice, marketConfig, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, side, poolConfig, discountBps, debugLogs) {
964
+ this.getDecreaseSizeCollateralAndFeeSync = function (positionAccount, marketCorrelation, maxPayOffBps, sizeDeltaUsd, keepLevSame, targetPrice, targetEmaPrice, marketConfig, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, side, poolConfig, discountBps, debugLogs) {
965
965
  if (discountBps === void 0) { discountBps = constants_1.BN_ZERO; }
966
966
  if (debugLogs === void 0) { debugLogs = false; }
967
967
  if (!marketConfig.marketAccount.equals(positionAccount.market)) {
@@ -984,7 +984,6 @@ var PerpetualsClient = (function () {
984
984
  var closeRatio = (positionDelta.sizeAmount.mul(decimalPower)).div(positionAccount.sizeAmount);
985
985
  positionDelta.sizeUsd = (positionAccount.sizeUsd.mul(closeRatio)).div(decimalPower);
986
986
  positionDelta.lockedAmount = (positionAccount.lockedAmount.mul(closeRatio)).div(decimalPower);
987
- positionDelta.lockedUsd = (positionAccount.lockedUsd.mul(closeRatio)).div(decimalPower);
988
987
  positionDelta.collateralUsd = (positionAccount.collateralUsd.mul(closeRatio)).div(decimalPower);
989
988
  positionDelta.unsettledFeesUsd = (positionAccount.unsettledFeesUsd.mul(closeRatio)).div(decimalPower);
990
989
  positionDelta.degenSizeUsd = positionAccount.degenSizeUsd.mul(closeRatio).div(decimalPower);
@@ -1012,14 +1011,21 @@ var PerpetualsClient = (function () {
1012
1011
  feesAmountUsd = assetsUsd.sub(newPnl.lossUsd);
1013
1012
  }
1014
1013
  var closeAmount = collateralMinMaxPrice.max.getTokenAmount(closeAmountUsd, collateralCustodyAccount.decimals);
1014
+ var newLockAmount = collateralMinMaxPrice.max.getTokenAmount(_this.getLockedUsd(constants_1.BN_ZERO, closeAmountUsd, side, marketCorrelation, maxPayOffBps), collateralCustodyAccount.decimals);
1015
+ if (newLockAmount.gt(positionDelta.lockedAmount)) {
1016
+ positionDelta.lockedAmount = constants_1.BN_ZERO;
1017
+ }
1018
+ else {
1019
+ positionDelta.lockedAmount = positionDelta.lockedAmount.sub(newLockAmount);
1020
+ }
1015
1021
  var newPosition = PositionAccount_1.PositionAccount.from(positionAccount.publicKey, __assign({}, positionAccount));
1016
1022
  newPosition.sizeAmount = positionAccount.sizeAmount.sub(positionDelta.sizeAmount);
1017
1023
  newPosition.sizeUsd = positionAccount.sizeUsd.sub(positionDelta.sizeUsd);
1018
- newPosition.lockedUsd = positionAccount.lockedUsd.sub(positionDelta.lockedUsd);
1019
1024
  newPosition.lockedAmount = positionAccount.lockedAmount.sub(positionDelta.lockedAmount);
1020
1025
  newPosition.collateralUsd = positionAccount.collateralUsd.sub(positionDelta.collateralUsd);
1021
1026
  newPosition.unsettledFeesUsd = positionAccount.unsettledFeesUsd.sub(positionDelta.unsettledFeesUsd);
1022
1027
  newPosition.degenSizeUsd = positionAccount.degenSizeUsd.sub(positionDelta.degenSizeUsd);
1028
+ newPosition.collateralUsd = newPosition.collateralUsd.add(closeAmountUsd);
1023
1029
  var feeUsdWithDiscount = constants_1.BN_ZERO;
1024
1030
  var feeUsd = sizeDeltaUsd.mul(targetCustodyAccount.fees.closePosition).div(new anchor_1.BN(constants_1.RATE_POWER));
1025
1031
  if (discountBps.gt(constants_1.BN_ZERO)) {
@@ -1033,24 +1039,25 @@ var PerpetualsClient = (function () {
1033
1039
  feeUsdWithDiscount = feeUsdWithDiscount.add(lockAndUnsettledFeeUsd);
1034
1040
  if (keepLevSame) {
1035
1041
  var collateralAmountReceived = closeAmount;
1036
- var collateralAmountRecievedUsd = closeAmountUsd;
1037
- var _a = _this.getMaxWithdrawableAmountSyncInternal(newPosition, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, poolConfig, closeAmountUsd), maxWithdrawableAmount = _a.maxWithdrawableAmount, diffUsd = _a.diffUsd;
1042
+ var collateralAmountReceivedUsd = closeAmountUsd;
1043
+ var _a = _this.getMaxWithdrawableAmountSyncInternal(newPosition, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, poolConfig), maxWithdrawableAmount = _a.maxWithdrawableAmount, maxWithdrawableAmountUsd = _a.maxWithdrawableAmountUsd, diffUsd = _a.diffUsd;
1038
1044
  if (debugLogs) {
1039
1045
  console.log("maxWithdrawableAmount ", maxWithdrawableAmount.toString(), keepLevSame);
1040
1046
  console.log("collateralAmountReceived ", collateralAmountReceived.toString(), keepLevSame);
1041
1047
  }
1042
- if (collateralAmountReceived.lt(constants_1.BN_ZERO)) {
1048
+ if (collateralAmountReceivedUsd.lt(constants_1.BN_ZERO)) {
1043
1049
  collateralAmountReceived = constants_1.BN_ZERO;
1044
- collateralAmountRecievedUsd = constants_1.BN_ZERO;
1050
+ collateralAmountReceivedUsd = constants_1.BN_ZERO;
1045
1051
  }
1046
- else if (collateralAmountReceived.gt(maxWithdrawableAmount)) {
1052
+ else if (collateralAmountReceivedUsd.gt(maxWithdrawableAmountUsd)) {
1047
1053
  if (debugLogs) {
1048
1054
  console.log("exceeding to redicing maxWithdrawableAmount ", maxWithdrawableAmount.toString(), collateralAmountReceived.toString());
1049
1055
  }
1050
1056
  collateralAmountReceived = maxWithdrawableAmount;
1051
- collateralAmountRecievedUsd = collateralMinMaxPrice.min.getAssetAmountUsd(maxWithdrawableAmount, collateralCustodyAccount.decimals);
1057
+ collateralAmountReceivedUsd = maxWithdrawableAmountUsd;
1052
1058
  }
1053
1059
  var entryPrice = OraclePrice_1.OraclePrice.from({ price: newPosition.entryPrice.price, exponent: new anchor_1.BN(newPosition.entryPrice.exponent), confidence: constants_1.BN_ZERO, timestamp: constants_1.BN_ZERO });
1060
+ newPosition.collateralUsd = newPosition.collateralUsd.sub(collateralAmountReceivedUsd);
1054
1061
  var lockAndUnsettledFeeUsdNew = _this.getLockFeeAndUnsettledUsdForPosition(newPosition, collateralCustodyAccount, currentTimestamp);
1055
1062
  var finalLiquidationPrice = _this.getLiquidationPriceContractHelper(entryPrice, lockAndUnsettledFeeUsdNew, side, targetCustodyAccount, newPosition);
1056
1063
  var finalPnl = _this.getPnlSync(newPosition, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, targetCustodyAccount.pricing.delaySeconds, poolConfig);
@@ -1063,8 +1070,8 @@ var PerpetualsClient = (function () {
1063
1070
  lockAndUnsettledFeeUsd: lockAndUnsettledFeeUsd,
1064
1071
  newLev: newLev,
1065
1072
  liquidationPrice: finalLiquidationPrice,
1066
- collateralAmountRecieved: collateralAmountReceived,
1067
- collateralAmountRecievedUsd: collateralAmountRecievedUsd,
1073
+ collateralAmountReceived: collateralAmountReceived,
1074
+ collateralAmountReceivedUsd: collateralAmountReceivedUsd,
1068
1075
  newCollateralUsd: newPosition.collateralUsd.add(diffUsd),
1069
1076
  newPnl: finalPnlUsd
1070
1077
  };
@@ -1073,8 +1080,7 @@ var PerpetualsClient = (function () {
1073
1080
  throw "only same leverage is supported for now";
1074
1081
  }
1075
1082
  };
1076
- this.getMaxWithdrawableAmountSyncInternal = function (positionAccount, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, poolConfig, closeAmountUsd, errorBandwidthPercentageUi) {
1077
- if (closeAmountUsd === void 0) { closeAmountUsd = constants_1.BN_ZERO; }
1083
+ this.getMaxWithdrawableAmountSyncInternal = function (positionAccount, targetPrice, targetEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTimestamp, poolConfig, errorBandwidthPercentageUi) {
1078
1084
  if (errorBandwidthPercentageUi === void 0) { errorBandwidthPercentageUi = 5; }
1079
1085
  if (errorBandwidthPercentageUi > 100 || errorBandwidthPercentageUi < 0) {
1080
1086
  throw new Error("errorBandwidthPercentageUi cannot be >100 or <0");
@@ -1087,10 +1093,9 @@ var PerpetualsClient = (function () {
1087
1093
  var exitFeeUsd = positionAccount.sizeUsd.mul(targetCustodyAccount.fees.closePosition).div(new anchor_1.BN(constants_1.RATE_POWER));
1088
1094
  var lockAndUnsettledFeeUsd = _this.getLockFeeAndUnsettledUsdForPosition(positionAccount, collateralCustodyAccount, currentTimestamp);
1089
1095
  var lossUsd = profitLoss.lossUsd.add(exitFeeUsd).add(lockAndUnsettledFeeUsd);
1090
- var currentCollateralUsd = positionAccount.collateralUsd.sub(closeAmountUsd);
1091
1096
  var availableInitMarginUsd = constants_1.BN_ZERO;
1092
- if (profitLoss.lossUsd.lt(currentCollateralUsd)) {
1093
- availableInitMarginUsd = currentCollateralUsd.sub(lossUsd);
1097
+ if (profitLoss.lossUsd.lt(positionAccount.collateralUsd)) {
1098
+ availableInitMarginUsd = positionAccount.collateralUsd.sub(lossUsd);
1094
1099
  }
1095
1100
  else {
1096
1101
  console.log("profitLoss.lossUsd > coll :: should have been liquidated");
@@ -1220,12 +1225,12 @@ var PerpetualsClient = (function () {
1220
1225
  var cumulativeLockFee = _this.getCumulativeLockFeeSync(collateralCustodyAccount, currentTimestamp);
1221
1226
  var lockFeeUsd = constants_1.BN_ZERO;
1222
1227
  if (cumulativeLockFee.gt(position.cumulativeLockFeeSnapshot)) {
1223
- lockFeeUsd = cumulativeLockFee.sub(position.cumulativeLockFeeSnapshot).mul(position.lockedUsd).div(new anchor_1.BN(constants_1.RATE_POWER));
1228
+ lockFeeUsd = cumulativeLockFee.sub(position.cumulativeLockFeeSnapshot).mul(position.sizeUsd).div(new anchor_1.BN(constants_1.RATE_POWER));
1224
1229
  }
1225
1230
  lockFeeUsd = lockFeeUsd.add(position.unsettledFeesUsd);
1226
1231
  return lockFeeUsd;
1227
1232
  };
1228
- this.getLockedUsd = function (sideUsd, side, marketCorrelation, maxPayOffBps) {
1233
+ this.getLockedUsd = function (sizeUsd, collateralUsd, side, marketCorrelation, maxPayOffBps) {
1229
1234
  var maxPayOffBpsNew = constants_1.BN_ZERO;
1230
1235
  if (marketCorrelation || (0, types_1.isVariant)(side, 'short')) {
1231
1236
  maxPayOffBpsNew = anchor_1.BN.min(new anchor_1.BN(constants_1.BPS_POWER), maxPayOffBps);
@@ -1233,7 +1238,7 @@ var PerpetualsClient = (function () {
1233
1238
  else {
1234
1239
  maxPayOffBpsNew = maxPayOffBps;
1235
1240
  }
1236
- var lockedUsd = (sideUsd.mul(maxPayOffBpsNew)).div(new anchor_1.BN(constants_1.BPS_POWER));
1241
+ var lockedUsd = ((sizeUsd.add(collateralUsd)).mul(maxPayOffBpsNew)).div(new anchor_1.BN(constants_1.BPS_POWER));
1237
1242
  return lockedUsd;
1238
1243
  };
1239
1244
  this.getLiquidationPriceContractHelper = function (entryOraclePrice, lockAndUnsettledFeeUsd, side, targetCustodyAccount, positionAccount) {
@@ -1372,7 +1377,7 @@ var PerpetualsClient = (function () {
1372
1377
  }
1373
1378
  return liquidationPrice.price.isNeg() ? zeroOraclePrice : liquidationPrice;
1374
1379
  };
1375
- this.getMaxProfitPriceSync = function (entryPrice, marketCorrelation, side, positionAccount) {
1380
+ this.getMaxProfitPriceSync = function (entryPrice, marketCorrelation, side, collateralPrice, positionAccount) {
1376
1381
  var zeroOraclePrice = OraclePrice_1.OraclePrice.from({
1377
1382
  price: constants_1.BN_ZERO,
1378
1383
  exponent: constants_1.BN_ZERO,
@@ -1383,7 +1388,7 @@ var PerpetualsClient = (function () {
1383
1388
  return zeroOraclePrice;
1384
1389
  }
1385
1390
  var priceDiffProfit = OraclePrice_1.OraclePrice.from({
1386
- price: positionAccount.lockedUsd.mul(new anchor_1.BN(10).pow(new anchor_1.BN(positionAccount.sizeDecimals + 3)))
1391
+ price: (collateralPrice.price.mul(positionAccount.lockedAmount)).mul(new anchor_1.BN(10).pow(new anchor_1.BN(positionAccount.sizeDecimals + 3)))
1387
1392
  .div(positionAccount.sizeAmount),
1388
1393
  exponent: new anchor_1.BN(-1 * constants_1.RATE_DECIMALS),
1389
1394
  confidence: constants_1.BN_ZERO,
@@ -1411,7 +1416,7 @@ var PerpetualsClient = (function () {
1411
1416
  }
1412
1417
  return maxProfitPrice.price.isNeg() ? zeroOraclePrice : maxProfitPrice;
1413
1418
  };
1414
- this.getEstimateProfitLossforTpSlEntry = function (positionAccount, isTakeProfit, userEntrytpSlOraclePrice, collateralDeltaAmount, sizeDeltaAmount, side, marketAccountPk, targetTokenPrice, targetTokenEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, poolConfig) {
1419
+ this.getEstimateProfitLossforTpSlEntry = function (positionAccount, isTakeProfit, userEntrytpSlOraclePrice, collateralDeltaAmount, sizeDeltaAmount, side, marketCorrelation, maxPayOffBps, marketAccountPk, targetTokenPrice, targetTokenEmaPrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, poolConfig) {
1415
1420
  if (collateralDeltaAmount.isNeg() || sizeDeltaAmount.isNeg()) {
1416
1421
  throw new Error("Delta Amounts cannot be negative.");
1417
1422
  }
@@ -1441,10 +1446,9 @@ var PerpetualsClient = (function () {
1441
1446
  positionAccount.sizeUsd = positionAccount.sizeUsd.add(sizeDeltaUsd);
1442
1447
  positionAccount.sizeAmount = positionAccount.sizeAmount.add(sizeDeltaAmount);
1443
1448
  positionAccount.market = marketAccountPk;
1444
- positionAccount.lockedUsd = targetTokenPrice.getAssetAmountUsd(positionAccount.sizeAmount, targetCustodyAccount.decimals);
1445
- positionAccount.lockedAmount = collateralPrice.getTokenAmount(positionAccount.lockedUsd, collateralCustodyAccount.decimals);
1446
1449
  var collateralDeltaUsd = collateralPrice.getAssetAmountUsd(collateralDeltaAmount, collateralCustodyAccount.decimals);
1447
1450
  positionAccount.collateralUsd = positionAccount.collateralUsd.add(collateralDeltaUsd);
1451
+ positionAccount.lockedAmount = positionAccount.lockedAmount.add(collateralPrice.getTokenAmount(_this.getLockedUsd(sizeDeltaUsd, collateralDeltaUsd, side, marketCorrelation, maxPayOffBps), collateralCustodyAccount.decimals));
1448
1452
  var currentTime = new anchor_1.BN((0, utils_1.getUnixTs)());
1449
1453
  var pnl = _this.getPnlSync(positionAccount, userEntrytpSlOraclePrice, userEntrytpSlOraclePrice, targetCustodyAccount, collateralPrice, collateralEmaPrice, collateralCustodyAccount, currentTime, targetCustodyAccount.pricing.delaySeconds, poolConfig);
1450
1454
  var pnlUsd = pnl.profitUsd.sub(pnl.lossUsd);
@@ -5449,72 +5453,53 @@ var PerpetualsClient = (function () {
5449
5453
  });
5450
5454
  });
5451
5455
  };
5452
- this.settleRebates = function (owner_1, rebateSymbol_1, rewardSymbol_1, poolConfig_1) {
5453
- var args_1 = [];
5454
- for (var _i = 4; _i < arguments.length; _i++) {
5455
- args_1[_i - 4] = arguments[_i];
5456
- }
5457
- return __awaiter(_this, __spreadArray([owner_1, rebateSymbol_1, rewardSymbol_1, poolConfig_1], args_1, true), void 0, function (owner, rebateSymbol, rewardSymbol, poolConfig, createUserATA) {
5458
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, rebateMint, userTokenAccount, _a, settleRebatesInstruction, err_29;
5459
- if (createUserATA === void 0) { createUserATA = true; }
5460
- return __generator(this, function (_b) {
5461
- switch (_b.label) {
5462
- case 0:
5463
- publicKey = this.provider.wallet.publicKey;
5464
- preInstructions = [];
5465
- instructions = [];
5466
- postInstructions = [];
5467
- additionalSigners = [];
5468
- _b.label = 1;
5469
- case 1:
5470
- _b.trys.push([1, 5, , 6]);
5471
- rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
5472
- rebateMint = poolConfig.getTokenFromSymbol(rebateSymbol).mintKey;
5473
- userTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(rebateMint, owner, true);
5474
- _a = createUserATA;
5475
- if (!_a) return [3, 3];
5476
- return [4, (0, utils_1.checkIfAccountExists)(userTokenAccount, this.provider.connection)];
5477
- case 2:
5478
- _a = !(_b.sent());
5479
- _b.label = 3;
5480
- case 3:
5481
- if (_a) {
5482
- instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(publicKey, userTokenAccount, publicKey, rebateMint));
5483
- }
5484
- return [4, this.program.methods
5485
- .settleRebates()
5486
- .accounts({
5487
- transferAuthority: poolConfig.transferAuthority,
5488
- perpetuals: this.perpetuals.publicKey,
5489
- pool: poolConfig.poolAddress,
5490
- rewardCustody: rewardCustody.custodyAccount,
5491
- rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
5492
- rewardCustodyTokenAccount: rewardCustody.tokenAccount,
5493
- rebateVault: poolConfig.rebateVault,
5494
- rebateTokenAccount: poolConfig.rebateTokenAccount,
5495
- tokenMint: rebateMint,
5496
- tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5497
- eventAuthority: this.eventAuthority.publicKey,
5498
- program: this.programId,
5499
- ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
5500
- })
5501
- .instruction()];
5502
- case 4:
5503
- settleRebatesInstruction = _b.sent();
5504
- instructions.push(settleRebatesInstruction);
5505
- return [3, 6];
5506
- case 5:
5507
- err_29 = _b.sent();
5508
- console.log("perpClient settleRebatesInstruction error:: ", err_29);
5509
- throw err_29;
5510
- case 6: return [2, {
5511
- instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5512
- additionalSigners: additionalSigners
5513
- }];
5514
- }
5515
- });
5456
+ this.settleRebates = function (rebateSymbol, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
5457
+ var preInstructions, instructions, postInstructions, additionalSigners, rewardCustody, rebateMint, settleRebatesInstruction, err_29;
5458
+ return __generator(this, function (_a) {
5459
+ switch (_a.label) {
5460
+ case 0:
5461
+ preInstructions = [];
5462
+ instructions = [];
5463
+ postInstructions = [];
5464
+ additionalSigners = [];
5465
+ _a.label = 1;
5466
+ case 1:
5467
+ _a.trys.push([1, 3, , 4]);
5468
+ rewardCustody = poolConfig.custodies.find(function (i) { return i.mintKey.equals(poolConfig.getTokenFromSymbol(rewardSymbol).mintKey); });
5469
+ rebateMint = poolConfig.getTokenFromSymbol(rebateSymbol).mintKey;
5470
+ return [4, this.program.methods
5471
+ .settleRebates()
5472
+ .accounts({
5473
+ transferAuthority: poolConfig.transferAuthority,
5474
+ perpetuals: this.perpetuals.publicKey,
5475
+ pool: poolConfig.poolAddress,
5476
+ rewardCustody: rewardCustody.custodyAccount,
5477
+ rewardCustodyOracleAccount: this.useExtOracleAccount ? rewardCustody.extOracleAccount : rewardCustody.intOracleAccount,
5478
+ rewardCustodyTokenAccount: rewardCustody.tokenAccount,
5479
+ rebateVault: poolConfig.rebateVault,
5480
+ rebateTokenAccount: poolConfig.rebateTokenAccount,
5481
+ tokenMint: rebateMint,
5482
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
5483
+ eventAuthority: this.eventAuthority.publicKey,
5484
+ program: this.programId,
5485
+ ixSysvar: web3_js_1.SYSVAR_INSTRUCTIONS_PUBKEY
5486
+ })
5487
+ .instruction()];
5488
+ case 2:
5489
+ settleRebatesInstruction = _a.sent();
5490
+ instructions.push(settleRebatesInstruction);
5491
+ return [3, 4];
5492
+ case 3:
5493
+ err_29 = _a.sent();
5494
+ console.log("perpClient settleRebatesInstruction error:: ", err_29);
5495
+ throw err_29;
5496
+ case 4: return [2, {
5497
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
5498
+ additionalSigners: additionalSigners
5499
+ }];
5500
+ }
5516
5501
  });
5517
- };
5502
+ }); };
5518
5503
  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) {
5519
5504
  var args_1 = [];
5520
5505
  for (var _i = 11; _i < arguments.length; _i++) {
@@ -7686,8 +7671,54 @@ var PerpetualsClient = (function () {
7686
7671
  }
7687
7672
  });
7688
7673
  }); };
7674
+ this.initRebateVault = function (allowRebatePayout, rebateSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7675
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rebateCustodyMint, initRebateVaultInstruction, err_60;
7676
+ return __generator(this, function (_a) {
7677
+ switch (_a.label) {
7678
+ case 0:
7679
+ publicKey = this.provider.wallet.publicKey;
7680
+ preInstructions = [];
7681
+ instructions = [];
7682
+ postInstructions = [];
7683
+ additionalSigners = [];
7684
+ _a.label = 1;
7685
+ case 1:
7686
+ _a.trys.push([1, 3, , 4]);
7687
+ rebateCustodyMint = poolConfig.getTokenFromSymbol(rebateSymbol).mintKey;
7688
+ return [4, this.program.methods
7689
+ .initRebateVault({
7690
+ allowRebatePayout: allowRebatePayout
7691
+ })
7692
+ .accounts({
7693
+ admin: publicKey,
7694
+ multisig: this.multisig.publicKey,
7695
+ transferAuthority: poolConfig.transferAuthority,
7696
+ perpetuals: this.perpetuals.publicKey,
7697
+ rebateMint: rebateCustodyMint,
7698
+ rebateTokenAccount: poolConfig.rebateTokenAccount,
7699
+ rebateVault: poolConfig.rebateVault,
7700
+ systemProgram: web3_js_1.SystemProgram.programId,
7701
+ tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
7702
+ rent: web3_js_1.SYSVAR_RENT_PUBKEY
7703
+ })
7704
+ .instruction()];
7705
+ case 2:
7706
+ initRebateVaultInstruction = _a.sent();
7707
+ instructions.push(initRebateVaultInstruction);
7708
+ return [3, 4];
7709
+ case 3:
7710
+ err_60 = _a.sent();
7711
+ console.log("perpClient initRebateVaultInstruction error:: ", err_60);
7712
+ throw err_60;
7713
+ case 4: return [2, {
7714
+ instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7715
+ additionalSigners: additionalSigners
7716
+ }];
7717
+ }
7718
+ });
7719
+ }); };
7689
7720
  this.distributeTokenReward = function (amount, epochCount, rewardSymbol, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7690
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_60;
7721
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, rewardCustodyMint, fundingTokenAccount, revenueFundingTokenAccount, distributeTokenRewardInstruction, err_61;
7691
7722
  return __generator(this, function (_a) {
7692
7723
  switch (_a.label) {
7693
7724
  case 0:
@@ -7726,9 +7757,9 @@ var PerpetualsClient = (function () {
7726
7757
  instructions.push(distributeTokenRewardInstruction);
7727
7758
  return [3, 4];
7728
7759
  case 3:
7729
- err_60 = _a.sent();
7730
- console.log("perpClient distributeTokenRewardInstruction error:: ", err_60);
7731
- throw err_60;
7760
+ err_61 = _a.sent();
7761
+ console.log("perpClient distributeTokenRewardInstruction error:: ", err_61);
7762
+ throw err_61;
7732
7763
  case 4: return [2, {
7733
7764
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7734
7765
  additionalSigners: additionalSigners
@@ -7737,7 +7768,7 @@ var PerpetualsClient = (function () {
7737
7768
  });
7738
7769
  }); };
7739
7770
  this.setTokenStakeLevel = function (owner, stakeLevel) { return __awaiter(_this, void 0, void 0, function () {
7740
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_61;
7771
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenStakeLevelInstruction, err_62;
7741
7772
  return __generator(this, function (_a) {
7742
7773
  switch (_a.label) {
7743
7774
  case 0:
@@ -7765,9 +7796,9 @@ var PerpetualsClient = (function () {
7765
7796
  instructions.push(setTokenStakeLevelInstruction);
7766
7797
  return [3, 4];
7767
7798
  case 3:
7768
- err_61 = _a.sent();
7769
- console.log("perpClient setTokenStakeLevelInstruction error:: ", err_61);
7770
- throw err_61;
7799
+ err_62 = _a.sent();
7800
+ console.log("perpClient setTokenStakeLevelInstruction error:: ", err_62);
7801
+ throw err_62;
7771
7802
  case 4: return [2, {
7772
7803
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7773
7804
  additionalSigners: additionalSigners
@@ -7776,7 +7807,7 @@ var PerpetualsClient = (function () {
7776
7807
  });
7777
7808
  }); };
7778
7809
  this.setTokenReward = function (owner, amount, epochCount, poolConfig) { return __awaiter(_this, void 0, void 0, function () {
7779
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_62;
7810
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, tokenStakeAccount, setTokenRewardInstruction, err_63;
7780
7811
  return __generator(this, function (_a) {
7781
7812
  switch (_a.label) {
7782
7813
  case 0:
@@ -7808,9 +7839,9 @@ var PerpetualsClient = (function () {
7808
7839
  instructions.push(setTokenRewardInstruction);
7809
7840
  return [3, 4];
7810
7841
  case 3:
7811
- err_62 = _a.sent();
7812
- console.log("perpClient setTokenRewardInstruction error:: ", err_62);
7813
- throw err_62;
7842
+ err_63 = _a.sent();
7843
+ console.log("perpClient setTokenRewardInstruction error:: ", err_63);
7844
+ throw err_63;
7814
7845
  case 4: return [2, {
7815
7846
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7816
7847
  additionalSigners: additionalSigners
@@ -7819,7 +7850,7 @@ var PerpetualsClient = (function () {
7819
7850
  });
7820
7851
  }); };
7821
7852
  this.resizeInternalOracle = function (extOracle, tokenMint, intOracleAccount) { return __awaiter(_this, void 0, void 0, function () {
7822
- var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_63;
7853
+ var publicKey, preInstructions, instructions, postInstructions, additionalSigners, resizeInternalOracleInstruction, err_64;
7823
7854
  return __generator(this, function (_a) {
7824
7855
  switch (_a.label) {
7825
7856
  case 0:
@@ -7848,9 +7879,9 @@ var PerpetualsClient = (function () {
7848
7879
  instructions.push(resizeInternalOracleInstruction);
7849
7880
  return [3, 4];
7850
7881
  case 3:
7851
- err_63 = _a.sent();
7852
- console.log("perpClient resizeInternalOracleInstruction error:: ", err_63);
7853
- throw err_63;
7882
+ err_64 = _a.sent();
7883
+ console.log("perpClient resizeInternalOracleInstruction error:: ", err_64);
7884
+ throw err_64;
7854
7885
  case 4: return [2, {
7855
7886
  instructions: __spreadArray(__spreadArray(__spreadArray([], preInstructions, true), instructions, true), postInstructions, true),
7856
7887
  additionalSigners: additionalSigners
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import { BN } from "@coral-xyz/anchor";
3
2
  import { Pool, TokenRatios, StakeStats, CompoundingStats, Permissions } from "./types";
4
3
  import { PublicKey } from "@solana/web3.js";
@@ -23,7 +23,7 @@
23
23
  "stakedLpTokenSymbol": "sFLP.1",
24
24
  "perpetuals": "81XigYeVi4vCZhKq6trfbYPqj6SEmP7xH46GTwxGxhmz",
25
25
  "transferAuthority": "49hcrkDRS4chZw6G7CJLAAaZxttz4Cz7jCouFdvg5JDy",
26
- "tokenMint": "FAFxVxnkzZHMCodkWyoccgUNgVScqMw2mhhQBYDFjFAF",
26
+ "tokenMint": "fafsR7zoBPiSBAa96fUQiCJExsoXV5u6HaWrdXL19B2",
27
27
  "tokenVault": "6Knz2PVpKdT4wzgZsNMZwvPR3sh8ik93wfXbu6fSgoKy",
28
28
  "tokenVaultTokenAccount": "7iNSKn6fnZHJFD9xnvGYRYdKrNXrGp6aLHJz15yjcM6E",
29
29
  "rebateVault": "H19XuZAiYwpZfi3nhFsbUwyTWnfZqB7qWjs1Mi9JVWLE",
@@ -127,10 +127,10 @@
127
127
  "symbol": "ZEC",
128
128
  "mintKey": "zecrXUjqA7bZdozZkqbh3wgrVGdwCd4jHRBg8Gd8Vrf",
129
129
  "decimals": 8,
130
- "usdPrecision": 2,
130
+ "usdPrecision": 4,
131
131
  "tokenPrecision": 4,
132
132
  "isStable": false,
133
- "isVirtual": false,
133
+ "isVirtual": true,
134
134
  "lazerId": 66,
135
135
  "pythTicker": "Crypto.ZEC/USD",
136
136
  "pythPriceId": "0xbe9b59d178f0d6a97ab4c343bff2aa69caa1eaae3e9048a65788c529b125bb24",
@@ -224,17 +224,17 @@
224
224
  "pythPriceId": "0x67be9f519b95cf24338801051f9a808eff0a578ccb388db73b7f6fe1de019ffb"
225
225
  },
226
226
  {
227
- "custodyId": 5,
228
- "custodyAccount": "69i9vSMGgm9ih6jLpzg2YZXpt6xRtiKYaxVGZLyNBxRT",
229
- "tokenAccount": "GGTvh4u8UDmrKaMjVRZtpVECw4hDbdocBbQ11b88uWbV",
227
+ "custodyId": 6,
228
+ "custodyAccount": "9UGk7k6x9qBiegCNKtCvvVnc3PcAv3VxnEnuFLHbXkzE",
229
+ "tokenAccount": "2Gfmf3YSGmhu34qmeaTTrULGN4UD9dbcubSyNw9ef56s",
230
230
  "symbol": "ZEC",
231
231
  "mintKey": "zecrXUjqA7bZdozZkqbh3wgrVGdwCd4jHRBg8Gd8Vrf",
232
232
  "decimals": 8,
233
- "usdPrecision": 2,
233
+ "usdPrecision": 4,
234
234
  "tokenPrecision": 4,
235
235
  "isStable": false,
236
- "isVirtual": false,
237
- "intOracleAddress": "CKGi7WnzD5zBNZAA6ZQxCecg3GaWqV1aoEQvoLr9T8C4",
236
+ "isVirtual": true,
237
+ "intOracleAddress": "78s4o5YXUA73gDG557MNNeJyoQoUxms8SdTBbVZ6j2Q2",
238
238
  "extOracleAddress": "HzdKMXqocYWqy7mh8AKDoZFJinjeGMfBKmGAxGbasc28",
239
239
  "lazerId": 66,
240
240
  "pythTicker": "Crypto.ZEC/USD",
@@ -356,32 +356,32 @@
356
356
  },
357
357
  {
358
358
  "marketId": 7,
359
- "marketAccount": "DDcZvQpfTnqjz2mNYhcHvLMwn6PhgrN2bpBDD9W2dj3v",
360
- "marketCorrelation": true,
361
- "pool": "4SR2FJETBR4Q5uhsiT6a5ALF51jQwy4AjDQgGyvacGLi",
362
- "targetCustody": "69i9vSMGgm9ih6jLpzg2YZXpt6xRtiKYaxVGZLyNBxRT",
363
- "collateralCustody": "69i9vSMGgm9ih6jLpzg2YZXpt6xRtiKYaxVGZLyNBxRT",
359
+ "marketAccount": "5awifMKx3S2EHpPSA2yLiNE8VgR8kweNbNJsL43xE1Uy",
360
+ "marketCorrelation": false,
361
+ "pool": "9VN3TRG2GW1ugaPwkVzBC1tGQ1vatUvXTQ8dWrxNbCWA",
362
+ "targetCustody": "9UGk7k6x9qBiegCNKtCvvVnc3PcAv3VxnEnuFLHbXkzE",
363
+ "collateralCustody": "9BJ1J3GwvswPNMNsSoxkLrhePW4zUDaKRSuaoJGjRFe5",
364
364
  "side": "long",
365
- "maxLev": 50,
366
- "degenMinLev": 50,
367
- "degenMaxLev": 50,
368
- "targetCustodyId": 5,
369
- "collateralCustodyId": 5,
365
+ "maxLev": 100,
366
+ "degenMinLev": 125,
367
+ "degenMaxLev": 500,
368
+ "targetCustodyId": 6,
369
+ "collateralCustodyId": 0,
370
370
  "targetMint": "zecrXUjqA7bZdozZkqbh3wgrVGdwCd4jHRBg8Gd8Vrf",
371
- "collateralMint": "zecrXUjqA7bZdozZkqbh3wgrVGdwCd4jHRBg8Gd8Vrf"
371
+ "collateralMint": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr"
372
372
  },
373
373
  {
374
374
  "marketId": 8,
375
- "marketAccount": "4zz1aPZG2gFN9rKmuzRmuypeZWTeS3z81KNjrLF6E5qV",
375
+ "marketAccount": "4kceR5EhDVNJAdKMxdyCiPxeny7XRmVthMJzr3gQiizN",
376
376
  "marketCorrelation": false,
377
- "pool": "4SR2FJETBR4Q5uhsiT6a5ALF51jQwy4AjDQgGyvacGLi",
378
- "targetCustody": "69i9vSMGgm9ih6jLpzg2YZXpt6xRtiKYaxVGZLyNBxRT",
379
- "collateralCustody": "BwroR4MpPBFWLocL5CM4kLDAjx1aH3ogma1zYJfbHS1E",
377
+ "pool": "9VN3TRG2GW1ugaPwkVzBC1tGQ1vatUvXTQ8dWrxNbCWA",
378
+ "targetCustody": "9UGk7k6x9qBiegCNKtCvvVnc3PcAv3VxnEnuFLHbXkzE",
379
+ "collateralCustody": "9BJ1J3GwvswPNMNsSoxkLrhePW4zUDaKRSuaoJGjRFe5",
380
380
  "side": "short",
381
- "maxLev": 50,
382
- "degenMinLev": 50,
383
- "degenMaxLev": 50,
384
- "targetCustodyId": 5,
381
+ "maxLev": 100,
382
+ "degenMinLev": 125,
383
+ "degenMaxLev": 500,
384
+ "targetCustodyId": 6,
385
385
  "collateralCustodyId": 0,
386
386
  "targetMint": "zecrXUjqA7bZdozZkqbh3wgrVGdwCd4jHRBg8Gd8Vrf",
387
387
  "collateralMint": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr"
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import { BN } from "@coral-xyz/anchor";
3
2
  import { Mint } from "@solana/spl-token";
4
3
  import { CustodyAccount } from "./CustodyAccount";
@@ -1,4 +1,3 @@
1
- /// <reference types="bn.js" />
2
1
  import { BN } from "@coral-xyz/anchor";
3
2
  import { PublicKey } from "@solana/web3.js";
4
3
  import { ContractOraclePrice, Position } from "./types";