Skip to content
Request an audit

‹ All findings

mul() and div() in NFTPMath are misleading due to scaling by 1e18 underneath

Low/InfoNftperp Exchange·Three Sigma · NFT perpetuals · 2nd January, 20243S-NFTPerp-N09

Description

Usually mul() and div() do multiplication and division, respectively, without scaling by 1e18 (commonly used by SafeMath). However, NFTPMath mul() and div() scale the operations by 1e18, misleading code readers.

For example, when looking at ClearingHouse:openPosition(), it seems that it would round down to 0 in _assertMaxLeverage(), but this is not the case as it correctly scales the numbers.

Recommendation

Consider renaming the functions to fullMulWad() and fullDivWad().

Status

Acknowledged