DEV Community

Anna Botsford
Anna Botsford

Posted on

TWAMM vs TWAP Order: How Large Trades Execute

A TWAP order is a schedule of separate swaps, while a TWAMM is an automated market maker that executes a long-term order as virtual trades inside its pool.

How Do TWAP and TWAMM Execute a Large Sale?

A TWAP order relies on a bot or keeper to send each swap at a set interval; a TWAMM builds that time-splitting into the pool. Both let you spread a large sale over time so the entire amount does not hit the market at once. The difference is who carries out the schedule.

Say you want to sell 100,000 tokens over 24 hours. An illustrative TWAP bot could send 24 hourly swaps of about 4,167 tokens each. Every swap is a separate transaction that pays gas and trades at the price available when it arrives. The bot or keeper must keep running; a missed transaction leaves part of your planned sale for later.

For the same illustrative sale, a TWAMM order places the 100,000 tokens into a pool with a duration of roughly 24 hours. The pool assigns the order a steady selling rate and works out the effect of tiny virtual trades as time passes. This mechanism is built into an AMM. Fraxswap embeds a TWAMM in a constant-product pool derived from Uniswap V2.

Paradigm proposed the TWAMM design in 2021. “Virtual” matters here: the pool calculates what the scheduled trades have done when someone interacts with it, instead of sending a blockchain transaction for every tiny slice. Your sale progresses according to the order’s schedule, and the tokens received from it become claimable. Placing the order takes a transaction; claiming proceeds later takes another.

Why Do Gas Costs and Price Impact Differ?

Gas costs and price impact differ because a TWAP bot sends every slice as a swap, while a TWAMM accounts for many virtual slices together and offsets opposing long-term orders before their net pressure moves the pool’s price.

Take a simplified moment during your 100,000-token sale. Your order is virtually selling 100 tokens, while another long-term order is buying the equivalent of 60 tokens at the pool’s current price. Those opposing flows offset within the TWAMM calculation. Roughly 40 tokens of net selling pressure then move the reserve curve. If there is no opposing long-term buy order, the pool must absorb your full virtual sale at that moment.

That offset is useful for a large trade. A standalone TWAP bot pays gas for each submitted slice, whether or not someone happens to buy at the same time. Its swaps may meet buying activity in the market, but the bot has no built-in way to pair its scheduled sale with an opposing scheduled order inside the pool. A TWAMM handles both directions as part of the same pool calculation, so matched flow causes less movement along its pricing curve.

  • Bot-run TWAP: You choose the slice size, interval and where the bot sends each swap. More slices mean more transactions and more gas. The bot can change its route or schedule if its setup allows.
  • TWAMM long-term order: You choose an amount and duration for a particular pool. Virtual slices need no separate transaction from you, and opposing long-term flow can offset part of the sale. Execution follows that pool’s liquidity and prices.

For the 24-hour sale, the practical choice starts with the pool. A TWAMM suits a pair with enough liquidity when you want to place the sale once and let it run. A bot-run TWAP suits a sale that needs routing across pools or active changes to its timing. Compare the pool’s available liquidity and expected execution with the bot’s gas bill for all its planned swaps. Splitting either way reduces the size of each encounter with the market; it does not fix the price you will receive over the day.

Related Questions

What Is a Long-Term Order on Fraxswap?

A long-term order is an instruction to sell a specified token amount from one pair over a chosen period. The tokens enter the TWAMM when you place the order. Its virtual trades gradually exchange them for the other token in that pair, and the proceeds can be claimed. It is an order to keep trading over time, so the amount of the other token you receive depends on prices as the sale runs.

Is a TWAP Order the Same as a TWAP Oracle?

No. A TWAP order sends trades over time; a TWAP oracle reports a time-weighted average price calculated from price observations. A contract might read that average to value an asset, but the oracle does not place your swaps. The shared name describes the use of time in each case, which is why confusing them can lead you to a price feed when you are looking for an order tool.

Can I Cancel a TWAMM Order Midway?

Yes. Cancelling a TWAMM order stops its remaining virtual sales and returns the unsold tokens along with proceeds earned so far. Cancellation is a transaction, so it costs gas. The portion already sold stays sold: cancelling changes what happens next, not the trades the pool has already accounted for.

Top comments (0)