There are several duplicate calls or storage access that can be cached. For example, here, iSYNTH(_synth).TOKEN() is called twice:
uint _weight = iUTILS(UTILS()).calcValueInBase(iSYNTH(_synth).TOKEN(), _amount);
if(iPOOLS(POOLS).isAnchor(iSYNTH(_synth).TOKEN())
or here it calculates _value.sub(_fee) twice:
// Get fee amount
_balances[_to] += (_value.sub(_fee));
...
emit Transfer(_from, _to, (_value.sub(_fee)));
or:
uint _synthUnits = iUTILS(UTILS()).calcSynthUnits(_actualInputBase, mapToken_baseAmount[token], mapToken_Units[token]); // Get Units
outputAmount = iUTILS(UTILS()).calcSwapOutput(_actualInputBase, mapToken_baseAmount[token], mapToken_tokenAmount[token]); // Get output
Handle
paulius.eth
Vulnerability details
Impact
There are several duplicate calls or storage access that can be cached. For example, here, iSYNTH(_synth).TOKEN() is called twice: uint _weight = iUTILS(UTILS()).calcValueInBase(iSYNTH(_synth).TOKEN(), _amount); if(iPOOLS(POOLS).isAnchor(iSYNTH(_synth).TOKEN()) or here it calculates _value.sub(_fee) twice: // Get fee amount _balances[_to] += (_value.sub(_fee)); ... emit Transfer(_from, _to, (_value.sub(_fee))); or: uint _synthUnits = iUTILS(UTILS()).calcSynthUnits(_actualInputBase, mapToken_baseAmount[token], mapToken_Units[token]); // Get Units outputAmount = iUTILS(UTILS()).calcSwapOutput(_actualInputBase, mapToken_baseAmount[token], mapToken_tokenAmount[token]); // Get output