Skip to content

Commit 771a5e0

Browse files
authored
fix: sgho issue (#2577)
1 parent bd8a4ef commit 771a5e0

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

pages/sgho.page.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import { WalletBalance } from 'src/modules/reserve-overview/ReserveActions';
1515
import { SGHODepositPanel } from 'src/modules/sGho/SGhoDepositPanel';
1616
import { SGHOHeader } from 'src/modules/sGho/SGhoHeader';
1717
import { useRootStore } from 'src/store/root';
18+
import { CustomMarket } from 'src/ui-config/marketsConfig';
1819
import { SAFETY_MODULE } from 'src/utils/events';
20+
import { useShallow } from 'zustand/shallow';
1921

2022
import { useWeb3Context } from '../src/libs/hooks/useWeb3Context';
2123

@@ -33,14 +35,24 @@ const SavingsGhoWithdrawModal = dynamic(() =>
3335
export 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

Comments
 (0)