FeeToken

Git Source

Inherits: IFeeToken, Migratable, ERC20PermitUpgradeable

This contract exposes functionality for wrapping and unwrapping tokens for use as fees in the protocol.

State Variables

PERMIT_TYPEHASH

Returns the EIP712 typehash used in the encoding of a signed digest for a permit.

keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")

bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;

parameterRegistry

The address of the parameter registry.

address public immutable parameterRegistry;

underlying

Returns the address of the underlying token.

address public immutable underlying;

_FEE_TOKEN_STORAGE_LOCATION

bytes32 internal constant _FEE_TOKEN_STORAGE_LOCATION =
    0x5671b09487cb30093710a244e87d44c3076fe3dd19f604be8dafc153e2d9cb00;

Functions

_getFeeTokenStorage

function _getFeeTokenStorage() internal pure returns (FeeTokenStorage storage $);

constructor

Constructor for the implementation contract, such that the implementation cannot be initialized.

The parameter registry and underlying token must not be the zero address.

The parameter registry and underlying token are immutable so that they are inlined in the contract code, and have minimal gas cost.

constructor(address parameterRegistry_, address underlying_);

Parameters

NameTypeDescription
parameterRegistry_addressThe address of the parameter registry.
underlying_addressThe address of the underlying token.

initialize

Initializes the contract.

function initialize() public initializer;

permit

Sets value_ as the allowance of spender_ over owner_'s tokens, given `owner_'s signed approval.

function permit(address owner_, address spender_, uint256 value_, uint256 deadline_, uint8 v_, bytes32 r_, bytes32 s_)
    public
    override(IFeeToken, ERC20PermitUpgradeable);

Parameters

NameTypeDescription
owner_addressThe owner of the tokens.
spender_addressThe spender of the tokens.
value_uint256The value of the tokens.
deadline_uint256The deadline of the permit (must be the current or future timestamp).
v_uint8An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
r_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
s_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).

deposit

Deposits amount_ of the underlying token.

function deposit(uint256 amount_) external;

Parameters

NameTypeDescription
amount_uint256The amount of the underlying token to deposit.

depositWithPermit

Deposits amount_ of the underlying token, given owner_'s signed approval.

function depositWithPermit(uint256 amount_, uint256 deadline_, uint8 v_, bytes32 r_, bytes32 s_) external;

Parameters

NameTypeDescription
amount_uint256The amount of the underlying token to deposit.
deadline_uint256The deadline of the permit (must be the current or future timestamp).
v_uint8An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
r_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
s_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).

depositFor

Deposits amount_ of the underlying token for recipient_.

This function conforms to ERC20Wrapper.depositFor.

function depositFor(address recipient_, uint256 amount_) external returns (bool success_);

Parameters

NameTypeDescription
recipient_addressThe recipient of the underlying token.
amount_uint256The amount of the underlying token to deposit.

depositForWithPermit

Deposits amount_ of the underlying token for recipient_, given owner_'s signed approval.

This function conforms to ERC20Wrapper.depositFor.

function depositForWithPermit(address recipient_, uint256 amount_, uint256 deadline_, uint8 v_, bytes32 r_, bytes32 s_)
    external
    returns (bool success_);

Parameters

NameTypeDescription
recipient_addressThe recipient of the underlying token.
amount_uint256The amount of the underlying token to deposit.
deadline_uint256The deadline of the permit (must be the current or future timestamp).
v_uint8An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
r_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).
s_bytes32An ECDSA secp256k1 signature parameter (EIP-2612 via EIP-712).

withdraw

Withdraws amount_ of the underlying token.

function withdraw(uint256 amount_) external;

Parameters

NameTypeDescription
amount_uint256The amount of the underlying token to withdraw.

withdrawTo

Withdraws amount_ of the underlying token for recipient_.

This function conforms to ERC20Wrapper.withdrawTo.

function withdrawTo(address recipient_, uint256 amount_) external returns (bool success_);

Parameters

NameTypeDescription
recipient_addressThe recipient of the underlying token.
amount_uint256The amount of the underlying token to withdraw.

migrate

Initiates a migration of the proxy, in a way defined by the implementation.

Normally, the implementation has a way of determining the migrator that needs to be delegatecalled.

function migrate() external;

DOMAIN_SEPARATOR

Returns the EIP712 domain separator used in the encoding of a signed digest.

function DOMAIN_SEPARATOR()
    external
    view
    override(IFeeToken, ERC20PermitUpgradeable)
    returns (bytes32 domainSeparator_);

decimals

Returns the decimals places of the token.

function decimals() public pure override(IERC20Metadata, ERC20Upgradeable) returns (uint8 decimals_);

migratorParameterKey

The parameter registry key used to fetch the migrator.

function migratorParameterKey() public pure returns (string memory key_);

nonces

Returns the current nonce for owner_ that must be included for the next valid permit signature.

function nonces(address owner_) public view override(IFeeToken, ERC20PermitUpgradeable) returns (uint256 nonce_);

Parameters

NameTypeDescription
owner_addressThe owner of the tokens.

Returns

NameTypeDescription
nonce_uint256The nonce of the owner.

getPermitDigest

Returns the EIP-712 digest for a permit.

function getPermitDigest(address owner_, address spender_, uint256 value_, uint256 nonce_, uint256 deadline_)
    external
    view
    returns (bytes32 digest_);

Parameters

NameTypeDescription
owner_addressThe owner of the tokens.
spender_addressThe spender of the tokens.
value_uint256The value of the tokens.
nonce_uint256The nonce of the permit signature.
deadline_uint256The deadline of the permit signature.

Returns

NameTypeDescription
digest_bytes32The EIP-712 digest.

_depositWithPermit

function _depositWithPermit(address recipient_, uint256 amount_, uint256 deadline_, uint8 v_, bytes32 r_, bytes32 s_)
    internal;

_deposit

function _deposit(address recipient_, uint256 amount_) internal;

_withdraw

function _withdraw(address recipient_, uint256 amount_) internal;

_getPermitDigest

Returns the EIP-712 digest for a permit.

function _getPermitDigest(address owner_, address spender_, uint256 value_, uint256 nonce_, uint256 deadline_)
    internal
    view
    returns (bytes32 digest_);

Parameters

NameTypeDescription
owner_addressThe owner of the tokens.
spender_addressThe spender of the tokens.
value_uint256The value of the tokens.
nonce_uint256The nonce of the permit signature.
deadline_uint256The deadline of the permit signature.

Returns

NameTypeDescription
digest_bytes32The EIP-712 digest.

_isZero

function _isZero(address input_) internal pure returns (bool isZero_);

Structs

FeeTokenStorage

The UUPS storage for the fee token.

Note: storage-location: erc7201:xmtp.storage.FeeToken

struct FeeTokenStorage {
    uint256 __placeholder;
}