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

1 stars 0 forks source link

[Gas] Do not send value if holdingsValue is 0 #60

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Vulnerability details

Gas optimization suggestion:

Here it is better to replace ">=" with ">" as sending 0 is a waste of gas (similar code is also used in CrossMarginLiquidation): // send back trader money if (holdingsValue >= maintainerCut4Account + account.borrowed) { // send remaining funds back to trader Fund(fund()).withdraw( borrowToken, traderAddress, holdingsValue - account.borrowed - maintainerCut4Account ); }

Eth address

0x523B5b2Cc58A818667C22c862930B141f85d49DD

Handle

paulius.eth

Email address

pauliax6@gmail.com