use safe erc20 & new logGas
This commit is contained in:
@@ -45,6 +45,22 @@ library SafeERC20 {
|
||||
);
|
||||
}
|
||||
|
||||
function safeApprove(
|
||||
IERC20 token,
|
||||
address spender,
|
||||
uint256 value
|
||||
) internal {
|
||||
// safeApprove should only be called when setting an initial allowance,
|
||||
// or when resetting it to zero. To increase and decrease it, use
|
||||
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
|
||||
// solhint-disable-next-line max-line-length
|
||||
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));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
|
||||
* on the return value: the return value is optional (but if data is returned, it must not be false).
|
||||
|
||||
Reference in New Issue
Block a user