为pancakeswap的js代码getpair bot实现“getliquidity”函数

js5cn81o  于 2021-09-23  发布在  Java
关注(0)|答案(0)|浏览(286)

我复制了朱利安的代码,修改了一点,现在我不知道如何在这里编写流动性函数。
有人能提出一些建议吗?我完全迷路了

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}`);

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题