diff --git a/src/pages/Pools/components/DepositForm/DepositForm.tsx b/src/pages/Pools/components/DepositForm/DepositForm.tsx index 0673db1da6..26d0064bbe 100644 --- a/src/pages/Pools/components/DepositForm/DepositForm.tsx +++ b/src/pages/Pools/components/DepositForm/DepositForm.tsx @@ -28,11 +28,6 @@ import { PoolName } from '../PoolName'; import { StyledPlusDivider, StyledTokenInput } from './DepositForm.styles'; import { DepositOutputAssets } from './DepositOutputAssets'; -const isCustomAmountsMode = (form: ReturnType, pool: LiquidityPool) => - // If pool has no liquidity, the assets ratio is set by the user, - // therefore the value inputted is directly used. - (form.dirty && Object.values(form.touched).filter(Boolean).length > 0) || pool.isEmpty; - type DepositFormProps = { pool: LiquidityPool; overlappingModalRef: RefObject; @@ -45,8 +40,6 @@ const DepositForm = ({ pool, overlappingModalRef, onSuccess, onSigning }: Deposi const [slippage, setSlippage] = useState(0.1); - const [isCustomMode, setCustomMode] = useState(false); - const accountId = useAccountId(); const { t } = useTranslation(); const { getAvailableBalance } = useGetBalances(); @@ -64,7 +57,7 @@ const DepositForm = ({ pool, overlappingModalRef, onSuccess, onSigning }: Deposi if (feeCurrencyAmount && transaction.fee.data) { const newFeeCurrencyAmount = transaction.calculateAmountWithFeeDeducted(feeCurrencyAmount); - if (isCustomMode) { + if (pool.isEmpty) { return amounts.map((amount) => transaction.fee.isEqualFeeCurrency(amount.currency) ? newFeeCurrencyAmount : amount ); @@ -75,7 +68,7 @@ const DepositForm = ({ pool, overlappingModalRef, onSuccess, onSigning }: Deposi return amounts; }, - [isCustomMode, pool, transaction] + [pool, transaction] ); const getTransactionArgs = useCallback( @@ -148,11 +141,7 @@ const DepositForm = ({ pool, overlappingModalRef, onSuccess, onSigning }: Deposi }); const handleChange: ChangeEventHandler = async (e) => { - const isCustom = isCustomAmountsMode(form, pool); - - if (isCustom) { - return setCustomMode(true); - } + if (pool.isEmpty) return; if (!e.target.value || isNaN(Number(e.target.value))) { return form.setValues({ ...form.values, ...defaultValues }); diff --git a/src/test/pages/Pools.test.tsx b/src/test/pages/Pools.test.tsx index 9280f99d9e..a7b4808b6f 100644 --- a/src/test/pages/Pools.test.tsx +++ b/src/test/pages/Pools.test.tsx @@ -206,52 +206,6 @@ describe('Pools Page', () => { getClaimableFarmingRewards.mockReturnValue(CLAIMABLE_REWARDS); }); - it('should be able to enter customisable input amounts mode', async () => { - jest - .spyOn(LIQUIDITY_POOLS.ONE, 'getLiquidityDepositInputAmounts') - .mockReturnValue(LIQUIDITY_POOLS.ONE.pooledCurrencies); - - const [DEFAULT_CURRENCY_1, DEFAULT_CURRENCY_2] = LIQUIDITY_POOLS.ONE.pooledCurrencies; - - await render(, { path }); - - const tabPanel = await withinModalTabPanel(TABLES.AVAILABLE_POOLS, LP_TOKEN_A.ticker, TABS.DEPOSIT); - - await userEvent.type( - tabPanel.getByRole('textbox', { - name: new RegExp(`${DEFAULT_CURRENCY_1.currency.ticker} deposit amount`, 'i') - }), - DEFAULT_CURRENCY_1.toString(), - { delay: 1 } - ); - - expect(LIQUIDITY_POOLS.ONE.getLiquidityDepositInputAmounts).toHaveBeenCalledWith(DEFAULT_CURRENCY_1); - - await waitFor(() => { - expect( - tabPanel.getByRole('textbox', { - name: new RegExp(`${DEFAULT_CURRENCY_2.currency.ticker} deposit amount`, 'i') - }) - ).toHaveValue(DEFAULT_CURRENCY_2.toString()); - }); - - await userEvent.type( - tabPanel.getByRole('textbox', { - name: new RegExp(`${DEFAULT_CURRENCY_2.currency.ticker} deposit amount`, 'i') - }), - '10', - { delay: 1 } - ); - - await waitFor(() => { - expect( - tabPanel.getByRole('textbox', { - name: new RegExp(`${DEFAULT_CURRENCY_1.currency.ticker} deposit amount`, 'i') - }) - ).toHaveValue(DEFAULT_CURRENCY_1.toString()); - }); - }); - it('should render illiquid pool and deposit with custom ratio', async () => { jest .spyOn(LIQUIDITY_POOLS.EMPTY, 'getLiquidityDepositInputAmounts')