# Sun

{% hint style="warning" %}
Note that this page has not been updated to reflect the current state of Beanstalk, but is left here as a reference.
{% endhint %}

The Sun advances Beanstalk to the next Season through the `sunrise` function in the Season Facet. Every time an hour passes, `sunrise` can be called 1 more time.

The Season Facet has [several subcontracts](https://github.com/BeanstalkFarms/Beanstalk/tree/master/protocol/contracts/beanstalk/sun/SeasonFacet):

* [`Oracle.sol`](https://github.com/BeanstalkFarms/Beanstalk/blob/master/protocol/contracts/farm/facets/SeasonFacet/Oracle.sol) -> Calculates the time weighted average number of Beans that Bean is above/below its value peg in all pools on the [Oracle Whitelist](https://docs.bean.money/farm/sun#oracle-whitelist).
* [`Weather.sol`](https://github.com/BeanstalkFarms/Beanstalk/blob/master/protocol/contracts/farm/facets/SeasonFacet/Weather.sol) -> Changes the Max Temperature (interest rate) depending on the Bean price, debt level and demand for Soil.
* [`Sun.sol`](https://github.com/BeanstalkFarms/Beanstalk/blob/master/protocol/contracts/farm/facets/SeasonFacet/Sun.sol) -> Sets the Soil for the next Season and mints new Beans if `Oracle` returns `deltaB > 0` and distributes them as follows:
  * Up to 1/3 to Active Fertilizer holders (see [Barn](https://docs.bean.money/developers/protocol/barn));
  * Up to 1/2 of the remaining amount to Pod holders (see [Field](https://docs.bean.money/developers/protocol/field)); and
  * The rest to Stalkholders in the Silo (see [Silo](https://docs.bean.money/developers/protocol/silo)).

`sunrise` does the following steps:

1. Increments the Season number;
2. Calls `Oracle` to get `deltaB`;
3. Calls `Weather` to adjust the Max Temperature and checks for Rain and Season of Plenty;
4. Calls `Sun` to set the Soil and mint Beans if `deltaB > 0`; and
5. Pays `msg.sender` Beans for paying the transaction fee associated with calling the function.

{% hint style="warning" %}
In the Beanstalk ecosystem,

* **Rain** is referred to as **Oversaturation**; and
* **Season of Plenty** is referred to as **Flood**.

See [Terminology Discrepancies](https://docs.bean.money/developers/misc/terminology-discrepancies).
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.bean.money/developers/protocol/sun.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
