|
1 | | -// TODO: Уточнить, что не подходит для реализации вестинга ребейз токенов |
| 1 | +# True Vesting |
2 | 2 |
|
3 | | -## Foundry |
| 3 | +**True Vesting** is a pet project for creating decentralized vesting of an ERC-20 token. The decentralization lies in the fact that, after the token is created, its entire supply is transferred to a dedicated contract responsible for distribution. The token cannot be withdrawn by the owner or any other party. The token can only be sent to specific contracts that handle its distribution according to predefined rules. |
4 | 4 |
|
5 | | -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** |
| 5 | +Currently, only one type of distribution has been implemented—vesting. Other types can be successfully added later. |
6 | 6 |
|
7 | | -Foundry consists of: |
| 7 | +The project does not implement full-fledged tokenomics and serves only as an example for two allocation groups: team and liquidity. Any coincidences are purely accidental. |
8 | 8 |
|
9 | | -- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). |
10 | | -- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. |
11 | | -- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. |
12 | | -- **Chisel**: Fast, utilitarian, and verbose solidity REPL. |
| 9 | +_Important!_ The project i**s not designed to support vesting for rebase tokens** or tokens with dynamically changing quantities. |
13 | 10 |
|
14 | | -## Documentation |
| 11 | +## Smart Contract Overview |
15 | 12 |
|
16 | | -https://book.getfoundry.sh/ |
| 13 | +The following smart contracts have been implemented: |
| 14 | +- [MetaToken.sol](./src/MetaToken.sol). The ERC-20 token contract, which we will distribute through the contract `MetaTokenDistributor.sol`. |
| 15 | +- [MetaTokenDistributor.sol](./src/tokenDistribution/MetaTokenDistributor.sol). A contract that will initiate various types of vesting. It can be upgraded to handle token locking, adding liquidity, sending tokens to mentors, and so on. |
| 16 | +- [VestingParams.sol](./src/tokenDistribution/vesting/VestingParams.sol). A contract that stores parameters for all types of vesting (in our case, two types: team and liquidity). It includes the description of allocations, a list of beneficiary addresses, and the token unlock schedule. |
| 17 | +- [Vesting.sol](./src/tokenDistribution/vesting/Vesting.sol). Implementation of the vesting contract. A new instance is created for each type of vesting. It organizes the token unlock process according to the established schedule. |
17 | 18 |
|
18 | | -## Usage |
| 19 | +## Architecture |
19 | 20 |
|
20 | | -### Build |
| 21 | + |
21 | 22 |
|
22 | | -```shell |
23 | | -$ forge build |
24 | | -``` |
| 23 | +The smart contract architecture outlines the process of creating new vesting instances.To create a new vesting, the following deployment and smart contract call process must be executed: |
25 | 24 |
|
26 | | -### Test |
| 25 | +1. Deploy the `VestingParams.sol` smart contract, which defines all vesting rules for all vesting types. |
| 26 | +2. Deploy the `MetaTokenDistributor.sol` smart contract. The distribution contract accepts and stores the address of `VestingParams.sol`. |
| 27 | +3. Under the hood, a `MetaToken.sol` contract for distribution will be deployed. |
| 28 | +4. At the time of `MetaToken.sol` deployment, its entire supply will be sent to the `MetaTokenDistributor.sol` contract. |
| 29 | +5. To initiate vesting, the `startVesting()` function must be called on the `MetaTokenDistributor.sol` contract. |
| 30 | +6. The `MetaTokenDistributor.sol` contract will request vesting parameters from the `VestingParams.sol` contract. |
| 31 | +7. Deploy a `Vesting.sol` contract using the minimal clone pattern. |
27 | 32 |
|
28 | | -```shell |
29 | | -$ forge test |
30 | | -``` |
| 33 | +_Important!_ Each type of vesting can only be initiated once and by anyone after the vesting start time has been reached. |
31 | 34 |
|
32 | | -### Format |
| 35 | +### Maximum number of beneficiaries |
33 | 36 |
|
34 | | -```shell |
35 | | -$ forge fmt |
36 | | -``` |
| 37 | +The list of beneficiaries is determined at the moment of deploying the smart contract [VestingParams.sol](./src/tokenDistribution/vesting/VestingParams.sol) in the constructor. Therefore, it is important to understand the maximum number of beneficiaries that can be set in this way without exceeding the block gas limit. |
37 | 38 |
|
38 | | -### Gas Snapshots |
| 39 | +As of 2025, the block gas limit in the Ethereum network is 36 million. In the Arbitrum network, it is significantly higher, but according to the documentation, the practical working limit is 32 million. |
39 | 40 |
|
40 | | -```shell |
41 | | -$ forge snapshot |
42 | | -``` |
| 41 | +To determine the actual gas consumption, you can refer to the load test [MaxBeneficiaries.t.sol](./test/tokenDistribution/vesting/loadTests/MaxBeneficiaries.t.sol). Run the test with gas profiling using `forge test -vvv --mt test_deploy_moreBeneficiaries --gas-report`. |
43 | 42 |
|
44 | | -### Anvil |
| 43 | +The resulting table shows that for 401 beneficiaries, `19_448_973` gas will be consumed, which is optimal and will occupy approximately half of the block gas limit in Ethereum. |
45 | 44 |
|
46 | | -```shell |
47 | | -$ anvil |
48 | | -``` |
| 45 | + |
49 | 46 |
|
50 | | -### Deploy |
| 47 | +Important! For deployment on other networks, it is necessary to check the documentation and review the block and transaction gas limits. |
51 | 48 |
|
52 | | -```shell |
53 | | -$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> |
54 | | -``` |
| 49 | +## Getting started |
55 | 50 |
|
56 | | -### Cast |
| 51 | +The project is written using a [Foundry framework](https://book.getfoundry.sh/). |
57 | 52 |
|
58 | | -```shell |
59 | | -$ cast <subcommand> |
60 | | -``` |
| 53 | +### Usage |
61 | 54 |
|
62 | | -### Help |
| 55 | +**Build** |
63 | 56 |
|
64 | 57 | ```shell |
65 | | -$ forge --help |
66 | | -$ anvil --help |
67 | | -$ cast --help |
| 58 | +$ forge build |
68 | 59 | ``` |
69 | 60 |
|
70 | | -### Maximum number of beneficiaries |
| 61 | +**Test** |
71 | 62 |
|
72 | | -The list of beneficiaries is determined at the moment of deploying the smart contract [VestingParams.sol](./src/tokenDistribution/vesting/VestingParams.sol) in the constructor. Therefore, it is important to understand the maximum number of beneficiaries that can be set in this way without exceeding the block gas limit. |
73 | | - |
74 | | -As of 2025, the block gas limit in the Ethereum network is 36 million. In the Arbitrum network, it is significantly higher, but according to the documentation, the practical working limit is 32 million. |
75 | | - |
76 | | -To determine the actual gas consumption, you can refer to the load test [MaxBeneficiaries.t.sol](./test/tokenDistribution/vesting/loadTests/MaxBeneficiaries.t.sol). Run the test with gas profiling using `forge test -vvv --mt test_deploy_moreBeneficiaries --gas-report`. |
| 63 | +```shell |
| 64 | +$ forge test |
| 65 | +``` |
77 | 66 |
|
78 | | -The resulting table shows that for 401 beneficiaries, `19_448_973` gas will be consumed, which is optimal and will occupy approximately half of the block gas limit in Ethereum. |
| 67 | +**Test coverage** |
79 | 68 |
|
80 | | - |
| 69 | +```shell |
| 70 | +$ forge coverage |
| 71 | +``` |
81 | 72 |
|
82 | | -Important! For deployment on other networks, it is necessary to check the documentation and review the block and transaction gas limits. |
| 73 | +**Format** |
83 | 74 |
|
| 75 | +```shell |
| 76 | +$ forge fmt |
| 77 | +``` |
0 commit comments