@@ -2,7 +2,7 @@ import { convertRawAmountToDecimalFormat, isZero } from '@/helpers/utilities';
22import { createDerivedStore } from '@/state/internal/createDerivedStore' ;
33import { shallowEqual } from '@/worklets/comparisons' ;
44import { useStakingPositionStore } from '../rnbwStakingPositionStore' ;
5- import { divWorklet , sumWorklet , toFixedWorklet , toPercentageWorklet } from '@/framework/core/safeMath' ;
5+ import { divWorklet , sumWorklet , toFixedWorklet , toPercentageWorklet , truncateToDecimals } from '@/framework/core/safeMath' ;
66import { formatNumber } from '@/helpers/strings' ;
77
88type StakingEarnings = {
@@ -41,10 +41,10 @@ export const useRnbwStakingEarnings = createDerivedStore<StakingEarnings>(
4141
4242 return {
4343 totalEarnings : formatNumber ( totalEarnings , { decimals : 4 } ) ,
44- cashbackEarnings : formatNumber ( cashbackEarnings ) ,
45- cashbackShare : totalIsZero ? '0%' : `${ toPercentageWorklet ( cashbackRatio , 0.001 ) } %` ,
46- exitRewardsEarnings : formatNumber ( exitRewardsEarnings ) ,
47- exitRewardsShare : totalIsZero ? '0%' : `${ toPercentageWorklet ( exitRewardsRatio , 0.001 ) } %` ,
44+ cashbackEarnings : isZero ( cashbackEarnings ) ? '0' : formatNumber ( truncateToDecimals ( cashbackEarnings , 2 ) , { decimals : 2 } ) ,
45+ cashbackShare : totalIsZero ? '0%' : `${ toPercentageWorklet ( cashbackRatio ) } %` ,
46+ exitRewardsEarnings : isZero ( exitRewardsEarnings ) ? '0' : formatNumber ( truncateToDecimals ( exitRewardsEarnings , 2 ) , { decimals : 2 } ) ,
47+ exitRewardsShare : totalIsZero ? '0%' : `${ toPercentageWorklet ( exitRewardsRatio ) } %` ,
4848 } ;
4949 } ,
5050 { equalityFn : shallowEqual , fastMode : true }
0 commit comments