Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: xSuperchainERC20 #275

Open
wants to merge 13 commits into
base: sc-feat/xsuperc20
Choose a base branch
from
Open

Conversation

0xChin
Copy link
Member

@0xChin 0xChin commented Feb 11, 2025

No description provided.

@hexshire hexshire self-requested a review February 11, 2025 22:59
@@ -0,0 +1,328 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.4 <0.9.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

XERC20 current implementation allows you to compile using a wide range of solidity versions but SuperchainERC20 is using a fixed version, in this case I think it is a good idea to use the more restrictive option to reduce compatibility errores. Use pragma solidity 0.8.25;

Copy link
Member Author

@0xChin 0xChin Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pragma solidity >=0.8.4 <0.9.0;

import { IXERC20 } from "interfaces/L2/IXERC20.sol";
import { ERC20 } from "@solady-v0.0.245/tokens/ERC20.sol";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused import

Copy link
Member Author

@0xChin 0xChin Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


/// @title XSuperchainERC20
/// @notice A SuperchainERC20 + xERC20 implementation
contract XSuperchainERC20 is SuperchainERC20, Ownable, IXERC20 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make the contract abstract like SuperchainERC20

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 15 to 20
string private _name;

/**
* @notice The symbol of the token
*/
string private _symbol;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these variables (since the contract will be abstract the override of the name() and symbol() functions should be done in the derived contract)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 50 to 51
string memory __name,
string memory __symbol,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these params (since the contract will be abstract the override of the name() and symbol() functions should be done in the derived contract)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 55 to 56
_name = __name;
_symbol = __symbol;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these assignations (since the contract will be abstract the override of the name() and symbol() functions should be done in the derived contract)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 114 to 130
/**
* @notice Returns the name of the token
*
* @return _name The name of the token
*/
function name() public view override returns (string memory) {
return _name;
}

/**
* @notice Returns the symbol of the token
*
* @return _symbol The symbol of the token
*/
function symbol() public view override returns (string memory) {
return _symbol;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove these functions (since the contract will be abstract the override of the name() and symbol() functions should be done in the derived contract)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


contract XSuperchainERC20Test is SuperchainERC20Test {
function setUp() public override {
superchainERC20 = new XSuperchainERC20("Test", "TEST", address(0));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the contract will be abstract a mock contract will be needed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @param _bridge The address of the bridge we are setting the limits too
*/
function setLimits(address _bridge, uint256 _mintingLimit, uint256 _burningLimit) external onlyOwner {
if (_mintingLimit > (type(uint256).max / 2) || _burningLimit > (type(uint256).max / 2)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use bit shifting for this one. Just because it looks cooler 😎

Suggested change
if (_mintingLimit > (type(uint256).max / 2) || _burningLimit > (type(uint256).max / 2)) {
if (_mintingLimit > (type(uint256).max >> 1) || _burningLimit > (type(uint256).max >> 1)) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look cooler? I think you mean saving 2 gas per tx 😎 perf(xSupERC20): optimize uint256/2 check

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we should add this one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how that lib showed up lol. Fixed in chore: remove automate lib

@hexshire hexshire added the hold Do not merge for now label Feb 14, 2025
@defi-wonderland defi-wonderland deleted a comment from linear bot Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hold Do not merge for now
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants