This repository has been archived by the owner on Jul 12, 2019. It is now read-only.
/
11_SCHEME-REP-Lock_Whitelisted_tokens.js
109 lines (91 loc) 路 4.41 KB
/
11_SCHEME-REP-Lock_Whitelisted_tokens.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* global artifacts, web3 */
/* eslint no-undef: "error" */
const assert = require('assert')
const DxLockWhitelisted4Rep = artifacts.require('DxLockWhitelisted4Rep')
const FixedPriceOracle = artifacts.require('FixedPriceOracle')
const DxAvatar = artifacts.require('DxAvatar')
const DxController = artifacts.require('DxController')
const BasicTokenWhitelist = artifacts.require('BasicTokenWhitelist')
const getDXContractAddress = require('../src/helpers/getDXContractAddresses.js')(web3, artifacts)
const dateUtil = require('../src/helpers/dateUtil')
const { registerScheme } = require('./helpers/schemeUtils')
const {
maxLockingWhitelistedTokensPeriod
} = require('../src/config/bootstrap')
const {
whitelistedTokensReward
} = require('../src/config/initalRepDistribution')
const {
initialDistributionStart,
initialDistributionEnd,
redeemStart
} = require('../src/config/timePeriods')
module.exports = async function (deployer, network) {
const dxAvatar = await DxAvatar.deployed()
const dxController = await DxController.deployed()
// Deploy Price Oracle
const fixedPriceOracle = await deployPriceOracle(deployer, network)
// Deploy DxLockWhitelisted4Rep scheme
console.log('Deploy DxLockWhitelisted4Rep that inherits from LockingToken4Reputation') // TODO:
const dxLockWhitelisted4Rep = await deployer.deploy(DxLockWhitelisted4Rep)
console.log('Configure DxLockWhitelisted4Rep')
assert(whitelistedTokensReward, `The parameter whitelistedTokensReward was not defined`)
assert(initialDistributionStart, `The parameter initialDistributionStart was not defined`)
assert(initialDistributionEnd, `The parameter initialDistributionEnd was not defined`)
assert(redeemStart, `The parameter redeemStart was not defined`)
assert(maxLockingWhitelistedTokensPeriod, `The parameter maxLockingWhitelistedTokensPeriod was not defined`)
console.log(' - Avatar address:', dxAvatar.address)
console.log(' - Reputation reward:', whitelistedTokensReward)
console.log(' - Locking start time:', dateUtil.formatDateTime(initialDistributionStart))
console.log(' - Locking end time:', dateUtil.formatDateTime(initialDistributionEnd))
console.log(' - Redeem enable time:', dateUtil.formatDateTime(redeemStart))
console.log(' - max locking period:', maxLockingWhitelistedTokensPeriod)
console.log(' - Price Oracle address:', fixedPriceOracle.address)
await dxLockWhitelisted4Rep.initialize(
dxAvatar.address,
whitelistedTokensReward,
dateUtil.toEthereumTimestamp(initialDistributionStart),
dateUtil.toEthereumTimestamp(initialDistributionEnd),
dateUtil.toEthereumTimestamp(redeemStart),
maxLockingWhitelistedTokensPeriod,
fixedPriceOracle.address
)
await registerScheme({
label: 'DxLockWhitelisted4Rep',
schemeAddress: dxLockWhitelisted4Rep.address,
avatarAddress: dxAvatar.address,
controller: dxController,
web3
})
}
async function deployPriceOracle (deployer, network) {
let tokenWhitelistAddress, whiteListAddressMsg
if (network === 'rinkeby') {
await deployer.deploy(BasicTokenWhitelist)
console.log('Deploy BasicTokenWhitelist for testing in Rinkeby:')
const basicTokenWhitelist = await BasicTokenWhitelist.deployed()
whiteListAddressMsg = 'Token White List Address (BasicTokenWhitelist, only for testing): %s', tokenWhitelistAddress
// Add some test tokens for Rinkeby
const whitelistedTokens = {
WETH: '0xc778417e063141139fce010982780140aa0cd5ab',
RDN: '0x3615757011112560521536258c1e7325ae3b48ae',
OMG: '0x00df91984582e6e96288307e9c2f20b38c8fece9',
testGEN: '0xa1f34744c80e7a9019a5cd2bf697f13df00f9773',
GEN: '0x543ff227f64aa17ea132bf9886cab5db55dcaddf'
}
console.log('\nWhite list the tokens: ')
Object.keys(whitelistedTokens).forEach(tokenName => {
console.log(' - %s: %s', tokenName, whitelistedTokens[tokenName])
})
await basicTokenWhitelist.updateApprovalOfToken(whitelistedTokens, true)
tokenWhitelistAddress = basicTokenWhitelist.address
} else {
tokenWhitelistAddress = await getDXContractAddress('DutchExchangeProxy')
whiteListAddressMsg = 'Token White List Address (DutchX): %s', tokenWhitelistAddress
}
console.log('Deploy FixedPriceOracle: for setting the prices for the tokens')
console.log(' - ' + whiteListAddressMsg)
await deployer.deploy(FixedPriceOracle, tokenWhitelistAddress)
const fixedPriceOracle = await FixedPriceOracle.deployed()
return fixedPriceOracle
}