-
Notifications
You must be signed in to change notification settings - Fork 1
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
Audit fix #5
Merged
Merged
Audit fix #5
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bfd9894
use constant address
hujw77 8f3c33c
revert #3 and fix #4
hujw77 c081b7d
clean
hujw77 fc0af85
fix
hujw77 09988ca
deploy on pangolin
hujw77 7c68d57
Add RewardsDistribution
hujw77 3af5196
deploy on pangolin
hujw77 6a6b9b3
rm debug info
hujw77 ae858db
deploy for runtime
hujw77 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// hevm: flattened sources of src/RewardsDistribution.sol | ||
|
||
pragma solidity >=0.4.24 >=0.5.16 <0.6.0; | ||
|
||
////// src/Owned.sol | ||
/* pragma solidity ^0.5.16; */ | ||
|
||
|
||
// https://github.com/Synthetixio/synthetix/blob/v2.27.2/contracts/Owned.sol | ||
contract Owned { | ||
address public owner; | ||
address public nominatedOwner; | ||
|
||
constructor(address _owner) public { | ||
require(_owner != address(0), "Owner address cannot be 0"); | ||
owner = _owner; | ||
emit OwnerChanged(address(0), _owner); | ||
} | ||
|
||
function nominateNewOwner(address _owner) external onlyOwner { | ||
nominatedOwner = _owner; | ||
emit OwnerNominated(_owner); | ||
} | ||
|
||
function acceptOwnership() external { | ||
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); | ||
emit OwnerChanged(owner, nominatedOwner); | ||
owner = nominatedOwner; | ||
nominatedOwner = address(0); | ||
} | ||
|
||
modifier onlyOwner { | ||
require(msg.sender == owner, "Only the contract owner may perform this action"); | ||
_; | ||
} | ||
|
||
event OwnerNominated(address newOwner); | ||
event OwnerChanged(address oldOwner, address newOwner); | ||
} | ||
|
||
////// src/interfaces/IRewardsDistributionRecipient.sol | ||
/* pragma solidity >=0.4.24; */ | ||
|
||
interface IRewardsDistributionRecipient { | ||
function notifyRewardAmount() external payable; | ||
} | ||
|
||
////// src/RewardsDistribution.sol | ||
/* pragma solidity ^0.5.16; */ | ||
|
||
/* import "./Owned.sol"; */ | ||
/* import "./interfaces/IRewardsDistributionRecipient.sol"; */ | ||
|
||
contract RewardsDistribution is Owned { | ||
constructor(address _owner) public Owned(_owner) {} | ||
|
||
function() external payable {} | ||
|
||
function distributeRewards(address ktonStakingRewards, uint256 reward) external payable onlyOwner returns (bool) { | ||
require(reward > 0, "Nothing to distribute"); | ||
require( | ||
address(this).balance >= reward, "RewardsDistribution contract does not have enough tokens to distribute" | ||
); | ||
IRewardsDistributionRecipient(ktonStakingRewards).notifyRewardAmount.value(reward)(); | ||
emit RewardsDistributed(reward); | ||
return true; | ||
} | ||
|
||
event RewardsDistributed(uint256 amount); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
pragma solidity ^0.5.16; | ||
|
||
|
||
// https://github.com/Synthetixio/synthetix/blob/v2.27.2/contracts/Owned.sol | ||
contract Owned { | ||
address public owner; | ||
address public nominatedOwner; | ||
|
||
constructor(address _owner) public { | ||
require(_owner != address(0), "Owner address cannot be 0"); | ||
owner = _owner; | ||
emit OwnerChanged(address(0), _owner); | ||
} | ||
|
||
function nominateNewOwner(address _owner) external onlyOwner { | ||
nominatedOwner = _owner; | ||
emit OwnerNominated(_owner); | ||
} | ||
|
||
function acceptOwnership() external { | ||
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership"); | ||
emit OwnerChanged(owner, nominatedOwner); | ||
owner = nominatedOwner; | ||
nominatedOwner = address(0); | ||
} | ||
|
||
modifier onlyOwner { | ||
require(msg.sender == owner, "Only the contract owner may perform this action"); | ||
_; | ||
} | ||
|
||
event OwnerNominated(address newOwner); | ||
event OwnerChanged(address oldOwner, address newOwner); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
pragma solidity ^0.5.16; | ||
|
||
import "./Owned.sol"; | ||
import "./interfaces/IRewardsDistributionRecipient.sol"; | ||
|
||
contract RewardsDistribution is Owned { | ||
constructor(address _owner) public Owned(_owner) {} | ||
|
||
function() external payable {} | ||
|
||
function distributeRewards(address ktonStakingRewards, uint256 reward) external payable onlyOwner returns (bool) { | ||
require(reward > 0, "Nothing to distribute"); | ||
require( | ||
address(this).balance >= reward, "RewardsDistribution contract does not have enough tokens to distribute" | ||
); | ||
IRewardsDistributionRecipient(ktonStakingRewards).notifyRewardAmount.value(reward)(); | ||
emit RewardsDistributed(reward); | ||
return true; | ||
} | ||
|
||
event RewardsDistributed(uint256 amount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pragma solidity >=0.4.24; | ||
|
||
interface IRewardsDistributionRecipient { | ||
function notifyRewardAmount() external payable; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
ktonStakingRewards