Skip to content

Instantly share code, notes, and snippets.

@ryanberckmans
Created June 6, 2021 16:57
Show Gist options
  • Save ryanberckmans/ce33d2eea8809be9dbb94799d5be7a2d to your computer and use it in GitHub Desktop.
Save ryanberckmans/ce33d2eea8809be9dbb94799d5be7a2d to your computer and use it in GitHub Desktop.
Yesterday's total miner revenue from flashbots mev
# Here's a bash 1-liner to calculate how much flashbots MEV revenue was earned by miners yesterday.
# It uses the flashbots API, coingecko API, and requires curl, awk, jq, and ruby.
# Data is only available for the last 24 hours or most recent 10,000 blocks, per flashbots API limits.
# See blocks.flashbots.net.
#
# Example output:
#
# Yesterday's total miner MEV revenue
# -----------------------------------
# 486.25 ETH
# $1,324,337.98 USD (with an ETH price of $2723.56)
#
# Here's the 1-liner:
RECENT_BLOCK_LIMIT=5760 && LAST_24H_TOTAL_MEV_MINER_REWARD_ETH=$(curl --silent https://blocks.flashbots.net/v1/blocks?limit=$RECENT_BLOCK_LIMIT | jq '.blocks[].miner_reward' | tr -d '"' | awk '{s+=$1} END {print s}' | ruby -e 'p $stdin.gets.to_i / 10.0**18') && ETH_USD=$(curl --silent "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd" | jq '.ethereum.usd') && LAST_24H_TOTAL_MEV_MINER_REWARD_USD=$(ruby -e "p $LAST_24H_TOTAL_MEV_MINER_REWARD_ETH * $ETH_USD") && LAST_24H_TOTAL_MEV_MINER_REWARD_ETH_FORMATTED=$(printf "%'.2f\n" $LAST_24H_TOTAL_MEV_MINER_REWARD_ETH) && LAST_24H_TOTAL_MEV_MINER_REWARD_USD_FORMATTED=$(printf "$%'.2f\n" $LAST_24H_TOTAL_MEV_MINER_REWARD_USD) && echo -e "Yesterday's total miner MEV revenue\n-----------------------------------\n$LAST_24H_TOTAL_MEV_MINER_REWARD_ETH_FORMATTED ETH\n$LAST_24H_TOTAL_MEV_MINER_REWARD_USD_FORMATTED USD (with an ETH price of \$$ETH_USD)\n\nNote: yesterday's data is defined as the most recent 5760 blocks"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment