Beanstalk
  • Agronomics Handbook
  • Farmers' Almanac
  • Whitepaper
  • Contract Addresses
  • 🌱Overview
    • Introduction
    • Development Ethos
    • EIP-2535 Diamond
    • App Storage
    • Internal Balances
  • 🌾Protocol
    • Overview
    • Louper
    • Sun
      • Season Facet
    • Silo
      • Silo Facet
      • BDV Facet
      • Whitelist Facet
      • Convert Facet
      • Convert Getters Facet
      • Enroot Facet
      • Approval Facet
      • Metadata Facet
      • Migration Facet
      • Legacy Claim Withdrawal Facet
    • Field
      • Field Facet
      • Fundraiser Facet
    • Barn
      • Fertilizer Facet
      • Unripe Facet
    • Market
      • Marketplace Facet
    • Farm
      • Farm Facet
      • Depot Facet
      • Token Facet
      • Token Support Facet
      • Curve Facet
    • Diamond
      • Diamond Cut Facet
      • Diamond Loupe Facet
      • Ownership Facet
      • Pause Facet
  • 📜Misc.
    • Technical Recordings
    • Upgrade History
    • FAQ
    • Terminology Discrepancies
Powered by GitBook
On this page
  • Call Functions
  • Transfers
  • Transfer Token
  • Transfer Internal Token From
  • Approvals
  • Approve Token
  • Increase Token Allowance
  • Decrease Token Allowance
  • Token Allowance
  • Permits
  • Permit Token
  • Token Permit Nonces
  • Token Permit Domain Separator
  • ERC-1155
  • On ERC-1155 Received
  • On ERC-1155 Batch Received
  • WETH
  • Wrap Ether
  • Unwrap Ether
  • View Functions
  • Get Internal Balance
  • Get Internal Balances
  • Get External Balance
  • Get External Balances
  • Get Balance
  • Get Balances
  • Get All Balance
  • Get All Balances
  • Events
  • Internal Balance Changed
  • Token Approval
Edit on GitHub
Export as PDF
  1. Protocol
  2. Farm

Token Facet

PreviousDepot FacetNextToken Support Facet

Last updated 6 months ago

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

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

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

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

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

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

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

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

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

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

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

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

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

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

🌾
Transfer Token
Transfer Internal Token From
Approve Token
Increase Token Allowance
Decrease Token Allowance
Token Allowance
Permit Token
Token Permit Nonces
Token Permit Domain Separator
On ERC-1155 Received
On ERC-1155 Batch Received
Wrap Ether
Unwrap Ether
Get Internal Balance
Get Internal Balances
Get External Balance
Get External Balances
Get Balance
Get Balances
Get All Balance
Get All Balances
Internal Balance Changed
Token Approval
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances
Internal Balances