Skip to content

Commit

Permalink
fix (#5738)
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat authored and ibrahimtaveras00 committed May 16, 2024
1 parent 0e01043 commit 0262a3c
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/screens/ExchangeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { ethereumUtils, gasUtils } from '@/utils';
import { IS_ANDROID, IS_IOS, IS_TEST } from '@/env';
import logger from '@/utils/logger';
import { CROSSCHAIN_SWAPS, useExperimentalFlag } from '@/config';
import { CrosschainQuote, Quote } from '@rainbow-me/swaps';
import { ChainId, CrosschainQuote, Quote, QuoteError } from '@rainbow-me/swaps';
import store from '@/redux/store';
import { getCrosschainSwapServiceTime } from '@/handlers/swap';
import useParamsForExchangeModal from '@/hooks/useParamsForExchangeModal';
Expand All @@ -76,6 +76,7 @@ import { AddressOrEth, ParsedAsset } from '@/__swaps__/types/assets';
import { TokenColors } from '@/graphql/__generated__/metadata';
import { estimateSwapGasLimit } from '@/raps/actions';
import { estimateCrosschainSwapGasLimit } from '@/raps/actions/crosschainSwap';
import { isUnwrapEth, isWrapEth } from '@/__swaps__/utils/swaps';

export const DEFAULT_SLIPPAGE_BIPS = {
[Network.mainnet]: 100,
Expand Down Expand Up @@ -449,14 +450,34 @@ export default function ExchangeModal({ fromDiscover, ignoreInitialTypeCheck, te
colors: outputCurrency.colors as TokenColors,
} as ParsedAsset;

const isWrapOrUnwrapEth = () => {
return (
isWrapEth({
buyTokenAddress: tradeDetails?.buyTokenAddress,
sellTokenAddress: tradeDetails?.sellTokenAddress,
chainId: inputCurrency?.chainId || ChainId.mainnet,
}) ||
isUnwrapEth({
buyTokenAddress: tradeDetails?.buyTokenAddress,
sellTokenAddress: tradeDetails?.sellTokenAddress,
chainId: inputCurrency?.chainId || ChainId.mainnet,
})
);
};

const { nonce, errorMessage } = await walletExecuteRap(wallet, isCrosschainSwap ? 'crosschainSwap' : 'swap', {
chainId,
flashbots,
nonce: currentNonce,
assetToSell: transformedAssetToSell,
assetToBuy: transformedAssetToBuy,
sellAmount: inputAmount,
quote: tradeDetails,
quote: {
...tradeDetails,
feeInEth: isWrapOrUnwrapEth() ? '0' : tradeDetails.feeInEth,
fromChainId: inputCurrency.chainId,
toChainId: outputCurrency.chainId,
},
amount: inputAmount,
meta: {
inputAsset: transformedAssetToSell,
Expand Down

0 comments on commit 0262a3c

Please sign in to comment.