From 596a098ec2532eea1ffc644a70e1dd5fed594fad Mon Sep 17 00:00:00 2001 From: ben2x4 <86395884+ben2x4@users.noreply.github.com> Date: Thu, 3 Nov 2022 16:54:10 -0700 Subject: [PATCH] bandaid for token-to-token swap (#280) --- .../selectEligiblePoolsForTokenToTokenSwap.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/queries/useQueryMatchingPoolForSwap/util/selectEligiblePoolsForTokenToTokenSwap.ts b/queries/useQueryMatchingPoolForSwap/util/selectEligiblePoolsForTokenToTokenSwap.ts index 7885ba87..0e8c567c 100644 --- a/queries/useQueryMatchingPoolForSwap/util/selectEligiblePoolsForTokenToTokenSwap.ts +++ b/queries/useQueryMatchingPoolForSwap/util/selectEligiblePoolsForTokenToTokenSwap.ts @@ -52,13 +52,23 @@ export function selectEligiblePoolsForTokenToTokenSwap({ const intermediaryToken = tokenA.symbol === poolAssetA.symbol ? poolAssetB : poolAssetA + const intermediaryTokenPositionInputPool = + intermediaryToken.denom === poolAssetA.denom ? 'a' : 'b' + const passThroughSwapOutputPool = poolsList.find( ({ pool_assets: [assetA, assetB] }) => { + const intermediaryTokenPositionOutputPool = + intermediaryToken.denom === assetA.denom ? 'a' : 'b' + + const intermediaryTokenInSamePosition = + intermediaryTokenPositionInputPool == + intermediaryTokenPositionOutputPool return ( - (intermediaryToken.symbol === assetA.symbol && + ((intermediaryToken.symbol === assetA.symbol && tokenB.symbol === assetB.symbol) || - (tokenB.symbol === assetA.symbol && - intermediaryToken.symbol === assetB.symbol) + (tokenB.symbol === assetA.symbol && + intermediaryToken.symbol === assetB.symbol)) && + intermediaryTokenInSamePosition ) } )