@@ -96,7 +96,8 @@ contract UFragmentsPolicy is Ownable {
96
96
// Used in computation of (Upper-Lower)/(1-(Upper/Lower)/2^(Growth*delta))) + Lower
97
97
int256 public rebaseFunctionLowerPercentage;
98
98
int256 public rebaseFunctionUpperPercentage;
99
- int256 public rebaseFunctionGrowth;
99
+ int256 public rebaseFunctionPositiveGrowth;
100
+ int256 public rebaseFunctionNegativeGrowth;
100
101
101
102
int256 private constant ONE = int256 (10 ** DECIMALS);
102
103
@@ -166,10 +167,6 @@ contract UFragmentsPolicy is Ownable {
166
167
orchestrator = orchestrator_;
167
168
}
168
169
169
- function setRebaseFunctionGrowth (int256 rebaseFunctionGrowth_ ) external onlyOwner {
170
- require (rebaseFunctionGrowth_ >= 0 );
171
- rebaseFunctionGrowth = rebaseFunctionGrowth_;
172
- }
173
170
174
171
function setRebaseFunctionLowerPercentage (int256 rebaseFunctionLowerPercentage_ )
175
172
external
@@ -187,6 +184,16 @@ contract UFragmentsPolicy is Ownable {
187
184
rebaseFunctionUpperPercentage = rebaseFunctionUpperPercentage_;
188
185
}
189
186
187
+ function setRebaseFunctionPositiveGrowth (int256 rebaseFunctionPositiveGrowth_ ) external onlyOwner {
188
+ require (rebaseFunctionPositiveGrowth_ >= 0 );
189
+ rebaseFunctionPositiveGrowth = rebaseFunctionPositiveGrowth_;
190
+ }
191
+
192
+ function setRebaseFunctionNegativeGrowth (int256 rebaseFunctionNegativeGrowth_ ) external onlyOwner {
193
+ require (rebaseFunctionNegativeGrowth_ >= 0 );
194
+ rebaseFunctionNegativeGrowth = rebaseFunctionNegativeGrowth_;
195
+ }
196
+
190
197
/**
191
198
* @notice Sets the deviation threshold fraction. If the exchange rate given by the market
192
199
* oracle is within this fractional distance from the targetRate, then no supply
@@ -246,7 +253,8 @@ contract UFragmentsPolicy is Ownable {
246
253
// deviationThreshold = 0.05e18 = 5e16
247
254
deviationThreshold = 25 * 10 ** (DECIMALS - 3 );
248
255
249
- rebaseFunctionGrowth = int256 (45 * (10 ** DECIMALS));
256
+ rebaseFunctionPositiveGrowth = int256 (45 * (10 ** DECIMALS)); // Positive growth
257
+ rebaseFunctionNegativeGrowth = int256 (45 * (10 ** DECIMALS)); // Negative growth
250
258
rebaseFunctionUpperPercentage = int256 (5 * (10 ** (DECIMALS - 2 ))); // 0.05
251
259
rebaseFunctionLowerPercentage = int256 ((- 77 ) * int256 (10 ** (DECIMALS - 3 ))); // -0.77
252
260
@@ -334,12 +342,19 @@ contract UFragmentsPolicy is Ownable {
334
342
}
335
343
int256 targetRateSigned = targetRate.toInt256Safe ();
336
344
int256 normalizedRate = rate.toInt256Safe ().mul (ONE).div (targetRateSigned);
337
- int256 rebasePercentage = computeRebasePercentage (
338
- normalizedRate,
339
- rebaseFunctionLowerPercentage,
340
- rebaseFunctionUpperPercentage,
341
- rebaseFunctionGrowth
342
- );
345
+
346
+ // Determine growth and bounds based on positive or negative rebase
347
+ int256 growth = normalizedRate >= ONE
348
+ ? rebaseFunctionPositiveGrowth
349
+ : rebaseFunctionNegativeGrowth;
350
+ int256 lower = normalizedRate >= ONE
351
+ ? - rebaseFunctionUpperPercentage
352
+ : rebaseFunctionLowerPercentage;
353
+ int256 upper = normalizedRate >= ONE
354
+ ? rebaseFunctionUpperPercentage
355
+ : - rebaseFunctionLowerPercentage;
356
+
357
+ int256 rebasePercentage = computeRebasePercentage (normalizedRate, lower, upper, growth);
343
358
return uFrags.totalSupply ().toInt256Safe ().mul (rebasePercentage).div (ONE);
344
359
}
345
360
0 commit comments