Solidity implementation of the Stablecoin system using a beacon proxy pattern with OpenZeppelin contracts.
- Beacon Proxy Upgradeability -- All stablecoin proxies share a single
Stablecoinimplementation via aTwoStepUpgradeableBeacon; upgrades apply atomically across every deployed instance - ERC-7201 Namespaced Storage -- Collision-resistant storage layout across all mixin contracts
- Mint Rate Limiting -- Each minter has an independent capacity that replenishes over a configurable rolling interval
- Blocklist -- Addresses can be blocked from sending, receiving, or approving token transfers
- Role-Based Access Control -- Granular roles with separated concerns:
DEFAULT_ADMIN_ROLE-- Role and upgrade management (single holder, two-step transfer with configurable delay)MINT_ROLE-- Mint tokens up to the configured rate limitMINT_RATE_LIMIT_ROLE-- Update rate-limit configurations for existing mintersBURN_ROLE-- Burn the caller's own tokensBLOCKLIST_ROLE/UNBLOCKLIST_ROLE-- Add or remove addresses from the blocklistPAUSE_ROLE/UNPAUSE_ROLE-- Pause and unpause all token transfersMETADATA_ROLE-- Update the contract-level metadata URI (ERC-7572)
- Foundry (forge, cast, anvil)
forge buildforge test -vvvforge fmt --checkevm/
├── src/
│ ├── Stablecoin.sol # ERC-20 stablecoin implementation
│ ├── StablecoinFactory.sol # UUPS-upgradeable factory (CREATE2 deploys)
│ ├── TwoStepUpgradeableBeacon.sol # Beacon with two-step ownership transfer
│ ├── MutableBeaconProxy.sol # Proxy that can swap its beacon
│ ├── interfaces/ # Solidity interfaces
│ └── lib/
│ ├── Blocklist.sol # Blocklist mixin
│ ├── RateLimit.sol # Rolling rate-limit mixin
│ ├── TokenMetadata.sol # Custom decimals + ERC-7572 contractURI mixin
│ └── ERC3009Upgradeable.sol # ERC-3009 transfer-with-authorization mixin
├── test/
│ ├── unit/ # Per-function unit tests
│ ├── integration/ # End-to-end workflow tests
│ ├── attack/ # Adversarial scenario tests
│ ├── benchmark/ # Gas benchmark tests
│ └── lib/ # Test base contracts and mocks
└── foundry.toml # Foundry configuration
| Dependency | Purpose |
|---|---|
| OpenZeppelin Contracts Upgradeable | Access control, ERC-20 extensions, proxy utilities |
| OpenZeppelin Contracts | ERC-1967 utils, CREATE2, UUPS |
| forge-std | Foundry testing and scripting standard library |