Skip to content

Commit 60b9239

Browse files
authored
Merge pull request #447 from morpho-org/chore/foundry-v1.4.1
Foundry v1.4.1
2 parents 380bf7b + 90bfc4c commit 60b9239

File tree

10 files changed

+77
-57
lines changed

10 files changed

+77
-57
lines changed

foundry.lock

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"lib/erc4626-tests": {
3+
"rev": "232ff9ba8194e406967f52ecc5cb52ed764209e9"
4+
},
5+
"lib/forge-std": {
6+
"rev": "bf909b22fa55e244796dfa920c9639fdffa1c545"
7+
},
8+
"lib/morpho-blue": {
9+
"rev": "e701e7ea524633682f81e355bec0d7c88fe02f65"
10+
},
11+
"lib/morpho-blue-irm": {
12+
"rev": "a7d9cce3451b4a106bfd40933ac57a785b5228f3"
13+
},
14+
"lib/openzeppelin-contracts": {
15+
"rev": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0"
16+
}
17+
}

foundry.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@ optimizer = true
88
optimizer_runs = 200
99
bytecode_hash = "none"
1010

11-
[profile.default.rpc_endpoints]
11+
[rpc_endpoints]
1212
mainnet = "https://eth-mainnet.g.alchemy.com/v2/${ALCHEMY_KEY}"
1313
tenderly = "https://rpc.tenderly.co/fork/${TENDERLY_FORK_ID}"
1414

1515
[profile.default.fmt]
1616
wrap_comments = true
1717

18+
[lint]
19+
exclude_lints = [
20+
"unaliased-plain-import",
21+
"unused-import",
22+
"erc20-unchecked-transfer",
23+
"unwrapped-modifier-logic",
24+
"mixed-case-variable",
25+
"unsafe-typecast",
26+
"asm-keccak256",
27+
]
28+
1829
[profile.no_via_ir]
1930
via-ir = false
2031

src/MetaMorpho.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,7 @@ contract MetaMorpho is ERC4626, ERC20Permit, Ownable2Step, Multicall, IMetaMorph
467467
}
468468

469469
/// @inheritdoc IMetaMorphoBase
470-
function acceptCap(MarketParams memory marketParams)
471-
external
472-
afterTimelock(pendingCap[marketParams.id()].validAt)
473-
{
470+
function acceptCap(MarketParams memory marketParams) external afterTimelock(pendingCap[marketParams.id()].validAt) {
474471
Id id = marketParams.id();
475472

476473
// Safe "unchecked" cast because pendingCap <= type(uint184).max.

src/MetaMorphoFactory.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ contract MetaMorphoFactory is IMetaMorphoFactory {
4545
string memory symbol,
4646
bytes32 salt
4747
) external returns (IMetaMorpho metaMorpho) {
48-
metaMorpho =
49-
IMetaMorpho(address(new MetaMorpho{salt: salt}(initialOwner, MORPHO, initialTimelock, asset, name, symbol)));
48+
metaMorpho = IMetaMorpho(
49+
address(new MetaMorpho{salt: salt}(initialOwner, MORPHO, initialTimelock, asset, name, symbol))
50+
);
5051

5152
isMetaMorpho[address(metaMorpho)] = true;
5253

src/mocks/ERC1820Registry.sol

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
*
2929
*/
3030
pragma solidity ^0.8.0;
31+
3132
// IV is value needed to have a vanity address starting with '0x1820'.
3233
// IV: 53759
3334

@@ -205,15 +206,14 @@ contract ERC1820Registry {
205206
mstore(x, erc165ID) // Place signature at beginning of empty storage
206207
mstore(add(x, 0x04), _interfaceId) // Place first argument directly next to signature
207208

208-
success :=
209-
staticcall(
210-
30000, // 30k gas
211-
_contract, // To addr
212-
x, // Inputs are stored at location x
213-
0x24, // Inputs are 36 (4 + 32) bytes long
214-
x, // Store output over input (saves space)
215-
0x20 // Outputs are 32 bytes long
216-
)
209+
success := staticcall(
210+
30000, // 30k gas
211+
_contract, // To addr
212+
x, // Inputs are stored at location x
213+
0x24, // Inputs are 36 (4 + 32) bytes long
214+
x, // Store output over input (saves space)
215+
0x20 // Outputs are 32 bytes long
216+
)
217217

218218
result := mload(x) // Load the result
219219
}

src/mocks/ERC777Mock.sol

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,7 @@ contract ERC777 is Context, IERC777, IERC20 {
296296
* - if `account` is a contract, it must implement the {IERC777Recipient}
297297
* interface.
298298
*/
299-
function _mint(address account, uint256 amount, bytes memory userData, bytes memory operatorData)
300-
internal
301-
virtual
302-
{
299+
function _mint(address account, uint256 amount, bytes memory userData, bytes memory operatorData) internal virtual {
303300
_mint(account, amount, userData, operatorData, true);
304301
}
305302

test/forge/ReallocateIdleTest.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ contract ReallocateIdleTest is IntegrationTest {
3434
suppliedAssets[1] = bound(suppliedAssets[1], 1, CAP2);
3535
suppliedAssets[2] = bound(suppliedAssets[2], 1, CAP2);
3636

37-
allocations.push(MarketAllocation(idleParams, 0));
38-
allocations.push(MarketAllocation(allMarkets[0], suppliedAssets[0]));
39-
allocations.push(MarketAllocation(allMarkets[1], suppliedAssets[1]));
40-
allocations.push(MarketAllocation(allMarkets[2], suppliedAssets[2]));
41-
allocations.push(MarketAllocation(idleParams, type(uint256).max));
37+
allocations.push(MarketAllocation({marketParams: idleParams, assets: 0}));
38+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: suppliedAssets[0]}));
39+
allocations.push(MarketAllocation({marketParams: allMarkets[1], assets: suppliedAssets[1]}));
40+
allocations.push(MarketAllocation({marketParams: allMarkets[2], assets: suppliedAssets[2]}));
41+
allocations.push(MarketAllocation({marketParams: idleParams, assets: type(uint256).max}));
4242

4343
uint256 idleBefore = _idle();
4444

test/forge/ReallocateWithdrawTest.sol

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ contract ReallocateWithdrawTest is IntegrationTest {
3434
}
3535

3636
function testReallocateWithdrawMax() public {
37-
allocations.push(MarketAllocation(allMarkets[0], 0));
38-
allocations.push(MarketAllocation(allMarkets[1], 0));
39-
allocations.push(MarketAllocation(allMarkets[2], 0));
40-
allocations.push(MarketAllocation(idleParams, type(uint256).max));
37+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: 0}));
38+
allocations.push(MarketAllocation({marketParams: allMarkets[1], assets: 0}));
39+
allocations.push(MarketAllocation({marketParams: allMarkets[2], assets: 0}));
40+
allocations.push(MarketAllocation({marketParams: idleParams, assets: type(uint256).max}));
4141

4242
vm.expectEmit();
4343
emit EventsLib.ReallocateWithdraw(
@@ -72,7 +72,7 @@ contract ReallocateWithdrawTest is IntegrationTest {
7272
morpho.supply(allMarkets[0], 1, 0, address(vault), hex"");
7373
vm.stopPrank();
7474

75-
allocations.push(MarketAllocation(allMarkets[0], 0));
75+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: 0}));
7676

7777
vm.prank(ALLOCATOR);
7878
vm.expectRevert(abi.encodeWithSelector(ErrorsLib.MarketNotEnabled.selector, allMarkets[0].id()));
@@ -95,11 +95,11 @@ contract ReallocateWithdrawTest is IntegrationTest {
9595
assets[1] = morpho.expectedSupplyAssets(allMarkets[1], address(vault));
9696
assets[2] = morpho.expectedSupplyAssets(allMarkets[2], address(vault));
9797

98-
allocations.push(MarketAllocation(idleParams, 0));
99-
allocations.push(MarketAllocation(allMarkets[0], newAssets[0]));
100-
allocations.push(MarketAllocation(allMarkets[1], newAssets[1]));
101-
allocations.push(MarketAllocation(allMarkets[2], newAssets[2]));
102-
allocations.push(MarketAllocation(idleParams, type(uint256).max));
98+
allocations.push(MarketAllocation({marketParams: idleParams, assets: 0}));
99+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: newAssets[0]}));
100+
allocations.push(MarketAllocation({marketParams: allMarkets[1], assets: newAssets[1]}));
101+
allocations.push(MarketAllocation({marketParams: allMarkets[2], assets: newAssets[2]}));
102+
allocations.push(MarketAllocation({marketParams: idleParams, assets: type(uint256).max}));
103103

104104
uint256 expectedIdle = _idle() + 3 * CAP2 - newAssets[0] - newAssets[1] - newAssets[2];
105105

@@ -141,9 +141,9 @@ contract ReallocateWithdrawTest is IntegrationTest {
141141
function testReallocateWithdrawIncreaseSupply() public {
142142
_setCap(allMarkets[2], 3 * CAP2);
143143

144-
allocations.push(MarketAllocation(allMarkets[0], 0));
145-
allocations.push(MarketAllocation(allMarkets[1], 0));
146-
allocations.push(MarketAllocation(allMarkets[2], 3 * CAP2));
144+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: 0}));
145+
allocations.push(MarketAllocation({marketParams: allMarkets[1], assets: 0}));
146+
allocations.push(MarketAllocation({marketParams: allMarkets[2], assets: 3 * CAP2}));
147147

148148
vm.expectEmit();
149149
emit EventsLib.ReallocateWithdraw(
@@ -175,25 +175,25 @@ contract ReallocateWithdrawTest is IntegrationTest {
175175

176176
_setCap(allMarkets[1], 0);
177177

178-
allocations.push(MarketAllocation(allMarkets[0], 0));
179-
allocations.push(MarketAllocation(allMarkets[1], 0));
180-
allocations.push(MarketAllocation(allMarkets[2], 0));
178+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: 0}));
179+
allocations.push(MarketAllocation({marketParams: allMarkets[1], assets: 0}));
180+
allocations.push(MarketAllocation({marketParams: allMarkets[2], assets: 0}));
181181

182-
allocations.push(MarketAllocation(allMarkets[0], suppliedAssets[0]));
183-
allocations.push(MarketAllocation(allMarkets[1], suppliedAssets[1]));
184-
allocations.push(MarketAllocation(allMarkets[2], suppliedAssets[2]));
182+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: suppliedAssets[0]}));
183+
allocations.push(MarketAllocation({marketParams: allMarkets[1], assets: suppliedAssets[1]}));
184+
allocations.push(MarketAllocation({marketParams: allMarkets[2], assets: suppliedAssets[2]}));
185185

186186
vm.prank(ALLOCATOR);
187187
vm.expectRevert(abi.encodeWithSelector(ErrorsLib.UnauthorizedMarket.selector, allMarkets[1].id()));
188188
vault.reallocate(allocations);
189189
}
190190

191191
function testReallocateSupplyCapExceeded() public {
192-
allocations.push(MarketAllocation(allMarkets[0], 0));
193-
allocations.push(MarketAllocation(allMarkets[1], 0));
194-
allocations.push(MarketAllocation(allMarkets[2], 0));
192+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: 0}));
193+
allocations.push(MarketAllocation({marketParams: allMarkets[1], assets: 0}));
194+
allocations.push(MarketAllocation({marketParams: allMarkets[2], assets: 0}));
195195

196-
allocations.push(MarketAllocation(allMarkets[0], CAP2 + 1));
196+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: CAP2 + 1}));
197197

198198
vm.prank(ALLOCATOR);
199199
vm.expectRevert(abi.encodeWithSelector(ErrorsLib.SupplyCapExceeded.selector, allMarkets[0].id()));
@@ -207,8 +207,8 @@ contract ReallocateWithdrawTest is IntegrationTest {
207207

208208
_setCap(allMarkets[0], type(uint184).max);
209209

210-
allocations.push(MarketAllocation(idleParams, 0));
211-
allocations.push(MarketAllocation(allMarkets[0], 2 * CAP2 + rewards));
210+
allocations.push(MarketAllocation({marketParams: idleParams, assets: 0}));
211+
allocations.push(MarketAllocation({marketParams: allMarkets[0], assets: 2 * CAP2 + rewards}));
212212

213213
vm.prank(ALLOCATOR);
214214
vm.expectRevert(ErrorsLib.InconsistentReallocation.selector);

test/forge/helpers/BaseTest.sol

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,7 @@ contract BaseTest is Test {
7474
irm.setApr(0.5 ether); // 50%.
7575

7676
idleParams = MarketParams({
77-
loanToken: address(loanToken),
78-
collateralToken: address(0),
79-
oracle: address(0),
80-
irm: address(irm),
81-
lltv: 0
77+
loanToken: address(loanToken), collateralToken: address(0), oracle: address(0), irm: address(irm), lltv: 0
8278
});
8379

8480
vm.startPrank(MORPHO_OWNER);

test/forge/helpers/IntegrationTest.sol

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ contract IntegrationTest is BaseTest {
5151
string memory name,
5252
string memory symbol
5353
) public returns (IMetaMorpho) {
54-
return
55-
IMetaMorpho(deployCode("MetaMorpho.sol", abi.encode(owner, morpho, initialTimelock, asset, name, symbol)));
54+
return IMetaMorpho(
55+
deployCode("MetaMorpho.sol", abi.encode(owner, morpho, initialTimelock, asset, name, symbol))
56+
);
5657
}
5758

5859
function _idle() internal view returns (uint256) {

0 commit comments

Comments
 (0)