factors
This module provides constants for various impact thresholds, slippage limits, and basis point calculations used throughout the GMX protocol. These factors help determine when to show warnings to users and set default acceptable limits for trading operations.
Constants
USD_DECIMALS: number- Number of decimal places for USD values
import { USD_DECIMALS } from "@gmx-ui/sdk/configs/factors";
const oneDollar = 10n ** BigInt(USD_DECIMALS);
BASIS_POINTS_DIVISOR: number- Divisor for basis points calculations (10000)
import { BASIS_POINTS_DIVISOR } from "@gmx-ui/sdk/configs/factors";
const percentage = (basisPoints / BASIS_POINTS_DIVISOR) * 100;
BASIS_POINTS_DIVISOR_BIGINT: bigint- BigInt version of basis points divisor
import { BASIS_POINTS_DIVISOR_BIGINT } from "@gmx-ui/sdk/configs/factors";
const percentageBigInt = (basisPointsBigInt * 100n) / BASIS_POINTS_DIVISOR_BIGINT;
BASIS_POINTS_DECIMALS: number- Number of decimal places for basis points
import { BASIS_POINTS_DECIMALS } from "@gmx-ui/sdk/configs/factors";
const formattedBps = basisPoints.toFixed(BASIS_POINTS_DECIMALS);
HIGH_PRICE_IMPACT_BPS: number- Threshold for high price impact warning (80 basis points = 0.8%)
import { HIGH_PRICE_IMPACT_BPS } from "@gmx-ui/sdk/configs/factors";
if (priceImpactBps > HIGH_PRICE_IMPACT_BPS) {
console.warn("High price impact detected");
}
HIGH_POSITION_IMPACT_BPS: number- Threshold for high position impact warning (50 basis points = 0.5%)
import { HIGH_POSITION_IMPACT_BPS } from "@gmx-ui/sdk/configs/factors";
const isHighPositionImpact = positionImpactBps > HIGH_POSITION_IMPACT_BPS;
HIGH_COLLATERAL_IMPACT_BPS: number- Threshold for high collateral impact warning (2500 basis points = 25%)
import { HIGH_COLLATERAL_IMPACT_BPS } from "@gmx-ui/sdk/configs/factors";
if (collateralImpactBps > HIGH_COLLATERAL_IMPACT_BPS) {
console.warn("High collateral impact");
}
HIGH_SWAP_IMPACT_BPS: number- Threshold for high swap impact warning (50 basis points = 0.5%)
import { HIGH_SWAP_IMPACT_BPS } from "@gmx-ui/sdk/configs/factors";
const showSwapWarning = swapImpactBps > HIGH_SWAP_IMPACT_BPS;
DEFAULT_ACCEPTABLE_PRICE_IMPACT_BUFFER: number- Default buffer for acceptable price impact (30 basis points = 0.3%)
import { DEFAULT_ACCEPTABLE_PRICE_IMPACT_BUFFER } from "@gmx-ui/sdk/configs/factors";
const maxAcceptableImpact = priceImpact + DEFAULT_ACCEPTABLE_PRICE_IMPACT_BUFFER;
HIGH_ALLOWED_SWAP_SLIPPAGE_BPS: number- Threshold for high swap slippage (20 basis points = 0.2%)
import { HIGH_ALLOWED_SWAP_SLIPPAGE_BPS } from "@gmx-ui/sdk/configs/factors";
if (slippageBps > HIGH_ALLOWED_SWAP_SLIPPAGE_BPS) {
console.warn("High slippage tolerance");
}
DEFAULT_ALLOWED_SWAP_SLIPPAGE_BPS: bigint- Default allowed swap slippage (100 basis points = 1%)
import { DEFAULT_ALLOWED_SWAP_SLIPPAGE_BPS } from "@gmx-ui/sdk/configs/factors";
const slippageTolerance = DEFAULT_ALLOWED_SWAP_SLIPPAGE_BPS;