diff --git a/packages/dapp/components/redeem/lib/use-prices.ts b/packages/dapp/components/redeem/lib/use-prices.ts index 4fb336373..9b22d050e 100644 --- a/packages/dapp/components/redeem/lib/use-prices.ts +++ b/packages/dapp/components/redeem/lib/use-prices.ts @@ -17,14 +17,16 @@ const usePrices = (): [BigNumber | null, BigNumber | null, () => Promise] return; } - const dollarTokenAddress = protocolContracts.managerFacet && await protocolContracts.managerFacet.dollarTokenAddress(); - const newTwapPrice = protocolContracts.twapOracleDollar3poolFacet && await protocolContracts.twapOracleDollar3poolFacet.consult(dollarTokenAddress); - - const dollar3poolMarket = protocolContracts.managerFacet && await protocolContracts.managerFacet.stableSwapMetaPoolAddress(); - const dollarMetapool = getIMetaPoolContract(dollar3poolMarket, provider) - const newSpotPrice = await dollarMetapool["get_dy(int128,int128,uint256)"](0, 1, utils.parseEther("1")); - setTwapPrice(newTwapPrice); - setSpotPrice(newSpotPrice); + if(protocolContracts.managerFacet && protocolContracts.twapOracleDollar3poolFacet) { + const dollarTokenAddress = await protocolContracts.managerFacet.dollarTokenAddress(); + const newTwapPrice = await protocolContracts.twapOracleDollar3poolFacet.consult(dollarTokenAddress); + const dollar3poolMarket = await protocolContracts.managerFacet.stableSwapMetaPoolAddress(); + const dollarMetapool = getIMetaPoolContract(dollar3poolMarket, provider) + 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) }