Skip to content

Commit

Permalink
fix: make code clean in use-prices
Browse files Browse the repository at this point in the history
  • Loading branch information
bojan07 authored and molecula451 committed Oct 3, 2023
1 parent df8cefa commit d41cc0d
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/dapp/components/redeem/lib/use-prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ const usePrices = (): [BigNumber | null, BigNumber | null, () => Promise<void>]
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)
}
Expand Down

1 comment on commit d41cc0d

@ubiquibot
Copy link

@ubiquibot ubiquibot bot commented on d41cc0d Oct 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.