Skip to content

Commit 4a5972e

Browse files
committed
fix: forge fmt
1 parent 8785488 commit 4a5972e

10 files changed

Lines changed: 92 additions & 192 deletions

File tree

src/tokenDistribution/MetaTokenDistributor.sol

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,8 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
7070
revert VestingHasAlreadyStarted();
7171
}
7272

73-
(
74-
Schedule memory schedule,
75-
Beneficiary[] memory beneficiaries,
76-
uint256 vestingTotalAmount
77-
) = _vestingParams.getVestingParams(vestingType);
73+
(Schedule memory schedule, Beneficiary[] memory beneficiaries, uint256 vestingTotalAmount) =
74+
_vestingParams.getVestingParams(vestingType);
7875

7976
vesting = Clones.clone(_vestingImpl);
8077

@@ -103,4 +100,4 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
103100
function getVestingParamsAddress() external view returns (address) {
104101
return address(_vestingParams);
105102
}
106-
}
103+
}

src/tokenDistribution/utils/Common.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ struct Beneficiary {
1919
enum VestingType {
2020
TEAM,
2121
LIQUIDITY
22-
}
22+
}

src/tokenDistribution/vesting/Vesting.sol

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ contract Vesting is IVesting, Initializable {
4747
* @param schedule The structure that defines the vesting schedule
4848
* @param beneficiaries List of accounts and amounts to be distributed
4949
*/
50-
function initialize(IERC20 baseToken, Schedule calldata schedule, Beneficiary[] calldata beneficiaries) external initializer {
50+
function initialize(IERC20 baseToken, Schedule calldata schedule, Beneficiary[] calldata beneficiaries)
51+
external
52+
initializer
53+
{
5154
if (address(baseToken) == address(0)) {
5255
revert ZeroAddress();
5356
}
@@ -238,4 +241,4 @@ contract Vesting is IVesting, Initializable {
238241
}
239242

240243
// endregion
241-
}
244+
}

src/tokenDistribution/vesting/VestingParams.sol

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ contract VestingParams is IVestingParams {
3434
/// @notice List of beneficiaries for vesting type
3535
mapping(VestingType vestingType => Beneficiary[] beneficiaries) private _beneficiaries;
3636

37-
constructor(
38-
uint64 startTime,
39-
Beneficiary[] memory teamBeneficiaries,
40-
Beneficiary[] memory liquidityBeneficiaries
41-
) {
37+
constructor(uint64 startTime, Beneficiary[] memory teamBeneficiaries, Beneficiary[] memory liquidityBeneficiaries) {
4238
if (startTime < block.timestamp) {
4339
revert InvalidStartTime();
4440
}
@@ -56,13 +52,8 @@ contract VestingParams is IVestingParams {
5652
* @return schedule Schedule structure
5753
*/
5854
function getSchedule(VestingType vestingType) public view returns (Schedule memory schedule) {
59-
(
60-
,
61-
uint256 numberOfPeriods,
62-
uint256 tgePortion,
63-
uint256 cliffPeriod,
64-
uint256 vestingPortion
65-
) = getVestingConstant(vestingType);
55+
(, uint256 numberOfPeriods, uint256 tgePortion, uint256 cliffPeriod, uint256 vestingPortion) =
56+
getVestingConstant(vestingType);
6657

6758
Period[] memory periods = new Period[](numberOfPeriods);
6859

@@ -78,10 +69,7 @@ contract VestingParams is IVestingParams {
7869
periods[i] = Period({endTime: vestingStartTime + (i - 1) * MONTH, portion: vestingPortion});
7970
}
8071

81-
schedule = Schedule({
82-
startTime: _startTime,
83-
periods: periods
84-
});
72+
schedule = Schedule({startTime: _startTime, periods: periods});
8573
}
8674

8775
/**
@@ -140,19 +128,11 @@ contract VestingParams is IVestingParams {
140128
function getVestingParams(VestingType vestingType)
141129
external
142130
view
143-
returns (
144-
Schedule memory,
145-
Beneficiary[] memory,
146-
uint256 totalAmount
147-
)
131+
returns (Schedule memory, Beneficiary[] memory, uint256 totalAmount)
148132
{
149133
(totalAmount,,,,) = getVestingConstant(vestingType);
150134

151-
return (
152-
getSchedule(vestingType),
153-
getBeneficiaries(vestingType),
154-
totalAmount
155-
);
135+
return (getSchedule(vestingType), getBeneficiaries(vestingType), totalAmount);
156136
}
157137

158138
/// @notice Return start time for all vesting types
@@ -189,4 +169,4 @@ contract VestingParams is IVestingParams {
189169
revert IncorrectBeneficiaryAmounts();
190170
}
191171
}
192-
}
172+
}

src/tokenDistribution/vesting/interfaces/IVesting.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,4 @@ interface IVesting {
5151
function unlockedOf(address account) external view returns (uint256);
5252
function lockedOf(address account) external view returns (uint256);
5353
function availableToClaim(address account) external view returns (uint256);
54-
}
54+
}

src/tokenDistribution/vesting/interfaces/IVestingParams.sol

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ interface IVestingParams {
3434
function getVestingParams(VestingType vestingType)
3535
external
3636
view
37-
returns (
38-
Schedule memory schedule,
39-
Beneficiary[] memory beneficiaries,
40-
uint256 totalAmount
41-
);
37+
returns (Schedule memory schedule, Beneficiary[] memory beneficiaries, uint256 totalAmount);
4238
function getStartTime() external view returns (uint64);
43-
}
39+
}

test/tokenDistribution/MetaTokenDistributor.t.sol

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ contract MetaTokenDistributorTest is Test {
2121

2222
function setUp() external {
2323
vestingStartTime = uint64(block.timestamp + MONTH);
24-
(Beneficiary[] memory teamBeneficiaries, Beneficiary[] memory liquidityBeneficiaries)
25-
= _generateBeneficiaries();
24+
(Beneficiary[] memory teamBeneficiaries, Beneficiary[] memory liquidityBeneficiaries) = _generateBeneficiaries();
2625

2726
vestingParams = new VestingParams(vestingStartTime, teamBeneficiaries, liquidityBeneficiaries);
2827
distributor = new MetaTokenDistributor(address(vestingParams));
@@ -44,8 +43,7 @@ contract MetaTokenDistributorTest is Test {
4443

4544
function test_deploy_startTimeEqualBlockTimestamp() external {
4645
vestingStartTime = uint64(block.timestamp);
47-
(Beneficiary[] memory teamBeneficiaries, Beneficiary[] memory liquidityBeneficiaries)
48-
= _generateBeneficiaries();
46+
(Beneficiary[] memory teamBeneficiaries, Beneficiary[] memory liquidityBeneficiaries) = _generateBeneficiaries();
4947

5048
vestingParams = new VestingParams(vestingStartTime, teamBeneficiaries, liquidityBeneficiaries);
5149
distributor = new MetaTokenDistributor(address(vestingParams));
@@ -59,7 +57,6 @@ contract MetaTokenDistributorTest is Test {
5957
}
6058

6159
function test_deploy_revertIfZeroAddress() external {
62-
6360
vm.expectRevert(IMetaTokenDistributor.ZeroAddress.selector);
6461

6562
distributor = new MetaTokenDistributor(address(0));
@@ -113,27 +110,21 @@ contract MetaTokenDistributorTest is Test {
113110

114111
// region - Service functions -
115112

116-
function _generateBeneficiaries() private returns (Beneficiary[] memory teamBeneficiaries, Beneficiary[] memory liquidityBeneficiaries) {
113+
function _generateBeneficiaries()
114+
private
115+
returns (Beneficiary[] memory teamBeneficiaries, Beneficiary[] memory liquidityBeneficiaries)
116+
{
117117
teamBeneficiary1 = makeAddr("teamBeneficiary1");
118118
teamBeneficiary2 = makeAddr("teamBeneficiary2");
119119
liquidityBeneficiary = makeAddr("liquidityBeneficiary");
120120

121121
teamBeneficiaries = new Beneficiary[](2);
122-
teamBeneficiaries[0] = Beneficiary({
123-
account: teamBeneficiary1,
124-
amount: 60_000_000e18
125-
});
126-
teamBeneficiaries[1] = Beneficiary({
127-
account: teamBeneficiary2,
128-
amount: 40_000_000e18
129-
});
122+
teamBeneficiaries[0] = Beneficiary({account: teamBeneficiary1, amount: 60_000_000e18});
123+
teamBeneficiaries[1] = Beneficiary({account: teamBeneficiary2, amount: 40_000_000e18});
130124

131125
liquidityBeneficiaries = new Beneficiary[](1);
132-
liquidityBeneficiaries[0] = Beneficiary({
133-
account: liquidityBeneficiary,
134-
amount: 287_500_000e18
135-
});
126+
liquidityBeneficiaries[0] = Beneficiary({account: liquidityBeneficiary, amount: 287_500_000e18});
136127
}
137128

138129
// endregion
139-
}
130+
}

test/tokenDistribution/vesting/Vesting.t.sol

Lines changed: 28 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,12 @@ contract VestingTest is Test {
7474
assertEq(vesting.unlockedOf(beneficiary1), BENEFICIARY1_AMOUNT * SCHEDULE_TGE_PORTION / BASIS_POINTS);
7575
assertEq(vesting.unlockedOf(beneficiary2), BENEFICIARY2_AMOUNT * SCHEDULE_TGE_PORTION / BASIS_POINTS);
7676

77-
assertEq(vesting.lockedOf(beneficiary1), BENEFICIARY1_AMOUNT * (BASIS_POINTS - SCHEDULE_TGE_PORTION) / BASIS_POINTS);
78-
assertEq(vesting.lockedOf(beneficiary2), BENEFICIARY2_AMOUNT * (BASIS_POINTS - SCHEDULE_TGE_PORTION) / BASIS_POINTS);
77+
assertEq(
78+
vesting.lockedOf(beneficiary1), BENEFICIARY1_AMOUNT * (BASIS_POINTS - SCHEDULE_TGE_PORTION) / BASIS_POINTS
79+
);
80+
assertEq(
81+
vesting.lockedOf(beneficiary2), BENEFICIARY2_AMOUNT * (BASIS_POINTS - SCHEDULE_TGE_PORTION) / BASIS_POINTS
82+
);
7983
}
8084

8185
function test_deploy_emitVestingAndBeneficiariesInitialized() external {
@@ -366,7 +370,8 @@ contract VestingTest is Test {
366370
vm.prank(beneficiary1);
367371
vesting.claim();
368372

369-
uint256 expectedMiddleOfPeriod1Amount = expectedTGEAmount + (BENEFICIARY1_AMOUNT * SCHEDULE_PERIOD_PORTION / BASIS_POINTS) / 2;
373+
uint256 expectedMiddleOfPeriod1Amount =
374+
expectedTGEAmount + (BENEFICIARY1_AMOUNT * SCHEDULE_PERIOD_PORTION / BASIS_POINTS) / 2;
370375

371376
assertEq(META.balanceOf(beneficiary1), expectedMiddleOfPeriod1Amount);
372377
assertEq(META.balanceOf(address(vesting)), VESTING_TOTAL_AMOUNT - expectedMiddleOfPeriod1Amount);
@@ -378,9 +383,7 @@ contract VestingTest is Test {
378383
vesting.claim();
379384

380385
uint256 expectedPeriod1Amount = BENEFICIARY1_AMOUNT * SCHEDULE_PERIOD_PORTION / BASIS_POINTS;
381-
uint256 expectedMiddleOfPeriod2Amount =
382-
expectedTGEAmount
383-
+ expectedPeriod1Amount
386+
uint256 expectedMiddleOfPeriod2Amount = expectedTGEAmount + expectedPeriod1Amount
384387
+ (BENEFICIARY1_AMOUNT * SCHEDULE_PERIOD_PORTION / BASIS_POINTS) / 2;
385388

386389
assertEq(META.balanceOf(beneficiary1), expectedMiddleOfPeriod2Amount);
@@ -400,7 +403,10 @@ contract VestingTest is Test {
400403

401404
// region - Service function -
402405

403-
function _deployVesting(IERC20 baseToken, Beneficiary[] memory beneficiaries, Schedule memory schedule) private returns (Vesting) {
406+
function _deployVesting(IERC20 baseToken, Beneficiary[] memory beneficiaries, Schedule memory schedule)
407+
private
408+
returns (Vesting)
409+
{
404410
Vesting vestingImpl = new Vesting();
405411

406412
address vestingAddress = Clones.clone(address(vestingImpl));
@@ -411,54 +417,36 @@ contract VestingTest is Test {
411417
Vesting(vestingAddress).initialize(baseToken, schedule, beneficiaries);
412418

413419
return Vesting(vestingAddress);
414-
415420
}
416421

417-
function _getBeneficiariesAndSchedule() private view returns (Beneficiary[] memory beneficiaries, Schedule memory schedule) {
422+
function _getBeneficiariesAndSchedule()
423+
private
424+
view
425+
returns (Beneficiary[] memory beneficiaries, Schedule memory schedule)
426+
{
418427
beneficiaries = _getBeneficiaries();
419428
schedule = _getSchedule();
420429
}
421430

422431
function _getBeneficiaries() private view returns (Beneficiary[] memory beneficiaries) {
423432
beneficiaries = new Beneficiary[](2);
424-
beneficiaries[0] = Beneficiary({
425-
account: beneficiary1,
426-
amount: BENEFICIARY1_AMOUNT
427-
});
428-
beneficiaries[1] = Beneficiary({
429-
account: beneficiary2,
430-
amount: BENEFICIARY2_AMOUNT
431-
});
433+
beneficiaries[0] = Beneficiary({account: beneficiary1, amount: BENEFICIARY1_AMOUNT});
434+
beneficiaries[1] = Beneficiary({account: beneficiary2, amount: BENEFICIARY2_AMOUNT});
432435
}
433436

434437
function _getSchedule() private view returns (Schedule memory schedule) {
435438
Period[] memory periods = new Period[](SCHEDULE_TOTAL_PERIODS);
436439
// tge
437-
periods[0] = Period({
438-
endTime: VESTING_TGE_END,
439-
portion: SCHEDULE_TGE_PORTION
440-
});
440+
periods[0] = Period({endTime: VESTING_TGE_END, portion: SCHEDULE_TGE_PORTION});
441441

442442
// cliff
443-
periods[1] = Period({
444-
endTime:VESTING_CLIFF_END,
445-
portion: 0
446-
});
447-
448-
periods[2] = Period({
449-
endTime: VESTING_PERIOD_1_END,
450-
portion: SCHEDULE_PERIOD_PORTION
451-
});
452-
453-
periods[3] = Period({
454-
endTime: VESTING_PERIOD_2_END,
455-
portion: SCHEDULE_PERIOD_PORTION
456-
});
457-
458-
schedule = Schedule({
459-
startTime: VESTING_TGE_END,
460-
periods: periods
461-
});
443+
periods[1] = Period({endTime: VESTING_CLIFF_END, portion: 0});
444+
445+
periods[2] = Period({endTime: VESTING_PERIOD_1_END, portion: SCHEDULE_PERIOD_PORTION});
446+
447+
periods[3] = Period({endTime: VESTING_PERIOD_2_END, portion: SCHEDULE_PERIOD_PORTION});
448+
449+
schedule = Schedule({startTime: VESTING_TGE_END, periods: periods});
462450
}
463451

464452
// endregion

0 commit comments

Comments
 (0)