From d22f355ef467532602438887a07b91dde517e42e Mon Sep 17 00:00:00 2001 From: MathisGD Date: Tue, 4 Jul 2023 19:50:25 +0200 Subject: [PATCH] fix: safeTransfer --- src/Market.sol | 4 ++-- src/interfaces/IERC20.sol | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Market.sol b/src/Market.sol index d321e3cc0..50dee219d 100644 --- a/src/Market.sol +++ b/src/Market.sol @@ -155,7 +155,7 @@ contract Blue { collateral[id][msg.sender] += amount; - market.collateralAsset.transferFrom(msg.sender, address(this), amount); + market.collateralAsset.safeTransferFrom(msg.sender, address(this), amount); } function withdrawCollateral(Market calldata market, uint amount) external { @@ -169,7 +169,7 @@ contract Blue { require(isHealthy(market, id, msg.sender), "not enough collateral"); - market.collateralAsset.transfer(msg.sender, amount); + market.collateralAsset.safeTransfer(msg.sender, amount); } // Liquidation. diff --git a/src/interfaces/IERC20.sol b/src/interfaces/IERC20.sol index 5a1f7b909..31f0cc95f 100644 --- a/src/interfaces/IERC20.sol +++ b/src/interfaces/IERC20.sol @@ -1,7 +1,6 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity >=0.5.0; -interface IERC20 { - function transferFrom(address, address, uint) external; - function transfer(address, uint) external; -} +/// @dev Empty because we only call functions in assembly. It prevents calling +/// transfer (transferFrom) instead of safeTransfer (safeTransferFrom). +interface IERC20 {}