All pages
Powered by GitBook
1 of 3

Loading...

Loading...

Loading...

Field

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

The Field is Beanstalk's credit facility. Beanstalk relies on a decentralized set of creditors to maintain Bean price stability.

Anytime Beanstalk is willing to issue debt, there is Soil in the Field. Soil represents the number of Beans that Beanstalk is currently willing to borrow.

Anytime there is Soil in the Field, Farmers can Sow Beans in exchange for Pods. Pods are stored in Plots and placed at the end of the Pod Line.

Pods become Harvestable on a First In, First Out (FIFO) basis when deltaB > 0 over the course of a Season. Assuming there are Unharvestable Pods and Unfertilized Beans, 1/3 of Bean mints turn Pods into Harvestable Pods, which can be Harvested (redeemed) for Beans via the harvest() function. When a Plot is Harvested, it is deleted from storage.

Pods are implemented using 3 indices:

  • podIndex -> The total number of Pods ever created.

  • harvestableIndex -> The total number of Pods that ever became Harvestable.

  • harvestedIndex -> The total number of Pods ever Harvested.

When Beans are Sown, a Plot is created at the current podIndex with beans * (1 + weather). Pods and podIndex are incremented by the number of Pods.

When Pods become Harvestable, harvestableIndex is incremented by the number of newly Harvestable Pods. Plots are Harvestable if the index of a Plot is less than harvestableIndex. Plots can be partially Harvested, in which case Beanstalk deletes the first part of the Plot and creates a new Plot at the harvestableIndex. When a Plot is Harvested, the harvestedIndex increases by the number of Harvested Pods.

Fundraiser

Fundraisers allow Beanstalk to raise non-Bean stablecoins to pay for services on behalf of the protocol, such as audits. Fundraisers can be created through the createFundraiser() function by Beanstalk or the owner of the contract.

Each Fundraiser requires:

  1. The token address of the non-Bean token being raised;

  2. The amount of tokens being raised; and

  3. The address to send the tokens to upon completion of the Fundraiser.

Farmers fund() Fundraisers by transferring the non-Bean stablecoin to Beanstalk and in exchange receive Pods at the current Weather at the end of the Pod Line. Funding is akin to Sowing, but instead of burning Beans, Beanstalk is raising a non-Bean stable coin.

Once all of the Funds have been raised, the tokens are transferred to the payee address stored in the Fundraiser.

You can find links to past BIPs that created Fundraisers here.

Field Facet

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

The Field Facet is where Beans are Sown.

Call Functions

Sow

function sow(
    uint256 beans,
    uint256 minTemperature,
    LibTransfer.From mode
)
    external
    payable
    returns (uint256 pods);

Sow Beans in exchange for Pods.

Parameter
Type
Description

beans

uint256

The number of Beans to Sow.

minTemperature

uint256

The minimum Temperature at which to Sow.

mode

From

The balance to transfer Beans from; see .

Return Value
Type
Description

pods

uint256

The number of Pods received.

Sow With Min

function sowWithMin(
    uint256 beans,
    uint256 minTemperature,
    uint256 minSoil,
    LibTransfer.From mode
) public payable returns (uint256 pods);

Sow Beans in exchange for Pods. Use at least minSoil.

Parameter
Type
Description

beans

uint256

The number of Beans to Sow.

minTemperature

uint256

The minimum Temperature at which to Sow.

minSoil

uint256

The minimum amount of Soil to use; reverts if there is less than this much Soil available upon execution.

mode

From

The balance to transfer Beans from; see .

Return Value
Type
Description

pods

uint256

The number of Pods received.

Harvest

function harvest(uint256[] calldata plots, LibTransfer.To mode)
    external
    payable;

Harvest Pods from the Field.

Parameter
Type
Description

plots

uint256[]

List of Plot IDs to Harvest.

mode

To

The balance to transfer Beans to; see .

View Functions

Pod Index

function podIndex() public view returns (uint256);

Returns the total number of Pods ever minted.

Return Type
Description

uint256

The total number of Pods ever minted.

Harvestable Index

function harvestableIndex() public view returns (uint256);

Returns the index below which Pods are Harvestable.

Return Type
Description

uint256

The index below which Pods are Harvestable.

Total Pods

function totalPods() public view returns (uint256);

Returns the number of outstanding Pods. Includes Pods that are currently Harvestable but have not yet been Harvested.

Return Type
Description

uint256

The number of outstanding Pods.

Total Harvested

function totalHarvested() public view returns (uint256);

Returns the number of Pods that have ever been Harvested.

Return Type
Description

uint256

The number of Pods that have ever been Harvested.

Total Harvestable

function totalHarvestable() public view returns (uint256);

Returns the number of Pods that are currently Harvestable but have not yet been Harvested.

Return Type
Description

uint256

The number of Pods that are currently Harvestable but have not yet been Harvested.

Total Unharvestable

function totalUnharvestable() public view returns (uint256);

Returns the number of Pods that are not yet Harvestable.

Return Type
Description

uint256

The number of Pods that are not yet Harvestable.

Plot

function plot(address account, uint256 index)
    public
    view
    returns (uint256);

Returns the number of Pods remaining in a Plot.

Parameter
Type
Description

account

address

The account that owns a Plot.

index

uint256

The ID of a Plot.

Return Type
Description

uint256

The number of Pods remaining in a Plot.

Total Soil

function totalSoil() external view returns (uint256);

Returns the total available Soil.

Return Type
Description

uint256

The total available Soil.

Yield

function yield() external view returns (uint32);

Returns the current yield (aka "Temperature") offered by Beanstalk when burning Beans in exchange for Pods.

Return Type
Description

uint32

The current yield offered by Beanstalk when burning Beans in exchange for Pods.

Temperature

function temperature() external view returns (uint256);

Returns the current Temperature, the interest rate offered by Beanstalk in exchange for Sowing Beans.

Return Value
Description

uint256

The current Temperature.

Max Temperature

function maxTemperature() external view returns (uint256);

Returns the Maximum Temperature that Beanstalk is willing to offer this Season.

Return Type
Description

uint256

The Maximum Temperature.

Remaining Pods

function remainingPods() external view returns (uint256);

Returns the remaining Pods that could be issued this Season.

Return Value
Description

uint256

The remaining Pods that could be issued this Season.

Events

Sow

event Sow(
    address indexed account,
    uint256 index,
    uint256 beans,
    uint256 pods
);

Emitted from LibDibbler.sowNoSoil when an account creates a Plot. A Plot is a set of Pods created in from a single sow or fund call.

Parameter
Type
Description

account

address

The account that Sowed Beans for Pods.

index

uint256

The Place in Line of the Plot.

beans

uint256

The amount of Beans burnt to create the Plot.

pods

uint256

The amount of Pods associated with the created Plot.

Harvest

event Harvest(address indexed account, uint256[] plots, uint256 beans);

Emitted when account claims the Beans associated with Harvestable Pods.

Parameter
Type
Description

account

address

The account that owns the plots.

plots

uint256[]

The indices of Plots that were Harvested.

beans

uint256

The amount of Beans transferred to account.

Pod Listing Cancelled

event PodListingCancelled(address indexed account, uint256 index);

Emitted when a Pod Listing is Cancelled.

Parameter
Type
Description

account

address

The account that created the Pod Listing.

index

uint256

The index of the Plot listed.

LibTransfer.From
LibTransfer.From
LibTransfer.To

Fundraiser Facet

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

The Fundraiser Facet dandles the creation, funding, and completion of Fundraisers.

Call Functions

Fund

function fund(
    uint32 id,
    uint256 amount,
    LibTransfer.From mode
) external payable nonReentrant returns (uint256);

Fund a Fundraiser in exchange for Pods.

Parameter
Type
Description

id

uint32

The Fundraiser ID.

amount

uint256

Amount of fundraisers[id].token to provide.

mode

From

Balance to spend tokens from; see .

Return Type
Description

uint256

The number of Pods received.

Create Fundraiser

function createFundraiser(
    address payee,
    address token,
    uint256 amount
) external payable;

Creates a Fundraiser. Can only be called by the owner of Beanstalk.

Parameter
Type
Description

payee

address

The address to which funds are delivered at the end of the Fundraiser.

token

address

The address of the token that can be sent to the Fundraiser in exchange for Pods.

amount

uint256

The amount of token that is being raised.

View Functions

Remaining Funding

function remainingFunding(uint32 id) public view returns (uint256);

Returns the remaining number of tokens to raise.

Parameter
Type
Description

id

uint32

The Fundraiser ID.

Return Type
Description

uint256

The remaining number of tokens to raise.

Total Funding

function totalFunding(uint32 id) public view returns (uint256);

Returns the total amount of tokens raised so far.

Parameter
Type
Description

id

uint32

The Fundraiser ID.

Return Type
Description

uint256

The total amount of tokens raised so far.

Funding Token

function fundingToken(uint32 id) public view returns (address);

Returns the address of the token that can be sent to the Fundraiser.

Parameter
Type
Description

id

uint32

The Fundraiser ID.

Return Type
Description

address

The address of the token that can be sent to the Fundraiser.

Fundraiser

function fundraiser(uint32 id)
    public
    view
    returns (Storage.Fundraiser memory);

Returns the Fundraiser struct.

Parameter
Type
Description

id

uint32

The Fundraiser ID.

Return Type
Description

Fundraiser

Returns the Fundraiser struct in .

Number Of Fundraisers

function numberOfFundraisers() public view returns (uint32);

Returns the number of Fundraisers.

Return Type
Description

uint32

The number of Fundraisers.

Events

Create Fundraiser

event CreateFundraiser(
    uint32 indexed id,
    address fundraiser,
    address token,
    uint256 amount
);

Emitted when a Fundraiser is created.

Parameter
Type
Description

id

uint32

The Fundraiser ID.

fundraiser

address

The address to which funds are delivered.

token

address

The address of the token that can be sent to the Fundraiser in exchange for Pods.

amount

uint256

The amount of token that is being raised.

Fund Fundraiser

event FundFundraiser(
    address indexed account,
    uint32 indexed id,
    uint256 amount
);

Emitted when a Farmer calls fund.

Parameter
Type
Description

account

address

The address of the Farmer.

id

uint32

The Fundraiser ID.

amount

uint256

The amount of token that account provided.

Complete Fundraiser

event CompleteFundraiser(uint32 indexed id);

Emitted when a Fundraiser is fully funded.

Parameter
Type
Description

id

uint32

The Fundraiser ID.

LibTransfer.From
App Storage