A Foundry implementation of an overcollateralized stablecoin protocol.
Users deposit approved collateral, mint DSC, burn DSC to reduce debt, redeem collateral, and liquidate unhealthy positions. Collateral values come from Chainlink price feeds.
DeStablecoin.sol: ERC20 stablecoin token namedDeStablecoinwith symbolDSC. Minting and burning are restricted to the owner.DSCEngine.sol: Core protocol engine for collateral deposits, DSC minting, redemptions, health factors, price valuation, and liquidations.
- Collateral tokens and price feeds are configured at deployment.
- Positions must remain overcollateralized.
- The liquidation threshold is
50%, which requires200%collateralization. - Liquidators receive a
10%collateral bonus. - Price feeds are rejected if the answer is non-positive, stale, or incomplete.
Install Foundry:
curl -L https://foundry.paradigm.xyz | bash
foundryupInstall submodules if needed:
git submodule update --init --recursiveBuild and test:
forge build
forge testCheck formatting:
forge fmt --checkLocal Anvil deployment:
anvil
forge script script/DeployDSC.s.sol:DeployDSC --rpc-url http://127.0.0.1:8545 --broadcastSepolia deployment:
PRIVATE_KEY=<your_private_key> forge script script/DeployDSC.s.sol:DeployDSC --rpc-url <sepolia_rpc_url> --broadcastsrc/ Core contracts
script/ Deployment and network configuration
test/ Unit tests and mocks
lib/ Foundry dependencies