You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
852 B
44 lines
852 B
pragma solidity ^0.4.24;
|
|
|
|
import "./ERC20.sol";
|
|
import "./IERC20.sol";
|
|
|
|
|
|
/**
|
|
* @title SafeERC20
|
|
* @dev Wrappers around ERC20 operations that throw on failure.
|
|
* To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
|
|
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
|
|
*/
|
|
library SafeERC20 {
|
|
function safeTransfer(
|
|
IERC20 _token,
|
|
address _to,
|
|
uint256 _value
|
|
)
|
|
internal
|
|
{
|
|
require(_token.transfer(_to, _value));
|
|
}
|
|
|
|
function safeTransferFrom(
|
|
IERC20 _token,
|
|
address _from,
|
|
address _to,
|
|
uint256 _value
|
|
)
|
|
internal
|
|
{
|
|
require(_token.transferFrom(_from, _to, _value));
|
|
}
|
|
|
|
function safeApprove(
|
|
IERC20 _token,
|
|
address _spender,
|
|
uint256 _value
|
|
)
|
|
internal
|
|
{
|
|
require(_token.approve(_spender, _value));
|
|
}
|
|
}
|
|
|