Analyzing the Block Builder's Revenue

Analyzing the Block Builder's Revenue

masterdai

masterdai

Devrel

In our recent article, I briefly discussed the significant role that the block builder plays within the MEV supply chain network. The block builder's main responsibility is to combine transactions from the mempool with the profitable bundles being built by the searcher.

In this article, I will guide you through a step-by-step process to calculate the cost and revenue of the block builder.

Let's take a specific block as an example, block number 17419900. You can search for it on the Ethscan website and identify its block builder through the extra data or fee recipient transaction. Clearly, this block was produced by Flashbots Builder.

ethereum-block-1741990.png

last-TX-1741990.png

At the end of the block for which the block builder is responsible, the block builder also rewards the validator who proposed the block. In this case, flashbots-builder.eth sent 0.1919321 ether to the validator's address, serving as both the MEV-boost reward and the cost of the block builder.

The revenue of the block builder is divided into two parts. The first part is the block reward, which is calculated by subtracting the burnt fees from the transaction fees. In this case, it amounts to 0.18263526 ether. The second part is the direct payments made by validators to the block builder. Searchers have the option to directly pay the block builder a certain amount of ether. This behavior typically occurs through internal transactions within the block. The following example demonstrates this: 0x9ba88D transferred 0.012998 ether to flashbots-builder.eth.

Which means the total revenue of the flashbots builder in this block is :

0.18263526 + 0.012998 - 0.1919321 = 0.00370116 ether

internal-TX-1741990.png

Block builders sometimes subsidize their operations to gain a larger market share, leading to blocks with negative revenue. Delphi Digital's article highlights builder 0x69 as an example, which successfully subsidizes the majority of their blocks while still turning a profit. Notably, they achieve significant profits from specific blocks such as block 16067709 (with a 76 ETH profit) and block 16067699 (with a 139 ETH profit). This strategic use of subsidies is employed by builders aiming to capture the market. In the block building industry, it's a winner-take-all scenario. Despite generally thin profits, there exists the potential for substantial ETH returns.

If you want to analyze data related to Ethereum blocks, you can use this query to retrieve the last transfer(data:0x) transaction recorded in each block. The query identifies and selects the latest transaction for each block in the Ethereum blockchain.

with indexs as (
    select
        block_number,
        max(transaction_index) as transaction_index
    from
        ethereum.transactions
    where block_timestamp>'2023-04-01'
    group by block_number
)
select
    block_number,
    block_timestamp,
    from_address,
    to_address,
    value / 1e18 as ETH,
	input
from
    ethereum.transactions
where (block_number,transaction_index) in (select * from indexs)
and input = '0x'

 order by block_number desc
  1. The query begins by creating a temporary set of data called indexs. This set includes two columns: block_number and transaction_index. It is created by looking at the ethereum.transactions table and selecting the highest transaction_index for each unique block_number. Only rows where the block_timestamp is later than '2023-04-01' are considered. The data in indexs is grouped by block_number.

  2. The main part of the query retrieves specific information from the ethereum.transactions table. It selects the following columns for the output: block_number, block_timestamp, from_address, to_address, Revenue (which is calculated as value/1e18), and input.

  3. The query filters the rows from the ethereum.transactions table based on two conditions:

    • The combination of block_number and transaction_index should match the values found in the indexs set. This ensures that only rows with matching block_number and transaction_index values are included.
    • The value in the input column should be exactly '0x'.
  4. The results are then arranged in descending order based on the block_number. This means that the output will be sorted from the highest block_number to the lowest.

In simpler terms, this query retrieves specific information from the ethereum.transactions table. It first creates a temporary set of data that identifies the highest transaction_index for each block_number after a certain date. Then, it selects the desired columns from the table, filters the rows based on conditions related to block_number, transaction_index, and input value, and finally sorts the results based on the block_number in descending order.

You can also import the block data into Excel by using the following code.

Run npm install axios and npm install exceljs to install the required dependencies.

Put your SQL query into the query line, along with the task ID generated on our document.

const axios = require('axios');
const excel = require('exceljs');

const options = {
  method: 'POST',
  url: 'https://api.chainbase.online/v1/dw/query',
  headers: {
    accept: 'application/json',
    'x-api-key': 'your api key',
    'content-type': 'application/json',
  },
  data: {
    task_id: 'xxxxxxx',
    page: 1,
    query: 'your sql'
  },
};

const workbook = new excel.Workbook();
const worksheet = workbook.addWorksheet('Data');

// Add headers
worksheet.addRow(['Block Number', 'Block Timestamp', 'From Address', 'To Address', 'ETH', 'Input']);

async function fetchData(page) {
  options.data.page = page;

  try {
    const response = await axios.request(options);

    if (response.data && response.data.data && Array.isArray(response.data.data.result)) {
      const data = response.data.data.result;

      for (const row of data) {
        worksheet.addRow([
          row.block_number,
          row.block_timestamp,
          row.from_address,
          row.to_address,
          row.ETH,
          row.input,
        ]);
      }

      if (response.data.data.meta && response.data.data.meta.next_page) {
        const nextPage = response.data.data.meta.next_page;
        return fetchData(nextPage); // Return the promise to ensure sequential fetching
      } else {
        return true; // Indicate that all pages have been fetched
      }
    } else {
      console.error('Invalid response data:', response.data);
      return false; // Indicate an error occurred
    }
  } catch (error) {
    console.error(error);
    return false; // Indicate an error occurred
  }
}

async function fetchAllData() {
  let currentPage = 1;
  const totalPages = 3; // Set the total number of pages to fetch

  while (currentPage <= totalPages) {
    const success = await fetchData(currentPage);
    if (!success) {
      console.error('Error occurred while fetching data. Terminating.');
      return;
    }
    currentPage++;
  }

  await workbook.xlsx.writeFile('chainbaseData.xlsx');
  console.log('Excel file created successfully.');
}

fetchAllData();

By analyzing this data, in my case, I have chosen to select the most recent 3000 blocks' transactions and analyze the block builders' market share.

Block builderCount of To AddressSum of ETH
0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5717110.2250996
0x1f9090aae28b8a3dceadf281b0f12828e676c32664477.75061889
0x690b9a9e9aa1c9db991c7721a92d351db4fac99053675.93068564
0xdafea492d9c6733ae3d56b7ed1adb60692c98bc536234.08247563
0xb4c9e4617a16be36b92689b9e07e9f64757c17921209.349838553
0xbaf6dc2e647aeb6f510f9e318856a1bcd66c5e196413.3957448
0xfeebabe6b0418ec13b30aadf129f5dcdd4f70cea499.565605888
0x4838b106fce9647bdf1e7877bf73ce8b0bad5f97302.632173092
0xce0babc8398144aa98d9210d595e3a9714910748301.829768113
0x5124fcc2b3f99f571ad67d075643c743f38f1c34260.893549901
0xbd3afb0bb76683ecb4225f9dbc91f998713c3b01188.954708645
0x17d3c369932e200eab7264eca79e3f72a3f3d563160.030609463

In conclusion, calculating the block revenue is essential for understanding the profitability of block builders in the MEV supply chain network. The revenue of the block builder is comprised of the block reward and direct payments made by validators. However, some builders subsidize their operations to gain a larger market share, leading to blocks with negative revenue. By analyzing data related to Ethereum blocks, it is possible to retrieve specific information from the Ethereum transactions table and import it into Excel using a code snippet. Analyzing this data can help identify the market share of different block builders and potentially identify profitable blocks. Overall, understanding the revenue of block builders is crucial for understanding the economics of the MEV supply chain network.

About Chainbase

Chainbase is an all-in-one data infrastructure for Web3 that allows you to index, transform, and use on-chain data at scale. By leveraging enriched on-chain data and streaming computing technologies across one data infrastructure, Chainbase automates the indexing and querying of blockchain data, enabling developers to accomplish more with less effort.

Want to learn more about Chainbase?

Visit our website chainbase.com Sign up for a free account, and Check out our documentation.

Website|Blog|Twitter|Discord|Link3