From 22a231a407c4da015115e17fb7b2f1ca481b9604 Mon Sep 17 00:00:00 2001 From: Debugger022 Date: Fri, 22 Dec 2023 14:36:19 +0530 Subject: [PATCH] fix: N-05 --- contracts/TokenConverter/AbstractTokenConverter.sol | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/contracts/TokenConverter/AbstractTokenConverter.sol b/contracts/TokenConverter/AbstractTokenConverter.sol index ffb57bb9..f84eae77 100644 --- a/contracts/TokenConverter/AbstractTokenConverter.sol +++ b/contracts/TokenConverter/AbstractTokenConverter.sol @@ -604,16 +604,15 @@ abstract contract AbstractTokenConverter is AccessControlledV8, IAbstractTokenCo revert ConversionEnabledOnlyForPrivateConversions(); } - amountConvertedMantissa = amountOutMantissa; - uint256 tokenInToOutConversion; - (amountInMantissa, tokenInToOutConversion) = _getAmountIn(amountOutMantissa, tokenAddressIn, tokenAddressOut); uint256 maxTokenOutReserve = balanceOf(tokenAddressOut); /// If contract has less liquidity for tokenAddressOut than amountOutMantissa if (maxTokenOutReserve < amountOutMantissa) { - amountInMantissa = ((maxTokenOutReserve * EXP_SCALE) + tokenInToOutConversion - 1) / tokenInToOutConversion; //round-up - amountConvertedMantissa = maxTokenOutReserve; + amountOutMantissa = maxTokenOutReserve; } + + amountConvertedMantissa = amountOutMantissa; + (amountInMantissa, ) = _getAmountIn(amountOutMantissa, tokenAddressIn, tokenAddressOut); } /// @notice To get the amount of tokenAddressOut tokens sender could receive on providing amountInMantissa tokens of tokenAddressIn