diff --git a/config/arb-config.js b/config/arb-config.js index 554cb5a..c74bb2d 100644 --- a/config/arb-config.js +++ b/config/arb-config.js @@ -3,7 +3,7 @@ module.exports = { //TOKEN WETH: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1", CHI: "0x0000000000000000000000000000000000000000", - DODO: "", + DODO: "0x69Eb4FA4a2fbd498C257C57Ea8b7655a2559A581", //Helper DODOSellHelper: "0x18AA6Bb215CDBd179E7beAE10F66C21B26971306", @@ -23,6 +23,7 @@ module.exports = { CP: "0x8F8Dd7DB1bDA5eD3da8C9daf3bfa471c12d58486", ERC20: "0xC3528D128CC227fd60793007b5e3FdF7c2945282", MintableERC20: "0x70eFB31271C0796833f80dA4E6538d05B2AFA72C", + CustomERC20: "", //Factory DVMFactory: "0xb0C7cB15b52b0093130487209e96CFeC0Ba4Ff66", @@ -31,6 +32,7 @@ module.exports = { UpCpFactory: "0x69f52AC40185A2A005D49114F0B77b7bA856F0a0", CrowdPoolingFactory: "0x884E3EE9e25896c57E7d8d6FAACef22B02BCD6bE", ERC20Factory: "0x141b4497a298340E8B451ac4eeE947B00aDbe07A", + ERC20V2Factory: "", //Approve DODOApprove: "0xCDFD45f965De9932367833Ca7187e4c9C43A2380", diff --git a/config/bsc-config.js b/config/bsc-config.js index 7221337..46cbed7 100644 --- a/config/bsc-config.js +++ b/config/bsc-config.js @@ -22,6 +22,7 @@ module.exports = { CP: "0x5D6e6A0BFB2176AFCc4FB809822D8e009216b245", ERC20: "0xef49a6dba1c8df859e49c17e9a485b439c7689d3", MintableERC20: "0x6373ceb657c83c91088d328622573fb766064ac4", + CustomERC20: "", //Factory DVMFactory: "0x790B4A80Fb1094589A3c0eFC8740aA9b0C1733fB", @@ -30,6 +31,7 @@ module.exports = { UpCpFactory: "0x4F57F6929E58AE564F6AB090fE0AEEcb39B0f270", CrowdPoolingFactory: "0x778DF5B12170e8af8dF94356BfC864E57CE185DC", ERC20Factory: "0x5e84190a270333aCe5B9202a3F4ceBf11b81bB01", + ERC20V2Factory: "", //Approve DODOApprove: "0xa128Ba44B2738A558A1fdC06d6303d52D3Cef8c1", diff --git a/config/eth-config.js b/config/eth-config.js index ebf3101..0e02d7d 100644 --- a/config/eth-config.js +++ b/config/eth-config.js @@ -22,6 +22,7 @@ module.exports = { CP: "0x327344B382EE1b44FB0a72945fCDCC7243200dD7", ERC20: "0x85351262f7474ebe23ffacd633cf20a491f1325d", MintableERC20: "0x0596908263ef2724fbfbcafa1c983fcd7a629038", + CustomERC20: "", //Factory DVMFactory: "0x72d220cE168C4f361dD4deE5D826a01AD8598f6C", @@ -30,6 +31,7 @@ module.exports = { UpCpFactory: "0x78D338F9d54E9e41872E68cB1c01d9499d87eE52", CrowdPoolingFactory: "0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25", ERC20Factory: "0x44D5dF24d5Ef52A791D6436Fa45A8D426f6de34e", + ERC20V2Factory: "", //Approve DODOApprove: "0xCB859eA579b28e02B87A1FDE08d087ab9dbE5149", diff --git a/config/heco-config.js b/config/heco-config.js index 8deb374..f0764d8 100644 --- a/config/heco-config.js +++ b/config/heco-config.js @@ -22,6 +22,7 @@ module.exports = { CP: "0x5B67cF070ce4303Ff4d450f21Cc371F9f0549335", ERC20: "0x62e1622a47c9fe74b2cf0bade5ecb8669ff9bfbf", MintableERC20: "0xdd9de5ed7a11b1ed3314cd7f754f27a15dedc63f", + CustomERC20: "", //Factory DVMFactory: "0xd8c77CF0F01222b07B8343A681C46eFA3faEa985", @@ -30,6 +31,7 @@ module.exports = { UpCpFactory: "0xF7c3467786efAA9BD4022941ecd5a00C61b17FA9", CrowdPoolingFactory: "0x56133d0b63abf7A15D5697dD2dB9e04730f1A9C2", ERC20Factory: "0x2cCDF6F742afBe813B68Ec6bb421C1BEa74fBd46", + ERC20V2Factory: "", //Approve DODOApprove: "0x68b6c06Ac8Aa359868393724d25D871921E97293", diff --git a/config/kovan-config.js b/config/kovan-config.js index 46d3b86..0b4810f 100644 --- a/config/kovan-config.js +++ b/config/kovan-config.js @@ -22,6 +22,7 @@ module.exports = { CP: "0x6092eFEf82CaDcd07f3a545cBe6C83dae713aE0A", ERC20: "0x77d2e257241e6971688b08bda9f658f065d7bb41", MintableERC20: "0xa45a64daba80757432fa4d654df12f65f020c13c", + CustomERC20: "0x3a0e0F2EDFC0e96BD700815f953Bcb6d8a6FF0AB", //Factory DVMFactory: "0x322F8014C125Da09314d3a68d4d9F427823F17FD", @@ -30,6 +31,7 @@ module.exports = { CrowdPoolingFactory: "0x9e6E8985D52E91eDf1671f28Ca73bc4F3E219b72", UpCpFactory: "0x25AE560522165eacCFbF2287493AF12B8ad718e7", ERC20Factory: "0xCb1A2f64EfB02803276BFB5a8D511C4D950282a0", + ERC20V2Factory: "0xce4Bdc3151bF9F9dcADAED961a65D32f7bAC5460", //Approve DODOApprove: "0xa375b128e139ae54EF7F189BC8fEb4624f1c2Afa", diff --git a/config/matic-config.js b/config/matic-config.js index 804c0fd..b56ff7b 100644 --- a/config/matic-config.js +++ b/config/matic-config.js @@ -23,6 +23,7 @@ module.exports = { CP: "0xf50BDc9E90B7a1c138cb7935071b85c417C4cb8e", ERC20: "0xE8C9A78725D0451FA19878D5f8A3dC0D55FECF25", MintableERC20: "0x7737fd30535c69545deeEa54AB8Dd590ccaEBD3c", + CustomERC20: "", //Factory DVMFactory: "0xbAb9F4ff4A19a0e8EEBC56b06750253228ffAc6E", @@ -31,6 +32,7 @@ module.exports = { UpCpFactory: "0x335aC99bb3E51BDbF22025f092Ebc1Cf2c5cC619", CrowdPoolingFactory: "0x85351262f7474Ebe23FfAcD633cf20A491F1325D", ERC20Factory: "0xaeB5CF31b97dce6134e416129845e01106fFB177", + ERC20V2Factory: "", //Approve DODOApprove: "0x9aE501385Bc7996A2A4a1FBb00c8d3820611BCB5", diff --git a/config/rinkeby-config.js b/config/rinkeby-config.js new file mode 100644 index 0000000..081b096 --- /dev/null +++ b/config/rinkeby-config.js @@ -0,0 +1,102 @@ +module.exports = { + RINKEBY_CONFIG: { + //TOKEN + WETH: "0xB26c0d8Be2960c70641A95A9195BE1f59Ac83aC0", + CHI: "0x0000000000000000000000000000000000000000", + DODO: "0xeaa70c2a40820dF9D38149C84dd943CFcB562587", + + //Helper + DODOSellHelper: "0x4635FAc4471BC5B5839007f1EF65ff469ace333F", + DODOCalleeHelper: "0x87C296100df953aFa324ABB870891baD9dDBf0fC", + DODOV1PmmHelper: "0xEb06236b035f1Db7F1D181Efd635Edd621874472", + DODOV2RouteHelper: "0x80a70F228D8faBF20fdaf8274b9A7c4AE3551861", + + //Template + CloneFactory: "0x823ECBfCCD3e6Cb67d4c9334F743BEe0E60A7349", + FeeRateModel: "0x0ae835f585638CCbD4D7eAA339ED033f8194Bcfe", + PermissionManager: "0x7949a4D350F69ef5Ff4c3079751250f5b7B86a00", + DVM: "0x44BD801ACAf994bD628d01d84299BE94010dc08B", + DPP: "0x604BFaDa2EAC7E011DdF9aA8848b38e8b02aDdD2", + DSP: "0xe2C23cBF03930418BF97e173FE3E950aD29fdb06", + DPPAdmin: "0x2FF619B4Cfe36b0F92dD933256B1581a3269a5F4", + CP: "0x6850eE8cF963B913a8eC3610B5f128C3100178E5", + ERC20: "0x80Dd80AF76D82c1962DdFb7d69C6Fdca2AAEEF00", + MintableERC20: "0x595D13871de67Ae33b452e6ef59Aa18d23634FdE", + CustomERC20: "0x0Cd57DC8367362314C510446FD106B66989Eb81a", + + //Factory + DVMFactory: "0x17DddEFA0c82E0c850a4Adac2aFE3F1fe977A242", + DPPFactory: "0x510b49803E356C750f3a93bA5508C0FFD9f71bDD", + DSPFactory: "0xa1ab675cB49BA0DC3F39fA4C20E216572A8dD3c8", + CrowdPoolingFactory: "0xDD43520779dDCfbDe373174Ee36aEaD39771cD4f", + UpCpFactory: "0xb09E91505347234Cb722D67042290f50F1C13749", + ERC20Factory: "0x48476599281CB7DD46dbE47264C4594d1d2E19A8", + ERC20V2Factory: "0x6659fB6fc609e8c5159Aaccb80e49cCB8F64442a", + + //Approve + DODOApprove: "0xcC8d87A7C747eeE4242045C47Ef25e0A81D56ae3", + DODOApproveProxy: "0x790917CA55c9B01974BFDd066537Fb3DF42Bb0E3", + + //Periphery + DODOIncentive: "0x0000000000000000000000000000000000000000", + + //Adpater + DODOV1Adapter: "0x7ffd33271765E37FdD527a03ca13783DCD4dD3E6", + DODOV2Adapter: "0x733488ea274561fe8543cF5386fEcC6EE932Ba5E", + UniAdapter: "0x5964Af417A0cdFa8C0E171733FB1c570b2b515E8", + + //Proxy + DODOV2Proxy: "0xba001E96AF87bF9d8D0BDA667067A9921FE6d294", + DSPProxy: "0x0f6345D1d07C134BB0973AD102F38eA9195F6f78", + CpProxy: "0x2E483CBb9e76fE6543168DEd698d9244EE1ED8Dd", + DODORouteProxy: "0xe2b538a781eB5a115a1359B8f363B9703Fd19dE6", + + + //vDODO + DODOCirculationHelper: "0xe4Aec985debDDbbCB2358e8C8F9384DD6421d163", + Governance: "0x0000000000000000000000000000000000000000", + dodoTeam: "0x7e83d9d94837eE82F0cc18a691da6f42F03F1d86", + vDODOToken: "0x8751f874eCd2874f2a5ced95A08364C203e4146A", + + //Account + multiSigAddress: "0x7e83d9d94837eE82F0cc18a691da6f42F03F1d86", + defaultMaintainer: "0x7e83d9d94837eE82F0cc18a691da6f42F03F1d86", + + //FeeRateImpl: "0xCc5e58B59158A9dfb13e4d902958689fA0e7dE9c", + //multiCall: "0xb7E1C577f95959a3eD11f9281702850328b4e0e4", + //DODO: "0xF65899222FC7C73044Fe24f954b3b29Ff092B9e2", + //DODOZoo: "0x168442Fec1e1E782c8770185dBb8328B91dC45c0", + //DODOSwapCalcHelper: "0x5020d289E1140Dc733126a71818A08F7f0fe1AE1", + //DODOMineV2Factory: "0x3932E00a51d0D3b85C8Eb7C3ED0FcCB0dF98B3FF" + + //================== NFT ==================== + BuyoutModel: "0x98F5aF1E7Fb03A085D2a28713995e4A923860288", + Fragment: "0xDF7eccee9f5C92D1Baf036DB9410456f9382E045", + NFTCollateralVault: "0x23d72eA97a9E43411Eeb908d128DF337aD334582", + DODONFTRouteHelper: "0xb0Ca341b6fbdC607A507D821780e29f9601a58B3", + + InitializableERC721: "0xC0ccfC832BD45Cd3A2d62e47FE92Fc50DD2210ac", + InitializableERC1155: "0x9DC9086B65cCBec43F92bFa37Db81150Ed1DDDed", + NFTTokenFactory: "0xd2BffcCBC1F2a7356f8DaBB55B33E47D62de1bB1", + + DodoNftErc721: "0x3Bc20358B31aD498d5a245B36bC993DDBE9A4405", + DodoNftErc1155: "0xc498F36eF82Aa5dBE0ecF6DD56DD55398E80E13D", + + DODONFTRegistry: "0x69efeCA5070Cb22c1094cffEbacafC09c058c139", + DODONFTProxy: "0x0CF019E13C6527BD34eC6c8323F11aB5DF6f0922", + + //================= DropsV1 ================= + MysteryBoxV1: "", + RandomGenerator: "0x69C8a7fc6E05d7aa36114B3e35F62DEcA8E11F6E", + RandomPool: [], + + //================= DropsV2 ================== + DropsFeeModel: "0xA012249Fac6D77Daf246BFBdC193fFBC8814298C", + DropsProxy: "0xa968a8B14174395c922347Ab593a0CD7EFf30cf1", + + //DODODropsV2: "0x4A2b9f63AE41cF3003A494F2d8Fcd9Ed850b9A6f" + + // DropsERC721: "0x3df8d553275781C777f432A74EEE9099226B9d13", + // DropsERC1155: "0x3a8EcF30428bd4e33Cd7011533DFd596F7705c8F", + } +} \ No newline at end of file diff --git a/configAdapter.js b/configAdapter.js index abdaa8f..46a0668 100644 --- a/configAdapter.js +++ b/configAdapter.js @@ -4,15 +4,13 @@ const { HECO_CONFIG } = require("./config/heco-config"); const { KOVAN_CONFIG } = require("./config/kovan-config"); const { MBTEST_CONFIG } = require("./config/mbtest-config"); const { MBTESTNET_CONFIG } = require("./config/mbtestnet-config"); -const { OKTEST_CONFIG } = require("./config/oktest-config"); -const { ARBTEST_CONFIG } = require("./config/arbtest-config"); const { MATIC_CONFIG } = require("./config/matic-config"); const { ARB_CONFIG } = require("./config/arb-config"); +const { RINKEBY_CONFIG } = require("./config/rinkeby-config"); exports.GetConfig = function (network, accounts) { var CONFIG = {} switch (network) { - //mainnet case "live": CONFIG = ETH_CONFIG break; @@ -34,6 +32,11 @@ exports.GetConfig = function (network, accounts) { CONFIG.multiSigAddress = accounts[0] CONFIG.defaultMaintainer = accounts[0] break; + case "rinkeby": + CONFIG = RINKEBY_CONFIG + CONFIG.multiSigAddress = accounts[0] + CONFIG.defaultMaintainer = accounts[0] + break; case "mbtestnet": CONFIG = MBTEST_CONFIG CONFIG.multiSigAddress = accounts[0] @@ -44,16 +47,6 @@ exports.GetConfig = function (network, accounts) { CONFIG.multiSigAddress = accounts[0] CONFIG.defaultMaintainer = accounts[0] break; - case "oktest": - CONFIG = OKTEST_CONFIG - CONFIG.multiSigAddress = accounts[0] - CONFIG.defaultMaintainer = accounts[0] - break; - case "arbtest": - CONFIG = ARBTEST_CONFIG - CONFIG.multiSigAddress = accounts[0] - CONFIG.defaultMaintainer = accounts[0] - break; } return CONFIG -} \ No newline at end of file +} diff --git a/contracts/Factory/ERC20V2Factory.sol b/contracts/Factory/ERC20V2Factory.sol index 7c1b094..ca4a843 100644 --- a/contracts/Factory/ERC20V2Factory.sol +++ b/contracts/Factory/ERC20V2Factory.sol @@ -47,10 +47,15 @@ contract ERC20V2Factory is InitializableOwnable { address public immutable _CLONE_FACTORY_; address public _ERC20_TEMPLATE_; address public _CUSTOM_ERC20_TEMPLATE_; + uint256 public _CREATE_FEE_; // ============ Events ============ // 0 Std 1 TradeBurn or TradeFee 2 Mintable event NewERC20(address erc20, address creator, uint256 erc20Type); + event ChangeCreateFee(uint256 newFee); + event Withdraw(address account, uint256 amount); + event ChangeStdTemplate(address newStdTemplate); + event ChangeCustomTemplate(address newCustomTemplate); // ============ Registry ============ // creator -> token address list @@ -59,6 +64,10 @@ contract ERC20V2Factory is InitializableOwnable { // ============ Functions ============ + fallback() external payable {} + + receive() external payable {} + constructor( address cloneFactory, address erc20Template, @@ -74,7 +83,8 @@ contract ERC20V2Factory is InitializableOwnable { string memory name, string memory symbol, uint8 decimals - ) external returns (address newERC20) { + ) external payable returns (address newERC20) { + require(msg.value >= _CREATE_FEE_, "CREATE_FEE_NOT_ENOUGH"); newERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_ERC20_TEMPLATE_); IStdERC20(newERC20).init(msg.sender, totalSupply, name, symbol, decimals); _USER_STD_REGISTRY_[msg.sender].push(newERC20); @@ -90,7 +100,8 @@ contract ERC20V2Factory is InitializableOwnable { uint256 tradeFeeRatio, address teamAccount, bool isMintable - ) external returns (address newCustomERC20) { + ) external payable returns (address newCustomERC20) { + require(msg.value >= _CREATE_FEE_, "CREATE_FEE_NOT_ENOUGH"); newCustomERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_CUSTOM_ERC20_TEMPLATE_); ICustomERC20(newCustomERC20).init( @@ -121,4 +132,26 @@ contract ERC20V2Factory is InitializableOwnable { { return (_USER_STD_REGISTRY_[user], _USER_CUSTOM_REGISTRY_[user]); } + + // ============ Ownable ============= + function changeCreateFee(uint256 newFee) external onlyOwner { + _CREATE_FEE_ = newFee; + emit ChangeCreateFee(newFee); + } + + function withdraw() external onlyOwner { + uint256 amount = address(this).balance; + msg.sender.transfer(amount); + emit Withdraw(msg.sender, amount); + } + + function updateStdTemplate(address newStdTemplate) external onlyOwner { + _ERC20_TEMPLATE_ = newStdTemplate; + emit ChangeStdTemplate(newStdTemplate); + } + + function updateCustomTemplate(address newCustomTemplate) external onlyOwner { + _CUSTOM_ERC20_TEMPLATE_ = newCustomTemplate; + emit ChangeCustomTemplate(newCustomTemplate); + } } diff --git a/deploy-detail-periphery.txt b/deploy-detail-periphery.txt index 680b2e5..af555bb 100644 --- a/deploy-detail-periphery.txt +++ b/deploy-detail-periphery.txt @@ -501,3 +501,17 @@ network type: arb Deploy time: 2021/6/3 下午4:23:04 Deploy type: DODORouteProxy DODORouteProxy Address: 0x3E64F18168651d140AaE57e0cF325874d066bA9E +==================================================== +network type: rinkeby +Deploy time: 2021/6/29 上午10:05:29 +Deploy type: ERC20V2Factory +CustomERC20Address: 0x0Cd57DC8367362314C510446FD106B66989Eb81a +ERC20V2FactoryAddress: 0x6659fB6fc609e8c5159Aaccb80e49cCB8F64442a +Init ERC20V2Factory Tx: 0xbeb3138087efe8f2c41805c8b7a4fe94b17f8abbef4e5d739da8125d1e44e504 +==================================================== +network type: kovan +Deploy time: 2021/6/29 上午10:30:59 +Deploy type: ERC20V2Factory +CustomERC20Address: 0x3a0e0F2EDFC0e96BD700815f953Bcb6d8a6FF0AB +ERC20V2FactoryAddress: 0xce4Bdc3151bF9F9dcADAED961a65D32f7bAC5460 +Init ERC20V2Factory Tx: 0x5c03786d3e12b5c9532429f83c548a892c2d1ec613a44db81a9595e3bf017490 diff --git a/migrations/4_deploy_periphery.js b/migrations/4_deploy_periphery.js index dcc9fe9..47224c2 100644 --- a/migrations/4_deploy_periphery.js +++ b/migrations/4_deploy_periphery.js @@ -27,6 +27,9 @@ const DODOV2RouteHelper = artifacts.require("DODOV2RouteHelper"); const ERC20Mine = artifacts.require("ERC20Mine"); const vDODOMine = artifacts.require("vDODOMine"); +const ERC20V2Factory = artifacts.require("ERC20V2Factory"); +const ERC20 = artifacts.require("InitializableERC20"); +const CustomERC20 = artifacts.require("CustomERC20"); const CurveAdapter = artifacts.require("CurveUnderlyingAdapter"); @@ -44,7 +47,7 @@ module.exports = async (deployer, network, accounts) => { let DppFactoryAddress = CONFIG.DPPFactory; let UpCpFactoryAddress = CONFIG.UpCpFactory; let CpFactoryAddress = CONFIG.CrowdPoolingFactory; - + let ERC20V2FactoryAddress = CONFIG.ERC20V2Factory; let DODOCirculationHelperAddress = CONFIG.DODOCirculationHelper; let GovernanceAddress = CONFIG.Governance; @@ -56,10 +59,47 @@ module.exports = async (deployer, network, accounts) => { let DefaultPermissionAddress = CONFIG.PermissionManager; let CpTemplateAddress = CONFIG.CP; let DvmTemplateAddress = CONFIG.DVM; + let CustomERC20Address = CONFIG.CustomERC20; + let ERC20Address = CONFIG.ERC20; let multiSigAddress = CONFIG.multiSigAddress; let defaultMaintainer = CONFIG.defaultMaintainer; + if (deploySwitch.ERC20V2Factory) { + logger.log("===================================================="); + logger.log("network type: " + network); + logger.log("Deploy time: " + new Date().toLocaleString()); + logger.log("Deploy type: ERC20V2Factory"); + + if (ERC20Address == "") { + await deployer.deploy(ERC20); + ERC20Address = ERC20.address; + logger.log("ERC20Address: ", ERC20Address); + } + if (CustomERC20Address == "") { + await deployer.deploy(CustomERC20); + CustomERC20Address = CustomERC20.address; + logger.log("CustomERC20Address: ", CustomERC20Address); + } + + if (ERC20V2FactoryAddress == "") { + await deployer.deploy( + ERC20V2Factory, + CloneFactoryAddress, + ERC20Address, + CustomERC20Address + ); + ERC20V2FactoryAddress = ERC20V2Factory.address; + logger.log("ERC20V2FactoryAddress: ", ERC20V2FactoryAddress); + + const erc20V2FactoryInstance = await ERC20V2Factory.at(ERC20V2FactoryAddress); + var tx = await erc20V2FactoryInstance.initOwner(multiSigAddress); + logger.log("Init ERC20V2Factory Tx:", tx.tx); + } + + } + + if (deploySwitch.ERC20Mine) { logger.log("===================================================="); logger.log("network type: " + network); diff --git a/truffle-config.js b/truffle-config.js index 0a1d4ed..aa5bed1 100644 --- a/truffle-config.js +++ b/truffle-config.js @@ -58,7 +58,8 @@ module.exports = { DSP: false, LockedVault: false, MULTIHOP: false, - CpProxy: false + CpProxy: false, + ERC20V2Factory: false }, networks: { @@ -87,6 +88,18 @@ module.exports = { skipDryRun: true }, + rinkeby: { + networkCheckTimeout: 100000, + provider: function () { + return new HDWalletProvider(privKey, "https://rinkeby.infura.io/v3/" + infuraId); + // return new HDWalletProvider(privKey, "https://eth-rinkeby.dodoex.io"); + }, + gas: 10000000, + gasPrice: 1500000000, + network_id: 4, + skipDryRun: true + }, + live: { networkCheckTimeout: 100000, provider: function () {