solidstate-network/solidstate-solidity

Treat maximum ERC20 allowance as infinite

ItsNickBarry opened this issue · 2 comments

If an ERC20 allowance is set to type(uint256).max, it is wasteful and impractical to update storage when part of this allowance is spent. Instead, this value should be treated as equal to infinity, and left unchanged.

A new helper function will be needed to encapsulate this along with the existing allowance update logic.

Should use vaults branch as base branch due to addition of ERC20BaseInternal#_allowance function.
Edit: vaults branch has been merged in to master.

While in the majority of cases the gas savings would be desirable, I think the potential for unexpected behavior outweighs the benefit.

For reference, the Solmate ERC20 implementation includes this feature.