# (Legacy) Maximum Available Liquidity

{% hint style="warning" %}
If you're going to initiate a cross-chain request, please make sure there's enough buffer liquidity on the target chain since there will always be a time gap between reading the stats and executing the request.
{% endhint %}

The major concept is that we can get the rough available liquidity by getting the balance of the `YPoolVault` contract If the deposit token is native token. If it's ERC20-like token, we get the balance of the `YPoolVault` contract from the deposit token contract.

However, the balance we get directly from the contract is just a rough number since some of the balance might belong to the XY worker.

As mentioned in the **public states** in [(Legacy) Integrate Y Pool Contract](/single-bridge-integration/ybridge-contract-integration/legacy-integrate-y-pool-contract.md), some of the fees belong to XY worker. Therefore we should deduct those part if we are aiming higher accuracy of available liquidity.

If the deposit token of a `YPoolVault` is the native token, `depositAndWithdrawFees` should be deducted.

`closeSwapGasFees` should always be deducted whether the deposit token of a `YPoolVault` is the native token or not

The last uncertainty is the asset accidentally sent to the `YPoolVault`. This kind of asset will NOT be withdrawn immediately. Therefore, please make sure there's enough buffer when you're trying to initiate a cross-chain request directly with the smart contracts.


---

# 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.xy.finance/single-bridge-integration/ybridge-contract-integration/legacy-integrate-y-pool-contract/legacy-maximum-available-liquidity.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.
