From afc757022a8f5a1c2cef5a44ffa27d571e198ea8 Mon Sep 17 00:00:00 2001 From: owen05 Date: Sun, 1 Aug 2021 23:22:33 +0800 Subject: [PATCH] deploy mineV3 && add ERC20Helper --- config/arb-config.js | 6 +-- config/bsc-config.js | 6 +-- config/eth-config.js | 6 +-- config/heco-config.js | 6 +-- config/matic-config.js | 6 +-- contracts/DODOToken/DODOMineV3/BaseMine.sol | 5 +++ contracts/helper/ERC20Helper.sol | 42 +++++++++++++++++++++ deploy-detail-periphery.txt | 37 ++++++++++++++++++ truffle-config.js | 5 ++- 9 files changed, 102 insertions(+), 17 deletions(-) create mode 100644 contracts/helper/ERC20Helper.sol diff --git a/config/arb-config.js b/config/arb-config.js index bf56afb..5404158 100644 --- a/config/arb-config.js +++ b/config/arb-config.js @@ -21,7 +21,7 @@ module.exports = { DPPAdmin: "0x1dc8D1f1600B7C1D39e6b60FBC7b021Bc4F9C993", CP: "0x8F8Dd7DB1bDA5eD3da8C9daf3bfa471c12d58486", - ERC20MineV3: "", + ERC20MineV3: "0x973CAB76C35BB1da47e044A63546c69A8Ac1143c", ERC20: "0xBb245F54569841906eC7eDFFf72a910557B81378", MintableERC20: "0x70eFB31271C0796833f80dA4E6538d05B2AFA72C", CustomERC20: "0xcE2a934933465E187c95AcAce60BC650a06aD373", @@ -34,7 +34,7 @@ module.exports = { CrowdPoolingFactory: "0x884E3EE9e25896c57E7d8d6FAACef22B02BCD6bE", ERC20Factory: "0x141b4497a298340E8B451ac4eeE947B00aDbe07A", ERC20V2Factory: "0xE3c91fDCe30DD5Aa95138D6c4d63f43a26e9066e", - DODOMineV3Registry: "", + DODOMineV3Registry: "0xf6585FE94f2147682723FCdFFb973757BCdB608F", //Approve DODOApprove: "0xCDFD45f965De9932367833Ca7187e4c9C43A2380", @@ -50,7 +50,7 @@ module.exports = { DSPProxy: "0x3a343F2e4e142412c5dD130359edb765a6054965", CpProxy: "0x2cD18557E14aF72DAA8090BcAA95b231ffC9ea26", RouteProxy: "0x3E64F18168651d140AaE57e0cF325874d066bA9E", - DODOMineV3Proxy: "", + DODOMineV3Proxy: "0x579D25c519de3235aeD83A277E67c6420d9Fd1bE", //Account multiSigAddress: "0x1e0D4043C0CD3ed15F3c2AfE60B0F213c9b5E30d", diff --git a/config/bsc-config.js b/config/bsc-config.js index c887f84..a8d368b 100644 --- a/config/bsc-config.js +++ b/config/bsc-config.js @@ -20,7 +20,7 @@ module.exports = { DSP: "0xE3c91fDCe30DD5Aa95138D6c4d63f43a26e9066e", DPPAdmin: "0x44D5dF24d5Ef52A791D6436Fa45A8D426f6de34e", CP: "0x5D6e6A0BFB2176AFCc4FB809822D8e009216b245", - ERC20MineV3: "", + ERC20MineV3: "0xBA428FC3c5ce457c236869787c26f725Ff5168D8", ERC20: "0x99155E68aC1523B6f461F6427A90607ecCF7bDF5", MintableERC20: "0x6373ceb657c83c91088d328622573fb766064ac4", @@ -34,7 +34,7 @@ module.exports = { CrowdPoolingFactory: "0x778DF5B12170e8af8dF94356BfC864E57CE185DC", ERC20Factory: "0x5e84190a270333aCe5B9202a3F4ceBf11b81bB01", ERC20V2Factory: "0x652C09785c15db4adAce871eD8874b8968A19A4D", - DODOMineV3Registry: "", + DODOMineV3Registry: "0x2A5aa99095E3724b8955BF7b5E47dbe2730dabD8", //Approve DODOApprove: "0xa128Ba44B2738A558A1fdC06d6303d52D3Cef8c1", @@ -54,7 +54,7 @@ module.exports = { DSPProxy: "0x2442A8B5cdf1E659F3F949A7E454Caa554D4E65a", CpProxy: "0xA867241cDC8d3b0C07C85cC06F25a0cD3b5474d8", RouteProxy: "0x6B3D817814eABc984d51896b1015C0b89E9737Ca", - DODOMineV3Proxy: "", + DODOMineV3Proxy: "0x3c39dCb3630D305530a30419b3DEEcea629597AC", //vDODO DODOCirculationHelper: "", diff --git a/config/eth-config.js b/config/eth-config.js index fd205de..1e8eebf 100644 --- a/config/eth-config.js +++ b/config/eth-config.js @@ -20,7 +20,7 @@ module.exports = { DSP: "0x8735AAd3BEae15487a017EE32cb11d8fd593e036", DPPAdmin: "0x5515363c0412AdD5c72d3E302fE1bD7dCBCF93Fe", CP: "0x327344B382EE1b44FB0a72945fCDCC7243200dD7", - ERC20MineV3: "", + ERC20MineV3: "0xD57f29B297e33c977e2186a751414BFeD6A38c5a", ERC20: "0x8443a5bD91C8f68582F90dD3354f750900C5E8Cc", MintableERC20: "0x0596908263ef2724fbfbcafa1c983fcd7a629038", CustomERC20: "0x9Cd85f012050FE030271dCB7c0a0C1e2043Ce4a9", @@ -33,7 +33,7 @@ module.exports = { CrowdPoolingFactory: "0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25", ERC20Factory: "0x44D5dF24d5Ef52A791D6436Fa45A8D426f6de34e", ERC20V2Factory: "0xAA810cd0363d3378F0a13e327EC2Aee7051aDa73", - DODOMineV3Registry: "", + DODOMineV3Registry: "0xf8ab09b3D2d5EfA603f4646E5a8A12588E852195", //Approve DODOApprove: "0xCB859eA579b28e02B87A1FDE08d087ab9dbE5149", @@ -52,7 +52,7 @@ module.exports = { DSPProxy: "0x4599ed18F34cFE06820E3684bF0aACB8D75c644d", CpProxy: "0x048B8926bb0eE9c52e05D61fDffbCCffbeE06Fc2", RouteProxy: "0xa2398842F37465f89540430bDC00219fA9E4D28a", - DODOMineV3Proxy: "", + DODOMineV3Proxy: "0x0d9685D4037580F68D9F77B08971f17E1000bBdc", //vDODO DODOCirculationHelper: "0x357c5e9cfa8b834edcef7c7aabd8f9db09119d11", diff --git a/config/heco-config.js b/config/heco-config.js index 9e8b26c..f6daa93 100644 --- a/config/heco-config.js +++ b/config/heco-config.js @@ -20,7 +20,7 @@ module.exports = { DSP: "0xEB5470DfCF2BA5CDdC108E8B65A7ED2A77EA3c2D", DPPAdmin: "0x3232fd648997F89E614A021fdAc756d61F9030A1", CP: "0x5B67cF070ce4303Ff4d450f21Cc371F9f0549335", - ERC20MineV3: "", + ERC20MineV3: "0xBE227f1383C1c5f96948e1939EFaC011FAba56D8", ERC20: "0x2870fB656C7D245dc74afbA34B0d453FA67Ce4fA", MintableERC20: "0xdd9de5ed7a11b1ed3314cd7f754f27a15dedc63f", CustomERC20: "0x2cE80F95eD3d2a76694896843F18413ae83baF40", @@ -33,7 +33,7 @@ module.exports = { CrowdPoolingFactory: "0x56133d0b63abf7A15D5697dD2dB9e04730f1A9C2", ERC20Factory: "0x2cCDF6F742afBe813B68Ec6bb421C1BEa74fBd46", ERC20V2Factory: "0x1297264617bd34270B77c2fFD3aA110D3fd2f7aF", - DODOMineV3Registry: "", + DODOMineV3Registry: "0xeA73542FbF76b35e46901e0Ca19BcC5A0361F5BF", //Approve DODOApprove: "0x68b6c06Ac8Aa359868393724d25D871921E97293", DODOApproveProxy: "0x91737709De4b2eDEE3a2B78A84e21a60C0b4D70b", @@ -51,7 +51,7 @@ module.exports = { DSPProxy: "0x9951CdEc21F42ab69D02daAAFEF4C3fc810B36FF", CpProxy: "0x8930101c6cFbe0f3cb31E7526a16E72255388E97", RouteProxy: "0xEc0fA5746E37dE75bDA9C1F874F2B75C12e505F6", - DODOMineV3Proxy: "", + DODOMineV3Proxy: "0x50832DEdCF8b390160D892654530Fb96042d674B", //vDODO DODOCirculationHelper: "", diff --git a/config/matic-config.js b/config/matic-config.js index 7956c63..3263a68 100644 --- a/config/matic-config.js +++ b/config/matic-config.js @@ -21,7 +21,7 @@ module.exports = { DPPAdmin: "0xB5Dc5E183c2aCf02aB879A8569aB4EDAf147d537", CP: "0xf50BDc9E90B7a1c138cb7935071b85c417C4cb8e", - ERC20MineV3: "", + ERC20MineV3: "0xda59427Bd9d4827Ec9f751719eb79b0a3e74FA4D", ERC20: "0x34b9Dc29AaDc313F2BF828B7Be1e0DEe393D28e3", MintableERC20: "0x7737fd30535c69545deeEa54AB8Dd590ccaEBD3c", CustomERC20: "0xaF49DBAaf177beE57f84731260a9eb8819d25eff", @@ -34,7 +34,7 @@ module.exports = { CrowdPoolingFactory: "0x42ddEc68db70F5992eB7AB22dfaD8A57109841C9", ERC20Factory: "0xaeB5CF31b97dce6134e416129845e01106fFB177", ERC20V2Factory: "0x8e2f666F316b614c76676215F16F0A9746f96a90", - DODOMineV3Registry: "", + DODOMineV3Registry: "0x27566bf9504466F6f3a1571E1863Da42fff4D25E", //Approve DODOApprove: "0x6D310348d5c12009854DFCf72e0DF9027e8cb4f4", @@ -50,7 +50,7 @@ module.exports = { DSPProxy: "0xfDDCA6ffCE24dF5bE3e8AaD32081822f86178048", CpProxy: "0x5480B32c03647ff5E5A653F0465E798DBe558B57", RouteProxy: "0x53eE28b9F0A6416857C1e7503032E27e80F52DA0", - DODOMineV3Proxy: "", + DODOMineV3Proxy: "0x47a65e74dd6b6B5E3243dBb01EDEd9D55ba234Ad", //Account multiSigAddress: "0x3CD6D7F5fF977bf8069548eA1F9441b061162b42", diff --git a/contracts/DODOToken/DODOMineV3/BaseMine.sol b/contracts/DODOToken/DODOMineV3/BaseMine.sol index 9830983..46cf800 100644 --- a/contracts/DODOToken/DODOMineV3/BaseMine.sol +++ b/contracts/DODOToken/DODOMineV3/BaseMine.sol @@ -228,6 +228,11 @@ contract BaseMine is InitializableOwnable { RewardTokenInfo storage rt = rewardTokenInfos[i]; require(block.number > rt.endBlock, "DODOMineV3: MINING_NOT_FINISHED"); + + uint256 gap = rt.endBlock.sub(rt.lastFlagBlock); + uint256 totalReward = rt.workThroughReward.add(gap.mul(rt.rewardPerBlock)); + uint256 totalDepositReward = IRewardVault(rt.rewardVault)._TOTAL_REWARD_(); + require(amount <= totalDepositReward.sub(totalReward), "DODOMineV3: NOT_ENOUGH"); IRewardVault(rt.rewardVault).withdrawLeftOver(msg.sender,amount); diff --git a/contracts/helper/ERC20Helper.sol b/contracts/helper/ERC20Helper.sol new file mode 100644 index 0000000..624ef65 --- /dev/null +++ b/contracts/helper/ERC20Helper.sol @@ -0,0 +1,42 @@ +/* + + Copyright 2021 DODO ZOO. + SPDX-License-Identifier: Apache-2.0 + +*/ + +pragma solidity 0.6.9; + +interface IERC20ForCheck { + function decimals() external view returns (uint); + function name() external view returns (string memory); + function symbol() external view returns (string memory); + + function balanceOf(address account) external view returns (uint256); + function allowance(address owner, address spender) external view returns (uint256); +} + + +contract ERC20Helper { + function isERC20(address token, address user, address spender) external view returns(bool isOk, string memory symbol, string memory name, uint decimals, uint256 balance, uint256 allownance) { + try this.judgeERC20(token, user, spender) returns (string memory _symbol, string memory _name, uint _decimals, uint256 _balance, uint256 _allownance) { + symbol = _symbol; + name = _name; + decimals = _decimals; + balance = _balance; + allownance = _allownance; + isOk = true; + } catch { + isOk = false; + } + } + + function judgeERC20(address token, address user, address spender) external view returns(string memory symbol, string memory name, uint decimals, uint256 balance, uint256 allownance) { + name = IERC20ForCheck(token).name(); + symbol = IERC20ForCheck(token).symbol(); + decimals = IERC20ForCheck(token).decimals(); + + balance = IERC20ForCheck(token).balanceOf(user); + allownance = IERC20ForCheck(token).allowance(user,spender); + } +} \ No newline at end of file diff --git a/deploy-detail-periphery.txt b/deploy-detail-periphery.txt index 4aab95e..ee25932 100644 --- a/deploy-detail-periphery.txt +++ b/deploy-detail-periphery.txt @@ -541,3 +541,40 @@ Deploy type: MineV3 DODOMineV3RegistryAddress Init tx: 0x907607d1b96595c1ceba9d515a02bea5197c9db86f5e23a5097073d0adcf9a63 DODOApproveProxy Unlock tx: 0x64b4e96618a6dad94575f3fb162389e8ae10e90903460d7740d45cc0fc8a8dc6 DODOApproveProxy AddProxy tx: 0x23416aa911f38a3babcb22226765a553c8458f68914906506f3acab675a75661 +==================================================== +network type: bsclive +Deploy time: 2021/7/28 上午10:41:27 +Deploy type: MineV3 +ERC20MineV3Address: 0x1eB6Cc182184007265E826beEb16103174fdbCee +DODOMineV3RegistryAddress: 0xf1ED17F78Dad13f3B9caaD90b9aF18b94e0C6d6a +Init DODOMineV3Registry Tx: 0xd0d88ed2ba4236ac3303d5ab856c68be2201b17214178e701aa0bce32075b495 +DODOMineV3ProxyAddress: 0x3c1336d70972f55C2b78e515CE2730691aD07eE2 +Init DODOMineV3Proxy Tx: 0x92f27d8e713f47fe318e0581055833e23e476633da82ddfc9df49dd4d214136a +==================================================== +network type: bsclive +Deploy time: 2021/7/28 上午11:11:27 +Deploy type: MineV3 +DODOMineV3RegistryAddress: 0x2A5aa99095E3724b8955BF7b5E47dbe2730dabD8 +Init DODOMineV3Registry Tx: 0x6ecf2f50f91cebc3930f580bdd1dd7f27699ca1eb98cc830c40a361f57fc5716 +DODOMineV3ProxyAddress: 0x3c39dCb3630D305530a30419b3DEEcea629597AC +Init DODOMineV3Proxy Tx: 0xe8bf59875830af8a5e006f8c276b0626bf439021a93d916ca31b820d701619dd +==================================================== +network type: heco +Deploy time: 2021/7/28 上午11:24:14 +Deploy type: MineV3 +DODOMineV3RegistryAddress: 0xeA73542FbF76b35e46901e0Ca19BcC5A0361F5BF +Init DODOMineV3Registry Tx: 0x6904819b486b40c7d2a3ad637a5ead9362023f1611f93ec20ea9149b65046cec +DODOMineV3ProxyAddress: 0x50832DEdCF8b390160D892654530Fb96042d674B +Init DODOMineV3Proxy Tx: 0x918d1ab979bc05391719005b14555123909c8d268c782ba8b105c48896e99ab4 +==================================================== +network type: live +Deploy time: 2021/7/28 下午12:37:22 +Deploy type: MineV3 +DODOMineV3RegistryAddress: 0xf8ab09b3D2d5EfA603f4646E5a8A12588E852195 +Init DODOMineV3Registry Tx: 0x948d5df00c7fd6999bb3c539cec7760cbbd47997e95671d8fb155c9fe533457d +DODOMineV3ProxyAddress: 0x0d9685D4037580F68D9F77B08971f17E1000bBdc +Init DODOMineV3Proxy Tx: 0xa24b951703bdda5fd697ce49ddbb491d338cb4c9e35bd93dc6a3c42c60f5ee73 +==================================================== +network type: arb +Deploy time: 2021/7/28 下午1:04:45 +Deploy type: MineV3 diff --git a/truffle-config.js b/truffle-config.js index 81192d9..6727aa5 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -64,6 +64,7 @@ module.exports = { COLLECTIONS: false, MYSTERYBOX_V1: false, Drops_V2: false, + MineV3: false }, networks: { @@ -110,7 +111,7 @@ module.exports = { return new HDWalletProvider(privKey, "https://mainnet.infura.io/v3/" + infuraId); }, gas: 6000000, - gasPrice: 18000000000, + gasPrice: 25000000000, network_id: 1, skipDryRun: true }, @@ -186,7 +187,7 @@ module.exports = { ) }, network_id: '42161', - gasPrice: 100000000, + gasPrice: 400000000, }, matic: {