vdAMM - Dependencies
TransferHelper.sol
This Solidity library provides a set of helper methods for safely interacting with ERC20 tokens and transferring Ethereum (ETH). It includes functions for approving, transferring, transferring from a particular address, and transferring ETH. These functions are designed to handle ERC20 tokens that do not consistently return true or false.
TransferHelper
A library that provides helper methods for safely interacting with ERC20 tokens and transferring Ethereum (ETH).
safeApprove
function safeApprove(address token, address to, uint value) internal
Approves the transfer of a certain amount of tokens to a given address. Throws an error if the operation fails.
Parameters
- token address: The address of the ERC20 token contract.
- to address: The address to approve the transfer to.
- value uint: The amount of tokens to approve for transfer.
Return Values
- void: No return value.
Errors
- 'TransferHelper: APPROVE_FAILED': Thrown if the approval operation fails.
safeTransfer
function safeTransfer(address token, address to, uint value) internal
Transfers a certain amount of tokens to a given address. Throws an error if the operation fails.
Parameters
- token address: The address of the ERC20 token contract.
- to address: The address to transfer the tokens to.
- value uint: The amount of tokens to transfer.
Return Values
- void: No return value.
Errors
- 'TransferHelper: TRANSFER_FAILED': Thrown if the transfer operation fails.
safeTransferFrom
function safeTransferFrom(address token, address from, address to, uint value) internal
Transfers a certain amount of tokens from a specific address to another. Throws an error if the operation fails.
Parameters
- token address: The address of the ERC20 token contract.
- from address: The address to transfer the tokens from.
- to address: The address to transfer the tokens to.
- value uint: The amount of tokens to transfer.
Return Values
- void: No return value.
Errors
- 'TransferHelper: TRANSFER_FROM_FAILED': Thrown if the transfer operation fails.
safeTransferETH
function safeTransferETH(address to, uint value) internal
Transfers a certain amount of ETH to a given address. Throws an error if the operation fails.
Parameters
- to address: The address to transfer the ETH to.
- value uint: The amount of ETH to transfer.
Return Values
- void: No return value.
Errors
- 'TransferHelper: ETH_TRANSFER_FAILED': Thrown if the ETH transfer operation fails.