mahmud - Less Amount of Wrapped token is sent to the `JalaRouter02` than should be when calling `swapExactTokensForETH` in the `JalaMasterRouter`. #224
Less Amount of Wrapped token is sent to the JalaRouter02 than should be when calling swapExactTokensForETH in the JalaMasterRouter.
Summary
In the swapExactTokensForETH function in the JalaMasterRouter contract, the amount of token sent into the JalaRouter02 contract is less than it should be.
Vulnerability Detail
In the swapExactTokensForETH function in the JalaMasterRouter contract, the input token(underlying) is first wrapped and then the wrapped token is then sent to the JalaRouter02 contract for the swap. The underlying token's decimal is usually less than the wrapped token's decimal(18) and therefore the input amount(in underlying token) is supposed to be multiplied by the decimalOffset to match the decimal of the wrapped token before being sent to the JalaRouter02 contract for the swap. However, the input amount (amountIn) is sent directly to the JalaRouter02 contract without being multiplied by the decimalOffset effectly reducing the amount of wrapped token sent to the JalaRouter02 contract.
Impact
Lesser wrapped tokens are sent to the JalaRouter02 contract than should be.
mahmud
high
Less Amount of Wrapped token is sent to the
JalaRouter02
than should be when callingswapExactTokensForETH
in theJalaMasterRouter
.Summary
In the
swapExactTokensForETH
function in theJalaMasterRouter
contract, the amount of token sent into theJalaRouter02
contract is less than it should be.Vulnerability Detail
In the
swapExactTokensForETH
function in theJalaMasterRouter
contract, the input token(underlying) is first wrapped and then the wrapped token is then sent to theJalaRouter02
contract for the swap. The underlying token's decimal is usually less than the wrapped token's decimal(18) and therefore the input amount(in underlying token) is supposed to be multiplied by thedecimalOffset
to match the decimal of the wrapped token before being sent to theJalaRouter02
contract for the swap. However, the input amount (amountIn
) is sent directly to theJalaRouter02
contract without being multiplied by thedecimalOffset
effectly reducing the amount of wrapped token sent to theJalaRouter02
contract.Impact
Lesser wrapped tokens are sent to the
JalaRouter02
contract than should be.Code Snippet
https://github.com/sherlock-audit/2024-02-jala-swap/blob/030d3ed54214754301154bce0e58ea534100a7e3/jalaswap-dex-contract/contracts/JalaMasterRouter.sol#L300
Tool used
Manual Review
Recommendation
Get the tokenOffset and multiply it with the amountIn before sending to the
JalaRouter02
contract.Duplicate of #146