The holy grail of automated trading - Trailing stop now available for MakerDAO and Liquity

The holy grail of automated trading - Trailing stop now available for MakerDAO and Liquity

Back in April we came out with a blog post announcing the next generation of DeFi automation which marked the launch of our new modular automated strategies architecture.

Since then we've released automated strategies such as Savings protection for riskless yield earning in combination with collateralised debt positions, Stop loss and Take profit options for minimizing losses and maximizing profits, as well as revised Automated leverage management that recently went live for Aave v3 on Arbitrum and Optimism and that will soon replace our legacy automation available for Aave v2 and Compound.

Today we're taking things one step further and introducing our most advanced strategy yet.

We are very proud to share that a Trailing stop strategy is now available for MakerDAO and Liquity users at

What is a Trailing stop?

A trailing stop is a dynamic strategy that allows users to configure a percentage drop from peak market value that would trigger full closing of your position once reached.

Compared to a standard Stop loss where you simply configure a fixed price at which your position would be closed, a Trailing stop will actively follow any upward market movements by the set percentage, continuously increasing your stop price every time the market moves up and reaches a new peak from the moment the Trailing stop was enabled.

Example chart of a 15% trailing stop enabled on September 30th 2021.

Hopefully the example helps clarify how trailing stops work for anyone who's new to the concept, though this example specifically is one of market moving up after a trailing stop is enabled, which may not be the case. Because of this, trailing stops are often paired with a standard stop loss, where the former helps lock in profits and the latter minimizes losses in case market heads down right after the user opens their position.

For an additional intro to trailing stops we can also recommend skimming through this Investopedia article.

How does the DFS Trailing stop work?

Our implementation of a Trailing stop is built on our new modular automated strategies architecture and additionally powered by Chainlink, which provides on-chain historical market data, and 0x, which provides liquidity for needed asset swaps.

As with all our other strategies, the Trailing stop is also made up of a trigger, which is in this case the user configured percentage drop in asset price from reached peak market price since enabling, and a recipe, which is in this case a set of actions that fully closes your Vault or Trove by paying debt with currently supplied collateral.

Overview of the trailing stop for a MakerDAO Vault, specifically with closing to DAI. The only difference with Liquity would be the use of an ETH flash loan in the executed recipe.

The most interesting part of this strategy is certainly the trigger, which is made possible by Chainlink and their storing of all price updates on-chain as rounds. This is why at the moment of enabling this strategy, one of the pieces of data stored for every user is the roundId (effectively current market price) at the moment of enabling the strategy.

After any user enables the trailing stop, the DFS Automation backend will keep track of all price changes (all Chainlink rounds) moving forward, noting every new peak price and checking if the user configured %% drop has been reached. But, while the backend does the tracking, the actual trigger verification is done fully on-chain and no automated transaction can be executed unless the on-chain trigger condition is fulfilled.

How can you set up a Trailing stop for your Vault or Trove?

As with our other automated features, enabling the Trailing Stop is fairly straightforward. For all existing MakerDAO and Liquity users, you can simply switch to the Automate tab in our dedicated protocol dashboards and you'll find the new automated strategy now available.

The actual configuration only requires you to input the percentage that you want the stop price to be below the reached market peak and to select the asset you want your position to be closed to (e.g. collateral asset or debt asset).

Once you enable the Trailing stop, note you'll be able to check what the current stop price is on this screen at any point in the future, and there'll be a nice chart added (similar to the example from earlier in the post) as the market keeps moving to better show you how your trailing stop has been progressing with time.

💡We recommend enabling a Trailing stop in combination with a standard Stop loss, where the static Stop loss can help you minimize losses, while a Trailing stop can give your position breathing room to lock in profits as market (hopefully) moves up. This will be an especially good combo for leveraged positions.

ℹ️One note for Liquity users: your Liquity Trove needs to be on a smart wallet (dsproxy) in order to be able to use DFS automated strategies. All Troves created using DeFi Saver are on a smart wallet by default and this is also the default behaviour for MakerDAO globally, but any existing Troves open outside of DeFi Saver unfortunately cannot be migrated.

Next steps

With the first rollout of trailing stops now done for MakerDAO and Liquity on Ethereum mainnet, we'll be looking to introduce the trailing stop, as well as standard stop loss and take profit options, for Aave v3 users on Arbitrum and Optimism L2s and likely for any other protocol we integrate on L2s in the meantime.

While we understand the power of a trailing stop, we also fully recognise how much nicer it is to run leveraged and automated positions in a lower fees environment provided by Arbitrum and Optimism and we aim to establish feature parity between mainnet and L2s in the coming months.

As always, for any feedback, suggestions and comments, find us in the DeFi Saver discord - we'd love to have you there and always appreciate the great input our users keep sharing.