@gmx-io/sdk 1.0.6 → 1.0.7

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.
@@ -21,9 +21,9 @@ function getMarketIndexName(p) {
21
21
  return `${prefix}${firstToken.baseSymbol || firstToken.symbol}/USD`;
22
22
  }
23
23
  exports.getMarketIndexName = getMarketIndexName;
24
- function getMarketPoolName(p) {
24
+ function getMarketPoolName(p, separator = "-") {
25
25
  const { longToken, shortToken } = p;
26
- return `${longToken.symbol}-${shortToken.symbol}`;
26
+ return `${longToken.symbol}${separator}${shortToken.symbol}`;
27
27
  }
28
28
  exports.getMarketPoolName = getMarketPoolName;
29
29
  function getContractMarketPrices(tokensData, market) {
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.roundBigIntToDecimals = exports.roundToOrder = exports.roundToTwoDecimals = exports.roundUpDivision = exports.parseValue = exports.bigNumberify = exports.toBigNumberWithDecimals = exports.roundWithDecimals = exports.getPlusOrMinusSymbol = exports.padDecimals = exports.limitDecimals = exports.getLimitedDisplay = exports.formatAmountFree = exports.formatArrayAmount = exports.formatKeyAmount = exports.formatAmount = exports.numberWithCommas = exports.formatFactor = exports.formatBalanceAmountWithUsd = exports.formatBalanceAmount = exports.formatAmountHuman = exports.formatPercentageDisplay = exports.formatUsdPrice = exports.formatRatePercentage = exports.formatTokenAmountWithUsd = exports.formatTokenAmount = exports.formatPercentage = exports.formatDeltaUsd = exports.formatUsd = exports.adjustForDecimals = exports.bigintToNumber = exports.trimZeroDecimals = exports.numberToBigint = exports.applyFactor = exports.roundUpMagnitudeDivision = exports.getBasisPoints = exports.basisPointsToFloat = exports.expandDecimals = exports.TRIGGER_PREFIX_BELOW = exports.TRIGGER_PREFIX_ABOVE = exports.PERCENT_PRECISION_DECIMALS = exports.MaxUint256 = exports.BN_NEGATIVE_ONE = exports.BN_ONE = exports.BN_ZERO = exports.PRECISION = exports.PRECISION_DECIMALS = exports.BASIS_POINTS_DIVISOR_BIGINT = exports.BASIS_POINTS_DIVISOR = exports.USD_DECIMALS = void 0;
4
- exports.absDiffBps = exports.clamp = exports.calculateDisplayDecimals = exports.deserializeBigIntsInObject = exports.serializeBigIntsInObject = exports.removeTrailingZeros = exports.maxbigint = exports.minBigNumber = void 0;
3
+ exports.roundToOrder = exports.roundToTwoDecimals = exports.roundUpDivision = exports.parseValue = exports.bigNumberify = exports.toBigNumberWithDecimals = exports.roundWithDecimals = exports.getPlusOrMinusSymbol = exports.padDecimals = exports.limitDecimals = exports.getLimitedDisplay = exports.formatAmountFree = exports.formatArrayAmount = exports.formatKeyAmount = exports.formatAmount = exports.numberWithCommas = exports.formatFactor = exports.formatBalanceAmountWithUsd = exports.formatBalanceAmount = exports.formatAmountHuman = exports.formatPercentageDisplay = exports.formatUsdPrice = exports.formatRatePercentage = exports.formatTokenAmountWithUsd = exports.formatTokenAmount = exports.formatPercentage = exports.formatDeltaUsd = exports.formatUsd = exports.adjustForDecimals = exports.bigintToNumber = exports.trimZeroDecimals = exports.numberToBigint = exports.applyFactor = exports.roundUpMagnitudeDivision = exports.getBasisPoints = exports.basisPointsToFloat = exports.expandDecimals = exports.TRIGGER_PREFIX_BELOW = exports.TRIGGER_PREFIX_ABOVE = exports.PERCENT_PRECISION_DECIMALS = exports.MaxUint256 = exports.BN_NEGATIVE_ONE = exports.BN_ONE = exports.BN_ZERO = exports.PRECISION = exports.PRECISION_DECIMALS = exports.BASIS_POINTS_DECIMALS = exports.BASIS_POINTS_DIVISOR_BIGINT = exports.BASIS_POINTS_DIVISOR = exports.USD_DECIMALS = void 0;
4
+ exports.absDiffBps = exports.clamp = exports.calculateDisplayDecimals = exports.deserializeBigIntsInObject = exports.serializeBigIntsInObject = exports.removeTrailingZeros = exports.maxbigint = exports.minBigNumber = exports.roundBigIntToDecimals = void 0;
5
5
  const viem_1 = require("viem");
6
6
  const bigmath_1 = require("./bigmath");
7
7
  exports.USD_DECIMALS = 30;
8
8
  exports.BASIS_POINTS_DIVISOR = 10000;
9
9
  exports.BASIS_POINTS_DIVISOR_BIGINT = 10000n;
10
+ exports.BASIS_POINTS_DECIMALS = 4;
10
11
  exports.PRECISION_DECIMALS = 30;
11
12
  exports.PRECISION = expandDecimals(1, exports.PRECISION_DECIMALS);
12
13
  exports.BN_ZERO = 0n;
@@ -41,8 +41,8 @@ function createRawTradeActionTransformer(marketsInfoData, wrappedToken, tokensDa
41
41
  initialCollateralToken,
42
42
  timestamp: rawAction.timestamp,
43
43
  transaction: rawAction.transaction,
44
- reason: rawAction.reason,
45
- reasonBytes: rawAction.reasonBytes,
44
+ reason: rawAction.reason ?? undefined,
45
+ reasonBytes: rawAction.reasonBytes ?? undefined,
46
46
  twapParams: rawAction.twapGroupId && rawAction.numberOfParts
47
47
  ? {
48
48
  twapGroupId: rawAction.twapGroupId,
@@ -115,8 +115,8 @@ function createRawTradeActionTransformer(marketsInfoData, wrappedToken, tokensDa
115
115
  borrowingFeeAmount: rawAction.borrowingFeeAmount ? BigInt(rawAction.borrowingFeeAmount) : undefined,
116
116
  fundingFeeAmount: rawAction.fundingFeeAmount ? BigInt(rawAction.fundingFeeAmount) : undefined,
117
117
  liquidationFeeAmount: rawAction.liquidationFeeAmount ? BigInt(rawAction.liquidationFeeAmount) : undefined,
118
- reason: rawAction.reason,
119
- reasonBytes: rawAction.reasonBytes,
118
+ reason: rawAction.reason ?? undefined,
119
+ reasonBytes: rawAction.reasonBytes ?? undefined,
120
120
  transaction: rawAction.transaction,
121
121
  timestamp: rawAction.timestamp,
122
122
  shouldUnwrapNativeToken: rawAction.shouldUnwrapNativeToken,
@@ -1,4 +1,4 @@
1
- export { USD_DECIMALS, BASIS_POINTS_DIVISOR, BASIS_POINTS_DIVISOR_BIGINT } from "../utils/numbers";
1
+ export { USD_DECIMALS, BASIS_POINTS_DIVISOR, BASIS_POINTS_DIVISOR_BIGINT, BASIS_POINTS_DECIMALS } from "../utils/numbers";
2
2
  // V2
3
3
  export const HIGH_PRICE_IMPACT_BPS = 80; // 0.8%
4
4
  export const HIGH_POSITION_IMPACT_BPS = 50; // 0.5%
@@ -110,7 +110,7 @@ export async function increaseOrderHelper(sdk, params) {
110
110
  referralCodeForTxn: params.referralCodeForTxn,
111
111
  triggerPrice: params.limitPrice,
112
112
  collateralTokenAddress: collateralToken.address,
113
- isLong: true,
113
+ isLong: params.isLong,
114
114
  receiveTokenAddress: collateralTokenAddress,
115
115
  indexToken: marketInfo.indexToken,
116
116
  marketInfo,