# Uniswap subgraph 范例

1、Uniswap info 如果要用在自己的基于Uniswap V2合约的Swap上，简单来讲要做以下调整：

A、subgraph.yaml&#x20;

修改数据源：

source:&#x20;

address: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'&#x20;

abi: Factory&#x20;

startBlock: 10000834

这 里的address 和 startBlock 请根据实际的合约进行调整。startBlock一般以合约创建的区块作为起始区块。

network 目前在 HyperGraph中，Heco和BSC请写为mainnet， HSC的请写为hsc

B、修改代码src/mappings/helpers.ts 中的 Factory 合约地址

export const FACTORY\_ADDRESS = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'

C、修改稳定币和跟踪流动性的白名单资产

修改的地方在: src/mappings/pricing.ts 注意，地址请务必用**小写**。

&#x20;**`const`**` ``WETH_ADDRESS = '0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f'`

`// New Stablecoin pair needed!`

`// TODO: HUSD to HUSDT`

**`const`**` ``WHT_HUSD_PAIR = '0xf07b1e4a87794293f781373fd1f0cfa65e7592a4'`

`export function`` `**`getHtPriceInUSD`**`():`` `**`BigDecimal`** **`{`**

&#x20; `// fetch eth prices for each stablecoin`

&#x20; **`let`**` ``husdPair = Pair.load(WHT_HUSD_PAIR) // usdt is token0`

&#x20; `if (husdPair !== null)`` `**`{`**

&#x20;   `return husdPair.token0Price`

&#x20; **`}`**` ``else`` `**`{`**

&#x20;   `return ZERO_BD`

&#x20; **`}`**

**`}`**

`// token where amounts should contribute to tracked volume and liquidity`

**`let`**` ``WHITELIST: string[] =`` `**`[`**

&#x20; `'0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f', // WHT`

&#x20; `'0x0298c2b32eae4da002a15f36fdf7615bea3da047', // HUSD`

&#x20; `'0x64ff637fb478863b7468bc97d30a5bf3a428a1fd', // ETH`

&#x20; `'0x66a79d23e58475d2738179ca52cd0b41d73f0bea', // HBTC`

&#x20; `'0xa71edc38d189767582c38a3145b5873052c3e47a'  // HUSDT`

**`]`**

Subgraph 示例下载地址：

{% embed url="<https://github.com/HGDotNetwork/Uniswap-v2-subgraph>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hg.network/product-chan-pin-bang-zhu/xiang-mu-fan-li/uniswap-subgraph-fan-li.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
