Jul 26, 2024
We are excited to be embarking on a collaboration with Defi.money, an EVM agnostic stablecoin protocol that leverages Curve Finance’s LLAMMA liquidation mechanism to safeguard users from volatility. This engagement focuses on providing robust risk parameterization and monitoring services to support Defi.money's rollout on Arbitrum, Optimism, and potentially additional L2s, leading up to a full protocol launch by Q3.
Defi.money is notably an authorized fork of crvUSD, with a collaborative attitude toward the parent protocol. As a consequence of the complementary relationship between Defi.money and Curve, our development efforts will additionally benefit crvUSD. This engagement involves improvements to the existing crvUSD simulation codebases which will enable more precision in assessing the risk of crvUSD mint markets and LlamaLend markets. These improvements will allow us to give additional guidance on protocol health and setting suitable parameters, and will instill greater user trust in the protocol.
Research Goals
The primary research goal of this project is to develop and validate comprehensive risk parameterization models for Defi.money to be used for deploying new and adjusting existing $MONEY markets. In particular, we strive to optimize the A
, fee
, loan_discount
, liquidation_discount
, and debt_ceiling
parameters.
Source: crvUSD Deployer API
Our work will be based on the crvUSD simulation framework developed by Xenophon Labs. The simulator will be adapted to Defi.money's contracts. Various extensions, both from the assumption and the modeling perspectives, will be proposed and implemented.
Why It Matters
Risk parameters optimization is critical for the stability and efficiency of Defi.money. Here's why finding these parameters matters:
Debt Ceiling: the debt ceiling bounds the number of tokens that can be borrowed inside of a market. It should be determined based on the available liquidity of both the collateral and the borrowed token. The liquidator has to repay the debt of the CDP eligible for liquidation, implying an equivalent amount of tokens has to be purchased before the transaction. Similarly, the discounted collateral obtained after the transaction has to be sold for currency, typically USDC or ETH. Hence, we have to make sure that both the borrowed and collateral token are liquid enough to ensure proper liquidation. This is ensured by controlling the debt ceiling.
Liquidation Discount: Discount applied to the borrower's collateral when the associated CDP is eligible for liquidation. It ensures there is a proper incentive for repaying a user's debt as fast as possible. An excessive discount causes unnecessary losses to the borrower when liquidated, while a too-small discount might not ensure enough margin between the moment the CDP is elected for liquidation and the moment the debt is repaid. Indeed, assuming infinite liquidity, if the liquidation discount is too small, the price of the collateral token might further decrease making the liquidation operation not profitable. The liquidation discount is dependent on borrowed and collateral token liquidity as well as the collateral token's volatility.
Loan Discount: Given a certain amount of collateral, the loan discount is used to infer the loan-to-value, which in turn determines the percentage of collateral's value that can be converted to debt. The loan discount should always be higher than the liquidation discount, or else immediate liquidation would occur. The difference between the loan discount and the liquidation discount accounts for a safety measure against oracle volatility, safeguarding borrowers from flash liquidations.
Fee: The fee parameter determines the cost of trade execution in the LLAMMA. It is important to calibrate the fee properly to get an optimal rebalancing AMM. A fee that is too high makes soft-liquidating and deliquidating more expensive, causing the market to operate in coarser granularity. On the other hand, setting the fees too low causes the borrowers to incur more significant losses. Indeed, the borrowers are subject to the loss-versus-rebalancing (LVR) penalty, which describes the difference between holding an LP position inside of the LLAMMA and a replicating portfolio of that LP position in an infinitely liquid market. Since the borrowers always sell/buy collateral at worse than market prices, the rebalancing losses accumulate in LVR. Too small fees might not compensate LVR, making the market unattractive to use.
A: The amplification coefficient controls the tick size inside of the LLAMMA. The ticks are proportional to $\frac{1}{A}$. A correlated pair might want to use a high value of A, while a highly uncorrelated pair should opt for a lower value of A.
Methodology Description
To determine the optimal values for the parameters A
, fee
, loan_discount
, and liquidation_discount
for Defi.money, we rely on Agent-Based Modeling (ABM). The high-level methodology is based on work by Xenophon for crvUSDrisk and can be broken down into:
Agent-Based Modeling (ABM):
Agents: This involves modeling the key agents in the Defi.money protocol, namely the Arbitrageur, Liquidator, and Keeper. These agents interact with Defi.money smart contracts based on predefined behaviors. More specifically, each agent is characterized by a decision-making function based on the smart contract's state.
Simulation: The system's state transitions are driven by the agents' interactions with market prices and liquidity, which are provided externally. The simulation captures how these interactions impact the protocol's performance.
Stress Testing:
Stress Scenarios: Various stress scenarios are created to test the system under different market conditions. These scenarios vary in terms of price volatility, debt levels, and liquidity availability.
Metrics: Key metrics tracked during stress testing include Bad Debt, Liquidated Debt, Net Peg Keeper Debt, LVR (Loss-Versus-Rebalancing), Fee Income, and Oracle Error. The scenarios are categorized into baseline, adverse, and severe conditions, reflecting potential real-world market stresses.
Monte Carlo Simulations:
Aggregation: Thousands of simulations are run for each stress scenario, aggregating the key metrics to derive mean, median, and 99th percentile (p99) values. Each simulation spans a 24-hour period with price updates occurring every 5 minutes.
Insights: This aggregation helps understand the system's performance under different market conditions and identify potential risks.
Model Inputs:
Prices: Asset prices are simulated using Geometric Brownian Motion (GBM) and Ornstein-Uhlenbeck processes, with additional jumps to model extreme volatility and rare events, such as stablecoin depegs.
Debt: Debt distributions are sampled from historical data, assuming borrowers are passive, meaning they do not alter their debt or collateral levels during the time of the simulation. This increases the burden on liquidators and tests the system's ability to handle stress.
Liquidity: Both internal liquidity (in Peg Keeper Pools) and external liquidity (available in the broader market) are modeled. This helps assess the system's capacity to manage liquidations and arbitrage opportunities effectively.
This work is built on the shoulders of giants, relying on previous simulations built by Curve Research, 0xReviews, Xenophon Labs, and michwill. Their work is hosted in the GitHub repos crvUSDrisk, crvUSDsim, curvesim, and llama-simulator.
Conclusion
The outcome of this research will allow LlamaRisk to make more authoritative recommendations on parameterization and exposure limits to Curve ecosystem stablecoin and lending market protocols, with support for chain agnostic protocols such as Defi.money. The work conducted here will be incorporated into our risk monitor portal with real-time insights about protocol health, underlying collaterals, and user behaviors. The risk portal will give users direct access to information about our recommendations based on simulation output and whether the state of the protocol falls within recommended guidelines. Our aim is for this tool to be a resource for DAO stakeholders to make informed governance decisions and for protocol users (minters/borrowers) to have confidence that the protocol has undergone a thorough review of risks that can be analyzed quantitatively.
We look forward to sharing the outcomes of this project which aims to strengthen synergies between Curve and its authorized forks, and to support the successful rollout of Defi.money on Arbitrum, Optimism, and more to come.