This commit is contained in:
owen05
2021-12-27 21:40:32 +08:00
parent b1b84f8818
commit 55fea6602f
10 changed files with 32 additions and 21 deletions

View File

@@ -82,8 +82,8 @@ contract CPVesting is CPFunding {
function _claimBaseToken(address to) internal { function _claimBaseToken(address to) internal {
uint256 claimableBaseAmount = getClaimableBaseToken(msg.sender); uint256 claimableBaseAmount = getClaimableBaseToken(msg.sender);
_transferBaseOut(to, claimableBaseAmount);
_CLAIMED_BASE_TOKEN_[msg.sender] = _CLAIMED_BASE_TOKEN_[msg.sender].add(claimableBaseAmount); _CLAIMED_BASE_TOKEN_[msg.sender] = _CLAIMED_BASE_TOKEN_[msg.sender].add(claimableBaseAmount);
_transferBaseOut(to, claimableBaseAmount);
emit ClaimBaseToken(msg.sender, claimableBaseAmount); emit ClaimBaseToken(msg.sender, claimableBaseAmount);
} }

View File

@@ -24,9 +24,5 @@ interface ICP {
function emergencySettle() external; function emergencySettle() external;
function claimBaseToken() external;
function ClaimQuoteToken(address to,bytes calldata data) external;
function claimLPToken() external; function claimLPToken() external;
} }

View File

@@ -168,7 +168,7 @@ contract FairFunding is Vesting {
// ============ Settle Functions ============ // ============ Settle Functions ============
function settle() public isForceStop preventReentrant { function settle() public isNotForceStop preventReentrant {
require(_FINAL_PRICE_ == 0 && isFundingEnd(), "CAN_NOT_SETTLE"); require(_FINAL_PRICE_ == 0 && isFundingEnd(), "CAN_NOT_SETTLE");
_FINAL_PRICE_ = getCurrentPrice(); _FINAL_PRICE_ = getCurrentPrice();
if(_TOTAL_RAISED_FUNDS_ == 0) { if(_TOTAL_RAISED_FUNDS_ == 0) {
@@ -187,7 +187,7 @@ contract FairFunding is Vesting {
// ============ Funding Functions ============ // ============ 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"); require(isDepositOpen(), "DEPOSIT_NOT_OPEN");
uint256 currentFundBalance = IERC20(_FUNDS_ADDRESS_).balanceOf(address(this)); uint256 currentFundBalance = IERC20(_FUNDS_ADDRESS_).balanceOf(address(this));

View File

@@ -142,7 +142,7 @@ contract InstantFunding is Vesting {
function depositFunds(address to) function depositFunds(address to)
external external
preventReentrant preventReentrant
isForceStop isNotForceStop
returns (uint256 newTokenAllocation) returns (uint256 newTokenAllocation)
{ {
require(isDepositOpen(), "DEPOSIT_NOT_OPEN"); require(isDepositOpen(), "DEPOSIT_NOT_OPEN");

View File

@@ -12,9 +12,11 @@ import {InitializableOwnable} from "../../lib/InitializableOwnable.sol";
import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol"; import {ReentrancyGuard} from "../../lib/ReentrancyGuard.sol";
import {SafeMath} from "../../lib/SafeMath.sol"; import {SafeMath} from "../../lib/SafeMath.sol";
import {IERC20} from "../../intf/IERC20.sol"; import {IERC20} from "../../intf/IERC20.sol";
import {SafeERC20} from "../../lib/SafeERC20.sol";
contract Storage is InitializableOwnable, ReentrancyGuard { contract Storage is InitializableOwnable, ReentrancyGuard {
using SafeMath for uint256; using SafeMath for uint256;
using SafeERC20 for IERC20;
bool public _FORCE_STOP_ = false; bool public _FORCE_STOP_ = false;
address public _QUOTA_; address public _QUOTA_;
@@ -58,7 +60,7 @@ contract Storage is InitializableOwnable, ReentrancyGuard {
// ============ Modifiers ============ // ============ Modifiers ============
modifier isForceStop() { modifier isNotForceStop() {
require(!_FORCE_STOP_, "FORCE_STOP"); require(!_FORCE_STOP_, "FORCE_STOP");
_; _;
} }
@@ -69,6 +71,6 @@ contract Storage is InitializableOwnable, ReentrancyGuard {
_FORCE_STOP_ = true; _FORCE_STOP_ = true;
_TOTAL_TOKEN_AMOUNT_ = 0; _TOTAL_TOKEN_AMOUNT_ = 0;
uint256 tokenAmount = IERC20(_TOKEN_ADDRESS_).balanceOf(address(this)); uint256 tokenAmount = IERC20(_TOKEN_ADDRESS_).balanceOf(address(this));
IERC20(_TOKEN_ADDRESS_).transfer(_OWNER_, tokenAmount); IERC20(_TOKEN_ADDRESS_).safeTransfer(_OWNER_, tokenAmount);
} }
} }

View File

@@ -52,6 +52,8 @@ contract Vesting is Storage {
cliffRate = _LP_CLIFF_RATE_; cliffRate = _LP_CLIFF_RATE_;
} }
require(timestamp >= vestingStart, "NOT_START_TO_CLAIM");
uint256 timePast = timestamp.sub(vestingStart); uint256 timePast = timestamp.sub(vestingStart);
if (timePast < vestingDuration) { if (timePast < vestingDuration) {
uint256 remainingTime = vestingDuration.sub(timePast); uint256 remainingTime = vestingDuration.sub(timePast);
@@ -94,12 +96,12 @@ contract Vesting is Storage {
DecimalMath.ONE, DecimalMath.ONE,
isOpenTWAP isOpenTWAP
); );
IERC20(_TOKEN_ADDRESS_).transferFrom(msg.sender, _INITIAL_POOL_, initialTokenAmount); IERC20(_TOKEN_ADDRESS_).safeTransferFrom(msg.sender, _INITIAL_POOL_, initialTokenAmount);
if(totalUsedRaiseFunds > _INITIAL_FUND_LIQUIDITY_) { if(totalUsedRaiseFunds > _INITIAL_FUND_LIQUIDITY_) {
IERC20(_FUNDS_ADDRESS_).transfer(_INITIAL_POOL_, _INITIAL_FUND_LIQUIDITY_); IERC20(_FUNDS_ADDRESS_).safeTransfer(_INITIAL_POOL_, _INITIAL_FUND_LIQUIDITY_);
}else { }else {
IERC20(_FUNDS_ADDRESS_).transfer(_INITIAL_POOL_, totalUsedRaiseFunds); IERC20(_FUNDS_ADDRESS_).safeTransfer(_INITIAL_POOL_, totalUsedRaiseFunds);
} }
(_TOTAL_LP_, , ) = IDVM(_INITIAL_POOL_).buyShares(address(this)); (_TOTAL_LP_, , ) = IDVM(_INITIAL_POOL_).buyShares(address(this));

View File

@@ -12,6 +12,7 @@ import {InitializableOwnable} from "../lib/InitializableOwnable.sol";
import {ICloneFactory} from "../lib/CloneFactory.sol"; import {ICloneFactory} from "../lib/CloneFactory.sol";
import {SafeMath} from "../lib/SafeMath.sol"; import {SafeMath} from "../lib/SafeMath.sol";
import {IERC20} from "../intf/IERC20.sol"; import {IERC20} from "../intf/IERC20.sol";
import {SafeERC20} from "../lib/SafeERC20.sol";
import {DecimalMath} from "../lib/DecimalMath.sol"; import {DecimalMath} from "../lib/DecimalMath.sol";
import {IDODOStarter} from "../DODOStarter/intf/IDODOStarter.sol"; import {IDODOStarter} from "../DODOStarter/intf/IDODOStarter.sol";
@@ -23,6 +24,8 @@ import {IDODOStarter} from "../DODOStarter/intf/IDODOStarter.sol";
*/ */
contract DODOStarterFactory is InitializableOwnable { contract DODOStarterFactory is InitializableOwnable {
using SafeMath for uint256; using SafeMath for uint256;
using SafeERC20 for IERC20;
// ============ Templates ============ // ============ Templates ============
address public immutable _CLONE_FACTORY_; address public immutable _CLONE_FACTORY_;
@@ -83,7 +86,7 @@ contract DODOStarterFactory is InitializableOwnable {
) external payable permissionCheck(addressList[0],addressList[1]) returns(address newFairFundPool){ ) external payable permissionCheck(addressList[0],addressList[1]) returns(address newFairFundPool){
newFairFundPool = ICloneFactory(_CLONE_FACTORY_).clone(_FAIR_FUND_TEMPLATE_); 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}(""); (bool success, ) = newFairFundPool.call{value: msg.value}("");
require(success, "Settle fund Transfer failed"); require(success, "Settle fund Transfer failed");
@@ -107,7 +110,7 @@ contract DODOStarterFactory is InitializableOwnable {
) external permissionCheck(addressList[0],addressList[1]) returns(address newInstantFundPool){ ) external permissionCheck(addressList[0],addressList[1]) returns(address newInstantFundPool){
newInstantFundPool = ICloneFactory(_CLONE_FACTORY_).clone(_INSTANT_FUND_TEMPLATE_); 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( IDODOStarter(newInstantFundPool).init(
addressList, addressList,

View File

@@ -16,6 +16,7 @@ const DODOToken = artifacts.require("DODOToken");
const UpCrowdPoolingFactory = artifacts.require("UpCrowdPoolingFactory"); const UpCrowdPoolingFactory = artifacts.require("UpCrowdPoolingFactory");
const CpFactory = artifacts.require("CrowdPoolingFactory"); const CpFactory = artifacts.require("CrowdPoolingFactory");
const MultiCall = artifacts.require("Multicall"); const MultiCall = artifacts.require("Multicall");
const UserQuota = artifacts.require("UserQuota");
const LockedTokenVault = artifacts.require("LockedTokenVault"); const LockedTokenVault = artifacts.require("LockedTokenVault");
const DODORouteProxy = artifacts.require("DODORouteProxy"); const DODORouteProxy = artifacts.require("DODORouteProxy");
const DODOCpProxy = artifacts.require("DODOCpProxy"); const DODOCpProxy = artifacts.require("DODOCpProxy");
@@ -303,6 +304,12 @@ module.exports = async (deployer, network, accounts) => {
logger.log("MultiCallAddress: ", MultiCallAddress); logger.log("MultiCallAddress: ", MultiCallAddress);
} }
if (deploySwitch.UserQuota) {
await deployer.deploy(UserQuota);
UserQuotaAddress = UserQuota.address;
logger.log("UserQuotaAddress: ", UserQuotaAddress);
}
if (deploySwitch.CPFactory) { if (deploySwitch.CPFactory) {
logger.log("===================================================="); logger.log("====================================================");
logger.log("network type: " + network); logger.log("network type: " + network);

View File

@@ -45,7 +45,7 @@
"solc": "^0.6.9", "solc": "^0.6.9",
"ts-node": "^8.10.2", "ts-node": "^8.10.2",
"typescript": "^3.9.5", "typescript": "^3.9.5",
"web3": "^1.2.9", "web3": "^1.2.8",
"web3-core-helpers": "^1.2.8", "web3-core-helpers": "^1.2.8",
"web3-eth-contract": "^1.2.8" "web3-eth-contract": "^1.2.8"
}, },
@@ -55,7 +55,6 @@
"prettier": "^2.0.5", "prettier": "^2.0.5",
"prettier-plugin-solidity": "^1.0.0-alpha.52", "prettier-plugin-solidity": "^1.0.0-alpha.52",
"solidity-coverage": "^0.7.7", "solidity-coverage": "^0.7.7",
"truffle-assertions": "^0.9.2", "truffle-assertions": "^0.9.2"
"web3-provider-engine": "~15.0.12"
} }
} }

View File

@@ -19,7 +19,6 @@
*/ */
var HDWalletProvider = require("@truffle/hdwallet-provider"); var HDWalletProvider = require("@truffle/hdwallet-provider");
const NonceTrackerSubprovider = require('web3-provider-engine/subproviders/nonce-tracker')
var privKey = process.env.privKey; var privKey = process.env.privKey;
var infuraId = process.env.infuraId; var infuraId = process.env.infuraId;
@@ -104,7 +103,9 @@ module.exports = {
gas: 10000000, gas: 10000000,
gasPrice: 1500000000, gasPrice: 1500000000,
network_id: 4, network_id: 4,
skipDryRun: true skipDryRun: true,
confirmations: 2,
timeoutBlocks: 200,
}, },
live: { live: {
@@ -120,8 +121,9 @@ module.exports = {
bsclive: { bsclive: {
provider: function () { 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, network_id: 56,
confirmations: 10, confirmations: 10,
timeoutBlocks: 200, timeoutBlocks: 200,