From df8cefa15341fba0ece2cbd5dea5aba7638369e4 Mon Sep 17 00:00:00 2001 From: bojan07 Date: Tue, 3 Oct 2023 05:39:24 -0400 Subject: [PATCH] fix: added debug option to refreshPrices function --- packages/dapp/components/redeem/lib/use-prices.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) } }