Add SafeERC20.forceApprove()
PR Checklist
TBD
- [ ] Tests
- [ ] Documentation
- [ ] Changelog entry
Please provide more detail. If we offer this function, what should we recommend to developers? Should they always use this function when they need to call approve? Are there circumstances where they shouldn't use it? Are there risks they should consider?
@frangio if your contract is performing token approve and expecting to spend it later in the same transaction This forceApprove is the cheapest way to do so without any allowance pre-checks. In best scenario it will only perform approve(amount), in worst scenario it will make 3 calls: approve(amount), approve(0), approve(amount). So this methods do best effort to set token approve to desired amount.
My question is different: should we be recommending that everyone use forceApprove?
@frangio I think it depends on the situation. If developer is going to spend this approve in the same transaction, then yes, I would recommend to use it. If this approve should be spent by someone else in different transaction then I would suggest to use safe increase/decrease.
Great! That recommendation makes a lot of sense to me. We should include this in the docs.
This targets next-5.0. Since we want it in 4.9 we need to target master.
Replacing this PR with #4067