@@ -15,7 +15,9 @@ import { WalletBalance } from 'src/modules/reserve-overview/ReserveActions';
1515import { SGHODepositPanel } from 'src/modules/sGho/SGhoDepositPanel' ;
1616import { SGHOHeader } from 'src/modules/sGho/SGhoHeader' ;
1717import { useRootStore } from 'src/store/root' ;
18+ import { CustomMarket } from 'src/ui-config/marketsConfig' ;
1819import { SAFETY_MODULE } from 'src/utils/events' ;
20+ import { useShallow } from 'zustand/shallow' ;
1921
2022import { useWeb3Context } from '../src/libs/hooks/useWeb3Context' ;
2123
@@ -33,14 +35,24 @@ const SavingsGhoWithdrawModal = dynamic(() =>
3335export default function SavingsGho ( ) {
3436 const { openSavingsGhoDeposit, openSavingsGhoWithdraw } = useModalContext ( ) ;
3537 const { currentAccount } = useWeb3Context ( ) ;
36- const trackEvent = useRootStore ( ( store ) => store . trackEvent ) ;
38+ const [ trackEvent , currentMarket , setCurrentMarket ] = useRootStore (
39+ useShallow ( ( store ) => [ store . trackEvent , store . currentMarket , store . setCurrentMarket ] )
40+ ) ;
3741 const currentMarketData = useRootStore ( ( store ) => store . currentMarketData ) ;
3842 const { breakpoints } = useTheme ( ) ;
3943 const downToXsm = useMediaQuery ( breakpoints . down ( 'xsm' ) ) ;
4044 const { data : stakeUserResult } = useUserStakeUiData ( currentMarketData ) ;
4145
4246 const { data : stakeGeneralResult } = useGeneralStakeUiData ( currentMarketData ) ;
4347
48+ // Automatically switch to mainnet if not already on mainnet
49+ // since sGHO only exists on Ethereum mainnet
50+ useEffect ( ( ) => {
51+ if ( currentMarket !== CustomMarket . proto_mainnet_v3 ) {
52+ setCurrentMarket ( CustomMarket . proto_mainnet_v3 ) ;
53+ }
54+ } , [ currentMarket , setCurrentMarket ] ) ;
55+
4456 useEffect ( ( ) => {
4557 trackEvent ( 'Page Viewed' , {
4658 'Page Name' : 'sGHO' ,
0 commit comments