Skip to content

paulsimroth/foundry-defi-protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeFi Protocol with Stablecoin

Intro

This is a project built with Foundry. This project is meant to be a stablecoin where users can deposit WETH and WBTC in exchange for a token that will be pegged to the USD. The main Contract is called DSCEngine.sol and it severves as the execution protocol of this project. Included is the DecentralizedStableCoin, which is a burnable ERC20 Token.

This system is designed to be as minimal as possible and have the Token maintain a peg of 1 Token == 1 US$

This stablecoin has the properties:

  • Exogenous collateral
  • US Dollar pegging
  • Stabilization Algorithm

This system should always be over collateralized. At no point should the value of all collateral <= US$ backed value of all DSC

Summary

  1. Relative Stability, pegging to USD
    1. Chainlink Price Feed
    2. Function to exchange ETH & BTC -> USD
  2. Stability Mechanism: Algorithmic
    1. Users can only mint with enough collateral (coded)
  3. Collateral: Exogenous (Crypto)
    1. wETH
    2. wBTC

Techstack

Foundry Documentation

https://book.getfoundry.sh/

Usage

Build

$ forge build

Test

$ forge test

Run local tests on Sepolia by forking

$ forge test --fork-url $SEPOLIA_RPC_URL

Format

$ forge fmt

Gas Snapshots

$ forge snapshot

Anvil

Anvil is Foundrys local dev blockchain

$ anvil

Deploy

  1. Setup environment variables You'll want to set your SEPOLIA_RPC_URL and PRIVATE_KEY as environment variables. You can add them to a .env file, similar to what you see in .env.example.
  • PRIVATE_KEY: The private key of your account (like from metamask). NOTE: FOR DEVELOPMENT, PLEASE USE A KEY THAT DOESN'T HAVE ANY REAL FUNDS ASSOCIATED WITH IT.You can learn how to export it here.
  • SEPOLIA_RPC_URL: This is url of the sepolia testnet node you're working with. You can get setup with one for free from Alchemy. Optionally, add your ETHERSCAN_API_KEY if you want to verify your contract on Etherscan.
  1. Get testnet ETH Head over to faucets.chain.link and get some testnet ETH. You should see the ETH show up in your metamask.

  2. Deploy

$ forge script script/DeployDSC.s.sol --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY

Cast

$ cast <subcommand>

Thank you

If you found this useful, feel free to follow me or contact me!

paulsimroth

@paul.simroth

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published