• Stars
    star
    129
  • Rank 279,262 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A JS port of "mev-inspect-py" optimised for ease of use.

MEV Inspect

A JS port of mev-inspect-py optimised for ease of use.

Motivation

While mev-inspect-py is great, I believe that there are a few changes can be made to make historical MEV data more accessible. Here are some defining decisions for this port:

  • Written in Typescript: easier to run in browser/node, while keeping the code type-safe
  • Infra layer decoupling: message query, caching, and persistence layers can be added independenty when/if needed
  • Pricing data decoupling: to calculate profit and cost in USD, a pricing provider of your choice can be used
  • Single transaction inspection: while missing some types of MEV, this is helpful for quick transaction review
  • Using logs instead of call traces: any historical node would work

Other, less fundamental, changes include:

  • Fork support (e.g. Sushiswap)
  • Multichain support
  • Abilitiy to "bring your own transaction receipts" (e.g. via Alchemy)

API

  • Inspector
    • constructor(chainId, provider)
    • tx(hash): processes a single transaction given hash
    • block(number): processes a single block given number
    • receipts(receipts): processes an arbitrary amount of transaction receipts
  • getBlock(mev): get MEV block number
  • getTransaction(mev): get MEV transaction hash
  • getArbitrages(mevList): filter out non-arbitrage MEV
  • getLiquidations(mevList): filter out non-liquidation MEV
  • getSandwiches(mevList): filter out non-sandwich MEV
  • getJitSandwiches(mevList): filter out non-JIT liquidity sandwich MEV
  • getNftArbitrages(mevList): filter out non-NFT arbitrage MEV

A common data flow is to first fetch all the MEV using any of the Inspector method, then filter it by type using getArbitrages, etc, and finally process each type of MEV separately

Usage

This package requires ethers V6. If you use ethers V5, you need to use mev-inspect V3.

This package uses BigInt. If you use a bundler, you may want to set the build target to es2020.

This package is a pure ESM package. Follow this guide for more info.

npm i mev-inspect
// Ethers V6
import { AlchemyProvider } from 'ethers';
import { Inspector } from 'mev-inspect';

const arbitrageTx =
  '0x06387618ee3752bed447f192802895921a7d45a60875927adfedc93a68bcbe05';
const key = process.env.PROVIDER_KEY;
const provider = new AlchemyProvider(1, key);
const inspector = new Inspector(1, provider);
const txMev = await inspector.tx(arbitrageTx);
console.log(txMev);

For more examlples, see examples.

Support

MEV type

  • Arbitrage
  • Liquidations
  • Sandwiches
  • JIT liquidity sandwiches
  • NFT arbitrage

Chains

  • Ethereum
  • Polygon
  • Arbitrum
  • Optimism
  • Avalanche

Protocols

  • Swaps: Uniswap V2/V3 (+ forks), Balancer V1/V2, Curve V1/V2, 0x V3/V4, Bancor V2/V3
  • Lending: Compound V2 (+ forks), Aave V1/V2/V3
  • NFT swaps: Opensea (Seaport), LooksRare, Sudoswap, X2Y2

How it works

It starts by fetching all event logs for a given transaction or block. Then, it "sorts" logs based on their source and type. From those logs, it extracts swap data. It then analyzes the swaps to find arbitrage.

More Repositories

1

blocksmith

Bitcoin/Ethereum key manipulation
Python
255
star
2

ethcall

ethers.js-compatible wrapper around Multicall
TypeScript
177
star
3

astro-analytics

Astro components for site analytics
Astro
110
star
4

hollander-core

ERC20 token swaps via gradual dutch auctions
Solidity
43
star
5

deployless-multicall

Solidity
28
star
6

catflip

MakerDAO system parameters
Vue
16
star
7

bag-app

Onchain Farcaster Frames
TypeScript
15
star
8

ethereum-json-rpc

An interactive reference of the Ethereum node API
Vue
13
star
9

abi-coder

Ethereum ABI encoding and decoding utils
TypeScript
11
star
10

metablock-page

Vue
10
star
11

astro-head

Batteries-included Astro component for your `<head>`
Astro
8
star
12

brickwork-vue

Customizable and accessible UI components with sane defaults for Vue 3
Vue
8
star
13

ethlabel

Ethereum address to labels mapping database
TypeScript
7
star
14

telegame

Library for Telegram Gaming Platform
Python
6
star
15

module-frame

FC frames + ERC7579 modules
Solidity
6
star
16

sandpack-vue

Vue components for Sandpack
TypeScript
6
star
17

astro-latex

LaTeX component for Astro
Astro
4
star
18

module-airdrop-claim

TypeScript
4
star
19

evmbeat

Live stats for 20+ EVM networks
Vue
4
star
20

mev-explorer

Vue
3
star
21

sublime-astro

Astro syntax highlighting for Sublime Text
3
star
22

hollander-react

TypeScript
2
star
23

compound-governance-dashboard

Compound Governance Dashboard (currently Ropsten)
Vue
2
star
24

starter-app

Bare-bones app template using Vue, Vite, and Vercel
Vue
2
star
25

ethdev

Ethereum dapp development utilities
JavaScript
2
star
26

eip-7702

TypeScript
2
star
27

balancer-toolbox

Vue
1
star
28

hollander-subgraph

https://thegraph.com/hosted-service/subgraph/destiner/hollander-goerli
TypeScript
1
star
29

sor

JavaScript
1
star
30

hyperlane-hook-scroll

Solidity
1
star
31

hollander-app

Vue
1
star
32

block-subgraph

Block indexing subgraph
TypeScript
1
star
33

astro-alpha

Bold, but minimal blog theme for Astro.
Vue
1
star
34

reports

1
star
35

telegram-bot

TypeScript
1
star