> For the complete documentation index, see [llms.txt](https://docs.polystream.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.polystream.xyz/smart-contracts.md).

# Smart Contracts

The source code of Polystream contracts is available on [Github](https://github.com/polystream-core/polystream-contracts).

The core contracts fall into following categories in the Github repository:

* Adapter
* Core
* Rewards
* Strategy

### Adapter

Adapter contracts serve as standardized connectors between Polystream and various decentralized lending protocols (e.g., Aave, LayerBank). Each adapter abstracts the complexities and differences of individual protocols, enabling a uniform method for supplying assets, withdrawing assets, and harvesting yield.

### Core

The Core contracts serve as the backbone of Polystream, managing user deposits, withdrawals, yield distribution, and the registry of supported DeFi protocols and adapters. They enable smooth interactions between users, adapters, and yield-generating protocols.

### Rewards

The **Rewards** contracts handle the accurate and fair distribution of yield rewards generated by the Polystream vault. Rewards are distributed based on each user's share and the duration their assets are staked (time-weighted contributions). The system ensures that rewards are calculated, tracked, and claimed transparently.

### Strategy

Polystream employs an automated **Yield Optimization Strategy** designed to continuously maximize returns for users. By dynamically evaluating and reallocating funds across supported DeFi protocols, the system ensures user deposits always benefit from the highest available APY (Annual Percentage Yield).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.polystream.xyz/smart-contracts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
