diff --git a/contracts/CrowdPooling/impl/CPVesting.sol b/contracts/CrowdPooling/impl/CPVesting.sol index 5c040d2..80e6ab8 100644 --- a/contracts/CrowdPooling/impl/CPVesting.sol +++ b/contracts/CrowdPooling/impl/CPVesting.sol @@ -82,8 +82,8 @@ contract CPVesting is CPFunding { function _claimBaseToken(address to) internal { uint256 claimableBaseAmount = getClaimableBaseToken(msg.sender); - _transferBaseOut(to, claimableBaseAmount); _CLAIMED_BASE_TOKEN_[msg.sender] = _CLAIMED_BASE_TOKEN_[msg.sender].add(claimableBaseAmount); + _transferBaseOut(to, claimableBaseAmount); emit ClaimBaseToken(msg.sender, claimableBaseAmount); } diff --git a/contracts/CrowdPooling/intf/ICP.sol b/contracts/CrowdPooling/intf/ICP.sol index 350b41a..38de9e8 100644 --- a/contracts/CrowdPooling/intf/ICP.sol +++ b/contracts/CrowdPooling/intf/ICP.sol @@ -24,9 +24,5 @@ interface ICP { function emergencySettle() external; - function claimBaseToken() external; - - function ClaimQuoteToken(address to,bytes calldata data) external; - function claimLPToken() external; } diff --git a/contracts/DODOStarter/impl/FairFunding.sol b/contracts/DODOStarter/impl/FairFunding.sol index 80a1e91..027418e 100644 --- a/contracts/DODOStarter/impl/FairFunding.sol +++ b/contracts/DODOStarter/impl/FairFunding.sol @@ -168,7 +168,7 @@ contract FairFunding is Vesting { // ============ Settle Functions ============ - function settle() public isForceStop preventReentrant { + function settle() public isNotForceStop preventReentrant { require(_FINAL_PRICE_ == 0 && isFundingEnd(), "CAN_NOT_SETTLE"); _FINAL_PRICE_ = getCurrentPrice(); if(_TOTAL_RAISED_FUNDS_ == 0) { @@ -187,7 +187,7 @@ contract FairFunding is Vesting { // ============ Funding Functions ============ - function depositFunds(address to) external preventReentrant isForceStop returns(uint256 inputFund) { + function depositFunds(address to) external preventReentrant isNotForceStop returns(uint256 inputFund) { require(isDepositOpen(), "DEPOSIT_NOT_OPEN"); uint256 currentFundBalance = IERC20(_FUNDS_ADDRESS_).balanceOf(address(this)); diff --git a/contracts/DODOStarter/impl/InstantFunding.sol b/contracts/DODOStarter/impl/InstantFunding.sol index 6bdf00e..6a5b9f7 100644 --- a/contracts/DODOStarter/impl/InstantFunding.sol +++ b/contracts/DODOStarter/impl/InstantFunding.sol @@ -142,7 +142,7 @@ contract InstantFunding is Vesting { function depositFunds(address to) external preventReentrant - isForceStop + isNotForceStop returns (uint256 newTokenAllocation) { require(isDepositOpen(), "DEPOSIT_NOT_OPEN"); diff --git a/contracts/DODOStarter/impl/Storage.sol b/contracts/DODOStarter/impl/Storage.sol index 65806a5..d338d84 100644 --- a/contracts/DODOStarter/impl/Storage.sol +++ b/contracts/DODOStarter/impl/Storage.sol @@ -12,9 +12,11 @@ import {InitializableOwnable} from "../../lib/InitializableOwnable.sol"; import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol"; import {SafeMath} from "../../lib/SafeMath.sol"; import {IERC20} from "../../intf/IERC20.sol"; +import {SafeERC20} from "../../lib/SafeERC20.sol"; contract Storage is InitializableOwnable, ReentrancyGuard { using SafeMath for uint256; + using SafeERC20 for IERC20; bool public _FORCE_STOP_ = false; address public _QUOTA_; @@ -58,7 +60,7 @@ contract Storage is InitializableOwnable, ReentrancyGuard { // ============ Modifiers ============ - modifier isForceStop() { + modifier isNotForceStop() { require(!_FORCE_STOP_, "FORCE_STOP"); _; } @@ -69,6 +71,6 @@ contract Storage is InitializableOwnable, ReentrancyGuard { _FORCE_STOP_ = true; _TOTAL_TOKEN_AMOUNT_ = 0; uint256 tokenAmount = IERC20(_TOKEN_ADDRESS_).balanceOf(address(this)); - IERC20(_TOKEN_ADDRESS_).transfer(_OWNER_, tokenAmount); + IERC20(_TOKEN_ADDRESS_).safeTransfer(_OWNER_, tokenAmount); } } \ No newline at end of file diff --git a/contracts/DODOStarter/impl/Vesting.sol b/contracts/DODOStarter/impl/Vesting.sol index 8bc61d3..de94a4c 100644 --- a/contracts/DODOStarter/impl/Vesting.sol +++ b/contracts/DODOStarter/impl/Vesting.sol @@ -52,6 +52,8 @@ contract Vesting is Storage { cliffRate = _LP_CLIFF_RATE_; } + require(timestamp >= vestingStart, "NOT_START_TO_CLAIM"); + uint256 timePast = timestamp.sub(vestingStart); if (timePast < vestingDuration) { uint256 remainingTime = vestingDuration.sub(timePast); @@ -94,12 +96,12 @@ contract Vesting is Storage { DecimalMath.ONE, isOpenTWAP ); - IERC20(_TOKEN_ADDRESS_).transferFrom(msg.sender, _INITIAL_POOL_, initialTokenAmount); + IERC20(_TOKEN_ADDRESS_).safeTransferFrom(msg.sender, _INITIAL_POOL_, initialTokenAmount); if(totalUsedRaiseFunds > _INITIAL_FUND_LIQUIDITY_) { - IERC20(_FUNDS_ADDRESS_).transfer(_INITIAL_POOL_, _INITIAL_FUND_LIQUIDITY_); + IERC20(_FUNDS_ADDRESS_).safeTransfer(_INITIAL_POOL_, _INITIAL_FUND_LIQUIDITY_); }else { - IERC20(_FUNDS_ADDRESS_).transfer(_INITIAL_POOL_, totalUsedRaiseFunds); + IERC20(_FUNDS_ADDRESS_).safeTransfer(_INITIAL_POOL_, totalUsedRaiseFunds); } (_TOTAL_LP_, , ) = IDVM(_INITIAL_POOL_).buyShares(address(this)); diff --git a/contracts/Factory/DODOStarterFactory.sol b/contracts/Factory/DODOStarterFactory.sol index 797f839..d3e6402 100644 --- a/contracts/Factory/DODOStarterFactory.sol +++ b/contracts/Factory/DODOStarterFactory.sol @@ -12,6 +12,7 @@ import {InitializableOwnable} from "../lib/InitializableOwnable.sol"; import {ICloneFactory} from "../lib/CloneFactory.sol"; import {SafeMath} from "../lib/SafeMath.sol"; import {IERC20} from "../intf/IERC20.sol"; +import {SafeERC20} from "../lib/SafeERC20.sol"; import {DecimalMath} from "../lib/DecimalMath.sol"; import {IDODOStarter} from "../DODOStarter/intf/IDODOStarter.sol"; @@ -23,6 +24,8 @@ import {IDODOStarter} from "../DODOStarter/intf/IDODOStarter.sol"; */ contract DODOStarterFactory is InitializableOwnable { using SafeMath for uint256; + using SafeERC20 for IERC20; + // ============ Templates ============ address public immutable _CLONE_FACTORY_; @@ -83,7 +86,7 @@ contract DODOStarterFactory is InitializableOwnable { ) external payable permissionCheck(addressList[0],addressList[1]) returns(address newFairFundPool){ newFairFundPool = ICloneFactory(_CLONE_FACTORY_).clone(_FAIR_FUND_TEMPLATE_); - IERC20(addressList[1]).transferFrom(msg.sender, newFairFundPool,sellTokenAmount); + IERC20(addressList[1]).safeTransferFrom(msg.sender, newFairFundPool,sellTokenAmount); (bool success, ) = newFairFundPool.call{value: msg.value}(""); require(success, "Settle fund Transfer failed"); @@ -107,7 +110,7 @@ contract DODOStarterFactory is InitializableOwnable { ) external permissionCheck(addressList[0],addressList[1]) returns(address newInstantFundPool){ newInstantFundPool = ICloneFactory(_CLONE_FACTORY_).clone(_INSTANT_FUND_TEMPLATE_); - IERC20(addressList[1]).transferFrom(msg.sender, newInstantFundPool,sellTokenAmount); + IERC20(addressList[1]).safeTransferFrom(msg.sender, newInstantFundPool,sellTokenAmount); IDODOStarter(newInstantFundPool).init( addressList, diff --git a/migrations/4_deploy_periphery.js b/migrations/4_deploy_periphery.js index ee710f2..856bad8 100644 --- a/migrations/4_deploy_periphery.js +++ b/migrations/4_deploy_periphery.js @@ -16,6 +16,7 @@ const DODOToken = artifacts.require("DODOToken"); const UpCrowdPoolingFactory = artifacts.require("UpCrowdPoolingFactory"); const CpFactory = artifacts.require("CrowdPoolingFactory"); const MultiCall = artifacts.require("Multicall"); +const UserQuota = artifacts.require("UserQuota"); const LockedTokenVault = artifacts.require("LockedTokenVault"); const DODORouteProxy = artifacts.require("DODORouteProxy"); const DODOCpProxy = artifacts.require("DODOCpProxy"); @@ -303,6 +304,12 @@ module.exports = async (deployer, network, accounts) => { logger.log("MultiCallAddress: ", MultiCallAddress); } + if (deploySwitch.UserQuota) { + await deployer.deploy(UserQuota); + UserQuotaAddress = UserQuota.address; + logger.log("UserQuotaAddress: ", UserQuotaAddress); + } + if (deploySwitch.CPFactory) { logger.log("===================================================="); logger.log("network type: " + network); diff --git a/package.json b/package.json index d2fdba8..0fd043c 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "solc": "^0.6.9", "ts-node": "^8.10.2", "typescript": "^3.9.5", - "web3": "^1.2.9", + "web3": "^1.2.8", "web3-core-helpers": "^1.2.8", "web3-eth-contract": "^1.2.8" }, @@ -55,7 +55,6 @@ "prettier": "^2.0.5", "prettier-plugin-solidity": "^1.0.0-alpha.52", "solidity-coverage": "^0.7.7", - "truffle-assertions": "^0.9.2", - "web3-provider-engine": "~15.0.12" + "truffle-assertions": "^0.9.2" } } diff --git a/truffle-config.js b/truffle-config.js index a9c85e4..ce28c3a 100755 --- a/truffle-config.js +++ b/truffle-config.js @@ -19,7 +19,6 @@ */ var HDWalletProvider = require("@truffle/hdwallet-provider"); -const NonceTrackerSubprovider = require('web3-provider-engine/subproviders/nonce-tracker') var privKey = process.env.privKey; var infuraId = process.env.infuraId; @@ -104,7 +103,9 @@ module.exports = { gas: 10000000, gasPrice: 1500000000, network_id: 4, - skipDryRun: true + skipDryRun: true, + confirmations: 2, + timeoutBlocks: 200, }, live: { @@ -120,8 +121,9 @@ module.exports = { bsclive: { provider: function () { - return new HDWalletProvider(privKey, "https://bsc-dataseed1.binance.org"); + return new HDWalletProvider(privKey, "https://bsc-dataseed3.ninicoin.io"); }, + networkCheckTimeout:100000, network_id: 56, confirmations: 10, timeoutBlocks: 200,