Overview
StableGuard is a research-grade, modular stablecoin system designed to demonstrate production-style architecture (module wiring, timelock, explicit invariants) with strong safety guardrails and gas-optimized paths. It runs locally with mocks, no fork, no deployment, and no external infra required.
What it demonstrates
- Modular protocol decomposition (oracle, collateral, liquidation, auction, repeg, arbitrage, timelock)
- Oracle design with validation + 18-dec normalization + fallback price path
- Liquidation engineering: direct liquidation and MEV-aware Dutch auctions (commit-reveal)
- Peg management primitives: bounded repeg actions + optional arbitrage coordination
- Safety-by-default patterns: rate limits, circuit breakers, non-reentrancy, timelocked admin actions
Key features
-
Validated PriceOracle
- feed freshness / bounds checks
- decimals normalization to 18
- conservative fallback pricing with telemetry events
-
Collateral + safety guardrails
- per-token LTV/threshold configuration
- strict mint constraints to enforce minimum collateral ratio
-
Liquidation paths
- direct liquidation under caps
- Dutch auction liquidation with commit-reveal to reduce manipulation/MEV
-
Arbitrage + Repeg
- deviation monitoring vs target
- bounded buy/sell pressure under cooldowns/limits
- optional DEX routing for arbitrage execution
-
Timelock
- queue/execute/cancel lifecycle for sensitive ops (auditability + reaction time)
Non-production scope: StableGuard is built for local research/prototyping. Treat it as a learning base, not a mainnet-ready deployment.
Architecture notes
- StableGuard (core) orchestrates mint/burn and enforces invariants.
- Managers isolate responsibilities (oracle, collateral, liquidation, auctions, repeg, arbitrage).
- Observability is treated as a feature: key state transitions emit explicit telemetry events.
Quickstart
git clone https://github.com/casaisdev/StableGuard.gitThen:
forge install
forge build
forge test -vvNotes
- StableGuard is designed to be deterministic: local mocks + pinned deps, so tests don’t require RPCs or environment variables.
- ETH is represented as
address(0)for native-collateral flows and is explicitly supported by the oracle path in this design. - The Dutch auction flow uses commit-reveal to reduce MEV/sniping relative to naive fixed-bonus liquidation mechanisms.
Next steps
If I were to evolve StableGuard further:
- Add deeper invariant/property testing (longer fuzz runs + scenario suites)
- Add multi-oracle redundancy + cross-validation policy
- Add a monitoring “runbook” layer derived from telemetry events
- Add a stronger governance story (multisig owner + staged parameter rollouts + stricter timelock controls)