Skip to content

Commit

Permalink
feat: post-deploy v2 prep
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
deluca-mike committed Jan 13, 2025
1 parent 6b57c30 commit e635cb7
Show file tree
Hide file tree
Showing 34 changed files with 1,532 additions and 1,768 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"files": "*.sol",
"options": {
"bracketSpacing": true,
"compiler": "0.8.23",
"compiler": "0.8.26",
"parser": "solidity-parse",
"printWidth": 120,
"tabWidth": 4,
Expand Down
2 changes: 1 addition & 1 deletion .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"compiler-version": [
"error",
"0.8.23"
"0.8.26"
],
"comprehensive-interface": "off",
"const-name-snakecase": "off",
Expand Down
8 changes: 3 additions & 5 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
gas_reports = ["*"]
gas_reports_ignore = []
ignored_error_codes = []
solc_version = "0.8.23"
solc_version = "0.8.26"
optimizer = true
optimizer_runs = 999999
verbosity = 3
block_number = 20_270_778
block_timestamp = 1_720_550_400
fork_block_number = 20_270_778
fork_block_number = 21_345_650
rpc_storage_caching = { chains = ["mainnet"], endpoints = "all" }
evm_version = "shanghai"
evm_version = "cancun"

[profile.production]
build_info = true
Expand Down
2 changes: 1 addition & 1 deletion lib/common
2 changes: 1 addition & 1 deletion package.json
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": {
Expand Down
20 changes: 12 additions & 8 deletions script/DeployBase.sol
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
// 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 { 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 the M Token contract.
* @param registrar_ The address the Registrar contract.
* @param excessDestination_ The address of the excess destination.
* @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.
*/
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_`, 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_));
}

Expand Down
10 changes: 8 additions & 2 deletions script/DeployProduction.s.sol
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: UNLICENSED

pragma solidity 0.8.23;
pragma solidity 0.8.26;

import { Script, console2 } from "../lib/forge-std/src/Script.sol";

Expand All @@ -19,6 +19,12 @@ contract DeployProduction is Script, DeployBase {

error ResultingProxyMismatch(address expected, address actual);

// NOTE: Ensure this is the correct Registrar testnet/mainnet address.
address internal constant _REGISTRAR = 0x119FbeeDD4F4f4298Fb59B720d5654442b81ae2c;

// NOTE: Ensure this is the correct Excess Destination testnet/mainnet address.
address internal constant _EXCESS_DESTINATION = 0xd7298f620B0F752Cf41BD818a16C756d9dCAA34f; // Vault

// NOTE: Ensure this is the correct M Token testnet/mainnet address.
address internal constant _M_TOKEN = 0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b;

Expand Down Expand Up @@ -62,7 +68,7 @@ contract DeployProduction is Script, DeployBase {

if (currentNonce_ != startNonce_) revert UnexpectedDeployerNonce();

(address implementation_, address proxy_) = deploy(_M_TOKEN, _MIGRATION_ADMIN);
(address implementation_, address proxy_) = deploy(_M_TOKEN, _REGISTRAR, _EXCESS_DESTINATION, _MIGRATION_ADMIN);

vm.stopBroadcast();

Expand Down
61 changes: 0 additions & 61 deletions src/Migratable.sol

This file was deleted.

26 changes: 26 additions & 0 deletions src/MigratorV1.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: BUSL-1.1

pragma solidity 0.8.26;

/**
* @title Migrator contract for migrating a WrappedMToken contract from V1 to V2.
* @author M^0 Labs
*/
contract MigratorV1 {
/// @dev Storage slot with the address of the current factory. `keccak256('eip1967.proxy.implementation') - 1`.
uint256 private constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

address public immutable implementationV2;

constructor(address implementationV2_) {
implementationV2 = implementationV2_;
}

fallback() external virtual {
address implementationV2_ = implementationV2;

assembly {
sstore(_IMPLEMENTATION_SLOT, implementationV2_)
}
}
}
47 changes: 0 additions & 47 deletions src/Proxy.sol

This file was deleted.

Loading

0 comments on commit e635cb7

Please sign in to comment.