Dual Stability Mechanism: Minting and Redeeming USC
How is Stability Maintained? How Can Users Mint and Redeem USC?
Introduction to the Dual Stability Mechanism
The dual stability mechanism is designed to maintain the price of USC stable at 1 USD. To understand the mechanism behind this contract, users must be familiar with some essential calculations on arbitrage data.

Arbitrage Data
Arbitrage data includes all the necessary information needed in the arbitrage functions to identify the current arbitrage opportunity and execute transactions accordingly. Five data variables exist: isPriceAboveTarget, isExcessOfReserves, reserveDiff, delta, and discount.
PriceAboveTarget identifies if the price of USC is above or below 1 USD:
isExcessOfReserves verifies the solvency state of the protocol by checking if the LSTs and ETH reserves to back USC are in excess or in deficit
reserveDiff is a measure of the excess or deficit gap between reserves and circulating USC supply. reserveDiff defines the discount when the price of USC is at 1 USD and the reserves are in deficit or excess.
delta is a number that indicates the amount of ETH or USC that must be added to the USC/ETH Uniswap pool to keep it balanced (in USD terms) and re-peg the price at 1 USD
Depending on the price of USC with respect to the target price, the function _calculateDelta is called with different inputs. In all cases, it returns the root solution to a quadratic equation (i.e., delta).
When the price of USC is above peg ( _arbitrageAbovePegExcessOfReserves, _arbitrageAbovePegDeficitOfReserves), the arbitrage function calls _calculateDeltaUSC, which returns the delta in USC that must be added in the pool to return its price at 1 USD.
In this case, the quadratic equation is of the following form:

Note: , , ,
Similarly, when the price of USC is below peg ( _arbitrageBelowPegExcessOfReserves, _arbitrageBelowPegDeficitOfReserves), the arbitrage function calls _calculateDeltaETH, which returns the delta in ETH that must be added to increase the price at 1 USD.
In this scenario, the quadratic equation is as follows:

Note: , , ,
In the background, the function calculateDelta performs all the necessary steps to get a real (positive) root for delta .
f = (1 - pool_fee) = 0.997on 18 decimals, in square root formulaa = fparameter
bin square root formula,b = rIn * (1+f), on 18 decimalsparameter
cin square root formula,c = rIn^2 - (rIn * rOut * priceOut) / priceIn.
To learn more about delta calculation: https://hackmd.io/@6jzKo0C7QCGkNGHQ9oU28g/ryQdB_5M6
discount is a number between zero and one which measures the difference between reserves and USC supply. This used to define an additional arbitrage opportunity when the price of USC is at approximately 1 USD.
Arbitrage Functions
Users can call arbitrage functions to make profits and stabilise the price of USC at 1 USD. Different arbitrage opportunities can arise depending on the price of USC and the solvency state. There exist six arbitrage opportunities:
_arbitrageAbovePegExcessOfReserves
uscPrice ≥ USC_TARGET_PRICE
reservesValue > UscTotalSupplyValue
_arbitrageAbovePegDeficitOfReserves
uscPrice ≥ USC_TARGET_PRICE
reservesValue ≤ UscTotalSupplyValue
_arbitrageBelowPegExcessOfReserves
uscPrice < USC_TARGET_PRICE
reservesValue > UscTotalSupplyValue
_arbitrageBelowPegDeficitOfReserves
uscPrice < USC_TARGET_PRICE
reservesValue ≤ UscTotalSupplyValue
arbitrageAtPegExcessOfReserves
discount != 0
reservesValue > UscTotalSupplyValue
_arbitrageAtPegDeficitOfReserves
discount != 0
reservesValue ≤ UscTotalSupplyValue
All arbitrage functions return the rewardValue in USD.
Rewards to Function Caller
The function caller is rewarded with the arbitrage profits in all arbitrage functions. The arbitrage profits arise because smart contracts always price USC at 1 USD.
Rewards for _arbitrageAbovePegExcessOfReserves and _arbitrageAbovePegDeficitOfReserves are distributed in ETH:
Rewards for _arbitrageBelowPegExcessOfReserves and _arbitrageBelowPegDeficitOfReserves are distributed in USC:
Finally, since the ending currency for arbitrage _arbitrageAtPegExcessOfReserves and _arbitrageAtPegDeficitOfReserves is CHI, the arbitrage rewards are given with the governance token.
For _arbitrageAtPegExcessOfReserves, chiArbitrageReward is discount * chiReceived from the ETH - CHI swap. While, in _arbitrageAtPegDeficitOfReserves, chiArbitrageReward is discount * chiToCoverEth.
Minting and Redeeming USC
Any user can mint USC by depositing ETH, stETH or WETH and calling the mint function . Similarly, any user can burn USC and receive the equivalent dollar value in WETH from the protocol's reserves.
Note that when minting (redeeming) USC, a protocol fee of 0.3% is deducted from the minted (redeemed) amount.
It is important to note that USC can only be minted and burnt when the price of USC and the collateral ratio are within a predefined range (≈ $1 price for USC, ≈ CR 100%) .
When USC is minted with ETH (WETH), the ethAmount - fee ( wethAmount - fee) is sent to the reserveHolder and then staked into Lido via a rebalancing function.
When USC is burnt, the ethAmountToRedeem is set to the USC value less any fee, which is then deducted from the protocol's reserves and given to the redeemer in the form of WETH.
Last updated