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

Various small improvements #371

Merged
merged 4 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Morpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ contract Morpho is IMorpho {
/// @notice Initializes the contract.
/// @param newOwner The new owner of the contract.
constructor(address newOwner) {
require(newOwner != address(0), ErrorsLib.ZERO_ADDRESS);
MathisGD marked this conversation as resolved.
Show resolved Hide resolved
owner = newOwner;

DOMAIN_SEPARATOR = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256("Morpho"), block.chainid, address(this)));
Expand Down Expand Up @@ -405,6 +406,7 @@ contract Morpho is IMorpho {
/// @inheritdoc IMorpho
/// @dev Warning: reverts if the signature has already been submitted.
/// @dev The signature is malleable, but it has no impact on the security here.
/// @dev The nonce is passed as argument to be able to revert with a different error message.
function setAuthorizationWithSig(Authorization memory authorization, Signature calldata signature) external {
require(block.timestamp < authorization.deadline, ErrorsLib.SIGNATURE_EXPIRED);
require(authorization.nonce == nonce[authorization.authorizer]++, ErrorsLib.INVALID_NONCE);
Expand Down
11 changes: 7 additions & 4 deletions src/interfaces/IMorpho.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ interface IMorpho {
function DOMAIN_SEPARATOR() external view returns (bytes32);

/// @notice The owner of the contract.
/// @dev It has the power to change the owner.
/// @dev It has the power to set fees on markets and set the fee recipient.
/// @dev It has the power to enable but not disable IRMs and LLTVs.
function owner() external view returns (address);

/// @notice The fee recipient.
/// @dev The recipient receives the fees through a supply position.
/// @notice The fee recipient of all markets.
/// @dev The recipient receives the fees of a given market through a supply position on this market.
function feeRecipient() external view returns (address);

/// @notice Users' storage for market `id`.
Expand All @@ -75,8 +78,8 @@ interface IMorpho {
/// @dev Anyone is authorized to modify their own positions, regardless of this variable.
function isAuthorized(address authorizer, address authorized) external view returns (bool);

/// @notice The `user`'s current nonce. Used to prevent replay attacks with EIP-712 signatures.
function nonce(address user) external view returns (uint256);
/// @notice The `authorizer`'s current nonce. Used to prevent replay attacks with EIP-712 signatures.
function nonce(address authorizer) external view returns (uint256);

/// @notice The market params corresponding to `id`.
function idToMarketParams(Id id)
Expand Down
5 changes: 0 additions & 5 deletions src/libraries/MathLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ library MathLib {
return mulDivDown(x, y, WAD);
}

/// @dev (x * y) / WAD rounded up.
function wMulUp(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivUp(x, y, WAD);
}

/// @dev (x * WAD) / y rounded down.
function wDivDown(uint256 x, uint256 y) internal pure returns (uint256) {
return mulDivDown(x, WAD, y);
Expand Down
5 changes: 5 additions & 0 deletions test/forge/integration/TestIntegrationOnlyOwner.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ contract IntegrationOnlyOwnerTest is BaseTest {
using MathLib for uint256;
using MorphoLib for Morpho;

function testDeployWithAddressZero() public {
vm.expectRevert();
MerlinEgalite marked this conversation as resolved.
Show resolved Hide resolved
new Morpho(address(0));
}

function testSetOwnerWhenNotOwner(address addressFuzz) public {
vm.assume(addressFuzz != OWNER);

Expand Down