How a swap is priced, and why the number keeps moving

News
3 September 2026
Vladimiros Mykogian
Vladimiros Mykogian
Founder

Written by the people building Melmex, from how it actually works.

How a swap is priced, and why the number keeps moving

You type an amount, a number appears, and a few seconds later it is a slightly different number. Nothing has gone wrong. Here is what happens between the two.

There is no single price

A swap does not happen at a quoted market price the way a share does on an exchange. It happens against a pool of assets held by a contract, and the rate depends on how much of that pool you are moving. Small amounts barely disturb it. Large ones move the price against you as you go, which is why the rate you get is worse for a larger order than a smaller one on the same pair.

There are also many pools. The same pair may exist across half a dozen venues on the same network, each with a different depth and a different rate at that instant. Melmex asks 0x, which searches those venues and returns the best route it can build, sometimes a single pool, sometimes a path split across several.

Why the number keeps moving

Because the pools are being used by everybody else at the same time. A quote is a photograph of the market, and it is out of date almost immediately. This is normal, and it is why the amount is re-quoted while you are looking at it rather than frozen at whatever it was when you started typing.

Slippage, and why you get to set it

Between signing and landing on-chain, the price can move again. Slippage tolerance is the limit you accept: set it to half a per cent and the transaction will fail rather than fill at a rate more than half a per cent worse than quoted. Failing sounds bad and usually is not. You pay the network fee and keep your assets, which is the better outcome when the market has moved against you.

Set it too tight on a volatile pair and swaps will keep failing. Set it too loose and you invite a worse fill than you meant to accept. For major pairs the default is fine; for thin ones, widen it deliberately rather than by reflex.

Approvals, and the one to be careful with

Before a contract can move a token on your behalf, you grant it an allowance: a separate transaction with its own fee, which is why a first swap on a new token costs two signatures. You can approve exactly the amount of this swap, or an unlimited amount so you never see the prompt again. Unlimited is convenient and it is a standing permission; grant it only to contracts you mean to keep using.

What Melmex takes

Nothing. There is no fee added to swaps here. The rate you see is the route's rate, and the only costs are the network fee and whatever the pools charge, both of which are shown before you sign. If that changes, it will change on this page first.