Skip to main content

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​

Each function returns a bigint representing the number of oracle price signatures required for that operation type. Import any function directly from @gmx-io/sdk/utils/fees.

estimateDepositOraclePriceCount​

estimateDepositOraclePriceCount(swapsCount: number | bigint): bigint

Estimates the number of oracle prices required for a deposit operation. Returns 3n + swapsCount.

import { estimateDepositOraclePriceCount } from "@gmx-io/sdk/utils/fees";

const priceCount = estimateDepositOraclePriceCount(2);
console.log(priceCount); // 5n

estimateWithdrawalOraclePriceCount​

estimateWithdrawalOraclePriceCount(swapsCount: bigint): bigint

Estimates the number of oracle prices required for a withdrawal operation. Returns 3n + swapsCount.

import { estimateWithdrawalOraclePriceCount } from "@gmx-io/sdk/utils/fees";

const priceCount = estimateWithdrawalOraclePriceCount(1n);
console.log(priceCount); // 4n

estimateOrderOraclePriceCount​

estimateOrderOraclePriceCount(swapsCount: number): bigint

Estimates the number of oracle prices required for an order operation. Returns 3n + swapsCount.

import { estimateOrderOraclePriceCount } from "@gmx-io/sdk/utils/fees";

const priceCount = estimateOrderOraclePriceCount(0);
console.log(priceCount); // 3n

estimateShiftOraclePriceCount​

estimateShiftOraclePriceCount(): bigint

Estimates the number of oracle prices required for a shift operation. Always returns 4n.

import { estimateShiftOraclePriceCount } from "@gmx-io/sdk/utils/fees";

const priceCount = estimateShiftOraclePriceCount();
console.log(priceCount); // 4n

estimateGlvDepositOraclePriceCount​

estimateGlvDepositOraclePriceCount(marketCount: bigint, swapsCount?: bigint): bigint

Estimates the number of oracle prices required for a GLV deposit operation. Returns 2n + marketCount + swapsCount. swapsCount defaults to 0n.

import { estimateGlvDepositOraclePriceCount } from "@gmx-io/sdk/utils/fees";

const priceCount = estimateGlvDepositOraclePriceCount(3n, 1n);
console.log(priceCount); // 6n

estimateGlvWithdrawalOraclePriceCount​

estimateGlvWithdrawalOraclePriceCount(marketCount: bigint, swapsCount?: bigint): bigint

Estimates the number of oracle prices required for a GLV withdrawal operation. Returns 2n + marketCount + swapsCount. swapsCount defaults to 0n.

import { estimateGlvWithdrawalOraclePriceCount } from "@gmx-io/sdk/utils/fees";

const priceCount = estimateGlvWithdrawalOraclePriceCount(2n);
console.log(priceCount); // 4n