Search…
⌃K
Links

SafeERC20

library SafeERC20

Index

Reference

Functions

safeApprove

function safeApprove(ERC20 _token, address _spender, uint256 _amount) internal returns (bool)
Same as a standards-compliant ERC20.approve() that never reverts (returns false). Note that this makes an external call to the token.
Parameters:
  • _token - ERC20
  • _spender - address
  • _amount - uint256
Returns:
  • bool

safeTransfer

function safeTransfer(ERC20 _token, address _to, uint256 _amount) internal returns (bool)
Same as a standards-compliant ERC20.transfer() that never reverts (returns false). Note that this makes an external call to the token.
Parameters:
  • _token - ERC20
  • _to - address
  • _amount - uint256
Returns:
  • bool

safeTransferFrom

function safeTransferFrom(ERC20 _token, address _from, address _to, uint256 _amount) internal returns (bool)
Same as a standards-compliant ERC20.transferFrom() that never reverts (returns false). Note that this makes an external call to the token.
Parameters:
  • _token - ERC20
  • _from - address
  • _to - address
  • _amount - uint256
Returns:
  • bool

staticAllowance

function staticAllowance(ERC20 _token, address _owner, address _spender) internal view returns (uint256)
Static call into ERC20.allowance(). Reverts if the call fails for some reason (should never fail).
Parameters:
  • _token - ERC20
  • _owner - address
  • _spender - address
Returns:
  • uint256

staticBalanceOf

function staticBalanceOf(ERC20 _token, address _owner) internal view returns (uint256)
Static call into ERC20.balanceOf(). Reverts if the call fails for some reason (should never fail).
Parameters:
  • _token - ERC20
  • _owner - address
Returns:
  • uint256

staticTotalSupply

function staticTotalSupply(ERC20 _token) internal view returns (uint256)
Static call into ERC20.totalSupply(). Reverts if the call fails for some reason (should never fail).
Parameters:
  • _token - ERC20
Returns:
  • uint256