Some storage locations that are enumerated by variables such as user address (tradingAccountId) or marketId do not follow ERC7201 standards. For example, while Position::POSITION_LOCATION is defined correctly according to ERC7201, when using the Position::load function, the slot location derived using variables like tradingAccountId and marketId loses ERC7201 compatibility.
Performing an AND NOT operation with ~bytes32(uint256(0xff)) ensures that the storage slot's rightmost byte is 00. This prepares for a future upgrade when Ethereum switches its storage data structure to Verkle Trees, allowing 256 adjacent slots to be warmed at once. However, the current version ignores this, and slots created this way do not end with 00 as the rightmost byte.
For example, if marketId = 1 and tradingAccountId = 1324, the slot would be:
It is clearly visible that the slot's rightmost byte is not 00 using this formula, thus it is not ERC7201 compatible.
Manual Review
To fix this, the ERC7201 suggested formula can be used to ensure ERC7201 compatibility:
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.