HomeKnowledge BaseGetting to Grips with Time-Weighted Average Price (TWAP) orders

Getting to Grips with Time-Weighted Average Price (TWAP) orders

8 min read
·
Published Nov 29, 2024, 6:51 PM

Understanding-TWAP.png

Have you TWAP’d yet? No? You’re in the right place. TWAPs, or Time-Weighted Average Price (TWAP) orders are a unique type of trade that lets users apply a number of different parameters to their trades.

TWAPs have been around for a while on centralized exchanges, but CoW TWAP — CoW Swap’s version of TWAP — comes with several important benefits that traders won’t find on CEX alternatives. Curious?

The below guide will take you through what TWAPs, when should you use it, and most importantly, how to use them on CoW Swap.

What is a TWAP order?

TWAP orders allow traders to spread their trade over a specified period of time. In essence: a TWAP order consists of multiple smaller orders placed at regular intervals over a predefined time period. You decide on the intervals, the number of parts, and other key factors including total duration and part duration.

The "Total duration" is the duration it takes to execute all parts of your TWAP order. Let’s say your order consists of two parts placed every 30m, the total time to complete the order is1h. Each limit order remains open for 30m until the next part becomes active.

The "Part duration" meanwhile, refers to the duration between each part of your TWAP order. You can choose a shorter time to allow for faster execution of each part, potentially reducing price fluctuations. Or go for a longer duration if you’re looking to even out your trades over time.

Then there’s the “sell per part” and “buy per part” options. Sell per part is the estimated amount that will be sold in each part of the order. Buy per part is the estimated amount that will receive in each part of the order.

Last, but not least, a TWAP order allows you to specify a unique feature called Price Protection.

Expressed as a percentage, price protection is a feature that will stop your order from executing if the market price of your token dips more than your set price protection. So let’s say you set 10% as your price protection. Your start your twap, but before the first part of the trade is due to complete, the price of your asset drops by 12%. Because the price has dropped below the threshold you set, the trade is stopped.

This set-and-forget feature means you can manage your trades in more flexible ways.

Why Should You TWAP?

Is ultimate control over your future trades not enough? There are several additional reasons why TWAP should be part of your DeFi arsenal.

Dollar-cost averaging (DCA) becomes quick and easy

Let’s see you’re a trader and you’ve spotted a promising project you want to buy tokens over some time as part of a dollar-cost averaging (DCA) investment strategy. DCA involves investing a fixed amount of money in an asset at regular intervals, regardless of the asset’s price, to reduce the impact of market volatility.

In the highly volatile world of crypto, there’s always a chance you might make a large investment just before a sudden drop. ByTWAP minimizes this risk by breaking down your investment into smaller, evenly distributed purchases over time.

Let’s say you’re not exactly sure when’s the right time to hit the “Swap” button. With TWAP orders, you can set and forget your trade and forget about trying to find the perfect moment to trade.

Thinking about selling assets using a DCA strategy? You can do that too. Investors can also use TWAP to sell their positions through dollar-cost averaging. Simply switch the assets you’re swapping and TWAP will help you exit the market for an average price.

Reduce your price impact

If you’ve dabbled in the world of small-cap cryptocurrencies you’ll be aware that making large trades can often mean you get a lot less than what you were planning. That’s where TWAPs come in.

By splitting up large trades into multiple smaller orders, TWAP helps mitigate the negative effects of price impact. A bunch of smaller orders affect liquidity pools, and therefore prices, much less than one big order, meaning you end up getting a better deal for your trades.

When should you TWAP?

There are lots of different occasions when TWAP orders may be more beneficial than regular swaps. Below are a few examples.

When you want to sell your small cap tokens

Built up a war chest of small caps but can’t seem to exit? TWAP orders can be useful for breaking up the trade into chunks. Trying to push large trades in small caps can often face hurdles. But with TWAP you can set your trade to execute over periods as long as a month and in multiple chunks, helping you exit small caps in one go.

When you’re trying to reduce your slippage

If you’re trying to keep your slippage low, using TWAP to split up a large order into smaller parts allows you to use a smaller slippage tolerance for each part. TWAP orders are also protected from MEV, helping protect your trades. The MEV bots can look elsewhere.

When you want to receive 100% of your order surplus

On CoW Swap, all order surplus is forwarded to you. If your order executes for a better price than your quoted price — thanks to Coincidence of Wants or any other price improvement that solvers are able to find — the extra price improvement will be forwarded to you.

When you’re trying to navigate volatile prices

By giving traders the time-weighted average price, TWAP orders smooth out market volatility, which makes trying to predict prices a thing of the past.

When you want to specify certain conditions or parameters

TWAP orders allow you to fine-tune your order by specifying the number of parts you’d like it split up into, as well as the time period you want it to execute over. On CoW Swap, TWAP orders also have a “price protection” option which protects your order from executing at an unfavorable price due to market volatility.

How do you TWAP?

So now you know about all the features of TWAP orders, how do you get started? You’ll first need to ensure that you have a Safe wallet, one of the most trusted wallet providers in crypto.

Don’t have a Safe? No problem! Create one here. After you make a Safe, you’ll also need to upgrade your fallback handler. Learn what this means and how to do it here.

Once your Safe is fully set up, you can access TWAP directly through the CoW Swap order interface.

TWAP orders on Ethereum Mainnet have a $1,000 minimum per order part. This ensures that gas costs are relatively low compared to the entire order size, even with multiple parts involved. Smaller traders can also enjoy CoW TWAP on Gnosis Chain where part minimums are only $5 (and the gas is much cheaper!)

You can find the full how-to guide on CoW TWAP orders here.

As a reminder, using TWAP orders with CoW Swap offers a number of additional benefits. These include:

  • All prices are aggregated from the best available on-chain and off-chain liquidity

  • Traders are fully protected from MEV

  • Orders are free to place and free to cancel

  • Traders never pay for failed transactions

  • Transactions are gasless as fees are paid in the sell token

Getting to grips with the TWAP order interface

Screenshot 2024-11-29 at 17.18.19.png

To get started with TWAP orders through the Safe app, you will first need to authorize a transaction signing request that contains a batch of transactions.

This batch includes a “setFallbackHandler’’ function. TWAP orders are the first order type that runs on a new conditional order framework, super-charging your Safe.

In order for this framework to make complex trades on your behalf, an upgrade to Safe’s “fallback handler” is required. Don’t worry though, you will be automatically prompted to upgrade to use TWAP.

This framework allows you to do things like set fallbackhandler so that your Safe works with CoW Swap’s conditional framework. This means you can deploy your entire TWAP strategy, and trigger the first part of the TWAP in one go.

set up your safe works with CoW Swap conditional framework, immediately deploy my entire TWAP strategy, and trigger the first part/tx of the TWAP in one go.

The TWAP interface has several sections:

  • Trading Assets: Select the assets you want to swap and the amounts of each.

  • Price Protection: Provides protection against major price movements. Your TWAP order won’t execute if the market price dips more than this percentage (calculated from the asset price at the time of order submission).

  • Number of parts: Enter the number of parts you would like your order split into.

  • Total Duration: The total amount of time your order will take to execute.

  • Part Duration: Automatically calculated from your total duration and number of parts, part duration shows how long CoW Swap will wait between each part of your order.

  • Sell & Buy per part: Shows an estimate of how much CoW Swap will sell and buy with each part of your trade.

Each one is a simple toggle, all you have to do is set the parameters that work for you and you’re done.

Happy TWAP’ing!