Automate UniSwap LPs with SAFE and Zodiac Roles Mod

There is always going to be a security trade-off when automation is involved. Whether Keepers are involved, a Relayer or a protocol like Gelato, at the end of the day, the executor needs the correct access to perform the automation.

Thanks to smart contracts though, it doesn’t have to be this way. You can still use a multi-sig smart wallet like SAFE in conjunction with the Zodiac Roles Modifier to designate Roles that only certain authorized accounts can execute. This is how a number of DAOs can enable another entity to manage their treasuries in a non-custodial and zero trust way. Projects like KarpatKey specialize in this type treasury management. They even released an open source tool you can use to manage this type of permissions on Safe and Zodiac Roles.

What this guide is going to show you is how you can enable and configure Zodiac Roles in your SAFE with a preset specifically simplified for Uniswap V3. After the module is configured you can create automation bots that can collect fees and compound them for you. All while keeping your assets safe under your existing multi-signature scheme.

Enable CoinKontrol Safe App

Our CoinKontrol Safe App is not yet part of the default set of Apps, so you’ll have to add it manually (is it open source if you are keen to audit the code). Here’s how to add the app to your Safe:

From the Apps menu, select My custom apps
From the Apps menu, select My custom apps

Click on “Add custom Safe App” button and add the following URL in the input box:

https://safe.coinkontrol.com

This is how the menu looks once you add the URL.

Adding the custom SAFE app
Adding the custom SAFE app

But I don’t trust your SAFE App

If you don’t trust a 3rd party SAFE app like this, we also prepared a repository with a more transparent setup, based on the starter kit privided by Gnosis Guild. Using this approach you can keep track of the permissions you apply in a source controlled repository apply / remove permissions as needed.

If you go this route, you will need to deploy the Zodiac Safe Modifier yourself (the CoinKontrol app handles that in the first step). After deploying the modifier and enabling the Role, you can still automate using CoinKontrol app. If you don’t need automation at all, then you can skip CoinKontrol altogether and just use the zodiac pilot browser extension - once you connect your safe and the Role mod, you will be able to browse all your dApps and execute transactions using the designated account you gave access to perform those actions.

Deploying the Roles Modifier from the Zodiac Safe App
Deploying the Roles Modifier from the Zodiac Safe App

Deploy Zodiac Roles

Once you configured and opened the SAFE app you will be greeted by the default screen where you can deploy the Zodiac proxy role contract (in case you don’t have one already). Click on the “Add Roles Modifier” and get redirected to confirm the transaction. Make sure you double check what you’re signing:

  • deploy the proxy module of Zodiac Roles Modifier V2

  • enable the module in your SAFE

  • set transaction unwrappers

    • this is to allow the Role to execute batch transactions
Initial CoinKontrol screen
Initial CoinKontrol screen

Note that you don’t have to enable the Zodiac Roles Modifier from the CoinKontrol app - this is here for convenience only. You can navigate to the Zodiac SAFE app which is part of the official list of apps and deploy it from there as well.

Create and enable Role for UniswapV3

Now that the role modifier is enabled, you can create the preset for managing a UniswapV3 position. We allow you to customize what operations you want to allow. For example, you may only want to allow the collection of fees, or the swapping of a pair etc.

Add UniswapV3 Role and permissions
Add UniswapV3 Role and permissions

After you selected the tokens you want to manage and the full permissions, click on “Apply Role” to get redirected to the Zodiac Roles App where you can review the permissions you are enabling in your Zodiac Roles mod. Note that at this point, you are only creating the Role - until you add a member account to that Role, you still don’t allow anyone else other than the SAFE owners to execute transactions.

Permissions view
Permissions view

⚠️ It’s super important to pay attention to what you are enabling in the Roles modifier. After you add a member to the Role you are creating they will be able to execute transactions that bypass the regular safe execution.

Scroll to the bottom of the Zodiac Roles app and click on the “Execute” button. This will redirect you to the Confirm transaction page where you can review what you’re signing once again.

Sign up for a CoinKontrol account

You are now ready to automate your position. At the time of this writing, CoinKontrol can only manage existing UniswapV3 Positions and not mint them from scratch. After you sign up (you can either use email or Gmail SSO), you will be prompted with the onboarding screen where you can configure your SAFE address:

CoinKontrol onboarding
CoinKontrol onboarding

The wallet address you see in there is your CoinKontrol hot wallet. This is the wallet you will add as a member to your Zodiac Roles mod in your Safe. You also need to fund this wallet with a small amount. Being on Arbitrum means that transactions fees are extremely cheap - we recommend only funding a very small amount at a time (~$20-30). Remember that even though this wallet won’t have access to your funds, if CoinKontrol gets hacked, this hot wallet would get exposed.

After you configure your SAFE, navigate to the Bots page and you’re ready to create your first automation bot.

Create a new bot
Create a new bot

After you select the SAFE, the form will auto-populate drop downs for the rest of the Zodiac Roles information you will need. Below we explain each of those for posterity.

Roles module address

This is the Zodiac roles mod you just deployed earlier. When you open the CoinKontrol SAFE app, you will see the address right at the top.

Role key

The role key is a hash of the Role name. We don’t expose setting a custom name for the Role in our SAFE app to keep things simple in the UI. But this is how our transaction automation will know how to execute transactions against your SAFE via the Zodiac role mod.

NFT ID

The NFT ID is the Uniswap position ID. You can find this in Uniswap or by navigating to the Positions page in CoinKontrol. Note that every single position you created in Uniswap will be displayed there, select the one you want to automate.

Strategy

When you sign up, we create a few default strategies you can select from:

  • collect

  • collect and compound

  • compound

As the names suggest, you can pick whatever action you want the bot to make. In the future we will allow you to customize positions and also provide more advanced ones.

Lastly, select the Wallet and the Safe from the drop downs and create the bot.

Add CoinKontrol wallet as member in Zodiac Role

Before enabling the bot, we need to add the address that the bot will use to execute transactions to the Zodiac Role we created. Go back to your SAFE and open the CoinKontrol SAFE app and add the wallet address as a member of the role you created earlier:

You are now good to go, you can enable the bot in CoinKontrol and soon you will see the transactions listed for your bot.

To be continued…

This simple workflow is nice, but it’s still very basic. The plan is to be able to use a bot to automatically exit and re-enter positions depending on what the price of the tokens is doing. We are also planning on integrating hedging strategies for your assets.

Also worth mentioning, there are alternatives to this if you don’t use a SAFE and still want auto-compounding positions: Revert is one of them.

Subscribe to CoinKontrol
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.