0
//original code courtesy of EatTheBlocks   

factory.on('PairCreated', async (token0, token1, pairAddress) => {
    console.log(`
      New pair detected on PancakeSwap
      =================
      token0Address: ${token0}
      token1Address: ${token1}
      pairAddress: ${pairAddress}
    `)
});

//Here's a snippet I've been trying to use but I don't know the right parameters
// and construction and intellisense isn't really helping me at all
// const newPairContract = new ethers.Contract(
//   pairAddress,
//   [''],
//   account
// );

This code works fine but when I manually check the results on bscScan, most of the counterparts to a BNB token turn out to be LP tokens. From this point, for the non-BNB token, I need to determine the symbol, name (if non-LP), and size of the liquidity pool.

Please if you can answer this question, let's stay within the boundaries of Node.js and Web3 and don't lead me to a language that I don't know, like Py.

10
  • why do you need these bogus variables? The Name is Pancake LPs and the Symbol is Cake-LP , they are hardcoded, you don't need to query them: github.com/pancakeswap/pancake-swap-core/blob/…
    – Nulik
    Jul 29 at 23:16
  • for the size of liquidity pool, yeah, it makes sense, the method is totalSupply()
    – Nulik
    Jul 29 at 23:17
  • everybody queries ethereum using javascript, I don't know why you can't find examples on the net, if you would ask for Golang, or Rust,that would be rare thing indeed
    – Nulik
    Jul 29 at 23:18
  • @Nulik, you misunderstand the first part of my question. The factory emits a message when a new pair is created that includes the addresses of the two tokens in the new pair. For my purposes, I am only interested in pairs where one of the two tokens is WBNB. The first part of my question is how to find the name and symbol of the token that is not WBNB. It must be a new token but when I check manually, bscScan shows them as LP tokens, so I guess that means most of them are LP tokens and I won't be able to see a new token manually unless I'm very, very lucky. Ergo, this code. Jul 29 at 23:34
  • Regarding your answer for the second part of my question, thank you so much. I've seen this variable in the documentation but I don't know exactly how to call it. I started to write it like this: // const newPairContract = new ethers.Contract( // pairAddress, // [''], // account // ); But I don't know how to wire it up from here and the intellisense hover-overs would really be useful if I already knew the constructs. Jul 29 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.