(args)
| 665 | } |
| 666 | |
| 667 | function decodeSwapsTx(args) { |
| 668 | const { |
| 669 | swapsTransactions, |
| 670 | swapsTokens, |
| 671 | conversionRate, |
| 672 | currentCurrency, |
| 673 | primaryCurrency, |
| 674 | tx: { |
| 675 | id, |
| 676 | txParams, |
| 677 | txParams: { gas, from, to }, |
| 678 | hash, |
| 679 | }, |
| 680 | tx, |
| 681 | contractExchangeRates, |
| 682 | assetSymbol, |
| 683 | } = args; |
| 684 | const swapTransaction = (swapsTransactions && swapsTransactions[id]) || {}; |
| 685 | const totalGas = calculateTotalGas({ |
| 686 | ...txParams, |
| 687 | gas: swapTransaction.gasUsed || gas, |
| 688 | }); |
| 689 | const sourceToken = swapsTokens?.find( |
| 690 | ({ address }) => address === swapTransaction?.sourceToken?.address, |
| 691 | ); |
| 692 | const destinationToken = |
| 693 | swapTransaction?.destinationToken?.swaps || |
| 694 | swapsTokens?.find( |
| 695 | ({ address }) => address === swapTransaction?.destinationToken?.address, |
| 696 | ); |
| 697 | if (!sourceToken || !destinationToken) return [undefined, undefined]; |
| 698 | |
| 699 | const renderFrom = renderFullAddress(from); |
| 700 | const renderTo = renderFullAddress(to); |
| 701 | const ticker = getTicker(args.ticker); |
| 702 | const totalEthGas = renderFromWei(totalGas); |
| 703 | const decimalSourceAmount = |
| 704 | swapTransaction.sourceAmount && |
| 705 | renderFromTokenMinimalUnit( |
| 706 | swapTransaction.sourceAmount, |
| 707 | swapTransaction.sourceToken.decimals, |
| 708 | ); |
| 709 | const decimalDestinationAmount = |
| 710 | swapTransaction.destinationToken.decimals && |
| 711 | renderFromTokenMinimalUnit( |
| 712 | !!swapTransaction?.receivedDestinationAmount && |
| 713 | swapTransaction?.receivedDestinationAmount > 0 |
| 714 | ? swapTransaction.receivedDestinationAmount |
| 715 | : swapTransaction.destinationAmount, |
| 716 | swapTransaction.destinationToken.decimals, |
| 717 | ); |
| 718 | let totalAmountForEthSourceTokenFormatted; |
| 719 | if (sourceToken.symbol === 'ETH') { |
| 720 | const totalAmountForEthSourceToken = |
| 721 | Number(!isNaN(totalEthGas) ? totalEthGas : 0) + |
| 722 | Number(decimalSourceAmount); |
| 723 | totalAmountForEthSourceTokenFormatted = `${limitToMaximumDecimalPlaces( |
| 724 | totalAmountForEthSourceToken, |
no test coverage detected