Skip to content

Commit 31dc128

Browse files
committed
fix nexugenerator
1 parent 059e93b commit 31dc128

4 files changed

Lines changed: 31 additions & 6 deletions

File tree

contracts/NexusGenerator.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
pragma solidity ^0.8.12;
33

44
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
5+
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
56
import "./NexusToken.sol";
67
import "./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);

scripts/mainnet/extra_deploy.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as dotenv from "dotenv";
2+
import { deployContract } from '../utils';
3+
import { parseEther } from "ethers/lib/utils";
4+
5+
dotenv.config();
6+
7+
const nexusTokenaddress = "0x6DaF228391e388B05BBc682FEA3CB1Cc3E38c44E"
8+
const multiStakingDistributor = "0xa96d4Dfb9EED8824cae29fA0b7e62c72b5e51018";
9+
const nexusPerBlock = parseEther("0");
10+
const startBlock = 0
11+
const bonusEndBlock = 0
12+
13+
14+
async function main() {
15+
// await deployContract("Multicall2", [], "Mocks");
16+
const nexusGenerator = await deployContract("NexusGenerator", [nexusTokenaddress, multiStakingDistributor, nexusPerBlock, startBlock, bonusEndBlock], "")
17+
}
18+
19+
main().catch((error) => {
20+
console.error(error);
21+
process.exitCode = 1;
22+
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
NexusGenerator : 0x8Ad2D1A537fe16d1C619fD877a26FA584798107f
1+
NexusGenerator : 0x265287f794e956cFAF66297515BFF34631bB625c

scripts/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export const deployContract = async function (name: string, params: any, periphe
1515
let address = factory.address
1616
await contract.deployTransaction.wait(5);
1717

18+
console.log(name, address)
19+
1820
fs.mkdirSync(`scripts/params`, { recursive: true });
1921
fs.mkdirSync(`scripts/result`, { recursive: true });
2022
const outputCodes = `module.exports = ${JSON.stringify(params)}`

0 commit comments

Comments
 (0)