fix: remove stablecoin usd val fetch in logging to reduce infura spend (#4543)

remove stablecoin usd val fetch reduce infura
This commit is contained in:
lynn 2022-08-30 15:15:49 -04:00 committed by GitHub
parent fac3845756
commit b82b9acc54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 29 deletions

@ -10,7 +10,6 @@ import {
getDurationUntilTimestampSeconds,
getTokenAddress,
} from 'components/AmplitudeAnalytics/utils'
import { useStablecoinValue } from 'hooks/useStablecoinPrice'
import useTransactionDeadline from 'hooks/useTransactionDeadline'
import { ReactNode } from 'react'
import { Text } from 'rebass'
@ -30,8 +29,6 @@ interface AnalyticsEventProps {
transactionDeadlineSecondsSinceEpoch: number | undefined
isAutoSlippage: boolean
isAutoRouterApi: boolean
tokenInAmountUsd: string | undefined
tokenOutAmountUsd: string | undefined
swapQuoteReceivedDate: Date | undefined
routes: RoutingDiagramEntry[]
}
@ -70,16 +67,12 @@ const formatAnalyticsEventProperties = ({
transactionDeadlineSecondsSinceEpoch,
isAutoSlippage,
isAutoRouterApi,
tokenInAmountUsd,
tokenOutAmountUsd,
swapQuoteReceivedDate,
routes,
}: AnalyticsEventProps) => ({
estimated_network_fee_usd: trade.gasUseEstimateUSD ? formatToDecimal(trade.gasUseEstimateUSD, 2) : undefined,
transaction_hash: hash,
transaction_deadline_seconds: getDurationUntilTimestampSeconds(transactionDeadlineSecondsSinceEpoch),
token_in_amount_usd: tokenInAmountUsd ? parseFloat(tokenInAmountUsd) : undefined,
token_out_amount_usd: tokenOutAmountUsd ? parseFloat(tokenOutAmountUsd) : undefined,
token_in_address: getTokenAddress(trade.inputAmount.currency),
token_out_address: getTokenAddress(trade.outputAmount.currency),
token_in_symbol: trade.inputAmount.currency.symbol,
@ -121,8 +114,6 @@ export default function SwapModalFooter({
const transactionDeadlineSecondsSinceEpoch = useTransactionDeadline()?.toNumber() // in seconds since epoch
const isAutoSlippage = useUserSlippageTolerance()[0] === 'auto'
const [clientSideRouter] = useClientSideRouter()
const tokenInAmountUsd = useStablecoinValue(trade.inputAmount)?.toFixed(2)
const tokenOutAmountUsd = useStablecoinValue(trade.outputAmount)?.toFixed(2)
const routes = getTokenPath(trade)
return (
@ -139,8 +130,6 @@ export default function SwapModalFooter({
transactionDeadlineSecondsSinceEpoch,
isAutoSlippage,
isAutoRouterApi: !clientSideRouter,
tokenInAmountUsd,
tokenOutAmountUsd,
swapQuoteReceivedDate,
routes,
})}

@ -4,7 +4,6 @@ import { sendAnalyticsEvent } from 'components/AmplitudeAnalytics'
import { EventName } from 'components/AmplitudeAnalytics/constants'
import { formatPercentInBasisPointsNumber, formatToDecimal, getTokenAddress } from 'components/AmplitudeAnalytics/utils'
import { DEFAULT_TXN_DISMISS_MS, L2_TXN_DISMISS_MS } from 'constants/misc'
import { useStablecoinValue } from 'hooks/useStablecoinPrice'
import LibUpdater from 'lib/hooks/transactions/updater'
import { useCallback, useMemo } from 'react'
import { useAppDispatch, useAppSelector } from 'state/hooks'
@ -22,23 +21,12 @@ interface AnalyticsEventProps {
trade: InterfaceTrade<Currency, Currency, TradeType>
hash: string | undefined
allowedSlippage: Percent
tokenInAmountUsd: string | undefined
tokenOutAmountUsd: string | undefined
succeeded: boolean
}
const formatAnalyticsEventProperties = ({
trade,
hash,
allowedSlippage,
tokenInAmountUsd,
tokenOutAmountUsd,
succeeded,
}: AnalyticsEventProps) => ({
const formatAnalyticsEventProperties = ({ trade, hash, allowedSlippage, succeeded }: AnalyticsEventProps) => ({
estimated_network_fee_usd: trade.gasUseEstimateUSD ? formatToDecimal(trade.gasUseEstimateUSD, 2) : undefined,
transaction_hash: hash,
token_in_amount_usd: tokenInAmountUsd ? parseFloat(tokenInAmountUsd) : undefined,
token_out_amount_usd: tokenOutAmountUsd ? parseFloat(tokenOutAmountUsd) : undefined,
token_in_address: getTokenAddress(trade.inputAmount.currency),
token_out_address: getTokenAddress(trade.outputAmount.currency),
token_in_symbol: trade.inputAmount.currency.symbol,
@ -65,8 +53,6 @@ export default function Updater() {
trade: { trade },
allowedSlippage,
} = useDerivedSwapInfo()
const tokenInAmountUsd = useStablecoinValue(trade?.inputAmount)?.toFixed(2)
const tokenOutAmountUsd = useStablecoinValue(trade?.outputAmount)?.toFixed(2)
const dispatch = useAppDispatch()
const onCheck = useCallback(
@ -101,8 +87,6 @@ export default function Updater() {
trade,
hash,
allowedSlippage,
tokenInAmountUsd,
tokenOutAmountUsd,
succeeded: receipt.status === 1,
})
)
@ -115,7 +99,7 @@ export default function Updater() {
isL2 ? L2_TXN_DISMISS_MS : DEFAULT_TXN_DISMISS_MS
)
},
[addPopup, allowedSlippage, dispatch, isL2, tokenInAmountUsd, tokenOutAmountUsd, trade, transactions]
[addPopup, allowedSlippage, dispatch, isL2, trade, transactions]
)
const pendingTransactions = useMemo(() => (chainId ? transactions[chainId] ?? {} : {}), [chainId, transactions])