Skip to main content

TWAP orders

Time-Weighted Average Price (TWAP) orders are an advanced feature of CoW Protocol, ideal for executing large trades with minimal price impact by distributing the order over a specified time.

Introduction

TWAP orders allow you to split a large trade into smaller parts, executed at regular intervals. This helps in minimizing market impact and in doing so likely achieves a better average price.

Benefits

  • Reduce price impact on large orders: For example, buying $1M of ETH over 3 hours in 6 parts; the TWAP will place an order of $166k every 30min, significantly reducing the price impact and allowing the market to recover.
  • Average buy price over time: This strategy reduces the risk of buying at a high price by averaging the prices over a selected period.
  • Ideal for recurring or big trades: The minimum required order size is $5k on Mainnet or $5 on Gnosis Chain.

Placing a TWAP Order

Connect your Safe wallet

CoW Swap TWAP requires a Safe wallet.

Once CoW Swap is loaded and connected to your Safe 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.

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. The parts have a minimum size of $5k on Mainnet or $5 on Gnosis Chain because each part will need to be executed on-chain, meaning there's a cost associated with each execution.

  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.

Unsupported wallet? Upgrade Safe Fallback Handler

If your wallet is unsupported, upgrade 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 have reviewed the details, 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 to the API. 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. This is a multi-step process that ensures your order is securely processed and activated.

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


The "Order in signing state" screen shows that your order may require additional signatures from your Safe. Ensure all necessary parties sign to proceed.


After all signatures are collected and the transaction is submitted on-chain, 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

Canceling a TWAP order involves a few simple steps. Begin by locating your active TWAP order in the "Your Orders" section to manage it.

Here in the order overview, find the order you intend to cancel. Click the three-dot menu icon at the end of the order's row to open up additional actions. Select "Cancel order" from the dropdown menu to initiate 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 opportunity to review and ensure that you are canceling the correct order.

When you confirm the cancellation by clicking "Request cancellation," a new transaction will be created in your Safe. This transaction is not final until all required parties (Safe owners) provide their signature.

Once all signatures are collected, the transaction to cancel the order will be executed. It's vital to coordinate with all signers to complete this promptly, especially if the order needs to be canceled quickly due to changing market conditions or other strategic considerations. After the cancellation transaction is fully signed and submitted, the order will be removed from your active orders list and considered canceled.

Conclusion

TWAP orders are a strategic approach for large trades, reducing price impact and securing better average prices. Try it out and let us know your experience at info@cow.fi!