Skip to content

Commit

Permalink
Merge pull request #10 from morpho-org/feat/mutable-name-3
Browse files Browse the repository at this point in the history
Mutable name and symbol
  • Loading branch information
MathisGD authored Aug 19, 2024
2 parents 1d13573 + 891624c commit 632dd01
Show file tree
Hide file tree
Showing 31 changed files with 299 additions and 449 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/certora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ jobs:
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc-0.8.19
- name: Install solc (0.8.21)
- name: Install solc (0.8.26)
run: |
wget https://github.com/ethereum/solidity/releases/download/v0.8.21/solc-static-linux
wget https://github.com/ethereum/solidity/releases/download/v0.8.26/solc-static-linux
chmod +x solc-static-linux
sudo mv solc-static-linux /usr/local/bin/solc-0.8.21
sudo mv solc-static-linux /usr/local/bin/solc-0.8.26
- name: Apply munging
run: make -C certora munged
Expand Down
4 changes: 2 additions & 2 deletions certora/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ This folder contains the verification of MetaMorpho using CVL, Certora's Verific

The code is compiled using 2 versions of solidity, which must be installed to run the verification as:

- `solc` for solidity compiler version 0.8.21 which is used for compiling MetaMorpho
- `solc8.19` for solidity compiler version 0.8.19 which is used for compiling Morpho Blue.
- `solc-0.8.26` for solidity compiler version 0.8.26 which is used for compiling MetaMorpho
- `solc-0.8.19` for solidity compiler version 0.8.19 which is used for compiling Morpho Blue.

The verification is run on modified source files, which are made available by running:

Expand Down
3 changes: 2 additions & 1 deletion certora/confs/ConsistentState.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"certora/helpers/MetaMorphoHarness.sol",
"certora/helpers/Util.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"parametric_contracts": [
"MetaMorphoHarness",
],
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/DistinctIdentifiers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"files": [
"certora/helpers/MetaMorphoHarness.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/DistinctIdentifiers.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/Enabled.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"files": [
"certora/helpers/MetaMorphoHarness.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Enabled.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/Immutability.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"files": [
"certora/helpers/MetaMorphoHarness.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Immutability.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
5 changes: 3 additions & 2 deletions certora/confs/LastUpdated.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
],
"solc_map": {
"MorphoHarness": "solc-0.8.19",
"MetaMorphoHarness": "solc-0.8.21",
"Util": "solc-0.8.21",
"MetaMorphoHarness": "solc-0.8.26",
"Util": "solc-0.8.26",
},
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/LastUpdated.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
5 changes: 3 additions & 2 deletions certora/confs/Liveness.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
],
"solc_map": {
"MorphoHarness": "solc-0.8.19",
"MetaMorphoHarness": "solc-0.8.21",
"Util": "solc-0.8.21",
"MetaMorphoHarness": "solc-0.8.26",
"Util": "solc-0.8.26",
},
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Liveness.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
5 changes: 3 additions & 2 deletions certora/confs/LostAssetsLink.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"certora/helpers/Util.sol",
],
"solc_map": {
"MetaMorphoHarness": "solc-0.8.21",
"MetaMorphoHarness": "solc-0.8.26",
"MorphoHarness": "solc-0.8.19",
"Util": "solc-0.8.21"
"Util": "solc-0.8.26"
},
"solc_evm_version": "cancun",
"link": [
"MetaMorphoHarness:MORPHO=MorphoHarness",
],
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/LostAssetsNoLink.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"files": [
"certora/helpers/MetaMorphoHarness.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/LostAssetsNoLink.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/MarketInteractions.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"certora/helpers/MetaMorphoHarness.sol",
"certora/helpers/Util.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"parametric_contracts": [
"MetaMorphoHarness",
],
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/PendingValues.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"files": [
"certora/helpers/MetaMorphoHarness.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/PendingValues.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/Range.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"files": [
"certora/helpers/MetaMorphoHarness.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Range.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/Reentrancy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"files": [
"certora/helpers/MetaMorphoHarness.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Reentrancy.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
7 changes: 4 additions & 3 deletions certora/confs/Reverts.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
],
"solc_map": {
"MorphoHarness": "solc-0.8.19",
"MetaMorphoHarness": "solc-0.8.21",
"Util": "solc-0.8.21",
"ERC20Standard": "solc-0.8.21",
"MetaMorphoHarness": "solc-0.8.26",
"Util": "solc-0.8.26",
"ERC20Standard": "solc-0.8.26",
},
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Reverts.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/Roles.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"files": [
"certora/helpers/MetaMorphoHarness.sol",
],
"solc": "solc-0.8.21",
"solc": "solc-0.8.26",
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Roles.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
3 changes: 2 additions & 1 deletion certora/confs/Timelock.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
],
"solc_map": {
"MorphoHarness": "solc-0.8.19",
"MetaMorphoHarness": "solc-0.8.21",
"MetaMorphoHarness": "solc-0.8.26",
},
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Timelock.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
11 changes: 6 additions & 5 deletions certora/confs/Tokens.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
],
"solc_map": {
"MorphoHarness": "solc-0.8.19",
"MetaMorphoHarness": "solc-0.8.21",
"Util": "solc-0.8.21",
"ERC20NoRevert": "solc-0.8.21",
"ERC20Standard": "solc-0.8.21",
"ERC20USDT": "solc-0.8.21",
"MetaMorphoHarness": "solc-0.8.26",
"Util": "solc-0.8.26",
"ERC20NoRevert": "solc-0.8.26",
"ERC20Standard": "solc-0.8.26",
"ERC20USDT": "solc-0.8.26",
},
"solc_evm_version": "cancun",
"verify": "MetaMorphoHarness:certora/specs/Tokens.spec",
"loop_iter": "2",
"optimistic_loop": true,
Expand Down
2 changes: 1 addition & 1 deletion certora/helpers/IMorphoHarness.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;
pragma solidity 0.8.26;

import {Id, MarketParams, Market, IMorpho} from "../../lib/morpho-blue/src/interfaces/IMorpho.sol";

Expand Down
2 changes: 1 addition & 1 deletion certora/helpers/MetaMorphoHarness.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;
pragma solidity 0.8.26;

import {
Math, MetaMorpho, Id, ConstantsLib, PendingUint192, PendingAddress, MarketConfig
Expand Down
2 changes: 1 addition & 1 deletion certora/helpers/Util.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;
pragma solidity 0.8.26;

import {
MarketParams,
Expand Down
2 changes: 1 addition & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
src = "src"
test = "test/forge"
libs = ["lib"]
evm_version = "paris"
evm_version = "cancun"
fs_permissions = [
{ access = "read", path = "./config/"},
{ access = "read", path = "./out/"}
Expand Down
10 changes: 6 additions & 4 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,21 @@ const config: HardhatUserConfig = {
order: "fifo",
},
},
// Required because hardhat has a bug regarding contract sizes.
allowUnlimitedContractSize: true,
},
},
solidity: {
compilers: [
{
version: "0.8.21",
version: "0.8.26",
settings: {
optimizer: {
enabled: true,
runs: 200,
enabled: false,
runs: 0,
},
viaIR: true,
evmVersion: "paris",
evmVersion: "cancun",
},
},
{
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
"@types/node": "^20.11.0",
"chai": "^4.4.0",
"dotenv": "^16.3.1",
"hardhat": "^2.19.4",
"hardhat": "^2.22.8",
"hardhat-gas-reporter": "^1.0.9",
"hardhat-tracer": "^2.7.0",
"hardhat-tracer": "^3.1.0",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.1.1",
Expand Down
45 changes: 39 additions & 6 deletions src/MetaMorpho.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;
pragma solidity 0.8.26;

import {
MarketConfig,
Expand Down Expand Up @@ -110,26 +110,39 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph
/// @inheritdoc IMetaMorphoBase
uint256 public lostAssets;

/// @dev "Overrides" the ERC20's storage variable to be able to modify it.
string private _name;

/// @dev "Overrides" the ERC20's storage variable to be able to modify it.
string private _symbol;

/* CONSTRUCTOR */

/// @dev Initializes the contract.
/// @param owner The owner of the contract.
/// @param morpho The address of the Morpho contract.
/// @param initialTimelock The initial timelock.
/// @param _asset The address of the underlying asset.
/// @param _name The name of the vault.
/// @param _symbol The symbol of the vault.
/// @param __name The name of the vault.
/// @param __symbol The symbol of the vault.
/// @dev We pass "" as name and symbol to the ERC20 because these are overriden in this contract.
constructor(
address owner,
address morpho,
uint256 initialTimelock,
address _asset,
string memory _name,
string memory _symbol
) ERC4626(IERC20(_asset)) ERC20Permit(_name) ERC20(_name, _symbol) Ownable(owner) {
string memory __name,
string memory __symbol
) ERC4626(IERC20(_asset)) ERC20Permit("") ERC20("", "") Ownable(owner) {
if (morpho == address(0)) revert ErrorsLib.ZeroAddress();
if (initialTimelock > ConstantsLib.MAX_TIMELOCK) revert ErrorsLib.AboveMaxTimelock();

_name = __name;
emit EventsLib.SetName(__name);

_symbol = __symbol;
emit EventsLib.SetSymbol(__symbol);

MORPHO = IMorpho(morpho);
DECIMALS_OFFSET = uint8(uint256(18).zeroFloorSub(IERC20Metadata(_asset).decimals()));

Expand Down Expand Up @@ -187,6 +200,18 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph

/* ONLY OWNER FUNCTIONS */

function setName(string memory newName) external onlyOwner {
_name = newName;

emit EventsLib.SetName(newName);
}

function setSymbol(string memory newSymbol) external onlyOwner {
_symbol = newSymbol;

emit EventsLib.SetSymbol(newSymbol);
}

/// @inheritdoc IMetaMorphoBase
function setCurator(address newCurator) external onlyOwner {
if (newCurator == curator) revert ErrorsLib.AlreadySet();
Expand Down Expand Up @@ -501,6 +526,14 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph
return ERC4626.decimals();
}

function name() public view override(IERC20Metadata, ERC20) returns (string memory) {
return _name;
}

function symbol() public view override(IERC20Metadata, ERC20) returns (string memory) {
return _symbol;
}

/// @inheritdoc IERC4626
/// @dev Warning: May be higher than the actual max deposit due to duplicate markets in the supplyQueue.
function maxDeposit(address) public view override returns (uint256) {
Expand Down
2 changes: 1 addition & 1 deletion src/MetaMorphoFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity 0.8.21;
pragma solidity 0.8.26;

import {IMetaMorpho} from "./interfaces/IMetaMorpho.sol";
import {IMetaMorphoFactory} from "./interfaces/IMetaMorphoFactory.sol";
Expand Down
6 changes: 6 additions & 0 deletions src/interfaces/IMetaMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ interface IMetaMorphoBase {
/// @dev Does not revert if there is no pending market removal.
function revokePendingMarketRemoval(Id id) external;

/// @notice Sets the name of the vault.
function setName(string memory newName) external;

/// @notice Sets the symbol of the vault.
function setSymbol(string memory newSymbol) external;

/// @notice Submits a `newGuardian`.
/// @notice Warning: a malicious guardian could disrupt the vault's operation, and would have the power to revoke
/// any pending guardian.
Expand Down
6 changes: 6 additions & 0 deletions src/libraries/EventsLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import {PendingAddress} from "./PendingLib.sol";
/// @custom:contact security@morpho.org
/// @notice Library exposing events.
library EventsLib {
/// @notice Emitted when the name of the vault is set.
event SetName(string name);

/// @notice Emitted when the symbol of the vault is set.
event SetSymbol(string symbol);

/// @notice Emitted when a pending `newTimelock` is submitted.
event SubmitTimelock(uint256 newTimelock);

Expand Down
Loading

0 comments on commit 632dd01

Please sign in to comment.