Skip to content

Commit

Permalink
Fix/deploy issues usd test (#40)
Browse files Browse the repository at this point in the history
* adds USD test allocation and fixes some deploy bugs

* Bugfixes

Co-authored-by: Mick de Graaf <[email protected]>
  • Loading branch information
dmvt and MickdeGraaf authored Jun 8, 2020
1 parent 844e723 commit 0ebd33a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
38 changes: 38 additions & 0 deletions allocations/mainnet/USD++test.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

21 changes: 9 additions & 12 deletions buidler.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -224,25 +222,25 @@ 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
const tokenContract = IERC20Factory.connect(token.address, signers[0]);

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}`);
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 0ebd33a

Please sign in to comment.