The Exchange.sol removeLiquidity() function calls this.totalSupply() twice. To save gas, call it once and set the value to a variable, because using a variable is cheaper than a second function call.
Move line 187, shown below, to a line before the require statement. Modify the require statement to reference the variable. The end result will look like:
Handle
sirhashalot
Vulnerability details
Impact
The Exchange.sol
removeLiquidity()
function calls this.totalSupply() twice. To save gas, call it once and set the value to a variable, because using a variable is cheaper than a second function call.Proof of Concept
There are two calls to this.totalSupply() in
removeLiquidity()
Recommended Mitigation Steps
Move line 187, shown below, to a line before the require statement. Modify the require statement to reference the variable. The end result will look like: