Skip to content

feat: add SuperchainERC20 baseline#11675

Merged
tynes merged 8 commits intoethereum-optimism:developfrom
defi-wonderland:sc/superchain-erc20-baseline
Sep 16, 2024
Merged

feat: add SuperchainERC20 baseline#11675
tynes merged 8 commits intoethereum-optimism:developfrom
defi-wonderland:sc/superchain-erc20-baseline

Conversation

@agusduha
Copy link
Copy Markdown
Contributor

Description

Add a baseline standard of the SuperchainERC20.

Tests

Add SuperchainERC20 unit tests

Additional context

We choose to go with this design to let contracts that inherits the standard be proxied or not. The downside in the current implementation is the default constructor being used in OptimismSuperchainERC20 because of being proxied.

We would love to hear some feedback on the design to know if the ideal is a simple vanilla implementation, something like this or maybe something more focus on upgradeability.

Metadata

@tynes
Copy link
Copy Markdown
Contributor

tynes commented Sep 12, 2024

Is this ready for review?

agusduha and others added 3 commits September 12, 2024 14:22
* feat: add superchain erc20 baseline

* feat: make superchain ERC20 simpler

* fix: small version fix and tests

* test: fix test name
@0xng 0xng force-pushed the sc/superchain-erc20-baseline branch from c6b4128 to d87a38e Compare September 12, 2024 20:45
@0xng
Copy link
Copy Markdown
Contributor

0xng commented Sep 12, 2024

@tynes It's now ready to review. We decided to make SuperchainERC20 as minimal as possible and abstract so that contracts extending from it can choose what sort of storage to use freely.

We only have one design question, and it's around the address zero check in the SuperchainERC20#sendERC20 function. For it to be fully compliant with the standard or a hundred percent unopionionated it should not have it. However, it seems like a check most contracts extending for it would want. We weren't sure whether to leave it or not. We removed it from relayERC20 as it didn't make sense there if it was already checked in sendERC20. Any thoughts on this would be appreciated.

@0xng 0xng marked this pull request as ready for review September 12, 2024 21:06
@0xng 0xng requested a review from a team as a code owner September 12, 2024 21:06
@0xng 0xng requested a review from smartcontracts September 12, 2024 21:06
@tynes
Copy link
Copy Markdown
Contributor

tynes commented Sep 13, 2024

Curious how you would feel about supporting #11899 as part of this. The rationale is here #11880

Since we updated the OptimismMintableERC20 with this feature, I think it makes sense to also have it in the OptimismSuperchainERC20. Definitely hear your argument about being minimal, but not having this feature would create an inconsistent experience. It basically gives a superpower to the tokens

edit: I suppose this could be done in a follow up

@tynes
Copy link
Copy Markdown
Contributor

tynes commented Sep 13, 2024

Looks like the recently added interface check failed

@tynes
Copy link
Copy Markdown
Contributor

tynes commented Sep 13, 2024

@tynes It's now ready to review. We decided to make SuperchainERC20 as minimal as possible and abstract so that contracts extending from it can choose what sort of storage to use freely.

We only have one design question, and it's around the address zero check in the SuperchainERC20#sendERC20 function. For it to be fully compliant with the standard or a hundred percent unopionionated it should not have it. However, it seems like a check most contracts extending for it would want. We weren't sure whether to leave it or not. We removed it from relayERC20 as it didn't make sense there if it was already checked in sendERC20. Any thoughts on this would be appreciated.

Definitely on board with leaving it in there

@tynes
Copy link
Copy Markdown
Contributor

tynes commented Sep 13, 2024

Tests look great to me! Ready to merge after the checks are passing CI

@0xng
Copy link
Copy Markdown
Contributor

0xng commented Sep 14, 2024

@tynes Assigned this issue to us: #11899. Will take care of this next. Thought it was cleaner to make it in a separate PR as it touches on the SuperchainWETH contract as well. I also created a task for us to refine the interfaces when a standard is introduced.

Also, as a note, for these last commits I added the main thing I felt to be untidy was to create an interface for Solady's ERC20, not due to the interface per se, but because I was not certain where to place it. I created a directory called dependency/interface and placed it there, but doubt it will see much use outside of this particular interface, so if you have any nit or opinion on this, let me know. Either way, a fun thing the interface-checker showed me is that Solady's ERC20 has named returns for some functions that OZ's ERC20 doesn't.

Lastly, on the ISemver being part of the IOptimismMintableERC20Extensions I'm a bit on the fence. It is mostly because I felt it mixed two concepts, one being the additional events and functions of the OptimismMintableERC20 and the other being versioning, but have no strong opinions here, so I can add it in a quick commit if you or anyone would like it there better.

@tynes
Copy link
Copy Markdown
Contributor

tynes commented Sep 16, 2024

@tynes Assigned this issue to us: #11899. Will take care of this next. Thought it was cleaner to make it in a separate PR as it touches on the SuperchainWETH contract as well. I also created a task for us to refine the interfaces when a standard is introduced.

Also, as a note, for these last commits I added the main thing I felt to be untidy was to create an interface for Solady's ERC20, not due to the interface per se, but because I was not certain where to place it. I created a directory called dependency/interface and placed it there, but doubt it will see much use outside of this particular interface, so if you have any nit or opinion on this, let me know. Either way, a fun thing the interface-checker showed me is that Solady's ERC20 has named returns for some functions that OZ's ERC20 doesn't.

Lastly, on the ISemver being part of the IOptimismMintableERC20Extensions I'm a bit on the fence. It is mostly because I felt it mixed two concepts, one being the additional events and functions of the OptimismMintableERC20 and the other being versioning, but have no strong opinions here, so I can add it in a quick commit if you or anyone would like it there better.

This all sounds good to me

@tynes tynes added this pull request to the merge queue Sep 16, 2024
Merged via the queue into ethereum-optimism:develop with commit 9968aa3 Sep 16, 2024
samlaf pushed a commit to samlaf/optimism that referenced this pull request Nov 10, 2024
* feat: add superchain erc20 baseline (ethereum-optimism#37)

* feat: add superchain erc20 baseline

* feat: make superchain ERC20 simpler

* fix: small version fix and tests

* test: fix test name

* test: remove unused import

* feat: making baseline abstract

* fix: interfaces to comply with the new interface checker

* fix: import paths and empty line

* fix: lint line

---------

Co-authored-by: 0xng <ng@defi.sucks>
Co-authored-by: 0xng <87835144+0xng@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SuperchainERC20: Baseline implementation

3 participants