- The purpose it to build a Unit of Exchange that will hold its purchasing value for grocery items over time. Using Ethereum, smart contracts, exogeneous collateral, algorithms, and game theory I plan to create the solution for everyday people facing inflation at the grocery store.
- Relatively Stable in regards to purchasing power of time
- Stability Mechanism - Minting/Burning
- Algorithmic
- Over-collateralized
- Collateral - Exogenous (ETH/BTC/GOLD), Grocery Inventory Index
- Governance - Game Theory, Monetary Incentives
- Main Contracts
- Stablecoin
- Engine
- Treasury Smart Contract Wallet
- Test Contracts
- Unit
- StableCoin
- Engine
- Smart Contract Wallet
- Oracle
- Mocks
- ERC20
- FailedMint
- FailedTransfer
- FailedTransferFrom
- MoreDebtThanCollateral
- V3Aggregator (Chainlink)
- Fuzz
- ContinueOnRevert
- FailOnRevert
- Unit
- Scripts
- HelperConfig
- DeployStableCoin
- PriceFeed
- Oracle from Chainlink
- Foundry.toml
- remappings
- block explorers
- rpc_endpoints
-
Main Contracts - Coin and Engine
- Start with Valuecoin contract
- burnable (minting process), and ownable (by the engine)
- part of script needs to be transferring ownership to engine
- burnable (minting process), and ownable (by the engine)
- From the engine, people are going to deposit collateral, mint coin, redeem collateral, burn coin, liquidate
- to move tokens use "bool success = IERC20(tokenAddress).transfer(msg.sender, tokenAmount)"
- use transfer when going from another contract that isn't you
- transferFrom is when its going from your wallet
- to move tokens use "bool success = IERC20(tokenAddress).transfer(msg.sender, tokenAmount)"
- Checks, Effects, Interactions mental model for functions
- Start with Valuecoin contract
-
Build deploy script first then realize need HelperConfig for network (constructor) args and contract address details (struct)
- scripts use function run() public view returns
- scripts import script from forge
-
HelperConfig is where all deployable networks, collateral tokens, and chainlink price feeds belong.
- for networks use if else statement with block.chainid
- use chainlink data feeds or v3aggregator interface with mockerc20 for token and pricefeed addresses
-
Internal functions allow calls to be made from anybody
- examples were from the liquidate function which called burn and redeem functions which needed to be moved to internal and variables shifted from msg.sender to "from" and "to"
- still kept the public functions but utlized the internal function logic
-
Import Test, console2, StdCheats, deploy scripts, main contracts, mock files
-
Mocks need to match the files in the lib folder
-
function setUp() external
- Got to start with deploying the script and setting up the "environment" to test
- vm.deal, vm.prank, vm.hoax
- Got to start with deploying the script and setting up the "environment" to test
-
Could be a good idea to write unit tests before scripts and then right integration tests while you write scripts
-
Unit testing each one of the functions from engine contract
- Constructor tests, price tests, public function tests, view and pure function tests
-
Mock testing the mintable coin - transfer, mint, transferFrom, price fluctuations, and priceFeed
-
Use modifiers with unique names, not a function name from another contract
- modifiers can be used in numerous tests to keep from doing redundant work. for example pranking user with funds and approving a token
-
Makefile setup for each deployable network
- use .env to advantage
-
Check out HelperConfig to make sure the right networks and configs are setup
-
make deploy-base ARGS="--network base-sepolia"
- deployment on base testnet using makerfile setup
-
make sure to create .env file and source .env afterward to save
-
basescan api may be different than etherscan api
- Treasury Address
- Simple Smart Contract Wallet
- Deployed during script with the other contracts
- Owned by private key used to deploy but would like to transfer ownership to SVCEngine and add functions to interact with it through the engine
- Treasury Fee could be implemented in some cool ways during liquidate function on SVCEngine
- NFTs to represent healthFactor
- better the health factor, the cooler the NFT