There is an incorrect use of variable in the arithmetic calculation pertaining to assigning protocolFeeAmount in changeFeeQuote(). Although it does not currently affect the protocol, it will when the Factory owner decides to start collecting protocol fees.
Proof of Concept
feeAmount is first correctly computed after adjusting changeFee to the correct exponent. However, instead of using inputAmount, the function logic uses the diminished feeAmount to multiply with Factory(factory).protocolFeeRate(). This will make protocolFeeAmount very much smaller than expected possibly as good as nothing, defeating the purpose of introducing it to the system.
Lines of code
https://github.com/code-423n4/2023-04-caviar/blob/main/src/PrivatePool.sol#L737
Vulnerability details
Impact
There is an incorrect use of variable in the arithmetic calculation pertaining to assigning
protocolFeeAmount
inchangeFeeQuote()
. Although it does not currently affect the protocol, it will when the Factory owner decides to start collecting protocol fees.Proof of Concept
feeAmount
is first correctly computed after adjustingchangeFee
to the correct exponent. However, instead of usinginputAmount
, the function logic uses the diminishedfeeAmount
to multiply withFactory(factory).protocolFeeRate()
. This will makeprotocolFeeAmount
very much smaller than expected possibly as good as nothing, defeating the purpose of introducing it to the system.PrivatePool.sol#L731-L738
Recommended Mitigation Steps
It is recommended replacing
feeAmount
withinputAmount
like it has been done so when calculating forfeeAmount
.