The collateral calculation in the given code snippet appears to be inconsistent. The order.execute() function returns a value different than 0 only if the parameter passed to it is equal to 3. Calling the function without a check whether the parameter is equal to 3 leads to bigger gas costs without any added value.
Vulnerability Detail
The collateral value is consistently 0 unless the side is 3.
Review and clarify the logic for collateral calculation to ensure consistency and accuracy. Consider revising the code to explicitly handle cases where currentPosition is not 3 to avoid confusion and potential errors.
A check whether currentPosition is equal to 3 may be added:
Informational 07 currentPosition Check
Low/Info issue submitted by 1337web3
Summary
The collateral calculation in the given code snippet appears to be inconsistent. The
order.execute()
function returns a value different than 0 only if the parameter passed to it is equal to 3. Calling the function without a check whether the parameter is equal to 3 leads to bigger gas costs without any added value.Vulnerability Detail
The collateral value is consistently 0 unless the side is 3.
https://github.com/sherlock-audit/2024-05-kwenta-x-perennial-integration-update/blob/main/perennial-v2/packages/perennial-extensions/contracts/MultiInvoker.sol#L392
Impact
The collateral calculation logic may lead to bigger gas costs without any added value.
Code Snippet
Tool used
Manual Review
Recommendation
Review and clarify the logic for collateral calculation to ensure consistency and accuracy. Consider revising the code to explicitly handle cases where
currentPosition
is not 3 to avoid confusion and potential errors. A check whethercurrentPosition
is equal to 3 may be added: