-
Notifications
You must be signed in to change notification settings - Fork 4
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
Mint/burn ethereum #44
Merged
MathisGD
merged 27 commits into
feat/optimism-morpho-token
from
feat/mint-burn-ethereum
Oct 22, 2024
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
de4f8da
feat: mint/burn ethereum
MerlinEgalite 679c7c2
chore: small letter for token
QGarchery 7536a3e
docs: author Morpho Association
QGarchery 1a05089
chore: missed small letter
QGarchery 0e663e5
chore: get back to OZ v5.0.1
QGarchery 0c996bc
fix: test bundler address(1)
QGarchery bd826d5
chore: use STORAGE LAYOUT
QGarchery e303f86
chore: rename dao to owner
QGarchery 8089691
fix: init permit
QGarchery 971ba5c
fix: visibility of public functions
QGarchery ced305c
docs: natspec on optimism getters
QGarchery 25771e9
chore: use internal instead of private
QGarchery f385bee
chore: rename test file according to convention
QGarchery d09c21a
fix: use correct license
QGarchery ed5ec9b
chore: consistent solidity version
QGarchery 04238df
chore: use relative paths
QGarchery 472666b
feat: enforce line wrapping in the config
QGarchery 42afb3e
chore: forge fmt
QGarchery f1f6dc7
fix: missed absolute dependency
QGarchery 4549e02
fix: missed inconsistent pragma
QGarchery 5d7f08b
fix: optimism token inherit from bridge interface
QGarchery 3fa15cb
Merge branch 'feat/mint-burn-ethereum' into fix/optimism
QGarchery 5910fa5
refactor: move mint and burn to Token
QGarchery 6dd488b
test: testMint and testBurn
MathisGD 6644279
test: 2 more mint tests
MathisGD 5042b50
chore: fmt
MathisGD 294f345
Merge pull request #45 from morpho-org/fix/optimism
MerlinEgalite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule openzeppelin-contracts-upgradeable
updated
342 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import {Token} from "./Token.sol"; | |
/// @title MorphoTokenEthereum | ||
/// @author Morpho Association | ||
/// @custom:contact [email protected] | ||
/// @notice The Morpho Token contract for Ethereum. | ||
/// @notice The Morpho token contract for Ethereum. | ||
contract MorphoTokenEthereum is Token { | ||
/* CONSTANTS */ | ||
|
||
|
@@ -21,12 +21,12 @@ contract MorphoTokenEthereum is Token { | |
/// @notice Reverts if the address is the zero address. | ||
error ZeroAddress(); | ||
|
||
/* PUBLIC */ | ||
/* EXTERNAL */ | ||
|
||
/// @notice Initializes the contract. | ||
/// @param owner The new owner. | ||
/// @param wrapper The wrapper contract address to migrate legacy MORPHO tokens to the new one. | ||
function initialize(address owner, address wrapper) public initializer { | ||
function initialize(address owner, address wrapper) external initializer { | ||
require(owner != address(0), ZeroAddress()); | ||
|
||
__ERC20_init(NAME, SYMBOL); | ||
|
@@ -35,4 +35,16 @@ contract MorphoTokenEthereum is Token { | |
_transferOwnership(owner); | ||
_mint(wrapper, 1_000_000_000e18); // Mint 1B to the wrapper contract. | ||
} | ||
|
||
/// @dev Mints tokens. | ||
function mint(address to, uint256 amount) external onlyOwner { | ||
_mint(to, amount); | ||
emit Mint(to, amount); | ||
} | ||
|
||
/// @dev Burns sender's tokens. | ||
function burn(uint256 amount) external { | ||
_burn(_msgSender(), amount); | ||
emit Burn(_msgSender(), amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// SPDX-License-Identifier: MIT | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity 0.8.27; | ||
|
||
import {IOptimismMintableERC20} from "./interfaces/IOptimismMintableERC20.sol"; | ||
|
@@ -11,7 +11,7 @@ import {Token} from "./Token.sol"; | |
/// @author Morpho Association | ||
/// @custom:contact [email protected] | ||
/// @notice The Morpho token contract for Optimism networks. | ||
contract MorphoTokenOptimism is Token { | ||
contract MorphoTokenOptimism is Token, IOptimismMintableERC20 { | ||
/* CONSTANTS */ | ||
|
||
/// @dev The name of the token. | ||
|
@@ -21,25 +21,17 @@ contract MorphoTokenOptimism is Token { | |
string internal constant SYMBOL = "MORPHO"; | ||
|
||
// keccak256(abi.encode(uint256(keccak256("morpho.storage.OptimismMintableERC20")) - 1)) & ~bytes32(uint256(0xff)) | ||
bytes32 private constant OptimismMintableERC20StorageLocation = | ||
bytes32 internal constant OptimismMintableERC20StorageLocation = | ||
0x6fd4c0a11d0843c68c809f0a5f29b102d54bc08a251c384d9ad17600bfa05d00; | ||
|
||
/* STRUCTS */ | ||
/* STORAGE LAYOUT */ | ||
|
||
/// @custom:storage-location erc7201:morpho.storage.OptimismMintableERC20 | ||
struct OptimismMintableERC20Storage { | ||
address _remoteToken; | ||
address _bridge; | ||
} | ||
|
||
/* EVENTS */ | ||
|
||
/// @dev Emitted whenever tokens are minted for an account. | ||
event Mint(address indexed account, uint256 amount); | ||
|
||
/// @dev Emitted whenever tokens are burned from an account. | ||
event Burn(address indexed account, uint256 amount); | ||
|
||
/* ERRORS */ | ||
|
||
/// @notice Reverts if the address is the zero address. | ||
|
@@ -57,28 +49,27 @@ contract MorphoTokenOptimism is Token { | |
_; | ||
} | ||
|
||
/* PUBLIC */ | ||
/* EXTERNAL */ | ||
|
||
/// @notice Initializes the contract. | ||
/// @param dao The DAO address. | ||
/// @param remoteToken_ The address of the Morpho Token on Ethereum. | ||
/// @param owner The new owner. | ||
/// @param remoteToken_ The address of the Morpho token on Ethereum. | ||
/// @param bridge_ The address of the StandardBridge contract. | ||
function initialize(address dao, address remoteToken_, address bridge_) public initializer { | ||
require(dao != address(0), ZeroAddress()); | ||
function initialize(address owner, address remoteToken_, address bridge_) external initializer { | ||
require(owner != address(0), ZeroAddress()); | ||
require(remoteToken_ != address(0), ZeroAddress()); | ||
require(bridge_ != address(0), ZeroAddress()); | ||
|
||
__ERC20_init(NAME, SYMBOL); | ||
__ERC20Permit_init(NAME); | ||
|
||
OptimismMintableERC20Storage storage $ = _getOptimismMintableERC20Storage(); | ||
$._remoteToken = remoteToken_; | ||
$._bridge = bridge_; | ||
|
||
_transferOwnership(dao); // Transfer ownership to the DAO. | ||
_transferOwnership(owner); | ||
} | ||
|
||
/* EXTERNAL */ | ||
|
||
/// @dev Allows the StandardBridge on this network to mint tokens. | ||
function mint(address to, uint256 amount) external onlyBridge { | ||
_mint(to, amount); | ||
|
@@ -100,24 +91,22 @@ contract MorphoTokenOptimism is Token { | |
return _interfaceId == interfaceERC165 || _interfaceId == interfaceOptimismMintableERC20; | ||
} | ||
|
||
/// @custom:legacy | ||
/// @dev Legacy getter for REMOTE_TOKEN. | ||
/// @dev Returns the address of the Morpho token on Ethereum. | ||
function remoteToken() external view returns (address) { | ||
OptimismMintableERC20Storage storage $ = _getOptimismMintableERC20Storage(); | ||
return $._remoteToken; | ||
} | ||
|
||
/// @custom:legacy | ||
/// @dev Legacy getter for BRIDGE. | ||
/// @dev Returns the address of the StandardBridge contract. | ||
function bridge() external view returns (address) { | ||
OptimismMintableERC20Storage storage $ = _getOptimismMintableERC20Storage(); | ||
return $._bridge; | ||
} | ||
|
||
/* PRIVATE */ | ||
/* INTERNAL */ | ||
|
||
/// @dev Returns the OptimismMintableERC20Storage struct. | ||
function _getOptimismMintableERC20Storage() private pure returns (OptimismMintableERC20Storage storage $) { | ||
function _getOptimismMintableERC20Storage() internal pure returns (OptimismMintableERC20Storage storage $) { | ||
assembly { | ||
$.slot := OptimismMintableERC20StorageLocation | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
pragma solidity >=0.5.0; | ||
|
||
/// @title IDelegates | ||
/// @author Morpho Labs | ||
/// @author Morpho Association | ||
/// @custom:contact [email protected] | ||
interface IERC20DelegatesUpgradeable { | ||
function delegatedVotingPower(address account) external view returns (uint256); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
test/MorphoTokenOptimism.t.sol → test/MorphoTokenOptimismTest.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could probably rename this file to
MorphoTokenEthereum.sol