Closed code423n4 closed 1 year ago
Closing as invalid.
fractionalTokenAmount
is asserted to be greater than 0
. See https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L71
berndartmueller marked the issue as unsatisfactory: Invalid
Lines of code
https://github.com/code-423n4/2022-12-caviar/blob/main/src/Pair.sol#L63-L99
Vulnerability details
Impact
User didn't get an
lpToken
when trying to add liquidity to the pair with somebaseTokenAmount
. The user lost their asset since they didn't get anylpToken
Proof of Concept
Inside
Pair.sol
contract, theadd()
function exist for adding liquidity to the pair. User can input 3 parametersbaseTokenAmount
,fractionalTokenAmount
andminLpTokenAmount
and then expect to get anlpToken
.In a scenario where the
add()
function is called with some amount ofbaseTokenAmount
but thefractionalTokenAmount
andminLpTokenAmount
is 0, user is still expected to get somelpToken
.Note that, with current implementation, the
fractionalTokenAmount
is not mandatory to have value, also theminLpTokenAmount
, so both can be 0 and the function will not be reverted.Now if the user input
baseTokenAmount
some value, while others are 0, then theadd()
function will not reverted, and unfortunately the user will not be minted anylpToken
because thelpTokenAmount
will be 0.Here, user send their
baseTokenAmount
but didn't get anylpToken
, thus lost of asset.Tools Used
Manual Analysis
Recommended Mitigation Steps
Check if
lpTokenAmount
is 0, if so then revert the transaction.