HomeKnowledge BaseHow to use CoW Swap’s TWAP orders via Safe Wallet

How to use CoW Swap’s TWAP orders via Safe Wallet

5 min read

Note: TWAP orders are most useful for big trades! So, when trading on Mainnet, the minimum TWAP order size is $5k. This minimum ensures that your savings from reduced price impact are not lost on execution fees (AKA gas fees). If you want to trade smaller amounts, head over to Gnosis Chain, where the TWAP order minimum is only $5 (and the gas fees are much cheaper!)

TWAP orders are now available in the CoW Swap order interface under the “Advanced” tab.

Have a Safe? Awesome! You can try out TWAP here.

Don’t have a Safe? Not a problem! Create one here.

For the below guide, we already have a Safe created. To get started, navigate to CoW Swap and connect your Safe wallet via Wallet Connect, or directly using the CoW Swap Safe native app.

Once your wallet is connected, there are two ways to access TWAP orders:

  • Next to “Limit” in the center module, there is a tab that says “Advanced Orders” → clicking this opens the TWAP orders interface
  • On the top-left corner of the page, next to the CoW Swap logo, it says “Trade” → clicking this opens a drop-down menu that lets you choose between “Swap,” “Limit orders,” and “Advanced orders”

Once you have selected the “Advanced” tab, you will see the following screen: 1-twap-how-to.webp

After you click “Unlock TWAP orders (BETA)”, you will be taken to the TWAP orders interface.

2-twap-how-to.webp

On the left side of this screen, you can see the order box where you input your TWAP order parameters. On the right, there is a panel that shows your open orders and order history.

In order to place a TWAP trade, you need to input your tokens and amounts, indicate how many parts you would like to split your order into, and select the time duration of your order.

3-twap-how-to.webp

To get started, select the tokens you would like to swap from the token list.

4-twap-how-to.webp

Once you’ve chosen your tokens, you need to select the numbers of parts your TWAP order will be split into, as well as the duration of the TWAP order as a whole.

5-twap-how-to.webp

As an added bonus, trading via a smart contract wallet like Safe automatically bundles your approval transaction and your trade together to save you time and gas.

6-twap-how-to.webp

Below the Safe bundling banner, you will see a yellow notice. This notice is not related to your TWAP order itself, but to your wallet. TWAP orders are based on the “Composable CoW” conditional order framework which uses Safe fallback handlers to enhance the functionality of your smart contract wallet.

7-twap-how-to.webp

In order to use TWAP orders, you will need to upgrade your Safe fallback handler. This is a secure process; the code was co-developed by CoW Swap and the Safe team and it has undergone two external audits (you can find the final results of the audits here).

Note: if you are interested in learning more about the fallback handler upgrade process, please refer to this article. If the fallback handler is new to you, please refer to this Safe article for a full introduction to the concept.

Once you understand how the fallback handler interacts with your Safe wallet, you can check the “Modify Safe’s fallback handler when placing order” box in order to upgrade your wallet. This upgrade will take place alongside your trade and bundle any token approvals as a single transaction.

8-twap-how-to.webp

After you click “Approve”, you will be prompted to review your order one last time. Review all of your order details including the price protection, limit price, the minimum tokens you’re set to receive, and all your TWAP properties and ensure everything looks good.

9-twap-how-to.webp

To actually place your TWAP order, click “Place TWAP order” and review & sign your transaction from your Safe interface.

10-twap-how-to.webp

11-twap-how-to.webp

After you sign your order, you will see an “Order submitted” pop-up and your order will appear in the order panel on the side.

12-twap-how-to.webp

In the order panel, you will notice that the order status is not “open,” but rather indicates that your order is still in the “signing” stage. The wallet used in this example requires 2 out of 3 signers to execute a transaction. By creating the transaction, we have performed one of the signatures, and to reach the threshold we need one more signer. To sign, the second signer would need to connect to the Safe wallet and navigate to the “Transactions” queue.

14-twap-how-to.webp

In the queue, we can see our pending transaction and confirm it with the last signature required.

15-twap-how-to.webp

16-twap-how-to.webp

17-twap-how-to.webp

After the last confirmation for the order is done, the order is placed and it will appear in the “Your Orders” UI.

The interface includes several ways to view your orders. You can get a high-level overview at a glance, expand to see the different parts of your TWAP order (in this example the first part executed immediately, which is why only 3 parts are shown), or click into the order to view a full list of details.

18-twap-how-to.webp

19-twap-how-to.webp

20-twap-how-to.webp

Now that your TWAP order is placed, you can sit back, relax, and watch it get filled with CoW Swap’s signature MEV protection and best prices.

21-twap-how-to.webp

We wish you much surplus and happy TWAP order trading! Give TWAP orders a try today and let us know what you think by reaching out on Twitter or Discord!

22-twap-how-to.webp