(Note · · 5 min read)

The price moved between the quote and the trade

Showing a live price from an on-chain pool looks like reading a number. It is not: the number depends on the size of the trade, it changes with every other trade, and by the time a user has read it and confirmed, it is already out of date.

By Md. Habibur Rahman Shohel, full-stack & AI product engineer in Dhaka

A pool price is a function, not a value

The rate for a small amount and a large one differ, because the trade itself moves the pool. Quoting a single headline price and applying it to any size understates the cost of large trades, which is precisely where the complaints come from.

Quote for the actual amount the user entered, and recompute when they change it. The quote belongs to the pair and the size together.

Separate the two things that move the price

Price impact is the part caused by this trade's own size against the pool's depth — predictable, and worth showing when it is significant. Slippage is the part caused by other trades landing between the quote and execution — unpredictable, and what a tolerance protects against.

Users conflate them and the interface should not. Someone seeing a poor rate deserves to know whether their own size caused it, in which case a smaller trade helps, or whether the market moved.

Enforce the quote on chain

A price displayed in the interface is a claim. The protection is a minimum output encoded in the transaction, so execution at a worse rate fails rather than proceeding.

Derive that minimum from the quote the user actually saw, with their tolerance applied. Computing it from a fresh quote at submission time means the user agreed to one number and the transaction enforces another.

Quotes expire, visibly

Give every quote a short lifetime and refresh it. When it refreshes and has moved materially, say so before the user confirms rather than letting a better number be replaced by a worse one in silence.

Pause refreshing while a wallet confirmation is open. A quote changing underneath an open prompt means the user confirms a transaction built from a price they never saw, which is the worst version of this.

Make the whole cost visible

The rate is one component. Protocol fees, pool fees and the network fee all change what somebody actually receives, and on a small trade the network fee can exceed everything else.

Show the amount received after all of it, in the terms the user cares about. A quote that is accurate about the rate and silent about fees is still a number nobody can act on, and the discrepancy is discovered after the irreversible step.

Price and eligibility are separate checks

Where a rate depends on who is trading — a holder discount, a staking tier — the discount is an eligibility decision verified server-side and on chain, while the base price comes from the pool. Keep them distinct in the code.

On a staking protocol I built, that is exactly the shape: rewards and a discount of up to a stated maximum on swaps, with the price itself read live from the pool. The discount is a rule about the user; the price is a fact about the market. Conflating them produces a quote that is wrong in two ways at once.

Say what failed

A transaction rejected by a minimum-output check is not an error, it is the protection working. Explain it in those terms — the price moved beyond your tolerance, nothing was spent beyond the network fee — and offer a refreshed quote.

A generic failure message here reads as a broken product, and sends a user who was protected to ask why the application is unreliable.

Common questions

Why does the price change between quote and execution?

Because a pool price depends on both the trade's size and every other trade landing in between. The quote belongs to the pair and the amount together, so it must be recomputed when the amount changes and refreshed on a short lifetime.

What is the difference between price impact and slippage?

Price impact is caused by your own trade's size against the pool's depth and is predictable; slippage is caused by other trades landing between quote and execution and is not. A tolerance protects against the second, and the interface should not conflate them.

How is a quote actually enforced?

With a minimum output encoded in the transaction, derived from the quote the user saw plus their tolerance, so execution at a worse rate fails. Computing it from a fresh quote at submission means the user agreed to one number and the transaction enforces another.

What should a failed slippage check tell the user?

That the protection worked: the price moved beyond their tolerance and nothing was spent beyond the network fee, with a refreshed quote offered. A generic error here reads as a broken product to a user who was in fact protected.

Need something like this built?