Sách trắng thiết kế Curve Stablecoin (phiên bản tham khảo tiếng Trung và tiếng Anh)
tiêu đề cấp đầu tiênCurve Finance
Tổng hợp gốc:JamesX,iZUMi Research
Overview
The design of the stablecoin has few concepts: lending-liquidating amm algorithm (LLAMMA), PegKeeper, Monetary Policy are the most important ones. But the main idea is in LLAMMA: replacing liquidations with a special-purpose AMM.
Mô tả hình ảnh


Figure 2 : Dependence of the loss on the price shift relative to the liquidation threshold. Time window for the observation is 3 days
chữ
In this design, if someone borrows against collateral, even at liquidation threshold, and the price of collateral dips and bounces - no significant loss happen. For example, according to simulations using historic data for ETH/USD since Sep 2017 , if one leaves the CDP unattended for 3 days and during this time the price drop of 10% below the liquidation threshold happened - only 1% of collateral gets lost.
tiêu đề phụ
AMM for continuous liquidation/deliquidation (LLAMMA)
Thanh lý liên tục/AMM không thanh lý (LLAMMA)
The core idea of the stablecoin design is Lending-Liquidating AMM Algorithm. The idea is that it converts between collateral (for example, ETH) and the stablecoin (let’s call it USD here). If the price of collateral is high - a user has deposits all in ETH, but as it goes lower, it converts to USD. This is very different from traditional AMM designs where one has USD on top and ETH on the bottom instead.
Ý tưởng cốt lõi của thiết kế stablecoin là thuật toán AMM Lending-Liquidating. Ý tưởng là nó chuyển đổi giữa tài sản thế chấp (ví dụ: ETH) và một stablecoin (ở đây hãy gọi nó là USD). Nếu giá của tài sản thế chấp cao - tất cả tiền gửi của người dùng đều bằng ETH, nhưng khi giá thấp hơn, nó sẽ được chuyển đổi thành USD stablecoin. Điều này rất khác so với thiết kế AMM truyền thống.Thiết kế AMM truyền thống là đặt USD stablecoin ở trên cùng (nửa trên của đường cong AMM) và ETH ở dưới cùng (nửa dưới của đường cong AMM).
The below description doesn’t serve as fully self-consistent rigorous proofs. A lot of that (especially the invariant) are obtained from dimensional considerations. More research might be required to have a full mathematical description, however the below is believed to be enough to implement in practice.
Mô tả sau đây không đóng vai trò là bằng chứng nghiêm ngặt hoàn toàn tự nhất quán. Nhiều thứ (đặc biệt là những thứ bất biến) được xem xét từ nhiều khía cạnh khác nhau. Để có một mô tả toán học hoàn chỉnh, có thể cần nhiều nghiên cứu hơn, tuy nhiên mô tả dưới đây được coi là đủ để hỗ trợ việc triển khai trong các hợp đồng thông minh.
This is only possible with an external price oracle. In a nutshell, if one makes a typical AMM (for example with a bonding curve being a piece of hyperbola) and ramps its “center price” from (for example) down to up, the tokens will adiabatically convert from (for example) USD to ETH while proving liquidity in both ways on the way (Fig. 3 ). It is somewhat similar to avoided crossing (also called Landau-Zener transition) in quantum physics (though only as an idea: mathematical description of the process could be very different). The range where the liquidity is concentrated is called band here, at the constant po band has liquidity from pcd to pcu. We seek for pcd(po) and pcu(po) being functions of po only, functions being more steep than linear and, hence, growing faster than po(Fig. 4 ). In addition, let’s defifine prices p↓and p↑ being prices where p↓(po) = po, and p↑(po) = po, defining ends of bands in adiabatic limit (e.g. p = po).
Điều này chỉ có thể thực hiện được thông qua nguồn cấp dữ liệu giá từ các nhà tiên tri bên ngoài. Nói tóm lại, nếu một người lấy một AMM điển hình (ví dụ: đường cong liên kết là một đoạn hypebol) và đặt"giá trung tâm"Để chuyển từ (giả sử) xuống lên, mã thông báo sẽ chuyển đổi "một cách đáng tin cậy" từ (giả sử) USD sang ETH, đồng thời cung cấp thanh khoản theo cả hai cách trong quy trình (Hình 3). Điều này hơi giống với việc "tránh giao cắt" (còn được gọi là chuyển tiếp Landau-Zener) trong vật lý lượng tử (mặc dù chỉ là một khái niệm: mô tả toán học của quá trình này có thể rất khác).

Mô tả hình ảnh
Figure 3 : Behavior of an “AMM with an external price source”. External price pcenter determines a price around which liquidity is formed. AMM supports liquidity concentrated from prices pcd to pcu, pcd < pcenter < pcu. When current price p is out of range between pcd and pcu, AMM is either fully in stablecoin (when at pcu) or fully in collateral (when at pcd). When pcd ≤ p ≤ pcu, AMM price is equal to the current price p.
Figure 4 : AMM which we search for. We seek to construct an AMM where pcd and pcu are such functions of po that when po grows, they grow even faster. In this case, this AMM will be all in ETH when ETH is expensive, and all in USD when ETH is cheap.
We start from a number of bands where, similarly to Uniswap 3 , hyperbolic shape of the bonding curve is preserved by adding virtual balances. Let say, the amount of USD is x, and the amount of ETH is y, therefore the “amplifified” constant-product invariant would be:
Chúng tôi bắt đầu với một số dải, tương tự như Uniswap 3, bằng cách thêm "số dư ảo", giữ nguyên hình dạng hyperbol của đường cong liên kết. Giả sử số lượng USD là x và số lượng ETH là y, vì vậy"nâng cao"Hằng số - Sản phẩm bất biến sẽ là:

We also can denote x 0 ≡ x + f and y 0 ≡ y + g so that the invariant can be written as a familiar I = x 0 y 0. However, f and g do not stay constant: they change with the external price oracle (and so does the invariant I, so it is only the invariant while the oracle price po is unchanged). At a given po, f and g are constant across the band. As mentioned before, we denote p↑ as the top price of the band and p↓as the bottom price of the band. We defifine A (a measure of concentration of liquidity) in such a way that:
Chúng ta cũng có thể biểu diễn x 0 ≡x+f và y 0 ≡y+g, sao cho bất biến có thể được viết dưới dạng quen thuộc I=x 0 y 0 . Tuy nhiên, f và g không phải là hằng số: chúng thay đổi khi giá tiên tri bên ngoài thay đổi (I cũng vậy, vì vậy nó chỉ bất biến khi giá tiên tri po không đổi). Tại một po nhất định, f và g không đổi trên toàn dải. Như trước đây, chúng tôi biểu thị p↑ là giá cao nhất của dải và p↓ là giá dưới cùng của dải. Định nghĩa của chúng tôi về A (thước đo mức độ tập trung thanh khoản) như sau:

The property we are looking for is such that higher price po should lead to even higher price at the same balances, so that the current market price (which will, on average, follow po) is lower than that, and the band will trade towards being all in ETH (and the opposite is also true for the other direction). It is possible to find many ways to satisfy that but we need one:
Tài sản mà chúng tôi đang tìm kiếm là: giá po cao hơn sẽ dẫn đến giá cao hơn cho cùng một số dư, vì vậy giá thị trường hiện tại (trung bình, sẽ theo po) thấp hơn giá này và biên độ sẽ hướng tới Tất cả các giao dịch trong hướng của ETH (và cả hướng khác nữa). Nhiều cách có thể được tìm thấy để thỏa mãn, nhưng chúng ta cần cách này:

where y 0 is a p 0 -dependent measure of deposits in the current band, denominated in ETH, defifined in such a way that when current price p, p↑ and po are equal to each other, then y = y 0 and x = 0 (see the point at po = p↑ on Fig. 4 ). Then if we substitute y at that moment:
Trong số đó, y 0 là một chỉ báo liên quan đến p 0 để đo lượng tiền gửi ban nhạc hiện tại và nó bằng ETH. Định nghĩa của nó là: khi giá hiện tại p, p↑ và po bằng nhau thì y=y 0 , x= 0 (xem Điểm của po=p↑ trong Hình 4). Vì vậy, nếu chúng ta thay thế y tại thời điểm đó:

Price is equal to dx 0 /dy 0 which then for a constant-product invariant is:
giá bằng dx 0 /dy 0 , thì đối với một tích không đổi bất biến, nó là:

One can substitute situations where po = p↑ or po = p↓ with x = 0 or y = 0 correspndingly to verify that the above formulas are self-consistent.
Chúng ta có thể sử dụng x= 0 hoặc y= 0 để thay thế po=p↑ hoặc po=p↓ để xác minh rằng công thức trên là tự hợp.
Typically for a band, we know p↑ and, hence, p↓, po, constant A, and also x and y (current deposits in the band). To calculate everything, we need to find yo. It can be found by solving the quadratic equation for the invariant:
Thông thường đối với một dải, chúng ta biết p↑ và do đó p↓, po, hằng số A, cũng như x và y (tiền gửi hiện tại trong dải). Để tính phần còn lại, chúng ta cần tìm yo. Nó có thể được tìm thấy bằng cách giải phương trình bậc hai cho các bất biến:

which turns into the quadratic equation against yo:
Điều này trở thành một phương trình bậc hai cho yo:

In the smart contract, we solve this quadratic equation in get_y 0 function.
Trong hợp đồng thông minh, chúng tôi giải phương trình bậc hai này trong hàm get_y 0.
While oracle price po stays constant, the AMM works in a normal way, e.g. sells ETH when going up / buys ETH when going down. By simply substituting x = 0 for the “current down” price pcd or y = 0 for the “current up” price pcu values into the equation of the invariant respectively, it is possible to show that AMM prices at the current value of po and the current value of p↑ are:
Với giá oracle po không đổi, AMM hoạt động theo cách bình thường, ví dụ: bán ETH khi nó tăng / mua ETH khi nó giảm. Chỉ cần thay x= 0 bằng"giảm hiện tại"Giá của pcd hoặc y= 0 được thay thế bằng"tăng hiện tại"Thay thế giá trị pcu của giá p vào phương trình bất biến tương ứng, có thể chỉ ra rằng giá AMM dưới giá trị hiện tại của po và giá trị hiện tại của p↑ là:

Another practically important question is: if price changes up or down so slowly that the oracle price po is fully capable to follow it adiabatically, what amount y↑ of ETH (if the price goes up) or x↓ of USD (if the price goes down) will the band end up with, given current values x and y and that we start also at p = po. While it’s not an immediately trivial mathematical problem to solve, numeric computations showed a pretty simple answer:
Một câu hỏi thực tế quan trọng khác: nếu giá thay đổi chậm đến mức giá tiên tri po hoàn toàn có thể theo nó "một cách đáng tin cậy" (trong một dải), thì hãy cho các giá trị hiện tại x và y, và chúng ta cũng bắt đầu từ Khi p=po bắt đầu, bao nhiêu y↑ ETH (nếu giá tăng) hoặc x↓ USD (nếu giá giảm) thì cuối cùng dải này sẽ nhận được. Mặc dù đây không phải là một vấn đề toán học có thể giải quyết ngay lập tức, nhưng các phép tính số cho thấy một câu trả lời khá đơn giản:

We will use these results when evaluating safety of the loan as well as the potential losses of the AMM.
Chúng tôi sẽ sử dụng những kết quả này khi đánh giá mức độ an toàn của việc cho vay và khả năng mất AMM.
Now we have a description of one band. We split all the price space into bands which touch each other with prices p↓ and p↑ so that if we set a base price pbase and have a band number n:
Bây giờ chúng ta có một mô tả về một ban nhạc. Chúng tôi chia tất cả không gian giá thành các dải có giá p↓ và p↑ chạm vào nhau, vì vậy nếu chúng tôi đặt giá cơ sở pbase với số dải n:

It is possible to prove that the solution of Eq. 7 and Eq. 5 for any band gives:
Đối với bất kỳ dải nào, có thể chỉ ra rằng có thể thu được các nghiệm của Phương trình 7 và Phương trình 5:

which shows that there are no gaps between the bands.
Điều này cho thấy rằng không có khoảng cách giữa các dải.
Trades occur while preserving the invariant from Eq. 1 , however the current price inside the AMM shifts when the price po: it goes up when po goes down and vice versa cubically, as can be seen from Eq. 8.
tiêu đề cấp đầu tiên
LLAMMA vs Stablecoin
Stablecoin is a CDP where one borrows stablecoin against a volatile collateral (cryptocurrency, for example, against ETH). The collateral is loaded into LLAMMA in such a price range (such bands) that if price of collateral goes down relatively slowly, the ETH gets converted into enough stablecoin to cover closing the CDP (which can happen via a self-liquidation, or via an external liquidation if the coverage is too close to dangerous limits, or not close at all while waiting for the price bounce).
Stablecoin là một loại CDP mà mọi người vay bằng tài sản thế chấp dễ bay hơi (một loại tiền điện tử như ETH). Tài sản thế chấp được tải vào phạm vi giá của LLAMMA (một dải như vậy) và nếu giá của tài sản thế chấp giảm tương đối chậm, ETH sẽ được chuyển đổi thành đủ stablecoin để trang trải cho việc đóng CDP (điều này có thể xảy ra thông qua tự thanh lý hoặc thông qua thanh lý bên ngoài, Nếu lãi suất thế chấp quá gần với giới hạn nguy hiểm, hoặc hoàn toàn không đóng cửa, trong khi chờ giá tăng trở lại).
When a user deposits collateral and borrows a stablecoin, the LLAMMA smart contract calculates the bands where to locate the collateral. When the price of the collateral changes, it starts getting converted to the stablecoin. When the system is “underwater”, user already has enough USD to cover the loan. The amount of stablecoins which can be obtained can be calculated using a public get_x_down method. If it gives values too close to the liquidation thresholds - an external liquidator can be involved (typically shouldn’t happen within a few days or even weeks after the collateral price went down and sideways, or even will not happen ever if collateral price never goes up or goes back up relatively quickly). A health method returns a ratio of get_x_down to debt plus the value increase in collateral when the price is well above “liquidation”.
Khi người dùng gửi tài sản thế chấp và vay một stablecoin, hợp đồng thông minh LLAMMA sẽ tính toán tài sản thế chấp nằm trong dải nào. Khi giá của tài sản thế chấp thay đổi, nó bắt đầu được chuyển đổi thành một stablecoin. Khi hệ thống ở trong"dưới nước", người dùng đã có đủ USD để thanh toán khoản vay. Số lượng stablecoin có thể thu được có thể được tính toán thông qua phương thức get_x_down công khai. Nếu nó đưa ra một giá trị quá gần với ngưỡng thanh lý - những người thanh lý bên ngoài có thể tham gia (điều này thường không xảy ra trong vài ngày hoặc thậm chí vài tuần sau khi giá tài sản thế chấp giảm và đi ngang, ngay cả khi giá tài sản thế chấp không bao giờ tăng hoặc tương đối nhanh hơn đón, nó sẽ không bao giờ xảy ra). khi giá cao hơn rất nhiều"để thanh lý", một phương pháp lành mạnh sẽ trả về tỷ lệ get_x_down trên nợ, cộng với mức tăng giá trị của tài sản thế chấp.
When a stablecoin charges interest, this should be reflected in the AMM, too. This is done by adjusting all the grid of prices. So, when a stablecoin charges interest rate r, all the grid of prices in the AMM shifts upwards with the same rate r which is done via a base_price multiplier. So, the multiplier goes up over time as long as the charged rate is positive.
Khi một stablecoin tính lãi, điều này sẽ được phản ánh trong AMM. Nó cũng phải được phản ánh. Điều này đạt được bằng cách điều chỉnh tất cả các lưới cho giá cả. Vì vậy, khi một stablecoin tính lãi suất r, tất cả giá trong AMM sẽ tăng lên với cùng mức lãi suất r và điều này được thực hiện thông qua hệ số nhân giá cơ sở. Vì vậy, miễn là tỷ lệ được tính là dương, hệ số nhân sẽ tăng lên theo thời gian.
When we calculate get_x_down or get_y_up, we are first looking for the amounts of stablecoin and collateral x∗ and y∗ if current price moves to the current price po. Then we look at how much stablecoin or collateral we get if po adiabatically changes to either the lowest price of the lowest band, or the highest price of the highest band respectively. This way, we can get a measure of how much stablecoin we will which is not dependent on the current instantaneous price, which is important for sandwich attack resistance.
Khi chúng tôi tính get_x_down hoặc get_y_up, điều đầu tiên chúng tôi tìm kiếm là số lượng stablecoin và tài sản thế chấp x∗ và y∗ nếu giá hiện tại chuyển sang giá hiện tại po. Sau đó, chúng tôi thấy, nếu po thay đổi đoạn nhiệt thành giá thấp nhất trong phạm vi thấp nhất hoặc giá cao nhất trong phạm vi cao nhất, thì chúng tôi nhận được bao nhiêu stablecoin hoặc tài sản thế chấp tương ứng. Bằng cách này, chúng tôi có thể đo lường số lượng stablecoin mà chúng tôi sẽ nhận được, điều này không phụ thuộc vào giá tức thời hiện tại, điều này rất quan trọng đối với khả năng chống lại các cuộc tấn công tầng lửng. **
**
It is important to point out that the LLAMMA uses po defined as ETH/USD price as a price source, and our stablecoin could be traded under the peg (ps < 1 ) or over peg (ps > 1 ). If ps < 1 , then price in the LLAMMA is p > po.
Cần chỉ ra rằng LLAMMA sử dụng po được xác định là giá của ETH/USD làm nguồn giá và stablecoin của chúng tôi có thể được giao dịch dưới mức chốt (ps<1) hoặc trên mức chốt (ps>1). nếu ps<1 , thì giá trong LLAMMA là p>po.
In adiabatic approximation, p = po/ps, and all the collateral<>stablecoin conversion would happen at a higher oracle price / as if oracle price was lower and equal to:
Trong phép tính gần đúng đoạn nhiệt, p=po/ps, tất cả tài sản thế chấp<>Chuyển đổi Stablecoin sẽ diễn ra ở mức giá tiên tri cao hơn / như thể giá tiên tri thấp hơn và bằng:

At this price, the amount of stablecoins obtained at conversion is higher by factor of 1/ps (if ps < 1 ) .
Ở mức giá này, số lượng tiền ổn định thu được khi chuyển đổi cao hơn theo hệ số 1/ps (nếu ps<1 )。
It is less desirable to have ps > 1 for prolonged times, and for that we will use the stabilizer (see next)
Ổn định tự động và chính sách tiền tệ
Automatic Stabilizer and Monetary Policy
Ổn định tự động và chính sách tiền tệ
When ps > 1 (for example, because of the increased demand for stablecoin), there is peg-keeping reserve formed by an asymmetric deposit into a stableswap Curve pool between the stablecoin and a redeemable reference coin or LP token. Once ps > 1 , the PegKeeper contract is allowed to mint uncollateralized stablecoin and (only!) deposit it to the stableswap pool single-sided in such a way that the final price after this is still no less than 1. When ps < 1 , the PegKeeper is allowed to withdraw (asymmetrically) and burn the stablecoin.
Khi ps > 1 (ví dụ: do nhu cầu về stablecoin tăng lên), sẽ có các khoản dự trữ cố định được hình thành bởi các khoản tiền gửi không đối xứng giữa stablecoin và đồng tiền tham chiếu có thể quy đổi hoặc mã thông báo LP vào nhóm Đường cong ổn định. Khi ps>1, hợp đồng PegKeeper được phép đúc các stablecoin không bảo đảm và chỉ gửi chúng vào nhóm hoán đổi ổn định ở một bên và giá cuối cùng sau khi làm như vậy vẫn không thấp hơn 1. khi ps< 1, PegKeeper được phép rút (bất đối xứng) và đốt stablecoin.
These actions cause price ps to quickly depreciate when it’s higher than 1 and appreciate if lower than 1 because asymmetric deposits and withdrawals change the price. Even though the mint is uncollateralized, the stablecoin appears to be implicitly collateralized by liquidity in the stablecoin pool. The whole mint/burn cycle appears, at the end, to be profitable while providing stability.
Những hành động này khiến giá ps giảm nhanh chóng trên 1 và tăng giá trị dưới 1 do tiền gửi và rút tiền bất đối xứng làm thay đổi giá. Mặc dù phần "đúc tiền" này không được thế chấp, nhưng stablecoin dường như được hỗ trợ bởi sự thế chấp ngầm về tính thanh khoản trong nhóm stablecoin. Cuối cùng, toàn bộ chu trình đúc/đốt dường như mang lại lợi nhuận trong khi vẫn mang lại sự ổn định.
Let’s denote the amount of stablecoin minted to the stabilizer (debt) as dst and the function which calculates necessary amount of redeemable USD to buy the stablecoin in a stableswap AMM get_dx as fdx(). Then, in order to keep reserves not very large, we use the “slow” mechanism of stabilization via varying the borrow r:
Hãy biểu thị số lượng stablecoin được đúc thành stablecoin (khoản nợ) dưới dạng dst và hàm tính toán số lượng USD có thể quy đổi cần thiết để mua stablecoin trong AMM hoán đổi ổn định get_dx dưới dạng fdx(). Sau đó, để giữ cho "dự trữ" không quá lớn, chúng tôi sử dụng"chậm"cơ chế ổn định.

where h is the change in ps at which the rate r changes by factor of 2 (higher ps leads to lower r). The amount of stabilizer debt dst will equilibrate at different value depending on the rate at ps = 1 r 0. Therefore, we can (instead of setting manually) be reducing r 0 while dst/supply is larger than some target number (for example, 5%) (thereby incentivizing borrowers to borrow-and-dump the stablecoin, decreasing its price and forcing the system to burn the dst) or increasing if it’s lower (thereby incentivizing borrowers to return loans and pushing ps up, forcing the system to increase the debt dst and the stabilizer deposits).
tiêu đề cấp đầu tiên
Kết luận/tóm tắt
The presented mechanisms can, hopefully, solve the riskiness of liquidations for stablecoin-making and borrowing purposes. In addition, stabilizer and automatic monetary policy mechanisms can help with peg-keeping without the need of keeping overly big PSMs.
Người ta hy vọng rằng cơ chế được đề xuất sẽ giải quyết bản chất rủi ro của việc thanh lý cho mục đích cho vay và đúc stablecoin. Ngoài ra, các cơ chế ổn định và chính sách tiền tệ tự động có thể giúp duy trì neo giá mà không cần phải duy trì PSM quá mức (mô-đun neo ổn định Peg Stability Module).


