# Integrations

Hashstack allows users to spend their loan on supported integrations in a variety of ways like swapping, staking and last but not the least adding liquidity. This list of integrations will only grow along with the growth of the Starknet ecosystem and the birth of new protocols.

While supporting these integrations we also monitor activity on these pools because they introduce a certain level of risk to the system. Protection of the users deposits is paramount so we have certain measures in place to be able to disable user activity on certain pools if it increases the risk taken on by the protocol and likewise only stable pools are currently whitelisted to be used as a part of risk management.

## Adding Liquidity

Of the user actions mentioned above, swapping and staking are fairly simple, but adding liquidity to an AMM pool is not that straightforward. Adding liquidity can be roughly broken down into two scenarios -

1. Loan market A is adding liquidity to pool BC: For this scenario, there is no common market between loan market A and the pool of markets B and C. Therefore, the first step is to swap A to either B or C, which is done to achieve the best result/route.

The liquidity split of B and C to the pool BC while ensuring the least/no amount of loan is left over is done through simplifying the equation -

$$getAmountOut(x) = quote(loan - x);$$

Here `get_amount_out(x)` and `quote(x)` are common view functions used in AMM’s which operate on the reserves of the pool and return the values. The simplification of the above equation is used to calculate the liquidity split for the best performance. It will resolve to a quadratic equation in x, which is then solved by calculating the determinant.


---

# 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.hashstack.finance/developers/integrations.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.
