code-423n4 / 2021-12-yetifinance-findings

0 stars 0 forks source link

Check if amount > 0 before token transfer can save gas #273

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Handle

WatchPug

Vulnerability details

https://github.com/code-423n4/2021-12-yetifinance/blob/5f5bf61209b722ba568623d8446111b1ea5cb61c/packages/contracts/contracts/TroveManagerRedemptions.sol#L228-L233

// send fee from user to YETI stakers
contractsCache.yusdToken.transferFrom(
    _redeemer,
    address(contractsCache.sYETI),
    totals.YUSDfee
);

Since totals.YUSDfee can be 0. Checking if (totals.YUSDfee > 0) before the transfer can potentially save an external call and the unnecessary gas cost of a 0 token transfer.

kingyetifinance commented 2 years ago

Duplicate #171