> 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/adapter.md).

# Adapter

### Purpose

* **Uniform Interface:** Adapters implement the `IProtocolAdapter` interface, providing a consistent set of functions regardless of underlying protocol differences.
* **Simplified Interaction:** They allow Polystream to interact seamlessly with multiple DeFi protocols without dealing directly with each protocol's unique implementations.
* **Yield Management:** Adapters handle yield harvesting, compounding, and fee management, simplifying profit calculations and risk management.

#### Key Components and Functionalities

[`IProtocolAdapter.sol`](https://github.com/polystream-core/polystream-contracts/blob/main/src/adapters/interfaces/IProtocolAdapter.sol)

Defines the standardized interface that all adapters must implement, including methods to:

* Supply and withdraw assets.
* Harvest and compound yields.
* Convert platform fees to rewards.
* Retrieve APY, balances, and principal data.

[`AaveAdapter.sol`](https://github.com/polystream-core/polystream-contracts/blob/main/src/adapters/AaveAdapter.sol)

Specific adapter for interacting with the Aave lending protocol:

* Handles supplying and withdrawing of assets to/from Aave pools.
* Harvests yield by withdrawing accrued interest and redepositing it, thereby compounding returns.
* Manages the conversion of fees into yield, tracks principal deposits, and calculates APY from Aave's interest rate models.

[`LayerBankAdapter.sol`](https://github.com/polystream-core/polystream-contracts/blob/main/src/adapters/LayerBankAdapter.sol)

Adapter specifically designed for LayerBank protocol:

* Manages asset deposits, withdrawals, and yield harvesting on LayerBank.
* Implements advanced handling, including error management for different redeem methods.
* Calculates APY based on LayerBank’s rate models, compounding yields by harvesting interest regularly.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
