estimateOraclePriceCount
This module provides utilities for estimating the number of oracle prices required for various GMX protocol operations. These functions help calculate gas costs and oracle price requirements for deposits, withdrawals, orders, shifts, and GLV operations.
Methods
estimateDepositOraclePriceCount
estimateDepositOraclePriceCount(swapsCount: number): bigint
Estimates the number of oracle prices required for a deposit operation.
import { estimateDepositOraclePriceCount } from "@gmx-ui/sdk/utils/fees";
// Estimate oracle prices for deposit with 2 swaps
const priceCount = estimateDepositOraclePriceCount(2);
console.log(priceCount); // 5n
estimateWithdrawalOraclePriceCount
estimateWithdrawalOraclePriceCount(swapsCount: number): bigint
Estimates the number of oracle prices required for a withdrawal operation.
import { estimateWithdrawalOraclePriceCount } from "@gmx-ui/sdk/utils/fees";
// Estimate oracle prices for withdrawal with 1 swap
const priceCount = estimateWithdrawalOraclePriceCount(1);
console.log(priceCount); // 4n
estimateOrderOraclePriceCount
estimateOrderOraclePriceCount(swapsCount: number): bigint
Estimates the number of oracle prices required for an order operation.
import { estimateOrderOraclePriceCount } from "@gmx-ui/sdk/utils/fees";
// Estimate oracle prices for order with 0 swaps
const priceCount = estimateOrderOraclePriceCount(0);
console.log(priceCount); // 3n
estimateShiftOraclePriceCount
estimateShiftOraclePriceCount(): bigint
Estimates the number of oracle prices required for a shift operation.
import { estimateShiftOraclePriceCount } from "@gmx-ui/sdk/utils/fees";
// Estimate oracle prices for shift operation
const priceCount = estimateShiftOraclePriceCount();
console.log(priceCount); // 4n
estimateGlvDepositOraclePriceCount
estimateGlvDepositOraclePriceCount(marketCount: bigint, swapsCount?: bigint): bigint
Parameters
marketCount: bigint- Number of markets involved in the GLV depositswapsCount: bigint- Number of swaps in the operation (optional, defaults to 0n)
Estimates the number of oracle prices required for a GLV deposit operation.
import { estimateGlvDepositOraclePriceCount } from "@gmx-ui/sdk/utils/fees";
// Estimate oracle prices for GLV deposit with 3 markets and 1 swap
const priceCount = estimateGlvDepositOraclePriceCount(3n, 1n);
console.log(priceCount); // 6n
estimateGlvWithdrawalOraclePriceCount
estimateGlvWithdrawalOraclePriceCount(marketCount: bigint, swapsCount?: bigint): bigint
Parameters
marketCount: bigint- Number of markets involved in the GLV withdrawalswapsCount: bigint- Number of swaps in the operation (optional, defaults to 0n)
Estimates the number of oracle prices required for a GLV withdrawal operation.
import { estimateGlvWithdrawalOraclePriceCount } from "@gmx-ui/sdk/utils/fees";
// Estimate oracle prices for GLV withdrawal with 2 markets
const priceCount = estimateGlvWithdrawalOraclePriceCount(2n);
console.log(priceCount); // 4n