@@ -4,9 +4,10 @@ import Rebase, { RebaseData } from './Rebase'
4
4
export interface PolicyData {
5
5
id : string
6
6
address : string
7
- rebaseFunctionLowerPercentage : string
8
- rebaseFunctionUpperPercentage : string
9
- rebaseFunctionGrowth : string
7
+ rebaseFunctionPositivePercentageLimit : string
8
+ rebaseFunctionPositiveGrowth : string
9
+ rebaseFunctionNegativePercentageLimit : string
10
+ rebaseFunctionNegativeGrowth : string
10
11
rebaseLag : string
11
12
deviationThreshold : string
12
13
minRebaseTimeIntervalSec : string
@@ -105,15 +106,35 @@ export default class Policy {
105
106
return new BigNumber ( '0' )
106
107
}
107
108
108
- const upper = new BigNumber ( this . rebaseFunctionUpperPercentage )
109
- const lower = new BigNumber ( this . rebaseFunctionLowerPercentage )
110
- const growth = new BigNumber ( this . rebaseFunctionGrowth )
109
+ // Commented out the original lines
110
+ // const positiveUpper = new BigNumber(this.rebaseFunctionPositivePercentageLimit)
111
+ // const positiveLower = new BigNumber(this.rebaseFunctionPositivePercentageLimit).negated()
112
+ // const positiveGrowth = new BigNumber(this.rebaseFunctionPositiveGrowth)
113
+
114
+ // const negativeUpper = new BigNumber(this.rebaseFunctionNegativePercentageLimit)
115
+ // const negativeLower = new BigNumber(this.rebaseFunctionNegativePercentageLimit).negated()
116
+ // const negativeGrowth = new BigNumber(this.rebaseFunctionNegativeGrowth)
117
+
118
+ // Hardcoded values
119
+ const positiveUpper = new BigNumber ( '0.05' ) . multipliedBy ( 1e18 )
120
+ const positiveLower = new BigNumber ( '-0.05' ) . multipliedBy ( 1e18 )
121
+ const positiveGrowth = new BigNumber ( '20' ) . multipliedBy ( 1e18 )
122
+
123
+ const negativeUpper = new BigNumber ( '-0.077' ) . multipliedBy ( 1e18 )
124
+ const negativeLower = new BigNumber ( '0.077' ) . multipliedBy ( 1e18 )
125
+ const negativeGrowth = new BigNumber ( '41' ) . multipliedBy ( 1e18 )
126
+
111
127
const scaling = new BigNumber ( '32' )
112
128
113
129
const delta = new BigNumber ( marketRate )
114
130
. div ( new BigNumber ( targetRate ) )
115
131
. minus ( new BigNumber ( '1' ) )
116
132
133
+ const isPositive = delta . gte ( 0 )
134
+ const upper = isPositive ? positiveUpper : negativeUpper
135
+ const lower = isPositive ? positiveLower : negativeLower
136
+ const growth = isPositive ? positiveGrowth : negativeGrowth
137
+
117
138
let exp = growth . multipliedBy ( delta )
118
139
exp = BigNumber . minimum ( new BigNumber ( '100' ) , exp )
119
140
exp = BigNumber . maximum ( new BigNumber ( '-100' ) , exp )
@@ -123,6 +144,7 @@ export default class Policy {
123
144
. dp ( 0 , BigNumber . ROUND_FLOOR )
124
145
. div ( scaling )
125
146
: exp . multipliedBy ( scaling ) . dp ( 0 , BigNumber . ROUND_CEIL ) . div ( scaling )
147
+
126
148
const pow = new BigNumber ( 2 ** exp . toNumber ( ) )
127
149
if ( pow . isEqualTo ( new BigNumber ( '0' ) ) ) {
128
150
return new BigNumber ( '0' )
0 commit comments