@@ -86,24 +86,17 @@ export default function Review() {
8686 marketAddress : market ,
8787 } ) ;
8888
89- const installmentsAmount = singleInstallment
89+ const totalAmount = singleInstallment
9090 ? ( borrow ?. assets ?? 0n )
91- : split
92- ? split . installments . reduce ( ( accumulator , current ) => accumulator + current , 0n ) /
93- BigInt ( split . installments . length )
94- : 0n ;
91+ : ( split ?. installments . reduce ( ( accumulator , current ) => accumulator + current , 0n ) ?? 0n ) ;
9592
96- const totalAmount = borrow
97- ? borrow . assets
93+ const installmentsAmount = singleInstallment
94+ ? totalAmount
9895 : split
99- ? split . installments . reduce ( ( accumulator , current ) => accumulator + current , 0n )
96+ ? totalAmount / BigInt ( split . installments . length )
10097 : 0n ;
10198
102- const feeAmount = borrow
103- ? borrow . assets - ( amount ?? 0n )
104- : split
105- ? split . installments . reduce ( ( accumulator , current ) => accumulator + current , 0n ) - ( amount ?? 0n )
106- : 0n ;
99+ const feeAmount = totalAmount === 0n ? 0n : totalAmount - ( amount ?? 0n ) ;
107100
108101 const { mutateAsync : mutateSendCalls } = useSendCalls ( ) ;
109102 const {
@@ -165,10 +158,10 @@ export default function Review() {
165158 } ) ,
166159 [ maturity , language ] ,
167160 ) ;
168- const rate = borrow
169- ? Number (
170- ( ( borrow . assets - ( amount ?? 0n ) ) * WAD * 31_536_000n ) / ( ( amount ?? 0n ) * ( borrow . maturity - timestamp ) ) ,
171- ) / 1e18
161+ const rate = singleInstallment
162+ ? borrow && amount
163+ ? Number ( ( feeAmount * WAD * 31_536_000n ) / ( amount * ( borrow . maturity - timestamp ) ) ) / 1e18
164+ : 0
172165 : split
173166 ? Number ( split . effectiveRate ) / 1e18
174167 : 0 ;
@@ -283,10 +276,7 @@ export default function Review() {
283276 < XStack alignItems = "center" gap = "$s2" >
284277 < AssetLogo height = { 16 } symbol = { symbol } width = { 16 } />
285278 < Text title3 color = "$uiNeutralPrimary" >
286- { (
287- Number ( singleInstallment ? totalAmount : installmentsAmount ) /
288- 10 ** ( assetMarket ?. decimals ?? 6 )
289- ) . toLocaleString ( language , {
279+ { ( Number ( installmentsAmount ) / 10 ** ( assetMarket ?. decimals ?? 6 ) ) . toLocaleString ( language , {
290280 minimumFractionDigits : 2 ,
291281 maximumFractionDigits : 2 ,
292282 } ) }
0 commit comments