Skip to main content

swap

This module provides utilities for calculating swap statistics and values in the GMX protocol. It includes functions for computing swap fees, price impact, and other swap-related metrics.

Methods

The @gmx-io/sdk/utils/swap module re-exports all functions from its sub-modules. The table below maps each function group to its documentation page.

Sub-moduleDescription
swapPathPath discovery: createFindSwapPath, getWrappedAddress
swapValuesAmount calculation: getSwapAmountsByFromValue, getSwapAmountsByToValue, getSwapPathComparator
swapStatsFee and price impact stats per swap step
swapRoutingRoute selection: getBestSwapPath, naive pre-selection
findSwapPathsBetweenTokensGraph traversal for all token-pair paths
findReachableTokensReachability analysis from a source token
preparedSwapDataPre-computed constants: MARKETS_ADJACENCY_GRAPH, TOKEN_SWAP_PATHS, REACHABLE_TOKENS