问题描述
我复制了 Julian 的代码,稍作修改,现在我无法理解如何在此处编写获取流动性函数的代码。
谁能给点建议?我完全迷路了
enter coconst ethers = require('ethers');
const addresses = {
WBNB: '0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c',factory: '0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73',router: '0x10ED43C718714eb63d5aA57B78B54704E256024E',recipient: 'your address'
}
//First address of this mnemonic must have enough BNB to pay for tx fess
const mnemonic = 'your mnemonic';
const provider = new ethers.providers.WebSocketProvider('wss://apis.ankr.com/wss');
const wallet = ethers.Wallet.fromMnemonic(mnemonic);
const account = wallet.connect(provider);
const factory = new ethers.Contract(
addresses.factory,['event PairCreated(address indexed token0,address indexed token1,address pair,uint)'],account
);
factory.on('PairCreated',async (token0,token1,pairAddress) => {
console.log(Date.Now() + "\n");
console.log(`
New pair detected
=================
token0: ${token0}
token1: ${token1}
pairAddress: ${pairAddress}
`);
});
类似这个功能
const pairBNBvalue = await erc.balanceOf(pairAddressx);
jmlBnb = await ethers.utils.formatEther(pairBNBvalue);
console.log(`value BNB : ${jmlBnb}`);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)