From 10a4d271514ddfc863f3950a467c201ea3fef2b7 Mon Sep 17 00:00:00 2001 From: Darya Kaviani Date: Fri, 15 Jul 2022 22:30:44 -0700 Subject: [PATCH] update to promise.all --- packages/frontend/src/state/lp/hooks.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/state/lp/hooks.ts b/packages/frontend/src/state/lp/hooks.ts index abf10c0da..60aa982a4 100644 --- a/packages/frontend/src/state/lp/hooks.ts +++ b/packages/frontend/src/state/lp/hooks.ts @@ -31,9 +31,10 @@ export const useOpenPositionDeposit = () => { async (squeethToMint: BigNumber, lowerTickInput: number, upperTickInput: number, vaultId: number, onTxConfirmed?: () => void) => { if (!contract || !address) return null - const squeethPrice = await getTwapSqueethPrice() const mintWSqueethAmount = fromTokenAmount(squeethToMint, OSQUEETH_DECIMALS) - const ethDebt = await getDebtAmount(mintWSqueethAmount) + const squeethPricePromise = getTwapSqueethPrice() + const ethDebtPromise = getDebtAmount(mintWSqueethAmount) + const [squeethPrice, ethDebt] = await Promise.all([squeethPricePromise, ethDebtPromise]) const collateralToMint = ethDebt.multipliedBy(COLLAT_RATIO) const collateralToLp = mintWSqueethAmount.multipliedBy(squeethPrice)