Skip to content

Commit

Permalink
Deployment fixes (#61)
Browse files Browse the repository at this point in the history
* testing allocation

* 1 too many zeros removed from deploy script

* WIP deployment

* cleanup

* Update packages

* Delete flat.sol

* Update example.env
  • Loading branch information
MickdeGraaf authored Sep 16, 2020
1 parent 5d44f96 commit 5fcb15d
Show file tree
Hide file tree
Showing 7 changed files with 506 additions and 106 deletions.
24 changes: 24 additions & 0 deletions allocations/localhost/UTXO.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "PieDAO UTXO",
"symbol": "UTXO",
"initialValue": "1",
"initialSupply": "1",
"cap": "10",
"tokens": [
{
"name": "pBTC",
"decimals": "18",
"address": "0x0078371BDeDE8aAc7DeBfFf451B74c5EDB385Af7",
"weight": "70",
"value": "10917.27"
},
{
"name": "pLTC",
"decimals": "18",
"address": "0x7c2C195CD6D34B8F845992d380aADB2730bB9C6F",
"weight": "30",
"value": "50.05"
}
]
}

24 changes: 24 additions & 0 deletions allocations/mainnet/UTXO.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "PieDAO UTXO",
"symbol": "UTXO",
"initialValue": "1",
"initialSupply": "1",
"cap": "10",
"tokens": [
{
"name": "pBTC",
"decimals": "18",
"address": "0x5228a22e72ccc52d415ecfd199f99d0665e7733b",
"weight": "70",
"value": "10466.54"
},
{
"name": "pLTC",
"decimals": "18",
"address": "0x5979F50f1D4c08f9A53863C2f39A7B0492C38d0f",
"weight": "30",
"value": "48.22"
}
]
}

24 changes: 24 additions & 0 deletions allocations/rinkeby/UTXO.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "PieDAO UTXO",
"symbol": "UTXO",
"initialValue": "1",
"initialSupply": "1",
"cap": "10",
"tokens": [
{
"name": "pBTC",
"decimals": "18",
"address": "0x013882e5481ec8a93BcDC45bEb0314006718ffD8",
"weight": "70",
"value": "10466.54"
},
{
"name": "pLTC",
"decimals": "18",
"address": "0xB9335F7985Bb9B7F8293cab50b95938895BCD78c",
"weight": "30",
"value": "48.22"
}
]
}

27 changes: 16 additions & 11 deletions buidler.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import LibAddRemoveTokenArtifact from "./artifacts/LibAddRemoveToken.json";
import LibWeightsArtifact from "./artifacts/LibWeights.json";
import LibPoolMathArtifact from "./artifacts/LibPoolMath.json";

// Uncomment line below when doing gas optimisations on a local network
usePlugin("buidler-gas-reporter");
usePlugin("@nomiclabs/buidler-waffle");
usePlugin("@nomiclabs/buidler-etherscan");
usePlugin("solidity-coverage");
Expand Down Expand Up @@ -74,8 +76,9 @@ const config: ExtendedBuidlerConfig = {
},
rinkeby: {
url: `https://rinkeby.infura.io/v3/${INFURA_API_KEY}`,
blockGasLimit: 8000000,
gas: 8000000,
blockGasLimit: 12000000,
gas: 12000000,
gasPrice: 20000000000,
accounts: [
RINKEBY_PRIVATE_KEY,
RINKEBY_PRIVATE_KEY_SECONDARY
Expand All @@ -88,10 +91,6 @@ const config: ExtendedBuidlerConfig = {
}
},
etherscan: {
// The url for the Etherscan API you want to use.
url: "https://api.etherscan.io/api",
// Your API key for Etherscan
// Obtain one at https://etherscan.io/
apiKey: ETHERSCAN_API_KEY
},
};
Expand All @@ -111,7 +110,7 @@ task("deploy-pie-smart-pool-factory", "deploys a pie smart pool factory")
const factory = await (new PProxiedFactoryFactory(signers[0])).deploy();
console.log(`Factory deployed at: ${factory.address}`);

const implementation = await run("deploy-pie-smart-pool") as Pv2SmartPool;
const implementation = await run("deploy-libraries-and-smartpool") as Pv2SmartPool;
await implementation.init(PLACE_HOLDER_ADDRESS, "IMPL", "IMPL", "1337");

await factory.init(taskArgs.balancerFactory, implementation.address);
Expand Down Expand Up @@ -144,7 +143,7 @@ task("deploy-pool-from-factory", "deploys a pie smart pool from the factory")

// Calc amount
const amount = new BigNumber(Math.floor((allocation.initialValue / token.value * token.weight / 100 * allocation.initialSupply * 10 ** token.decimals)).toString());

tokenAmounts.push(amount);
// Approve factory to spend token
const tokenContract = Ierc20Factory.connect(token.address, signers[0]);

Expand All @@ -156,8 +155,8 @@ task("deploy-pool-from-factory", "deploys a pie smart pool from the factory")
}
}

const tx = await factory.newProxiedSmartPool(name, symbol, initialSupply, tokenAddresses, tokenAmounts, tokenWeights, cap);
const receipt = await tx.wait(2); // wait for 2 confirmations
const tx = await factory.newProxiedSmartPool(name, symbol, initialSupply, tokenAddresses, tokenAmounts, tokenWeights, cap, { gasLimit: 10000000 });
const receipt = await tx.wait(); // wait for 2 confirmations
const event = receipt.events.pop();
console.log(`Deployed smart pool at : ${event.address}`);
return event.address;
Expand All @@ -174,7 +173,7 @@ task("deploy-pie-smart-pool", "deploys a pie smart pool")
const linkedArtifact = linkArtifact(Pv2SmartPoolArtifact, libraries);

const smartpool = (await deployContract(signers[0] as Wallet, linkedArtifact, [], {
gasLimit: 100000000,
gasLimit: 12000000,
})) as Pv2SmartPool;

console.log(`Pv2SmartPool deployed at: ${smartpool.address}`);
Expand Down Expand Up @@ -218,6 +217,7 @@ task("deploy-smart-pool-complete")
.setAction(async(taskArgs, { ethers, run }) => {
// run deploy factory task
const smartPoolFactoryAddress = await run("deploy-pie-smart-pool-factory", {balancerFactory: taskArgs.balancerFactory});

// run deploy pool from factory task
await run("deploy-pool-from-factory", { factory: smartPoolFactoryAddress, allocation: taskArgs.allocation });
});
Expand Down Expand Up @@ -289,6 +289,7 @@ task("deploy-balancer-factory", "deploys a balancer factory")
.setAction(async(taskArgs, { ethers }) => {
const signers = await ethers.getSigners();
const factoryAddress = await deployBalancerFactory(signers[0]);

console.log(`Deployed balancer factory at: ${factoryAddress}`);
});

Expand Down Expand Up @@ -395,7 +396,11 @@ internalTask("deploy-libraries-and-smartpool")
const signers = await ethers.getSigners();
const libraries = await run("deploy-libraries-and-get-object");

console.log("libraries");
console.log(libraries);

const contract = (await deploy("PV2SmartPool", {contractName: "PV2SmartPool", from: await signers[0].getAddress(), libraries}));

return Pv2SmartPoolFactory.connect(contract.address, signers[0]);
});

Expand Down
2 changes: 1 addition & 1 deletion example.env
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
INFURA_API_KEY=
KOVAN_PRIVATE_KEY=0x.....
KOVAN_PRIVATE_KEY_SECONDARY=0x.....
RINKEBY_PRIVATE_KEY=0x.....
RINKEBY_PRIVATE_KEY=0x....
RINKEBY_PRIVATE_KEY_SECONDARY=0x.....
MAINNET_PRIVATE_KEY=0x....
MAINNET_PRIVATE_KEY_SECONDARY=0x....
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
"homepage": "https://github.com/pie-dao/proxied-balancer-factory/readme",
"devDependencies": {
"@nomiclabs/buidler-ethers": "^1.3.4",
"@nomiclabs/buidler-etherscan": "^1.3.3",
"@nomiclabs/buidler-waffle": "^1.3.5",
"@typechain/ethers-v4": "^1.0.0",
"@types/chai": "^4.2.8",
"@types/mocha": "^7.0.1",
"@types/node": "^13.7.0",
"buidler-deploy": "^0.4.13",
"buidler-gas-reporter": "^0.1.3",
"chai": "^4.2.0",
"ethereum-waffle": "^2.3.2",
"ethers": "^4.0.47",
Expand All @@ -54,7 +54,8 @@
"test": "test"
},
"dependencies": {
"@nomiclabs/buidler": "^1.4.1",
"@nomiclabs/buidler": "^1.4.7",
"@nomiclabs/buidler-etherscan": "^2.1.0",
"@pie-dao/mock-contracts": "0.0.9",
"@pie-dao/proxy": "0.0.6",
"dotenv": "^8.2.0"
Expand Down
Loading

0 comments on commit 5fcb15d

Please sign in to comment.