This PR is coauthored by @mikheevm / mikhail.mikheev@gnosis.pm from Gnosis and myself stewart@prysm.xyz from prysm.xyz.
Currently some smart contract wallets cannot sell on Wyvern in exchange for a native token because wyvern uses .transfer() which forwards a fixed amount of gas to the address. If the address is a smart contract, and if the receiver function uses more than 2300 gas, then the entire transaction will fail due to out of gas. In the case of Gnosis Safe, the receive() function emits an event when it receives a native token which causes the the transfer() call to run out of gas.
The fix is to switch out the transfer() call with .call{value:..}. This opens the function to reentry attack, however atomicMatch() already has the reentrancyGuard modifier to prevent this.
I also added a test which verifies a smart contract can receive ether as the taker of an atomicMatch call despite using more than the 2300 fixed gas allotment given by transfer.
This PR is coauthored by @mikheevm / mikhail.mikheev@gnosis.pm from Gnosis and myself stewart@prysm.xyz from prysm.xyz.
Currently some smart contract wallets cannot sell on Wyvern in exchange for a native token because wyvern uses
.transfer()
which forwards a fixed amount of gas to the address. If the address is a smart contract, and if the receiver function uses more than2300
gas, then the entire transaction will fail due to out of gas. In the case of Gnosis Safe, thereceive()
function emits an event when it receives a native token which causes the the transfer() call to run out of gas.Example transaction: https://rinkeby.etherscan.io/tx/0xb03546168d6422c52000d41b5f791581f9dea6513ef4b42a84e5f9a8fe8256ce#internal
More info on this topic: https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/
The fix is to switch out the
transfer()
call with.call{value:..}
. This opens the function to reentry attack, howeveratomicMatch()
already has thereentrancyGuard
modifier to prevent this.I also added a test which verifies a smart contract can receive ether as the taker of an atomicMatch call despite using more than the 2300 fixed gas allotment given by transfer.