@@ -23,23 +23,38 @@ export const selectCurrentChainIdV3MarketKey = (state: RootStore): CustomMarket
2323export const selectCurrentChainIdV2MarketData = ( state : RootStore ) => {
2424 const v2MarketKey = selectCurrentChainIdV2MarketKey ( state ) ;
2525 const marketData = marketsData [ v2MarketKey ] ;
26- return state . data
27- . get ( state . currentChainId )
28- ?. get ( marketData . addresses . LENDING_POOL_ADDRESS_PROVIDER ) ;
26+ const v2MarketAddressProvider = marketData
27+ ? marketData . addresses . LENDING_POOL_ADDRESS_PROVIDER
28+ : undefined ;
29+ const currentChainId = state . currentChainId ;
30+ if ( v2MarketAddressProvider && currentChainId ) {
31+ return state . data . get ( state . currentChainId ) ?. get ( v2MarketAddressProvider ) ;
32+ }
33+ return undefined ;
2934} ;
3035
3136export const selectCurrentChainIdV3MarketData = ( state : RootStore ) => {
32- const v3MarketKey = selectCurrentChainIdV3MarketKey ( state ) ;
37+ const v3MarketKey = selectCurrentChainIdV2MarketKey ( state ) ;
3338 const marketData = marketsData [ v3MarketKey ] ;
34- return state . data
35- . get ( state . currentChainId )
36- ?. get ( marketData . addresses . LENDING_POOL_ADDRESS_PROVIDER ) ;
39+ const v3MarketAddressProvider = marketData
40+ ? marketData . addresses . LENDING_POOL_ADDRESS_PROVIDER
41+ : undefined ;
42+ const currentChainId = state . currentChainId ;
43+ if ( v3MarketAddressProvider && currentChainId ) {
44+ return state . data . get ( state . currentChainId ) ?. get ( v3MarketAddressProvider ) ;
45+ }
46+ return undefined ;
3747} ;
3848
3949export const selectCurrentUserLendingPoolData = ( state : RootStore ) => {
40- return state . data
41- . get ( state . currentChainId )
42- ?. get ( state . currentMarketData . addresses . LENDING_POOL_ADDRESS_PROVIDER ) ;
50+ const marketAddressProvider = state . currentMarketData
51+ ? state . currentMarketData . addresses . LENDING_POOL_ADDRESS_PROVIDER
52+ : undefined ;
53+ const currentChainId = state . currentChainId ;
54+ if ( marketAddressProvider && currentChainId ) {
55+ return state . data . get ( state . currentChainId ) ?. get ( marketAddressProvider ) ;
56+ }
57+ return undefined ;
4358} ;
4459
4560export const selectFormatUserEmodeCategoryId = ( reserve ?: PoolReserve ) => {
0 commit comments