XY Finance

Maximum Available Liquidity

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.
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 Y PoolVault 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 Smart Contract (Y Pool), 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.