@@ -150,18 +150,20 @@ const SimulatorPopup: React.FC<ISimulatorPopup> = ({ amountToStake, isStaking })
150
150
const currentTreeDisputesPerPnk = foundCourt ?. treeDisputesPerPnk ;
151
151
const currentTreeExpectedRewardPerPnk = foundCourt ?. treeExpectedRewardPerPnk ;
152
152
153
- const totalVotes =
154
- ! isUndefined ( courtCurrentEffectiveStake ) && ! isUndefined ( currentTreeVotesPerPnk )
155
- ? courtCurrentEffectiveStake * currentTreeVotesPerPnk
156
- : undefined ;
157
- const totalCases =
158
- ! isUndefined ( courtCurrentEffectiveStake ) && ! isUndefined ( currentTreeDisputesPerPnk )
159
- ? courtCurrentEffectiveStake * currentTreeDisputesPerPnk
160
- : undefined ;
161
- const totalRewards =
162
- ! isUndefined ( courtCurrentEffectiveStake ) && ! isUndefined ( currentTreeExpectedRewardPerPnk )
163
- ? courtCurrentEffectiveStake * currentTreeExpectedRewardPerPnk
164
- : undefined ;
153
+ const totals = useMemo ( ( ) => {
154
+ if ( isUndefined ( courtCurrentEffectiveStake ) ) return { } ;
155
+ return {
156
+ votes : ! isUndefined ( currentTreeVotesPerPnk ) ? courtCurrentEffectiveStake * currentTreeVotesPerPnk : undefined ,
157
+ cases : ! isUndefined ( currentTreeDisputesPerPnk )
158
+ ? courtCurrentEffectiveStake * currentTreeDisputesPerPnk
159
+ : undefined ,
160
+ rewards : ! isUndefined ( currentTreeExpectedRewardPerPnk )
161
+ ? courtCurrentEffectiveStake * currentTreeExpectedRewardPerPnk
162
+ : undefined ,
163
+ } ;
164
+ } , [ courtCurrentEffectiveStake , currentTreeVotesPerPnk , currentTreeDisputesPerPnk , currentTreeExpectedRewardPerPnk ] ) ;
165
+
166
+ const { votes : totalVotes , cases : totalCases , rewards : totalRewards } = totals ;
165
167
166
168
const courtFutureEffectiveStake = ! isUndefined ( courtCurrentEffectiveStake )
167
169
? Math . max ( isStaking ? courtCurrentEffectiveStake + amountToStake : courtCurrentEffectiveStake - amountToStake , 0 )
0 commit comments