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-module | Description |
|---|---|
swapPath | Path discovery: createFindSwapPath, getWrappedAddress |
swapValues | Amount calculation: getSwapAmountsByFromValue, getSwapAmountsByToValue, getSwapPathComparator |
swapStats | Fee and price impact stats per swap step |
swapRouting | Route selection: getBestSwapPath, naive pre-selection |
findSwapPathsBetweenTokens | Graph traversal for all token-pair paths |
findReachableTokens | Reachability analysis from a source token |
preparedSwapData | Pre-computed constants: MARKETS_ADJACENCY_GRAPH, TOKEN_SWAP_PATHS, REACHABLE_TOKENS |