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

0 stars 0 forks source link

Gas optimization on `_depositToAave` #122

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

shw

Vulnerability details

Impact

The function _depositToAave of ATokenYieldSource calls _lendingPool and _tokenAddress twice, both of which include function calls to external contracts. Thus, storing the first results into local variables and reuse them for the second time could help save gas.

Proof of Concept

Referenced code: ATokenYieldSource.sol#L175-L182

Recommended Mitigation Steps

Store the result of _tokenAddress() and _lendingPool() to local variables and resue them.

PierrickGT commented 3 years ago

PR: https://github.com/pooltogether/aave-yield-source/pull/15