Skip to main content

Transfer

Git Source

State Variables

_PERMIT2_PARAMS_LEN

uint256 internal constant _PERMIT2_PARAMS_LEN = 256;

Functions

approve

function approve(ERC20 token_, address spender_, uint256 amount_) internal;

transfer

Performs an ERC20 transfer of token_ from the caller

This function handles the following:

  1. Checks that the user has granted approval to transfer the token
  2. Transfers the token from the user
  3. Checks that the transferred amount was received

This function reverts if:

  • Approval has not been granted to this contract to transfer the token
  • The token transfer fails
  • The transferred amount is less than the requested amount
function transfer(
ERC20 token_,
address recipient_,
uint256 amount_,
bool validateBalance_
) internal;

Parameters

NameTypeDescription
token_ERC20Token to transfer
recipient_addressAddress of the recipient
amount_uint256Amount of tokens to transfer (in native decimals)
validateBalance_boolWhether to validate the balance of the recipient

transferFrom

Performs an ERC20 transferFrom of token_ from the sender

This function handles the following:

  1. Checks that the user has granted approval to transfer the token
  2. Transfers the token from the user
  3. Checks that the transferred amount was received

This function reverts if:

  • Approval has not been granted to this contract to transfer the token
  • The token transfer fails
  • The transferred amount is less than the requested amount
function transferFrom(
ERC20 token_,
address sender_,
address recipient_,
uint256 amount_,
bool validateBalance_
) internal;

Parameters

NameTypeDescription
token_ERC20Token to transfer
sender_addressAddress of the sender
recipient_addressAddress of the recipient
amount_uint256Amount of tokens to transfer (in native decimals)
validateBalance_boolWhether to validate the balance of the recipient

permit2TransferFrom

function permit2TransferFrom(
ERC20 token_,
address permit2_,
address sender_,
address recipient_,
uint256 amount_,
Permit2Approval memory approval_,
bool validateBalance_
) internal;

permit2OrTransferFrom

function permit2OrTransferFrom(
ERC20 token_,
address permit2_,
address sender_,
address recipient_,
uint256 amount_,
Permit2Approval memory approval_,
bool validateBalance_
) internal;

decodePermit2Approval

function decodePermit2Approval(bytes memory data_) internal pure returns (Permit2Approval memory);

Errors

UnsupportedToken

error UnsupportedToken(address token_);

InvalidParams

error InvalidParams();

Structs

Permit2Approval

Parameters used for Permit2 approvals

struct Permit2Approval {
uint48 deadline;
uint256 nonce;
bytes signature;
}