Skip to content

Commit cb3ff32

Browse files
committed
fix: generate schedule periods in VestingParams
1 parent 90fc63c commit cb3ff32

3 files changed

Lines changed: 93 additions & 52 deletions

File tree

src/tokenDistribution/vesting/VestingParams.sol

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ contract VestingParams is IVestingParams {
88
uint256 public constant MONTH = 30 days;
99

1010
// Team
11-
uint256 public constant TEAM_TOTAL_PERIODS = 38;
1211
uint256 public constant TEAM_TOTAL_AMOUNT = 100_000_000e18;
12+
uint256 public constant TEAM_NUMBER_OF_PERIODS = 27; // 25 periods + 1 period TGE + 1 period cliff
1313
uint256 public constant TEAM_TGE_PORTION = 0; // 0%
14-
uint256 public constant TEAM_VESTING_START_MONTH = 13; // thirteenth month from the start
14+
uint256 public constant TEAM_CLIFF_PERIOD = 13 * MONTH; // 13 month
1515
uint256 public constant TEAM_VESTING_PORTION = 400; // 4%
1616

1717
// Liquidity
18-
uint256 public constant LIQUIDITY_TOTAL_PERIODS = 24;
1918
uint256 public constant LIQUIDITY_TOTAL_AMOUNT = 287_500_000e18;
19+
uint256 public constant LIQUIDITY_NUMBER_OF_PERIODS = 22; // // 20 periods + 1 period TGE + 1 period cliff
2020
uint256 public constant LIQUIDITY_TGE_PORTION = 2000; // 20%
21-
uint256 public constant LIQUIDITY_VESTING_START_MONTH = 4; // fourth month from the start
21+
uint256 public constant LIQUIDITY_CLIFF_PERIOD = 4 * MONTH; // 4 month
2222
uint256 public constant LIQUIDITY_VESTING_PORTION = 400; // 4%
2323

2424
mapping(VestingType vestingType => Beneficiary[] beneficiaries) private _beneficiaries;
@@ -35,26 +35,24 @@ contract VestingParams is IVestingParams {
3535
function getSchedule(VestingType vestingType) public view returns (Schedule memory schedule) {
3636
(
3737
,
38-
uint256 totalPeriods,
38+
uint256 numberOfPeriods,
3939
uint256 tgePortion,
40-
uint256 vestingStartMonth,
40+
uint256 cliffPeriod,
4141
uint256 vestingPortion
4242
) = getVestingConstant(vestingType);
4343

44-
Period[] memory periods = new Period[](totalPeriods);
44+
Period[] memory periods = new Period[](numberOfPeriods);
4545

4646
// TGE
4747
periods[0] = Period({endTime: block.timestamp, portion: tgePortion});
4848

4949
// Cliff period
50-
// TODO: переделать на periods[1]
51-
for (uint256 i = 1; i < vestingStartMonth; i++) {
52-
periods[i] = Period({endTime: block.timestamp + i * MONTH, portion: 0});
53-
}
50+
periods[1] = Period({endTime: block.timestamp + cliffPeriod, portion: 0});
5451

5552
// Vesting period
56-
for (uint256 i = vestingStartMonth; i < totalPeriods; i++) {
57-
periods[i] = Period({endTime: block.timestamp + i * MONTH, portion: vestingPortion});
53+
uint256 vestingStartTime = block.timestamp + cliffPeriod;
54+
for (uint256 i = 2; i < numberOfPeriods; i++) {
55+
periods[i] = Period({endTime: vestingStartTime + (i - 1) * MONTH, portion: vestingPortion});
5856
}
5957

6058
schedule = Schedule({
@@ -73,28 +71,28 @@ contract VestingParams is IVestingParams {
7371
pure
7472
returns ( // TODO: описать возвращаемые значения в natspec
7573
uint256 totalAmount,
76-
uint256 totalPeriods,
74+
uint256 numberOfPeriods,
7775
uint256 tgePortions,
78-
uint256 vestingStartMonth,
76+
uint256 cliffPeriod,
7977
uint256 vestingPortion
8078
)
8179
{
8280
if (vestingType == VestingType.TEAM) {
8381
return (
8482
TEAM_TOTAL_AMOUNT,
85-
TEAM_TOTAL_PERIODS,
83+
TEAM_NUMBER_OF_PERIODS,
8684
TEAM_TGE_PORTION,
87-
TEAM_VESTING_START_MONTH,
85+
TEAM_CLIFF_PERIOD,
8886
TEAM_VESTING_PORTION
8987
);
9088
}
9189

9290
if (vestingType == VestingType.LIQUIDITY) {
9391
return (
9492
LIQUIDITY_TOTAL_AMOUNT,
95-
LIQUIDITY_TOTAL_PERIODS,
93+
LIQUIDITY_NUMBER_OF_PERIODS,
9694
LIQUIDITY_TGE_PORTION,
97-
LIQUIDITY_VESTING_START_MONTH,
95+
LIQUIDITY_CLIFF_PERIOD,
9896
LIQUIDITY_VESTING_PORTION
9997
);
10098
}

src/tokenDistribution/vesting/interfaces/IVestingParams.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ interface IVestingParams {
1616
pure
1717
returns (
1818
uint256 totalAmount,
19-
uint256 totalPeriods,
20-
uint256 tgePortions,
21-
uint256 vestingStartMonth,
19+
uint256 numberOfPeriods,
20+
uint256 tgePortion,
21+
uint256 cliffPeriod,
2222
uint256 vestingPortion
2323
);
2424
function getVestingParams(VestingType vestingType)

test/tokenDistribution/vesting/VestingParams.t.sol

Lines changed: 73 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,25 @@ contract VestingParamsTest is Test {
136136

137137
assertEq(teamTotalAmount, vestingParams.TEAM_TOTAL_AMOUNT());
138138
assertEq(teamSchedule.startTime, block.timestamp);
139-
assertEq(teamSchedule.periods.length, vestingParams.TEAM_TOTAL_PERIODS());
139+
140+
// TGE
140141
assertEq(teamSchedule.periods[0].portion, vestingParams.TEAM_TGE_PORTION());
141142
assertEq(teamSchedule.periods[0].endTime, block.timestamp);
143+
144+
// Cliff period
142145
assertEq(teamSchedule.periods[1].portion, 0);
143-
assertEq(teamSchedule.periods[1].endTime, block.timestamp + vestingParams.MONTH());
144-
assertEq(teamSchedule.periods[13].portion, vestingParams.TEAM_VESTING_PORTION());
145-
assertEq(teamSchedule.periods[13].endTime, block.timestamp + 13 * vestingParams.MONTH());
146+
assertEq(teamSchedule.periods[1].endTime, block.timestamp + vestingParams.TEAM_CLIFF_PERIOD());
147+
148+
// Vesting periods
149+
uint256 startTeamVestingTime = block.timestamp + vestingParams.TEAM_CLIFF_PERIOD();
150+
151+
assertEq(teamSchedule.periods[2].portion, vestingParams.TEAM_VESTING_PORTION());
152+
assertEq(teamSchedule.periods[2].endTime, startTeamVestingTime + vestingParams.MONTH());
153+
assertEq(teamSchedule.periods[3].portion, vestingParams.TEAM_VESTING_PORTION());
154+
assertEq(teamSchedule.periods[3].endTime, startTeamVestingTime + 2 * vestingParams.MONTH());
146155
// ...
147-
assertEq(teamSchedule.periods[37].portion, vestingParams.TEAM_VESTING_PORTION());
148-
assertEq(teamSchedule.periods[37].endTime, block.timestamp + 37 * vestingParams.MONTH());
156+
assertEq(teamSchedule.periods[26].portion, vestingParams.TEAM_VESTING_PORTION());
157+
assertEq(teamSchedule.periods[26].endTime, startTeamVestingTime + 25 * vestingParams.MONTH());
149158

150159
(
151160
Schedule memory liquiditySchedule,
@@ -160,16 +169,28 @@ contract VestingParamsTest is Test {
160169

161170
assertEq(liquidityTotalAmount, vestingParams.LIQUIDITY_TOTAL_AMOUNT());
162171
assertEq(liquiditySchedule.startTime, block.timestamp);
163-
assertEq(liquiditySchedule.periods.length, vestingParams.LIQUIDITY_TOTAL_PERIODS());
172+
assertEq(liquiditySchedule.periods.length, vestingParams.LIQUIDITY_NUMBER_OF_PERIODS());
173+
174+
// TGE
164175
assertEq(liquiditySchedule.periods[0].portion, vestingParams.LIQUIDITY_TGE_PORTION());
165176
assertEq(liquiditySchedule.periods[0].endTime, block.timestamp);
177+
178+
// Cliff period
166179
assertEq(liquiditySchedule.periods[1].portion, 0);
167-
assertEq(liquiditySchedule.periods[1].endTime, block.timestamp + vestingParams.MONTH());
180+
assertEq(liquiditySchedule.periods[1].endTime, block.timestamp + vestingParams.LIQUIDITY_CLIFF_PERIOD());
181+
182+
// Vesting periods
183+
uint256 startLiquidityVestingTime = block.timestamp + vestingParams.LIQUIDITY_CLIFF_PERIOD();
184+
185+
assertEq(liquiditySchedule.periods[2].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
186+
assertEq(liquiditySchedule.periods[2].endTime, startLiquidityVestingTime + vestingParams.MONTH());
187+
assertEq(liquiditySchedule.periods[3].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
188+
assertEq(liquiditySchedule.periods[3].endTime, startLiquidityVestingTime + 2 * vestingParams.MONTH());
168189
assertEq(liquiditySchedule.periods[4].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
169-
assertEq(liquiditySchedule.periods[4].endTime, block.timestamp + 4 * vestingParams.MONTH());
190+
assertEq(liquiditySchedule.periods[4].endTime, startLiquidityVestingTime + 3 * vestingParams.MONTH());
170191
// ...
171-
assertEq(liquiditySchedule.periods[23].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
172-
assertEq(liquiditySchedule.periods[23].endTime, block.timestamp + 23 * vestingParams.MONTH());
192+
assertEq(liquiditySchedule.periods[21].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
193+
assertEq(liquiditySchedule.periods[21].endTime, startLiquidityVestingTime + 20 * vestingParams.MONTH());
173194
}
174195

175196
// endregion
@@ -180,32 +201,54 @@ contract VestingParamsTest is Test {
180201
Schedule memory teamSchedule = vestingParams.getSchedule(VestingType.TEAM);
181202

182203
assertEq(teamSchedule.startTime, block.timestamp);
183-
assertEq(teamSchedule.periods.length, vestingParams.TEAM_TOTAL_PERIODS());
204+
assertEq(teamSchedule.periods.length, vestingParams.TEAM_NUMBER_OF_PERIODS());
205+
206+
// TGE
184207
assertEq(teamSchedule.periods[0].portion, vestingParams.TEAM_TGE_PORTION());
185208
assertEq(teamSchedule.periods[0].endTime, block.timestamp);
209+
210+
// Cliff period
186211
assertEq(teamSchedule.periods[1].portion, 0);
187-
assertEq(teamSchedule.periods[1].endTime, block.timestamp + vestingParams.MONTH());
188-
assertEq(teamSchedule.periods[13].portion, vestingParams.TEAM_VESTING_PORTION());
189-
assertEq(teamSchedule.periods[13].endTime, block.timestamp + 13 * vestingParams.MONTH());
212+
assertEq(teamSchedule.periods[1].endTime, block.timestamp + vestingParams.TEAM_CLIFF_PERIOD());
213+
214+
// Vesting periods
215+
uint256 startVestingTime = block.timestamp + vestingParams.TEAM_CLIFF_PERIOD();
216+
217+
assertEq(teamSchedule.periods[2].portion, vestingParams.TEAM_VESTING_PORTION());
218+
assertEq(teamSchedule.periods[2].endTime, startVestingTime + vestingParams.MONTH());
219+
assertEq(teamSchedule.periods[3].portion, vestingParams.TEAM_VESTING_PORTION());
220+
assertEq(teamSchedule.periods[3].endTime, startVestingTime + 2 * vestingParams.MONTH());
190221
// ...
191-
assertEq(teamSchedule.periods[37].portion, vestingParams.TEAM_VESTING_PORTION());
192-
assertEq(teamSchedule.periods[37].endTime, block.timestamp + 37 * vestingParams.MONTH());
222+
assertEq(teamSchedule.periods[26].portion, vestingParams.TEAM_VESTING_PORTION());
223+
assertEq(teamSchedule.periods[26].endTime, startVestingTime + 25 * vestingParams.MONTH());
193224
}
194225

195226
function test_getSchedule_LIQUIDITY() external view {
196227
Schedule memory liquiditySchedule = vestingParams.getSchedule(VestingType.LIQUIDITY);
197228

198229
assertEq(liquiditySchedule.startTime, block.timestamp);
199-
assertEq(liquiditySchedule.periods.length, vestingParams.LIQUIDITY_TOTAL_PERIODS());
230+
assertEq(liquiditySchedule.periods.length, vestingParams.LIQUIDITY_NUMBER_OF_PERIODS());
231+
232+
// TGE
200233
assertEq(liquiditySchedule.periods[0].portion, vestingParams.LIQUIDITY_TGE_PORTION());
201234
assertEq(liquiditySchedule.periods[0].endTime, block.timestamp);
235+
236+
// Cliff period
202237
assertEq(liquiditySchedule.periods[1].portion, 0);
203-
assertEq(liquiditySchedule.periods[1].endTime, block.timestamp + vestingParams.MONTH());
238+
assertEq(liquiditySchedule.periods[1].endTime, block.timestamp + vestingParams.LIQUIDITY_CLIFF_PERIOD());
239+
240+
// Vesting periods
241+
uint256 startVestingTime = block.timestamp + vestingParams.LIQUIDITY_CLIFF_PERIOD();
242+
243+
assertEq(liquiditySchedule.periods[2].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
244+
assertEq(liquiditySchedule.periods[2].endTime, startVestingTime + vestingParams.MONTH());
245+
assertEq(liquiditySchedule.periods[3].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
246+
assertEq(liquiditySchedule.periods[3].endTime, startVestingTime + 2 * vestingParams.MONTH());
204247
assertEq(liquiditySchedule.periods[4].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
205-
assertEq(liquiditySchedule.periods[4].endTime, block.timestamp + 4 * vestingParams.MONTH());
248+
assertEq(liquiditySchedule.periods[4].endTime, startVestingTime + 3 * vestingParams.MONTH());
206249
// ...
207-
assertEq(liquiditySchedule.periods[23].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
208-
assertEq(liquiditySchedule.periods[23].endTime, block.timestamp + 23 * vestingParams.MONTH());
250+
assertEq(liquiditySchedule.periods[21].portion, vestingParams.LIQUIDITY_VESTING_PORTION());
251+
assertEq(liquiditySchedule.periods[21].endTime, startVestingTime + 20 * vestingParams.MONTH());
209252
}
210253

211254
// endregion
@@ -215,32 +258,32 @@ contract VestingParamsTest is Test {
215258
function test_getVestingConstant_TEAM() external view {
216259
(
217260
uint256 totalAmount,
218-
uint256 totalPeriods,
261+
uint256 numberOfPeriods,
219262
uint256 tgePortions,
220-
uint256 vestingStartMonth,
263+
uint256 cliffPeriod,
221264
uint256 vestingPortion
222265
) = vestingParams.getVestingConstant(VestingType.TEAM);
223266

224267
assertEq(totalAmount, vestingParams.TEAM_TOTAL_AMOUNT());
225-
assertEq(totalPeriods, vestingParams.TEAM_TOTAL_PERIODS());
268+
assertEq(numberOfPeriods, vestingParams.TEAM_NUMBER_OF_PERIODS());
226269
assertEq(tgePortions, vestingParams.TEAM_TGE_PORTION());
227-
assertEq(vestingStartMonth, vestingParams.TEAM_VESTING_START_MONTH());
270+
assertEq(cliffPeriod, vestingParams.TEAM_CLIFF_PERIOD());
228271
assertEq(vestingPortion, vestingParams.TEAM_VESTING_PORTION());
229272
}
230273

231274
function test_getVestingConstant_LIQUIDITY() external view {
232275
(
233276
uint256 totalAmount,
234-
uint256 totalPeriods,
277+
uint256 numberOfPeriods,
235278
uint256 tgePortions,
236-
uint256 vestingStartMonth,
279+
uint256 cliffPeriod,
237280
uint256 vestingPortion
238281
) = vestingParams.getVestingConstant(VestingType.LIQUIDITY);
239282

240283
assertEq(totalAmount, vestingParams.LIQUIDITY_TOTAL_AMOUNT());
241-
assertEq(totalPeriods, vestingParams.LIQUIDITY_TOTAL_PERIODS());
284+
assertEq(numberOfPeriods, vestingParams.LIQUIDITY_NUMBER_OF_PERIODS());
242285
assertEq(tgePortions, vestingParams.LIQUIDITY_TGE_PORTION());
243-
assertEq(vestingStartMonth, vestingParams.LIQUIDITY_VESTING_START_MONTH());
286+
assertEq(cliffPeriod, vestingParams.LIQUIDITY_CLIFF_PERIOD());
244287
assertEq(vestingPortion, vestingParams.LIQUIDITY_VESTING_PORTION());
245288
}
246289

0 commit comments

Comments
 (0)