xETH leverages the Curve stableswap pools through an AMO in order to stabilize the price, this combination makes it so the Curve pool acts as both the main exchange for xETH to trade in and also where the minting and redeeming of xETH takes place.
The AMO accomplishes this through rebalances of which there are two types:
When the skew of the pool is smaller than the rebalance down threshold a rebalance down can happen, the AMO mints xETH and single asset deposits it into the xETH/pxETH Curve pool.
This decreases the price of xETH, increases the amount of xETH in circulation and increases the LP balance of the AMO.
When the skew of the pool is larger than the rebalance up threshold a rebalance up can happen, the AMO single asset withdraws xETH/pxETH LP tokens into xETH, which is burnt.
This increases the price of xETH, decreases the amount of xETH in circulation and decreases the LP balance of the AMO.
Rebalance Defender Setup
The rebalance defender is a whitelist only role that allows the whitelisted address to call the rebalance function, it is given to an Open Zeppelin Defender bot to execute on rebalances whenever the skew deviates from the established thresholds.
The defender provides the AMO with the quote for the rebalancer, the AMO contract then calculates its own backup quote to compare with the defender’s, under normal circumstances the defender’s quote will be far more accurate and be the one used but in the unlikely event that the defender has been compromised the backup quote will kick in defending the AMO from a sandwich attack.
Additional security measures for the defender are:
A minimum of 1,800 blocks (8 hours approx) need to pass after a rebalance has been executed.
Both rebalance up and rebalance down have their own caps limiting the max amount of xETH or LP tokens that can be rebalanced in a single transaction.
Open Zeppelin Defender
Thanks to OZ defender the transactions never get sent to the public mempool.