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

fmt #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
21 changes: 9 additions & 12 deletions src/KTONStakingRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, Reentr

/* ========== CONSTRUCTOR ========== */

constructor(
address _rewardsDistribution,
address _stakingToken
) public {
constructor(address _rewardsDistribution, address _stakingToken) public {
stakingToken = IERC20(_stakingToken);
rewardsDistribution = _rewardsDistribution;
}
Expand All @@ -57,14 +54,15 @@ contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, Reentr
if (_totalSupply == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)
);
return rewardPerTokenStored.add(
lastTimeRewardApplicable().sub(lastUpdateTime).mul(rewardRate).mul(1e18).div(_totalSupply)
);
}

function earned(address account) public view returns (uint256) {
return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(rewards[account]);
return _balances[account].mul(rewardPerToken().sub(userRewardPerTokenPaid[account])).div(1e18).add(
rewards[account]
);
}

function getRewardForDuration() external view returns (uint256) {
Expand Down Expand Up @@ -93,7 +91,7 @@ contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, Reentr
uint256 reward = rewards[msg.sender];
if (reward > 0) {
rewards[msg.sender] = 0;
(bool success, ) = msg.sender.call.value(reward)("");
(bool success,) = msg.sender.call.value(reward)("");
require(success, "Transfer failed");
emit RewardPaid(msg.sender, reward);
}
Expand All @@ -119,7 +117,7 @@ contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, Reentr
// This keeps the reward rate in the right range, preventing overflows due to
// very high values of rewardRate in the earned and rewardsPerToken functions;
// Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
uint balance = address(this).balance;
uint256 balance = address(this).balance;
require(rewardRate <= balance.div(rewardsDuration), "Provided reward too high");

lastUpdateTime = block.timestamp;
Expand All @@ -146,4 +144,3 @@ contract StakingRewards is IStakingRewards, RewardsDistributionRecipient, Reentr
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
}

1 change: 0 additions & 1 deletion src/interfaces/IStakingRewards.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
pragma solidity >=0.4.24;


interface IStakingRewards {
// Views
function lastTimeRewardApplicable() external view returns (uint256);
Expand Down
Loading