remove SafeERC20 dependency

This commit is contained in:
andyk 2020-06-02 18:16:27 +03:00
parent f3597f670f
commit 268e749a6d
9 changed files with 12 additions and 26 deletions

View File

@ -2,7 +2,6 @@
pragma solidity ^0.6.8; pragma solidity ^0.6.8;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "../libraries/UniversalERC20.sol"; import "../libraries/UniversalERC20.sol";
import "../mocks/tokens/MintableERC20.sol"; import "../mocks/tokens/MintableERC20.sol";
@ -14,9 +13,8 @@ import "../mocks/tokens/MintableERC20.sol";
/// - Mints the tokenToBurn /// - Mints the tokenToBurn
/// - Sends back the tokenToBurn /// - Sends back the tokenToBurn
contract MockKyberProxy { contract MockKyberProxy {
using SafeERC20 for IERC20;
using SafeERC20 for MintableERC20;
using UniversalERC20 for IERC20; using UniversalERC20 for IERC20;
using UniversalERC20 for MintableERC20;
/// @notice The token which the msg.sender of tradeWithHint will burn /// @notice The token which the msg.sender of tradeWithHint will burn
MintableERC20 public tokenToBurn; MintableERC20 public tokenToBurn;
@ -38,9 +36,9 @@ contract MockKyberProxy {
) external payable returns (uint256) { ) external payable returns (uint256) {
require(tokenToBurn.mint(1 ether), "TRADE_WITH_HINT. Reverted mint()"); require(tokenToBurn.mint(1 ether), "TRADE_WITH_HINT. Reverted mint()");
if (!_fromToken.isETH()) { if (!_fromToken.isETH()) {
_fromToken.safeTransferFrom(msg.sender, address(this), _amount); _fromToken.universalTransferFrom(msg.sender, address(this), _amount, false);
} }
tokenToBurn.safeTransfer(msg.sender, 1 ether); tokenToBurn.universalTransfer(msg.sender, 1 ether);
return 1 ether; return 1 ether;
} }
} }

View File

@ -2,7 +2,6 @@
pragma solidity ^0.6.8; pragma solidity ^0.6.8;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "../mocks/tokens/MintableERC20.sol"; import "../mocks/tokens/MintableERC20.sol";
@ -10,8 +9,7 @@ import "../interfaces/IOneSplit.sol";
import "../libraries/UniversalERC20.sol"; import "../libraries/UniversalERC20.sol";
contract MockOneSplit is IOneSplit { contract MockOneSplit is IOneSplit {
using SafeERC20 for IERC20; using UniversalERC20 for MintableERC20;
using SafeERC20 for MintableERC20;
using UniversalERC20 for IERC20; using UniversalERC20 for IERC20;
MintableERC20 public tokenToBurn; MintableERC20 public tokenToBurn;
@ -57,8 +55,8 @@ contract MockOneSplit is IOneSplit {
) public override payable { ) public override payable {
require(tokenToBurn.mint(10000 ether), "TRADE_WITH_HINT. Reverted mint()"); require(tokenToBurn.mint(10000 ether), "TRADE_WITH_HINT. Reverted mint()");
if (!fromToken.isETH()) { if (!fromToken.isETH()) {
fromToken.safeTransferFrom(msg.sender, address(this), amount); fromToken.universalTransferFrom(msg.sender, address(this), amount, false);
} }
tokenToBurn.safeTransfer(msg.sender, 10000 ether); tokenToBurn.universalTransfer(msg.sender, 10000 ether);
} }
} }

View File

@ -39,7 +39,7 @@ contract OneSplitAdapter is IExchangeAdapter {
function approveExchange(IERC20[] calldata _tokens) external override { function approveExchange(IERC20[] calldata _tokens) external override {
for (uint256 i = 0; i < _tokens.length; i++) { for (uint256 i = 0; i < _tokens.length; i++) {
if (!_tokens[i].isETH()) { if (!_tokens[i].isETH()) {
_tokens[i].safeApprove(0x1814222fa8c8c1C1bf380e3BBFBd9De8657Da476, UintConstants.maxUintMinus1()); _tokens[i].universalApprove(0x1814222fa8c8c1C1bf380e3BBFBd9De8657Da476, UintConstants.maxUintMinus1());
} }
} }
} }

View File

@ -3,7 +3,6 @@ pragma solidity ^0.6.8;
import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol"; import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol"; import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
@ -25,7 +24,6 @@ import "../libraries/UniversalERC20.sol";
/// and burn it (sending to address(0) the tokenToBurn) /// and burn it (sending to address(0) the tokenToBurn)
contract TokenDistributor is ReentrancyGuard, VersionedInitializable { contract TokenDistributor is ReentrancyGuard, VersionedInitializable {
using SafeMath for uint256; using SafeMath for uint256;
using SafeERC20 for IERC20;
using UniversalERC20 for IERC20; using UniversalERC20 for IERC20;
struct Distribution { struct Distribution {

View File

@ -3,14 +3,12 @@ pragma solidity ^0.6.8;
import "@openzeppelin/contracts/math/SafeMath.sol"; import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "../interfaces/IFlashLoanReceiver.sol"; import "../interfaces/IFlashLoanReceiver.sol";
import "../../interfaces/ILendingPoolAddressesProvider.sol"; import "../../interfaces/ILendingPoolAddressesProvider.sol";
import "../../libraries/UniversalERC20.sol"; import "../../libraries/UniversalERC20.sol";
abstract contract FlashLoanReceiverBase is IFlashLoanReceiver { abstract contract FlashLoanReceiverBase is IFlashLoanReceiver {
using SafeERC20 for IERC20;
using UniversalERC20 for IERC20; using UniversalERC20 for IERC20;
using SafeMath for uint256; using SafeMath for uint256;

View File

@ -2,13 +2,10 @@
pragma solidity ^0.6.8; pragma solidity ^0.6.8;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "../libraries/UintConstants.sol"; import "../libraries/UintConstants.sol";
interface IExchangeAdapter { interface IExchangeAdapter {
using SafeERC20 for IERC20;
event Exchange( event Exchange(
address indexed from, address indexed from,
address indexed to, address indexed to,

View File

@ -444,9 +444,6 @@ contract LendingPoolCore is VersionedInitializable {
); );
} else { } else {
require(msg.value >= _amount, "The amount and the value sent to deposit do not match"); require(msg.value >= _amount, "The amount and the value sent to deposit do not match");
//solium-disable-next-line
(bool result, ) = _feeAddress.call{ value: _amount, gas: 50000}("");
require(result, "Transfer of ETH failed");
} }
IERC20(_token).universalTransferFrom( IERC20(_token).universalTransferFrom(
_user, _user,

View File

@ -26,7 +26,7 @@ library UniversalERC20 {
if (isETH(token)) { if (isETH(token)) {
(bool result, ) = payable(to).call{value: amount, gas: 50000}(""); (bool result, ) = payable(to).call{value: amount, gas: 50000}("");
require(result, "Transfer of ETH failed"); require(result, "ETH_TRANSFER_FAILED");
} else { } else {
token.safeTransfer(to, amount); token.safeTransfer(to, amount);
} }
@ -53,14 +53,14 @@ library UniversalERC20 {
(bool result, ) = payable(to).call{value: amount, gas: 50000}( (bool result, ) = payable(to).call{value: amount, gas: 50000}(
"" ""
); );
require(result, "Transfer of ETH failed"); require(result, "ETH_TRANSFER_FAILED");
} }
if (returnExcess && msg.value > amount) { if (returnExcess && msg.value > amount) {
(bool result, ) = msg.sender.call{ (bool result, ) = msg.sender.call{
value: msg.value.sub(amount), value: msg.value.sub(amount),
gas: 50000 gas: 50000
}(""); }("");
require(result, "Transfer of ETH failed"); require(result, "ETH_TRANSFER_FAILED");
} }
} else { } else {
token.safeTransferFrom(from, to, amount); token.safeTransferFrom(from, to, amount);
@ -81,7 +81,7 @@ library UniversalERC20 {
value: msg.value.sub(amount), value: msg.value.sub(amount),
gas: 50000 gas: 50000
}(""); }("");
require(result, "Transfer of ETH failed"); require(result, "ETH_TRANSFER_FAILED");
} }
} else { } else {
token.safeTransferFrom(msg.sender, address(this), amount); token.safeTransferFrom(msg.sender, address(this), amount);

View File

@ -6,7 +6,7 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../flashloan/base/FlashLoanReceiverBase.sol"; import "../../flashloan/base/FlashLoanReceiverBase.sol";
import "../tokens/MintableERC20.sol"; import "../tokens/MintableERC20.sol";
import "../libraries/UniversalERC20.sol"; import "../../libraries/UniversalERC20.sol";
contract MockFlashLoanReceiver is FlashLoanReceiverBase { contract MockFlashLoanReceiver is FlashLoanReceiverBase {