Start typing to search this publication.
defi news
Open menu

Subscribe to defi news

Get new posts delivered straight to your inbox.

How Are Fraxswap Fees Calculated? Trace a Short Swap

defi news
2 min read

Fraxswap lets you explain a short swap by separating the pair fee, price impact, and gas. The pair deducts its fee from the input before pricing the remainder; that fee stays in the pool’s reserves for liquidity providers, while gas is paid separately in the chain’s native token. The Fraxswap site explains the AMM and its long-term orders, giving background for both kinds of trade.

How Do Fraxswap Pair Contracts Price a Swap?

Each pair contract calculates output using its stored fee rate and the reserves before the trade. Say you send 1,000 A tokens into a pool holding 100,000 A and 100,000 B. The starting spot price is one B per A. For this illustration, set the fee rate to 1%; use the pair’s rate at the time of your own trade.

The fee is 1,000 × 0.01 = 10 A, leaving 990 A for pricing. Under the constant-product rule, x × y = k, output = input after fee × y / (x + input after fee), where x and y are the starting reserves. Here, 990 × 100,000 / 100,990 gives about 980.30 B.

At the starting spot price, 1,000 A represents 1,000 B. The 10 A fee is worth 10 B at that price, leaving a 990 B benchmark. Receiving 980.30 B puts price impact at about 9.70 B. The 19.70 B shortfall from the original spot benchmark is thus 10 B of fee equivalent plus 9.70 B of price impact, before gas.

The fee has no separate token transfer to find on an explorer. All 1,000 A enters the pool’s reserves, although only 990 A enters the pricing calculation; the 10 A difference remains as liquidity provider income. To rebuild a trade, multiply its input by the pair’s fee rate, then price the remainder against its reserves. If the Fraxswap Router used several pairs, repeat this calculation for each hop using that hop’s input, rate, and reserves.

How Are Gas and Long-Term Orders Charged?

Gas is paid for submitted transactions, while a long-term order incurs the pool fee as its slices execute. On Ethereum and Arbitrum, gas is paid in ETH: gas used × gas price. Gas depends on the work performed, not the amount of tokens traded, and a submitted transaction consumes gas even if it reverts.

A long-term order spreads its sale through the embedded time-weighted market maker. Each slice pays the pair fee on its input and trades against the reserves available then, so its price impact can change over time. For a completed order, the user pays gas for placement and withdrawal rather than for every virtual slice. Total cost is input × fee rate + price impact + gas, after converting those amounts into the same unit.

Subscribe to defi news