diff --git a/src/Vault.sol b/src/Vault.sol index e84029f..f7aa905 100644 --- a/src/Vault.sol +++ b/src/Vault.sol @@ -230,7 +230,7 @@ contract Vault is IVault, ERC4626, ERC20Permit { currentLosses = _calculateLockedLosses() + (assets - loan); latestRepay = block.timestamp; - IERC20(asset()).safeTransfer(receiver, assets); + if (assets > 0) IERC20(asset()).safeTransfer(receiver, assets); emit Borrowed(receiver, assets); @@ -265,7 +265,7 @@ contract Vault is IVault, ERC4626, ERC20Permit { // the vault is not responsible for any payoff // slither-disable-next-line arbitrary-send-erc20 // super.totalAssets() += assets and never overflows by definition - IERC20(asset()).safeTransferFrom(repayer, address(this), assets); + if (assets > 0) IERC20(asset()).safeTransferFrom(repayer, address(this), assets); emit Repaid(repayer, assets, debt); } diff --git a/src/services/credit/CallOption.sol b/src/services/credit/CallOption.sol index 855ba03..4177175 100644 --- a/src/services/credit/CallOption.sol +++ b/src/services/credit/CallOption.sol @@ -209,7 +209,7 @@ contract CallOption is CreditService { toBorrow = toTransfer - redeemed > freeLiquidity ? freeLiquidity : toTransfer - redeemed; } // We will always have ithil.balanceOf(address(this)) >= toCall, so the following succeeds - ithil.safeTransfer(ownerAddress, toCall); + if (toCall > 0) ithil.safeTransfer(ownerAddress, toCall); // repay the user's losses if (toBorrow > 0 && freeLiquidity > 0) manager.borrow(agreement.loans[0].token, toBorrow, 0, ownerAddress); } diff --git a/src/services/debit/GmxService.sol b/src/services/debit/GmxService.sol index 09609ee..0f2374f 100644 --- a/src/services/debit/GmxService.sol +++ b/src/services/debit/GmxService.sol @@ -119,7 +119,7 @@ contract GmxService is AuctionRateModel, DebitService { totalRewards = toTransfer < newRewards ? newRewards - toTransfer : 0; totalCollateral -= agreement.collaterals[0].amount; // Transfer weth: since toTransfer <= totalWithdraw - weth.safeTransfer(msg.sender, toTransfer); + if (toTransfer > 0) weth.safeTransfer(msg.sender, toTransfer); } function wethReward(uint256 tokenID) public view returns (uint256) {