Cover Image for Maximizing Crypto Gains: Using Mempool Data and Bitquery APIs for Token Price Predictions

Maximizing Crypto Gains: Using Mempool Data and Bitquery APIs for Token Price Predictions

Mempool
Price

The crypto market is a fast-paced game full of opportunities that look like cheat codes and malicious individuals and schemes that you may not want to be associated with.

The key difference between traditional markets and crypto markets is the way we predict the future price action of an underlying asset. Cryptocurrencies offer different data sources that are not accessible in tradfi.

One such goldmine of a source that is not very popular in the crypto market is mempool - a crucial component in blockchain architecture and a treasure trove for data-savvy and arbitrage traders. Mempool - short for memory pool serves as an awaiting area for unconfirmed transactions on a blockchain - before a transaction is included in a block.

Using on-chain data tools like Bitquery facilitates users with real-time data through subscriptions. Using live data will help you realize potential opportunities and red flags.

In this article, we will learn just that through a couple of case studies, so let’s get right into it.

How does Mempool help predict price actions?

The mempool (memory pool) in blockchain networks contains unconfirmed transactions waiting to be included in the next block. Analyzing mempool data can provide valuable real-time insights into market sentiment and potential price movements. Here's how specific attributes of mempool data can be used for token price analysis:

1. Transaction Volume and Frequency

The number and frequency of pending transactions for a particular token can indicate increased interest or activity, potentially preceding a token price movement.

Example: Uniswap (UNI) had seen a meteoric price increase during mid-February of 2024. The price of Uniswap almost doubled and the transaction count /day went almost 10x.

Onspot mempool analysis can give you an edge over others when it comes to such event types

Some reasons for the same could be:

  • Growing interest in the token, possibly due to positive news or speculation

  • Increased trading activity, which might lead to higher volatility

  • Potential price movement as demand changes

Analysis Rationale: Sudden spikes in transaction volume often precede price movements. Traders monitoring this data might interpret it as a signal to enter or exit positions, potentially amplifying the price effect.

2. Gas Fees

In networks like Ethereum, rising gas fees often correlate with increased demand for block space. This can signal growing interest in specific tokens or protocols.

Example: During the launch of Yuga Labs' Otherside NFT collection, Ethereum gas fees spiked to unprecedented levels. At its peak, gas prices reached nearly 8,000 gwei, with some users reportedly paying thousands of dollars with of ETH just in transaction fees. This surge was due to the immense demand for the NFTs, causing a massive influx of transactions on the Ethereum network.

Tracking gas fees helps us track such changes in demand and supply.

Analysis Rationale: Higher gas fees suggest users are willing to pay more to ensure their transactions are processed quickly. This often correlates with time-sensitive opportunities or strong convictions about imminent price movements.

3. Smart Contract Interactions

Pending interactions with decentralized exchanges (DEXs) or lending protocols can provide insights into imminent trading activity.

Example: YFI was launched with a total supply of only 30,000 tokens, distributed to users who provided liquidity to specific pools on yearn.finance.

Surge in Pending Transactions

  • Immediately after the announcement, there was a massive surge in pending transactions on Ethereum, particularly on decentralized exchanges like Uniswap.

  • Many users were trying to acquire YFI tokens by swapping ETH or other tokens.

  • The Ethereum mempool became congested with a high number of pending swap transactions.

Price Movement

Impact on ETH and Gas Prices

  • The surge in transactions caused Ethereum gas prices to spike dramatically.

  • While ETH price wasn't significantly impacted in this case, the gas price increase affected the entire Ethereum ecosystem.

Analysis Rationale: Smart contract interactions, especially with DEXs, directly impact token supply and demand. Large pending volumes can foreshadow imminent price changes once these transactions are confirmed.

4. Large Value Transfers

Significant pending transfers, especially from known whale addresses, may foreshadow market-moving events.

Example Compound Finance is a major DeFi lending protocol on the Ethereum blockchain. COMP is its governance token, distributed to users of the protocol as an incentive.

Event Details

  1. Bug Introduction - September 2021:
  • A buggy upgrade was implemented in the Compound protocol's Comptroller contract.

  • This bug caused the protocol to distribute excessive amounts of COMP tokens to some users.

  1. Abnormal On-chain Activity:
  • Shortly after the upgrade, observers noticed a surge in abnormal transactions involving the COMP token.

  • Large amounts of COMP were being claimed by addresses that shouldn't have been eligible for such rewards.

  • This activity was visible in the mempool before transactions were confirmed.

  1. Market Reaction:
  1. Protocol Response:
  • Compound's team acknowledged the issue and began working on a fix.

  • However, due to the protocol's governance structure, implementing the fix would take several days.

Analysis Rationale: Large holders have the potential to impact token prices significantly. Other traders often closely watch their actions, and significant movements can trigger broader market reactions.

How to Interpret Mempool Data?

The art of mempool analysis lies in interpreting various metrics to identify potential price movements. By leveraging advanced blockchain data analysis techniques, analysts can gain valuable insights into market dynamics.

Bitquery’s plethora of queries on the topic can be a good start, with its easy-to-use UI, you can also fetch data from blockchain with almost no SQL experience.

Let's explore key aspects of mempool analysis with practical examples.

1. Identifying Supply and Demand Trends

The volume and direction of pending orders in the mempool can indicate incoming market pressures.

Example: Imagine the mempool shows a sudden influx of pending orders for the ABC hypothetical token:

  • 500 pending sell orders totaling 100,000 ABC tokens

  • Only 50 pending buy orders totaling 5,000 ABC tokens

This imbalance suggests incoming selling pressure, which could lead to a price decrease for ABC token.

Advanced Technique: Implement real-time tracking of pending orders across multiple decentralized exchanges. By aggregating this data, you can get a comprehensive view of supply-demand imbalances for example total circulating supply of a token, providing a more accurate picture of potential price movements.

2. Spotting Arbitrage Opportunities

Differences in pending trades across DEXs can reveal arbitrage opportunities, often leading to short-term price equalizations.

Example: Pending orders in the mempool show:

  • DEX A: 100 pending buy orders for XYZ token at $10

  • DEX B: 100 pending sell orders for XYZ token at $10.5

This disparity indicates a potential arbitrage opportunity, which could lead to a quick price adjustment as traders exploit this difference.

Advanced Technique: Develop a system to compare pending orders across different DEXs and even different blockchains. This broader view enhances your ability to identify and act on arbitrage opportunities quickly.

3. Recognizing Spikes in Trading Activity

Explanation: Sudden increases in pending swap transactions for a particular token pair could precede a price surge or drop.

Example: The mempool shows a 50% increase in pending swap transactions for the DEFI/ETH pair in the last 10 minutes. This could indicate:

  • Breaking news about the DEFI project

  • A potential pump-and-dump scheme in progress

  • Imminent price volatility for DEFI token

Advanced Technique: Implement WebSocket connections to enable real-time monitoring of mempool activity. Set up alerts for sudden spikes in trading activity, allowing for quick reactions to market changes.

Websockets are quite useful because:

  • Real-time data: WebSockets provide a persistent connection between the client and server, allowing for instant data transmission as soon as it's available. This is crucial for mempool analysis, where timing is everything.

  • Efficiency: Unlike RESTful polling, WebSockets don't require constant requests to the server. This reduces latency and server load, making it ideal for high-frequency monitoring.

  • Scalability: WebSockets can handle a large number of simultaneous connections, making them suitable for monitoring multiple token pairs or blockchain networks concurrently.

But how to implement WebSockets? Check this Bitquery article to understand in detail.

This query can be a good starting point while studying DEX and trading volume points.

4. Detecting Patterns

Explanation: Recurring patterns in mempool data, such as regular large transfers or contract interactions, might correlate with cyclical price movements.

Example: Analysis of historical mempool data shows that every Friday at 3 PM UTC, there's a spike in pending transactions interacting with a particular yield farming contract. This pattern often precedes a 2-3% price increase in the associated token over the weekend.

Advanced Technique: Plot each and every mempool transaction you generate via Bitquery’s API into a database along with the time and token price, over time, where there are huge spikes in volatility and hefty price action, look at the mempool data. You can further itemize the data and use pattern identification algorithms to flag and analyze these data into opportunities and red flags

Let us look at some of the ways you can use Bitquery/s Mempool and subscription features to increase your profits.

Case Study 1: Detecting Rug Pulls

Mempools are a great source of predicting short-term price actions, but due to their temporary and dynamic nature hooking them up with a bigger setup makes more sense. A rug pull detection mechanism can be one of those ‘ bigger setups’. And using the Bitquery APIs can make your work cut out for you.

Rug pulls are a form of exit scam where developers and other core project stakeholders abandon a project by selling their bags and create a major imbalance in the liquidity pool that other token holders cannot sell their assets.

This is usually very common in low market cap meme coins on DEXes and is a major concern in the crypto space. Mempool analysis can help in giving early warning signs of potential rug pulls, allowing vigilant investors to get out of the project before something like this happens.

Methodology: Our approach involves monitoring the mempool for large transactions involving recently created tokens. A sudden, significant transfer of a new token can be an indicator of a potential rug pull.

Step-by-step process using Bitquery

  • Monitor large pending transactions in the mempool (especially the developer tokens)

  • Cross-reference with token creation date

  • Flag potential rug pulls or influential transactions

This is a query that gives large transactions, their value, and the associated time stamp on the mempool.

By using Bitquery, you can create a more efficient and effective rug pull detection system. It allows you to process large volumes of mempool data in real-time, potentially giving investors crucial early warnings about suspicious activity in the crypto space, without the need to build and maintain complex blockchain data infrastructure yourself.

Let's look at what the sandwich strategy is.

Case Study 2: Sandwich Trading Using Mempool Data

Sandwich trading is a strategy where a trader attempts to profit from a large pending transaction

by executing trades immediately before and after it.

The biggest challenge with this strategy is getting streamlined mempool data in the language you are comfortable in. Bitquery solves that making your work cut out for you, hence we will use Bitquery for the tool.

This tutorial helps you build dashboards to track sandwich attacks in real-time.

By leveraging mempool data, we can identify potential opportunities for this strategy. Let's explore how to implement this using Bitquery's tools.

Methodology

  • Monitor the mempool for large pending transactions through Bitquery

  • Place a buy order with higher fees to execute before the large transaction

  • Place a sell order to execute after the large transaction

This is a query that helps you detect the token price of more than a predetermined amount.

To get the query in the language you want, you can get the code snippet on the right side of the screen.

We would then need to automate to trigger another order that can help you execute steps 2 and 3 in your quant bot.

The pseudo-code looks like:

while True:

    large_tx = monitor_mempool()
    if large_tx and is_profitable(large_tx):
        # Step 1: Buy ETH with a higher gas price
        buy_eth(amount=calculate_amount(large_tx),
                gas_price=large_tx.gas_price * 1.1)
        
        # Step 2: Wait for a large transaction to be mined
        wait_for_transaction(large_tx.hash)
        
        # Step 3: Sell ETH immediately after
        sell_eth(amount=calculate_amount(large_tx))

Key Considerations

  • Speed is crucial. The system must be able to detect opportunities and execute trades very quickly.

  • Gas fees must be carefully managed to ensure profitability.

  • The strategy carries risks, including potential losses if the market moves unexpectedly or if the large transaction is canceled or modified.

  • Ethical considerations: This strategy can be seen as a form of front-running and may be considered controversial.

Implementation with Bitquery

To implement this strategy:

  • Use the subscription to monitor the mempool continuously.

  • When a large transaction is detected, quickly estimate its price impact.

  • If profitable, use this sandwich opportunity detection query to fetch current token prices and gas fees.

  • Execute the buy transaction with a slightly higher gas price.

  • Monitor the blockchain for the large transaction to be mined.

  • Immediately execute the sell transaction once the large transaction is confirmed.

This implementation leverages Bitquery's real-time mempool data to identify potential sandwich trading opportunities quickly. By using Bitquery, we can efficiently monitor the mempool without having to run and maintain our own Ethereum node, which significantly simplifies the implementation of this strategy.

However, it's crucial to note that sandwich trading is a complex and potentially risky strategy

Other than that, you can also use Mempool for:

  • Arbitrage opportunities

  • Flash Loan Attack Detection

  • MEV (Miner Extractable Value) Opportunities

  • Token Launch Monitoring

  • DApp Usage Trends

Summing up

Mempool analysis offers a unique and powerful approach to predicting token price movements in the fast-paced world of cryptocurrency trading. By leveraging the real-time insights provided by pending transactions, traders can gain a valuable edge in anticipating market shifts.

Using Bitquery for mempool analysis can help you do it faster and in a smarter manner.

--

Written by Harshil

Subscribe to our newsletter

Subscribe and never miss any updates related to our APIs, new developments & latest news etc. Our newsletter is sent once a week on Monday.