crvUSD - Curve's StableCoin

crvUSD = Uniswap-V3 + MakerDAO

Uniswap-V3 concentrated liquidity & collateralised lending.

(credit to https://crvusd.0xreviews.xyz/)
(credit to https://crvusd.0xreviews.xyz/)

Abstract:

crvUSD provides an innovative way of stablecoin service that drastically reduces the loss during liquidation through the use of Lending-Liquidating AMM Algorithm (LLAMMA). LLAMMA spreads liquidity into bands and introduces “devaluation” of partial collateral when collateral price drops, and recovers the collateral when price bounces back; In a historical back-test, if the price of the collateral drops and then rebounds, the liquidation loss under LLAMMA was as little as 1% upon liquidation, if the collateral loan is spread across a range of 20%.
It also provides a permissionless arbitrage point of service where arbitrageur can compete without need of capital (through PegKeeper). With PegKeeper, it closes the arbitrage loop by bridging curvePool AMM with the new lendingAMM. Once crvUSD is released into production, it is expected veCRV would increase in utility as veCRV holder can decide the addition of collateral type and upper limit of crvUSD that collateral market can accommodate.

Context:

crvUSD is a Curve’s upcoming stablecoin. The code is published on GitHub and is still under active development.

Problems to Solve:

From the whitepaper, crvUSD is developed as a stablecoin with a more advanced and gentle liquidation mechanics.
In classic collateral-enabled stablecoin protocols, a position would be liquidated when the value of that collateral position drops below the loan value, plus certain buffer. This has the benefit of simplicity but create massive losses for the loan taker if liquidation happens.
For example, the liquidation penalty on Liquity is 9.09%, quite significant even though Liquity is already aggressive in lowing this buffer relative to other stablecoin protocols. This buffer is needed mainly to offset the volatility in the price of the underlying risky-asset collateral, as well as the delay in oracle price update(s) in the blockchain space.

How crvUSD solves this?

crvUSD reduces the liquidation penalty significantly, by providing an innovative liquidation mechanism, called LLAMMA. (yes a very lengthy name). Outlined in a historical back-test in the whitepaper, under LLAMMA, if the price hit liquidation threshold and then rebounded later, the liquidation loss would be as little as 1% upon liquidation, if the collateral loan is spread across a range of 20%.

LLAMMA works by creating “bands”, where collateral is deposited into a range of them. Similar to ticks in Uniswap-V3, each band have a non-linear price relationship to each other. Health factor of a position is then computed by calculating the effective collateral value based on user’s share on each of the band. As the price of collateral drops, the deposited collateral in the top of the band ranges would be swapped into crvUSD gradually (devaluation), while the health factor could remain positive (healthy). Liquidation would only happen if the health factor drops to negative with regards to the liquidation discount, then the entire position would be repaid with penalty; Since part of the collateral would be already devalued (without penalty) when liquidation happens, loss over the entire position would be reduced considerably relative to the traditional one-size liquidation.

ps: Self-liquidation without the penalty is possible: If the position drops into the liquidation threshold and no liquidator goes ahead to liquidate the position. The loan taker can call self-liquidation to close out the position without taking any penalty (alternatively, he can take the penalty to himself, essentially rewarding himself with his own money zeroing out any gain).

Architecture:

There are multiple components in the design based on the whitepaper and published code:

ControllerFactory:

  • Factory is eligible to deploy AMM markets and control versioning of all the contracts.

  • Factory can update the upper limit of crvUSD each collateral market can mint.

  • Factory would initialize the liquidation threshold, borrowing_discount (aka LTV), address of controller, MonetaryPolicy and admin fee for a particular market upon addMarket(). adminFee and LTV can be changed later in controller.

  • Factory is governed by an admin which likely to be holder of veCRV.



Controller:

  • Controller is the main entry point for users to interact with the AMM market. All user interaction for example create_loan, repay, liquidate etc, are called through the controller.

  • The controller is the admin of AMM.

  • Each controller would map to only 1 AMM.

  • Controller log the value of loan and collateral of each depositor.

  • Controller can update adminFee and LTV.

AMM

  • AMM is the core logic at which any swapping is calculated.

  • Except Exchange(); all other functions can only be called by Controller.

  • exchange() is the entry point to swap collateral to crvUSD or vice versa given the deposited price band is above the active band.

  • Once deployed, AMM for a market is immutable. However the deployed version for the next market in factory can be upgraded.

MonetaryPolicy (MP)

  • MP is a separate module defining the rate at which the loan would grow.

  • From the repo, there is a constantRate MP as well as a dynamicRate MP

  • MP is initialised upon creation of a market and can be updated by controller.

PegKeeper

  • PegKeeper is an actor that interacts with the AMM in crvUSD and the collateral curvePool (another AMM pool) when any misprice happens.

  • PegKeeper would offset the misprice by add_liquidity/remove_liquidity into curvePool.

  • Supposedly, pegKeeper would be allowed to mint uncollateralized stablecoin and deposit it to the stableswap pool single-sided in such a way that the final price after this is still no less than the pegged price minus some threshold.

  • The PegKeeper is allowed to withdraw (asymmetrically) and burn the stablecoin.

  • With above anyone can called the update() function to check for mis_price, without he/she having to provide the capital for arbitrage; if mis_price exists above the threshold then the caller would share a fraction of the arbitrage profit. (caller_share)

  • PegKeeper is added into MonetaryPolicy.

Example In Action

https://crvusd.0xreviews.xyz/
Oracle Price = 1000
Top 5 bands: 990/980.1/970.3/960.6/950.99

In this simulation, AMM price is assumed to be 1020.3, where there is no arbitrage and all collateral is still healthy in the top bands. active band is only 1, where only band 0 can be “devalued” (which is emptied by default).
If the price of AMM increases, top band could be devalued.

As you can see, if AMM price increases to 1040.80, then the collateral in tick1 would be swapped into crvUSD mostly.
If AMM price increases slightly to 1041.02, then active band can be updated to 2, and band 2 would be eligible for swapping now.

As you can see on tick1, collateral (y) is already swapped fully into crvUSD (x), whereas tick2/3/4/5 still have some collateral. The execution price would be calculated based on the invariant I = (f + x)(y + g), whereas x and y are balance of crvUSD and collateral in that band respectively.
The process continues when AMM price increases.

All top 5 ticks would be “devalued” when AMM price turns in 1128.18.

This is a position-agnostic, price-only simulation. If at any point the position drops below the health factor then the entire position would be liquidated (taken) by the liquidator, essentially withdrawing all user share from bands. This is where liquidation discount (penalty) would be introduced. This can be triggered by loan sizes due to interest accural, not necessarily by price action.

Impact:

crvUSD is a new and innovative way to create stablecoin with a much more gentle liquidation mechanism, by blending uniswap-V3-like concentrated liquidity with collateralized lending. It leverages on the success of Curve-V2 AMM to create a seamless arbitrage model that makes the lending market much more efficient. Once crvUSD gets released and proves itself to what it promises:

  1. veCRV increases in governance power
    Besides boosting yield and voting for gauges, veCRV can increase in utility by governing the type of collateral that can be added to mint crvUSD, as well as the upper limit.

  2. Bridging liquidity from lending market to AMM
    With crvUSD, liquidity in lending market can then be provided to AMM as well, increasing the liquidity provision in the bigger market. Vice versa, if price rebounds, then the price action would be bridged back to the lending market through pegkeeper, cushioning any subsequent liquidation. This would help reduce market volatility that is incentivised to trigger liquidation.

  3. Create a new wave of lending market research and protocols engineering
    LLAMMA is an elegant way of combining concentrated liquidity and stablecoin lending. This new codebase would be explored further once it is proven in the production environment. New protocols and aggregators that build on top of lending market as well as Curve would erupt and push the Defi boundary further.

Appendix:

Tl:dr Depositor Flow:

  • Permissioned factory model controls the type of collateral and upper limit crvUSD of each collateral can mint

  • Once a lending market is created, User create loans by depositing collateral into bands based on the latest oracle price.

  • During creation of a loan, the depositor send in collateral as well as specify the range of band that he/she would like for the deposit to spread across. This value can be ranged from 5 to 50.

  • There is an interest rate, increasing the size of loan per second. This can be static, or a dynamic variable as a function of total loaned amount.

  • User owns share of liquidity in bands upon depositing; If price of collateral stays above the price where deposit happens; the collateral would remain there and nothing would happen.

  • If price of collateral drops, active band hitting the band where the depositor put int money, the collateral in the top band would be converted to crvUSD by arbitrageur. This is called devaluation. Devaluation does not incur penalty to depositor.

  • Once a position suffers devaluation, it means the collateral within the devalued band would be swapped to crvUSD. If price recovers later, the crvUSD would be swapped back to collateral.

  • The the price of collateral continues to drop, the health factor of the position would hit negative to a point, where liquidation could happen and penalty is incurred.

  • Once health factor drops to negative, liquidation of an entire position would happen as an atomic operation. Liquidator would pay the entire debt and takes out the user_shares of depositor across all bands (both crvUSD and collateral).

  • Each band has an upper and lower price limit that has the relationship of (A-1) / A. During devaluation (collateral being swapped to crvUSD), the price within the band would moves within this narrow range as ratio of collateral decreases.

  • Therefore, liquidity in each band would smooth out prices between them, making execution price continuous even in a band.

Subscribe to GeekRunner
Receive the latest updates directly to your inbox.
Mint this entry as an NFT to add it to your collection.
Verification
This entry has been permanently stored onchain and signed by its creator.