M^0 is an EVM-compatible, immutable protocol that enables minting and burning of the ERC20 token $M. It also allows for $M distributions to yield earners and governance token ($ZERO) holders. There are three main types of actors in the protocol - Minters, Validators, and Yield Earners - all of which are permissioned via governance. Protocol variables are also managed by governance and are stored in a Registrar configuration contract.
You may have to install the following tools to use this repository:
- foundry to compile and test contracts
- lcov to generate the code coverage report
- yarn to manage npm dependencies
- slither to static analyze contracts
Install dependencies:
yarn
forge install
Copy .env
and write down the env variables needed to run this project.
cp .env.example .env
Run the following command to compile the contracts:
forge compile
Forge is used for coverage, run it with:
yarn coverage
You can then consult the report by opening coverage/index.html
:
open coverage/index.html
To run all tests:
forge test
Run test that matches a test contract:
forge test --mc <test-contract-name>
Test a specific test case:
forge test --mt <test-case-name>
To run slither:
yarn slither
Prettier is used to format Solidity code. Use it by running:
yarn prettier
Solhint is used to lint Solidity files. Run it with:
yarn solhint
Or to autofix some issues:
yarn solhint-fix
Forge is used to generate the documentation. Run it with:
yarn doc
The command will generate the documentation in the docs
folder and spinup a local server on port 4000
to view the documentation.
![protocol_architecture](https://private-user-images.githubusercontent.com/1220854/294869193-d9949243-e83b-4e1d-82ac-4d8c3f2bf5fc.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0NTkwNjMsIm5iZiI6MTczOTQ1ODc2MywicGF0aCI6Ii8xMjIwODU0LzI5NDg2OTE5My1kOTk0OTI0My1lODNiLTRlMWQtODJhYy00ZDhjM2YyYmY1ZmMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI1MDIxMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNTAyMTNUMTQ1OTIzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZjU2YzdjYTBiZTU3ZmI1MWFiODIwMzFjMmM4MDI5MGYyZDNlM2VmYWE3OWQ1OTVkODliMTUxYjFjMWUxNzAyYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.67BprTgNATnPLIzUYgTDNetf6oqaEfPzP1B8T2YwtME)