But recently solidity released a new version with important Bugfixes:
The first one is related to ABI-encoding nested arrays directly from calldata. You can find more information here.
The second bug is triggered in certain inheritance structures and can cause a memory pointer to be interpreted as a calldata pointer or vice-versa. We also have a dedicated blog post about this bug.
Apart from these, there are several minor bug fixes and improvements.
getApproved is deleted when someone transfer a token to himself. By not changing ownership of the token, it is not intended or expected to change approvals.
It's possible to lose the ownership under specific circumstances.
Because an human error it's possible to set a new invalid owner. When you want to change the owner's address it's better to propose a new owner, and then accept this ownership with the new wallet.
Use of abi.encodePacked in PuttyV2 is safe, but unnecessary and not recommended. abi.encodePacked can result in hash collisions when used with two dynamic arguments (string/bytes).
There is also discussion of removing abi.encodePacked from future versions of Solidity (ethereum/solidity#11593), so using abi.encode now will ensure compatibility in the future.
It is possible to use the contract as a money launderer since it will be the contract that sends the money from possibly illicit activities to a third account.
Example:
Alice create an short like this:
order.isLong = false
order.isCall = false
order.duration = 0
order.expiration = type(uint).max
order.maker = Alice
order.baseAsset = WETH
order.premium = Amount to be laundred
order.whitelist.length == 0
order.strike = 0
Bob use the Alice order to call fillOrder with the msg.value = order.premium
Alice will receive from the market all the expected WETH without paying any fee.
6. Use npm packages instead of copy the dependencies
Some contracts use the openzeppelin libraries, as it should be, however these libraries are copied throughout the project instead of use the package manager.
Using the packages from the original developer helps us stay up-to-date when new bugs appear.
The contract PuttyV2Nft is abstract and remove the balanceOf logic in all method except the _burn one.
Although it is not an issue a priori, if the burn logic is changed to not transfer the token to 0xdead address, it could cause unnecessary errors.
Reference:
// send the long position to 0xdead. instead of doing a standard burn by sending to 0x000...000, sending to 0xdead ensures that the same position id cannot be minted again.
It's recommended to override the method _burn like this:
Low
1. Outdated compiler
The pragma version used are:
But recently solidity released a new version with important Bugfixes:
The first one is related to ABI-encoding nested arrays directly from calldata. You can find more information here.
The second bug is triggered in certain inheritance structures and can cause a memory pointer to be interpreted as a calldata pointer or vice-versa. We also have a dedicated blog post about this bug.
Apart from these, there are several minor bug fixes and improvements.
The minimum required version should be 0.8.14
Examples:
2. Undesired approval deletion
getApproved
is deleted when someone transfer a token to himself. By not changing ownership of the token, it is not intended or expected to change approvals.Affected source code:
3. Lack of ACK during owner change
It's possible to lose the ownership under specific circumstances.
Because an human error it's possible to set a new invalid owner. When you want to change the owner's address it's better to propose a new owner, and then accept this ownership with the new wallet.
Affected source code:
4. Use
encode
instead ofencodePacked
for hashigUse of
abi.encodePacked
inPuttyV2
is safe, but unnecessary and not recommended.abi.encodePacked
can result in hash collisions when used with two dynamic arguments (string/bytes).There is also discussion of removing
abi.encodePacked
from future versions of Solidity (ethereum/solidity#11593), so usingabi.encode
now will ensure compatibility in the future.Affected source code:
5. Use of money laundering
It is possible to use the contract as a money launderer since it will be the contract that sends the money from possibly illicit activities to a third account.
Example:
order.isLong
= falseorder.isCall
= falseorder.duration
= 0order.expiration
=type(uint).max
order.maker
= Aliceorder.baseAsset
= WETHorder.premium
= Amount to be laundredorder.whitelist.length
== 0order.strike
= 0fillOrder
with themsg.value = order.premium
Affected source code:
6. Use npm packages instead of copy the dependencies
Some contracts use the openzeppelin libraries, as it should be, however these libraries are copied throughout the project instead of use the package manager.
Using the packages from the original developer helps us stay up-to-date when new bugs appear.
Affected source code:
7. Override all
balanceOf
logicThe contract
PuttyV2Nft
is abstract and remove thebalanceOf
logic in all method except the_burn
one.Although it is not an issue a priori, if the burn logic is changed to not transfer the token to
0xdead
address, it could cause unnecessary errors.Reference:
It's recommended to override the method
_burn
like this:Affected source code: