Skip to content

Commit

Permalink
Merge pull request #349 from beethovenxfi/daniel/configurable-connect…
Browse files Browse the repository at this point in the history
…ing-tokens

Small adjustments to configurable-connecting-tokens
  • Loading branch information
John Grant authored Jan 25, 2023
2 parents 7c9a22d + bdf30c0 commit c3e0f98
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/routeProposal/filtering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ export function getBoostedGraph(
const graphPoolsSet: Set<PoolBase> = new Set();
const linearPools: PoolBase[] = [];
const phantomPools: PoolBase[] = [];
const connectingTokens = config.connectingTokens.map(
(connectingToken) => connectingToken.address
);
// Here we add all linear pools, take note of phantom pools,
// add LBP pools with tokenIn or tokenOut and their corresponding
// highest liquidity WETH connections
Expand All @@ -194,9 +197,6 @@ export function getBoostedGraph(
phantomPools.push(pool);
}
if (config.lbpRaisingTokens && pool.isLBP) {
const connectingTokens = config.connectingTokens.map(
(connectingToken) => connectingToken.address
);
handleLBPCase(
graphPoolsSet,
config.lbpRaisingTokens,
Expand All @@ -211,21 +211,24 @@ export function getBoostedGraph(
}
// add best pools tokenIn -> connectingToken and connectingToken -> tokenOut
for (const connectingToken of config.connectingTokens) {
const bestTokenInToConnectingToken = getHighestLiquidityPool(
const bestTokenInToConnectingTokenPoolId = getHighestLiquidityPool(
tokenIn,
connectingToken.address,
poolsAllDict
);
if (bestTokenInToConnectingToken) {
graphPoolsSet.add(poolsAllDict[bestTokenInToConnectingToken]);
}
const bestConnectingTokenToTokenOut = getHighestLiquidityPool(
const bestConnectingTokenToTokenOutPoolId = getHighestLiquidityPool(
connectingToken.address,
tokenOut,
poolsAllDict
);
if (bestConnectingTokenToTokenOut) {
graphPoolsSet.add(poolsAllDict[bestConnectingTokenToTokenOut]);
if (
bestTokenInToConnectingTokenPoolId &&
bestConnectingTokenToTokenOutPoolId
) {
graphPoolsSet.add(poolsAllDict[bestTokenInToConnectingTokenPoolId]);
graphPoolsSet.add(
poolsAllDict[bestConnectingTokenToTokenOutPoolId]
);
}
}
if (linearPools.length == 0) return {};
Expand Down

0 comments on commit c3e0f98

Please sign in to comment.