Skip to content

Commit

Permalink
revert #3 and fix #4
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Feb 20, 2024
1 parent bfd9894 commit 8f3c33c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 19 deletions.
32 changes: 32 additions & 0 deletions flat/IStakingRewards.f.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// hevm: flattened sources of src/interfaces/IStakingRewards.sol

pragma solidity >=0.4.24;

////// src/interfaces/IStakingRewards.sol
/* pragma solidity >=0.4.24; */

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

function rewardPerToken() external view returns (uint256);

function earned(address account) external view returns (uint256);

function getRewardForDuration() external view returns (uint256);

function totalSupply() external view returns (uint256);

function balanceOf(address account) external view returns (uint256);

// Mutative

function stake(uint256 amount) external;

function withdraw(uint256 amount) external;

function getReward() external;

function exit() external;
}

18 changes: 5 additions & 13 deletions flat/KTONStakingRewards.f.sol
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,10 @@ contract ReentrancyGuard {
/* pragma solidity ^0.5.16; */

contract RewardsDistributionRecipient {
address public rewardsDistribution;
// "sc/ktnstk" in bytes.
address public constant rewardsDistribution = 0x73632F6b746e73746B0000000000000000000000;

function notifyRewardAmount() external payable;
function notifyRewardAmount() external;

modifier onlyRewardsDistribution() {
require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract");
Expand Down Expand Up @@ -483,7 +484,7 @@ contract KTONStakingRewards is IStakingRewards, RewardsDistributionRecipient, Re

/* ========== STATE VARIABLES ========== */

IERC20 public stakingToken;
IERC20 public constant stakingToken = IERC20(0x0000000000000000000000000000000000000402);
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public rewardsDuration = 7200;
Expand All @@ -496,13 +497,6 @@ contract KTONStakingRewards is IStakingRewards, RewardsDistributionRecipient, Re
uint256 private _totalSupply;
mapping(address => uint256) private _balances;

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

constructor(address _rewardsDistribution, address _stakingToken) public {
stakingToken = IERC20(_stakingToken);
rewardsDistribution = _rewardsDistribution;
}

/* ========== VIEWS ========== */

function totalSupply() external view returns (uint256) {
Expand Down Expand Up @@ -570,9 +564,7 @@ contract KTONStakingRewards is IStakingRewards, RewardsDistributionRecipient, Re

/* ========== RESTRICTED FUNCTIONS ========== */

function notifyRewardAmount() external payable onlyRewardsDistribution updateReward(address(0)) {
uint256 reward = msg.value;
require(reward >= rewardsDuration, "Provided reward too low");
function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) {
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(rewardsDuration);
} else {
Expand Down
19 changes: 19 additions & 0 deletions flat/RewardsDistributionRecipient.f.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// hevm: flattened sources of src/RewardsDistributionRecipient.sol

pragma solidity >=0.5.16 <0.6.0;

////// src/RewardsDistributionRecipient.sol
/* pragma solidity ^0.5.16; */

contract RewardsDistributionRecipient {
// "sc/ktnstk" in bytes.
address public constant rewardsDistribution = 0x73632F6b746e73746B0000000000000000000000;

function notifyRewardAmount() external;

modifier onlyRewardsDistribution() {
require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract");
_;
}
}

4 changes: 1 addition & 3 deletions src/KTONStakingRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ contract KTONStakingRewards is IStakingRewards, RewardsDistributionRecipient, Re

/* ========== RESTRICTED FUNCTIONS ========== */

function notifyRewardAmount() external payable onlyRewardsDistribution updateReward(address(0)) {
uint256 reward = msg.value;
require(reward >= rewardsDuration, "Provided reward too low");
function notifyRewardAmount(uint256 reward) external onlyRewardsDistribution updateReward(address(0)) {
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(rewardsDuration);
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/RewardsDistributionRecipient.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pragma solidity ^0.5.16;

contract RewardsDistributionRecipient {
// "KTONStakingRewards" in bytes.
address public constant rewardsDistribution = 0x4b544f4e5374616b696e67526577617264730000;
// "sc/ktnstk" in bytes.
address public constant rewardsDistribution = 0x73632F6b746e73746B0000000000000000000000;

function notifyRewardAmount() external payable;
function notifyRewardAmount() external;

modifier onlyRewardsDistribution() {
require(msg.sender == rewardsDistribution, "Caller is not RewardsDistribution contract");
Expand Down

0 comments on commit 8f3c33c

Please sign in to comment.