@@ -94,9 +94,13 @@ 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;
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;
100104
101105 int256 private constant ONE = int256 (10 ** DECIMALS);
102106
@@ -166,25 +170,30 @@ contract UFragmentsPolicy is Ownable {
166170 orchestrator = orchestrator_;
167171 }
168172
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_ )
175174 external
176175 onlyOwner
177176 {
178- require (rebaseFunctionLowerPercentage_ <= 0 );
179- rebaseFunctionLowerPercentage = rebaseFunctionLowerPercentage_ ;
177+ require (rebaseFunctionNegativePercentageLimit_ <= 0 );
178+ rebaseFunctionNegativePercentageLimit = rebaseFunctionNegativePercentageLimit_ ;
180179 }
181180
182- function setRebaseFunctionUpperPercentage (int256 rebaseFunctionUpperPercentage_ )
181+ function setRebaseFunctionPositivePercentageLimit (int256 rebaseFunctionPositivePercentageLimit_ )
183182 external
184183 onlyOwner
185184 {
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_;
188197 }
189198
190199 /**
@@ -246,9 +255,10 @@ contract UFragmentsPolicy is Ownable {
246255 // deviationThreshold = 0.05e18 = 5e16
247256 deviationThreshold = 25 * 10 ** (DECIMALS - 3 );
248257
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
252262
253263 minRebaseTimeIntervalSec = 1 days ;
254264 rebaseWindowOffsetSec = 7200 ; // 2AM UTC
@@ -334,12 +344,25 @@ contract UFragmentsPolicy is Ownable {
334344 }
335345 int256 targetRateSigned = targetRate.toInt256Safe ();
336346 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+
343366 return uFrags.totalSupply ().toInt256Safe ().mul (rebasePercentage).div (ONE);
344367 }
345368
0 commit comments