6
6
} = require ( 'ethers' ) ;
7
7
const {
8
8
toBytes32,
9
+ allowZeroOrUpdateIfNonZero,
9
10
constants : { ZERO_ADDRESS } ,
10
11
} = require ( '../../../..' ) ;
11
12
@@ -107,7 +108,7 @@ module.exports = async ({
107
108
target : SystemSettings ,
108
109
read : 'waitingPeriodSecs' ,
109
110
readTarget : previousSystemSettings ,
110
- expected : input => waitingPeriodSecs === '0' || input !== '0' , // only change if setting to non-zero from zero
111
+ expected : allowZeroOrUpdateIfNonZero ( waitingPeriodSecs ) ,
111
112
write : 'setWaitingPeriodSecs' ,
112
113
writeArg : waitingPeriodSecs ,
113
114
comment : 'Set the fee reclamation (SIP-37) waiting period' ,
@@ -121,7 +122,7 @@ module.exports = async ({
121
122
target : SystemSettings ,
122
123
read : 'priceDeviationThresholdFactor' ,
123
124
readTarget : previousSystemSettings ,
124
- expected : input => priceDeviationThresholdFactor === '0' || input !== '0' ,
125
+ expected : allowZeroOrUpdateIfNonZero ( priceDeviationThresholdFactor ) ,
125
126
write : 'setPriceDeviationThresholdFactor' ,
126
127
writeArg : priceDeviationThresholdFactor ,
127
128
comment : 'Set the threshold for the circuit breaker (SIP-65)' ,
@@ -145,7 +146,7 @@ module.exports = async ({
145
146
target : SystemSettings ,
146
147
read : 'issuanceRatio' ,
147
148
readTarget : previousSystemSettings ,
148
- expected : input => issuanceRatio === '0' || input !== '0' ,
149
+ expected : allowZeroOrUpdateIfNonZero ( issuanceRatio ) ,
149
150
write : 'setIssuanceRatio' ,
150
151
writeArg : issuanceRatio ,
151
152
comment : 'Set the issuance ratio - the c-ratio stored as an inverted decimal' ,
@@ -157,7 +158,7 @@ module.exports = async ({
157
158
target : SystemSettings ,
158
159
read : 'feePeriodDuration' ,
159
160
readTarget : previousSystemSettings ,
160
- expected : input => feePeriodDuration === '0' || input !== '0' ,
161
+ expected : allowZeroOrUpdateIfNonZero ( feePeriodDuration ) ,
161
162
write : 'setFeePeriodDuration' ,
162
163
writeArg : feePeriodDuration ,
163
164
comment : 'Set the fee period duration' ,
@@ -169,7 +170,7 @@ module.exports = async ({
169
170
target : SystemSettings ,
170
171
read : 'targetThreshold' ,
171
172
readTarget : previousSystemSettings ,
172
- expected : input => targetThreshold === '0' || input !== '0' ,
173
+ expected : allowZeroOrUpdateIfNonZero ( targetThreshold ) ,
173
174
write : 'setTargetThreshold' ,
174
175
writeArg : targetThreshold ,
175
176
comment :
@@ -182,7 +183,7 @@ module.exports = async ({
182
183
target : SystemSettings ,
183
184
read : 'liquidationDelay' ,
184
185
readTarget : previousSystemSettings ,
185
- expected : input => liquidationDelay === '0' || input !== '0' ,
186
+ expected : allowZeroOrUpdateIfNonZero ( liquidationDelay ) ,
186
187
write : 'setLiquidationDelay' ,
187
188
writeArg : liquidationDelay ,
188
189
comment : 'Set the delay from when an account is flagged till when it can be liquidated' ,
@@ -194,7 +195,7 @@ module.exports = async ({
194
195
target : SystemSettings ,
195
196
read : 'liquidationRatio' ,
196
197
readTarget : previousSystemSettings ,
197
- expected : input => liquidationRatio === '0' || input !== '0' ,
198
+ expected : allowZeroOrUpdateIfNonZero ( liquidationRatio ) ,
198
199
write : 'setLiquidationRatio' ,
199
200
writeArg : liquidationRatio ,
200
201
comment : 'Set the ratio below which an account can be flagged for liquidation' ,
@@ -206,7 +207,7 @@ module.exports = async ({
206
207
target : SystemSettings ,
207
208
read : 'liquidationPenalty' ,
208
209
readTarget : previousSystemSettings ,
209
- expected : input => liquidationPenalty === '0' || input !== '0' ,
210
+ expected : allowZeroOrUpdateIfNonZero ( liquidationPenalty ) ,
210
211
write : 'setLiquidationPenalty' ,
211
212
writeArg : liquidationPenalty ,
212
213
comment : 'Set the penalty amount a liquidator receives from a liquidated account' ,
@@ -218,7 +219,7 @@ module.exports = async ({
218
219
target : SystemSettings ,
219
220
read : 'rateStalePeriod' ,
220
221
readTarget : previousSystemSettings ,
221
- expected : input => rateStalePeriod === '0' || input !== '0' ,
222
+ expected : allowZeroOrUpdateIfNonZero ( rateStalePeriod ) ,
222
223
write : 'setRateStalePeriod' ,
223
224
writeArg : rateStalePeriod ,
224
225
comment : 'Set the maximum amount of time (in secs) that a rate can be used for' ,
@@ -230,7 +231,7 @@ module.exports = async ({
230
231
target : SystemSettings ,
231
232
read : 'minimumStakeTime' ,
232
233
readTarget : previousSystemSettings ,
233
- expected : input => minimumStakeTime === '0' || input !== '0' ,
234
+ expected : allowZeroOrUpdateIfNonZero ( minimumStakeTime ) ,
234
235
write : 'setMinimumStakeTime' ,
235
236
writeArg : minimumStakeTime ,
236
237
comment : 'Set the minimum amount of time SNX can be issued before any is burned (SIP-40)' ,
@@ -242,7 +243,7 @@ module.exports = async ({
242
243
target : SystemSettings ,
243
244
read : 'debtSnapshotStaleTime' ,
244
245
readTarget : previousSystemSettings ,
245
- expected : input => debtSnapshotStaleTime === '0' || input !== '0' ,
246
+ expected : allowZeroOrUpdateIfNonZero ( debtSnapshotStaleTime ) ,
246
247
write : 'setDebtSnapshotStaleTime' ,
247
248
writeArg : debtSnapshotStaleTime ,
248
249
comment : 'Set the length of time after which the DebtCache snapshot becomes stale (SIP-91)' ,
@@ -255,7 +256,7 @@ module.exports = async ({
255
256
read : 'crossDomainMessageGasLimit' ,
256
257
readArg : 0 ,
257
258
readTarget : previousSystemSettings ,
258
- expected : input => crossDomainDepositGasLimit === '0' || input !== '0' ,
259
+ expected : allowZeroOrUpdateIfNonZero ( crossDomainDepositGasLimit ) ,
259
260
write : 'setCrossDomainMessageGasLimit' ,
260
261
writeArg : [ 0 , crossDomainDepositGasLimit ] ,
261
262
comment : 'Set the gas limit for depositing onto L2' ,
@@ -268,7 +269,7 @@ module.exports = async ({
268
269
read : 'crossDomainMessageGasLimit' ,
269
270
readArg : 1 ,
270
271
readTarget : previousSystemSettings ,
271
- expected : input => crossDomainEscrowGasLimit === '0' || input !== '0' ,
272
+ expected : allowZeroOrUpdateIfNonZero ( crossDomainEscrowGasLimit ) ,
272
273
write : 'setCrossDomainMessageGasLimit' ,
273
274
writeArg : [ 1 , crossDomainEscrowGasLimit ] ,
274
275
comment : 'Set the gas limit for migrating escrowed SNX to L2' ,
@@ -281,7 +282,7 @@ module.exports = async ({
281
282
read : 'crossDomainMessageGasLimit' ,
282
283
readArg : 2 ,
283
284
readTarget : previousSystemSettings ,
284
- expected : input => crossDomainRewardGasLimit === '0' || input !== '0' ,
285
+ expected : allowZeroOrUpdateIfNonZero ( crossDomainRewardGasLimit ) ,
285
286
write : 'setCrossDomainMessageGasLimit' ,
286
287
writeArg : [ 2 , crossDomainRewardGasLimit ] ,
287
288
comment : 'Set the gas limit for depositing rewards to L2' ,
@@ -296,7 +297,7 @@ module.exports = async ({
296
297
read : 'crossDomainMessageGasLimit' ,
297
298
readArg : 3 ,
298
299
readTarget : previousSystemSettings ,
299
- expected : input => crossDomainWithdrawalGasLimit === '0' || input !== '0' ,
300
+ expected : allowZeroOrUpdateIfNonZero ( crossDomainWithdrawalGasLimit ) ,
300
301
write : 'setCrossDomainMessageGasLimit' ,
301
302
writeArg : [ 3 , crossDomainWithdrawalGasLimit ] ,
302
303
comment : 'Set the gas limit for withdrawing from L2' ,
@@ -309,7 +310,7 @@ module.exports = async ({
309
310
read : 'crossDomainMessageGasLimit' ,
310
311
readArg : 4 ,
311
312
readTarget : previousSystemSettings ,
312
- expected : input => crossDomainRelayGasLimit === '0' || input !== '0' ,
313
+ expected : allowZeroOrUpdateIfNonZero ( crossDomainRelayGasLimit ) ,
313
314
write : 'setCrossDomainMessageGasLimit' ,
314
315
writeArg : [ 4 , crossDomainRelayGasLimit ] ,
315
316
comment : 'Set the gas limit for relaying owner actions to L2' ,
@@ -336,7 +337,7 @@ module.exports = async ({
336
337
target : SystemSettings ,
337
338
read : 'etherWrapperMaxETH' ,
338
339
readTarget : previousSystemSettings ,
339
- expected : input => etherWrapperMaxETH === '0' || input !== '0' ,
340
+ expected : allowZeroOrUpdateIfNonZero ( etherWrapperMaxETH ) ,
340
341
write : 'setEtherWrapperMaxETH' ,
341
342
writeArg : etherWrapperMaxETH ,
342
343
comment : 'Set the max amount of Ether allowed in the EtherWrapper (SIP-112)' ,
@@ -348,7 +349,7 @@ module.exports = async ({
348
349
target : SystemSettings ,
349
350
read : 'etherWrapperMintFeeRate' ,
350
351
readTarget : previousSystemSettings ,
351
- expected : input => etherWrapperMintFeeRate === '0' || input !== '0' ,
352
+ expected : allowZeroOrUpdateIfNonZero ( etherWrapperMintFeeRate ) ,
352
353
write : 'setEtherWrapperMintFeeRate' ,
353
354
writeArg : etherWrapperMintFeeRate ,
354
355
comment : 'Set the fee rate for minting sETH from ETH in the EtherWrapper (SIP-112)' ,
@@ -361,7 +362,7 @@ module.exports = async ({
361
362
target : SystemSettings ,
362
363
read : 'etherWrapperBurnFeeRate' ,
363
364
readTarget : previousSystemSettings ,
364
- expected : input => etherWrapperBurnFeeRate === '0' || input !== '0' , // only change if the value to set is above zero and the value onchain is 0
365
+ expected : allowZeroOrUpdateIfNonZero ( etherWrapperBurnFeeRate ) ,
365
366
write : 'setEtherWrapperBurnFeeRate' ,
366
367
writeArg : etherWrapperBurnFeeRate ,
367
368
comment : 'Set the fee rate for burning sETH for ETH in the EtherWrapper (SIP-112)' ,
@@ -376,7 +377,7 @@ module.exports = async ({
376
377
target : SystemSettings ,
377
378
read : 'atomicMaxVolumePerBlock' ,
378
379
readTarget : previousSystemSettings ,
379
- expected : input => atomicMaxVolumePerBlock === '0' || input !== '0' , // only change if setting to non-zero from zero
380
+ expected : allowZeroOrUpdateIfNonZero ( atomicMaxVolumePerBlock ) ,
380
381
write : 'setAtomicMaxVolumePerBlock' ,
381
382
writeArg : atomicMaxVolumePerBlock ,
382
383
comment : 'SIP-120 Set max atomic volume per block (in USD amounts)' ,
@@ -390,7 +391,7 @@ module.exports = async ({
390
391
target : SystemSettings ,
391
392
read : 'atomicTwapWindow' ,
392
393
readTarget : previousSystemSettings ,
393
- expected : input => atomicTwapWindow === '0' || input !== '0' ,
394
+ expected : allowZeroOrUpdateIfNonZero ( atomicTwapWindow ) ,
394
395
write : 'setAtomicTwapWindow' ,
395
396
writeArg : atomicTwapWindow ,
396
397
comment : 'SIP-120 Set the TWAP window for atomic swaps' ,
@@ -513,7 +514,7 @@ module.exports = async ({
513
514
read : 'interactionDelay' ,
514
515
readArg : addressOf ( CollateralShort ) ,
515
516
readTarget : previousSystemSettings ,
516
- expected : input => interactionDelay === '0' || input !== '0' ,
517
+ expected : allowZeroOrUpdateIfNonZero ( interactionDelay ) ,
517
518
write : 'setInteractionDelay' ,
518
519
writeArg : [ CollateralShort . address , interactionDelay ] ,
519
520
comment : 'Ensure the CollateralShort contract has an interaction delay of zero on the OVM' ,
@@ -528,7 +529,7 @@ module.exports = async ({
528
529
read : 'collapseFeeRate' ,
529
530
readArg : addressOf ( CollateralShort ) ,
530
531
readTarget : previousSystemSettings ,
531
- expected : input => collapseFeeRate === '0' || input !== '0' ,
532
+ expected : allowZeroOrUpdateIfNonZero ( collapseFeeRate ) ,
532
533
write : 'setCollapseFeeRate' ,
533
534
writeArg : [ CollateralShort . address , collapseFeeRate ] ,
534
535
comment :
0 commit comments