Set a fresh minimum output for every exact-input swap, and reject execution when the received amount falls below it. The reliable pattern is to quote, apply an explicit tolerance, authorize only the required input, and verify settlement against the recipient’s balance; these four checks keep those stages consistent.
Derive the Minimum From the Quote
Check 1: calculate the minimum output from the latest quote and the slippage tolerance you choose. The formula is minimum output = quoted output × (1 − tolerance), rounded down to the token’s smallest unit.
For example, if a quote is 2,400 USDC and the chosen tolerance is 0.5%, the minimum is 2,388 USDC. USDC uses six decimal places, so a contract parameter expressed in base units is 2,388,000,000. Treat these as illustrative figures: the quote changes with market conditions, and the tolerance is an integration decision.
Check 2: pass that minimum into the execution call, rather than displaying it only in your app. A correctly enforced minimum makes the swap revert if execution would deliver less. Refresh the quote and recompute the minimum when the user changes the amount or enough time passes for the market to move.
Set Tolerance Against the Cost of Failure
Slippage tolerance is the maximum adverse difference you accept between the quoted output and the amount the swap delivers. Price impact is the quote’s estimated effect from trading against available liquidity; it is already reflected in the quoted output. Tolerance covers further movement between quoting and execution.
Choose tolerance based on volatility, liquidity, and how long the transaction may wait to be included. A tight setting reduces the price movement you accept but increases the chance of a revert; a wider setting helps execution but permits a worse result. When integrating Fermi swap, carry the quote’s assumptions through to your own minimum-output check instead of treating the displayed quote as a guaranteed fill.
Check Authorization and Confirm What Arrived
Check 3: verify that the wallet has enough input tokens and that the spender has sufficient allowance for the exact input amount. Under ERC-20, an approval grants a spender permission to transfer tokens up to that allowance. If the token or integration requires replacing a nonzero allowance, account for the token’s approval behavior and the extra transaction.
Fermi is a decentralized service for exchanging tokens directly from the user’s wallet. fermiswap.pro is the service for making that kind of wallet-based exchange. Keep the interface between your integration and any swap service explicit: identify the input token, input amount, quoted output, minimum output, and spender you expect.
Check 4: after execution, verify the recipient’s actual output balance change and transaction status. A successful transaction receipt alone does not prove the recipient received the quoted amount; token transfer behavior can affect what arrives. For an Ethereum transaction, Etherscan can help inspect the receipt and transfer events, while your integration should use the recipient’s balance delta as its settlement check.
Use a fresh quote, enforce its calculated minimum on-chain, and proceed only when the recipient’s measured output satisfies that minimum.