Closed code423n4 closed 3 years ago
WatchPug
https://github.com/code-423n4/2021-09-wildcredit/blob/c48235289a25b2134bb16530185483e8c85507f8/contracts/LendingPair.sol#L660-L684
_convertTokenValues is unnecessary when _fromToken and _toToken are the same, change to amountA and amountB can save gas.
Consider changing to:
uint supplyA = _returnToken == tokenA ? amountA : _convertTokenValues(tokenA, _returnToken, amountA, _priceA, _priceB); uint supplyB = _returnToken == tokenB ? amountB; : _convertTokenValues(tokenB, _returnToken, amountB, _priceB, _priceA);
_fromToken and _toToken can never be the same since Uniswap pairs are not allowed to have duplicate tokens in the same pair.
_fromToken
_toToken
per sponsor comment, invalid
Handle
WatchPug
Vulnerability details
https://github.com/code-423n4/2021-09-wildcredit/blob/c48235289a25b2134bb16530185483e8c85507f8/contracts/LendingPair.sol#L660-L684
_convertTokenValues is unnecessary when _fromToken and _toToken are the same, change to amountA and amountB can save gas.
Recommendation
Consider changing to: