Maker Simulation Series: Peg Stability Module (Pt. 3)

Cover Image for Maker Simulation Series: Peg Stability Module (Pt. 3)
Omer Goldberg
Omer Goldberg

Welcome back to the MakerDAO Simulation Series, where we highlight how the Chaos Labs platform can be used to enhance the testing of key protocol infrastructure in stateful, orchestrated environments. Though this series specifically focuses on some of our work during the MakerDAO SES program, the Chaos Labs platform can help you iterate on enhancements and optimize for a variety of potential parameters.

If you haven’t read the introduction to the series, you can check it out before continuing.

If you prefer video, check out this tutorial:

For the third simulation of our MakerDAO Simulation Series, we are focusing on the Peg Stability Module (PSM) for MakerDAO’s DAI. Whether you’re looking to evaluate the effectiveness of your algorithmic stablecoin, or looking to determine the risk level of a different smart contract function, the Chaos Labs platform can help you iterate and optimize on your developments.

Simulation Overview

Peg Stability Module (PSM)

The Peg Stability Module (PSM) allows users to swap a given collateral type directly for DAI at a fixed rate, rather than opening a vault and borrowing DAI against collateral. These are primarily used for stablecoins with USDC being the most popular.

A PSM operates similarly to a regular vault type with a zero stability fee and a liquidation ratio of 100%. Unlike regular vaults, users of PSM don't retain ownership of the asset and borrow DAI, instead, they swap the asset directly for DAI.

The PSM contract was primarily created to help keep the DAI peg close to $1 during times where DAI demand outstrips DAI supply (DAI price > 1$). The PSM contract allows Governance to collect fees on stablecoins at the point of the swap as a transaction fee, rather than over time as maintenance fees.

You can learn more about how the PSM works here.

Simulation Set Up

Since the PSM relies on the actions of users to keep the peg close to $1, we are going to first set up three kinds of agents in our simulation:

  • DAI Buyers: DAI buyers are agents that swap USDC for DAI on the CURVE 3Pool. In doing so, the DAI Buyers emulate DAI demand that outstrips DAI supply.
  • Arbitrageurs: Arbitrageurs are agents that swap USDC for DAI on USDC-PSM and sell it for a premium on CURVE 3Pool. Arbitrageurs swap USDC at an optimal rate to avoid slippage and maximize profit.
  • Vault Users: Vault Users are agents that open ETH-A vaults as long as DAI maintains its peg based on parameterized risk.

Edit Simulation

For a range of values for Tin (USDC->DAI swap fee), [0:0.2]%, we run agents independently for 1,000 iterations and measure the following:

  • DAI price
  • Total USDC collateral in Maker
  • Total Collateral in Maker
  • Liquidity on Curve

We are aiming to optimize for a low USDC collateral ratio, while maintaining a reasonable Peg (Community should decide max de-peg value allowed, which is equivalent to PSM fees).

Edit Simulation

Edit Simulation

From the visualizations created by the Chaos Labs platform, we can see that as the tin value increases, the arbitrage opportunity decreases and the protocol dependency on USDC as collateral drops, as well.

Simulation Flow

With everything set up, we let the on-chain transactions flow unabated to see how agents interact with the protocol. Specifically, we are seeing the following play out:

  • Price of ETH drops 43% in 14hrs
  • Several vaults become under-collateralized
  • Keepers bark and kick the vaults preparing them for auction
  • Flip Auctions are triggered
  • Vaults get liquidated

To see the simulation in action, you can watch the product demo alongside a walk-through of how the Chaos Labs platform:

  • Interacts with the data;
  • Sets up agents & observable; and
  • Creates observable data types throughout the simulation.


Simulation Takeaways

With the simulation set up, we let the on-chain transactions flow unabated to see how our agents interact with the protocol.

To see these interactions happen, you can check out the entire product demo here, alongside a walk-through of how the simulation unfolds on the Chaos Labs platform. In the full demo, you will see how the agents interact in the simulated auction.

Arbitrager Step 1: Swap USDC for DAI at a fixed rate via PSM

Arbitrateger Step 2: Sell DAI for USDC on Curve and profit the spread

While the Arbitrager continues to obtain profits, the other agents are buying DAI and opening new vaults within the protocol while they view minting DAI to be cheaper than a market purchase.

Insights and Conclusions

The PSM simulation brought a number of takeaways that could easily be transferred to other simulations for different protocols. Specifically, this simulation demonstrated the power of the Chaos platform for protocols and developers looking to set up sophisticated testing environments with:

  • Parameter optimization: With Chaos Labs, you can run a simulation with different parameter configurations to find the best metrics for your protocol’s health.
  • Simulation scale: The platform can easily handle concurrent simulations, allowing you to make minor changes in assumptions and compare the outputs.
  • Variable agent activities: Through Chaos Labs, we can construct agents who do not have a deterministic path, but act in their best interest given the simulation. Here, we created the profit-maximizing arbitrageurs who traded USDC/DAI at a depeg because it was in their best financial interest to do so.

For MakerDAO specifically, the simulation created scenarios that let the MakerDAO team make informed decisions based on quantified risks and benefits derived from the results. Specific risk-benefits scenarios included:

  • DAI De-peg: Higher fees can increase the amplitude of the DAI price and create volatility as arbitrage opportunities become less profitable. If a DAI de-peg event starts when the price is further from peg, then there may be less time for the peg to be reestablished, protect against a bank run and avoid a loss of confidence in DAI.
  • USDC/Total Collateral: Over reliance on stablecoins has a high correlation to the stability and security of DAI to third-party-controlled stablecoins as wrappers and reduces the value in opening vaults to mint DAI.
  • PSM fees as an additional revenue stream: Recently, the Maker community has been vocal about a need to increase revenue streams. By increasing revenue streams, the community hopes to establish a buffer on operating costs and additional capital to reinvest in the protocol. The PSM is widely used, but monetizing it presents risk trade-offs.

In addition to the information above, the simulation provided measurable conclusions on what would be the most optimal decision for the protocol.

  • Setting tin reduces dependency on USDC in times of high DAI demand, while peg is still reasonably maintained.
  • Optimal value configuration for tin: in this simulation 0.1% fees would maximize profit.
  • Quantifying the risk and benefits could have helped the community make an informed decision before setting the fees to 0.

About Chaos Labs

Chaos Labs is a software company building a simulation platform to allow teams to efficiently test protocols and understand how they will react to adversarial market environments. The backbone of our technology is a cloud-based, agent- and scenario-based simulation platform that allows users to orchestrate blockchain state, test new features, and optimize risk parameter selection.

Our technology allows users to:

  • Orchestrate protocol/blockchain state
  • Generate wallets with behavioral attributes
  • Test protocol performance in chaotic market conditions
  • Optimize risk parameters

Our mission is to secure and optimize protocols through verifiable agent- and scenario-based simulations.

The Chaos Labs simulation platform is built to emulate a production environment. Each simulation runs on a mainnet fork with the chain's current state so that your simulations include up-to-date account balances and the latest contracts and code deployed across DeFi. You cannot look at your protocol in a silo when you're testing adversarial environments. You must ensure you understand how external factors such as cascading liquidations, oracle failures, variable gas fees, liquidity crises, and more will impact your protocol in various situations.