Skip to content

Commit 0ebd33a

Browse files
dmvtMickdeGraaf
andauthored
Fix/deploy issues usd test (#40)
* adds USD test allocation and fixes some deploy bugs * Bugfixes Co-authored-by: Mick de Graaf <mick@mickdegraaf.nl>
1 parent 844e723 commit 0ebd33a

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

allocations/mainnet/USD++test.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "PieDAO Test USD Pool",
3+
"symbol": "TU",
4+
"initialValue": "1",
5+
"initialSupply": "100",
6+
"cap": "10",
7+
"tokens": [
8+
{
9+
"name": "USDC",
10+
"decimals": "6",
11+
"address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
12+
"weight": "47.22",
13+
"value": "1"
14+
},
15+
{
16+
"name": "DAI",
17+
"decimals": "18",
18+
"address": "0x6B175474E89094C44Da98b954EedeAC495271d0F",
19+
"weight": "20.42",
20+
"value": "1"
21+
},
22+
{
23+
"name": "TUSD",
24+
"decimals": "18",
25+
"address": "0x0000000000085d4780B73119b644AE5ecd22b376",
26+
"weight": "28.58",
27+
"value": "1"
28+
},
29+
{
30+
"name": "sUSD",
31+
"decimals": "18",
32+
"address": "0x57ab1e02fee23774580c119740129eac7081e9d3",
33+
"weight": "3.78",
34+
"value": "1"
35+
}
36+
]
37+
}
38+

buidler.config.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,10 @@ task("deploy-pool-from-factory", "deploys a pie smart pool from the factory")
122122
const tokenAmounts: BigNumberish[] = [];
123123
const tokenWeights: BigNumberish[] = [];
124124

125-
126-
127125
for (const token of tokens) {
128126
tokenAddresses.push(token.address);
129-
tokenWeights.push(constants.WeiPerEther.mul(token.weight).div(2));
130-
127+
tokenWeights.push(parseEther(token.weight).div(2));
128+
131129
// Calc amount
132130
let amount = new BigNumber((config.initialValue / token.value * token.weight / 100 * config.initialSupply * 10 ** token.decimals).toString());
133131
tokenAmounts.push(amount);
@@ -224,25 +222,25 @@ task("deploy-smart-pool-complete")
224222

225223
for (const token of tokens) {
226224
tokenAddresses.push(token.address);
227-
tokenWeights.push(constants.WeiPerEther.mul(token.weight).div(2));
228-
225+
tokenWeights.push(parseEther(token.weight).div(2));
226+
229227
// Calc amount
230-
let amount = new BigNumber((config.initialValue / token.value * token.weight / 100 * config.initialSupply * 10 ** token.decimals).toString());
228+
const amount = new BigNumber(Math.floor((config.initialValue / token.value * token.weight / 100 * config.initialSupply * 10 ** token.decimals)).toString());
231229
tokenAmounts.push(amount);
232230

233231
// Approve factory to spend token
234232
const tokenContract = IERC20Factory.connect(token.address, signers[0]);
235233

236234
const allowance = await tokenContract.allowance(await signers[0].getAddress(), factory.address);
237235
if(allowance.lt(amount)) {
238-
const approveTx = await tokenContract.approve(factory.address, constants.WeiPerEther);
236+
const approveTx = await tokenContract.approve(factory.address, constants.MaxUint256);
239237
console.log(`Approved: ${token.address} tx: ${approveTx.hash}`);
240238
await approveTx.wait(1);
241239
}
242-
240+
243241
}
244242

245-
const tx = await factory.newProxiedSmartPool(name, symbol, initialSupply, tokenAddresses, tokenAmounts, tokenWeights, cap);
243+
const tx = await factory.newProxiedSmartPool(name, symbol, initialSupply, tokenAddresses, tokenAmounts, tokenWeights, cap, {gasLimit: 8000000});
246244
const receipt = await tx.wait(2); //wait for 2 confirmations
247245
const event = receipt.events.pop();
248246
console.log(`Deployed smart pool at : ${event.address}`);
@@ -329,7 +327,6 @@ task("deploy-balancer-pool", "deploys a balancer pool from a factory")
329327
console.log(`Deployed balancer pool at : ${event.address}`);
330328
});
331329

332-
//npx buidler balancer-bind-token --pool 0xfE682598599015d9f0EE4A4B56dE1CEfd27Cb7d5 --token 0x363BE4b8F3a341f720AbCDC666b1FB769BE73852 --balance 0.07 --decimals 6 --weight 3.5 --network kovan
333330
task("balancer-bind-token", "binds a token to a balancer pool")
334331
.addParam("pool", "the address of the Balancer pool")
335332
.addParam("token", "address of the token to bind")
@@ -378,7 +375,7 @@ task("balancer-set-controller")
378375
.setAction(async(taskArgs, { ethers }) => {
379376
const signers = await ethers.getSigners();
380377
const pool = IBPoolFactory.connect(taskArgs.pool, signers[0]);
381-
378+
382379
const tx = await pool.setController(taskArgs.controller);
383380
const receipt = await tx.wait(1);
384381

0 commit comments

Comments
 (0)