Skip to content

Commit 8785488

Browse files
committed
docs: add natspec
1 parent 0cf6981 commit 8785488

7 files changed

Lines changed: 111 additions & 29 deletions

File tree

src/MetaToken.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ pragma solidity 0.8.28;
33

44
import {ERC20} from "solmate/tokens/ERC20.sol";
55

6+
/**
7+
* @title Token of MetaLamp
8+
* @author Pavel Naydanov
9+
* @notice General token of the MetaLamp. Inherited from ERC-20.
10+
* All supply of token is minted to the distributor's smart-contract, which releases vesting.
11+
*/
612
contract MetaToken is ERC20 {
713
uint256 private constant _INITIAL_TOTAL_SUPPLY = 1_000_000_000e18;
814

src/tokenDistribution/MetaTokenDistributor.sol

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,29 @@ import {Vesting, IVesting} from "./vesting/Vesting.sol";
1111
import {IVestingParams} from "./vesting/interfaces/IVestingParams.sol";
1212
import {Schedule, Beneficiary, VestingType} from "./utils/Common.sol";
1313

14+
/**
15+
* @title Distributor of MetaLamp token
16+
* @author Pavel Naydanov
17+
* @notice Deploy vesting contract, which based on vesting params.
18+
* At the time of contract deployment, an instance of the meta token is created.
19+
* Any account can start vesting after the start time.
20+
*/
1421
contract MetaTokenDistributor is IMetaTokenDistributor {
1522
using SafeERC20 for IERC20;
1623

24+
/// @notice Implementation of vesting contract for using in Clone
1725
address private _vestingImpl;
26+
27+
/// @notice MetaLamp token for distribution
1828
IERC20 private _META;
1929

30+
/// @notice A smart contract that stores vesting parameters (allocation, schedule, etc.)
2031
IVestingParams private _vestingParams;
2132

33+
/// @notice Stores addresses of created vestings
2234
mapping(VestingType vestingType => address vesting) private _vestingAddresses;
2335

36+
/// @dev Validate start vesting time
2437
modifier validateTime(VestingType vestingType) {
2538
uint64 startTime = _vestingParams.getStartTime();
2639

@@ -46,6 +59,12 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
4659
emit MetaTokenDeployed(address(_META));
4760
}
4861

62+
/**
63+
* @notice Start vesting
64+
* @param vestingType Type of vesting (Team, Liquidity, etc.)
65+
* @return vesting Address of created vesting contract
66+
* @dev Any can start vesting after start time
67+
*/
4968
function startVesting(VestingType vestingType) external validateTime(vestingType) returns (address vesting) {
5069
if (_vestingAddresses[vestingType] != address(0)) {
5170
revert VestingHasAlreadyStarted();
@@ -67,14 +86,20 @@ contract MetaTokenDistributor is IMetaTokenDistributor {
6786
emit VestingStarted(vesting);
6887
}
6988

89+
/// @notice Returns address of MetaLamp token
7090
function getMETAAddress() external view returns (address) {
7191
return address(_META);
7292
}
7393

94+
/**
95+
* @notice Returns address of created vesting contract
96+
* @param vestingType Type of vesting (Team, Liquidity, etc.)
97+
*/
7498
function getVestingAddress(VestingType vestingType) external view returns (address) {
7599
return _vestingAddresses[vestingType];
76100
}
77101

102+
/// @notice Returns address of VestingParams contract
78103
function getVestingParamsAddress() external view returns (address) {
79104
return address(_vestingParams);
80105
}

src/tokenDistribution/interfaces/IMetaTokenDistributor.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ pragma solidity 0.8.28;
44
import {VestingType} from "../utils/Common.sol";
55

66
interface IMetaTokenDistributor {
7+
/// @notice Emit when vesting contract deployed
78
event VestingStarted(address vesting);
9+
10+
/// @notice Emit when MetaLamp token deployed
811
event MetaTokenDeployed(address META);
912

13+
/// @notice Revert when trying to start vesting at an earlier start time
1014
error VestingStartTimeHasNotArrived();
15+
16+
/// @notice Revert when call with zero address
1117
error ZeroAddress();
18+
19+
/// @notice Revert when trying to start vesting again
1220
error VestingHasAlreadyStarted();
1321

1422
function startVesting(VestingType vestingType) external returns (address vesting);

src/tokenDistribution/vesting/Vesting.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import {Schedule, Period, Beneficiary} from "../utils/Common.sol";
99

1010
/**
1111
* @title Vesting contract of the base token
12-
* @dev Each new vesting instance is created through a factory using the Minimal Clones pattern.
12+
* @author Pavel Naydanov
13+
* @dev Each new vesting instance is created using the Minimal Clones pattern.
1314
* Vesting settings are set at the time of deploying a new instance in the initialize() function.
1415
* Beneficiaries can claim the token according to the schedule by calling the claim() function
1516
*/

src/tokenDistribution/vesting/VestingParams.sol

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ pragma solidity 0.8.28;
44
import {IVestingParams} from "./interfaces/IVestingParams.sol";
55
import {VestingType, Beneficiary, Schedule, Period} from "../utils/Common.sol";
66

7+
/**
8+
* @title Vesting params
9+
* @author Pavel Naydanov
10+
* @notice The contract describes the parameters of the launched vestings.
11+
* Includes: total amount of the vestings, the addresses of the beneficiaries, allocations, the unlocking schedule
12+
* The start time is common for all types of vesting. Start time and addresses of the beneficiaries are set during contract deployment.
13+
*/
714
contract VestingParams is IVestingParams {
815
uint256 public constant MONTH = 30 days;
916

@@ -21,7 +28,10 @@ contract VestingParams is IVestingParams {
2128
uint256 public constant LIQUIDITY_CLIFF_PERIOD = 4 * MONTH; // 4 month
2229
uint256 public constant LIQUIDITY_VESTING_PORTION = 400; // 4%
2330

31+
/// @notice Start time of vestings
2432
uint64 private _startTime;
33+
34+
/// @notice List of beneficiaries for vesting type
2535
mapping(VestingType vestingType => Beneficiary[] beneficiaries) private _beneficiaries;
2636

2737
constructor(
@@ -39,7 +49,12 @@ contract VestingParams is IVestingParams {
3949
_validateAndStoreBeneficiaries(VestingType.LIQUIDITY, liquidityBeneficiaries, LIQUIDITY_TOTAL_AMOUNT);
4050
}
4151

42-
/// @dev Portions 100% equal 10_000. It's _BASIS_POINTS, which declared in Vesting contract
52+
/**
53+
* @notice Get schedule by vesting type
54+
* @param vestingType Type of vesting (Team, Liquidity, etc.)
55+
* @dev Portions 100% equal 10_000. It's _BASIS_POINTS, which declared in Vesting contract
56+
* @return schedule Schedule structure
57+
*/
4358
function getSchedule(VestingType vestingType) public view returns (Schedule memory schedule) {
4459
(
4560
,
@@ -69,14 +84,28 @@ contract VestingParams is IVestingParams {
6984
});
7085
}
7186

87+
/**
88+
* @notice Get beneficiaries by vesting type
89+
* @param vestingType Type of vesting (Team, Liquidity, etc.)
90+
* @return List of the beneficiaries
91+
*/
7292
function getBeneficiaries(VestingType vestingType) public view returns (Beneficiary[] memory) {
7393
return _beneficiaries[vestingType];
7494
}
7595

96+
/**
97+
* @notice Get vesting constant by vesting type
98+
* @param vestingType Type of vesting (Team, Liquidity, etc.)
99+
* @return totalAmount Total amount of the vesting type
100+
* @return numberOfPeriods Number of vesting periods (includes tge and cliff periods)
101+
* @return tgePortions Unlocked tge portion based on BASIS_POINTS from vesting contract
102+
* @return cliffPeriod Duration time of the cliff period when unlocked amount is zero
103+
* @return vestingPortion Unlocked vesting period portion based on BASIS_POINTS from vesting contract
104+
*/
76105
function getVestingConstant(VestingType vestingType)
77106
public
78107
pure
79-
returns ( // TODO: описать возвращаемые значения в natspec
108+
returns (
80109
uint256 totalAmount,
81110
uint256 numberOfPeriods,
82111
uint256 tgePortions,
@@ -85,26 +114,29 @@ contract VestingParams is IVestingParams {
85114
)
86115
{
87116
if (vestingType == VestingType.TEAM) {
88-
return (
89-
TEAM_TOTAL_AMOUNT,
90-
TEAM_NUMBER_OF_PERIODS,
91-
TEAM_TGE_PORTION,
92-
TEAM_CLIFF_PERIOD,
93-
TEAM_VESTING_PORTION
94-
);
117+
totalAmount = TEAM_TOTAL_AMOUNT;
118+
numberOfPeriods = TEAM_NUMBER_OF_PERIODS;
119+
tgePortions = TEAM_TGE_PORTION;
120+
cliffPeriod = TEAM_CLIFF_PERIOD;
121+
vestingPortion = TEAM_VESTING_PORTION;
95122
}
96123

97124
if (vestingType == VestingType.LIQUIDITY) {
98-
return (
99-
LIQUIDITY_TOTAL_AMOUNT,
100-
LIQUIDITY_NUMBER_OF_PERIODS,
101-
LIQUIDITY_TGE_PORTION,
102-
LIQUIDITY_CLIFF_PERIOD,
103-
LIQUIDITY_VESTING_PORTION
104-
);
125+
totalAmount = LIQUIDITY_TOTAL_AMOUNT;
126+
numberOfPeriods = LIQUIDITY_NUMBER_OF_PERIODS;
127+
tgePortions = LIQUIDITY_TGE_PORTION;
128+
cliffPeriod = LIQUIDITY_CLIFF_PERIOD;
129+
vestingPortion = LIQUIDITY_VESTING_PORTION;
105130
}
106131
}
107132

133+
/**
134+
* @notice Get vesting params by vesting type
135+
* @param vestingType Type of vesting (Team, Liquidity, etc.)
136+
* @return Schedule of the vesting
137+
* @return List of the beneficiaries
138+
* @return totalAmount Total amount of the vesting type
139+
*/
108140
function getVestingParams(VestingType vestingType)
109141
external
110142
view
@@ -123,6 +155,7 @@ contract VestingParams is IVestingParams {
123155
);
124156
}
125157

158+
/// @notice Return start time for all vesting types
126159
function getStartTime() external view returns (uint64) {
127160
return _startTime;
128161
}

src/tokenDistribution/vesting/interfaces/IVesting.sol

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@ import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
66
import {Schedule, Beneficiary} from "../../utils/Common.sol";
77

88
interface IVesting {
9-
/// @dev It is forbidden to use a zero address
9+
/// @notice Revert when call with zero address
1010
error ZeroAddress();
1111

12-
/// @dev The list of beneficiaries must not be zero.
12+
/// @notice Revert when call with zero list of beneficiaries
1313
error ZeroBeneficiaries();
1414

15-
/// @dev The amount should not be zero
15+
/// @notice Revert when call with zero amount
1616
error ZeroAmount();
1717

18-
/// @dev Duplication of beneficiary for one vesting is not allowed
18+
/// @notice Revert when duplication of beneficiary for one vesting is not allowed
1919
error DuplicateBeneficiary(address account);
2020

21-
/// @dev The balance of the base token and the sum of all beneficiaries does not match
21+
/// @notice Revert when sum of beneficiaries amount mismatch with total amount
2222
error IncorrectAmountOfBeneficiaries();
2323

24-
/// @dev Invalid vesting start time. Must be greater or equal the current block timestamp
24+
/// @notice Revert when invalid vesting start time. Must be greater or equal the current block timestamp
2525
error InvalidStartTime();
2626

27-
/// @dev Vesting period portion must be less than BASIS_POINTS
27+
/// @notice Revert when vesting period portion less than BASIS_POINTS
2828
error InvalidPortion();
2929

30-
/// @dev Sum of vesting period portion must be equal BASIS_POINTS
30+
/// @notice Revert when sum of vesting period portion not equal BASIS_POINTS
3131
error IncorrectTotalPeriodPortions();
3232

33-
/// @dev Each new end period time must be greater then prev
33+
/// @notice Revert when each new end period time greater then prev
3434
error IncorrectPeriodTime();
3535

36-
/// @dev Emitted when vesting schedule params has been initialized
36+
/// @notice Emit when vesting schedule params has been initialized
3737
event ScheduleInitialized(Schedule schedule);
3838

39-
/// @dev Emitted when list of beneficiaries has been initialized
39+
/// @notice Emit when list of beneficiaries has been initialized
4040
event BeneficiariesInitialized(Beneficiary[] beneficiaries);
4141

42-
/// @dev Emitted when beneficiary has claimed vesting token
42+
/// @notice Emit when beneficiary has claimed vesting token
4343
event Claimed(address indexed account, uint256 amount);
4444

4545
function initialize(IERC20 baseToken, Schedule memory schedule, Beneficiary[] memory beneficiaries) external;

src/tokenDistribution/vesting/interfaces/IVestingParams.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,19 @@ pragma solidity 0.8.28;
44
import {VestingType, Beneficiary, Schedule} from "../../utils/Common.sol";
55

66
interface IVestingParams {
7+
/// @notice Revert when call with invalid start time
78
error InvalidStartTime();
9+
10+
/// @notice Revert when call with zero list of beneficiaries
811
error ZeroBeneficiaries();
12+
13+
/// @notice Revert when call with zero address
914
error ZeroAddress();
15+
16+
/// @notice Revert when call with zero amount
1017
error ZeroAmount();
18+
19+
/// @notice Revert when sum of beneficiaries amount mismatch with total amount
1120
error IncorrectBeneficiaryAmounts();
1221

1322
function getSchedule(VestingType vestingType) external view returns (Schedule memory schedule);

0 commit comments

Comments
 (0)