@@ -94,9 +94,13 @@ contract UFragmentsPolicy is Ownable {
94
94
95
95
// DECIMALS decimal fixed point numbers.
96
96
// Used in computation of (Upper-Lower)/(1-(Upper/Lower)/2^(Growth*delta))) + Lower
97
- int256 public rebaseFunctionLowerPercentage;
98
- int256 public rebaseFunctionUpperPercentage;
99
- int256 public rebaseFunctionGrowth;
97
+ /// @custom:oz-renamed-from rebaseFunctionLowerPercentage
98
+ int256 public rebaseFunctionNegativePercentageLimit;
99
+ /// @custom:oz-renamed-from rebaseFunctionUpperPercentage
100
+ int256 public rebaseFunctionPositivePercentageLimit;
101
+ /// @custom:oz-renamed-from rebaseFunctionGrowth
102
+ int256 public rebaseFunctionPositiveGrowth;
103
+ int256 public rebaseFunctionNegativeGrowth;
100
104
101
105
int256 private constant ONE = int256 (10 ** DECIMALS);
102
106
@@ -166,25 +170,30 @@ contract UFragmentsPolicy is Ownable {
166
170
orchestrator = orchestrator_;
167
171
}
168
172
169
- function setRebaseFunctionGrowth (int256 rebaseFunctionGrowth_ ) external onlyOwner {
170
- require (rebaseFunctionGrowth_ >= 0 );
171
- rebaseFunctionGrowth = rebaseFunctionGrowth_;
172
- }
173
-
174
- function setRebaseFunctionLowerPercentage (int256 rebaseFunctionLowerPercentage_ )
173
+ function setRebaseFunctionNegativePercentageLimit (int256 rebaseFunctionNegativePercentageLimit_ )
175
174
external
176
175
onlyOwner
177
176
{
178
- require (rebaseFunctionLowerPercentage_ <= 0 );
179
- rebaseFunctionLowerPercentage = rebaseFunctionLowerPercentage_ ;
177
+ require (rebaseFunctionNegativePercentageLimit_ <= 0 );
178
+ rebaseFunctionNegativePercentageLimit = rebaseFunctionNegativePercentageLimit_ ;
180
179
}
181
180
182
- function setRebaseFunctionUpperPercentage (int256 rebaseFunctionUpperPercentage_ )
181
+ function setRebaseFunctionPositivePercentageLimit (int256 rebaseFunctionPositivePercentageLimit_ )
183
182
external
184
183
onlyOwner
185
184
{
186
- require (rebaseFunctionUpperPercentage_ >= 0 );
187
- rebaseFunctionUpperPercentage = rebaseFunctionUpperPercentage_;
185
+ require (rebaseFunctionPositivePercentageLimit_ >= 0 );
186
+ rebaseFunctionPositivePercentageLimit = rebaseFunctionPositivePercentageLimit_;
187
+ }
188
+
189
+ function setRebaseFunctionPositiveGrowth (int256 rebaseFunctionPositiveGrowth_ ) external onlyOwner {
190
+ require (rebaseFunctionPositiveGrowth_ >= 0 );
191
+ rebaseFunctionPositiveGrowth = rebaseFunctionPositiveGrowth_;
192
+ }
193
+
194
+ function setRebaseFunctionNegativeGrowth (int256 rebaseFunctionNegativeGrowth_ ) external onlyOwner {
195
+ require (rebaseFunctionNegativeGrowth_ >= 0 );
196
+ rebaseFunctionNegativeGrowth = rebaseFunctionNegativeGrowth_;
188
197
}
189
198
190
199
/**
@@ -246,9 +255,10 @@ contract UFragmentsPolicy is Ownable {
246
255
// deviationThreshold = 0.05e18 = 5e16
247
256
deviationThreshold = 25 * 10 ** (DECIMALS - 3 );
248
257
249
- rebaseFunctionGrowth = int256 (45 * (10 ** DECIMALS));
250
- rebaseFunctionUpperPercentage = int256 (5 * (10 ** (DECIMALS - 2 ))); // 0.05
251
- rebaseFunctionLowerPercentage = int256 ((- 77 ) * int256 (10 ** (DECIMALS - 3 ))); // -0.077
258
+ rebaseFunctionPositiveGrowth = int256 (45 * (10 ** DECIMALS)); // Positive growth
259
+ rebaseFunctionNegativeGrowth = int256 (45 * (10 ** DECIMALS)); // Negative growth
260
+ rebaseFunctionPositivePercentageLimit = int256 (5 * (10 ** (DECIMALS - 2 ))); // 0.05
261
+ rebaseFunctionNegativePercentageLimit = int256 ((- 77 ) * int256 (10 ** (DECIMALS - 3 ))); // -0.077
252
262
253
263
minRebaseTimeIntervalSec = 1 days ;
254
264
rebaseWindowOffsetSec = 7200 ; // 2AM UTC
@@ -334,12 +344,25 @@ contract UFragmentsPolicy is Ownable {
334
344
}
335
345
int256 targetRateSigned = targetRate.toInt256Safe ();
336
346
int256 normalizedRate = rate.toInt256Safe ().mul (ONE).div (targetRateSigned);
337
- int256 rebasePercentage = computeRebasePercentage (
338
- normalizedRate,
339
- rebaseFunctionLowerPercentage,
340
- rebaseFunctionUpperPercentage,
341
- rebaseFunctionGrowth
342
- );
347
+
348
+ // Determine growth and bounds based on positive or negative rebase
349
+ int256 rebasePercentage;
350
+ if (normalizedRate >= ONE) {
351
+ rebasePercentage = computeRebasePercentage (
352
+ normalizedRate,
353
+ - rebaseFunctionPositivePercentageLimit,
354
+ rebaseFunctionPositivePercentageLimit,
355
+ rebaseFunctionPositiveGrowth
356
+ );
357
+ } else {
358
+ rebasePercentage = computeRebasePercentage (
359
+ normalizedRate,
360
+ rebaseFunctionNegativePercentageLimit,
361
+ - rebaseFunctionNegativePercentageLimit,
362
+ rebaseFunctionNegativeGrowth
363
+ );
364
+ }
365
+
343
366
return uFrags.totalSupply ().toInt256Safe ().mul (rebasePercentage).div (ONE);
344
367
}
345
368
0 commit comments