Requires Foundry to be installed.
# Clone the repository
git clone https://github.com/wasim007choudhary/BUSC-Protocol-DeFI-Stablecoin.git
# Enter project directory
cd BUSC-Protocol-DeFI-Stablecoin
# Install dependencies
forge install
# Build the project
forge buildThe project comes with a Makefile that automates common tasks such as build, deploy, test, and coverage.
Create a .env file in the project root and add the following variables:
For local Anvil network
ANVIL_RPC_URL=http://localhost:8545
ANVIL_PRIVATE_KEY=<your-local-anvil-private-key>
# For Sepolia testnet
SEPOLIA_RPC_URL=<your-sepolia-rpc-url>
SEPOLIA_PRIVATE_KEY=<your-sepolia-wallet-private-key>
ETHERSCAN_API_KEY=<your-etherscan-api-key>make deploy-anvil
make deploy-sepolia
Use the provided Makefile to simplify your workflow:
make clean
make remove
make install
make update
make build
make anvil
BUSC (Blockchain USD Coin) is a decentralized stablecoin designed to maintain a 1:1 peg with the US Dollar, backed by exogenous collateral (WETH & WBTC).
The protocol is implemented through the BUSCmotor contract, which serves as the backbone of the system — handling collateral deposits, minting & burning BUSC, redemptions, and liquidations.
This design draws inspiration from MakerDAO’s DSS architecture while simplifying governance, fees, and collateral types.
This repo contains the core BUSC ERC20, motor logic, deployment scripts, oracle libraries, and a robust Foundry test suite.
- Exogenously Collateralized — BUSC is always backed by external crypto assets (WETH, WBTC).
- Perpetually Overcollateralized — Collateral value > BUSC supply at all times.
- No Governance / No Fees — Minimalistic and trust-minimized design.
- Automatic Liquidations — Keeps the system solvent when health factors drop.
- 1:1 USD Peg — Achieved via minting, redemption, and liquidation mechanisms.
- Atomic Utilities — Combined functions (e.g., deposit & mint, burn & redeem) for better UX.
- ERC20MockDecimal — Added for local testing, enabling WBTC simulation with 8 decimals via helper config.
- Custom OracleLib — Ensures price freshness; if Chainlink price feeds are stale, the protocol freezes until valid data is restored.
📂 BUSC-Stablecoin/
│
├── 📂 assets/ # Logos & diagrams
├── 📂 cache/ # Foundry build cache
├── 📂 coverage/ # Coverage reports
├── 📂 lib/ # External deps
├── 📂 out/ # Build artifacts
├── 📂 script/ # Deployment scripts
│ ├── 📜 DeployBUSC.s.sol
│ └── 📜 HelperConfig.s.sol
│
├── 📂 src/ # Core protocol contracts
│ ├── 📜 BUSCmotor.sol
│ ├── 📜 BUSCstablecoin.sol
│ └── 📂 Oracle-lib/
│ └── 📜 OracleLib.sol
│
├── 📂 test/ # Test suite
│ ├── 📂 fuzz-invariant/
│ │ ├── 📂 ContinueOnRevert/
│ │ │ ├── 📜 HandlerContinueOnRevert.t.sol
│ │ │ └── 📜 InvariantsContinueOnRevert.t.sol
│ │ └── 📂 FailOnRevert/
│ │ ├── 📜 HandlerFailOnRevert.t.sol
│ │ └── 📜 InvariantsFailOnRevert.t.sol
│ │
│ ├── 📂 Mocks/
│ │ ├── 📜 ERC20MockDecimals.sol
│ │ └── 📜 MockV3Aggregator.sol
│ │
│ └── 📂 Unit/
│ ├── 📜 BUSC-Stablecoin.t.sol
│ └── 📜 BUSCmotor.t.sol
│
├── 📜 foundry.toml # Foundry config
└── 📜 README.md # Project docs
BUSCstablecoin.sol→ ERC20 token contract for BUSC.BUSCmotor.sol→ Protocol logic: collateral management, minting, burning, liquidation,redeeming and other Internal main logics.ERC20MockDecimal.sol→ Local testing helper for tokens with custom decimals (e.g., WBTC 8 decimals).OracleLib.sol→ Custom library wrapping Chainlink feeds to handle stale prices.
- WETH (Wrapped Ether)
- WBTC (Wrapped Bitcoin)
- Chainlink Oracles for reliable USD price feeds.
- OpenZeppelin ReentrancyGuard & ERC20 standards for security.
- Collateralization Ratio: 200%
- Liquidation Threshold: 50%
- Liquidation Bonus: 10%
- Minimum Health Factor:
1e18(must stay ≥ 1 to avoid liquidation) - Oracle Staleness Protection: Protocol freezes if Chainlink price feed is stale.
- ERC20MockDecimal → enables WBTC simulation (8 decimals) in local tests via
HelperConfig. - OracleLib → simulates stale price conditions and validates protocol freeze mechanism.
-
Protocol is designed to always stay overcollateralized.
-
Uses CEI pattern and ReentrancyGuard for security.
-
Collateral supported is strictly limited to WETH & WBTC.
-
Relies on Chainlink Oracles with custom staleness checks.
-
PRs and issues are welcome! Please:
-
Add/extend tests for new features.
-
Ensure forge fmt && forge test -vvv passes.
-
Run fuzzing (forge test --fuzz-runs 1000) before merging.
Wasim Choudhary
Builder of minimalistic, trustless financial primitives on Ethereum.
This project is licensed under the MIT License.
MIT © 2025 Wasim Choudhary