code-423n4 / 2021-10-union-findings

0 stars 0 forks source link

Gas: `AssetManager.getMoneyMarket` use assignment #72

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

cmichel

Vulnerability details

The tokenSupply is increased instead of set to the value directly. This performs an unnecessary addition as tokenSupply is always initialized to zero.

// @audit just do: tokenSupply = ...; as tokenSupply starts at 0
tokenSupply += moneyMarkets[marketId].getSupplyView(tokenAddress);
GalloDaSballo commented 3 years ago

Agree that equal has the same meaning and saves gas