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

# JavBorrowingProvider

### General Description

The `JavBorrowingProvider` smart contract that provides a borrowing and lending mechanism based on a collateralized token model. It allows users to buy and sell tokens, manage collateral assets, and interact with leveraged positions, all while ensuring automated price feeds and maintaining the integrity of collateralization ratios. The contract operates with an upgradeable structure, allowing for flexibility and future improvements.

#### Key Features:

* Buy and sell liquidity pool (LLP) tokens using various assets as collateral.
* Maintain a set of active tokens with associated collateral and price feeds.
* Manage and rebalance token positions based on predefined logic. (<mark style="color:red;">tbd</mark>)
* Distribute rewards and handle assets based on changes in the token value and collateral positions.

### Core Functionalities

* **Assert Management**
  * **receiveAssets** - Receives assets and updates the token amount for the specific collateral token.
  * **sendAssets** - Used for sending assets to external addresses, typically related to profit and loss (PnL) management.
  * **distributeReward** - Distributes rewards to LLP token holders based on the amount of assets they have provided to the system.
* **LLP buying and selling**
  * **buyLLP -** Allows users to buy LLP tokens by providing an input token (e.g., ETH, USDC) and an amount.
  * **sellLLP -** Allows users to sell LLP tokens in exchange for the underlying collateral token.
* **Tokens Management**
  * **addToken** or **updateToken -** These functions allow the contract owner (admin) to add or modify tokens in the system.


---

# 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.javsphere.com/engineering/smart-contracts/leveragex/javborrowingprovider.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.
