Uniswap subgraph 范例
1、Uniswap info 如果要用在自己的基于Uniswap V2合约的Swap上,简单来讲要做以下调整:
A、subgraph.yaml
修改数据源:
source:
address: '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'
abi: Factory
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 注意,地址请务必用小写。
const
WETH_ADDRESS = '0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f'
// New Stablecoin pair needed!
// TODO: HUSD to HUSDT
const
WHT_HUSD_PAIR = '0xf07b1e4a87794293f781373fd1f0cfa65e7592a4'
export function
getHtPriceInUSD
():
BigDecimal
{
// fetch eth prices for each stablecoin
let
husdPair = Pair.load(WHT_HUSD_PAIR) // usdt is token0
if (husdPair !== null)
{
return husdPair.token0Price
}
else
{
return ZERO_BD
}
}
// token where amounts should contribute to tracked volume and liquidity
let
WHITELIST: string[] =
[
'0x5545153ccfca01fbd7dd11c0b23ba694d9509a6f', // WHT
'0x0298c2b32eae4da002a15f36fdf7615bea3da047', // HUSD
'0x64ff637fb478863b7468bc97d30a5bf3a428a1fd', // ETH
'0x66a79d23e58475d2738179ca52cd0b41d73f0bea', // HBTC
'0xa71edc38d189767582c38a3145b5873052c3e47a' // HUSDT
]
Subgraph 示例下载地址:
Last updated