Skip to content
Request an audit

‹ All findings

Midnight constructor can use msg.sender instead of reading roleSetter from storage

Low/InfoMorpho Midnight·Blackthorn · Lending · 6th April, 2026CodebaseL-2

Summary

The constructor emits roleSetter (an SLOAD) in the event instead of msg.sender, wasting gas since they are the same value.

Vulnerability Detail

In the constructor:

solidity
constructor() {
    roleSetter = msg.sender;
    emit EventsLib.Constructor(roleSetter);
}

roleSetter was just assigned msg.sender, so the emit reads back from storage instead of using the already-available msg.sender from the calldata.

Impact

Wastes gas on an unnecessary SLOAD in the constructor.

Code Snippet

https://github.com/sherlock-audit/2026-04-morpho-midnight-apr-6th-2026/blob/main/morpho-org__midnight/src/Midnight.sol#L133-L136

Tool Used

Manual Review

Recommendation

solidity
constructor() {
    roleSetter = msg.sender;
    emit EventsLib.Constructor(msg.sender);
}