-
Notifications
You must be signed in to change notification settings - Fork 12.1k
Description
🧐 Motivation
There is an opinion that ERC777 is over-engineered and is a bad practice to follow. Moreover it introduces bad abstractions to rely on and requires very important checks to be implemented by every integrator.
Let's switch to EIP2612 (Permit) to deprecate dangerous infinite approve behavior and make it mainstream ASAP: https://github.com/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC20/extensions/draft-ERC20Permit.sol
📝 Details
Do we need to collect list of issues? Starting here:
-
Whole idea of avoiding spam tokens by having hook function is wrong. It is not possible to protect from spam tokens because developers of these tokens will always modify their tokens to allow spamming – just ignore them.
-
Token fallback concept is wrong because the callback is being called from token smart contract and there is no way to verify who was the original
msg.sender
. There are so many possible ways to abuseERC777Receiver
. The only way to solve it I see – work with whitelisted tokens only – DeFi deserves better approach. Imagine you have DEX and wanna deposit token and do custom action (swap):function tokensReceived( address operator, address from, address to, uint256 amount, bytes calldata userData, bytes calldata operatorData ) external override { address token = msg.sender; balances[token][operator] += amount; _performSwap(operator, operatorData); // <- `operator` is not trustworthy, due `msg.sender` can be malicious smart contract } function _performSwap(address user, bytes memory data) internal { // ... }