Open 0xClandestine opened 1 year ago
gm, thanks for the issue & pr!
so the reference implementation is meant more for readability and making the specification explicit. so tradeoffs were made in favor of readability over gas efficiency.
would you mind moving the optimized implementation to the alt/
directory? it can take the name of ERC6909Optimized.sol
. from there we can make further optimizations and stray further from readability.
First of all sick proposal 👏👏👏, just thought I would suggest some gas optimizations.
1) These custom errors aren't really needed, and increase gas since an unnecessary conditional check is needed to throw the error. In both
transfer
andtransferFrom
the checked arithmetic would throw a revert regardless of the conditional. The same applies to theInsufficientPermission
check withintransferFrom
.2) You can also use
unchecked
when modifying the receivers balance sincetotalSupply
cannot exceed 2**256-1. Checkouttransmissions/solmate/tokens/ERC20.sol
for reference.