@@ -122,30 +122,30 @@ export function formatGhoUserData({
122122 userGhoAvailableToBorrowAtDiscount = 0 ;
123123 }
124124
125- const userBalancePreDiscount = getCompoundedBalance ( {
125+ const balance = getCompoundedBalance ( {
126126 principalBalance : ghoUserData . userGhoScaledBorrowBalance ,
127127 reserveIndex : ghoReserveData . ghoCurrentBorrowIndex ,
128128 reserveRate : ghoReserveData . ghoBaseVariableBorrowRate ,
129129 lastUpdateTimestamp : Number ( ghoReserveData . ghoReserveLastUpdateTimestamp ) ,
130130 currentTimestamp,
131131 } ) ;
132- const accruedInterest = userBalancePreDiscount . minus (
132+ const balanceIncrease = balance . minus (
133133 rayMul (
134134 ghoUserData . userGhoScaledBorrowBalance ,
135135 ghoUserData . userPreviousGhoBorrowIndex ,
136136 ) ,
137137 ) ;
138- const discount = accruedInterest . multipliedBy (
139- 1 - Number ( normalize ( ghoUserData . userGhoDiscountPercent , 4 ) ) ,
140- ) ;
141- const userBorrowBalance = userBalancePreDiscount . minus ( discount ) ;
138+ const discountedAmount = balanceIncrease
139+ . multipliedBy ( ghoUserData . userGhoDiscountPercent )
140+ . dividedBy ( 10000 ) ; // discount is in basis points
141+ const userBorrowBalance = balance . minus ( discountedAmount ) ;
142142 return {
143143 userGhoDiscountPercent : Number (
144144 normalize ( ghoUserData . userGhoDiscountPercent , 4 ) ,
145145 ) ,
146146 userDiscountTokenBalance : formattedUserDiscountTokenBalance ,
147147 userGhoBorrowBalance : Number ( normalize ( userBorrowBalance , 18 ) ) ,
148- userDiscountedGhoInterest : Number ( normalize ( discount , 18 ) ) ,
148+ userDiscountedGhoInterest : Number ( normalize ( discountedAmount , 18 ) ) ,
149149 userGhoAvailableToBorrowAtDiscount,
150150 } ;
151151}
0 commit comments