code-423n4 / 2021-07-pooltogether-findings

0 stars 0 forks source link

[Optimization] Replace an external call with the immutable variable #66

Closed code423n4 closed 3 years ago

code423n4 commented 3 years ago

Handle

hrkrshnn

Vulnerability details

Replace an external call with the immutable variable

Context

@@ -59,7 +59,7 @@ contract MStableYieldSource is IYieldSource, ReentrancyGuard {

     /// @notice Approves of the max spend amount for the Savings contract.
     function approveMax() public {
-        IERC20(savings.underlying()).safeApprove(address(savings), type(uint256).max);
+        mAsset.safeApprove(address(savings), type(uint256).max);

         emit ApprovedMax(msg.sender);
     }

Instead of an expensive external call, the value would be replaced by a cheap push operation.

PierrickGT commented 3 years ago

Duplicate of https://github.com/code-423n4/2021-07-pooltogether-findings/issues/19