Token Facet

The Token Facet handles the transfers of assets outside the Silo.

Call Functions

Transfers

function transferToken(
    IERC20 token,
    address recipient,
    uint256 amount,
    LibTransfer.From fromMode,
    LibTransfer.To toMode
) external payable;

Transfers an asset from a Farmer's Internal and/or External Balance to a Farmer's Internal or External Balance.

ParameterTypeDescription

token

IERC20

The token to be transferred.

recipient

address

The recipient of the transferred tokens (can be msg.sender).

amount

uint256

The amount of tokens to be transferred.

fromMode

From

Specifies what balance to receive the tokens from (see Internal Balances).

toMode

To

Specifies what balance to send the tokens to (see Internal Balances).

function transferInternalTokenFrom(
    IERC20 token,
    address sender,
    address recipient,
    uint256 amount,
    LibTransfer.To toMode
) external payable nonReentrant;

WIP

ParameterTypeDescription

token

IERC20

WIP

sender

address

WIP

recipient

address

WIP

amount

uint256

WIP

toMode

To

WIP

Approvals

function approveToken(
    address spender,
    IERC20 token,
    uint256 amount
) external payable nonReentrant;

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

function increaseTokenAllowance(
    address spender,
    IERC20 token,
    uint256 addedValue
) public virtual nonReentrant returns (bool);

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

function decreaseTokenAllowance(
    address spender,
    IERC20 token,
    uint256 subtractedValue
) public virtual nonReentrant returns (bool);

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

function tokenAllowance(
    address account,
    address spender,
    IERC20 token
) public view virtual returns (uint256);

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

Permits

function permitToken(
    address owner,
    address spender,
    address token,
    uint256 value,
    uint256 deadline,
    uint8 v,
    bytes32 r,
    bytes32 s
) external payable nonReentrant;

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

function tokenPermitNonces(address owner)
    public
    view
    virtual
    returns (uint256);

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

function tokenPermitDomainSeparator() external view returns (bytes32);

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

ERC-1155

function onERC1155Received(
    address,
    address,
    uint256,
    uint256,
    bytes calldata
) external pure override returns (bytes4);

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

function onERC1155BatchReceived(
    address,
    address,
    uint256[] calldata,
    uint256[] calldata,
    bytes calldata
) external pure override returns (bytes4);

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

WETH

function wrapEth(uint256 amount, LibTransfer.To mode) external payable;

Wraps Ether into WETH.

ParameterTypeDescription

amount

uint256

The amount of Ether to wrap into WETH. Must be <= msg.value.

toMode

To

Specifies what balance to send the WETH to (see Internal Balances).

function unwrapEth(uint256 amount, LibTransfer.From mode) external payable;

Unwraps WETH into Ether.

ParameterTypeDescription

amount

uint256

The amount of WETH to unwrap into Ether.

fromMode

From

Specifies what balance to receive the WETH from (see Internal Balances).

View Functions

function getInternalBalance(address account, IERC20 token)
    public
    view
    returns (uint256 balance);
ParameterTypeDescription

account

address

WIP

token

IERC20

WIP

Return ValueTypeDescription

balance

uint256

WIP

function getInternalBalances(address account, IERC20[] memory tokens)
    external
    view
    returns (uint256[] memory balances);
ParameterTypeDescription

account

address

WIP

tokens

IERC20[]

WIP

Return ValueTypeDescription

balances

uint256[]

WIP

function getExternalBalance(address account, IERC20 token)
    public
    view
    returns (uint256 balance);
ParameterTypeDescription

account

address

WIP

token

IERC20

WIP

Return ValueTypeDescription

balance

uint256

WIP

function getExternalBalances(address account, IERC20[] memory tokens)
    external
    view
    returns (uint256[] memory balances);
ParameterTypeDescription

account

address

WIP

tokens

IERC20[]

WIP

Return ValueTypeDescription

balances

uint256[]

WIP

function getBalance(address account, IERC20 token)
    public
    view
    returns (uint256 balance);
ParameterTypeDescription

account

address

WIP

token

IERC20

WIP

Return ValueTypeDescription

balance

uint256

WIP

function getBalances(address account, IERC20[] memory tokens)
    external
    view
    returns (uint256[] memory balances);
ParameterTypeDescription

account

address

WIP

tokens

IERC20[]

WIP

Return ValueTypeDescription

balances

uint256[]

WIP

function getAllBalance(address account, IERC20 token)
    public
    view
    returns (Balance memory b);
ParameterTypeDescription

account

address

WIP

token

IERC20

WIP

Return ValueTypeDescription

b

Balance

WIP

function getAllBalances(address account, IERC20[] memory tokens)
    external
    view
    returns (Balance[] memory balances);
ParameterTypeDescription

account

address

WIP

tokens

IERC20[]

WIP

Return ValueTypeDescription

balances

Balance[]

WIP

Events

event InternalBalanceChanged(
    address indexed account,
    IERC20 indexed token,
    int256 delta
);
ParameterTypeDescription

account

address

WIP

token

IERC20

WIP

delta

int256

WIP

event TokenApproval(
    address indexed owner,
    address indexed spender,
    IERC20 token,
    uint256 amount
);
ParameterTypeDescription

owner

address

WIP

spender

address

WIP

token

IERC20

WIP

amount

uint256

WIP

Last updated