From 0e0bd4dbccceda24368987229fed3d513ea71ff0 Mon Sep 17 00:00:00 2001 From: Leifu Chen Date: Tue, 12 Jul 2022 19:58:37 +0300 Subject: [PATCH] add atomic swap check back and remove the duplicated redeem button --- sections/exchange/hooks/useExchange.tsx | 40 ++++++++----------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/sections/exchange/hooks/useExchange.tsx b/sections/exchange/hooks/useExchange.tsx index 2789cecbc1..da2e66fbc8 100644 --- a/sections/exchange/hooks/useExchange.tsx +++ b/sections/exchange/hooks/useExchange.tsx @@ -977,10 +977,22 @@ const useExchange = ({ setTxError(null); setTxConfirmationModalOpen(true); + const sourceCurrencyKey = ethers.utils.parseBytes32String( + getExchangeParams(true)[0] as string + ); + const destinationCurrencyKey = ethers.utils.parseBytes32String( getExchangeParams(true)[2] as string ); + const isAtomic = + !isL2 && + [sourceCurrencyKey, destinationCurrencyKey].every((currency) => + ATOMIC_EXCHANGES_L1.includes(currency) + ); + + const exchangeParams = getExchangeParams(isAtomic); + try { setIsSubmitting(true); @@ -1010,14 +1022,6 @@ const useExchange = ({ gasLimit: gasInfo?.limit, ...gasConfig, }; - const isAtomic = - !isL2 && - (destinationCurrencyKey === 'sBTC' || - destinationCurrencyKey === 'sETH' || - destinationCurrencyKey === 'sEUR' || - destinationCurrencyKey === 'sUSD'); - - const exchangeParams = getExchangeParams(isAtomic); if (isAtomic) { tx = await synthetixjs.contracts.Synthetix.exchangeAtomically(...exchangeParams, gas); @@ -1364,26 +1368,6 @@ const useExchange = ({ attemptRetry={handleRedeem} /> )} - {balances.length !== 0 && totalUSDBalance.gt(0) && ( - - )} - {!redeemTxModalOpen ? null : ( - - )} {txConfirmationModalOpen && ( setTxConfirmationModalOpen(false)}