# System Architecture

The SugarYield Markets operate on the BNB smart chain environment.

<figure><img src="/files/TsYvz4keJdIWTgm7raZx" alt=""><figcaption></figcaption></figure>

### Controller&#x20;

A function used by Keepers to initiate events that affect the Vaults.&#x20;

**TriggerEndEpoch:** Triggers the end of an epoch and transfers the Caramel vault premium to the Saltish Vault, closing the epoch.&#x20;

**TriggerDepeg:** Triggers if the epoch has not ended and the oracle reports a price lower than the Vault Market strike price, swapping the Caramel Vault premium with the Saltish Vault, and closing the epoch.&#x20;

**TriggerNullEpoch:** Triggers if, after the insurance epoch has begun and one of the Vault Markets has zero deposits, allowing everyone to withdraw their deposits since there is no possibility to resolve this Market.

### Vault&#x20;

A function used by Users to create ERC 1155 positions, where the ID of the token is represented by the Unix Timestamp of the last second of an Insurance Epoch.&#x20;

**Deposit:** Transfers WBNB and creates 1 to 1 an ERC1155 token corresponding to that epoch.&#x20;

**Withdraw:** Takes a fee if there is profit in this position and calculates the user's entitlement, which corresponds to the user's % shares of this Vault before the insurance epoch began.

### Vault Factory&#x20;

A function used by Sugar Yield admins to create Markets and corresponding Vaults, and for deploying new epochs for already created Markets.

### Staking Rewards&#x20;

A function that allows users, after creating Vault Market tokens (ERC1155 tokens), to deposit these tokens inside Staking Rewards to earn Sugar Yield tokens. This is designed to incentivize deposits in certain Vault Market Positions, with Sugar Yield token rewards varying based on Market conditions.&#x20;

<br>


---

# 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://sugar-yield.gitbook.io/sugaryield/learn-more/system-architecture.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.
