Skip to main content

TWAP orders

Time-Weighted Average Price (TWAP) orders are an advanced feature of CoW Protocol. Instead of executing a trade all at once, a TWAP splits it into smaller parts and executes them at regular intervals over a time period you choose. TWAP orders work with both EOA wallets (like MetaMask or Rabby) and Safe wallets.

Introduction​

A TWAP order takes one trade and turns it into a series of smaller ones, placed at even intervals. Because each part is only a slice of the total, it has less impact on the market price, and the market gets time to recover between parts. Averaging across several points in time can also smooth out the price you get.

People use TWAPs in a few different ways:

  • Breaking up a trade to reduce price impact, especially in pools with limited liquidity.
  • Getting an average price over time instead of committing to a single moment.
  • Scheduling buys or sells at regular intervals, like a recurring purchase.

Benefits​

  • Reduce price impact: Every trade moves the price a little, and in shallow pools that effect adds up quickly. For example, buying $1M of ETH over 3 hours in 6 parts means the TWAP places an order of about $166k every 30min, so the market can recover between parts. The same logic applies at any scale: splitting a $2k trade in a thin pool into a few parts can help too.
  • Average price over time: Spreading a trade across a selected period means your execution isn't tied to a single price point.
  • Set it and (mostly) forget it: Sign once, and CoW Protocol places each part for you at the interval you chose.
  • Minimum order size: $1k on Mainnet, or $1 on Gnosis Chain, Arbitrum One and Base.

Placing a TWAP Order​

Connect your wallet​

TWAP orders on CoW Swap work with two kinds of wallet:

  • 🦊 EOA wallets (MetaMask, Rabby, and friends): connect as usual, no special setup required.
  • 🔐 Safe wallets: open CoW Swap (Safe App) from your Safe. Don't have one yet? You can create a Safe. Once CoW Swap is loaded and connected, you can access TWAP orders via the "TWAP" tab near the center module or the drop-down menu next to the CoW Swap logo.

Select tokens​

Choose the token you wish to sell (e.g., WETH) and enter the total amount you wish to sell.

Funds are needed upfront

The full amount you want to sell needs to be in your wallet when you place the order. A TWAP is a single order that executes in parts, so make sure the total is available before you start.

Specify parameters​

This is a critical step where you'll define how your order will be executed over time. Here's how to fine-tune your TWAP order settings:

  1. Price Protection: This is a measure to prevent your order from being executed at a price that's too far from the market price when the order was placed. Set the percentage of price protection to define the acceptable price range for your trades. For instance, a 10% price protection means that your order will not execute if the price moves unfavorably by more than 10% from the price at the time the order was made.
  2. Number of Parts: Decide how many discrete parts you want to divide your order into. This choice will determine the granularity of your TWAP strategy. For example, if you choose to split your order into 2 parts and you are selling a total of 2 WETH, each part will involve selling 1 WETH. Each part is executed on-chain, meaning there's a cost associated with each execution, so very small parts may not be worthwhile.
  3. Total Duration: Choose the total time frame over which your order should be executed. The TWAP strategy will distribute your trades evenly across this duration. Select from predefined durations like 1 hour, or set a custom duration based on your trading strategy.
  4. Part Duration (read-only): View the duration of each individual part of your order. It is calculated automatically as the total duration divided by the number of parts. For instance, if your total duration is 1 hour and you have 2 parts, each part will have a duration of 30 minutes.
  5. Sell per Part (read-only): After setting the number of parts and the total duration, the interface will display the sell amount for each part. Ensure this aligns with your trade expectations.
  6. Buy per Part (read-only): Similarly, for a buy TWAP order, this will indicate how much of the token you are looking to purchase in each part of the order. Carefully review and adjust your order parameters to align with market conditions, anticipated movements, and your trading objectives, as they are crucial in dictating the execution and efficacy of your TWAP strategy. Once you have tailored these details to your satisfaction, you can move on to the next step to finalize and place your order.

Safe wallet only: upgrade the Safe Fallback Handler​

This step only applies to Safe wallets. If you're using an EOA wallet, skip ahead to "Review and confirm".

If your Safe is unsupported, upgrade it to a Safe with the special fallback handler required for TWAP orders. Learn all about the new Safe fallback handler and its relevance to Safe in this overview. Naturally, the upgrade process has undergone extensive auditing for increased peace of mind.

Review and confirm​

Check all the details of your order, including price protection and limit price. Once you're happy, confirm in your wallet.

With an EOA wallet, you sign a single transaction to create the TWAP order. Depending on the token and your existing allowances, you may also need one of the following before that:

  • a permit signature (for tokens that support permits), or
  • an on-chain approval transaction (for tokens that don't, or where your current allowance isn't enough). Your wallet will prompt you for whichever applies, so there's nothing to configure.

With a Safe wallet, sign the transaction in your Safe interface.

caution

A user should be careful when signing approval transactions. Verify carefully that the spender address is correct (in this case TWAPContract's address).

If in doubt about any of the above, do not sign the transaction. To review your approvals, you can use https://revoke.cash/.

Be careful when signing an order. All of the associated parameters are final and cannot be changed once the order is signed and submitted. If you make a mistake, you will need to cancel the order and create a new one. You can do this in the orders overview.

Finalization and monitoring​

Once you've signed the order, the process of finalizing and monitoring your TWAP order begins.

The "Order submitted successfully" screen indicates that your order has been initially accepted.


Safe wallets only: if your Safe has multiple owners, you'll see an "Order in signing state" screen while the remaining signatures are collected. Ensure all necessary parties sign to proceed.

Once the transaction is confirmed on-chain (for a Safe, after all signatures are collected), your order becomes 'active'. The "Orders overview" allows you to monitor its current status and see the full list of active orders.


Each TWAP can be expanded to show the individual parts.

The three-dot menu for the parent TWAP shows the actions available that affects all parts of a TWAP.

Each individual TWAP part also have a three-dot menu with actions pertaining to that individual order.

Finally, the "Order receipt" provides a detailed confirmation of your active TWAP order, complete with execution details and transaction details.

Cancelling a TWAP order​

Cancelling a TWAP order takes a few simple steps. Begin by locating your active TWAP order in the "Your Orders" section.

Find the order you intend to cancel and click the three-dot menu icon at the end of the order's row. Select "Cancel order" from the dropdown menu to start the cancellation process.

A confirmation window will appear, summarizing the order you are about to cancel, including the swap details and the transaction type. This is your chance to double-check that you're cancelling the right order.

When you confirm by clicking "Request cancellation", a cancellation transaction is created.

  • EOA wallets: confirm the transaction in your wallet. Cancellation happens on-chain, so it costs gas.
  • Safe wallets: the transaction appears in your Safe and isn't final until all required owners have signed. Cancellation is also on-chain and costs gas. It's worth coordinating with your co-signers promptly, especially if you need to cancel quickly because market conditions have changed. Once the cancellation transaction is confirmed, the order is removed from your active orders list and considered cancelled.

Conclusion​

TWAP orders spread a trade across time, which can reduce price impact and give you a smoother average price, whatever wallet you use. Try it out and let us know your experience at info@cow.fi!