Skip to content

Commit

Permalink
chore: Replace with studio endpoints (#9844)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->


<!-- start pr-codex -->

---

## PR-Codex overview
This PR updates PancakeSwap's endpoints to replace the proxy endpoint
with the studio endpoint, enhancing data retrieval efficiency.

### Detailed summary
- Replaced proxy endpoint with studio endpoint in `endpoints.ts`
- Added `theGraphApiKey` parameter in `SubgraphParams`
- Updated subgraph URLs with `theGraphApiKey` in `subgraphs.ts`

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your
question}`

<!-- end pr-codex -->
  • Loading branch information
chefjackson committed May 21, 2024
1 parent 1e5dca9 commit 63a63d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/good-days-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pancakeswap/chains': patch
---

Replace proxy endpoint with studio endpoint
5 changes: 4 additions & 1 deletion apps/web/src/config/constants/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ export const CELER_API = 'https://api.celerscan.com/scan'

export const EXPLORER_API = 'https://info-gateway.pancakeswap.com'

export const THE_GRAPH_PROXY_API = 'https://thegraph.pancakeswap.com'

export const V2_SUBGRAPH_URLS = {
...V2_SUBGRAPHS,
[ChainId.BSC]: `${EXPLORER_API}/subgraphs/v2/bsc/graphql`,
[ChainId.POLYGON_ZKEVM]: `${THE_GRAPH_PROXY_API}/exchange-v2-polygon-zkevm`,
}

export const BLOCKS_CLIENT_WITH_CHAIN = BLOCKS_SUBGRAPHS
Expand All @@ -57,7 +60,7 @@ export const ASSET_CDN = 'https://assets.pancakeswap.finance'

export const V3_SUBGRAPH_URLS = {
...V3_SUBGRAPHS,
// [ChainId.BSC]: `${EXPLORER_API}/subgraphs/v3/bsc/graphql`,
[ChainId.POLYGON_ZKEVM]: `${THE_GRAPH_PROXY_API}/exchange-v3-polygon-zkevm`,
}

export const STABLESWAP_SUBGRAPHS_URLS = {
Expand Down
9 changes: 5 additions & 4 deletions packages/chains/src/subgraphs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ChainId } from './chainId'

type SubgraphParams = {
noderealApiKey?: string
theGraphApiKey?: string
}

const publicSubgraphParams = {
Expand All @@ -20,15 +21,15 @@ export const STABLESWAP_SUBGRAPHS = {
[ChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-stableswap-arb',
} as const

export function getV3Subgraphs({ noderealApiKey }: SubgraphParams) {
export function getV3Subgraphs({ noderealApiKey, theGraphApiKey }: SubgraphParams) {
return {
[ChainId.ETHEREUM]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-eth',
[ChainId.GOERLI]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-goerli',
[ChainId.BSC]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-bsc',
[ChainId.BSC_TESTNET]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-chapel',
[ChainId.ARBITRUM_ONE]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-arb',
[ChainId.ARBITRUM_GOERLI]: 'https://api.thegraph.com/subgraphs/name/chef-jojo/exhange-v3-arb-goerli',
[ChainId.POLYGON_ZKEVM]: 'https://thegraph.pancakeswap.com/exchange-v3-polygon-zkevm',
[ChainId.POLYGON_ZKEVM]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/subgraphs/id/7HroSeAFxfJtYqpbgcfAnNSgkzzcZXZi6c75qLPheKzQ`,
[ChainId.POLYGON_ZKEVM_TESTNET]: null,
[ChainId.ZKSYNC]: 'https://api.studio.thegraph.com/query/45376/exchange-v3-zksync/version/latest',
[ChainId.ZKSYNC_TESTNET]: 'https://api.studio.thegraph.com/query/45376/exchange-v3-zksync-testnet/version/latest',
Expand All @@ -46,11 +47,11 @@ export function getV3Subgraphs({ noderealApiKey }: SubgraphParams) {
} as const satisfies Record<ChainId, string | null>
}

export function getV2Subgraphs({ noderealApiKey }: SubgraphParams) {
export function getV2Subgraphs({ noderealApiKey, theGraphApiKey }: SubgraphParams) {
return {
[ChainId.BSC]: 'https://proxy-worker-api.pancakeswap.com/bsc-exchange',
[ChainId.ETHEREUM]: 'https://api.thegraph.com/subgraphs/name/pancakeswap/exhange-eth',
[ChainId.POLYGON_ZKEVM]: 'https://thegraph.pancakeswap.com/exchange-v2-polygon-zkevm',
[ChainId.POLYGON_ZKEVM]: `https://gateway-arbitrum.network.thegraph.com/api/${theGraphApiKey}/subgraphs/id/37WmH5kBu6QQytRpMwLJMGPRbXvHgpuZsWqswW4Finc2`,
[ChainId.ZKSYNC_TESTNET]: 'https://api.studio.thegraph.com/query/45376/exchange-v2-zksync-testnet/version/latest',
[ChainId.ZKSYNC]: ' https://api.studio.thegraph.com/query/45376/exchange-v2-zksync/version/latest',
[ChainId.LINEA_TESTNET]: 'https://thegraph.goerli.zkevm.consensys.net/subgraphs/name/pancakeswap/exhange-eth/',
Expand Down

0 comments on commit 63a63d8

Please sign in to comment.