WeChart

Jan 28, 2022 | Blockchain

We-Chart-Logo

WeChart is a tool aiming to provide a software capable to detect whenever a token changes its price on the most common decentralised exchanges (DEXes) alive like PancakeSwap, BiSwap, Uniswap, etc., based on the chain where the scraper is running. It does this in the most efficient way possible, tracking such changes and recording them in a database (MongoDB). To run this tool, you will need a commercial full-node provider.

How Does This Work?

The price scraper listens for the latest swap made to the blockchain. Think of it like a lookout in a watchtower, observing and taking notes on every transaction that happens in the marketplace. By examining the liquidity pair reserves, it can accurately calculate token prices, capture the router of the swap, and determine the pair of tokens involved, just like a skilled trader noting down the prices of the items in a bustling market.

Setup

Follow these simple steps to set up WeChart:

  • Install MongoDB: sudo apt install -y mongodb
  • Install Node.js: sudo apt install nodejs
  • Install npm: sudo apt install npm
  • Download the repository.
  • Navigate to the repo from the terminal: cd pathtotokenChartingRepo
  • Install the repo dependencies: npm i
  • Create a .env and a config.js file based on the provided examples.
  • Start the scraper:
    • If you want it to restart on crash:
      • Install PM2: sudo npm install pm2 -g
      • Make PM2 restart the scraper if the server crashes:
        pm2 startup
      • Run the scraper:
        pm2 start npm --name charting-bot-restarter -- run restarter
      • Save the PM2 running processes:
        pm2 save
      • To see the current active PM2 processes:
        pm2 status
      • To see the scraper logs:
        pm2 logs charting-bot
    • If you don’t want it to restart on crash:
      npm run scraper

Improve This

If you know a more efficient way, or have any other suggestions, please let the community know by opening an issue with information about your ideas! ❤️ This repo can be used not only with PancakeSwap but also with any other exchange platform on any chain that is similar to PancakeSwap.

To Do

  • Multi-chain scraping (almost done) [currently BSC only]
  • Multi-chain server querying [currently BSC only]

Query the Prices

Inside the repo, you will find a REST API built with Express.js that allows you to query the scraped prices. Run the server with:

npm run server

Endpoints

  • GET /tokenprice/:contract: Returns the token price.
  • GET /tokenhistory/:contract?from=to=: Returns the history of the token in the specified time range (use unix timestamps to specify the time ranges).
  • There are more endpoints not documented yet.

Troubleshooting

If you encounter any bugs or issues, please report them, and I will try to respond as soon as possible. For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox