From 9371767b1fc47e2918a20a73a73c0be0aa526804 Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Thu, 9 Jan 2025 11:51:03 +0000 Subject: [PATCH] fix: remove hack - seems to be better without it? --- .../src/common/hooks/useConvertUsdToTokenValue.ts | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts b/apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts index aa5d4c7cc6..db21e8a158 100644 --- a/apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts +++ b/apps/cowswap-frontend/src/common/hooks/useConvertUsdToTokenValue.ts @@ -1,7 +1,7 @@ -import { TokenWithLogo, USDC } from '@cowprotocol/common-const' +import { USDC } from '@cowprotocol/common-const' import { getWrappedToken, tryParseCurrencyAmount } from '@cowprotocol/common-utils' import { SupportedChainId } from '@cowprotocol/cow-sdk' -import { Currency, CurrencyAmount } from '@uniswap/sdk-core' +import { Currency } from '@uniswap/sdk-core' import { useUsdPrice } from 'modules/usdAmount' @@ -15,7 +15,7 @@ export function useConvertUsdToTokenValue( const usdcToken = USDC[currencyUsdcPrice.currency.chainId as SupportedChainId] const usdAmount = tryParseCurrencyAmount(typedValue, usdcToken) - const tokenAmount = currencyUsdcPrice.price.invert().quote(hackyAdjustAmountDust(usdAmount)) + const tokenAmount = currencyUsdcPrice.price.invert().quote(usdAmount) return tokenAmount.toExact() } @@ -23,11 +23,3 @@ export function useConvertUsdToTokenValue( return typedValue } } - -/** - * TODO: this is a hacky way to adjust the amount to avoid dust - * For some reason, when you enter for example $366, price.quote() returns 365,9999999999 - */ -function hackyAdjustAmountDust(amount: CurrencyAmount): typeof amount { - return amount.add(tryParseCurrencyAmount('0.000001', amount.currency)) -}