# 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: 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.polystream.xyz/smart-contracts/adapter.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.
