Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AragonDeployer and deploy script. #4

Merged
merged 7 commits into from
Sep 7, 2020
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
cache
node_modules
truffle-config.js
artifacts/
build/
cache/
coverage/
node_modules/

buidler.config.js
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ artifacts
# Coverage
coverage
coverage.json

# Local settings
config.js
19 changes: 9 additions & 10 deletions buidler.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
const config = require('./config')

usePlugin('@nomiclabs/buidler-waffle')
usePlugin("@nomiclabs/buidler-etherscan");
usePlugin('buidler-gas-reporter')
usePlugin('solidity-coverage')

Expand All @@ -12,12 +15,9 @@ task('accounts', 'Prints the list of accounts', async () => {
}
})

// You have to export an object to set up your config
// This object can have the following optional entries:
// defaultNetwork, networks, solc, and paths.
// Go to https://buidler.dev/config/ to learn more
// Some of the settings should be defined in `./config.js`.
// Go to https://buidler.dev/config/ for the syntax.
module.exports = {
// This is a sample solc configuration that specifies which version of solc to use
solc: {
version: '0.6.12',
optimizer: {
Expand All @@ -26,9 +26,8 @@ module.exports = {
},
},

networks: {
coverage: {
url: 'http://localhost:8555'
}
},
defaultNetwork: "buidlerevm",

networks: config.networks,
etherscan: config.etherscan,
}
34 changes: 34 additions & 0 deletions config.sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = {
networks: {
// Needed for `solidity-coverage`
coverage: {
url: 'http://localhost:8555',
},

// Rinkeby
rinkeby: {
url: 'https://mainnet.infura.io/v3/YOUR-INFURA-API-KEY',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one should be https://rinkeby.infura.io....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

chainId: 4,
accounts: {
mnemonic: 'YOUR MNEMONIC HERE',
path: 'm/44\'/60\'/0\'/0',
initialIndex: 0,
count: 10,
},
gas: 'auto',
gasPrice: 1000000000, // 1 gwei
gasMultiplier: 1.5,
},

// Mainnet
mainnet: {
url: 'https://mainnet.infura.io/v3/YOUR-INFURA-API-KEY',
chainID: 1,
},
},
// Use to verify contracts on Etherscan
// https://buidler.dev/plugins/nomiclabs-buidler-etherscan.html
etherscan: {
apiKey: 'YOUR-ETHERSCAN-API-KEY',
},
}
30 changes: 30 additions & 0 deletions contracts/AragonDepositor.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6.12;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "./IFinance.sol";

contract AragonDepositor {
uint256 constant private SUPPLY = 10000000 * 10**18;

function execute(
ERC20 token,
IFinance finance
)
public
{
// Approve finance for maximum possible uint
token.approve(address(finance), SUPPLY);

// Deposits the tokens in Aragon Finance
// ERC20 as described here
// https://wiki.aragon.org/archive/dev/apps/finance/
finance.deposit(
address(token),
SUPPLY,
"BarnBridge Governance Token ($BOND) to be distributed according to https://client.aragon.org/#/barnbridgelaunch/0x0ee6df5b2482663f28e20c5927906724024121cc/vote/0/"
);

selfdestruct(msg.sender);
}
}
14 changes: 3 additions & 11 deletions contracts/BarnBridgeToken.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6.0;
pragma solidity ^0.6.12;

import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "./IFinance.sol";
Expand All @@ -8,22 +8,14 @@ contract BarnBridgeToken is ERC20Burnable {
uint256 constant private SUPPLY = 10000000 * 10**18;

constructor(
IFinance finance
address aragonDepositor
)
public
ERC20(
"BarnBridge Governance Token",
"BOND"
)
{
_mint(address(this), SUPPLY);

_approve(address(this), address(finance), SUPPLY);

finance.deposit(
address(this),
SUPPLY,
"BarnBridge Governance Token ($BOND) to be distributed according to https://client.aragon.org/#/barnbridgelaunch/0x0ee6df5b2482663f28e20c5927906724024121cc/vote/0/"
);
_mint(aragonDepositor, SUPPLY);
}
}
2 changes: 1 addition & 1 deletion contracts/IFinance.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6.0;
pragma solidity ^0.6.12;

interface IFinance {
function deposit(
Expand Down
2 changes: 1 addition & 1 deletion contracts/mocks/FinanceMock.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.6.0;
pragma solidity ^0.6.12;

import "../IFinance.sol";

Expand Down
63 changes: 51 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
"author": "BarnBridge",
"license": "Apache-2",
"devDependencies": {
"@nomiclabs/buidler": "^1.4.4",
"@nomiclabs/buidler": "^1.4.5",
"@nomiclabs/buidler-ethers": "^2.0.0",
"@nomiclabs/buidler-waffle": "^2.0.0",
"@nomiclabs/buidler-etherscan": "^2.0.1",
"@nomiclabs/buidler-waffle": "^2.1.0",
"@openzeppelin/contracts": "^3.1.0",
"bignumber.js": "^9.0.0",
"buidler-gas-reporter": "^0.1.3",
Expand All @@ -31,7 +32,7 @@
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"ethereum-waffle": "^3.1.0",
"ethers": "^5.0.9",
"ethers": "^5.0.10",
"solhint": "^3.2.0",
"solidity-coverage": "^0.7.10"
}
Expand Down
32 changes: 32 additions & 0 deletions scripts/deploy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const { ethers } = require('@nomiclabs/buidler')

async function main () {
// Deploy AragonDepositor
const AragonDepositor = await ethers.getContractFactory('AragonDepositor')
const aragonDepositor = await AragonDepositor.deploy()
console.log('AragonDepositor deployed to:', aragonDepositor.address)

// Deploy BarnBridge Governance Token
// and give all tokens to AragonDepositor
const Token = await ethers.getContractFactory('BarnBridgeToken')
const token = await Token.deploy(aragonDepositor.address)
await token.deployed()
console.log('BarnBridgeToken deployed to:', token.address)

// Run execute on AragonDepositor with
// - Token address
// - Finance address
const finance = '0x9e845029e3f0cbb47e3d1ac175bf26a6087c7ac7'
await aragonDepositor.execute(
token.address,
finance,
)
console.log('Executed deposit')
}

main()
.then(() => process.exit(0))
.catch(error => {
console.error(error)
process.exit(1)
})
Loading