Skip to content

Commit

Permalink
Merge remote-tracking branch 'private/feat/no-share-price-decrease-2'…
Browse files Browse the repository at this point in the history
… into feat/no-share-price-decrease-2
  • Loading branch information
MathisGD committed Aug 13, 2024
2 parents 29251fc + 16bf70f commit 5039521
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/certora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
- Immutability
- LastUpdated
- Liveness
- LostAssetsLink
- LostAssetsNoLink
- MarketInteractions
- PendingValues
- Range
Expand All @@ -30,8 +32,6 @@ jobs:
- Roles
- Timelock
- Tokens
- LostAssetsNoLink
- LostAssetsLink

steps:
- uses: actions/checkout@v4
Expand Down
30 changes: 15 additions & 15 deletions certora/applyMunging.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff -ruN interfaces/IMetaMorpho.sol interfaces/IMetaMorpho.sol
--- interfaces/IMetaMorpho.sol 2024-03-20 15:13:25.818251404 +0100
+++ interfaces/IMetaMorpho.sol 2024-03-22 11:22:35.598510490 +0100
--- interfaces/IMetaMorpho.sol 2024-08-12 17:01:51.540516233 +0200
+++ interfaces/IMetaMorpho.sol 2024-08-13 13:46:23.645208968 +0200
@@ -1,9 +1,9 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
Expand All @@ -24,8 +24,8 @@ diff -ruN interfaces/IMetaMorpho.sol interfaces/IMetaMorpho.sol

/// @notice The address of the curator.
diff -ruN libraries/ErrorsLib.sol libraries/ErrorsLib.sol
--- libraries/ErrorsLib.sol 2024-03-20 15:13:25.802251714 +0100
+++ libraries/ErrorsLib.sol 2024-03-22 11:22:35.598510490 +0100
--- libraries/ErrorsLib.sol 2024-08-12 17:00:02.975663176 +0200
+++ libraries/ErrorsLib.sol 2024-08-13 13:46:23.645208968 +0200
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
Expand All @@ -36,8 +36,8 @@ diff -ruN libraries/ErrorsLib.sol libraries/ErrorsLib.sol
/// @title ErrorsLib
/// @author Morpho Labs
diff -ruN libraries/EventsLib.sol libraries/EventsLib.sol
--- libraries/EventsLib.sol 2024-03-20 15:13:25.802251714 +0100
+++ libraries/EventsLib.sol 2024-03-22 11:22:35.598510490 +0100
--- libraries/EventsLib.sol 2024-08-12 17:01:51.540516233 +0200
+++ libraries/EventsLib.sol 2024-08-13 13:46:23.645208968 +0200
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity ^0.8.0;
Expand All @@ -48,8 +48,8 @@ diff -ruN libraries/EventsLib.sol libraries/EventsLib.sol
import {PendingAddress} from "./PendingLib.sol";

diff -ruN MetaMorpho.sol MetaMorpho.sol
--- MetaMorpho.sol 2024-03-20 15:13:25.862250553 +0100
+++ MetaMorpho.sol 2024-03-22 14:27:33.670423544 +0100
--- MetaMorpho.sol 2024-08-12 17:01:51.540516233 +0200
+++ MetaMorpho.sol 2024-08-13 13:46:23.649208876 +0200
@@ -9,24 +9,22 @@
IMetaMorphoBase,
IMetaMorphoStaticTyping
Expand Down Expand Up @@ -114,9 +114,9 @@ diff -ruN MetaMorpho.sol MetaMorpho.sol

/// @notice OpenZeppelin decimals offset used by the ERC4626 implementation.
/// @dev Calculated to be max(0, 18 - underlyingDecimals) at construction, so the initial conversion rate maximizes
@@ -107,6 +103,19 @@
@@ -110,6 +106,19 @@
/// @inheritdoc IMetaMorphoBase
uint256 public lastTotalAssets;
uint256 public lostAssets;

+ // HARNESS
+ // The index of the identifier of the last market withdrawn.
Expand All @@ -134,7 +134,7 @@ diff -ruN MetaMorpho.sol MetaMorpho.sol
/* CONSTRUCTOR */

/// @dev Initializes the contract.
@@ -126,7 +135,7 @@
@@ -129,7 +138,7 @@
) ERC4626(IERC20(_asset)) ERC20Permit(_name) ERC20(_name, _symbol) Ownable(owner) {
if (morpho == address(0)) revert ErrorsLib.ZeroAddress();

Expand All @@ -143,7 +143,7 @@ diff -ruN MetaMorpho.sol MetaMorpho.sol
DECIMALS_OFFSET = uint8(uint256(18).zeroFloorSub(IERC20Metadata(_asset).decimals()));

_checkTimelockBounds(initialTimelock);
@@ -338,6 +347,9 @@
@@ -341,6 +350,9 @@
seen[prevIndex] = true;

newWithdrawQueue[i] = id;
Expand All @@ -153,7 +153,7 @@ diff -ruN MetaMorpho.sol MetaMorpho.sol
}

for (uint256 i; i < currLength; ++i) {
@@ -355,6 +367,10 @@
@@ -358,6 +370,10 @@
}
}

Expand All @@ -164,7 +164,7 @@ diff -ruN MetaMorpho.sol MetaMorpho.sol
delete config[id];
}
}
@@ -743,6 +759,9 @@
@@ -735,6 +751,9 @@

if (supplyCap > 0) {
if (!marketConfig.enabled) {
Expand All @@ -174,7 +174,7 @@ diff -ruN MetaMorpho.sol MetaMorpho.sol
withdrawQueue.push(id);

if (withdrawQueue.length > ConstantsLib.MAX_QUEUE_LENGTH) revert ErrorsLib.MaxQueueLengthExceeded();
@@ -802,6 +821,9 @@
@@ -794,6 +813,9 @@
/// @dev Withdraws `assets` from Morpho.
function _withdrawMorpho(uint256 assets) internal {
for (uint256 i; i < withdrawQueue.length; ++i) {
Expand Down
26 changes: 5 additions & 21 deletions test/forge/LostAssetsTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,17 @@ pragma solidity ^0.8.0;

import "./helpers/IntegrationTest.sol";

contract ModifiedMorpho {
address public owner;
address public feeRecipient;
mapping(bytes32 => mapping(address => Position)) public position;
mapping(bytes32 => Market) public market;

function writeTotalSupplyAssets(bytes32 id, uint128 newValue) external {
market[id].totalSupplyAssets = newValue;
}
}

contract LostAssetsTest is IntegrationTest {
using stdStorage for StdStorage;
using MorphoBalancesLib for IMorpho;
using MarketParamsLib for MarketParams;

bytes modifiedCode = _makeModifiedCode();
bytes normalCode = address(morpho).code;

function _makeModifiedCode() internal returns (bytes memory) {
return address(new ModifiedMorpho()).code;
}

function _writeTotalSupplyAssets(bytes32 id, uint128 newValue) internal {
vm.etch(address(morpho), modifiedCode);
ModifiedMorpho(address(morpho)).writeTotalSupplyAssets(id, newValue);
vm.etch(address(morpho), normalCode);
uint256 marketSlot = 3;
bytes32 totalSupplySlot = keccak256(abi.encode(id, marketSlot));
bytes32 totalSupplyValue = vm.load(address(morpho), totalSupplySlot);
bytes32 newTotalSupplyValue = (totalSupplyValue >> 128 << 128) | bytes32(uint256(newValue));
vm.store(address(morpho), totalSupplySlot, newTotalSupplyValue);
}

function setUp() public override {
Expand Down

0 comments on commit 5039521

Please sign in to comment.