Shapley Value of MEV

We present a mechanism based on Shapley Value that redistributes MEV based on transactions' contribution to the satisfaction of user preferences. This mechanism is an implicit orderflow auction. We present an algorithm to benchmark empirically how much MEV would be redistributed back to users if this mechanism was deployed (and the distribution of those kickbacks). This mechanism is an early design of the mev-share product.

Consider the structure of a flashbots bundle, it is consisted of an array of

N user transactions
TN={t1,,tN}
and
M
searcher transactions
PM
.

Call the EVM execution function

Ξ, we use
ΞPPM(T¯,P):R+
to represent the maximum welfare (summation of utilities) of all the preferences in
P
when the bundle is constructed using transactions in the order given by the array
T¯
. Note here the array
T¯
is order-sensitive. For example, it can be that
Ξ([t1,t2],p)=1
but
Ξ([t2,t1],p)=2
.

We define a coalitional value function

VTTN,PPM(T,P) that returns the worth of a coalition of user transactions
T
to the preferences in
P
. Specifically,
VTTN,PPM(T,P)
equals the maximum value of all possible arrays (different orderings)
T¯
of transactions in
T
, i.e.,
VTTN,PPM(T,P)=maxT¯ is an ordering of all transactions in TΞ(T¯,P)
. Note that
T¯
should not discard transactions in
T
but only reorder it. Reusing the same example, if we have
Ξ([t1,t2],p)=1
and
Ξ([t2,t1],p)=2
, then
V({t1,t2},p)=2
.

For simplicity, we assume

M=1 and
P={p}
for now and abbreviate
V({t1,t2},p)=2
to
V({t1,t2})=2
.

Based on the existing structure of mev-explore,

p is usually a transaction in the bundle that is sent by the searcher that sells all of the tokens gained in previous steps into ETH and pockets that ETH into some identified proxy contract.

For example, if a searcher backruns a transaction

t1, it will send an arbitrage transaction
p
and send the bundle
t1,p
to Flashbots relay, where the relay will calculate the effective gas price of this bundle and use that as a bid to process a first price auction. Here, the ("effective gas price multiplied by the total gas used" minus "base fee multiplied by the total gas used" adds "the total ETH balance increase in the proxy contract") should act as a proxy of the total MEV extracted and therefore the utility of the preference
p
. Alternatively, we can use ("effective gas price multiplied by the total gas used" minus "base fee multiplied by the total gas used") as the utility of
p
for a more accurate estimation of historical kickback as it reflects the competitiveness of the searcher market better (we can even multiply the result by 0.8, i.e., assuming that in a competitive market, users will get 80% of the MEV share while validators/builders only get 20%).

Furthermore, we assume that the preference transaction

p reflects the actual preference of the searcher, despite that it was specifically tailored for the ordering
T¯N
, this assumption is justified by the fact that current mev-explore data doesn't take into account of off-chain hedging when calculating realized MEV, and off-chain hedging is same as our action of taking transactions out when calculating each sub-coalition
TTN
's worth.

Our mechanism works as follows:

  • we calculate the worth of each sub-coalition,
    VTTN(T)
    , if a transaction
    tT
    is sent by the searcher, we don't count it in
    T
    (this is to prevent/assuming the searchers from sybiling as users to boost their own kickback)
  • we allocate the transaction
    T
    such that
    min|T|argmaxTTNV(T)
    , i.e., we allocate the coalition that has the maximum worth, if there are multiple such coalitions, we allocate the coalition that has the smallest size
  • given the allocated coalition
    S
    , using the coalitional worth function, we calculate the shapley value of each transaction
    φtiS(ti)
  • we kickback
    φtiS(ti)
    to each transaction
    ti
    that was allocated

Some huristics we can use to refine the data analysis is to cross check

T with transactions that were in the mempool at the time and only pay out to those transactions.

We conduct our data analysis using historical data of finalized flashbots bundles (all public).

Example 1: suppose we see a bundle (suppose it is a sandwich) that has three transactions,

t1,t2,t3, we first use heuristics to figure out which is the searcher's preference
p
(mev-explore already has this function), suppose it is
t3
, then, we check if
t1
and
t2
were also sent by the same searcher, suppose
t1
is and
t2
is not, then we have
t2
being the user transactions (orderflow to be auctioned off) and
t3=p
being the preference. We can then calculate the worth of the coalition
T=t2
which suppose come out as 1, then we calculate the shapley value of
t2
which is also 1, then we say we redistributed 1 ETH back to the user who sent
t2

Example 2: suppose we see a bundle that has three transactions,

t1,t2,t3, suppose it is backrunning two transactions sent by different users. Then by checking we will know
t3=p
, then, we check if
t1
and
t2
were sent by the same searcher and found out that they were not. We can then calculate the worth of each sub-coalition of
TN={t1,t2}
. Suppose we have
V(t1)=1,V(t2)=1,V({t1,t2})=3
, then we can calculate the shapley value which is
φ(t1)=1.5
and
φ(t2)=1.5
. Thus, we know that if our mechanism was implemented, we will have each user that was backrunned getting 1.5 ETH back.

Pseoducode:

for each historical bundle:
    T_N = the set of all the transactions in the bundle;
    for each transaction t in the bundle:
        if t is a searcher preference:
            p = t;
    T = emptyset;
    for each transaction t in the bundle except p:
        if t is not sent by the same sender as p:
            if t was seen in the mempool:
                T = T add t;
    
    E = T_N difference T;
    
    for each non-empty subset T' of T:
        X = emptyset;
        for each different ordering of (T' \union E):
            simulate the ordering and calculate the utility of p;
            X = X add (utility of p);
        V(T') = maximum element in X
           
    VS = 0;
    for each non-empty subset T' of T:
        if V(T') > VS:
            VS = V(T');
    
    S = emptyset;
    for each non-empty subset T' of T:
        if V(T') = VS:
            S = S add T'
    
    sort S by cardinality of the element in increasing order;
    S' = the first element of S;
    
    allocate S';
    
    for each transaction tt in S':
        calculate shapley value of tt using V;
        kickback shapley value of tt to tt;
        
    plot the distirbution of the kickbacks;
    
plot the distirbution of the kickbacks for all bundles;