1
1
import { Trans } from '@lingui/macro' ;
2
2
import { Box , Button } from '@mui/material' ;
3
3
import { useRouter } from 'next/router' ;
4
- import { useCallback } from 'react' ;
4
+ import { useMemo } from 'react' ;
5
5
import { UserMigrationReserves } from 'src/hooks/migration/useUserMigrationReserves' ;
6
6
import { UserSummaryForMigration } from 'src/hooks/migration/useUserSummaryForMigration' ;
7
7
import { useModalContext } from 'src/hooks/useModal' ;
@@ -12,6 +12,7 @@ import {
12
12
selectSelectedBorrowReservesForMigrationV3 ,
13
13
} from 'src/store/v3MigrationSelectors' ;
14
14
import { CustomMarket , getNetworkConfig } from 'src/utils/marketsAndNetworksConfig' ;
15
+ import { useShallow } from 'zustand/shallow' ;
15
16
16
17
import { TxErrorView } from '../FlowCommons/Error' ;
17
18
import { GasEstimationError } from '../FlowCommons/GasEstimationError' ;
@@ -40,22 +41,31 @@ export const MigrateV3ModalContent = ({
40
41
const router = useRouter ( ) ;
41
42
const networkConfig = getNetworkConfig ( currentChainId ) ;
42
43
43
- const { supplyPositions, borrowPositions } = useRootStore (
44
- useCallback (
45
- ( state ) => ( {
46
- supplyPositions : selectedUserSupplyReservesForMigration (
47
- state . selectedMigrationSupplyAssets ,
48
- userMigrationReserves . supplyReserves ,
49
- userMigrationReserves . isolatedReserveV3
50
- ) ,
51
- borrowPositions : selectSelectedBorrowReservesForMigrationV3 (
52
- state . selectedMigrationBorrowAssets ,
53
- toUserSummaryForMigration ,
54
- userMigrationReserves
55
- ) ,
56
- } ) ,
57
- [ userMigrationReserves , toUserSummaryForMigration ]
58
- )
44
+ const { selectedMigrationSupplyAssets, selectedMigrationBorrowAssets } = useRootStore (
45
+ useShallow ( ( state ) => ( {
46
+ selectedMigrationSupplyAssets : state . selectedMigrationSupplyAssets ,
47
+ selectedMigrationBorrowAssets : state . selectedMigrationBorrowAssets ,
48
+ } ) )
49
+ ) ;
50
+
51
+ const supplyPositions = useMemo (
52
+ ( ) =>
53
+ selectedUserSupplyReservesForMigration (
54
+ selectedMigrationSupplyAssets ,
55
+ userMigrationReserves . supplyReserves ,
56
+ userMigrationReserves . isolatedReserveV3
57
+ ) ,
58
+ [ selectedMigrationSupplyAssets , userMigrationReserves ]
59
+ ) ;
60
+
61
+ const borrowPositions = useMemo (
62
+ ( ) =>
63
+ selectSelectedBorrowReservesForMigrationV3 (
64
+ selectedMigrationBorrowAssets ,
65
+ toUserSummaryForMigration ,
66
+ userMigrationReserves
67
+ ) ,
68
+ [ selectedMigrationBorrowAssets , toUserSummaryForMigration , userMigrationReserves ]
59
69
) ;
60
70
61
71
const supplyAssets = supplyPositions . map ( ( supplyAsset ) => {
0 commit comments