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

(fix) change how PancakeSwap fetches V2 pools #371

Merged
merged 2 commits into from
Dec 2, 2024
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
16 changes: 3 additions & 13 deletions src/connectors/pancakeswap/pancakeswap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,6 @@ export class PancakeSwap implements Uniswapish {
v2SubgraphClient = new GraphQLClient(v2Ethurl);
}

const pairs = SmartRouter.getPairCombinations(currencyA, currencyB);

// Create v2 candidate pool fetcher with your own on-chain fetcher
const getV2PoolsByCommonTokenPrices =
SmartRouter.createV2PoolsProviderByCommonTokenPrices(
SmartRouter.getCommonTokenPricesBySubgraph,
);
const getV2CandidatePools = SmartRouter.createGetV2CandidatePools(
getV2PoolsByCommonTokenPrices,
);

// Define v3 pool on-chain fetcher with customized tvl references
const getV3CandidatePools = SmartRouter.createGetV3CandidatePools(
// Use your customized v3 pool fetcher by default
Expand All @@ -403,8 +392,7 @@ export class PancakeSwap implements Uniswapish {

const allPools = await Promise.allSettled([
// @ts-ignore
SmartRouter.getStablePoolsOnChain(pairs, () => this.createPublicClient()),
getV2CandidatePools({
SmartRouter.getV2CandidatePools({
// @ts-ignore
onChainProvider: () => this.createPublicClient(),
// @ts-ignore
Expand Down Expand Up @@ -449,7 +437,9 @@ export class PancakeSwap implements Uniswapish {
// @ts-ignore
onChainProvider: () => this.createPublicClient(),
});

const pools = await this.getPools(baseToken, quoteToken);
logger.info(`Found ${pools.length} pools for ${baseToken.symbol}-${quoteToken.symbol}`);

const trade = await SmartRouter.getBestTrade(
baseTokenAmount,
Expand Down
Loading