Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Jun 7, 2024
1 parent 668cab4 commit 0ac6ff5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/collator/CollatorSet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ abstract contract CollatorSet is Initializable, CollatorStakingHubStorage {
votesOf[HEAD] = type(uint256).max;
}

/// @dev Fetch top k collators in ordered collator set.
/// @param `k` Count of top collators.
/// @return The `k` top collators.
/// *Note* The result of top collators length is always be `k`.
/// If the length of collator set `len` is less than `k`,
/// the array result of first `len` is filled by nomal collators
/// and the rest of `len - k` collators is filled by address(0)
function getTopCollators(uint256 k) public view returns (address[] memory) {
address[] memory topCollators = new address[](k);
uint256 len = count;
Expand Down
4 changes: 4 additions & 0 deletions src/collator/CollatorStakingHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ contract CollatorStakingHub is Initializable, ReentrancyGuardUpgradeable, Collat
_addCollator(collator, _assetsToVotes(commission, stakedOf(collator)), newPrev);
}

/// @dev Distribute collator reward from Staking Pallet Account.
/// The amount of the reward must be passed in via msg.value.
/// @notice Only Staking Pallet Account could call this function.
/// @param collator The collator address to distribute reward.
function distributeReward(address collator) public payable onlySystem nonReentrant {
address pool = poolOf[collator];
require(pool != address(0), "!collator");
Expand Down
6 changes: 6 additions & 0 deletions src/deposit/Deposit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ contract Deposit is
_disableInitializers();
}

/// @dev Migrate user's deposit from Deposit Pallet to Deposit smart contract.
/// The amount of the deposit value must be passed in via msg.value.
/// @notice Only Deposit Pallet Account could call this function.
/// @param account The user account address stored in Deposit Pallet.
/// @param months The user deposit months stored in Deposit Pallet.
/// @param startAt The user deposit start time stored in Deposit Pallet.
function migrate(address account, uint64 months, uint64 startAt) external payable onlySystem nonReentrant {
uint256 value = msg.value;
require(value > 0 && value < type(uint128).max, "!value");
Expand Down

0 comments on commit 0ac6ff5

Please sign in to comment.