Use safeIncreaseAllowance()
and safeDecreaseAllowance()
from OpenZeppelin’s SafeERC20
implementation to prevent race conditions from manipulating the allowance amounts. (see here)
- ERC20
approve()
-> Race-condition approve(100)
->approve(50)
- Allowance Decrease
- Front-run -> Spend 150
increaseAllowance()
decreaseAllowance()