Liquidity mining usually requires pledge of loan vouchers or LP vouchers. That is to say, instead of pledging the original token to get the reward of liquidity mining, users need to pledge the original token in DeFi first, and then pledge the voucher to the specified contract to get the reward of liquidity mining.
1、interface-2.6.0node_modules uniswapsdkdistconstants.d.ts(chainID,工厂)
增加chainID,替换factory,initcode
//line3,增加BSC 97
export declare enum ChainId{
MAINNET=1,
ROPSTEN=3,
RINKEBY=4,
GÖRLI=5,
KOVAN=42,
BSC=97
}
//line20,替换工厂和initcode
export declare const FACTORY_ADDRESS="0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";
export declare const INIT_CODE_HASH="0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f";
2、interface-2.6.0node_modules uniswapsdkdistsdk.esm.js(chainID,工厂,weth)
增加chainID,替换factory,initcode
增加weth
同目录下sdk.cjs.development.js,如有需要,也一样的方式替换
//line18,增加BSC
(function(ChainId){
ChainId[ChainId["MAINNET"]=1]="MAINNET";
ChainId[ChainId["ROPSTEN"]=3]="ROPSTEN";
ChainId[ChainId["RINKEBY"]=4]="RINKEBY";
ChainId[ChainId["GxD6RLI"]=5]="GxD6RLI";
ChainId[ChainId["KOVAN"]=42]="KOVAN";
ChainId[ChainId["BSC"]=97]="BSC";
})(ChainId||(ChainId={}));
//替换factory,initcode
var FACTORY_ADDRESS='0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
var INIT_CODE_HASH='0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f';
//line442,增加对应的weth
var WETH=(_WETH={},_WETH[ChainId.MAINNET]=/#__PURE__/new Token(ChainId.MAINNET,'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',18,'WETH','Wrapped Ether'),_WETH[ChainId.ROPSTEN]=/#__PURE__/new Token(ChainId.ROPSTEN,'0xc778417E063141139Fce010982780140Aa0cD5Ab',18,'WETH','Wrapped Ether'),_WETH[ChainId.RINKEBY]=/#__PURE__/new Token(ChainId.RINKEBY,'0xc778417E063141139Fce010982780140Aa0cD5Ab',18,'WETH','Wrapped Ether'),_WETH[ChainId.GÖRLI]=/#__PURE__/new Token(ChainId.GÖRLI,'0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6',18,'WETH','Wrapped Ether'),_WETH[ChainId.KOVAN]=/#__PURE__/new Token(ChainId.KOVAN,'0xd0A1E359811322d97991E03f863a0C30C2cF029C',18,'WETH','Wrapped Ether'),_WETH[ChainId.BSC]=/#__PURE__/new Token(ChainId.BSC,'0x替换成自己的WETH地址',18,'WETH','Wrapped Ether'),_WETH);
3、interface-2.6.0node_modules uniswapdefault-token-listbuilduniswap-default.tokenlist.json(weth)
WETH
//文件最下面按照格式增加一个weth
{
"name":"Wrapped Ether",
"address":"0x替换自己部署的weth",
"symbol":"WETH",
"decimals":18,
"chainId":97,
"logoURI":"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xd0A1E359811322d97991E03f863a0C30C2cF029C/logo.png"
}
4、interface-2.6.0node_modules uniswapsdkdistentitiestoken.d.ts(weth)
WETH
export declare const WETH:{
1:Token;
3:Token;
4:Token;
5:Token;
42:Token;
97:Token;
};
5、interface-2.6.0srcconnectorsindex.ts(网页支持的chainID)
增加支持的chainID
//line29,支持的网络增加97
export const injected=new InjectedConnector({
supportedChainIds:[1,3,4,5,42,97]
})
6、interface-2.6.0srcconstantsindex.ts(路由,weth)
替换路由,增加weth
//line6,替换路由地址
export const ROUTER_ADDRESS='0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D'
//line20,增加BSC
const WETH_ONLY:ChainTokenList={
[ChainId.MAINNET]:[WETH[ChainId.MAINNET]],
[ChainId.ROPSTEN]:[WETH[ChainId.ROPSTEN]],
[ChainId.RINKEBY]:[WETH[ChainId.RINKEBY]],
[ChainId.GÖRLI]:[WETH[ChainId.GÖRLI]],
[ChainId.KOVAN]:[WETH[ChainId.KOVAN]],
[ChainId.BSC]:[WETH[ChainId.BSC]]
}
7、interface-2.6.0srcconstantsmulticallindex.ts(multicall)
替换multicall合约地址
合约代码https://cn.etherscan.com/address/0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441#code
直接复制下,部署一个即可
const MULTICALL_NETWORKS:{[chainId in ChainId]:string}={
[ChainId.MAINNET]:'0xeefBa1e63905eF1D7ACbA5a8513c70307C1cE441',
[ChainId.ROPSTEN]:'0x53C43764255c17BD724F74c4eF150724AC50a3ed',
[ChainId.KOVAN]:'0x2cc8688C5f75E365aaEEb4ea8D6a480405A48D2A',
[ChainId.RINKEBY]:'0x42Ad527de7d4e9d9d011aC45B31D8551f8Fe9821',
[ChainId.GÖRLI]:'0x77dCa2C955b15e9dE4dbBCf1246B4B85b651e50e',
[ChainId.BSC]:'0x替换成自己部署的地址'
}
8、interface-2.6.0srcconstantsv1index.ts(v1 factory避免报错)
v1的factory,增加一个空的就好了
const V1_FACTORY_ADDRESSES:{[chainId in ChainId]:string}={
[ChainId.MAINNET]:'0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95',
[ChainId.ROPSTEN]:'0x9c83dCE8CA20E9aAF9D3efc003b2ea62aBC08351',
[ChainId.RINKEBY]:'0xf5D915570BC477f9B8D6C0E980aA81757A3AaC36',
[ChainId.GÖRLI]:'0x6Ce570d02D73d4c384b46135E87f8C592A8c86dA',
[ChainId.KOVAN]:'0xD3E51Ef092B2845f10401a0159B2B96e8B6c3D30',
[ChainId.BSC]:''
}
9、interface-2.6.0srcstatelistshooks.ts(增加chainID配置)
//line33,增加一个
/**
*An empty result,useful as a default.
*/
const EMPTY_LIST:TokenAddressMap={
[ChainId.KOVAN]:{},
[ChainId.RINKEBY]:{},
[ChainId.ROPSTEN]:{},
[ChainId.GÖRLI]:{},
[ChainId.MAINNET]:{},
[ChainId.BSC]:{}
}
10、interface-2.6.0srcutilsindex.ts(浏览器跳转查看hash)
该修改主要用于交易后的提示hash,可以直接点击到浏览器查看
注意host不要斜杠/结尾
//line20-30,直接用下面的替换
const ETHERSCAN_PREFIXES:{[chainId in ChainId]:string}={
1:'https://etherscan.io',
3:'https://ropsten.etherscan.io',
4:'https://rinkeby.etherscan.io',
5:'https://goerli.etherscan.io',
42:'https://kovan.etherscan.io',
97:'https://testnet.bscscan.com'
}
export function getEtherscanLink(chainId:ChainId,data:string,type:'transaction'|'token'|'address'):string{
const prefix=${ETHERSCAN_PREFIXES[chainId]||ETHERSCAN_PREFIXES[1]}
11、interface-2.6.0srccomponentsHeaderindex.tsx(显示的网络名称)
网页右上角显示网络名称
//line129,ChainId.BSC是在sdk中添加的,对应的值Bsc只是一个展示
const NETWORK_LABELS:{[chainId in ChainId]:string|null}={
[ChainId.MAINNET]:null,
[ChainId.RINKEBY]:'Rinkeby',
[ChainId.ROPSTEN]:'Ropsten',
[ChainId.GÖRLI]:'Görli',
[ChainId.KOVAN]:'Kovan',
[ChainId.BSC]:'Bsc'
}