@@ -30,21 +30,7 @@ const {
30
30
ZERO_ADDRESS ,
31
31
inflationStartTimestampInSecs,
32
32
} ,
33
- defaults : {
34
- WAITING_PERIOD_SECS ,
35
- PRICE_DEVIATION_THRESHOLD_FACTOR ,
36
- TRADING_REWARDS_ENABLED ,
37
- ISSUANCE_RATIO ,
38
- FEE_PERIOD_DURATION ,
39
- TARGET_THRESHOLD ,
40
- LIQUIDATION_DELAY ,
41
- LIQUIDATION_RATIO ,
42
- LIQUIDATION_PENALTY ,
43
- RATE_STALE_PERIOD ,
44
- EXCHANGE_FEE_RATES ,
45
- MINIMUM_STAKE_TIME ,
46
- AGGREGATOR_WARNING_FLAGS ,
47
- } ,
33
+ defaults,
48
34
} = require ( '../../../.' ) ;
49
35
50
36
const DEFAULTS = {
@@ -76,6 +62,7 @@ const deploy = async ({
76
62
77
63
const {
78
64
config,
65
+ params,
79
66
configFile,
80
67
synths,
81
68
deployment,
@@ -90,6 +77,43 @@ const deploy = async ({
90
77
91
78
const standaloneFeeds = Object . values ( feeds ) . filter ( ( { standalone } ) => standalone ) ;
92
79
80
+ const getDeployParameter = async name => {
81
+ const defaultParam = defaults [ name ] ;
82
+ let effectiveValue = defaultParam ;
83
+
84
+ if ( params ) {
85
+ const param = params . find ( p => p . name == name ) ;
86
+
87
+ if ( param ) {
88
+ if ( ! yes ) {
89
+ try {
90
+ await confirmAction (
91
+ yellow (
92
+ `⚠⚠⚠ WARNING: Found an entry for ${ param . name } in params.json. Specified value is ${ param . value } and default is ${ defaultParam } .` +
93
+ '\nDo you want to use the specified value (default otherwise)? (y/n) '
94
+ )
95
+ ) ;
96
+
97
+ effectiveValue = param . value ;
98
+ } catch ( err ) { }
99
+ } else {
100
+ // yes = true
101
+ effectiveValue = param . value ;
102
+ }
103
+ }
104
+ }
105
+
106
+ if ( effectiveValue !== defaultParam ) {
107
+ console . log (
108
+ yellow (
109
+ `PARAMETER OVERRIDE: Overriding default ${ name } with ${ effectiveValue } , specified in params.json.`
110
+ )
111
+ ) ;
112
+ }
113
+
114
+ return effectiveValue ;
115
+ } ;
116
+
93
117
console . log (
94
118
gray ( 'Checking all contracts not flagged for deployment have addresses in this network...' )
95
119
) ;
@@ -1296,12 +1320,13 @@ const deploy = async ({
1296
1320
synths . map ( ( { name } ) => systemSettings . methods . exchangeFeeRate ( toBytes32 ( name ) ) . call ( ) )
1297
1321
) ;
1298
1322
1323
+ const exchangeFeeRates = await getDeployParameter ( 'EXCHANGE_FEE_RATES' ) ;
1299
1324
const synthsRatesToUpdate = synths
1300
1325
. map ( ( synth , i ) =>
1301
1326
Object . assign (
1302
1327
{
1303
1328
currentRate : w3utils . fromWei ( synthRates [ i ] || '0' ) ,
1304
- targetRate : EXCHANGE_FEE_RATES [ synth . category ] ,
1329
+ targetRate : exchangeFeeRates [ synth . category ] ,
1305
1330
} ,
1306
1331
synth
1307
1332
)
@@ -1342,7 +1367,7 @@ const deploy = async ({
1342
1367
read : 'waitingPeriodSecs' ,
1343
1368
expected : input => input !== '0' ,
1344
1369
write : 'setWaitingPeriodSecs' ,
1345
- writeArg : WAITING_PERIOD_SECS ,
1370
+ writeArg : await getDeployParameter ( ' WAITING_PERIOD_SECS' ) ,
1346
1371
} ) ;
1347
1372
1348
1373
await runStep ( {
@@ -1351,16 +1376,17 @@ const deploy = async ({
1351
1376
read : 'priceDeviationThresholdFactor' ,
1352
1377
expected : input => input !== '0' , // only change if non-zero
1353
1378
write : 'setPriceDeviationThresholdFactor' ,
1354
- writeArg : PRICE_DEVIATION_THRESHOLD_FACTOR ,
1379
+ writeArg : await getDeployParameter ( ' PRICE_DEVIATION_THRESHOLD_FACTOR' ) ,
1355
1380
} ) ;
1356
1381
1382
+ const tradingRewardsEnabled = await getDeployParameter ( 'TRADING_REWARDS_ENABLED' ) ;
1357
1383
await runStep ( {
1358
1384
contract : 'SystemSettings' ,
1359
1385
target : systemSettings ,
1360
1386
read : 'tradingRewardsEnabled' ,
1361
- expected : input => input === TRADING_REWARDS_ENABLED , // only change if non-default
1387
+ expected : input => input === tradingRewardsEnabled , // only change if non-default
1362
1388
write : 'setTradingRewardsEnabled' ,
1363
- writeArg : TRADING_REWARDS_ENABLED ,
1389
+ writeArg : tradingRewardsEnabled ,
1364
1390
} ) ;
1365
1391
1366
1392
await runStep ( {
@@ -1369,7 +1395,7 @@ const deploy = async ({
1369
1395
read : 'issuanceRatio' ,
1370
1396
expected : input => input !== '0' , // only change if non-zero
1371
1397
write : 'setIssuanceRatio' ,
1372
- writeArg : ISSUANCE_RATIO ,
1398
+ writeArg : await getDeployParameter ( ' ISSUANCE_RATIO' ) ,
1373
1399
} ) ;
1374
1400
1375
1401
await runStep ( {
@@ -1378,7 +1404,7 @@ const deploy = async ({
1378
1404
read : 'feePeriodDuration' ,
1379
1405
expected : input => input !== '0' , // only change if non-zero
1380
1406
write : 'setFeePeriodDuration' ,
1381
- writeArg : FEE_PERIOD_DURATION ,
1407
+ writeArg : await getDeployParameter ( ' FEE_PERIOD_DURATION' ) ,
1382
1408
} ) ;
1383
1409
1384
1410
await runStep ( {
@@ -1387,7 +1413,7 @@ const deploy = async ({
1387
1413
read : 'targetThreshold' ,
1388
1414
expected : input => input !== '0' , // only change if non-zero
1389
1415
write : 'setTargetThreshold' ,
1390
- writeArg : TARGET_THRESHOLD ,
1416
+ writeArg : await getDeployParameter ( ' TARGET_THRESHOLD' ) ,
1391
1417
} ) ;
1392
1418
1393
1419
await runStep ( {
@@ -1396,7 +1422,7 @@ const deploy = async ({
1396
1422
read : 'liquidationDelay' ,
1397
1423
expected : input => input !== '0' , // only change if non-zero
1398
1424
write : 'setLiquidationDelay' ,
1399
- writeArg : LIQUIDATION_DELAY ,
1425
+ writeArg : await getDeployParameter ( ' LIQUIDATION_DELAY' ) ,
1400
1426
} ) ;
1401
1427
1402
1428
await runStep ( {
@@ -1405,7 +1431,7 @@ const deploy = async ({
1405
1431
read : 'liquidationRatio' ,
1406
1432
expected : input => input !== '0' , // only change if non-zero
1407
1433
write : 'setLiquidationRatio' ,
1408
- writeArg : LIQUIDATION_RATIO ,
1434
+ writeArg : await getDeployParameter ( ' LIQUIDATION_RATIO' ) ,
1409
1435
} ) ;
1410
1436
1411
1437
await runStep ( {
@@ -1414,7 +1440,7 @@ const deploy = async ({
1414
1440
read : 'liquidationPenalty' ,
1415
1441
expected : input => input !== '0' , // only change if non-zero
1416
1442
write : 'setLiquidationPenalty' ,
1417
- writeArg : LIQUIDATION_PENALTY ,
1443
+ writeArg : await getDeployParameter ( ' LIQUIDATION_PENALTY' ) ,
1418
1444
} ) ;
1419
1445
1420
1446
await runStep ( {
@@ -1423,7 +1449,7 @@ const deploy = async ({
1423
1449
read : 'rateStalePeriod' ,
1424
1450
expected : input => input !== '0' , // only change if non-zero
1425
1451
write : 'setRateStalePeriod' ,
1426
- writeArg : RATE_STALE_PERIOD ,
1452
+ writeArg : await getDeployParameter ( ' RATE_STALE_PERIOD' ) ,
1427
1453
} ) ;
1428
1454
1429
1455
await runStep ( {
@@ -1432,11 +1458,10 @@ const deploy = async ({
1432
1458
read : 'minimumStakeTime' ,
1433
1459
expected : input => input !== '0' , // only change if non-zero
1434
1460
write : 'setMinimumStakeTime' ,
1435
- writeArg : MINIMUM_STAKE_TIME ,
1461
+ writeArg : await getDeployParameter ( ' MINIMUM_STAKE_TIME' ) ,
1436
1462
} ) ;
1437
1463
1438
- const aggregatorWarningFlags = AGGREGATOR_WARNING_FLAGS [ network ] ;
1439
-
1464
+ const aggregatorWarningFlags = ( await getDeployParameter ( 'AGGREGATOR_WARNING_FLAGS' ) ) [ network ] ;
1440
1465
if ( aggregatorWarningFlags ) {
1441
1466
await runStep ( {
1442
1467
contract : 'SystemSettings' ,
0 commit comments