To integrate fermi swap, quote its Ethereum markets before sending a guarded trade. Your integration needs to discover an active pair, price the intended size, and enforce a minimum output when the transaction executes.
What does fermi swap do?
It fills Ethereum token swaps from a market maker’s own inventory. FermiSwap publishes prices that can change without a trade, so its quote is not determined by a fixed pool formula. A pair can remain listed while its current price or available inventory makes your requested size unfillable.
For an integrator, the useful model is a venue with four operations: discover pairs, check whether a direction is active, quote an input amount, and execute the swap. The maker delivers the output token from its inventory when the onchain swap succeeds.
Which markets can you route?
The supported markets are the pairs the Ethereum contract currently reports, rather than every combination of tokens in its inventory. Recent trading has included these pairs:
-
WETH/USDC
-
WETH/USDT
-
USDC/USDT
-
WBTC/USDC
-
WBTC/USDT
Here WETH is wrapped ether, and WBTC is an Ethereum token representing bitcoin exposure; neither is native ETH or BTC. Treat the list as a starting point for discovery. Read getPairs() from the deployed venue, resolve each token by contract address, and call isActive(tokenIn, tokenOut) for the direction you intend to trade. FermiSwap trading pairs can change status, and a familiar symbol alone does not identify a token safely.
Build and execute the swap
Build the route as a sequence of checks followed by one atomic transaction. The venue’s swap interface uses a push payment: the input tokens reach the venue before its swap call, within the same transaction.
-
Resolve the Ethereum deployment. Check that your RPC reports chain ID 1 and that the expected contract has bytecode at the address your integration uses. A documented venue address is 0x5979458912F80B96d30D4220af8E2e4925A33320; verify the deployed address and interface when configuring production, rather than copying an address from an old trade.
-
Discover the requested direction. Read getPairs(), match token contract addresses, then check isActive with the input and output in the user’s order. This prevents an inactive market from appearing as a usable route. It also keeps a WBTC request tied to the intended wrapped token contract.
-
Quote the exact input size. In your route builder, include fermi swap as a candidate when FermiSwap reports the direction active. Call quote(tokenIn, tokenOut, amountIn) through eth_call and retain the returned amount in the output token’s smallest units. For next-block pricing, simulate with a fresh published state override when your execution path supports one; a quote from ordinary latest-block state can miss a pending maker price update.
-
Set the output floor. Suppose a quote for 1 WETH returns 2,650 USDC, represented as 2,650,000,000 units because USDC has six decimals. With an illustrative 30 basis point tolerance, set minAmountOut to 2,642,050,000 units, or 2,642.05 USDC. Compare routes using the amount the recipient will receive after any route fee and estimated gas, not a displayed midprice.
-
Send one atomic swap transaction. Have the user approve your adapter for the exact input amount, or use an authorization method your adapter supports. In one transaction, the adapter pulls the input, transfers it to the venue, and calls swap(tokenIn, tokenOut, amountIn, minAmountOut, recipient, deadline); a short deadline, say two minutes, limits how long the order can execute. Do not send tokens to the venue in a separate transaction, because a later failed swap would not reverse that earlier transfer.
-
Confirm the delivered amount. Wait for the receipt, require success, and check the recipient’s output balance change or the venue’s swap event. Index by transaction hash and log position if your transaction can contain multiple swaps. A successful quote is only a pretrade estimate; the receipt tells you what settled.
What does the fill cost, and when should you reroute?
The effective cost comes from the quoted exchange rate, any fee in your route, and Ethereum gas. For example, a transaction using 180,000 gas at 20 gwei costs 0.0036 ETH; at an illustrative ETH price of $2,650, that is about $9.54. Gas is paid even when a submitted transaction reverts, which makes fresh quotes and simulation valuable for small trades.
I would use this route when it is active, can fill the full size, and offers the best net delivered amount under the user’s output floor. I would choose a different route if the pair is inactive, the quote fails at the requested size, or another executable route delivers more after gas and fees. Recheck that decision near submission: the maker’s price and inventory can change between your quote and the block that includes the trade.