diff --git a/packages/dapp/components/redeem/lib/use-prices.ts b/packages/dapp/components/redeem/lib/use-prices.ts index fb15312dd..4fb336373 100644 --- a/packages/dapp/components/redeem/lib/use-prices.ts +++ b/packages/dapp/components/redeem/lib/use-prices.ts @@ -12,7 +12,11 @@ const usePrices = (): [BigNumber | null, BigNumber | null, () => Promise] const [spotPrice, setSpotPrice] = useState(null); async function refreshPrices() { - if (protocolContracts && provider) { + try { + if(!protocolContracts || !provider) { + return; + } + const dollarTokenAddress = protocolContracts.managerFacet && await protocolContracts.managerFacet.dollarTokenAddress(); const newTwapPrice = protocolContracts.twapOracleDollar3poolFacet && await protocolContracts.twapOracleDollar3poolFacet.consult(dollarTokenAddress); @@ -21,6 +25,8 @@ const usePrices = (): [BigNumber | null, BigNumber | null, () => Promise] const newSpotPrice = await dollarMetapool["get_dy(int128,int128,uint256)"](0, 1, utils.parseEther("1")); setTwapPrice(newTwapPrice); setSpotPrice(newSpotPrice); + } catch (error) { + console.log("Error in refreshPrices: ", error) } }