Walkthrough — Automatically Swapping ERC20 tokens on Gnosis Protocol

Gelato
Gelato Network
Published in
5 min readJul 8, 2020

Walkthrough — Swapping 10.000 DAI for WETH every 60 minutes on GP:

1) Visit https://gnosis.gelato.exchange/

2) Click Connect Wallet and log in via Metamask

3) Choose your condition. In this case, we will only swap one token to another on GP, if a certain time (60 minutes) has passed.

4) Click on “Instruct Bot” to input the parameters of your transaction

5) Input 60 minutes, to have gelato submit a transaction every 60 minutes for you. You just defined the condition that specifies when gelato can execute the transaction.

6) Input the parameters for your action, which in this case is the swap on GP. For the slippage value, you can use for example 5 or 10%. As the transaction will occur at some point in the future, you will not be able to anticipate what the current market price at that time will be in order for your trade to be filled within a given time period (3 batches in this case, ~15 minutes). That is why, under the hood, we fetch the current market price from Kyber, at the time of execution for you.

The slippage you can input here, basically determines the likelihood of the order actually being filled. The higher the slippage, the more likely it will be filled, but also the worse of a price you might get. You should also not put the slippage too small, otherwise, your trade might not go through as planned and you will simply withdraw the inputted sell amount minus the fees.

In the “How often should this task be submitted” field, you can determine how often you want to trade. Inputting 2 means that after 60 minutes you will swap once and then after another 60 minutes you will swap again. And then your 2 automated tasks have completed and no other trades will occur. You can swap as much as you want.

7) Now you will be presented with an overview of your task. Note that the Gelato Provider of the dapp currently charges a $15 fee for every automated transaction. The fee will be paid when the order is being placed from your sell amount, in this case DAI. This is because the Provider needs to pay the relayer, who will execute your trade, for gas and an incentive reward. Scroll down and click “Submit Task” to start the submission.

Note: After submitting the task, every time your specified condition is fulfilled, funds will be withdrawn from your wallet, swapped on GP, and then sent back! You always have full custody over your funds.

8) If it’s your first time trading DAI through the UI, you will be asked to approve your Gnosis Safe proxy, which will be deployed for you after the transaction, to move DAI on your behalf. Click “Approve” and confirm the transaction in your wallet provider (e.g. Metamask).

9) Now it’s time to submit the actual task to gelato. If this is your first task submission, you will deploy a Gnosis Safe in the same transaction, which acts as your smart contract representation on gelato. This is the reason why your very first task submission transaction will be a lot more expensive than all the ones that follow.

10) You’re done! The executors of the gelato network are now monitoring the time condition you specified, and if 60 minutes have passed, they will swap 10.000 DAI for WETH on your behalf on GP. After another 60 minutes, they will do it again.

If you click on “My bot activity”, you can see an overview of all the tasks that you have scheduled. If you click on the eye icon under the “Details” column, you can see what the task is about again and get more information about the transactions that were executed on your behalf. You can also cancel the task at any time by clicking on the icon under the “Cancel” column.

Note that the funds will show up back in your wallet at most 30 minutes after the final order has been executed. This is due to the fact that we give GP 5 batches to fill the order before gelato can withdraw the funds back to your wallet

End of the walkthrough. Give it a try and make sure to let us know if you want to see any other integrations together with the Gnosis protocol.

What is Gelato?

Gelato is a tool for developers to automate smart contract executions on Ethereum. It makes it easy to build automated dapps, without having to run the underlying relay node infrastructure.

The design goal is to provide a highly accessible and reliable automation service, without a single point of failure.

--

--