diff --git a/src/apps/the-exchange/components/ExchangeAction/ExchangeAction.tsx b/src/apps/the-exchange/components/ExchangeAction/ExchangeAction.tsx index e1b9c92f..70a7442b 100644 --- a/src/apps/the-exchange/components/ExchangeAction/ExchangeAction.tsx +++ b/src/apps/the-exchange/components/ExchangeAction/ExchangeAction.tsx @@ -1,7 +1,8 @@ import { useEtherspotSwaps } from '@etherspot/transaction-kit'; import { CircularProgress } from '@mui/material'; -import { ethers } from 'ethers'; +import { BigNumber } from 'ethers'; import { useEffect, useState } from 'react'; +import { formatEther } from 'viem'; // services import { @@ -90,6 +91,10 @@ const ExchangeAction = () => { if ('receiveAmount' in bestOffer.offer) { // eslint-disable-next-line no-plusplus for (let i = 0; i < bestOffer.offer.transactions.length; ++i) { + const { value } = bestOffer.offer.transactions[i]; + const bigIntValue = BigNumber.from(value).toBigInt(); + const integerValue = formatEther(bigIntValue); + addToBatch({ title: getTransactionTitle( i, @@ -101,7 +106,7 @@ const ExchangeAction = () => { '', chainId: chainNameToChainIdTokensData(swapToken?.blockchain) || 0, to: bestOffer.offer.transactions[i].to, - value: bestOffer.offer.transactions[i].value, + value: integerValue, data: bestOffer.offer.transactions[i].data, }); } @@ -117,6 +122,9 @@ const ExchangeAction = () => { if (stepTransactions) { // eslint-disable-next-line no-plusplus for (let i = 0; i < stepTransactions.length; ++i) { + const { value } = stepTransactions[i]; + const bigIntValue = BigNumber.from(value).toBigInt(); + const integerValue = formatEther(bigIntValue); addToBatch({ title: getTransactionTitle( i, @@ -128,7 +136,7 @@ const ExchangeAction = () => { '', chainId: chainNameToChainIdTokensData(swapToken?.blockchain) || 0, to: stepTransactions[i].to || '', - value: ethers.BigNumber.from(stepTransactions[i].value), + value: integerValue, data: stepTransactions[i].data?.toString() ?? '', }); } diff --git a/src/services/tokensData.ts b/src/services/tokensData.ts index 22f801bf..74ede186 100644 --- a/src/services/tokensData.ts +++ b/src/services/tokensData.ts @@ -47,18 +47,42 @@ export const loadTokensData = (): Token[] => { if (tokensData.length === 0) { tokensData = (tokens as TokenDataType).data.flatMap((item) => item.blockchains - .map((blockchain, index) => ({ - id: item.id, - name: item.name, - symbol: item.symbol, - logo: item.logo, - blockchain, - contract: item.contracts[index], - decimals: item.decimals[index], - })) - .filter((token) => allowedBlockchains.includes(token.blockchain)) + .map((blockchain, index) => { + let { name } = item; + let { symbol } = item; + const contract = item.contracts[index]; + + if (name === 'XDAI' && symbol === 'XDAI') { + name = 'Wrapped XDAI'; + symbol = 'WXDAI'; + } + + if ( + name === 'Ethereum' && + symbol === 'ETH' && + contract !== '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' + ) { + name = 'Wrapped Ether'; + symbol = 'WETH'; + } + + return contract !== '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' + ? { + id: item.id, + name, + symbol, + logo: item.logo, + blockchain, + contract, + decimals: item.decimals[index], + } + : null; + }) + .filter( + (token): token is Token => + token !== null && allowedBlockchains.includes(token.blockchain) + ) ); - // Add native/gas tokens CompatibleChains.forEach((chain) => { const nativeAsset = getNativeAssetForChainId(chain.chainId);