From 0ebd33aea3c806fd0657b1241de56f43cd6ef60f Mon Sep 17 00:00:00 2001 From: Dan Matthews Date: Mon, 8 Jun 2020 12:07:42 +0300 Subject: [PATCH] Fix/deploy issues usd test (#40) * adds USD test allocation and fixes some deploy bugs * Bugfixes Co-authored-by: Mick de Graaf --- allocations/mainnet/USD++test.json | 38 ++++++++++++++++++++++++++++++ buidler.config.ts | 21 +++++++---------- 2 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 allocations/mainnet/USD++test.json diff --git a/allocations/mainnet/USD++test.json b/allocations/mainnet/USD++test.json new file mode 100644 index 0000000..8eba8a7 --- /dev/null +++ b/allocations/mainnet/USD++test.json @@ -0,0 +1,38 @@ +{ + "name": "PieDAO Test USD Pool", + "symbol": "TU", + "initialValue": "1", + "initialSupply": "100", + "cap": "10", + "tokens": [ + { + "name": "USDC", + "decimals": "6", + "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", + "weight": "47.22", + "value": "1" + }, + { + "name": "DAI", + "decimals": "18", + "address": "0x6B175474E89094C44Da98b954EedeAC495271d0F", + "weight": "20.42", + "value": "1" + }, + { + "name": "TUSD", + "decimals": "18", + "address": "0x0000000000085d4780B73119b644AE5ecd22b376", + "weight": "28.58", + "value": "1" + }, + { + "name": "sUSD", + "decimals": "18", + "address": "0x57ab1e02fee23774580c119740129eac7081e9d3", + "weight": "3.78", + "value": "1" + } + ] +} + diff --git a/buidler.config.ts b/buidler.config.ts index 0da2985..0152e90 100644 --- a/buidler.config.ts +++ b/buidler.config.ts @@ -122,12 +122,10 @@ task("deploy-pool-from-factory", "deploys a pie smart pool from the factory") const tokenAmounts: BigNumberish[] = []; const tokenWeights: BigNumberish[] = []; - - for (const token of tokens) { tokenAddresses.push(token.address); - tokenWeights.push(constants.WeiPerEther.mul(token.weight).div(2)); - + tokenWeights.push(parseEther(token.weight).div(2)); + // Calc amount let amount = new BigNumber((config.initialValue / token.value * token.weight / 100 * config.initialSupply * 10 ** token.decimals).toString()); tokenAmounts.push(amount); @@ -224,10 +222,10 @@ task("deploy-smart-pool-complete") for (const token of tokens) { tokenAddresses.push(token.address); - tokenWeights.push(constants.WeiPerEther.mul(token.weight).div(2)); - + tokenWeights.push(parseEther(token.weight).div(2)); + // Calc amount - let amount = new BigNumber((config.initialValue / token.value * token.weight / 100 * config.initialSupply * 10 ** token.decimals).toString()); + const amount = new BigNumber(Math.floor((config.initialValue / token.value * token.weight / 100 * config.initialSupply * 10 ** token.decimals)).toString()); tokenAmounts.push(amount); // Approve factory to spend token @@ -235,14 +233,14 @@ task("deploy-smart-pool-complete") const allowance = await tokenContract.allowance(await signers[0].getAddress(), factory.address); if(allowance.lt(amount)) { - const approveTx = await tokenContract.approve(factory.address, constants.WeiPerEther); + const approveTx = await tokenContract.approve(factory.address, constants.MaxUint256); console.log(`Approved: ${token.address} tx: ${approveTx.hash}`); await approveTx.wait(1); } - + } - const tx = await factory.newProxiedSmartPool(name, symbol, initialSupply, tokenAddresses, tokenAmounts, tokenWeights, cap); + const tx = await factory.newProxiedSmartPool(name, symbol, initialSupply, tokenAddresses, tokenAmounts, tokenWeights, cap, {gasLimit: 8000000}); const receipt = await tx.wait(2); //wait for 2 confirmations const event = receipt.events.pop(); console.log(`Deployed smart pool at : ${event.address}`); @@ -329,7 +327,6 @@ task("deploy-balancer-pool", "deploys a balancer pool from a factory") console.log(`Deployed balancer pool at : ${event.address}`); }); -//npx buidler balancer-bind-token --pool 0xfE682598599015d9f0EE4A4B56dE1CEfd27Cb7d5 --token 0x363BE4b8F3a341f720AbCDC666b1FB769BE73852 --balance 0.07 --decimals 6 --weight 3.5 --network kovan task("balancer-bind-token", "binds a token to a balancer pool") .addParam("pool", "the address of the Balancer pool") .addParam("token", "address of the token to bind") @@ -378,7 +375,7 @@ task("balancer-set-controller") .setAction(async(taskArgs, { ethers }) => { const signers = await ethers.getSigners(); const pool = IBPoolFactory.connect(taskArgs.pool, signers[0]); - + const tx = await pool.setController(taskArgs.controller); const receipt = await tx.wait(1);