Skip to content

A DeFi project to allow users to mint and burn stablecoin by depositing and redeeming collateral, including health factor and liquidation mechanism to incentivize protocol solvency.

Notifications You must be signed in to change notification settings

dt6120/defi-stablecoin-protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeFi Stablecoin Protocol

Overview

The protocol consists of an ERC20 stablecoin and is governed by its engine smart contract. The stablecoin is algorithmic and exogenous. The engine allows protocol participants to mint stablecoins by depositing collateral tokens and redeem collateral tokens by burning stablecoins. It also incorporates a health factor to assess and monitor the health of user positions, ensuring they stay overcollateralized. There is a liquidation mechanism that allows anyone to liquidate undercollateralized positions to restore protocol solvency in return for some bonus rewards. Since the stablecoin price is intended to be pegged to $1, the USD prices of collateral tokens are fetched using Chainlink price feeds. The entire project is built using Foundry and the test suite consists of unit and fuzz tests along with handler based invariant tests.

Getting started

  • Ensure you have Foundry and Git installed
# should return output like `git version 2.43.0`
git --version

# should return output like `forge 0.2.0 (bcacf39 2024-10-13T00:22:05.416295704Z)`
forge --version
  • Clone the repo
git clone https://github.com/dt6120/defi-stablecoin-protocol.git
  • Deploy stablecoin and engine smart contracts using script
forge script script/DeployDSC.s.sol
  • Run tests
# unit and fuzz tests
forge test --mt test_

# invariant tests
forge test --mt invariant_

# all tests
forge test
  • Check test suite coverage
forge coverage

Known issues

  • Protocol assumes collateral tokens have 18 decimals, other decimal value can break protocol.
  • Liquidation breaks when user position is <110% collateralized.
  • Stale price data halts the protocol functionality.
  • Current overcollateralization ratio and liquidation bonus percentage do not mathematically incentivize others to perform liquidation.

About

A DeFi project to allow users to mint and burn stablecoin by depositing and redeeming collateral, including health factor and liquidation mechanism to incentivize protocol solvency.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published