Researchers in the DeFi community and our friends from partners have been asking about how EigenPhi figures the profit and loss of an MEV transaction. Here is how we do it.
Identify all transfers in the transaction.
Combine these transfers to obtain the balance delta of this transaction.
Filter out the items in the balance delta that belong to arbitrageur accounts (usually the "from" and "to" addresses of the transaction, as well as some fund collection addresses), and calculate their total, resulting in an arbitrageur tokens balance delta.
Identify any Builder Payment in $ETH in the balance delta.
Add the identified Builder Payment in ETH to the arbitrageur token balances. That gives us the Revenue of this transaction in the form of the token balances.
Multiply each Revenue of the token balance (Ri) by its corresponding exchange rate (Ei) and sum them up to obtain Revenue in USD.
Let's assume:
Ri is the Revenue of the i-th token balance.
Ei is the exchange rate of the i-th token balance.
The total Revenue of the transaction is:
\(Revenue = \sum{Ri * Ei}\)
Transaction Fee In USD = gasPrice * gasUsed * $ETH Price
\(TransactionFeeInUSD = gasPrice * gasUsed * ETHPrice \)Builder Payment In USD = Builder Payment in $ETH * $ETH Price
Cost = Transaction Fee In USD + Builder Payment In USD
Profit = Revenue - Cost
In general, these are the steps of how we get the job done. Please feel free to leave your questions and comments.
Visit DeFi Strategies Case Studies by EigenPhi or bit.ly/head-first-defi to learn more trading tactic analyses.
Follow us via these to dig more hidden wisdom of DeFi:
EigenTx | Website | Discord | Twitter | YouTube | Substack | Medium | Telegram
Love it! Would like to see more of this type of breakdowns.