Skip to content

Commit

Permalink
refactor: subgraph url by network
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Feb 2, 2024
1 parent 928a6b1 commit 1cd7b69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions packages/token-converter-bot/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const subgraphUrlByNetwork = {
bsctestnet: "https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-chapel",
bscmainnet: "https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-bsc"
}

const config = {
subgraphUrl: subgraphUrlByNetwork[process.env.NETWORK]
}

export default config
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { SUPPORTED_CHAINS } from "../config/chains";
import { chains } from "../config/chains";
import publicClient from "../config/clients/publicClient";
import walletClient from "../config/clients/walletClient";
import config from '../config';

const REVERT_IF_NOT_MINED_AFTER = 60n; // seconds
const MAX_HOPS = 5;
Expand Down Expand Up @@ -37,7 +38,7 @@ export class TokenConverter {
abi: tokenConverterOperatorAbi,
};
this.v3SubgraphClient = createClient({
url: "https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-bsc",
url: config.subgraphUrl,
requestPolicy: "network-only",
});
this.quoteProvider = SmartRouter.createQuoteProvider({ onChainProvider: () => this.publicClient });
Expand Down

0 comments on commit 1cd7b69

Please sign in to comment.