@@ -4,9 +4,10 @@ import Rebase, { RebaseData } from './Rebase'
44export interface PolicyData {
55 id : string
66 address : string
7- rebaseFunctionLowerPercentage : string
8- rebaseFunctionUpperPercentage : string
9- rebaseFunctionGrowth : string
7+ rebaseFunctionPositivePercentageLimit : string
8+ rebaseFunctionPositiveGrowth : string
9+ rebaseFunctionNegativePercentageLimit : string
10+ rebaseFunctionNegativeGrowth : string
1011 rebaseLag : string
1112 deviationThreshold : string
1213 minRebaseTimeIntervalSec : string
@@ -105,15 +106,35 @@ export default class Policy {
105106 return new BigNumber ( '0' )
106107 }
107108
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+
111127 const scaling = new BigNumber ( '32' )
112128
113129 const delta = new BigNumber ( marketRate )
114130 . div ( new BigNumber ( targetRate ) )
115131 . minus ( new BigNumber ( '1' ) )
116132
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+
117138 let exp = growth . multipliedBy ( delta )
118139 exp = BigNumber . minimum ( new BigNumber ( '100' ) , exp )
119140 exp = BigNumber . maximum ( new BigNumber ( '-100' ) , exp )
@@ -123,6 +144,7 @@ export default class Policy {
123144 . dp ( 0 , BigNumber . ROUND_FLOOR )
124145 . div ( scaling )
125146 : exp . multipliedBy ( scaling ) . dp ( 0 , BigNumber . ROUND_CEIL ) . div ( scaling )
147+
126148 const pow = new BigNumber ( 2 ** exp . toNumber ( ) )
127149 if ( pow . isEqualTo ( new BigNumber ( '0' ) ) ) {
128150 return new BigNumber ( '0' )
0 commit comments