Gas optimization on BadgerYieldSource
#108
Labels
bug
Something isn't working
duplicate
This issue or pull request already exists
G (Gas Optimization)
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.The text was updated successfully, but these errors were encountered: