- EMISSION_ROLE: This role is granted to the emissionManager. It allows the role holders to mint new tokens.
- CAP_MANAGER_ROLE: This role is granted to the protocolCouncil. It allows the role holder to update the mint cap.
- PERMIT2_REVOKER_ROLE: This role is granted to the protocolCouncil and emergencyCouncil. It allows the role holders to update the permit2Enabled state, which controls whether the permit2 contract has full approval by default.
- MIGRATION_ROLE: This role is granted to the migrationManager. It allows the role holder to migrate tokens from the old contract to the new contract.
- EMISSION_ROLE: This role is granted to the emissionManager. It allows the role holder to mint new tokens.
- CAP_MANAGER_ROLE: This role is granted to the protocolCouncil. It allows the role holder to update the mint cap.
- PERMIT2_REVOKER_ROLE: This role is granted to the protocolCouncil and emergencyCouncil. It allows the role holders to update the permit2Enabled state, which controls whether the permit2 contract has full approval by default.
- Clone the above repository
- Install Foundry by following the instructions from here
then follow the steps on screen to setup
curl -L https://foundry.paradigm.xyz | bashfoundryup - Run
foundryup and then run npm install - Now you're ready with the setup, you can build, compile, test, deploy
Steps for testing, reviewing, and deploying a smart contract to a blockchain.
- Once the above setup is completed successfully, create an
.envfile and configure all the details as per.env.example. - For compiling and testing the contracts you can execute:
- Compile: this will generate the abi's in out/* respectively
forge build- Run test cases:
forge test- For detailed log of test scenarios or individual test cases, run:
forge test --match-test test_MintDelay -vvv(replacetest_MintDelaywith other function names).
- You will be able to see the test cases run and play with them accordingly if needed.
- For compiling the contracts,
or
npm run postinstall(if facing any errorsnpm run compile-contract-typesError occured: Not a valid ABIthen remove build-info folder from out dir and run the above command again) - this will generate the types for the contracts and you can find the abi's in out/* respectively. - After successful compilation, you can deploy contracts by running
npm run deploy -- --rpc-url <RPC_URL> - After a successful deployment of the token contract, you will see 3 addresses:
- Covalent X Token address
- Covalent Migration address
- Default Emission Manager address
- The deployments are stored in ./broadcast
Procedures for transferring token holders from one contract to another, ensuring accuracy and security.
-
This repo has 3 custom scripts which help us in transferring the tokens to holders.
-
Under the
scriptfolder, we have 3 TypeScript scripts:batchTransfer.tsbatchTransferCSV.tsGetHoldersLists.ts
-
GetHoldersLists.ts:
- Using the
ETHERSCAN_API_KEYandCQT addressinitialized by.env, this script fetches all the currentCQT Holdersand creates aholders.jsonfile underscript/staticFiles. - To run this script use the command
npm run fetch-holders.
- Using the
-
batchTransfer.ts:
- This script fetches all the holders from the above-generated JSON file along with the balance that needs to be distributed.
- Has extra two features along with batch transfer as below:
const ignoreAddresses = ['0xb270fc573f9f9868ab11b52ae7119120f6a4471d', '0x6af3d183d225725d975c5eaa08d442dd01aad8ff']; const ignoreAmount = ethers.utils.parseUnits('5000', 18);
ignoreAddressesis an array of addresses to be excluded from the batch transfer.ignoreAmountis a constant to exclude holders withignoreAmount <=from the batch transfer (e.g., holders with 5000 or less CQT won’t receive any tokens).
- To run this script, use the command
npm run distribute-tokens.
-
batchTransferCSV.ts:
- This script requires providing a CSV file of holders as
Tokenholders.csvunderscript/staticFilesand then transfers the tokens to the holders in the given CSV file. - Has extra two features along with batch transfer as below:
const ignoreAddresses = ['0xb270fc573f9f9868ab11b52ae7119120f6a4471d', '0x6af3d183d225725d975c5eaa08d442dd01aad8ff']; const ignoreAmount = ethers.utils.parseUnits('100', 18);
ignoreAddressesis an array of addresses to be excluded from the batch transfer.ignoreAmountis a constant to exclude holders withignoreAmount <=from the batch transfer (e.g., holders with 100 or less CQT won’t receive any tokens).
- To run this script, use the command
npm run distributeCSV.
- This script requires providing a CSV file of holders as
The inflation rate is calculated using the logarithm of the desired annual increase. For a 5% increase, the calculation is as follows:
- Formula:
INTEREST_PER_YEAR_LOG2 = log2(1.05) = 0.07038932789139801e18 - Here,
1.05represents the initial supply of 1.00 (1 billion) plus the 5% increase.
The mintPerSecondCap is calculated based on the annual compounded inflation but needs to consider a longer timeframe for accuracy. Initial calculations for 1 year might suggest 1.59 CXT per second, but over 10 years, due to compounding, the average increases:
- For One Year:
5% of 1 billion = 50 million / (365*24*60*60) = 1.59 CXT per second - Over 10 Years (Compounded):
Total minted over 10 years / (10*365*24*60*60) = ~2 CXT per second - Given the compounded rate, we've set
mintPerSecondCap = 2.5e18(or 2.5 tokens per second) as a conservative cap.
This approach ensures that the mintPerSecondCap is sufficiently conservative to cover the compounded inflation rate over a decade without allowing excessive minting.