Uniswap / v1-contracts

🐍Uniswap V1 smart contracts
GNU General Public License v3.0
496 stars 318 forks source link

Add Reentrancy Guard #22

Open haydenadams opened 5 years ago

haydenadams commented 5 years ago

Uniswap is safe from re-entrancy for tokens that don't allow arbitrary callbacks in transfer functions. However, for tokens that do allow arbitrary callbacks (such as ERC777), a re-entrancy guard could make the contract more secure.

Implementation: https://github.com/protofire/zeppelin-solidity/blob/master/contracts/ReentrancyGuard.sol

This would add ~5000-1000 gas until https://eips.ethereum.org/EIPS/eip-1283 is merged

BlinkyStitt commented 5 years ago

https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/utils/ReentrancyGuard.sol looks like it has had a few updates.

I haven't been able to find a similar library written in vyper though.

haydenadams commented 5 years ago

Can now add the decorator

@nonreentrant(key)

https://github.com/ethereum/vyper/pull/1264