Stablecoin infrastructure deployed as an appchain powered by Protokit.
Overview This project implements an overcollateralized stablecoin system called msUSD as an appchain using the Proto Kit framework. It's designed to maintain a stable value pegged to the US dollar, using MINA as collateral. The system incorporates various mechanisms to ensure stability, manage risk, and handle extreme market conditions.
Key Components
Core Functionalities
Minting and Burning 1.1. Minting: Users can create new msUSD by providing MINA as collateral. The amount of collateral required is determined by the current collateral ratio and MINA/USD price. 1.2. Burning: Users can redeem their msUSD for MINA collateral, subject to a 15-day cooldown period after minting.
Price Stability Mechanisms 2.1. Price Checks: The system regularly checks the msUSD price and can lock or unlock based on predefined thresholds. 2.2. Stability Pool Operations: 2.2.1. For low prices: Burns msUSD from the stability pool. 2.2.2. For high prices: Mints new msUSD into the stability pool. 2.3. Dynamic Reward Rates: Adjusts reward rates based on price deviations to incentivize stabilizing actions. 2.4. Emergency Fund Utilization: In extreme cases, uses reserved funds to stabilize the price.
Liquidity Provision 3.1. Users can provide liquidity to the stability pool in the form of MINA or msUSD. 3.2. Liquidity providers can withdraw their contributions.
Fee System 4.1. Fees are collected on minting, burning, and transfers. 4.2. Fees are distributed between a treasury and an emergency fund.
Governance 5.1. The CircuitsDAO can update critical parameters like the collateral price and ratio.
Advanced Features
Depeg Tolerance: 1.1. System locking mechanism for extreme price deviations. 1.2. Multi-tiered stabilization approach (stability pool, emergency funds). 1.3. Dynamic reward rates to incentivize corrective actions.
Failsafes: 2.1. Emergency fund utilization in extreme scenarios. 2.2. System locking to prevent operations during high volatility.
Scalability: 3.1. Uses UInt224 for large number handling, allowing for significant growth.
MEV Protection: 4.1. Being an appchain, it's inherently protected from MEV (Miner Extractable Value) attacks.
Verifiable State: 5.1. The entire state of the system is verifiable, enhancing transparency and trust.
Potential Use Cases
Limitations and Considerations
Conclusion The msUSD system represents a sophisticated approach to creating a stable asset in the cryptocurrency space. Its design incorporates multiple layers of stabilization mechanisms and failsafes, aiming to maintain peg stability even in volatile market conditions. While it offers robust features for stability and transparency, it also comes with inherent risks and complexities that users and developers should be aware of. As an appchain, it benefits from enhanced security and verifiability, potentially making it an attractive option for those seeking a stable asset within the MINA ecosystem.
Technical Implementation Overview : Implemented as a runtime module by Protokit.
1.1. Primary Framework: Proto Kit
2.1. Runtime Module
msUSD
.@runtimeModule()
, a Proto Kit decorator that sets up the necessary infrastructure for the module to run on the appchain.
2.2. State ManagementState
and StateMap
are extensively used for managing the system's state.stableBalances
, collateralBalances
, stableSupply
, etc.@state()
, allowing them to be part of the appchain's global state.
2.3. Runtime Methods@runtimeMethod()
.mint()
, burn()
, transfer()
, stabilize()
, etc.UInt224
for handling large numbers with high precision.3.1. State Abstractions
State
and StateMap
) are used to manage the appchain's state in a way that's compatible with Mina's zk-SNARK architecture.
3.2. Runtime Module Structure@runtimeModule()
decorator from Proto Kit is used to define the msUSD
class as a runtime module.mint()
and burn()
, where this.transaction.sender.value
is used to identify the transaction sender.
3.4. Block Height Accessthis.network.block.height
, a feature provided by Proto Kit's runtime environment.4.1. Dynamic Stabilization Mechanism
stabilize()
method implements a multi-tiered approach to maintain the stablecoin's peg.Provable.if()
in methods like stabilizeLowPrice()
and stabilizeHighPrice()
allows for conditional logic that can be efficiently proved in zero-knowledge circuits.
4.3. Fee Distribution SystemdistributeFee()
method implements a sophisticated fee distribution system, allocating fees between a treasury and an emergency fund.
4.4. Precision Handling5.1. Large Number Handling
UInt224
type, allowing for a wide range of values while maintaining precision.
5.2. State Updates in Zero-Knowledge Setting6.1. Price Oracle Simulation
updateCollateralPrice()
method, simulating an oracle for the proof of concept.
6.2. Emergency Fund MechanismThe msUSD stablecoin system leverages the unique features of the Mina Protocol and Proto Kit to create a sophisticated financial instrument. By utilizing zero-knowledge proofs, it aims to provide a stable asset with enhanced privacy and efficiency. The implementation demonstrates a careful balance between complex financial logic and the constraints of blockchain technology, particularly in a zero-knowledge setting.