Product Update: Automated Vaults

Huacayachief
Alpaca Finance
Published in
8 min readJan 5, 2023

--

Dear alpacas,

Today, we’re thrilled to show you around, as we take you on a short visit of our hypothetical “Automated Vaults Lab.” 😄

First, let’s start with an update. We have successfully rolled out repurchasing to all the planned AVs in November, and sunsetted the non-performing vaults. Despite the market downturn in November-December where we saw BTC drop ~20%, our AVs have performed well, returning as high as ~25% APY (on an annualized basis) on some vaults.

Data as of 4 January 2023; numbers in parentheses represent annualized return

Over the past few months, our team continuously worked to improve the effectiveness of the repurchasing mechanism. Since its algorithms have become more complex than the previous rebalancing system, we would like to take this opportunity to explain in more detail how the hedging operation and repurchasing work.

How does repurchasing work? How does it differ from rebalancing?

The ultimate goal of repurchasing and rebalancing are the same: to eliminate the delta exposure of Automated Vaults due to changes in asset prices (aka hedging). However, there are several aspects where repurchasing and rebalancing differ, which we discuss below:

Rule:

  • Rebalancing: The rule for rebalancing was very simple and straightforward. If the debt ratio > threshold, a rebalance was triggered. The drawback of this method was that it was relatively inflexible and only backwards looking, unable to keep up with major market changes (like major liquidity shifts, as in the FTX collapse), and cannot adjust for them in advance.
  • Repurchasing: Compared to rebalancing, we added more Intelligence Factors into the system to determine when and how to do repurchasing, which work to increase the aggregate long-term profitability. We’ll discuss how that works in more detail in the next section.

Note: While there is more flexibility around the timing and price when executing repurchasing txs, we have a safeguard in the smart contracts such that a repurchase transaction must reduce the delta exposure of the vault, otherwise, the transaction will be reverted. This check helps ensure that the txs will only improve the state of the AVs.

Cost:

  • Rebalancing: Higher cost because swaps happen on DEXs, incurring high swap fees (compared to on CEXs) and price impact for large vaults. It’s also susceptible to front-running and MEV bots.
  • Repurchasing: Lower cost as assets are repurchased at a fixed discount percentage regardless of the size of the transaction. To avoid front-running or manipulation, it also uses best practices such as probabilistic execution, which prevents a potential manipulator from reverse engineering the exact rules of execution.

Why does repurchasing sometimes appear to be “hanging” aka not executing?

Depending on the market condition, there is a specific optimal hedging strategy that will provide the highest potential returns for AVs. For example, if the market is volatile but the price is range bound, the optimal strategy would be to hold off any repurchasing / rebalancing tx, as one would otherwise be cementing the IL and paying for the tx costs unnecessarily as price oscillates in the range. On the other hand, if the market is trending in one direction, the best course of action would be to execute repurchases gradually over the price range as it moves. Waiting too late to execute would result in higher IL and loss in this case.

With the old rebalancing system, given the simplicity of the rule, the transactions got executed if the conditions were met regardless of the market conditions. This, sometimes, resulted in suboptimal behavior for our AVs. For example, you could see a lot of rebalances at bad prices during sharp price movements — i.e., rebalances for the initial price move, and rebalanced again as price reverted.

Example of multiple rebalance transactions being triggered on a sudden price movement.

However, the current repurchasing system leverages many data points including historical prices and various economic factors to develop signals which can determine, with a high probability, which market regime we are currently in (trending or range bound; will there be a reversion.) As the model gathers real-life operation data points, it also utilizes machine learning to improve its performance over time. Based on this information, the hedging algorithm would adjust its behavior (i.e., “operating mode”) based on what’s optimal at the time. We would also like to highlight that there is no separate code base for each mode, but rather the same code base with slightly different “formulas” for parameters , which would in turn change how each mode operates.

As mentioned earlier in the article, we also use probabilistic execution to help prevent a potential manipulator from reverse engineering the exact rules of execution. So to the outside observers, the transactions timing could look less deterministic. We know that many alpacas love the details, so let’s dive in a little more on how this works.

First, let’s us introduce the concept of Repurchasing Intensity Curve which defines the probability of a repurchasing transaction being executed as a function of the vault’s delta exposure. The curves would look something like the figure below:

You will notice that the shape of the curve is quite similar to our borrowing interest curve (if you replace the x-axis with utilization, and the y-axis with borrowing interest rate) and you would be right! At a conceptual level, they are trying to achieve similar outcomes.

  • At a low delta exposure (the vault is quite balanced), we are less interested in repurchasing happening, so we assign a low probability to it. In fact, below a certain delta exposure, we even assign a zero probability for repurchase to allow for the small price fluctuations, and make sure repurchasing does not happen.
  • As the delta exposure grows, the probability of a repurchasing happens also increase (this is analogous to the slope1 region of borrowing interest curve.)
  • Beyond a certain threshold, it becomes more critical that the repurchasing happens so the probability slope become more steep and approaches 1 to guaranteed the repurchasing happens (this is analogous to the slope3 region of our borrowing interest curve.)
  • Similar to how we can adjust the borrowing interest rate curves to achieve an optimal state for the lending vaults, here we can also adjust the coefficient / parameters of the Repurchasing Intensity Curve to make repurchasing more “relaxed” or “tight” to best suit the market conditions.

Using the method above, the model evaluates whether to execute a repurchasing transaction on a per block basis (every 3 seconds) using parameters like Probability.

Below we discuss the different operating modes for repurchasing.

Operating Mode 1: Normal Operations

  • In normal mode, the algorithm does not expect a price momentum in either direction.
  • In this state, price is allowed to move within the bound. Repurchasing is only triggered if it moves beyond the range.
  • At a gross simplification level, we could say that this mode closely resembles the old rebalancing system.

Operating Mode 2: Hedging Closely

  • In this mode, the AVs will hedge very closely (i.e., execute repurchasing with slight price movement.)
  • This mode is activated for when price momentum is expected, but the direction of the movement is unknown. This means the repurchasing would happen in either direction of the price move.
  • By hedging closely, the vaults’ delta exposure is kept close to zero and will have no bias for upcoming price movements.
Illustrative transactions pattern in the Hedging Closely mode

Operating Mode 3: Hedging Trend

  • In this mode, the algorithm believes that there is a high probability of price trending in a particular direction.
  • It will hedge the price movement closely, similar to Mode2. However, the hedge will only be one way in expectation of price moving in that direction.
  • A move in the other direction would not be hedged, due to anticipation of reversion.
Illustrative hedging transactions in an expected price uptrend

Operating Mode 4: Guarded (Analogue to Alpaca Guard).

  • In this mode, a big price movement is happening/has happened, but a mean reversion is expected based on the hedging algorithm’s signals, and so repurchasing is held off.
  • In recent months, this mode has been activated several times, including when BNB price spiked to 400, and afterwards when BNB price sharply declined. All this can be simplified into: our algorithm had a high degree of confidence that price would mean revert and thus held off on repurchasing. Through this approach, the result was that the vault became very profitable after the price mean-reverted.
  • So, in this operating mode, it could appear that the AVs are not active in executing repurchasing, while in fact, the system held off the transaction by design.
  • With the goal of minimizing volatility, going forward, we will tweak the parameters so that repurchasing happens more gradually, so you can expect the Vault’s performance to be smoother in the future compared to the post-FTX timeframe.

How do we know that repurchasing is working?

Our System is always monitoring the conditions to trigger repurchasing 24/7. We have redundancies in place to ensure the highest possible uptime for the operations. We have a lot of experience in this area, through operating liquidation bots, price feeds (Alpaca Guard.), etc., for Alpaca LYF, which have been battle-tested over the past 2 years.

We are in the process of creating a Telegram channel where we’ll provide real-time updates on the vault statuses (i.e., which state it’s in, current delta exposure, etc.) and the live repurchase tx log. We hope this will provide more transparency and a way for our community to keep track of the operations.

We expect this TG channel to go live in the next few weeks.

In the meantime, you can view historical repurchasing statistics on this dashboard: https://dune.com/metey/alpaca-finance-automated-vaults-info

--

--