@@ -375,7 +375,7 @@ export function parseUserStrategiesFinancialData(userPositions: EarnPosition[] =
375375
376376 const newAmount = assetBalance . amount . amount + acc [ assetBalance . token . address ] . amount ;
377377 const newAmountInUsd =
378- Number ( assetBalance . amount . amountInUSD ) + Number ( acc [ assetBalance . token . address ] . amountInUSD ) ;
378+ Number ( assetBalance . amount . amountInUSD ?? 0 ) + Number ( acc [ assetBalance . token . address ] . amountInUSD ?? 0 ) ;
379379 // eslint-disable-next-line no-param-reassign
380380 acc [ assetBalance . token . address ] = {
381381 amount : newAmount ,
@@ -406,14 +406,14 @@ export function parseUserStrategiesFinancialData(userPositions: EarnPosition[] =
406406
407407 const newAmount = tokenBalance . profit . amount + acc [ tokenBalance . token . address ] . amount ;
408408 const newAmountInUsd =
409- Number ( tokenBalance . profit . amountInUSD ) + Number ( acc [ tokenBalance . token . address ] . amountInUSD ) ;
409+ Number ( tokenBalance . profit . amountInUSD ?? 0 ) + Number ( acc [ tokenBalance . token . address ] . amountInUSD ?? 0 ) ;
410410
411411 // Asset tracking
412412 if ( isSameToken ( tokenBalance . token , position . strategy . asset ) ) {
413- currentProfitAssetUsd += Number ( tokenBalance . profit . amountInUSD ) ;
413+ currentProfitAssetUsd += Number ( tokenBalance . profit . amountInUSD ?? 0 ) ;
414414 }
415415 // Totals tracking
416- currentProfitTotalUsd += Number ( tokenBalance . profit . amountInUSD ) ;
416+ currentProfitTotalUsd += Number ( tokenBalance . profit . amountInUSD ?? 0 ) ;
417417
418418 // eslint-disable-next-line no-param-reassign
419419 acc [ tokenBalance . token . address ] = {
@@ -457,7 +457,8 @@ export function parseUserStrategiesFinancialData(userPositions: EarnPosition[] =
457457 const newRatiodUsdAmount =
458458 Number ( assetBalance ?. amount . amountInUSD || 0 ) * ( period . annualRatio * ( totalApy / 100 ) ) ;
459459 const newAmount = newRatiodAmount + periodAcc . byToken [ assetBalance . token . address ] . amount ;
460- const newAmountInUsd = newRatiodUsdAmount + Number ( periodAcc . byToken [ assetBalance . token . address ] . amountInUSD ) ;
460+ const newAmountInUsd =
461+ newRatiodUsdAmount + Number ( periodAcc . byToken [ assetBalance . token . address ] . amountInUSD || 0 ) ;
461462 // eslint-disable-next-line no-param-reassign
462463 periodAcc . byToken [ assetBalance . token . address ] = {
463464 amount : newAmount ,
@@ -514,9 +515,9 @@ export function parseUserStrategiesFinancialData(userPositions: EarnPosition[] =
514515 acc [ balance . token . address ] = {
515516 amount : acc [ balance . token . address ] . amount + balance . profit . amount ,
516517 amountInUnits : formatUnits ( acc [ balance . token . address ] . amount + balance . profit . amount , balance . token . decimals ) ,
517- amountInUSD : ( Number ( acc [ balance . token . address ] . amountInUSD ) + Number ( balance . profit . amountInUSD ) ) . toFixed (
518- 18
519- ) ,
518+ amountInUSD : (
519+ Number ( acc [ balance . token . address ] . amountInUSD ?? 0 ) + Number ( balance . profit . amountInUSD ?? 0 )
520+ ) . toFixed ( 18 ) ,
520521 } ;
521522 } ) ;
522523 } else {
@@ -536,13 +537,14 @@ export function parseUserStrategiesFinancialData(userPositions: EarnPosition[] =
536537 }
537538
538539 const amountProfit = currentBalanceToken . profit . amount - balance . profit . amount ;
539- const amountProfitInUsd = Number ( currentBalanceToken . profit . amountInUSD ) - Number ( balance . profit . amountInUSD ) ;
540+ const amountProfitInUsd =
541+ Number ( currentBalanceToken . profit . amountInUSD ?? 0 ) - Number ( balance . profit . amountInUSD ?? 0 ) ;
540542
541543 // eslint-disable-next-line no-param-reassign
542544 acc [ balance . token . address ] = {
543545 amount : acc [ balance . token . address ] . amount + amountProfit ,
544546 amountInUnits : formatUnits ( acc [ balance . token . address ] . amount + amountProfit , balance . token . decimals ) ,
545- amountInUSD : ( Number ( acc [ balance . token . address ] . amountInUSD ) + amountProfitInUsd ) . toFixed ( 18 ) ,
547+ amountInUSD : ( Number ( acc [ balance . token . address ] . amountInUSD ?? 0 ) + amountProfitInUsd ) . toFixed ( 18 ) ,
546548 } ;
547549 } ) ;
548550 }
@@ -552,7 +554,7 @@ export function parseUserStrategiesFinancialData(userPositions: EarnPosition[] =
552554
553555 const totalMonthlyEarnings = Object . values ( monthlyEarnings ) . reduce ( ( acc , amount ) => {
554556 // eslint-disable-next-line no-param-reassign
555- return acc + Number ( amount . amountInUSD ) || 0 ;
557+ return acc + Number ( amount . amountInUSD ?? 0 ) || 0 ;
556558 } , 0 ) ;
557559
558560 return {
0 commit comments