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
YPoolVaultcontract If the deposit token is native token. If it's ERC20-like token, we get the balance of the Y
PoolVaultcontract 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, 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
YPoolVaultis the native token,
depositAndWithdrawFeesshould be deducted.
closeSwapGasFeesshould always be deducted whether the deposit token of a
YPoolVaultis 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.