Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small adjustments to configurable-connecting-tokens #349

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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