The redeemToken function in BadgerYieldSource can be designed as more gas-efficient by reusing local variables.
Proof of Concept
Variables badgerSett and badger in the BadgerYieldSource are currently declared private. However, a similar implementation, SushiYieldSource, declares sushiBar and sushiAddr public. Suppose the badgerSett and badger in BadgerYieldSource are needed to be declared public. In that case, the redeemToken function can be more gas-efficient by reading these two state variables into local variables first and then reusing them, as written in the redeemToken function of SushiYieldSource contract.
Handle
shw
Vulnerability details
Impact
The
redeemToken
function inBadgerYieldSource
can be designed as more gas-efficient by reusing local variables.Proof of Concept
Variables
badgerSett
andbadger
in theBadgerYieldSource
are currently declaredprivate
. However, a similar implementation,SushiYieldSource
, declaressushiBar
andsushiAddr
public. Suppose thebadgerSett
andbadger
inBadgerYieldSource
are needed to be declaredpublic
. In that case, theredeemToken
function can be more gas-efficient by reading these two state variables into local variables first and then reusing them, as written in theredeemToken
function ofSushiYieldSource
contract.Referenced code: BadgerYieldSource.sol#L15-L16 BadgerYieldSource.sol#L57-L81 SushiYieldSource.sol#L17-L18 SushiYieldSource.sol#L66-L92
Recommended Mitigation Steps
Let
badgerSett
andbadger
bepublic
and re-write theredeemToken
function in theBadgerYieldSource
contract.