code-423n4 / 2021-04-vader-findings

1 stars 0 forks source link

Cache duplicate calls or storage access #291

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

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