Skip to content
Onchain Daily

Protocol-level crypto news, daily

Why Token Swaps Hit an Inventory Cap

A swap cap can come from pool reserves, a contract limit or the route; identifying which one failed tells you whether to change size, path or timing.

Onchain Daily Newsroom5 min read

Cover artwork for Why Token Swaps Hit an Inventory Cap

A token swap hits an inventory cap when the pool or route cannot deliver the requested output under its current balance and contract rules. The limit may come from the amount of a token available for sale, a maximum trade size enforced by a contract, or a quote that cannot meet the transaction’s minimum-output condition. Those causes look similar in a wallet, but they require different fixes.

In a constant-product pool, reserves determine the trade price: as a swap removes one token and adds another, the pool’s balance ratio shifts. For a fee-free pool with reserves x and y, trading input Δx returns Δy = y·Δx/(x + Δx). The formula shows why a larger order gets progressively less output per unit of input. Fees and other pool rules change the exact calculation, but the inventory constraint remains: a pool cannot return more tokens than it holds.

A wallet-level explainer such as fermi swap covers how a swap moves from quote to execution. The cap question is narrower: what limits the amount that the selected path can settle? A quote can also change before execution if another trade changes the pool’s reserves.

What does an inventory cap mean in a swap?

An inventory cap is the maximum amount a particular pool, vault, or route can supply or accept under its current state and rules. It is not a single universal parameter. Some contracts enforce an explicit maximum input or output; other swaps encounter a practical limit because available reserves make the requested price unacceptable.

In a pool that holds two assets, inventory means the usable balance of each asset in that pool. A trade needs enough of the output asset and must satisfy the pool’s swap logic. In a vault or market maker, the contract may impose additional bounds on how much it will exchange, even when its token balance is larger. The contract’s checks define the executable limit.

The interface may show a maximum because it estimates those constraints for a selected route. That figure can reflect one pool’s depth, a contract limit, or the route’s price-impact and minimum-output settings. It should not be read as a general limit on the token itself. Another pool or route may hold more inventory, but its fees, price, and execution conditions may differ.

Why can a quoted swap fail below the displayed cap?

A quote is an estimate based on pool state at the time it is requested; the transaction executes against state when it reaches the contract. If reserves move in between, the output can fall below the transaction’s minimum acceptable amount, causing a revert. The same can happen if the route’s balances or other relevant state change.

Slippage tolerance sets how far execution output may fall from the quoted amount before the transaction is rejected. It does not add inventory or override an explicit contract maximum. Raising it can allow a worse execution to proceed, but it will not make an underfunded pool deliver tokens it does not hold.

Token behavior can also affect the usable amount. A token that deducts a fee on transfer, for example, may deliver less to a pool than the transaction’s nominal input suggests. Contracts and routes that do not account for that behavior may reject the swap or produce a different result from the quote. The relevant balance is the amount the pool can actually use under its token and contract rules.

How should you diagnose and handle the cap?

Start by identifying whether the limit comes from the route’s inventory, a contract check, or a minimum-output condition. The quote and transaction error can help distinguish them, though interfaces vary in how they describe failures. Check these details before changing the trade:

  • Which pool or pools the route uses, and how much output-token inventory each can supply.
  • Whether the contract imposes a maximum input, output, or other swap bound.
  • The quoted output, estimated price impact, and minimum output set by slippage tolerance.
  • Whether the token has transfer behavior that changes the amount received by the pool.

If the pool’s price impact is the constraint, reducing the order size usually keeps more of the trade near the pool’s current price. A different route may offer more depth, but compare its total execution cost and confirm that the route remains valid when the transaction executes. If a contract maximum is binding, changing slippage alone will not help; the trade must fit within the contract’s rules.

Splitting an order does not create more inventory in the same pool. Each part still trades against that pool, and later parts encounter the changed reserves; separate transactions may also incur additional fees. Splitting can help when a contract has a per-swap limit, or when execution is deliberately spread across different pools or times, but those choices introduce their own costs and state changes.

For most users, the practical choice is to size the swap to the available route and its acceptable price impact, then verify the minimum output before signing. A displayed cap is a clue about the selected execution path, not a promise that every amount below it will clear.