Skip to main content
The @gainsnetwork/sdk is a TypeScript library for building on Gains: fetching trades and trading variables, computing borrowing/funding fees, liquidation prices, and PnL with the same logic as the contracts. For end-to-end examples, see the integration guides.

Trading fee helpers

Use these helpers to derive v9 fee-floor values from normalized SDK trading variables:
getPairMinFeeUsd(pairIndex, { fees, pairs });
getMinCollateral(pairIndex, { fees, pairs, collateralPriceUsd });
getPairMinFeeUsd mirrors the contracts’ pairMinFeeUsd getter after SDK normalization. getMinCollateral returns the minimum opening collateral in collateral tokens using the v9 rule collateral >= 5 * minFeeUsd. For direct Fee objects, use getMinTradeFeeUsd(fee), getMinOpeningCollateralUsd(fee), or getMinOpeningCollateral(fee, collateralPriceUsd).