|
@@ -18,11 +18,11 @@ library SafeERC20 {
|
|
|
using Address for address;
|
|
|
|
|
|
function safeTransfer(IERC20 token, address to, uint256 value) internal {
|
|
|
- callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
|
|
|
+ _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
|
|
|
}
|
|
|
|
|
|
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
|
|
|
- callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
|
|
|
+ _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
|
|
|
}
|
|
|
|
|
|
function safeApprove(IERC20 token, address spender, uint256 value) internal {
|
|
@@ -33,17 +33,17 @@ library SafeERC20 {
|
|
|
require((value == 0) || (token.allowance(address(this), spender) == 0),
|
|
|
"SafeERC20: approve from non-zero to non-zero allowance"
|
|
|
);
|
|
|
- callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
|
|
|
+ _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
|
|
|
}
|
|
|
|
|
|
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
|
|
|
uint256 newAllowance = token.allowance(address(this), spender).add(value);
|
|
|
- callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
|
|
|
+ _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
|
|
|
}
|
|
|
|
|
|
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
|
|
|
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
|
|
|
- callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
|
|
|
+ _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -52,7 +52,7 @@ library SafeERC20 {
|
|
|
* @param token The token targeted by the call.
|
|
|
* @param data The call data (encoded using abi.encode or one of its variants).
|
|
|
*/
|
|
|
- function callOptionalReturn(IERC20 token, bytes memory data) private {
|
|
|
+ function _callOptionalReturn(IERC20 token, bytes memory data) private {
|
|
|
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
|
|
|
// we're implementing it ourselves.
|
|
|
|