-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a857666
commit e076ca4
Showing
4 changed files
with
414 additions
and
2 deletions.
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
21 changes: 21 additions & 0 deletions
21
packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsFactory.sol
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,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "@openzeppelin/contracts/access/Ownable2Step.sol"; | ||
import "./InstantRewardsV2.sol"; | ||
|
||
contract InstantRewardsFactory is Ownable2Step { | ||
event InstantRewardsCreated(address indexed instantRewards, address indexed owner); | ||
|
||
function createInstantRewards( | ||
address signerAddress, | ||
uint256 start, | ||
uint256 end, | ||
string memory name | ||
) external returns (address) { | ||
InstantRewardsV2 instantRewards = new InstantRewardsV2(signerAddress, owner(), start, end, name); | ||
instantRewards.transferOwnership(owner()); | ||
emit InstantRewardsCreated(address(instantRewards), owner()); | ||
return address(instantRewards); | ||
} | ||
Check notice Code scanning / Slither Reentrancy vulnerabilities Low
Reentrancy in InstantRewardsFactory.createInstantRewards(address,uint256,uint256,string):
External calls: - instantRewards.transferOwnership(owner()) Event emitted after the call(s): - InstantRewardsCreated(address(instantRewards),owner()) |
||
} |
54 changes: 54 additions & 0 deletions
54
packages/zevm-app-contracts/contracts/instant-rewards/InstantRewardsV2.sol
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,54 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "./InstantRewards.sol"; | ||
|
||
contract InstantRewardsV2 is InstantRewards { | ||
string public name; | ||
|
||
uint256 public start; | ||
uint256 public end; | ||
|
||
event TimeframeUpdated(uint256 start, uint256 end); | ||
|
||
error InvalidTimeframe(); | ||
error InstantRewardNotActive(); | ||
error InstantRewardStillActive(); | ||
|
||
constructor( | ||
address signerAddress_, | ||
address owner, | ||
uint256 start_, | ||
uint256 end_, | ||
string memory name_ | ||
) InstantRewards(signerAddress_, owner) { | ||
if (signerAddress_ == address(0)) revert InvalidAddress(); | ||
if (start_ > end_) revert InvalidTimeframe(); | ||
start = start_; | ||
end = end_; | ||
name = name_; | ||
} | ||
|
||
function isActive() public view returns (bool) { | ||
return block.timestamp >= start && block.timestamp <= end; | ||
} | ||
Check notice Code scanning / Slither Block timestamp Low
InstantRewardsV2.isActive() uses timestamp for comparisons
Dangerous comparisons: - block.timestamp >= start && block.timestamp <= end |
||
|
||
function setTimeframe(uint256 start_, uint256 end_) external onlyOwner { | ||
if (start_ > end_) revert InvalidTimeframe(); | ||
if (start_ < block.timestamp || end_ < block.timestamp) revert InvalidTimeframe(); | ||
if (isActive()) revert InstantRewardStillActive(); | ||
start = start_; | ||
end = end_; | ||
emit TimeframeUpdated(start_, end_); | ||
} | ||
Check notice Code scanning / Slither Block timestamp Low
InstantRewardsV2.setTimeframe(uint256,uint256) uses timestamp for comparisons
Dangerous comparisons: - start_ < block.timestamp || end_ < block.timestamp |
||
|
||
function claim(ClaimData memory claimData) public override { | ||
if (!isActive()) revert InstantRewardNotActive(); | ||
super.claim(claimData); | ||
} | ||
|
||
function withdraw(address wallet, uint256 amount) public override { | ||
if (isActive()) revert InstantRewardStillActive(); | ||
super.withdraw(wallet, amount); | ||
} | ||
} |
Oops, something went wrong.