Most automated market makers were built on an assumption so basic that nobody writes it down: that when you call transfer(to, amount), the recipient gains exactly amount and the sender loses exactly amount. Value is conserved across the wire. Every reserve update, every slippage check, every liquidity calculation, and every price oracle in a classic constant-product AMM leans on that assumption.
Fee-on-transfer (FOT) tokens break it. They skim a cut on every transfer, and some go further and reflect, rebase, or run arbitrary logic inside the transfer itself. The moment that happens, "sent" and "received" stop being the same number, and a whole stack of math that was quietly depending on them being equal starts producing wrong answers.
The reason this is worth writing about is that it is not always loud. Sometimes the swap reverts, and the user just sees a failed transaction. But often it does not revert at all. The numbers are simply a little bit wrong, everywhere downstream, in ways that favor whoever understands the gap. That is the part that is easy to miss.
What an AMM is actually assuming

Take a Uniswap V2 style pair. The core invariant is x * y = k: the product of the two reserves stays constant across a trade, minus the fee. The pair does not pull your tokens. You send the input to the pair first, and then the pair measures its own balances and checks that the invariant still holds:

There is something clever here worth noticing: the pair derives amount0In from its real, measured balance, not from whatever the caller claimed to send. So the pair itself is more FOT-tolerant than people expect. The breakage is rarely in this single function. It is in everything built on top of it that does assume the nominal numbers are true.
Failure one: the precompute mismatch

The router is where it starts to go wrong. A normal swapExactTokensForTokens precomputes the whole route before touching the pair:

getAmountsOut is pure reserve math. It has no idea the token taxes transfers. So it computes an output assuming the pair will receive the full amounts[0]. Then safeTransferFrom moves the input, the token skims its cut, and the pair receives less than amounts[0]. Now _swap asks the pair to pay out the output that was computed for the untaxed input. The pair measures its real balance, runs the K-check, and the invariant no longer holds, so it reverts.
This is why Uniswap shipped swapExactTokensForTokensSupportingFeeOnTransferTokens. Instead of precomputing, it measures the recipient's balance before and after and checks the delta against the minimum:

That variant works for a simple one-hop FOT token on both legs, because it only trusts measured deltas. But notice what just happened. The fix is a second, parallel code path that exists only because the main one cannot be trusted. The assumption was never removed. It was routed around.
Failure two: the quote is a lie

This is the quiet one. Aggregators, portfolio trackers, bots, and your own frontend all call getAmountsOut (or an equivalent view) to quote a trade before the user signs. For a FOT token, that function returns a number that cannot happen, because it does not model the tax on either leg.
Nothing reverts. The user is simply quoted more than they will receive, routing engines pick the wrong path because they are comparing fictional outputs, and arbitrage bots that price the pool with standard math misjudge the real edge. Every integrator downstream inherits an error they never see, because the function that lied to them is the same one the honest tokens use correctly. The breakage is invisible until someone reconciles what they expected against what actually landed.
Failure three: providing and removing liquidity
There is no "supporting fee on transfer" variant for addLiquidity in the classic router, and that is not an oversight so much as a structural problem. addLiquidity transfers the two amounts into the pair and mints LP shares based on those nominal amounts. With a FOT token the pair received less than it was told, so the shares are minted against reserves that do not exist. The discrepancy surfaces on the next sync or the next swap's K-check. In practice, adding liquidity to a FOT token through a naive router either reverts or mints shares at the wrong ratio, which quietly dilutes whoever was already in the pool.
Removal has the mirror problem. The amounts the router promises to return are computed from reserves, but the FOT token skims the payout on the way to the user, so the amountMin guards either trip or the user is shorted below what they verified.
Failure four: reserves and the oracle drift
Classic V2 caches reserves and updates price0CumulativeLast at each interaction to build a TWAP oracle. That accumulator assumes reserves move only because of trades. FOT tokens with reflection or rebase change balances passively, with no swap at all. Now the pool's real balance drifts away from its cached reserves between interactions. Anyone can call skim to pocket the difference at the LPs' expense, and the TWAP records price movement that never corresponded to a trade. Anything consuming that oracle, a lending market setting collateral values for instance, inherits phantom price history.
Failure five: the transfer hook, which is the deep one
The failures above are about arithmetic. This one is about control flow, and it is the part most people underestimate.
Many FOT tokens do real work inside transfer. They route the collected tax somewhere, swap it to a stablecoin, add liquidity, or distribute reflections. That means an external, token-controlled callback fires in the middle of your swap, while your pool's balances are mid-flight. If that hook touches the pool, directly or through another contract, it reenters your AMM at exactly the moment your invariants are not yet restored.
So a market maker that wants to support these tokens is not just adjusting for a percentage. It has to be reentrancy-safe against the token's own logic, tolerate its own balances changing during an external call it did not initiate, and stay correct when the token being traded itself trades on the pool recursively. Add integer rounding on a percentage fee, where tiny amounts can round the tax to zero or trip an off-by-one in the invariant, and you have a surface that standard AMM test suites never exercise, because they were written for tokens that do nothing on transfer.
Why the patch is a patch
The SupportingFeeOnTransferTokens functions are good engineering, and for a single well-behaved FOT token they hold up. But they are a graft onto a core whose central assumption was never changed. You can see it in the shape of the fix: two swap paths instead of one, no equivalent for liquidity or for exact-output swaps (which are fundamentally incompatible with FOT, since you cannot promise an exact output when the amount shifts in transit), and a quoting layer that still answers as if transfers were lossless. The assumption of conservation is still wired through the reserves, the oracle, and the integrations. It was just quarantined in a few functions.
Building for it instead of around it

The alternative is to stop treating fee-on-transfer as an exception and design the market maker so a transfer fee is the normal case. I have been building exactly that, a FOT-native AMM, and I will keep the implementation to principles here since the code is closed pending audit. But the principles are the interesting part anyway, and none of them are secret:
Measure, never assume. Every amount the pool acts on should come from a real balance delta, balanceAfter - balanceBefore, never from the number the caller passed. The pool is the only honest source of truth about what it received and what it paid.
Make the fee a term in the math, not a surprise to the math. The invariant check, the quote function, and the liquidity accounting should all model the transfer fee explicitly, so quotes are honest to integrators and the invariant does not spuriously revert.
Check slippage on what the recipient actually received, not on what the pool sent. These are different numbers for a FOT token, and only one of them is the user's real outcome.
Keep reserves reconciled to measured balances on every interaction, and guard the paths (skim and friends) that let someone arbitrage the gap between cached reserves and real balances.
Be reentrancy-safe against the token itself, not just against external callers, because the token's transfer hook is an external caller you invited into the middle of your own state transition.
Test the amounts others do not. Exact-amount cases, dust, the boundaries where a percentage fee rounds to zero or one wei past an invariant. That is where FOT-native correctness is actually decided.
Why I care about this
Riffdex turns songs into tradeable tokens that pay a royalty on every trade, split between the artist and the fans who stake. The royalty is not a marketplace policy that a venue can choose to ignore, the way NFT royalties were and mostly stopped being honored. It lives in the token, on every transfer. Which means the asset is, by design, a fee-on-transfer token. A standard AMM would either reject it or quietly mishandle it, and "quietly mishandle" is the worst outcome for something whose entire promise is that the royalty is enforced and the numbers are honest.
So the market had to be built for the asset, not the asset filed down to fit the market. Fee-on-transfer is not an edge case to patch around here. It is the point.
If you have built AMMs or FOT tokens and have hit corners of this I have not, I would like to hear them. This is the kind of problem that gets more correct the more people have broken it.
Written by Melk — artist name of Stephen Heuvel, a self-taught builder and musician from Suriname, and the founder of Riffdex. I was one of the first artists to turn my music into an NFT (over 200 sold in a single day). It never felt right, so I spent the next two years building what music actually deserved: the AFT. Follow the build: @MelkRhm · Riffdex on X · Farcaster