update v2 deploy shell

This commit is contained in:
owen05
2021-01-08 20:43:12 +08:00
parent 34d9ccf668
commit 1677eda8ac
5 changed files with 151 additions and 76 deletions

View File

@@ -1,4 +1,5 @@
const fs = require("fs");
const Web3 = require('web3');
const { deploySwitch } = require('../truffle-config.js')
const file = fs.createWriteStream("../deploy-detail-v2.0.txt", { 'flags': 'a' });
let logger = new console.Console(file, file);
@@ -9,6 +10,7 @@ const ConstFeeRateModelTemplate = artifacts.require("ConstFeeRateModel");
const PermissionManagerTemplate = artifacts.require("PermissionManager");
const ExternalValueTemplate = artifacts.require("ExternalValue");
const ERC20Template = artifacts.require("InitializableERC20");
const DvmTemplate = artifacts.require("DVM");
const DppTemplate = artifacts.require("DPP");
const DppAdminTemplate = artifacts.require("DPPAdmin");
@@ -20,6 +22,7 @@ const CpFactory = artifacts.require("CrowdPoolingFactory");
const DODOApprove = artifacts.require("DODOApprove");
const DODOProxyV2 = artifacts.require("DODOV2Proxy01");
const DODOIncentive = artifacts.require("DODOIncentive");
const DODOSellHelper = artifacts.require("DODOSellHelper");
const DODOCalleeHelper = artifacts.require("DODOCalleeHelper");
const DODOV2RouteHelper = artifacts.require("DODOV2RouteHelper");
@@ -53,6 +56,9 @@ module.exports = async (deployer, network, accounts) => {
let CpFactoryAddress = "";
//Approve
let DODOApproveAddress = "";
//Incentive
let DODOIncentiveAddress = "";
let DODOTokenAddress = "";
//Account
let multiSigAddress = "";
let defaultMaintainer = "";
@@ -74,7 +80,7 @@ module.exports = async (deployer, network, accounts) => {
// DefaultGasSourceAddress = "0xE0c0df0e0be7ec4f579503304a6C186cA4365407";
DefaultMtFeeRateAddress = "0xEfdE4225AC747136289979e29f1236527b2E4DB1";
DefaultPermissionAddress = "0xACc7E23368261e1E02103c4e5ae672E7D01f5797";
DvmTemplateAddress = "";
DppTemplateAddress = "";
DppAdminTemplateAddress = "";
@@ -85,6 +91,8 @@ module.exports = async (deployer, network, accounts) => {
CpFactoryAddress = "";
//Approve
DODOApproveAddress = "";
DODOIncentiveAddress = "";
DODOTokenAddress = "0xfF2985D13953Cb92ecc585aA2B6A4AF8cB46068f";
//Account
multiSigAddress = accounts[0];
defaultMaintainer = accounts[0];
@@ -94,6 +102,7 @@ module.exports = async (deployer, network, accounts) => {
WETHAddress = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
chiAddress = "0x0000000000004946c0e9F43F4Dee607b0eF1fA1c";
DODOCalleeHelperAddress = "";
DODORouteV2HelperAddress = "";
//Template
CloneFactoryAddress = "";
// FeeRateModelTemplateAddress = "";
@@ -115,6 +124,8 @@ module.exports = async (deployer, network, accounts) => {
CpFactoryAddress = "";
//Proxy
DODOApproveAddress = "";
DODOIncentiveAddress = "";
DODOTokenAddress = "0x43Dfc4159D86F3A37A5A4B3D4580b888ad7d4DDd";
//Account
multiSigAddress = "0x95C4F5b83aA70810D4f142d58e5F7242Bd891CB0";
defaultMaintainer = "0x95C4F5b83aA70810D4f142d58e5F7242Bd891CB0";
@@ -124,6 +135,7 @@ module.exports = async (deployer, network, accounts) => {
WETHAddress = "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c";
chiAddress = "0x0000000000000000000000000000000000000000";
DODOCalleeHelperAddress = "";
DODORouteV2HelperAddress = "";
//Template
CloneFactoryAddress = "";
// FeeRateModelTemplateAddress = "";
@@ -145,28 +157,20 @@ module.exports = async (deployer, network, accounts) => {
CpFactoryAddress = "";
//Proxy
DODOApproveAddress = "";
DODOIncentiveAddress = "";
DODOTokenAddress = "";
//Account
multiSigAddress = "";
defaultMaintainer = "";
multiSigAddress = "0x4073f2b9bB95774531b9e23d206a308c614A943a";
defaultMaintainer = "0x4073f2b9bB95774531b9e23d206a308c614A943a";
} else return;
if(deploySwitch.HELPER_V2) {
logger.log("====================================================");
logger.log("network type: " + network);
logger.log("Deploy time: " + new Date().toLocaleString());
logger.log("Deploy type: HELPER V2");
await deployer.deploy(DODOV2RouteHelper, "0xF2a62693FB14b326C3719e5aeEF28e8e66dC954e","0x58Bc8D248AcbE95CE29CF893C6666D58AF92d941");
DODOV2RouteHelperAddress = DODOV2RouteHelper.address;
logger.log("DODOV2RouteHelper Address: ", DODOV2RouteHelperAddress);
}
if (deploySwitch.DEPLOY_V2) {
logger.log("====================================================");
logger.log("network type: " + network);
logger.log("Deploy time: " + new Date().toLocaleString());
logger.log("Deploy type: V2");
if (DODOTokenAddress == "") return;
//Helper
if (DODOSellHelperAddress == "") {
await deployer.deploy(DODOSellHelper);
@@ -262,6 +266,16 @@ module.exports = async (deployer, network, accounts) => {
logger.log("DODOApprove Address: ", DODOApproveAddress);
}
//Incentive
if (DODOIncentiveAddress == "") {
await deployer.deploy(DODOIncentive, DODOTokenAddress);
DODOIncentiveAddress = DODOIncentive.address;
logger.log("DODOIncentiveAddress: ", DODOIncentiveAddress);
const DODOIncentiveInstance = await DODOIncentive.at(DODOIncentiveAddress);
var tx = await DODOIncentiveInstance.initOwner(multiSigAddress);
logger.log("DODOIncentive Init tx: ", tx.tx);
}
//Factory
if (DvmFactoryAddress == "") {
await deployer.deploy(
@@ -294,7 +308,7 @@ module.exports = async (deployer, network, accounts) => {
var tx = await DppFactoryInstance.initOwner(multiSigAddress);
logger.log("Init DppFactory Tx:", tx.tx);
}
if (CpFactoryAddress == "") {
await deployer.deploy(
CpFactory,
@@ -323,16 +337,41 @@ module.exports = async (deployer, network, accounts) => {
CpFactoryAddress,
WETHAddress,
DODOApproveAddress,
DODOSellHelperAddress
DODOSellHelperAddress,
chiAddress,
DODOIncentiveAddress
);
logger.log("DODOProxyV2 Address: ", DODOProxyV2.address);
const DODOProxyV2Instance = await DODOProxyV2.at(DODOProxyV2.address);
var tx = await DODOProxyV2Instance.initOwner(multiSigAddress);
logger.log("Init DODOProxyV2 Tx:", tx.tx);
const DODOApproveInstance = await DODOApprove.at(DODOApproveAddress);
var tx = await DODOApproveInstance.init(multiSigAddress,DODOProxyV2.address);
var tx = await DODOApproveInstance.init(multiSigAddress, DODOProxyV2.address);
logger.log("DODOApprove Init tx: ", tx.tx);
if (network == 'kovan') {
//1. Proxy whiteList
//2. ChangeDODO Incentive proxy
const DODOIncentiveInstance = await DODOIncentive.at(DODOIncentiveAddress);
var tx = await DODOIncentiveInstance.changeDODOProxy(DODOProxyV2.address);
logger.log("DODOIncentive ChangeProxy tx: ", tx.tx);
//3. Open trade incentive
// const provider = new Web3.providers.HttpProvider("https://kovan.infura.io/v3/22d4a3b2df0e47b78d458f43fe50a199");
// if (!provider) {
// throw new Error(`Unable to find provider for network: ${network}`)
// }
// const web3 = new Web3(provider)
// const blockNum = await web3.eth.getBlockNumber();
// var tx = await DODOIncentiveInstance.switchIncentive(blockNum + 1);
// logger.log("DODOIncentive OpenSwitch tx: ", tx.tx);
//4. Transfer DODO to Trade Incentive
}
}
};

View File

@@ -13,54 +13,48 @@ const DVMFactory = artifacts.require("DVMFactory");
const DPPFactory = artifacts.require("DPPFactory");
const POOL_PARAM = [
// {
// baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
// quoteAddr: "0x69c8a7fc6e05d7aa36114b3e35f62deca8e11f6e", //USDC
// lpFeeRate: "3000000000000000", //0.003
// mtFeeRate: "1000000000000000", //0.001
// i: "10000000", //10
// k: "500000000000000000" //0.5
// },
// {
// baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
// quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
// lpFeeRate: "3000000000000000", //0.003
// mtFeeRate: "1000000000000000", //0.001
// i: "10000000", //10
// k: "0" //0
// },
// {
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
// quoteAddr: "0x69c8a7fc6e05d7aa36114b3e35f62deca8e11f6e", //USDC
// lpFeeRate: "3000000000000000", //0.003
// mtFeeRate: "1000000000000000", //0.001
// i: "5000000", //5
// k: "1000000000000000000" //1
// },
// {
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
// quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
// lpFeeRate: "3000000000000000", //0.003
// mtFeeRate: "1000000000000000", //0.001
// i: "8000000", //8
// k: "900000000000000000" //0.9
// },
{
baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
lpFeeRate: "0", //0
i: "10000000", //10
k: "500000000000000000" //0.5
},
{
baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
lpFeeRate: "3000000000000000", //0.003
mtFeeRate: "1000000000000000", //0.001
i: "45000000000000000000", //45
k: "800000000000000000" //0.8
i: "10000000", //10
k: "0" //0
},
{
baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
lpFeeRate: "3000000000000000", //0.003
mtFeeRate: "1000000000000000", //0.001
i: "30000000000000000000", //30
k: "300000000000000000" //0.3
quoteAddr: "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b", //USDC
lpFeeRate: "0", //0
i: "5000000", //5
k: "1000000000000000000" //1
},
{
baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
quoteAddr: "0x156595bAF85D5C29E91d959889B022d952190A64", //USDT
lpFeeRate: "3000000000000000", //0.003
i: "8000000", //8
k: "900000000000000000" //0.9
},
// {
// baseAddr: "0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE", //ABC0
// quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
// lpFeeRate: "3000000000000000", //0.003
// i: "45000000000000000000", //45
// k: "800000000000000000" //0.8
// },
// {
// baseAddr: "0xd7f02D1b4F9495B549787808503Ecfd231C3fbDA", //ABC1
// quoteAddr: "0x5eca15b12d959dfcf9c71c59f8b467eb8c6efd0b", //WETH
// lpFeeRate: "0", //0.003
// i: "30000000000000000000", //30
// k: "300000000000000000" //0.3
// },
];
module.exports = async (deployer, network, accounts) => {
@@ -70,10 +64,10 @@ module.exports = async (deployer, network, accounts) => {
let MintableERC20TemplateAddress = "0xA45a64DAba80757432fA4d654Df12f65f020C13C";
let ERC20FactoryAddress = "0xCb1A2f64EfB02803276BFB5a8D511C4D950282a0";
let DPPFactoryAddress = "0x58Bc8D248AcbE95CE29CF893C6666D58AF92d941";
let DVMFactoryAddress = "0xF2a62693FB14b326C3719e5aeEF28e8e66dC954e";
let DODOApproveAddress = "0xeEA9F08eBfde6915AB1C0051F3eB2612DbA95d5D";
let DODOProxyV2Address = "0x97B779AD504bbd5b1BFB50e57584a876Dc65171a";
let DPPFactoryAddress = "0x6D4a70354cd03ae3A8461eDE9A4dAd445a169a6B";
let DVMFactoryAddress = "0x0ac46584e4566d5841E7D708Ab4D92Ef191fFe37";
let DODOApproveAddress = "0xe51d8085aB43AC8BC98e965b2F7B79b998c23814";
let DODOProxyV2Address = "0xB035847e685925647AaA8b9d74e3bFF36f81EBcB";
const provider = new Web3.providers.HttpProvider("https://kovan.infura.io/v3/22d4a3b2df0e47b78d458f43fe50a199");
@@ -104,7 +98,7 @@ module.exports = async (deployer, network, accounts) => {
const DODOProxyV2Instance = await DODOProxyV2.at(DODOProxyV2Address);
var tx = await DODOProxyV2Instance.dodoSwapV2TokenToToken(
accounts[0],
"0x69c8a7fc6e05d7aa36114b3e35f62deca8e11f6e",
"0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b",
"0xd8C30a4E866B188F16aD266dC3333BD47F34ebaE",
web3.utils.toWei("10", 'mwei'),
0,
@@ -125,7 +119,7 @@ module.exports = async (deployer, network, accounts) => {
const token3Addr = "0x123ee47BaE3F64d422F2FB18ac444B47c1880F4C";
const token4Addr = "0x0ab8EF8B19655F32959c83e5fC5cD6536065D28f";
const token5Addr = "0x6462794c19e6b4543BEC56200212c7c746bbB9eB";
const quote0Addr = "0x69c8a7fc6e05d7aa36114b3e35f62deca8e11f6e";
const quote0Addr = "0x43688f367eb83697c3ca5d03c5055b6bd6f6ac4b";
const quote1Addr = "0x156595bAF85D5C29E91d959889B022d952190A64";
const token0 = await ERC20Template.at(token0Addr);
const token1 = await ERC20Template.at(token1Addr);
@@ -158,14 +152,13 @@ module.exports = async (deployer, network, accounts) => {
const DPPFactoryInstance = await DPPFactory.at(DPPFactoryAddress);
const assetTo = accounts[0];
const baseInAmount = web3.utils.toWei("1000", 'ether');
// const quoteInAmount = web3.utils.toWei("100", 'mwei');
const quoteInAmount = web3.utils.toWei("0", 'ether');
const baseInAmount = web3.utils.toWei("100000", 'ether');
const quoteInAmount = web3.utils.toWei("10000", 'mwei');
// const quoteInAmount = web3.utils.toWei("0", 'ether');
const deadline = Math.floor(new Date().getTime() / 1000 + 60 * 10);
//DVM Pool
for (var i = 0; i < POOL_PARAM.length; i++) {
tx = await DODOProxyV2Instance.createDODOVendingMachine(
assetTo,
POOL_PARAM[i].baseAddr,
POOL_PARAM[i].quoteAddr,
baseInAmount,
@@ -226,11 +219,11 @@ module.exports = async (deployer, network, accounts) => {
const ERC20FactoryInstance = await ERC20Factory.at(ERC20FactoryAddress);
const totalSupply = web3.utils.toWei("100000000", 'mwei');
for (let i = 0; i < 8; i++) {
var tx = await ERC20FactoryInstance.createStdERC20(totalSupply, 'ABC Token', 'ABC' + i, 18);
const totalSupply = web3.utils.toWei("1000000000", 'ether');
for (let i = 0; i < 1; i++) {
var tx = await ERC20FactoryInstance.createStdERC20(totalSupply, 'DODO Bird', 'DODO', 18);
// var tx = await ERC20FactoryInstance.createStdERC20(totalSupply, 'USDT Token', 'USDT', 6);
logger.log("ERC20 address: ", tx.logs[0].args['erc20'] + "; Symbol:" + 'ABC' + i);
logger.log("ERC20 address: ", tx.logs[0].args['erc20'] + "; Symbol:" + 'DODO');
// logger.log("ERC20 address: ", tx.logs[0].args['erc20'] + "; Symbol:" + 'USDT');
}
}