sherlock-audit / 2023-12-arcadia-judging

19 stars 15 forks source link

anya - Redundant Type Casting in calcUnrealisedDebt Function #198

Closed sherlock-admin closed 9 months ago

sherlock-admin commented 9 months ago

anya

medium

Redundant Type Casting in calcUnrealisedDebt Function

Summary

The calcUnrealisedDebt function performs calculations using uint256 variables but declares its return type as uint128. While it casts the final result to uint128 using SafeCastLib.safeCastTo128, this conversion is unnecessary due to the function's declared return type. This redundancy creates an extra step and might potentially cause confusion.

Vulnerability Detail

Impact

Code Snippet

https://github.com/sherlock-audit/2023-12-arcadia/blob/main/lending-v2/src/LendingPool.sol#L718-L736

Tool used

Manual Review

Recommendation

sherlock-admin2 commented 9 months ago

1 comment(s) were left on this issue during the judging contest.

takarez commented:

invalid

nevillehuang commented 9 months ago

Invalid, design decision to cap to unrealisedDebt to uint128 so no issue here, safe cast is there as a safety check.