Skip to content

Commit

Permalink
Merge pull request #52 from VenusProtocol/fix/oz-audit-private-conver…
Browse files Browse the repository at this point in the history
…sion

OZ audit fix for Private Conversion
  • Loading branch information
Debugger022 authored Jan 10, 2024
2 parents 781890c + 22a231a commit 343dd16
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions contracts/TokenConverter/AbstractTokenConverter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 343dd16

Please sign in to comment.