Exogenous • Over-Collateralized • Dollar-Pegged • Algorithmic Stablecoin
A minimal, MakerDAO-inspired stablecoin system built on Ethereum.
DeFiDollar (DFD) is a decentralized stablecoin pegged 1:1 to the US dollar, backed exclusively by WETH (and formerly WBTC) on the Sepolia testnet.
The protocol is designed to remain permanently over-collateralized:
Total USD value of deposited collateral ≥ Total DFD in circulation
| Contract | Address | Etherscan |
|---|---|---|
| DSCEngine | 0x94AfbdE9fdbc4842bCD14D7875c22a6199899266 |
View ↗ |
| DeFiDollar (DFD) | 0xB8F5D22dF2CEadF8c4577101a7dc5221F70281A4 |
View ↗ |
| OracleLib | 0xC7f2Cf4845C6db0e1a1e91ED41Bcd0FcC1b0E141 |
View ↗ |
| WETH (Collateral) | 0xdd13E55209Fd76AfE204dBda4007C227904f0a81 |
View ↗ |
| WBTC (Collateral) | 0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063 (Discontinued) |
— |
- Name: DeFiDollar
- Symbol: DFD
- Inherits
ERC20Burnable+Ownable - Only the DSCEngine can mint or burn tokens
Handles:
- Collateral deposit & withdrawal
- Minting & burning of DFD
- Health factor calculation
- Liquidation with 10% bonus for liquidators
- Integration with Chainlink price feeds (via OracleLib)
Key Risk Parameters
| Parameter | Value | Meaning |
|---|---|---|
| Liquidation Threshold | 50% | ~200% over-collateralization required |
| Minimum Health Factor | 1e18 |
Below → liquidatable |
| Liquidation Bonus | 10% | Reward for liquidators |
Wraps Chainlink price feeds and reverts if data is older than 3 hours, freezing the protocol rather than risking bad prices.
Important: Always approve the collateral token (WETH), not the stablecoin.
- ETH: Use a Sepolia faucet
- WETH: Wrap ETH via the mock token at
0xdd13…f0a81
cast send 0xdd13E55209Fd76AfE204dBda4007C227904f0a81 \
"approve(address,uint256)" \
0x94AfbdE9fdbc4842bCD14D7875c22a6199899266 1000000000000000000 \
--rpc-url $SEPOLIA_RPC_URL --private-key $PKOne-step (recommended):
cast send 0x94AfbdE9fdbc4842bCD14D7875c22a6199899266 \
"depositCollateralAndMintDsc(address,uint256,uint256)" \
0xdd13E55209Fd76AfE204dBda4007C227904f0a81 \
1000000000000000000 \ # 1 WETH
1000000000000000000000 \ # 1000 DFD (assuming sufficient collateral value)
--rpc-url $SEPOLIA_RPC_URL --private-key $PKcast call 0x94AfbdE9fdbc4842bCD14D7875c22a6199899266 \
"getHealthFactor(address)(uint256)" YOUR_ADDRESS \
--rpc-url $SEPOLIA_RPC_URL
≥ 1e18= safe |< 1e18= liquidatable
# Burn DFD and redeem collateral in one transaction
cast send 0x94AfbdE9fdbc4842bCD14D7875c22a6199899266 \
"redeemCollateralForDsc(address,uint256,uint256)" \
WETH_ADDRESS amountToRedeem amountDfdToBurn \
--rpc-url $SEPOLIA_RPC_URL --private-key $PKAnyone can call:
liquidate(address collateral, address user, uint256 debtToCover)→ Burn DFD, receive collateral + 10% bonus
Built with Foundry.
- Foundry (
forge) .envwithSEPOLIA_RPC_URL,PRIVATE_KEY,ETHERSCAN_API_KEY
forge build # Compile
forge test # Run full test suite (>90% coverage) with unit, fuzz, invariant tests
forge coverage # View coverage report
forge snapshot # Gas reportforge script script/DeployDSC.s.sol \
--rpc-url $SEPOLIA_RPC_URL \
--private-key $PRIVATE_KEY \
--broadcast --verify \
--etherscan-api-key $ETHERSCAN_API_KEY \
-vvvvsrc/
├── DecentralizedStableCoin.sol # DFD token
├── DSCEngine.sol # Core engine
└── libraries/
└── OracleLib.sol # Stale price guard
test/
├── unit/
├── fuzz/
└── invariants/
script/
└── DeployDSC.s.sol # Deployment script
- Educational / Experimental — Not audited
- Deployed only on Sepolia testnet
- WBTC support is disabled (use WETH only)
- In case of Chainlink oracle failure → protocol freezes (by design)
- Get Sepolia ETH → Wrap to WETH
WETH.approve(DSCEngine, amount)depositCollateralAndMintDsc(...)- Monitor
getHealthFactor(you)≥ 1 - Repay with
redeemCollateralForDsc(...)
Enjoy experimenting with your own decentralized dollar.
Built with curiosity, tested with rigor. 🧪💵