CompotaToken is a custom ERC20 interest-bearing token that continuously accrues yield to its holders.
- Interest Accrual: Tokens accrue interest over time, calculated based on a yearly interest rate set by the contract owner.
- Minting and Burning: The contract owner can mint new tokens to specified addresses and burn tokens from their own balance.
- Balance Tracking: User balances are tracked along with the accrued interest, providing an accurate total balance for each user.
- Interest Rate Control: The contract owner can update the yearly interest rate at any moment in time.
The easiest way to get started is by clicking the Use this template button at the top right of this page.
If you prefer to go the CLI way:
forge init my-project --template https://github.com/MZero-Labs/foundry-template
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
- slither to static analyze contracts
Install dependencies:
npm i
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:
npm run compile
Forge is used for coverage, run it with:
npm run coverage
You can then consult the report by opening coverage/index.html
:
open coverage/index.html
To run all tests:
npm 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:
npm run slither
Husky is used to run lint-staged and tests when committing.
Prettier is used to format code. Use it by running:
npm run prettier
Solhint is used to lint Solidity files. Run it with:
npm run solhint
To fix solhint errors, run:
npm run solhint-fix
The following Github Actions workflow are setup to run on push and pull requests:
It will build the contracts and run the test coverage, as well as a gas report.
The coverage report will be displayed in the PR by github-actions-report-lcov and the gas report by foundry-gas-diff.
For the workflows to work, you will need to setup the MNEMONIC_FOR_TESTS
and MAINNET_RPC_URL
repository secrets in the settings of your Github repository.
Some additional workflows are available if you wish to add fuzz, integration and invariant tests:
- .github/workflows/test-fuzz.yml
- .github/workflows/test-integration.yml
- .github/workflows/test-invariant.yml
You will need to uncomment them to activate them.
The documentation can be generated by running:
npm run doc
It will run a server on port 4000, you can then access the documentation by opening http://localhost:4000.
To compile the contracts for production, run:
npm run build
Open a new terminal window and run anvil to start a local chain:
anvil
Deploy the contracts by running:
npm run deploy-local
To deploy to the Sepolia testnet, run:
npm run deploy-sepolia