Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds assertions to verify rewards contract balance, rewards surplus and weight #144

Merged
merged 18 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/L2/L2Reward.sol
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,9 @@ contract L2Reward is Initializable, Ownable2StepUpgradeable, UUPSUpgradeable, IS
/// @param duration Duration in days for which the daily rewards is to be added.
/// @param delay Determines the start day from today till duration for whom rewards should be added.
function _addRewards(uint256 amount, uint16 duration, uint16 delay) internal virtual {
require(delay > 0, "Funding should start from next day or later");
require(amount > 0, "L2Reward: Funded amount should be greater than zero");
require(duration > 0, "L2Reward: Funding duration should be greater than zero");
require(delay > 0, "L2Reward: Funding should start from next day or later");

uint256 dailyReward = amount / duration;
uint256 today = todayDay();
Expand All @@ -533,6 +535,8 @@ contract L2Reward is Initializable, Ownable2StepUpgradeable, UUPSUpgradeable, IS
/// @param duration Duration in days for which the daily rewards is to be added.
/// @param delay Determines the start day from today till duration from which rewards should be added.
function addUnusedRewards(uint256 amount, uint16 duration, uint16 delay) public virtual onlyOwner {
require(amount > 0, "L2Reward: Funded amount should be greater than zero");
require(duration > 0, "L2Reward: Funding duration should be greater than zero");
require(delay > 0, "L2Reward: Rewards can only be added from next day or later");
require(amount <= rewardsSurplus, "L2Reward: Reward amount should not exceed available surplus funds");

Expand All @@ -548,6 +552,8 @@ contract L2Reward is Initializable, Ownable2StepUpgradeable, UUPSUpgradeable, IS
/// @param duration Duration in days for which the daily rewards is to be added.
/// @param delay Determines the start day from today till duration for which rewards should be added.
function fundStakingRewards(uint256 amount, uint16 duration, uint16 delay) public virtual onlyOwner {
require(amount > 0, "L2Reward: Funded amount should be greater than zero");
require(duration > 0, "L2Reward: Funding duration should be greater than zero");
require(delay > 0, "L2Reward: Funding should start from next day or later");

IL2LiskToken(l2TokenContract).transferFrom(msg.sender, address(this), amount);
Expand Down
Loading
Loading