[Bug | Dex] Different liquidity pools for the same assets
aidan-starke opened this issue · 1 comments
aidan-starke commented
I noticed this when using the dex
pallet to check liquidity for multicurrency, querying dex.liquidityPool
with the assets in a different order returns different results (one will return liquidity of [0, 0]
.
This meant I had to take the step of checking I had the right order to get the correct result;
https://github.com/futureversecom/trn-web-apps/blob/main/apps/app-staking/libs/hooks/useFeeEstimate/index.ts#L22-L36
const fetchLiquidityPool = useCallback(async (): Promise<LiquidityPool> => {
let [assetLiquidity, xrpLiquidity] = (
await rootApi.query.dex.liquidityPool([feeAsset!.assetId, 2])
).toJSON() as LiquidityPool;
if (assetLiquidity === 0 || xrpLiquidity === 0)
[xrpLiquidity, assetLiquidity] = (
await rootApi.query.dex.liquidityPool([2, feeAsset!.assetId])
).toJSON() as LiquidityPool;
if (assetLiquidity === 0 || xrpLiquidity === 0)
throw { message: "Insufficent liquidity in pool, please select another asset" };
return [assetLiquidity, xrpLiquidity];
}, [feeAsset, rootApi]);
zees-dev commented