From 1d64e081876628a9497160c343f0fcf943a0437f Mon Sep 17 00:00:00 2001 From: vkulinich Date: Fri, 15 Nov 2024 10:55:02 +0100 Subject: [PATCH] Fix decimals of min amount when removing liquidity from stablepool --- .../positions/StablepoolPosition.tsx | 2 +- .../removeLiquidity/RemoveLiquidityForm.tsx | 48 ++++++------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/src/sections/pools/stablepool/positions/StablepoolPosition.tsx b/src/sections/pools/stablepool/positions/StablepoolPosition.tsx index 450462998..64cf2fe3c 100644 --- a/src/sections/pools/stablepool/positions/StablepoolPosition.tsx +++ b/src/sections/pools/stablepool/positions/StablepoolPosition.tsx @@ -95,7 +95,7 @@ export const StablepoolPosition = ({ amount }: { amount: BN }) => { {t("value.token", { value: amount, fixedPointScale: STABLEPOOL_TOKEN_DECIMALS, - numberSuffix: `${t( + numberSuffix: ` ${t( "liquidity.stablepool.position.token", )}`, })} diff --git a/src/sections/pools/stablepool/removeLiquidity/RemoveLiquidityForm.tsx b/src/sections/pools/stablepool/removeLiquidity/RemoveLiquidityForm.tsx index 7d3c3bf2c..6e4dd9307 100644 --- a/src/sections/pools/stablepool/removeLiquidity/RemoveLiquidityForm.tsx +++ b/src/sections/pools/stablepool/removeLiquidity/RemoveLiquidityForm.tsx @@ -4,7 +4,7 @@ import { Spacer } from "components/Spacer/Spacer" import { Text } from "components/Typography/Text/Text" import { useMemo } from "react" import { Controller, useForm } from "react-hook-form" -import { Trans, useTranslation } from "react-i18next" +import { useTranslation } from "react-i18next" import { useStore } from "state/store" import { getFloatingPointAmount, normalizeBigNumber } from "utils/balance" import { @@ -20,6 +20,8 @@ import { STradingPairContainer } from "sections/pools/modals/RemoveLiquidity/Rem import { RemoveLiquidityInput } from "sections/pools/modals/RemoveLiquidity/components/RemoveLiquidityInput" import { useRpcProvider } from "providers/rpcProvider" import { useAssets } from "providers/assets" +import { scale } from "utils/balance" +import { createToastMessages } from "state/toasts" type RemoveLiquidityProps = { assetId: string @@ -86,7 +88,7 @@ export const RemoveStablepoolLiquidityForm = ({ position.poolId, assetId, removeSharesValue.dp(0).toString(), - minAmountOut.dp(0).toString(), + scale(minAmountOut, asset.decimals).dp(0).toString(), ), }, { @@ -97,38 +99,16 @@ export const RemoveStablepoolLiquidityForm = ({ onClose() form.reset() }, - toast: { - onLoading: ( - - - - - ), - onSuccess: ( - - - - - ), - }, + toast: createToastMessages("liquidity.stablepool.remove", { + t, + tOptions: { + out: liquidityOut, + amount: removeSharesValue, + fixedPointScale: STABLEPOOL_TOKEN_DECIMALS, + symbol: asset?.symbol, + }, + components: ["span", "span.highlight"], + }), }, ) }