Skip to content

ERC20 interest-bearing token that continuously accrues yield to its holders.

Notifications You must be signed in to change notification settings

jpgonzalezra/compota-token

Repository files navigation

CompotaToken

Overview

CompotaToken is a custom ERC20 interest-bearing token that continuously accrues yield to its holders.

Key Features

  • 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.

Getting started

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

Development

Installation

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

Env

Copy .env and write down the env variables needed to run this project.

cp .env.example .env

Compile

Run the following command to compile the contracts:

npm run compile

Coverage

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

Test

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

Code quality

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

CI

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:

You will need to uncomment them to activate them.

Documentation

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.

Deployment

Build

To compile the contracts for production, run:

npm run build

Deploy

Local

Open a new terminal window and run anvil to start a local chain:

anvil

Deploy the contracts by running:

npm run deploy-local

Sepolia

To deploy to the Sepolia testnet, run:

npm run deploy-sepolia

About

ERC20 interest-bearing token that continuously accrues yield to its holders.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published