diff --git a/src/pages/ThorChainLP/components/RemoveLiquidity/RemoveLiquidityInput.tsx b/src/pages/ThorChainLP/components/RemoveLiquidity/RemoveLiquidityInput.tsx index e22c1232665..95302aa7966 100644 --- a/src/pages/ThorChainLP/components/RemoveLiquidity/RemoveLiquidityInput.tsx +++ b/src/pages/ThorChainLP/components/RemoveLiquidity/RemoveLiquidityInput.tsx @@ -449,9 +449,30 @@ export const RemoveLiquidityInput: React.FC = ({ [estimatedPoolAssetFeesData?.txFeeCryptoBaseUnit, poolAssetFeeAsset?.precision], ) + const poolAssetFeeAssetDustAmountCryptoPrecision = useMemo(() => { + if (!poolAssetFeeAsset) return 0 + + return fromBaseUnit(poolAssetFeeAssetDustAmountCryptoBaseUnit, poolAssetFeeAsset?.precision) + }, [poolAssetFeeAssetDustAmountCryptoBaseUnit, poolAssetFeeAsset]) + + const poolAssetFeeAssetDustAmountFiatUserCurrency = useMemo(() => { + return bnOrZero(poolAssetFeeAssetDustAmountCryptoPrecision).times( + poolAssetFeeAssetMarketData.price, + ) + }, [poolAssetFeeAssetMarketData.price, poolAssetFeeAssetDustAmountCryptoPrecision]) + + // We also include the dust amount in the gas fee as it's deducted in the input validation + // This will result in displaying gas fees and dust amounts as a single value in the UI const poolAssetGasFeeFiatUserCurrency = useMemo( - () => bnOrZero(poolAssetTxFeeCryptoPrecision).times(poolAssetFeeAssetMarketData.price), - [poolAssetFeeAssetMarketData.price, poolAssetTxFeeCryptoPrecision], + () => + bnOrZero(poolAssetTxFeeCryptoPrecision) + .times(poolAssetFeeAssetMarketData.price) + .plus(poolAssetFeeAssetDustAmountFiatUserCurrency), + [ + poolAssetFeeAssetMarketData.price, + poolAssetTxFeeCryptoPrecision, + poolAssetFeeAssetDustAmountFiatUserCurrency, + ], ) const runeProtocolFeeCryptoPrecision = useMemo(() => { @@ -842,11 +863,6 @@ export const RemoveLiquidityInput: React.FC = ({ poolAssetFeeAsset?.precision, ) - const poolAssetFeeAssetDustAmountCryptoPrecision = fromBaseUnit( - poolAssetFeeAssetDustAmountCryptoBaseUnit, - poolAssetFeeAsset?.precision, - ) - return bnOrZero(poolAssetTxFeeCryptoPrecision) .plus(poolAssetFeeAssetDustAmountCryptoPrecision) .lte(poolAssetFeeAssetBalanceCryptoPrecision) @@ -855,8 +871,8 @@ export const RemoveLiquidityInput: React.FC = ({ withdrawType, poolAssetFeeAsset, poolAssetFeeAssetBalanceCryptoBaseUnit, - poolAssetFeeAssetDustAmountCryptoBaseUnit, poolAssetTxFeeCryptoPrecision, + poolAssetFeeAssetDustAmountCryptoPrecision, ]) const hasEnoughRuneBalanceForTx = useMemo(() => {