Skip to content

Commit

Permalink
issue ERC20 staking rewards (native TBD)
Browse files Browse the repository at this point in the history
  • Loading branch information
feuGeneA committed Sep 6, 2024
1 parent 0b2a5d5 commit 0900e50
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 2 deletions.
5 changes: 5 additions & 0 deletions contracts/staking/ERC20TokenStakingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,9 @@ contract ERC20TokenStakingManager is
function _unlock(uint256 value, address to) internal virtual override {
_getERC20StakingManagerStorage()._token.safeTransfer(to, value);
}

function _reward(address account, uint256 amount) internal virtual override {
ERC20TokenStakingManagerStorage storage $ = _getERC20StakingManagerStorage();
$._token.mint(account, amount);
}
}
5 changes: 5 additions & 0 deletions contracts/staking/NativeTokenStakingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@ contract NativeTokenStakingManager is
function _unlock(uint256 value, address to) internal virtual override {
payable(to).sendValue(value);
}

// solhint-disable-next-line no-empty-blocks
function _reward(address account, uint256 amount) internal virtual override {
// TODO: call the native minter precompile to mint `amount` for `account`
}
}
9 changes: 9 additions & 0 deletions contracts/staking/PoSValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ abstract contract PoSValidatorManager is IPoSValidatorManager, ValidatorManager

function completeEndValidation(uint32 messageIndex) external {
Validator memory validator = _completeEndValidation(messageIndex);

PoSValidatorManagerStorage storage $ = _getPoSValidatorManagerStorage();
uint256 rewardAmount = $._rewardCalculator.calculateReward(
validator.weight, validator.startedAt, validator.endedAt, 0, 0
);

_reward(validator.owner, rewardAmount);

_unlock(validator.weight, validator.owner);
}

Expand Down Expand Up @@ -136,4 +144,5 @@ abstract contract PoSValidatorManager is IPoSValidatorManager, ValidatorManager

function _lock(uint256 value) internal virtual returns (uint256);
function _unlock(uint256 value, address to) internal virtual;
function _reward(address account, uint256 amount) internal virtual;
}
Loading

0 comments on commit 0900e50

Please sign in to comment.