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

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

Transfer Token

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

Transfer Internal Token From

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

Approve Token

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

Increase Token Allowance

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

Decrease Token Allowance

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

Token Allowance

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

Permit Token

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

Token Permit Nonces

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

Token Permit Domain Separator

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

On ERC-1155 Received

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

On ERC-1155 Batch Received

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

Wrap Ether

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

Unwrap Ether

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

Get Internal Balance

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

Get Internal Balances

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

Get External Balance

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

Get External Balances

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

Get Balance

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

Get Balances

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

Get All Balance

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

Get All Balances

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

Internal Balance Changed

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

account

address

WIP

token

IERC20

WIP

delta

int256

WIP

Token Approval

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

PreviousDepot FacetNextToken Support Facet

Last updated 8 months ago

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 ).

🌾
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