generated from m0-foundation/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- solc 0.8.26 - latest common - latest forge-std - registrar as constructor arg - excess destination as constructor arg - constants made public - token name changed - batch start and stop earning - IsApprovedEarner and NotApprovedEarner errors have account as parameter - Indexing Math no longer needed? - Basic Migrator contract introduced - version bump - use more from common - zero account checks feat: post-deploy v2 prep - solc 0.8.26 - latest common - latest forge-std - registrar as constructor arg - excess destination as constructor arg - constants made public - token name changed - `IsApprovedEarner` and `NotApprovedEarner` errors have account as parameter - basic Migrator contract introduced - version bump - use more from common - more test coverage - fixed scripts to allow for generic deploy and mainnet upgrade
- Loading branch information
1 parent
050d781
commit 448d79c
Showing
41 changed files
with
1,896 additions
and
1,929 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Deploy script environment variables | ||
PRIVATE_KEY= # Private key of the deployer | ||
DEPLOYER= # Address the deployer | ||
DEPLOYER_PROXY_NONCE= # Nonce of the deployer when creating the Wrapped M proxy | ||
EXPECTED_PROXY= # Address of the expected Wrapped M proxy | ||
M_TOKEN= # Address of the M token | ||
REGISTRAR= # Address of the Registrar | ||
EXCESS_DESTINATION= # Address of the Excess Destination | ||
MIGRATION_ADMIN= # Address of the Migration Admin | ||
|
||
# RPC URL to deploy to | ||
DEPLOY_RPC_URL= | ||
|
||
# Used for verifying contracts on Etherscan | ||
ETHERSCAN_API_KEY= |
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,11 +1,11 @@ | ||
# Localhost RPC URL | ||
export LOCALHOST_RPC_URL=http://127.0.0.1:8545 | ||
LOCALHOST_RPC_URL=http://127.0.0.1:8545 | ||
|
||
# Mainnet RPC URLs | ||
export MAINNET_RPC_URL= | ||
MAINNET_RPC_URL= | ||
|
||
# Testnet RPC URLs | ||
export SEPOLIA_RPC_URL= | ||
SEPOLIA_RPC_URL= | ||
|
||
# Used for verifying contracts on Etherscan | ||
export ETHERSCAN_API_KEY= | ||
ETHERSCAN_API_KEY= |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Mainnet upgrade script environment variables | ||
PRIVATE_KEY= # Private key of the deployer | ||
|
||
# Mainnet RPC URL to perform upgrade | ||
MAINNET_RPC_URL= | ||
|
||
# Used for verifying contracts on Etherscan | ||
ETHERSCAN_API_KEY= |
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
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 common
updated
from 45aa01 to 3692db
Submodule forge-std
updated
22 files
+193 −0 | CONTRIBUTING.md | |
+17 −1 | README.md | |
+1 −1 | package.json | |
+12 −1 | scripts/vm.py | |
+4 −0 | src/StdChains.sol | |
+3 −3 | src/StdCheats.sol | |
+104 −0 | src/StdJson.sol | |
+104 −0 | src/StdToml.sol | |
+387 −23 | src/Vm.sol | |
+471 −463 | src/console.sol | |
+2 −2 | src/interfaces/IERC4626.sol | |
+1 −1 | test/StdAssertions.t.sol | |
+16 −15 | test/StdChains.t.sol | |
+10 −10 | test/StdCheats.t.sol | |
+12 −12 | test/StdError.t.sol | |
+1 −1 | test/StdJson.t.sol | |
+4 −14 | test/StdMath.t.sol | |
+5 −5 | test/StdStorage.t.sol | |
+1 −1 | test/StdStyle.t.sol | |
+1 −1 | test/StdToml.t.sol | |
+12 −12 | test/StdUtils.t.sol | |
+9 −6 | test/Vm.t.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@mzero-labs/wrapped-m-token", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Wrapped M Token", | ||
"author": "M^0 Labs <[email protected]>", | ||
"repository": { | ||
|
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity 0.8.26; | ||
|
||
import { Script, console2 } from "../lib/forge-std/src/Script.sol"; | ||
|
||
import { DeployBase } from "./DeployBase.sol"; | ||
|
||
contract DeployProduction is Script, DeployBase { | ||
error DeployerMismatch(address expected, address actual); | ||
|
||
error DeployerNonceTooHigh(); | ||
|
||
error UnexpectedDeployerNonce(); | ||
|
||
error CurrentNonceMismatch(uint64 expected, uint64 actual); | ||
|
||
error ExpectedProxyMismatch(address expected, address actual); | ||
|
||
error ResultingProxyMismatch(address expected, address actual); | ||
|
||
function run() external { | ||
address deployer_ = vm.rememberKey(vm.envUint("PRIVATE_KEY")); | ||
address expectedDeployer_ = vm.envAddress("DEPLOYER"); | ||
|
||
uint64 deployerProxyNonce_ = uint64(vm.envUint("DEPLOYER_PROXY_NONCE")); | ||
|
||
address expectedProxy_ = vm.envAddress("EXPECTED_PROXY"); | ||
|
||
console2.log("Deployer:", deployer_); | ||
|
||
if (deployer_ != expectedDeployer_) revert DeployerMismatch(expectedDeployer_, deployer_); | ||
|
||
uint64 currentNonce_ = vm.getNonce(deployer_); | ||
|
||
uint64 startNonce_ = currentNonce_; | ||
address implementation_; | ||
address proxy_; | ||
|
||
while (true) { | ||
if (startNonce_ > deployerProxyNonce_) revert DeployerNonceTooHigh(); | ||
|
||
(implementation_, proxy_) = mockDeploy(deployer_, startNonce_); | ||
|
||
if (proxy_ == expectedProxy_) break; | ||
|
||
++startNonce_; | ||
} | ||
|
||
vm.startBroadcast(deployer_); | ||
|
||
// Burn nonces until to `currentNonce_ == startNonce_`. | ||
while (currentNonce_ < startNonce_) { | ||
payable(deployer_).transfer(0); | ||
++currentNonce_; | ||
} | ||
|
||
if (currentNonce_ != vm.getNonce(deployer_)) revert CurrentNonceMismatch(currentNonce_, vm.getNonce(deployer_)); | ||
|
||
if (currentNonce_ != startNonce_) revert UnexpectedDeployerNonce(); | ||
|
||
(implementation_, proxy_) = deploy( | ||
vm.envAddress("M_TOKEN"), | ||
vm.envAddress("REGISTRAR"), | ||
vm.envAddress("EXCESS_DESTINATION"), | ||
vm.envAddress("MIGRATION_ADMIN") | ||
); | ||
|
||
vm.stopBroadcast(); | ||
|
||
console2.log("Wrapped M Implementation address:", implementation_); | ||
console2.log("Wrapped M Proxy address:", proxy_); | ||
|
||
if (proxy_ != expectedProxy_) revert ResultingProxyMismatch(expectedProxy_, proxy_); | ||
} | ||
} |
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,57 +1,91 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity 0.8.23; | ||
pragma solidity 0.8.26; | ||
|
||
import { ContractHelper } from "../lib/common/src/libs/ContractHelper.sol"; | ||
import { Proxy } from "../lib/common/src/Proxy.sol"; | ||
|
||
import { MigratorV1 } from "../src/MigratorV1.sol"; | ||
import { WrappedMToken } from "../src/WrappedMToken.sol"; | ||
import { Proxy } from "../src/Proxy.sol"; | ||
|
||
contract DeployBase { | ||
/** | ||
* @dev Deploys Wrapped M Token. | ||
* @param mToken_ The address the M Token contract. | ||
* @param migrationAdmin_ The address the Migration Admin. | ||
* @return implementation_ The address of the deployed Wrapped M Token implementation. | ||
* @return proxy_ The address of the deployed Wrapped M Token proxy. | ||
* @param mToken_ The address of the M Token contract. | ||
* @param registrar_ The address of the Registrar contract. | ||
* @param excessDestination_ The address of the excess destination. | ||
* @param migrationAdmin_ The address of the Migration Admin. | ||
* @return implementation_ The address of the deployed Wrapped M Token implementation. | ||
* @return proxy_ The address of the deployed Wrapped M Token proxy. | ||
*/ | ||
function deploy( | ||
address mToken_, | ||
address registrar_, | ||
address excessDestination_, | ||
address migrationAdmin_ | ||
) public virtual returns (address implementation_, address proxy_) { | ||
// Wrapped M token needs `mToken_` and `migrationAdmin_` addresses. | ||
// Wrapped M token needs `mToken_`, `registrar_`, `excessDestination_`, and `migrationAdmin_` addresses. | ||
// Proxy needs `implementation_` addresses. | ||
|
||
implementation_ = address(new WrappedMToken(mToken_, migrationAdmin_)); | ||
implementation_ = address(new WrappedMToken(mToken_, registrar_, excessDestination_, migrationAdmin_)); | ||
proxy_ = address(new Proxy(implementation_)); | ||
} | ||
|
||
function _getExpectedWrappedMTokenImplementation( | ||
address deployer_, | ||
uint256 deployerNonce_ | ||
) internal pure returns (address) { | ||
return ContractHelper.getContractFrom(deployer_, deployerNonce_); | ||
/** | ||
* @dev Deploys Wrapped M Token components needed to upgrade an existing Wrapped M proxy. | ||
* @param mToken_ The address of the M Token contract. | ||
* @param registrar_ The address of the Registrar contract. | ||
* @param excessDestination_ The address of the excess destination. | ||
* @param migrationAdmin_ The address of the Migration Admin. | ||
* @return implementation_ The address of the deployed Wrapped M Token implementation. | ||
* @return migrator_ The address of the deployed Migrator. | ||
*/ | ||
function deployUpgrade( | ||
address mToken_, | ||
address registrar_, | ||
address excessDestination_, | ||
address migrationAdmin_ | ||
) public virtual returns (address implementation_, address migrator_) { | ||
// Wrapped M token needs `mToken_`, `registrar_`, `excessDestination_`, and `migrationAdmin_` addresses. | ||
// Migrator needs `implementation_` addresses. | ||
|
||
implementation_ = address(new WrappedMToken(mToken_, registrar_, excessDestination_, migrationAdmin_)); | ||
migrator_ = address(new MigratorV1(implementation_)); | ||
} | ||
|
||
function getExpectedWrappedMTokenImplementation( | ||
/** | ||
* @dev Mock deploys Wrapped M Token, returning the would-be addresses. | ||
* @param deployer_ The address of the deployer. | ||
* @param deployerNonce_ The nonce of the deployer. | ||
* @return implementation_ The address of the would-be Wrapped M Token implementation. | ||
* @return proxy_ The address of the would-be Wrapped M Token proxy. | ||
*/ | ||
function mockDeploy( | ||
address deployer_, | ||
uint256 deployerNonce_ | ||
) public pure virtual returns (address) { | ||
return _getExpectedWrappedMTokenImplementation(deployer_, deployerNonce_); | ||
} | ||
) public view virtual returns (address implementation_, address proxy_) { | ||
// Wrapped M token needs `mToken_`, `registrar_`, `excessDestination_`, and `migrationAdmin_` addresses. | ||
// Proxy needs `implementation_` addresses. | ||
|
||
function _getExpectedWrappedMTokenProxy(address deployer_, uint256 deployerNonce_) internal pure returns (address) { | ||
return ContractHelper.getContractFrom(deployer_, deployerNonce_ + 1); | ||
implementation_ = ContractHelper.getContractFrom(deployer_, deployerNonce_); | ||
proxy_ = ContractHelper.getContractFrom(deployer_, deployerNonce_ + 1); | ||
} | ||
|
||
function getExpectedWrappedMTokenProxy( | ||
/** | ||
* @dev Mock deploys Wrapped M Token, returning the would-be addresses. | ||
* @param deployer_ The address of the deployer. | ||
* @param deployerNonce_ The nonce of the deployer. | ||
* @return implementation_ The address of the would-be Wrapped M Token implementation. | ||
* @return migrator_ The address of the would-be Migrator. | ||
*/ | ||
function mockDeployUpgrade( | ||
address deployer_, | ||
uint256 deployerNonce_ | ||
) public pure virtual returns (address) { | ||
return _getExpectedWrappedMTokenProxy(deployer_, deployerNonce_); | ||
} | ||
) public view virtual returns (address implementation_, address migrator_) { | ||
// Wrapped M token needs `mToken_`, `registrar_`, `excessDestination_`, and `migrationAdmin_` addresses. | ||
// Migrator needs `implementation_` addresses. | ||
|
||
function getDeployerNonceAfterProtocolDeployment(uint256 deployerNonce_) public pure virtual returns (uint256) { | ||
return deployerNonce_ + 2; | ||
implementation_ = ContractHelper.getContractFrom(deployer_, deployerNonce_); | ||
migrator_ = ContractHelper.getContractFrom(deployer_, deployerNonce_ + 1); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.