Arbitrage on Uniswap V2 Router

Using Gas Price Analysis of the Global TX Mempool and Front-running for sending TX

This is a quick example of getting all pending transactions from a Global TX mempool and filtering those sent to the Uniswap V2 Router. Using the ZMOK Front-running extension to get to the newest block and make an arbitrage.

1. Define what you target

  • Find the smart contract: Uniswap V2 Router (0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
  • Find the method signature, the first 4-bytes from the input, directly from the list of pending transactions or from the details of Input Data. (0x38ed1739* filters swapExactTokensForTokens)

The same can be applied to Uniswap V3 Router or any other decentralized exchange.

2. Track queued and pending transactions from around the globe in real-time

To monitor as many transactions as possible in a decentralized blockchain, you’d need to sync with hundreds of nodes around the globe. ZMOK brings you Global TX Mempool, a database where we centralise queued and pending transactions from mempools around the World.

Global TX Mempool is the initial part of the Front-running extension. Purchase it and add a new app with a Mainnet Front-running network. Copy the given FR endpoint (https://api.zmok.io/fr/…..)

Use the zmk_txpool_search custom method to search:

curl -X POST https://api.zmok.io/fr/your-app-id

-H ‘Content-type: application/json’

-d ‘{“jsonrpc”: “2.0”, “method”: “zmk_txpool_search”,

“params”:[{“to”: “0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D”, “input”: “0x38ed1739*”}], “id”: 1}’

As a result, you get all queued and pending transactions.

3. Make an arbitrage

Read the highest Gas parameters and set your gas +1gwei. Prepare your transaction to be sent.

Now, you need to get to the same or the newest block. It can be done simply by sending a raw transaction to the front-running endpoint, see the code example: https://docs.zmok.io/#/?id=devs-calling-sendrawtransaction-method-directly-from-your-code

Example repository

We did an example repository to be customised for your needs: https://github.com/zmok-io/uniswap-txpool-gasprice-checker

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
ZMOK.io

ZMOK.io

88 Followers

The fastest Ethereum nodes with the broadest supported WEB3 API methods