NFTTokenURIScaffold.sol#L166
Standard ERC721 tokenURI call will fail for CollateralizedDebt pools whose underlying pair.asset() or pair.collateral() have decimals lower than 4 whenever the corresponding due quantity is lower than 1e9.
Pairs asset and collateral ERC20 can be arbitrary and some ERC20 contracts have decimals lower than 4, so such a combination is possible. In such cases current tokenURI implementation fails, which can be the issue for all integrations down the line as various systems routinely make tokenURI calls.
Placing severity to be medium per Assets not at direct risk, but the function of the protocol or its availability could be impacted, which is the case here as protocol availability is in question when EIP level functionality fails.
https://eips.ethereum.org/EIPS/eip-721
https://github.com/d-xo/weird-erc20#low-decimals
NFTTokenURIScaffold.weiToPrecisionString will fail if used for a token with decimals lower than 4 as subtraction is performed without prior checks:
NFTTokenURIScaffold.sol#L166
NFTTokenURIScaffold.weiToPrecisionString is called by NFTTokenURIScaffold.tokenURI for pairs asset and collateral ERC20:
NFTTokenURIScaffold.sol#L16-L39
NFTTokenURIScaffold.tokenURI is used in CollateralizedDebt.tokenURI:
CollateralizedDebt.sol#L46
Pairs asset and collateral tokens can be arbitrary, while tokenURI is routinely requested by a variety of external systems
Consider adding the check and special care for low decimals case, for example add another naming rule similarly to how significantDigits > 1e9 case is being handled
amateur-dev (Timeswap) confirmed
vhawk19 (Timeswap) commented:
Mathepreneur (Timeswap) resolved
0xleastwood (judge) commented:
amateur-dev (Timeswap) commented:
0xleastwood (judge) commented:
For this contest, 12 reports were submitted by wardens detailing gas optimizations. The report highlighted below by Dravee received the top score from the judge.
The following wardens also submitted reports: IllIllI, CertoraInc, 0x1f8b, Tomio, WatchPug, gzeon, TerrierLover, robee, rfa, 0v3rf10w, kenta.
