-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from morpho-org/revert-240-refactor/interfaces
Revert "Refactor interfaces"
- Loading branch information
Showing
6 changed files
with
98 additions
and
118 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 |
---|---|---|
|
@@ -3,11 +3,7 @@ pragma solidity 0.8.21; | |
|
||
import {IMorphoMarketParams} from "./interfaces/IMorphoMarketParams.sol"; | ||
import { | ||
MarketConfig, | ||
PendingUint192, | ||
PendingAddress, | ||
MarketAllocation, | ||
IMetaMorphoStaticTyping | ||
IMetaMorpho, MarketConfig, PendingUint192, PendingAddress, MarketAllocation | ||
} from "./interfaces/IMetaMorpho.sol"; | ||
import {Id, MarketParams, Market, IMorpho} from "@morpho-blue/interfaces/IMorpho.sol"; | ||
|
||
|
@@ -32,7 +28,7 @@ import {IERC20, IERC4626, ERC20, ERC4626, Math, SafeERC20} from "@openzeppelin/t | |
/// @author Morpho Labs | ||
/// @custom:contact [email protected] | ||
/// @notice ERC4626 compliant vault allowing users to deposit assets to Morpho. | ||
contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorphoStaticTyping { | ||
contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorpho { | ||
using Math for uint256; | ||
using UtilsLib for uint256; | ||
using SafeCast for uint256; | ||
|
@@ -471,40 +467,44 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph | |
/* ERC4626 (PUBLIC) */ | ||
|
||
/// @inheritdoc IERC20Metadata | ||
function decimals() public view override(ERC20, ERC4626) returns (uint8) { | ||
function decimals() public view override(IERC20Metadata, ERC20, ERC4626) returns (uint8) { | ||
return ERC4626.decimals(); | ||
} | ||
|
||
/// @inheritdoc IERC4626 | ||
function maxWithdraw(address owner) public view override returns (uint256 assets) { | ||
function maxWithdraw(address owner) public view override(IERC4626, ERC4626) returns (uint256 assets) { | ||
(assets,,) = _maxWithdraw(owner); | ||
} | ||
|
||
/// @inheritdoc IERC4626 | ||
function maxRedeem(address owner) public view override returns (uint256) { | ||
function maxRedeem(address owner) public view override(IERC4626, ERC4626) returns (uint256) { | ||
(uint256 assets, uint256 newTotalSupply, uint256 newTotalAssets) = _maxWithdraw(owner); | ||
|
||
return _convertToSharesWithTotals(assets, newTotalSupply, newTotalAssets, Math.Rounding.Floor); | ||
} | ||
|
||
/// @inheritdoc IERC4626 | ||
function deposit(uint256 assets, address receiver) public override returns (uint256 shares) { | ||
function deposit(uint256 assets, address receiver) public override(IERC4626, ERC4626) returns (uint256 shares) { | ||
uint256 newTotalAssets = _accrueFee(); | ||
|
||
shares = _convertToSharesWithTotals(assets, totalSupply(), newTotalAssets, Math.Rounding.Floor); | ||
_deposit(_msgSender(), receiver, assets, shares); | ||
} | ||
|
||
/// @inheritdoc IERC4626 | ||
function mint(uint256 shares, address receiver) public override returns (uint256 assets) { | ||
function mint(uint256 shares, address receiver) public override(IERC4626, ERC4626) returns (uint256 assets) { | ||
uint256 newTotalAssets = _accrueFee(); | ||
|
||
assets = _convertToAssetsWithTotals(shares, totalSupply(), newTotalAssets, Math.Rounding.Ceil); | ||
_deposit(_msgSender(), receiver, assets, shares); | ||
} | ||
|
||
/// @inheritdoc IERC4626 | ||
function withdraw(uint256 assets, address receiver, address owner) public override returns (uint256 shares) { | ||
function withdraw(uint256 assets, address receiver, address owner) | ||
public | ||
override(IERC4626, ERC4626) | ||
returns (uint256 shares) | ||
{ | ||
uint256 newTotalAssets = _accrueFee(); | ||
|
||
// Do not call expensive `maxWithdraw` and optimistically withdraw assets. | ||
|
@@ -514,7 +514,11 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph | |
} | ||
|
||
/// @inheritdoc IERC4626 | ||
function redeem(uint256 shares, address receiver, address owner) public override returns (uint256 assets) { | ||
function redeem(uint256 shares, address receiver, address owner) | ||
public | ||
override(IERC4626, ERC4626) | ||
returns (uint256 assets) | ||
{ | ||
uint256 newTotalAssets = _accrueFee(); | ||
|
||
// Do not call expensive `maxRedeem` and optimistically redeem shares. | ||
|
@@ -524,7 +528,7 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph | |
} | ||
|
||
/// @inheritdoc IERC4626 | ||
function totalAssets() public view override returns (uint256 assets) { | ||
function totalAssets() public view override(IERC4626, ERC4626) returns (uint256 assets) { | ||
for (uint256 i; i < withdrawQueue.length; ++i) { | ||
assets += _supplyBalance(_marketParams(withdrawQueue[i])); | ||
} | ||
|
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
Oops, something went wrong.