Skip to content

Commit 263f4a0

Browse files
committed
Rename rebase function parameters to better reflect their semantics
1 parent 33771f3 commit 263f4a0

File tree

3 files changed

+46
-35
lines changed

3 files changed

+46
-35
lines changed

contracts/UFragmentsPolicy.sol

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ contract UFragmentsPolicy is Ownable {
9494

9595
// DECIMALS decimal fixed point numbers.
9696
// Used in computation of (Upper-Lower)/(1-(Upper/Lower)/2^(Growth*delta))) + Lower
97-
int256 public rebaseFunctionLowerPercentage;
98-
int256 public rebaseFunctionUpperPercentage;
97+
int256 public rebaseFunctionNegativePercentageLimit;
98+
int256 public rebaseFunctionPositivePercentageLimit;
9999
int256 public rebaseFunctionPositiveGrowth;
100100
int256 public rebaseFunctionNegativeGrowth;
101101

@@ -167,21 +167,20 @@ contract UFragmentsPolicy is Ownable {
167167
orchestrator = orchestrator_;
168168
}
169169

170-
171-
function setRebaseFunctionLowerPercentage(int256 rebaseFunctionLowerPercentage_)
170+
function setRebaseFunctionNegativePercentageLimit(int256 rebaseFunctionNegativePercentageLimit_)
172171
external
173172
onlyOwner
174173
{
175-
require(rebaseFunctionLowerPercentage_ <= 0);
176-
rebaseFunctionLowerPercentage = rebaseFunctionLowerPercentage_;
174+
require(rebaseFunctionNegativePercentageLimit_ <= 0);
175+
rebaseFunctionNegativePercentageLimit = rebaseFunctionNegativePercentageLimit_;
177176
}
178177

179-
function setRebaseFunctionUpperPercentage(int256 rebaseFunctionUpperPercentage_)
178+
function setRebaseFunctionPositivePercentageLimit(int256 rebaseFunctionPositivePercentageLimit_)
180179
external
181180
onlyOwner
182181
{
183-
require(rebaseFunctionUpperPercentage_ >= 0);
184-
rebaseFunctionUpperPercentage = rebaseFunctionUpperPercentage_;
182+
require(rebaseFunctionPositivePercentageLimit_ >= 0);
183+
rebaseFunctionPositivePercentageLimit = rebaseFunctionPositivePercentageLimit_;
185184
}
186185

187186
function setRebaseFunctionPositiveGrowth(int256 rebaseFunctionPositiveGrowth_) external onlyOwner {
@@ -255,8 +254,8 @@ contract UFragmentsPolicy is Ownable {
255254

256255
rebaseFunctionPositiveGrowth = int256(45 * (10**DECIMALS)); // Positive growth
257256
rebaseFunctionNegativeGrowth = int256(45 * (10**DECIMALS)); // Negative growth
258-
rebaseFunctionUpperPercentage = int256(5 * (10**(DECIMALS - 2))); // 0.05
259-
rebaseFunctionLowerPercentage = int256((-77) * int256(10**(DECIMALS - 3))); // -0.077
257+
rebaseFunctionPositivePercentageLimit = int256(5 * (10**(DECIMALS - 2))); // 0.05
258+
rebaseFunctionNegativePercentageLimit = int256((-77) * int256(10**(DECIMALS - 3))); // -0.077
260259

261260
minRebaseTimeIntervalSec = 1 days;
262261
rebaseWindowOffsetSec = 7200; // 2AM UTC
@@ -346,9 +345,19 @@ contract UFragmentsPolicy is Ownable {
346345
// Determine growth and bounds based on positive or negative rebase
347346
int256 rebasePercentage;
348347
if (normalizedRate >= ONE) {
349-
rebasePercentage = computeRebasePercentage(normalizedRate, -rebaseFunctionUpperPercentage, rebaseFunctionUpperPercentage, rebaseFunctionPositiveGrowth);
348+
rebasePercentage = computeRebasePercentage(
349+
normalizedRate,
350+
-rebaseFunctionPositivePercentageLimit,
351+
rebaseFunctionPositivePercentageLimit,
352+
rebaseFunctionPositiveGrowth
353+
);
350354
} else {
351-
rebasePercentage = computeRebasePercentage(normalizedRate, rebaseFunctionLowerPercentage, -rebaseFunctionLowerPercentage, rebaseFunctionNegativeGrowth);
355+
rebasePercentage = computeRebasePercentage(
356+
normalizedRate,
357+
rebaseFunctionNegativePercentageLimit,
358+
-rebaseFunctionNegativePercentageLimit,
359+
rebaseFunctionNegativeGrowth
360+
);
352361
}
353362

354363
return uFrags.totalSupply().toInt256Safe().mul(rebasePercentage).div(ONE);

scripts/deploy.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,10 @@ task('deploy:amplforce:testnet', 'Deploy ampleforth contract suite for testnet')
3333

3434
// Policy
3535
const DEVIATION_TRESHOLD = utils.parseUnits('0.002', 18) // 0.002% (ie) 0.05/24)
36-
const LOWER = utils.parseUnits('-0.005', 18)
37-
const UPPER = utils.parseUnits('0.005', 18)
38-
const GROWTH = utils.parseUnits('3', 18)
36+
const LOWER = utils.parseUnits('-0.005', 18) // rebaseFunctionNegativePercentageLimit
37+
const UPPER = utils.parseUnits('0.005', 18) // rebaseFunctionPositivePercentageLimit
38+
const POSITIVE_GROWTH = utils.parseUnits('31', 18) // rebaseFunctionPositiveGrowth;
39+
const NEGATIVE_GROWTH = utils.parseUnits('41', 18) // rebaseFunctionNegativeGrowth;
3940
const MIN_REBASE_INTERVAL = 1200 // 20 mins
4041
const REBASE_WINDOW_OFFSET = 0
4142
const REBASE_WINDOW_LEN = 2400 // 40 mins
@@ -119,7 +120,8 @@ task('deploy:amplforce:testnet', 'Deploy ampleforth contract suite for testnet')
119120

120121
// configure parameters
121122
await waitFor(policy.setDeviationThreshold(DEVIATION_TRESHOLD))
122-
await waitFor(policy.setRebaseFunctionGrowth(GROWTH))
123+
await waitFor(policy.setRebaseFunctionPositiveGrowth(POSITIVE_GROWTH))
124+
await waitFor(policy.setRebaseFunctionNegativeGrowth(NEGATIVE_GROWTH))
123125
await waitFor(policy.setRebaseFunctionLowerPercentage(LOWER))
124126
await waitFor(policy.setRebaseFunctionUpperPercentage(UPPER))
125127
await waitFor(

test/unit/UFragmentsPolicy.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -426,39 +426,39 @@ describe('UFragmentsPolicy:CurveParameters', async function () {
426426
})
427427
})
428428

429-
describe('when rebaseFunctionLowerPercentage is more than 0', async function () {
429+
describe('when rebaseFunctionNegativePercentageLimit is less than 0', async function () {
430+
it('should setRebaseFunctionNegativePercentageLimit', async function () {
431+
await uFragmentsPolicy
432+
.connect(deployer)
433+
.setRebaseFunctionNegativePercentageLimit(-1)
434+
expect(await uFragmentsPolicy.rebaseFunctionNegativePercentageLimit()).to.eq(-1)
435+
})
436+
})
437+
438+
describe('when rebaseFunctionNegativePercentageLimit is more than 0', async function () {
430439
it('should fail', async function () {
431440
await expect(
432441
uFragmentsPolicy
433442
.connect(deployer)
434-
.setRebaseFunctionLowerPercentage(1000),
443+
.setRebaseFunctionNegativePercentageLimit(1000),
435444
).to.be.reverted
436445
})
437446
})
438447

439-
describe('when rebaseFunctionLowerPercentage is less than 0', async function () {
440-
it('should setRebaseFunctionLowerPercentage', async function () {
441-
await uFragmentsPolicy
442-
.connect(deployer)
443-
.setRebaseFunctionLowerPercentage(-1)
444-
expect(await uFragmentsPolicy.rebaseFunctionLowerPercentage()).to.eq(-1)
445-
})
446-
})
447-
448-
describe('when rebaseFunctionUpperPercentage is less than 0', async function () {
448+
describe('when rebaseFunctionPositivePercentageLimit is less than 0', async function () {
449449
it('should fail', async function () {
450450
await expect(
451-
uFragmentsPolicy.connect(deployer).setRebaseFunctionUpperPercentage(-1),
451+
uFragmentsPolicy.connect(deployer).setRebaseFunctionPositivePercentageLimit(-1),
452452
).to.be.reverted
453453
})
454454
})
455455

456-
describe('when rebaseFunctionUpperPercentage is more than 0', async function () {
457-
it('should setRebaseFunctionUpperPercentage', async function () {
456+
describe('when rebaseFunctionPositivePercentageLimit is more than 0', async function () {
457+
it('should setRebaseFunctionPositivePercentageLimit', async function () {
458458
await uFragmentsPolicy
459459
.connect(deployer)
460-
.setRebaseFunctionUpperPercentage(1000)
461-
expect(await uFragmentsPolicy.rebaseFunctionUpperPercentage()).to.eq(1000)
460+
.setRebaseFunctionPositivePercentageLimit(1000)
461+
expect(await uFragmentsPolicy.rebaseFunctionPositivePercentageLimit()).to.eq(1000)
462462
})
463463
})
464464
})
@@ -1039,7 +1039,7 @@ describe('UFragmentsPolicy:Rebase', async function () {
10391039
.setRebaseFunctionPositiveGrowth('25' + '000000000000000000') // Positive growth
10401040
await uFragmentsPolicy
10411041
.connect(deployer)
1042-
.setRebaseFunctionUpperPercentage('10' + '0000000000000000')
1042+
.setRebaseFunctionPositivePercentageLimit('10' + '0000000000000000')
10431043
await increaseTime(60)
10441044
})
10451045

0 commit comments

Comments
 (0)