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

[Feature] Init ERC721 pool #17

Merged
merged 14 commits into from
May 14, 2024
Merged

Conversation

ayodeko
Copy link
Contributor

@ayodeko ayodeko commented May 6, 2024

No description provided.

@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

Comment on lines +174 to +186
function _getMultiplier(
uint256 _from,
uint256 _to
) internal view returns (uint256) {
if (_from > pool.endTime) {
return 0;
}
if (_to <= pool.endTime) {
return _to - _from;
} else {
return pool.endTime - _from;
}
}

Check notice

Code scanning / Slither

Block timestamp Low

ERC721LockUpPool._getMultiplier(uint256,uint256) uses timestamp for comparisons
Dangerous comparisons:
- _from > pool.endTime
- _to <= pool.endTime
Comment on lines 29 to 54
constructor(
address stakeToken,
address rewardToken,
uint256 rewardTokenPerSecond,
uint256 poolStartTime,
uint256 poolEndTime,
uint256 unstakeLockupTime,
uint256 claimLockUpTime
) Ownable(msg.sender) {
// Ensure the staking period is valid
if (poolStartTime > poolEndTime) revert InvalidStakingPeriod();
// Ensure the start time is in the future
if (poolStartTime < block.timestamp) revert InvalidStartTime();
// Ensure the lockup periods are valid
if (unstakeLockupTime > poolEndTime || claimLockUpTime > poolEndTime)
revert InvalidLockupTime();

pool.stakeToken = IERC721(stakeToken);
pool.rewardToken = IERC20(rewardToken);
pool.startTime = poolStartTime;
pool.endTime = poolEndTime;
pool.unstakeLockupTime = unstakeLockupTime;
pool.claimLockupTime = claimLockUpTime;
pool.rewardTokenPerSecond = rewardTokenPerSecond;
pool.lastUpdateTimestamp = block.timestamp;
}

Check notice

Code scanning / Slither

Block timestamp Low

Comment on lines 125 to 152
function claim() external nonReentrant {
// Check if the current timestamp is before the claim lockup time
if (block.timestamp < pool.claimLockupTime)
revert TokensInLockup(block.timestamp, pool.claimLockupTime);

// Update the pool
_updatePool();

// Get user information
UserInfo storage user = userInfo[msg.sender];
uint256 amount = user.amount;
uint256 pending = user.pending;

// Calculate pending rewards
if (amount > 0) {
pending += (amount * pool.accRewardPerShare) - user.rewardDebt;
user.rewardDebt = (user.amount * pool.accRewardPerShare);
}
if (pending == 0) revert NothingToClaim();
// Transfer pending rewards to the user
user.pending = 0;
unchecked {
user.claimed += pending;
}
pool.totalClaimed += pending;
pool.rewardToken.safeTransfer(msg.sender, pending);
emit Claim(msg.sender, pending);
}

Check notice

Code scanning / Slither

Block timestamp Low

ERC721LockUpPool.claim() uses timestamp for comparisons
Dangerous comparisons:
- block.timestamp < pool.claimLockupTime
- pending > 0
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slither found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@SergeyPoslavskiy SergeyPoslavskiy merged commit 3057de7 into develop May 14, 2024
4 checks passed
@SergeyPoslavskiy SergeyPoslavskiy linked an issue May 14, 2024 that may be closed by this pull request
@Alina1906 Alina1906 linked an issue May 14, 2024 that may be closed by this pull request
@SergeyPoslavskiy SergeyPoslavskiy deleted the feature/erc721lockupstakingpool branch July 10, 2024 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Implement ERC721LockUpPool Implement ERC721NoLockUpPool
2 participants