Aloe Explained #2: Staking and Rebalancing

Aloe Explained is a series where we discuss details of the Aloe Protocol in an accessible way. For a more general overview, check out our introductory post.

Imagine that Uniswap V3 is a newly-built library. They need to stock up on books for each section, so a few local benefactors offer to give the library a bunch of books in exchange for a portion of the late fees.

  • books for each section: liquidity for each trading range
  • local benefactors: liquidity providers
  • late fees: swap fees

Aloe is the librarian. It surveys patrons to figure out which types of books will soon be in demand, and if they’re not available locally, it can source them from other libraries. By the time the books become popular, sections are fully stocked and ready for action.

  • surveying patrons: trader activity prediction via staking
  • ensuring sections are stocked: optimal liquidity rebalancing


Staking is 100% permissionless, so anyone is free to participate. A new round starts every hour, on the hour. To participate, each staker must submit one or more proposals before the round starts. A proposal consists of lower bound price, upper bound price, and stake size.

When the round begins, Aloe combines the stakers’ proposals* into a single aggregate position* that reflects overall sentiment. This is done by (1) finding the weighted average over all positions, then (2) finding the 2nd moment on each side of that center.

The bottom two summations are simply the 2nd moment integral evaluated for a linear combination of step functions. To gain intuition, picture a metal rod on each side of the mean. Prices map to positions along the rod, and the density at each position is proportional to stake. Aloe’s bound is the rod’s center of mass.

At the conclusion of each round, each staker’s proposal is judged against the market prices to determine reward payouts. The steps to calculate rewards are as follows:

  1. Normalize the amount staked by each staker to a value between 0 and 1
  2. Divide the hour-long interval into 10 6-minute intervals and find the mean price the coin was traded at within each interval. From now on, we only use these 10 mean prices.
  3. The “true center” is defined as the overall mean over the hour-long interval. The true left and right bounds are calculated as follows:
The 2 is chosen to model a 5% significance level (capture the true level with a 95% certainty).

4. For each stake, find the squared distance from the staker’s lower bound to the true left and normalize — call this number “L”. Repeat this process for the upper bound and true right — call this number “R”.

5. Finally, average L and R to get a value between 0 and 1 for each staker. Finally, multiply this number by the stake amount to get the final reward number for each stake.

ALOE tokens are redistributed to stakers proportional to their normalized reward number. This has a few desirable effects:

  • Correctness is encouraged
  • Tight bounds are encouraged
  • Higher stake (more ALOE tokens) may lead to higher reward

A note on distributions: By default, stakers input a range corresponding to a uniform distribution. However, alternatives like normal or exponential distributions can be discretized and submitted as a set of ranges. We’ll support this type of discretization in our staking UI.


Every hour, Aloe pools will try to transition from their current position [A] to the aggregate position from staking [B]. Take the assets involved to be X and Y. Position A will have some amount of X, and some amount of Y.

Regardless of the ratio of amounts, it is possible to adjust liquidity so that one bound (either upper or lower) matches Position B. If Position B’s mean is greater than Position A’s, then Aloe will make the upper bound match, and vice versa.

For the other bound, the ratio of amounts does matter. In order to get the right ratio, one asset (X or Y) will need to be sold to obtain the other (Y or X). This is done via a Dutch Auction.

A Dutch Auction works by offering market makers a gradually increasing discount on the asset being sold. This means that every Dutch Auction will result in some amount of loss for the pool. How do we constrain Dutch Auction losses and keep rebalancing profitable?

  1. Rebalances are subject to some max shift per hour; chosen at pool construction time. For example, a stablecoin pool may select a 0.5% max shift per hour, while USDC-ETH may have something like 5%.
  2. Rebalances are subject to a Rebalance Budget. The Dutch Auction discount will stop growing when potential losses exceed the Rebalance Budget. If that discount is insufficient to incentivize auction completion, the rebalance stalls until the budget grows. The budget itself is essentially a per-pool treasury derived from (a small portion of) swap fees. It’s size is also constrained to be some % of the pool’s liquidity — there’s no reason to have the budget grow indefinitely.


Let’s look at the USDC-ETH pool. Assume Aloe has $30M of liquidity. Position A has bounds (2000, 3000) and Position B has bounds (2050, 3050). This means stakers have predicted a 2% mean price increase and expect volatility to remain constant.

To rebalance from A to B, the pool should sell 1450030 USDC for 580 ETH. If the Dutch Auction executes with a discount of 1%, we’ll actually get 574 ETH. Once we have the ETH, we can fully transition to Position B.*

Now assume the stakers were right and the mean ETH price does indeed rise from 2500 to 2550. The value of Position A increases by 0.8529%, and the value of Position B increases by 0.8993%. Position B has grown 5% more than Position A, even before accounting for Position B’s additional swap fees. Under these conditions, we could’ve sustained a Dutch Auction discount of up to 3% and still been better off.

If, on the other hand, the stakers were wrong* and the mean ETH price doesn’t change, it would take approximately 30 hours to recuperate Dutch Auction losses (or fewer if trading volume is high).


Overall, we’re pleased with these results and believe the rebalancing system will be profitable for liquidity providers. Here we’ve provided just one rebalance iteration, but in our upcoming whitepaper we’ll walk you through a simulation of many iterations. This tells us the how precise stakers need to be, and how often they can be wrong without sacrificing pool health.

[i] As an additional incentive against malicious proposals, we may use Chainlink VRF to select a random subset of proposals that will be aggregated.

[ii] If the community wants Aloe pools to have multiple positions at once (forming a normal distribution, for example), we can add that later via a governance proposal

[iii] Technically, the 1% Dutch Auction loss means that the lower bound of Position B will be 2049.59, not the specified 2050.

[iv] We plan to make Aloe robust enough to handle the case where the stakers’ prediction is exactly opposite of reality.




Automated capital allocation for DeFi

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Chasing Crypto Criminals

Weight Gain for Bitcoin and Ethereum? Fat and Thin Protocols

How to Trade Bitcoin at Bitmex

AEX Breaks into Southeast Asia Market, Officially Launching Vietnamese Version

Bitcoin vs Beanie Babies — Why You Will Lose Either Way

QZKCoin with 24-hours trading


Cryptocurrency Investing Tips: When Bitcoin Drops

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aloe Labs

Aloe Labs

Automated capital allocation for DeFi

More from Medium

Announcing the V2 Prediction Game with BTC

$FRKT Staking is now a reality!

Roadmap Update and Investor Announcement

Why did GLDBase digitize gold?