22pragma solidity ^ 0.8.12 ;
33
44import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol " ;
5+ import "@openzeppelin/contracts/security/ReentrancyGuard.sol " ;
56import "./NexusToken.sol " ;
67import "./Utils/MultiOwnable.sol " ;
78
8- contract NexusGenerator is MultiOwnable {
9+ contract NexusGenerator is MultiOwnable , ReentrancyGuard {
910 using SafeMath for uint256 ;
1011
1112 using SafeERC20 for IERC20 ;
@@ -444,7 +445,7 @@ contract NexusGenerator is MultiOwnable {
444445 }
445446
446447 // Deposit LP tokens to NexusGenerator for NXS allocation.
447- function depositLP (uint256 _pid , uint256 _amount ) public {
448+ function depositLP (uint256 _pid , uint256 _amount ) public nonReentrant {
448449 PoolInfo storage pool = poolInfo[_pid];
449450 UserInfo storage user = userInfo[_pid][msg .sender ];
450451 uint256 rtLen = rewardTokenInfo[_pid].length ;
@@ -478,7 +479,7 @@ contract NexusGenerator is MultiOwnable {
478479 uint256 _pid ,
479480 IERC20 _rewardToken ,
480481 uint256 _depositAmount
481- ) public {
482+ ) public nonReentrant {
482483 require (_pid < poolLength (), "Non Exist Pool " );
483484 uint256 _rid = getRewardTokenId (_pid, _rewardToken);
484485 require (_rid < rewardTokenInfo[_pid].length , "No reward token setting " );
@@ -505,7 +506,7 @@ contract NexusGenerator is MultiOwnable {
505506 }
506507
507508 // Withdraw LP tokens from NexusGenerator.
508- function withdraw (uint256 _pid , uint256 _amount ) public {
509+ function withdraw (uint256 _pid , uint256 _amount ) public nonReentrant {
509510 PoolInfo storage pool = poolInfo[_pid];
510511 UserInfo storage user = userInfo[_pid][msg .sender ];
511512 uint256 rtLen = rewardTokenInfo[_pid].length ;
@@ -533,7 +534,7 @@ contract NexusGenerator is MultiOwnable {
533534 }
534535
535536 // Withdraw without caring about rewards. EMERGENCY ONLY.
536- function emergencyWithdrawLP (uint256 _pid ) public {
537+ function emergencyWithdrawLP (uint256 _pid ) public nonReentrant {
537538 PoolInfo storage pool = poolInfo[_pid];
538539 UserInfo storage user = userInfo[_pid][msg .sender ];
539540 pool.lpToken.safeTransfer (address (msg .sender ), user.amount);
0 commit comments