TechFlow Logo
Login/ Sign up
ETH Gas
Gwei
Fear
gas
Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

2022.11.23
Share

TechFlow Selected TechFlow Selected

techFlow

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Hope the proposed mechanism can address the risks associated with liquidations for stablecoin and lending purposes.

2022.11.23 - 04:08:38
CurveLLAMMA
Hope the proposed mechanism can address the risks associated with liquidations for stablecoin and lending purposes.

Author: JamesX, iZUMi Research

This is a bilingual reference version of the Curve stablecoin design whitepaper, with added explanatory notes in Chinese and corrections to some spelling errors in the original. For reference and study purposes.

Overview

Several key concepts are central to this stablecoin design: the Lending-Liquidating AMM Algorithm (LLAMMA), PegKeeper (peg maintenance mechanism), and monetary policy. However, the core innovation lies in LLAMMA: replacing traditional over-collateralized loan liquidation processes with a specialized-purpose AMM.

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Figure 2: Dependence of losses on price movements relative to the liquidation threshold. Observation window is 3 days.

In this design, even if a user’s collateral experiences a price drop followed by a rebound—while remaining at or near the liquidation threshold—no significant loss occurs.

For example, simulations based on historical ETH/USD data since September 2017 show that if a CDP is left unattended for 3 days and the price drops 10% below the liquidation price during that period, only about 1% of the collateral is lost.

Continuous Liquidation / No-Liquidation AMM (LLAMMA)

The core idea behind the stablecoin design is the Lending-Liquidating AMM Algorithm (LLAMMA). The concept involves converting between collateral (e.g., ETH) and the stablecoin (here referred to as USD). When the collateral price is high, the user's deposit remains entirely in ETH; but as the price falls, it gradually converts into USD stablecoins. This differs significantly from traditional AMMs, where stablecoins like USD are placed on one side (top half of the curve) and volatile assets like ETH on the other (bottom half).

The following description does not constitute a fully self-consistent rigorous proof. Many aspects—especially the invariant—are derived heuristically from multiple considerations. A complete mathematical formulation may require further research, but the current description is considered sufficient for implementation in smart contracts.

This mechanism can only function with an external price oracle. In brief, if one constructs a typical AMM (e.g., with a bonding curve shaped like a hyperbola) and shifts its "center price" from lower to higher values, tokens will adiabatically convert from USD to ETH (or vice versa), while providing two-way liquidity throughout the process (see Figure 3). This is conceptually similar to “avoided crossing” (also known as Landau-Zener transition) in quantum physics—though purely analogical, as the actual mathematical description may differ significantly.

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

The range over which liquidity is concentrated is called a “band.” Within a constant oracle price band, there is liquidity ranging from pcd to pcu. We seek functions pcd(po) and pcu(po) that grow faster than linearly with po—i.e., their growth rate exceeds that of po (see Figure 4). Additionally, define prices p↓ and p↑ such that p↓(po)=po and p↑(po)=po, representing the bottom and top ends of the band in the adiabatic limit (e.g., when p=po).

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Figure 3: Behavior of an “AMM with external price source.” The external price pcenter determines the center around which liquidity is formed. The AMM supports concentrated liquidity between prices pcd and pcu, where pcd < pcenter < pcu. When the current price p moves outside the [pcd, pcu] range, the AMM becomes fully converted either into stablecoins (at pcu) or into collateral (at pcd). When pcd ≤ p ≤ pcu, the AMM price equals the current market price p.

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Figure 4: Desired AMM structure. We aim to construct an AMM where pcd and pcu are functions of po that grow super-linearly with po. In such a setup, when ETH is expensive, the AMM fully converts to ETH; when ETH is cheap, it fully converts to USD.

We begin similarly to Uniswap V3, using multiple bands with “virtual balances” preserving the hyperbolic shape of the bonding curve. Let x be the amount of USD and y the amount of ETH. Then the “enhanced” constant-product invariant becomes:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

We can also write x₀ ≡ x + f and y₀ ≡ y + g so that the invariant takes the familiar form I = x₀y₀. However, f and g are not constant—they vary with changes in the external oracle price po (and so does the invariant I, meaning it's only invariant when po is fixed). At any given po, f and g remain constant across a single band. As defined earlier, let p↑ denote the upper price bound of the band and p↓ the lower. Our definition of A—a measure of liquidity concentration—is as follows:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

The desired property we seek is: higher oracle prices po should result in higher internal prices for the same reserves, causing the current market price (on average tracking po) to fall below this level, thereby pushing trades toward full ETH exposure (and vice versa in the opposite direction). Many functional forms could satisfy this, but we need one satisfying:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Here, y₀ is a quantity related to po indicating the current band’s deposit measured in ETH. It is defined such that when the current price p, p↑, and po all coincide, then y = y₀ and x = 0 (see the point at po = p↑ in Figure 4). Substituting y accordingly:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Since price equals dx₀/dy₀, for a constant product invariant this gives:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

One can substitute x=0 or y=0 to verify consistency under conditions po=p↑ or po=p↓.

Typically, for a given band, we know p↑, hence p↓, po, constant A, and current deposits x and y. To compute everything else, we must determine y₀. This can be found by solving a quadratic equation derived from the invariant:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

This leads to a quadratic equation in terms of y₀:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

In the smart contract, this quadratic equation is solved within the get_y0 function.

When the oracle price po remains constant, the AMM operates normally—selling ETH when price rises and buying ETH when price falls. By substituting x=0 into the invariant equation for the lower boundary price pcd, or y=0 for the upper boundary price pcu, we derive the AMM price under current values of po and p↑:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

Another important practical question arises: if price changes slowly enough that the oracle price po can “adiabatically” follow the movement within a band, how much ETH (denoted y↑) would ultimately remain in the band if the price increases, or how much USD (x↓) if the price decreases—given initial x and y and starting from p=po? While not immediately solvable analytically, numerical computations yield a surprisingly simple answer:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

These results will be used in assessing lending safety and potential AMM losses.

Now we have a description for a single band. We divide the entire price space into contiguous bands, where the lower price p↓ of one band meets the upper price p↑ of the next. Setting a base price pbase and a band index n:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

For any band, it can be shown that solutions to Equations 7 and 5 lead to:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

This confirms that there are no gaps between adjacent bands.

Trades preserve the invariant in Equation 1, yet when the oracle price po changes, the internal price within the AMM shifts: when po decreases, the internal price increases, and vice versa—with a cubic dependence evident from Equation 8.

LLAMMA vs Stablecoin

A stablecoin here functions as a CDP where users borrow stablecoins against volatile collateral (cryptocurrencies like ETH). The collateral is deposited into a price range (band) within LLAMMA. If the collateral price declines gradually, ETH is automatically converted into sufficient stablecoins to cover the loan repayment (via self-liquidation, external liquidation if collateral ratio approaches danger levels, or simply waiting for price recovery without closing).

When a user deposits collateral and borrows a stablecoin, the LLAMMA smart contract determines the corresponding band. As the collateral price fluctuates, conversion into stablecoins begins. When the system goes “underwater,” the user already holds enough USD to repay the debt. The available stablecoin amount can be calculated via a public get_x_down method. If this value approaches the liquidation threshold too closely, external liquidators may intervene (though typically unnecessary unless price stays low for days or weeks; never required if price recovers quickly). When far above “liquidation,” a healthy position returns the ratio of get_x_down to debt plus increased collateral value.

When interest is charged on the stablecoin, this must be reflected in the AMM. This is achieved by shifting all price grids upward proportionally to the interest rate r, implemented via a base price multiplier. Thus, as long as the interest rate is positive, the multiplier increases over time.

When computing get_x_down or get_y_up, we first determine the quantities x* and y* of stablecoin and collateral that would exist if the current price moved to the oracle price po. Then, we calculate how much stablecoin or collateral would result if po were to adiabatically shift to the lowest price in the lowest band or highest price in the highest band, respectively. This provides a robust metric for expected stablecoin proceeds, independent of transient market prices—an important defense against sandwich attacks.

Note that LLAMMA uses po defined as the ETH/USD price as its input. Our stablecoin may trade below (ps < 1) or above (ps > 1) its peg. If ps < 1, then the effective price within LLAMMA becomes p > po.

Under the adiabatic approximation, p = po / ps, meaning all collateral ↔ stablecoin conversions occur at a higher oracle price—as if the oracle price were lower and equal to:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

At this adjusted price, the quantity of stablecoins obtained upon conversion is scaled up by a factor of 1/ps (when ps < 1).

Persistently having ps > 1 is undesirable; hence we employ a stabilizer mechanism (discussed next).

Automatic Stabilizer and Monetary Policy

When ps > 1 (e.g., due to increased demand for the stablecoin), anchor reserves are created through asymmetric deposits into the stableswap Curve pool—between the stablecoin and redeemable reference coins or LP tokens. Once ps > 1, the PegKeeper contract is permitted to mint uncollateralized stablecoins and deposit them unilaterally into the stableswap pool, ensuring the final price does not fall below 1. Conversely, when ps < 1, PegKeeper may withdraw (asymmetrically) and burn stablecoins.

These actions cause rapid depreciation when ps > 1 and appreciation when ps < 1, because asymmetric deposits and withdrawals shift the price. Even though this portion of “minting” is uncollateralized, the stablecoin appears implicitly backed by liquidity in the stableswap pool. Overall, the minting/burning cycle proves profitable while enhancing stability.

Let dst represent the quantity of stablecoins minted by the stabilizer (debt), and fdx() be the function calculating the redeemable USD needed to buy stablecoins via the stableswap AMM’s get_dx. To prevent the “reserve” from growing excessively large, we implement a “slow” stabilization mechanism by adjusting the borrowing rate r:

Curve Stablecoin Design Whitepaper: Continuous Liquidation / No-Liquidation AMM

where h is the change in ps, and r adjusts twice as fast (higher ps leads to lower r). The stabilizer debt dst will balance at different levels depending on how far ps deviates from 1. Therefore, instead of manual tuning, we can reduce r₀ when dst/supply exceeds a target threshold (e.g., 5%), incentivizing borrowers to take loans and sell stablecoins (lowering price and forcing system to burn dst). Conversely, increase r₀ when dst/supply is low, encouraging loan repayments and pushing ps upward (forcing system to accumulate more dst and stabilizer deposits).

Conclusion

We hope the proposed mechanism effectively mitigates the risks associated with liquidations in stablecoin and lending systems.

Furthermore, the stabilizer and automatic monetary policy mechanisms can help maintain price peg stability without requiring an oversized PSM (Peg Stability Module).

Join TechFlow official community to stay tuned

Add to Favorites
Share to Social Media

Related Articles

2025.04.11

IRS DeFi Broker Rule Repealed, CRV Surges 54% in One Week

CRV's rebound comes amid whale position cost restructuring, derivatives market short covering, and an expanding divergence between protocol revenue and TVL.

IRS DeFi Broker Rule Repealed, CRV Surges 54% in One Week
2024.07.02

What motivates crypto heavyweights to "bail out" Curve?

It turns out the Ve model's top-heavy effect has led to poor liquidity.

What motivates crypto heavyweights to "bail out" Curve?
2023.08.23

Shima Capital CTO's Reflection on Curve: Why We Need Runtime Protection and Aspect?

How to provide runtime protection?

Shima Capital CTO's Reflection on Curve: Why We Need Runtime Protection and Aspect?
2023.08.04

Bitget Research Weekly Highlights: Curve Stablecoin Pool Hacked, HashKey Approved as Hong Kong's First Retail-Facing Trading Platform

Focusing on on-chain data, weekly news roundup.

Bitget Research Weekly Highlights: Curve Stablecoin Pool Hacked, HashKey Approved as Hong Kong's First Retail-Facing Trading Platform
2023.08.04

Reflecting on the Curve Incident: How DeFi Recovered from the Brink of Collapse?

Those who say "DeFi is dead" are wrong—in fact, it's stronger than ever.

Reflecting on the Curve Incident: How DeFi Recovered from the Brink of Collapse?
2023.08.02

Is There No Way Out in the Face of the Curve Crisis? Response Strategies from the Perspective of DeFi Mining

How to prevent similar potential risks during daily DeFi mining?

Is There No Way Out in the Face of the Curve Crisis? Response Strategies from the Perspective of DeFi Mining
2023.07.31

DeFi Dead? Chainlink Saves Curve Founder's Australian Mansion?

You say DeFi is gone, which isn't sad enough; what's sadder is if blockchain itself no longer exists.

DeFi Dead? Chainlink Saves Curve Founder's Australian Mansion?
2023.06.09

"Embezzling" VC's tokens to buy mansions? Curve founder sued by ParaFi and three other major crypto VCs

Three prominent crypto VCs—ParaFi, Framework Ventures, and 1kx—have sued Curve founder Michael Egorov for business fraud in San Francisco.

"Embezzling" VC's tokens to buy mansions? Curve founder sued by ParaFi and three other major crypto VCs
2023.05.08

Analyzing May's Crypto Market Hot Narratives: Meme Season, Sui, and Curve Upgrade

The meme-driven market resembles the 2019 altcoin season pattern: a few people profit, some hop on and get rekt, while most remain spectators.

Analyzing May's Crypto Market Hot Narratives: Meme Season, Sui, and Curve Upgrade
2022.12.22

Curve Liquidity "Wrapping" Battle Overview: Could Yearn Emerge as the Ultimate Winner?

For holders, locking CRV for 4 years is not a particularly attractive option.

Curve Liquidity "Wrapping" Battle Overview: Could Yearn Emerge as the Ultimate Winner?
TechFlow Logo

Navigating Web3 tides with focused insights

Contribute An Articleemail
Media Requestsmsg

Risk Disclosure: This website's content is not investment advice and offers no trading guidance or related services. Per regulations from the PBOC and other authorities, users must be aware of virtual currency risks. Contact us / [email protected] ICP License: 琼ICP备2022009338号