Skip to content

Commit

Permalink
fix: added debug option to refreshPrices function
Browse files Browse the repository at this point in the history
  • Loading branch information
bojan07 committed Oct 3, 2023
1 parent b1b2bc2 commit dd22fa0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/dapp/components/redeem/lib/use-prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ const usePrices = (): [BigNumber | null, BigNumber | null, () => Promise<void>]
const [spotPrice, setSpotPrice] = useState<BigNumber | null>(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);

Expand All @@ -21,6 +25,8 @@ const usePrices = (): [BigNumber | null, BigNumber | null, () => Promise<void>]
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)
}
}

Expand Down

0 comments on commit dd22fa0

Please sign in to comment.