Skip to content

Commit 5f96df4

Browse files
committed
fix some issues
1 parent bfaddf1 commit 5f96df4

17 files changed

Lines changed: 48 additions & 16180 deletions

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
node_modules
2-
flatten
32
scripts
43
test/
54
.env
@@ -8,11 +7,13 @@ coverage.json
87
typechain
98
typechain-types
109
package-lock.json
11-
yarn.lock
10+
# yarn.lock
11+
flatten
1212

1313
#Hardhat files
1414
cache
1515
artifacts
1616

1717
yarn.lock
1818
yarn.lock
19+

contracts/NexusDiffuser.sol

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ contract NexusDiffuser is Ownable {
7171
_;
7272
}
7373

74-
constructor (
75-
address _factory,
76-
address _nexus,
77-
address _weth
78-
) {
74+
constructor(address _factory, address _nexus, address _weth) {
7975
factory = IUniswapV2Factory(_factory);
8076
nexus = _nexus;
8177
weth = _weth;
@@ -211,6 +207,7 @@ contract NexusDiffuser is Ownable {
211207
address[] calldata token1
212208
) external onlyEOA onlyHolder {
213209
// TODO: This can be optimized a fair bit, but this is safer and simpler for now
210+
require(token0.length == token1.length, "Not same length");
214211
uint256 len = token0.length;
215212
for (uint256 i = 0; i < len; i++) {
216213
_convert(token0[i], token1[i]);
@@ -321,10 +318,7 @@ contract NexusDiffuser is Ownable {
321318
IUniswapV2Pair pair = IUniswapV2Pair(
322319
factory.getPair(fromToken, toToken)
323320
);
324-
require(
325-
address(pair) != address(0),
326-
"NexusDiffuser: Cannot convert"
327-
);
321+
require(address(pair) != address(0), "NexusDiffuser: Cannot convert");
328322

329323
// Interactions
330324
(uint256 reserve0, uint256 reserve1, ) = pair.getReserves();
@@ -359,7 +353,6 @@ contract NexusDiffuser is Ownable {
359353
uint256 amountIn
360354
) internal returns (uint256 amountOut) {
361355
if (nexusTreasury != address(0)) {
362-
363356
uint256 treasuryAmount = _swap(
364357
token,
365358
nexus,
@@ -376,7 +369,9 @@ contract NexusDiffuser is Ownable {
376369
amountIn.mul(2).div(10),
377370
multiStakingGetter
378371
);
379-
nexusMultiStakingTotalAmount = nexusMultiStakingTotalAmount.add(multiStakingAmount);
372+
nexusMultiStakingTotalAmount = nexusMultiStakingTotalAmount.add(
373+
multiStakingAmount
374+
);
380375

381376
uint256 burnAmount = _swap(
382377
token,
@@ -399,7 +394,9 @@ contract NexusDiffuser is Ownable {
399394
amountIn.mul(3).div(10),
400395
multiStakingGetter
401396
);
402-
nexusMultiStakingTotalAmount = nexusMultiStakingTotalAmount.add(multiStakingAmount);
397+
nexusMultiStakingTotalAmount = nexusMultiStakingTotalAmount.add(
398+
multiStakingAmount
399+
);
403400

404401
uint256 burnAmount = _swap(
405402
token,
@@ -419,18 +416,12 @@ contract NexusDiffuser is Ownable {
419416
}
420417

421418
function setNexusTreasury(address _treasury) external {
422-
require(
423-
msg.sender == nexusTreasurySetter,
424-
"NexusDiffuser: FORBIDDEN"
425-
);
419+
require(msg.sender == nexusTreasurySetter, "NexusDiffuser: FORBIDDEN");
426420
nexusTreasury = _treasury;
427421
}
428422

429423
function setNexusTreasurySetter(address _nexusTreasurySetter) external {
430-
require(
431-
msg.sender == nexusTreasurySetter,
432-
"NexusDiffuser: FORBIDDEN"
433-
);
424+
require(msg.sender == nexusTreasurySetter, "NexusDiffuser: FORBIDDEN");
434425
nexusTreasurySetter = _nexusTreasurySetter;
435426
}
436427

contracts/NexusGenerator.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ contract NexusGenerator is MultiOwnable {
380380
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
381381
if (lpSupply == 0) {
382382
rtInfo.lastRewardTimestamp = type(uint256).max;
383-
rtInfo.rewardDuration == 0;
383+
rtInfo.rewardDuration = 0;
384384
return;
385385
}
386386
uint256 rewardDuration;

contracts/NexusNFT.sol

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ contract NexusEtherealsNFT is ERC721Enumerable, Ownable {
3030
uint256 public whitelistCount;
3131
bool public whitelistEnabled = true;
3232

33-
event AddressAdded(address indexed _address);
33+
event AddressAdded(address[] indexed _addresses);
3434
event AddressRemoved(address indexed _address);
3535
event WhitelistToggled(bool _enabled);
3636

@@ -56,26 +56,15 @@ contract NexusEtherealsNFT is ERC721Enumerable, Ownable {
5656
require(!paused, "the contract is paused");
5757
uint256 supply = totalSupply();
5858
require(_mintAmount > 0, "need to mint at least 1 NFT");
59-
require(
60-
_mintAmount <= maxMintAmount,
61-
"max mint amount per session exceeded"
62-
);
59+
require(_mintAmount <= maxMintAmount,"max mint amount per session exceeded");
6360
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
6461

6562
uint256 costToMint = isWhitelisted(msg.sender) && whitelistEnabled
66-
? cost - whitelistDiscount
67-
: cost;
63+
? cost - whitelistDiscount : cost;
6864

6965
if (msg.sender != owner()) {
70-
require(
71-
msg.value >= costToMint * _mintAmount,
72-
"insufficient funds"
73-
);
74-
require(
75-
addressMintedBalance[msg.sender] + _mintAmount <=
76-
maxNFTPerAddress,
77-
"max NFT per address exceeded"
78-
);
66+
require(msg.value >= costToMint * _mintAmount,"insufficient funds");
67+
require(addressMintedBalance[msg.sender] + _mintAmount <=maxNFTPerAddress,"max NFT per address exceeded");
7968
}
8069

8170
for (uint256 i = 1; i <= _mintAmount; i++) {
@@ -180,7 +169,6 @@ contract NexusEtherealsNFT is ERC721Enumerable, Ownable {
180169
whitelist[_addresses[i]] = true;
181170
whitelistIndices[_addresses[i]] = whitelistCount;
182171
whitelistCount++;
183-
emit AddressAdded(_addresses[i]);
184172
}
185173
}
186174
}

contracts/Referral.sol

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,10 @@ interface INexusEtherealsNFT {
1919

2020
function mint(uint256 _mintAmount) external payable;
2121

22-
function transferFrom(
23-
address from,
24-
address to,
25-
uint256 tokenId
26-
) external;
22+
function transferFrom(address from, address to, uint256 tokenId) external;
2723
}
2824

29-
contract NFTReferral is IERC721Receiver {
25+
contract NFTReferral is IERC721Receiver, Ownable {
3026
address public nexusNFT;
3127

3228
event ReferralUsed(
@@ -57,11 +53,7 @@ contract NFTReferral is IERC721Receiver {
5753

5854
NFT.mint{value: mintPrice * _mintamount}(_mintamount);
5955
for (uint256 i = 1; i <= _mintamount; i++) {
60-
NFT.transferFrom(
61-
address(this),
62-
msg.sender,
63-
curTokenSupply + i
64-
);
56+
NFT.transferFrom(address(this), msg.sender, curTokenSupply + i);
6557
}
6658
uint256 reward = msg.value - mintPrice * _mintamount;
6759
if (reward > 0) {
@@ -70,6 +62,15 @@ contract NFTReferral is IERC721Receiver {
7062
}
7163
}
7264

65+
function withdraw(address to) public onlyOwner {
66+
// =============================================================================
67+
// Do not remove this otherwise you will not be able to withdraw the funds.
68+
// =============================================================================
69+
(bool os, ) = payable(to).call{value: address(this).balance}("");
70+
require(os);
71+
// =============================================================================
72+
}
73+
7374
function onERC721Received(
7475
address,
7576
address,

0 commit comments

Comments
 (0)