Based HEAVILY on job done by https://github.com/usmfum/USM team. This is vulnerable and not usable in production version of USM stablecoin. Utilizes same mint<>fund logic with two tokens, where minters sell risk and funders buy risk. Bascially, you should read through series of brillant medium articles written by @jacob-eliosoff explaining how minimalistic stablecoin is build.
Proposed implementation strips all of the useful and usable mechanics of minimal stablecoin to present most primitive blueprint of it (If you still had problems, like me, to wrap your head around USM, it may help to see it's core functions through EIP-4626). It translates core functionality of USM to ERC-4626 previewFunctions and demonstrates how one can use newly proposed standard to build their own stable currency.
There are three easy/obvious routes to build stablecoin using 4626.
This project chooses to keep ERC-4626 expected behavior (Route no. 2).
Set .env
and run npx hardhat node
then npx hardhat run scripts/StableVault.ts --network localhost
Before running any command, make sure to install dependencies:
$ yarn install
Compile the smart contracts with Hardhat:
$ yarn compile
Run the Mocha tests:
$ yarn test
npx hardhat run --network rinkeby ./scripts/deploy.ts
npx hardhat verify --network <network> <DEPLOYED_CONTRACT_ADDRESS> "Constructor argument 1"