Token Facet

Note that this page has not been updated to reflect the current state of Beanstalk, but is left here as a reference.

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.

Parameter
Type
Description

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

toMode

To

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

WIP

Parameter
Type
Description

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.

Parameter
Type
Description

amount

uint256

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

toMode

To

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

Wraps Ether into WETH.

Parameter
Type
Description

amount

uint256

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

toMode

To

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

Wraps Ether into WETH.

Parameter
Type
Description

amount

uint256

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

toMode

To

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

Wraps Ether into WETH.

Parameter
Type
Description

amount

uint256

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

toMode

To

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.

Parameter
Type
Description

amount

uint256

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

toMode

To

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

Wraps Ether into WETH.

Parameter
Type
Description

amount

uint256

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

toMode

To

function tokenPermitDomainSeparator() external view returns (bytes32);

Wraps Ether into WETH.

Parameter
Type
Description

amount

uint256

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

toMode

To

ERC-1155

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

Wraps Ether into WETH.

Parameter
Type
Description

amount

uint256

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

toMode

To

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

Wraps Ether into WETH.

Parameter
Type
Description

amount

uint256

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

toMode

To

WETH

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

Wraps Ether into WETH.

Parameter
Type
Description

amount

uint256

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

toMode

To

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

Unwraps WETH into Ether.

Parameter
Type
Description

amount

uint256

The amount of WETH to unwrap into Ether.

fromMode

From

View Functions

function getInternalBalance(address account, IERC20 token)
    public
    view
    returns (uint256 balance);
Parameter
Type
Description

account

address

WIP

token

IERC20

WIP

Return Value
Type
Description

balance

uint256

WIP

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

account

address

WIP

tokens

IERC20[]

WIP

Return Value
Type
Description

balances

uint256[]

WIP

function getExternalBalance(address account, IERC20 token)
    public
    view
    returns (uint256 balance);
Parameter
Type
Description

account

address

WIP

token

IERC20

WIP

Return Value
Type
Description

balance

uint256

WIP

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

account

address

WIP

tokens

IERC20[]

WIP

Return Value
Type
Description

balances

uint256[]

WIP

function getBalance(address account, IERC20 token)
    public
    view
    returns (uint256 balance);
Parameter
Type
Description

account

address

WIP

token

IERC20

WIP

Return Value
Type
Description

balance

uint256

WIP

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

account

address

WIP

tokens

IERC20[]

WIP

Return Value
Type
Description

balances

uint256[]

WIP

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

account

address

WIP

token

IERC20

WIP

Return Value
Type
Description

b

Balance

WIP

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

account

address

WIP

tokens

IERC20[]

WIP

Return Value
Type
Description

balances

Balance[]

WIP

Events

event InternalBalanceChanged(
    address indexed account,
    IERC20 indexed token,
    int256 delta
);
Parameter
Type
Description

account

address

WIP

token

IERC20

WIP

delta

int256

WIP

event TokenApproval(
    address indexed owner,
    address indexed spender,
    IERC20 token,
    uint256 amount
);
Parameter
Type
Description

owner

address

WIP

spender

address

WIP

token

IERC20

WIP

amount

uint256

WIP

Last updated