fix: add back usd volume to swap submitted from ui instead of infura hook (#4563)
* init * typo
This commit is contained in:
parent
6fe5d4363d
commit
4d4462368b
@ -1,6 +1,6 @@
|
|||||||
import { Trans } from '@lingui/macro'
|
import { Trans } from '@lingui/macro'
|
||||||
import { Trade } from '@uniswap/router-sdk'
|
import { Trade } from '@uniswap/router-sdk'
|
||||||
import { Currency, Percent, TradeType } from '@uniswap/sdk-core'
|
import { Currency, CurrencyAmount, Percent, Token, TradeType } from '@uniswap/sdk-core'
|
||||||
import { ModalName } from 'components/AmplitudeAnalytics/constants'
|
import { ModalName } from 'components/AmplitudeAnalytics/constants'
|
||||||
import { Trace } from 'components/AmplitudeAnalytics/Trace'
|
import { Trace } from 'components/AmplitudeAnalytics/Trace'
|
||||||
import { ReactNode, useCallback, useMemo, useState } from 'react'
|
import { ReactNode, useCallback, useMemo, useState } from 'react'
|
||||||
@ -27,6 +27,8 @@ export default function ConfirmSwapModal({
|
|||||||
attemptingTxn,
|
attemptingTxn,
|
||||||
txHash,
|
txHash,
|
||||||
swapQuoteReceivedDate,
|
swapQuoteReceivedDate,
|
||||||
|
fiatValueInput,
|
||||||
|
fiatValueOutput,
|
||||||
}: {
|
}: {
|
||||||
isOpen: boolean
|
isOpen: boolean
|
||||||
trade: InterfaceTrade<Currency, Currency, TradeType> | undefined
|
trade: InterfaceTrade<Currency, Currency, TradeType> | undefined
|
||||||
@ -40,6 +42,8 @@ export default function ConfirmSwapModal({
|
|||||||
swapErrorMessage: ReactNode | undefined
|
swapErrorMessage: ReactNode | undefined
|
||||||
onDismiss: () => void
|
onDismiss: () => void
|
||||||
swapQuoteReceivedDate: Date | undefined
|
swapQuoteReceivedDate: Date | undefined
|
||||||
|
fiatValueInput?: CurrencyAmount<Token> | null
|
||||||
|
fiatValueOutput?: CurrencyAmount<Token> | null
|
||||||
}) {
|
}) {
|
||||||
// shouldLogModalCloseEvent lets the child SwapModalHeader component know when modal has been closed
|
// shouldLogModalCloseEvent lets the child SwapModalHeader component know when modal has been closed
|
||||||
// and an event triggered by modal closing should be logged.
|
// and an event triggered by modal closing should be logged.
|
||||||
@ -78,9 +82,21 @@ export default function ConfirmSwapModal({
|
|||||||
disabledConfirm={showAcceptChanges}
|
disabledConfirm={showAcceptChanges}
|
||||||
swapErrorMessage={swapErrorMessage}
|
swapErrorMessage={swapErrorMessage}
|
||||||
swapQuoteReceivedDate={swapQuoteReceivedDate}
|
swapQuoteReceivedDate={swapQuoteReceivedDate}
|
||||||
|
fiatValueInput={fiatValueInput}
|
||||||
|
fiatValueOutput={fiatValueOutput}
|
||||||
/>
|
/>
|
||||||
) : null
|
) : null
|
||||||
}, [onConfirm, showAcceptChanges, swapErrorMessage, trade, allowedSlippage, txHash, swapQuoteReceivedDate])
|
}, [
|
||||||
|
onConfirm,
|
||||||
|
showAcceptChanges,
|
||||||
|
swapErrorMessage,
|
||||||
|
trade,
|
||||||
|
allowedSlippage,
|
||||||
|
txHash,
|
||||||
|
swapQuoteReceivedDate,
|
||||||
|
fiatValueInput,
|
||||||
|
fiatValueOutput,
|
||||||
|
])
|
||||||
|
|
||||||
// text to show while loading
|
// text to show while loading
|
||||||
const pendingText = (
|
const pendingText = (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Trans } from '@lingui/macro'
|
import { Trans } from '@lingui/macro'
|
||||||
import { Currency, Percent, TradeType } from '@uniswap/sdk-core'
|
import { Currency, CurrencyAmount, Percent, Token, TradeType } from '@uniswap/sdk-core'
|
||||||
import { ElementName, Event, EventName } from 'components/AmplitudeAnalytics/constants'
|
import { ElementName, Event, EventName } from 'components/AmplitudeAnalytics/constants'
|
||||||
import { TraceEvent } from 'components/AmplitudeAnalytics/TraceEvent'
|
import { TraceEvent } from 'components/AmplitudeAnalytics/TraceEvent'
|
||||||
import {
|
import {
|
||||||
@ -31,6 +31,8 @@ interface AnalyticsEventProps {
|
|||||||
isAutoRouterApi: boolean
|
isAutoRouterApi: boolean
|
||||||
swapQuoteReceivedDate: Date | undefined
|
swapQuoteReceivedDate: Date | undefined
|
||||||
routes: RoutingDiagramEntry[]
|
routes: RoutingDiagramEntry[]
|
||||||
|
fiatValueInput?: CurrencyAmount<Token> | null
|
||||||
|
fiatValueOutput?: CurrencyAmount<Token> | null
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatRoutesEventProperties = (routes: RoutingDiagramEntry[]) => {
|
const formatRoutesEventProperties = (routes: RoutingDiagramEntry[]) => {
|
||||||
@ -69,6 +71,8 @@ const formatAnalyticsEventProperties = ({
|
|||||||
isAutoRouterApi,
|
isAutoRouterApi,
|
||||||
swapQuoteReceivedDate,
|
swapQuoteReceivedDate,
|
||||||
routes,
|
routes,
|
||||||
|
fiatValueInput,
|
||||||
|
fiatValueOutput,
|
||||||
}: AnalyticsEventProps) => ({
|
}: AnalyticsEventProps) => ({
|
||||||
estimated_network_fee_usd: trade.gasUseEstimateUSD ? formatToDecimal(trade.gasUseEstimateUSD, 2) : undefined,
|
estimated_network_fee_usd: trade.gasUseEstimateUSD ? formatToDecimal(trade.gasUseEstimateUSD, 2) : undefined,
|
||||||
transaction_hash: hash,
|
transaction_hash: hash,
|
||||||
@ -79,6 +83,8 @@ const formatAnalyticsEventProperties = ({
|
|||||||
token_out_symbol: trade.outputAmount.currency.symbol,
|
token_out_symbol: trade.outputAmount.currency.symbol,
|
||||||
token_in_amount: formatToDecimal(trade.inputAmount, trade.inputAmount.currency.decimals),
|
token_in_amount: formatToDecimal(trade.inputAmount, trade.inputAmount.currency.decimals),
|
||||||
token_out_amount: formatToDecimal(trade.outputAmount, trade.outputAmount.currency.decimals),
|
token_out_amount: formatToDecimal(trade.outputAmount, trade.outputAmount.currency.decimals),
|
||||||
|
token_in_amount_usd: fiatValueInput ? parseFloat(fiatValueInput.toFixed(2)) : undefined,
|
||||||
|
token_out_amount_usd: fiatValueOutput ? parseFloat(fiatValueOutput.toFixed(2)) : undefined,
|
||||||
price_impact_basis_points: formatPercentInBasisPointsNumber(computeRealizedPriceImpact(trade)),
|
price_impact_basis_points: formatPercentInBasisPointsNumber(computeRealizedPriceImpact(trade)),
|
||||||
allowed_slippage_basis_points: formatPercentInBasisPointsNumber(allowedSlippage),
|
allowed_slippage_basis_points: formatPercentInBasisPointsNumber(allowedSlippage),
|
||||||
is_auto_router_api: isAutoRouterApi,
|
is_auto_router_api: isAutoRouterApi,
|
||||||
@ -102,6 +108,8 @@ export default function SwapModalFooter({
|
|||||||
swapErrorMessage,
|
swapErrorMessage,
|
||||||
disabledConfirm,
|
disabledConfirm,
|
||||||
swapQuoteReceivedDate,
|
swapQuoteReceivedDate,
|
||||||
|
fiatValueInput,
|
||||||
|
fiatValueOutput,
|
||||||
}: {
|
}: {
|
||||||
trade: InterfaceTrade<Currency, Currency, TradeType>
|
trade: InterfaceTrade<Currency, Currency, TradeType>
|
||||||
hash: string | undefined
|
hash: string | undefined
|
||||||
@ -110,6 +118,8 @@ export default function SwapModalFooter({
|
|||||||
swapErrorMessage: ReactNode | undefined
|
swapErrorMessage: ReactNode | undefined
|
||||||
disabledConfirm: boolean
|
disabledConfirm: boolean
|
||||||
swapQuoteReceivedDate: Date | undefined
|
swapQuoteReceivedDate: Date | undefined
|
||||||
|
fiatValueInput?: CurrencyAmount<Token> | null
|
||||||
|
fiatValueOutput?: CurrencyAmount<Token> | null
|
||||||
}) {
|
}) {
|
||||||
const transactionDeadlineSecondsSinceEpoch = useTransactionDeadline()?.toNumber() // in seconds since epoch
|
const transactionDeadlineSecondsSinceEpoch = useTransactionDeadline()?.toNumber() // in seconds since epoch
|
||||||
const isAutoSlippage = useUserSlippageTolerance()[0] === 'auto'
|
const isAutoSlippage = useUserSlippageTolerance()[0] === 'auto'
|
||||||
@ -132,6 +142,8 @@ export default function SwapModalFooter({
|
|||||||
isAutoRouterApi: !clientSideRouter,
|
isAutoRouterApi: !clientSideRouter,
|
||||||
swapQuoteReceivedDate,
|
swapQuoteReceivedDate,
|
||||||
routes,
|
routes,
|
||||||
|
fiatValueInput,
|
||||||
|
fiatValueOutput,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<ButtonError
|
<ButtonError
|
||||||
|
@ -542,6 +542,8 @@ export default function Swap() {
|
|||||||
swapErrorMessage={swapErrorMessage}
|
swapErrorMessage={swapErrorMessage}
|
||||||
onDismiss={handleConfirmDismiss}
|
onDismiss={handleConfirmDismiss}
|
||||||
swapQuoteReceivedDate={swapQuoteReceivedDate}
|
swapQuoteReceivedDate={swapQuoteReceivedDate}
|
||||||
|
fiatValueInput={fiatValueInput}
|
||||||
|
fiatValueOutput={fiatValueOutput}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AutoColumn gap={'0px'}>
|
<AutoColumn gap={'0px'}>
|
||||||
|
Loading…
Reference in New Issue
Block a user