# Table of Contents - [Under the Hood of the DeFi Lego | Head First DeFi: TX & Strategies](#under-the-hood-of-the-defi-lego-head-first-defi-tx-strategies) - [Decoding the DNA of DeFi Transactions & Strategies | Head First DeFi: TX & Strategies](#decoding-the-dna-of-defi-transactions-strategies-head-first-defi-tx-strategies) - [Don't Let Your Trading Become the Recipe of Someone's Sandwich | Head First DeFi: TX & Strategies](#don-t-let-your-trading-become-the-recipe-of-someone-s-sandwich-head-first-defi-tx-strategies) - [Be Prepared To Explore the DeFi World | Head First DeFi: TX & Strategies](#be-prepared-to-explore-the-defi-world-head-first-defi-tx-strategies) - [From Arbitrage, Sandwich to JIT and Oracle Manipulation | Head First DeFi: TX & Strategies](#from-arbitrage-sandwich-to-jit-and-oracle-manipulation-head-first-defi-tx-strategies) - [Case Study Format | Head First DeFi: TX & Strategies](#case-study-format-head-first-defi-tx-strategies) - [MEV Transaction & Strategy 101 | Head First DeFi: TX & Strategies](#mev-transaction-strategy-101-head-first-defi-tx-strategies) - [What's Really Going on When Processing Liquidity in a Uniswap Pool? | Head First DeFi: TX & Strategies](#what-s-really-going-on-when-processing-liquidity-in-a-uniswap-pool-head-first-defi-tx-strategies) - [A $3.2 Million Profit Arbitrage, the Most Lucrative MEV of 2022 | Head First DeFi: TX & Strategies](#a-3-2-million-profit-arbitrage-the-most-lucrative-mev-of-2022-head-first-defi-tx-strategies) - [Conclusion | Head First DeFi: TX & Strategies](#conclusion-head-first-defi-tx-strategies) - [Pretend You Are One of the Shareholders of a Bank Branch. | Head First DeFi: TX & Strategies](#pretend-you-are-one-of-the-shareholders-of-a-bank-branch-head-first-defi-tx-strategies) - [Let's Match the Bank Branch to a Uniswap Pool. | Head First DeFi: TX & Strategies](#let-s-match-the-bank-branch-to-a-uniswap-pool-head-first-defi-tx-strategies) - [Liquidity Rebalancing: Moving Around $9.4 Million for More Fee Revenues. | Head First DeFi: TX & Strategies](#liquidity-rebalancing-moving-around-9-4-million-for-more-fee-revenues-head-first-defi-tx-strategies) - [The Hidden Tax That You Should Know About | Head First DeFi: TX & Strategies](#the-hidden-tax-that-you-should-know-about-head-first-defi-tx-strategies) - [Wallchain's MEV Arbitrage Redistribution | Head First DeFi: TX & Strategies](#wallchain-s-mev-arbitrage-redistribution-head-first-defi-tx-strategies) - [Rebalancing loan positions utilizing AAVE Flash loan | Head First DeFi: TX & Strategies](#rebalancing-loan-positions-utilizing-aave-flash-loan-head-first-defi-tx-strategies) - [The Notorious Jaredfromsubway.eth's Sandwich Attack | Head First DeFi: TX & Strategies](#the-notorious-jaredfromsubway-eth-s-sandwich-attack-head-first-defi-tx-strategies) - [Sandwich Targeting Liquidity Providers | Head First DeFi: TX & Strategies](#sandwich-targeting-liquidity-providers-head-first-defi-tx-strategies) - [Adding Liquidity. | Head First DeFi: TX & Strategies](#adding-liquidity-head-first-defi-tx-strategies) - [Understand Back-Run Arbitrages and Their Signals and Join the MEV Game. | Head First DeFi: TX & Strategies](#understand-back-run-arbitrages-and-their-signals-and-join-the-mev-game-head-first-defi-tx-strategies) - [Removing Liquidity. | Head First DeFi: TX & Strategies](#removing-liquidity-head-first-defi-tx-strategies) - [MEV-Share, Flashbots' MEV Redistribution Solution | Head First DeFi: TX & Strategies](#mev-share-flashbots-mev-redistribution-solution-head-first-defi-tx-strategies) - [A Cross-Chain Arbitrage: The Art of Arbitraging BANANA Cross BSC and Polygon Chains | Head First DeFi: TX & Strategies](#a-cross-chain-arbitrage-the-art-of-arbitraging-banana-cross-bsc-and-polygon-chains-head-first-defi-tx-strategies) --- # Under the Hood of the DeFi Lego | Head First DeFi: TX & Strategies [PreviousThe Flash-Loan-Enabled Sandwich Attack against Ethereum Foundation](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/the-flash-loan-enabled-sandwich-attack-against-ethereum-foundation) [NextWhat's Really Going on When Processing Liquidity in a Uniswap Pool?](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool) Last updated 8 months ago Was this helpful? DeFi is likened to a set of Lego blocks due to its flexible composability. This essentially means that DeFi protocols can be easily and flexibly combined, customized, and built upon - much like you would assemble pieces of Lego. While this represents a breakthrough in financial innovation and opens up an enormous range of possibilities, it also makes it difficult to understand and predict the behaviors and affiliations in trading within the DeFi ecosystem. Given the complexity and inherent variability of DeFi trades, the task of understanding and learning from these transactions can be daunting. That's where our dissection of the trading strategies comes into play. We delve into the mechanisms behind the individual trades and reveal what drives them. By shining a light on the tactics that lurk under the surface, we can provide valuable insight into how these transactions function and interact within the broader DeFi marketplace. You can glean significant knowledge from studying the initiators or pioneers of these trade tactics. These individuals or entities are leading the way in innovative trading, and their strategies can be a crucial part of understanding the DeFi space. Through careful analysis of the following cases, you can not only learn much from the strategies they've deployed but also understand how these tactics may evolve in the future and influence the DeFi landscape on a broader scale. This deep understanding could prove invaluable whether you're a seasoned trader or a newcomer to the DeFi space. [What's really going on when processing liquidity in a Uniswap Pool?](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool) [Liquidation: a good entry point to comprehend internal accounting used by many DeFi protocols.](/head-first-defi/under-the-hood-of-the-defi-lego/liquidation-a-good-entry-point-to-comprehend-internal-accounting-used-by-many-defi-protocols.) [A cross-chain arbitrage: the art of arbitraging BANANA cross BSC and Polygon chains.](/head-first-defi/under-the-hood-of-the-defi-lego/a-cross-chain-arbitrage-the-art-of-arbitraging-banana-cross-bsc-and-polygon-chains) [Liquidity rebalancing: moving around $9.4 million for more fee revenues.](/head-first-defi/under-the-hood-of-the-defi-lego/liquidity-rebalancing-moving-around-usd9.4-million-for-more-fee-revenues.) [Rebalancing loan positions utilizing AAVE Flash loan](/head-first-defi/under-the-hood-of-the-defi-lego/rebalancing-loan-positions-utilizing-aave-flash-loan) [How does the Grok Token Exploiter exploit the X token by baking his own cake and eating it?](/head-first-defi/under-the-hood-of-the-defi-lego/how-does-the-grok-token-exploiter-exploit-the-x-token-by-baking-his-own-cake-and-eating-it) --- # Decoding the DNA of DeFi Transactions & Strategies | Head First DeFi: TX & Strategies As a trader in the current DeFi era, you aim to: * use high-quality data to formulate and execute effective strategies, * seize transitory opportunities in the ever-changing market, * manage risk to minimize unnecessary losses. However, most existing web3 data tools fall short; they can't provide reliable transaction analysis that recognizes patterns and sends timely, automatic profit signals. To reach your goals, you need a deep understanding of transaction structures—akin to comprehending the DNA of a human body. Just like DNA codes for the various functions, behaviors, and attributes of a living organism, the structure of a DeFi transaction—comprising its different transfers, swaps, and interactions—acts as the cryptographic DNA that encodes the transaction's underlying strategy. By dissecting this "DNA," you gain a deep understanding of each transaction, decoding its inherent patterns and strategic elements. This depth of insight equips you to conduct advanced behavior and affiliation analysis, which are integral layers of understanding built upon structure analysis. In turn, you can recognize emerging opportunities and risks with unprecedented clarity. This booklet shows cases that explore the trinity of structure, behavior, and affiliation analysis in DeFi transactions and reveals the illuminated strategies. This booklet provides incremental cases for different user levels, from beginners to senior traders. Excitingly, venture forth to the next page, where a treasure trove of diverse transactions and meticulously crafted strategies eagerly await your discovery. [NextFrom Arbitrage, Sandwich to JIT and Oracle Manipulation](/head-first-defi/decoding-the-dna-of-defi-transactions-and-strategies/from-arbitrage-sandwich-to-jit-and-oracle-manipulation) Last updated 1 year ago Was this helpful? --- # Don't Let Your Trading Become the Recipe of Someone's Sandwich | Head First DeFi: TX & Strategies [PreviousMEV-Share, Flashbots' MEV Redistribution Solution](/head-first-defi/mev-transaction-and-strategy-101/mev-share-flashbots-mev-redistribution-solution) [NextThe Notorious Jaredfromsubway.eth's Sandwich Attack](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/the-notorious-jaredfromsubway.eths-sandwich-attack) Last updated 1 year ago Was this helpful? In a sandwich attack, the searchers/attackers 'sandwich' the victim's transactions between their own two transactions, called the front-run and the back-run. The victimized users suffer an implicit loss when these attackers reorder the transactions to benefit themselves. You can visit the in to understand more about the basic idea behind it. Next, we will walk you through some sandwich cases to show you how dangerous Sandwich MEV can be in terms of strategies under attack. * . [Sandwich MEV introduction](https://eigenphi-1.gitbook.io/classroom/mev-types/sandwich-mev) [EigenPhi's Classroom](https://eigenphi-1.gitbook.io/classroom/) [The notorious Jaredfromsubway.eth's Sandwich attack.](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/the-notorious-jaredfromsubway.eths-sandwich-attack) [Combined with Flash Loan, this leveraged Sandwich launched the attack with millions of volumes](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/combined-with-flash-loan-this-leveraged-sandwich-launched-the-attack-with-millions-of-volumes) [Liquidity providers can also be victims of Sandwich, as shown in this case.](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/sandwich-targeting-liquidity-providers) [Even the Ethereum Foundation couldn't escape the claw of this flash-loan-enabled Sandwich MEV.](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/the-flash-loan-enabled-sandwich-attack-against-ethereum-foundation) --- # Be Prepared To Explore the DeFi World | Head First DeFi: TX & Strategies In conclusion, this booklet serves as a comprehensive guide that deciphers the intricate 'genetic code' of DeFi transactions. * By examining **Transaction Structure**, we've led you through each transaction's 'DNA sequencing,' revealing the coded information that shapes the asset's journey. * Delving into **Trader Behavior**, you've learned to identify 'genetic markers' that signify specific trading patterns. * Focusing on **Entity Affiliation**, we've mapped the 'genomic connections' between different contracts and External Owned Accounts (EOAs), offering you a nuanced understanding of the interactions within this digital ecosystem. * By synthesizing structure, behavior, and affiliation—the 'DNA,' 'RNA,' and 'proteins' of DeFi, if you will—we've exhibited the overarching **Strategies** traders employ to navigate the ever-changing landscape of DeFi. Equipped with this invaluable genomic insight, you're better prepared to mitigate risks and seize opportunities in the dynamic world of DeFi transactions. [PreviousFrom Arbitrage, Sandwich to JIT and Oracle Manipulation](/head-first-defi/decoding-the-dna-of-defi-transactions-and-strategies/from-arbitrage-sandwich-to-jit-and-oracle-manipulation) [NextCase Study Format](/head-first-defi/decoding-the-dna-of-defi-transactions-and-strategies/case-study-format) Last updated 1 year ago Was this helpful? --- # From Arbitrage, Sandwich to JIT and Oracle Manipulation | Head First DeFi: TX & Strategies [PreviousDecoding the DNA of DeFi Transactions & Strategies](/head-first-defi) [NextBe Prepared To Explore the DeFi World](/head-first-defi/decoding-the-dna-of-defi-transactions-and-strategies/be-prepared-to-explore-the-defi-world) Last updated 1 year ago Was this helpful? Check out these case studies if you're new to analyzing DeFi transactions' structures and exploring strategies. They provide a solid foundation for further progress. Armed with this invaluable knowledge, you can boldly venture into the treacherous depths of the Dark Forest of DeFi, where a formidable adversary known as the Sandwich Attack lurks, also called Front-running. DeFi Lego's flexible composability makes it hard to grasp behaviors and affiliations of trading. We dissect the strategies below to reveal the tactics under the hood. You can learn a lot from the initiators of these trades. You are an expert now if you grasp the essentials of the transactions above. It's time to check out the following strategies that represent the pinnacle of DeFi participants exploiting Smart Contract's advanced features. Mastering them thoroughly will help you reduce risks and expand your trading toolkit as you strive to become a sleuth. [A $3.2 million profit arbitrage, the most lucrative arbitrage of 2022.](/head-first-defi/mev-transaction-and-strategy-101/a-usd3.2-million-profit-arbitrage-the-most-lucrative-mev-of-2022) [Understand back-run arbitrage and join the MEV game.](/head-first-defi/mev-transaction-and-strategy-101/understand-back-run-arbitrages-and-their-signals-and-join-the-mev-game.) [The hidden tax that you should know about.](/head-first-defi/mev-transaction-and-strategy-101/the-hidden-tax-that-you-should-know-about) [Wallchain's MEV arbitrage redistribution](/head-first-defi/mev-transaction-and-strategy-101/wallchains-mev-arbitrage-redistribution) [MEV Blocker, the multi-transaction MEV redistribution system that refunds 90% of builder rewards.](/head-first-defi/mev-transaction-and-strategy-101/mev-blocker-the-multi-transaction-mev-redistribution-system-that-refunds-90-of-builder-rewards) [MEV Share, Flashbots' MEV redistribution solution.](/head-first-defi/mev-transaction-and-strategy-101/mev-share-flashbots-mev-redistribution-solution) [With NFT arbitrage, someone was snipping your Baby Doge.](/head-first-defi/mev-transaction-and-strategy-101/with-nft-arbitrage-someone-was-snipping-your-baby-doge.) [The notorious Jaredfromsubway.eth's Sandwich attack.](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/the-notorious-jaredfromsubway.eths-sandwich-attack) [Combined with Flash Loan, this leveraged Sandwich launched the attack with millions of volumes.](https://app.gitbook.com/o/ahjSZgviWgaIHBT4FqC0/s/6mxU4QYtlg9O3vnppqQm/~/changes/35/dont-let-your-trading-become-the-recipe-of-someones-sandwich/combined-with-flash-loan-this-leveraged-sandwich-launched-the-attack-with-millions-of-volumes) [Liquidity providers can also be victims of Sandwich, as shown in this case.](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/sandwich-targeting-liquidity-providers) [Even the Ethereum Foundation couldn't escape the claw of this flash-loan-enabled Sandwich MEV.](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/the-flash-loan-enabled-sandwich-attack-against-ethereum-foundation) [What's really going on when processing liquidity in a Uniswap Pool?](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool) [Liquidation: a good entry point to comprehend internal accounting used by many DeFi protocols.](/head-first-defi/under-the-hood-of-the-defi-lego/liquidation-a-good-entry-point-to-comprehend-internal-accounting-used-by-many-defi-protocols.) [A cross-chain arbitrage: the art of arbitraging BANANA cross BSC and Polygon chains.](/head-first-defi/under-the-hood-of-the-defi-lego/a-cross-chain-arbitrage-the-art-of-arbitraging-banana-cross-bsc-and-polygon-chains) [Liquidity rebalancing: moving around $9.4 million for more fee revenues.](/head-first-defi/under-the-hood-of-the-defi-lego/liquidity-rebalancing-moving-around-usd9.4-million-for-more-fee-revenues.) [Rebalancing loan positions utilizing AAVE Flash loan](/head-first-defi/under-the-hood-of-the-defi-lego/rebalancing-loan-positions-utilizing-aave-flash-loan) [Just-in-time, an MEV type that benefits traders in the same trading venue.](/head-first-defi/unlocking-the-power-of-advanced-defi-transactions-and-becoming-a-defi-sleuth/just-in-time-an-mev-type-that-benefits-traders-in-the-same-trading-venue) [A bot devised distinct arbitrage strategies centered on the autonomous minting and burning of synthetic tokens.](/head-first-defi/unlocking-the-power-of-advanced-defi-transactions-and-becoming-a-defi-sleuth/a-bot-devised-arbitrage-strategies-centered-on-autonomous-minting-and-burning-of-synthetic-tokens) [The defect in a lending protocol's oracle module was exploited by a bot to generate a $110K profit.](/head-first-defi/unlocking-the-power-of-advanced-defi-transactions-and-becoming-a-defi-sleuth/the-defect-in-a-lending-protocols-oracle-module-was-exploited-by-a-bot-to-generate-a-usd110k-profit) [After the Vyper-Curve Exploit, Coffeebabe.eth utilized the Vyper-based Curve CRV/WETH pool's significant price deviation from the market price and made an arbitrage with a $5.4 million profit.](/head-first-defi/unlocking-the-power-of-advanced-defi-transactions-and-becoming-a-defi-sleuth/coffeebabe.eth-utilized-curves-crv-weth-pools-price-deviation-for-a-usd5.4-million-profit-arbitrage.) [The Vyper-Curve exploits released massive arbitrage opportunities. The Lightning Reflex Bot captured the first arbitrage opportunity after the attack, earning $296K profit after paying 50% of the revenue to the builder.](/head-first-defi/unlocking-the-power-of-advanced-defi-transactions-and-becoming-a-defi-sleuth/a-usd296k-profit-arbitrage-done-by-the-lightning-reflex-bot-after-the-vyper-curve-exploit) [An attacker set up baits to attract MEV arbitrage bots and emptied their wallets when they took the bait, causing a loss of hundreds of thousands.](/head-first-defi/unlocking-the-power-of-advanced-defi-transactions-and-becoming-a-defi-sleuth/an-attacker-baited-mev-arbitrage-bots-and-emptied-their-wallets) --- # Case Study Format | Head First DeFi: TX & Strategies We will use a template for each case. It contains sections as below. * Strategy One Liner: The sentence summarizes the gist of the current case. * Big Picture: The complete token flow chart/charts and link of the case. * Key Steps: The crucial steps of this strategy. * Key Protocols: The fundamental protocol of this strategy. * Key Addresses: Hash addresses that play essential roles. * Key Assets: Tokens that are significant for the strategy. * Simplified Illustration: An illustration that marks the essence of the strategy. * Step-by-step Decoding: Explanation of each step of the strategy. * More Details: More background and context that help you get a deep understanding. * Keywords: Tag like words to make it easier to search and index. [PreviousBe Prepared To Explore the DeFi World](/head-first-defi/decoding-the-dna-of-defi-transactions-and-strategies/be-prepared-to-explore-the-defi-world) [NextMEV Transaction & Strategy 101](/head-first-defi/mev-transaction-and-strategy-101) Last updated 1 year ago Was this helpful? --- # MEV Transaction & Strategy 101 | Head First DeFi: TX & Strategies [PreviousCase Study Format](/head-first-defi/decoding-the-dna-of-defi-transactions-and-strategies/case-study-format) [NextA $3.2 Million Profit Arbitrage, the Most Lucrative MEV of 2022](/head-first-defi/mev-transaction-and-strategy-101/a-usd3.2-million-profit-arbitrage-the-most-lucrative-mev-of-2022) Last updated 1 year ago Was this helpful? This section will walk you through the fundamental transactions and strategies of MEV. [A $3.2 million profit arbitrage, the most lucrative arbitrage of 2022.](/head-first-defi/mev-transaction-and-strategy-101/a-usd3.2-million-profit-arbitrage-the-most-lucrative-mev-of-2022) [Understand back-run arbitrage and join the MEV game.](/head-first-defi/mev-transaction-and-strategy-101/understand-back-run-arbitrages-and-their-signals-and-join-the-mev-game.) [The hidden tax that you should know about.](/head-first-defi/mev-transaction-and-strategy-101/the-hidden-tax-that-you-should-know-about) [Wallchain's MEV arbitrage redistribution](/head-first-defi/mev-transaction-and-strategy-101/wallchains-mev-arbitrage-redistribution) [MEV Blocker, the multi-transaction MEV redistribution system that refunds 90% of builder rewards.](/head-first-defi/mev-transaction-and-strategy-101/mev-blocker-the-multi-transaction-mev-redistribution-system-that-refunds-90-of-builder-rewards) [MEV Share, Flashbots' MEV redistribution solution.](/head-first-defi/mev-transaction-and-strategy-101/mev-share-flashbots-mev-redistribution-solution) [With NFT arbitrage, someone was snipping your Baby Doge.](/head-first-defi/mev-transaction-and-strategy-101/with-nft-arbitrage-someone-was-snipping-your-baby-doge.) --- # What's Really Going on When Processing Liquidity in a Uniswap Pool? | Head First DeFi: TX & Strategies When liquidity providers add or remove liquidity in a Uniswap pool, the protocol uses internal accounting to save gas fees, among other reasons. This approach hides many details that retail users do not care about. However, if you want to become a sleuth of DeFi, it's critical to find out what's really going on behind the curtain.EigenPhi's EigenTx transaction analyzer offers a comprehensive toolset to unravel the complexities of the internal accounting procedures associated with adding and removing liquidity to a Uniswap pool. Consider yourself as a liquidity provider now. Basically, you can regard yourself as a shareholder of a bank branch. Adding your liquidity to a Uniswap pool is like adding your asset to the asset of the bank branch. Now, follow my lead. [PreviousUnder the Hood of the DeFi Lego](/head-first-defi/under-the-hood-of-the-defi-lego) [NextPretend You Are One of the Shareholders of a Bank Branch.](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/pretend-you-are-one-of-the-shareholders-of-a-bank-branch.) Last updated 1 year ago Was this helpful? --- # A $3.2 Million Profit Arbitrage, the Most Lucrative MEV of 2022 | Head First DeFi: TX & Strategies [PreviousMEV Transaction & Strategy 101](/head-first-defi/mev-transaction-and-strategy-101) [NextUnderstand Back-Run Arbitrages and Their Signals and Join the MEV Game.](/head-first-defi/mev-transaction-and-strategy-101/understand-back-run-arbitrages-and-their-signals-and-join-the-mev-game.) Last updated 1 year ago Was this helpful? ### [](#strategy-one-liner) Strategy One-liner This is an arbitrage between two pools. The searcher made a profit of $3.2 million out of one single arbitrage, paying 1.2582 ETH to the miner as a bribe while borrowing about 297 WBTC from Uniswap by using the flash swap. ### [](#big-picture) Big Picture ### [](#key-steps) Key Steps 1. Step 0: The searcher borrowed 296.8354 WBTC from Uniswap V2's WETH/WBTC pool using Uniswap's flash swap. 2. Step 1: The searcher swapped the borrowed WBTC for 4,160.9977 WETH in Uniswap V3's WETH/WBTC pool. 3. Step 5: To ensure the miner accepts the arbitrage, the searcher transferred 1.2582 ETH to the miner as a bribe. ### [](#key-protocols) Key Protocols * Uniswap: The biggest DEX protocol. ### [](#key-addresses) Key Addresses * The searcher's EOA, shown as a pentagon, is marked as "from": 0xB8Ef267283E0A11a2CB7BdB4C1667B9c7E3a6e9F. * Uniswap V2 Liquidity Pool, shown as an oval, trading WBTC and WETH: 0xBb2b8038a1640196FbE3e38816F3e67Cba72D940 * Uniswap V3 Liquidity Pool, shown as an oval, trading WBTC and WETH: 0xCBCdF9626bC03E24f779434178A73a0B4bad62eD ### [](#key-assets) Key Assets WBTC, WETH. ### [](#simplified-illustration) Simplified Illustration ### [](#step-by-step-decoding) Step-by-step Decoding Step 0: The searcher's bot borrowed 296.835415WBTC from Uniswap V2's WETH/WBTC pool using Uniswap's flash swap. Step 1-2: The searcher's bot swapped the borrowed WBTC for 4,160.997729 WETH in Uniswap V3's WETH/WBTC pool. Step 3: The searcher's bot returned the borrowed WBTC in 2,193.2113 WETH. Step 4: The searcher burned 0.0072 ETH as a gas fee. Step 5: To ensure the miner accepts the arbitrage, the searcher transferred 1.258 ETH to the miner as a bribe. ### [](#more-details) More Details #### [](#how-do-we-get-the-token-flow-chart) How do we get the token flow chart? You can paste the transaction hash into the search box and click the search icon or button. #### [](#how-do-we-know-the-profit-and-loss-of-this-arbitrage) How do we know the profit and loss of this arbitrage? We have calculated and displayed the profit, revenue, and cost of this arbitrage right beside the token flow chart. The computation is based on the price of the tokens involved when the arbitrage happened. #### [](#how-do-we-get-the-balance-changes-of-each-hash-address) How do we get the balance changes of each hash address? On the bottom of the EigenTx transaction detail page, you can find the balance change table. The table below shows the profit of the searcher. ### [](#keywords) Keywords Uniswap, arbitrage, flash loan, flash swap The searcher's bot, shown as an oval, is marked as "to" in the center: 0xbaDc0dEfAfCF6d4239BDF0b66da4D7Bd36fCF05A. This used to be and lost 1,101 ETH. You can examine all the above transfers between two hashes in the Transfer List table at the bottom of the EigenTx transaction detail page. Visit for more about EigenTx's layout and features. Sometimes, all you have is the hash of a transaction. You can get the token flow chart by searching the transaction at or . Using : Using : [a famous bot that got hacked](https://www.halborn.com/blog/post/explained-the-0xbad-mev-bot-hack-september-2022) [the manual of EigenTx](https://eigenphi-1.gitbook.io/arbitrage-scan-user-guide/eigentx-evm-transaction-visualizer/overview) [https://eigenphi.io/](https://eigenphi.io/) [https://eigenphi.io/mev/eigentx](https://eigenphi.io/mev/eigentx) [https://eigenphi.io/](https://eigenphi.io/) [https://eigenphi.io/mev/eigentx](https://eigenphi.io/mev/eigentx) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FfF4jkQsCp1nmtwicCHmu%252Fimage.png%3Falt%3Dmedia%26token%3D14b0ff81-2026-4d0b-ac5f-e23148bb3c71&width=768&dpr=4&quality=100&sign=e6cae1d2&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FFdNBq833abSZfqwtYe3T%252Fimage.png%3Falt%3Dmedia%26token%3D7e63bfc2-cffd-4363-ad2f-2668bdf9a3bd&width=768&dpr=4&quality=100&sign=7f428e7&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FBC2qhmhReHMB4bvrCE4L%252Fimage.png%3Falt%3Dmedia%26token%3Db9a6024b-e25d-472f-9737-7348a9b18ea3&width=768&dpr=4&quality=100&sign=1b54efa8&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F1LopmocFMDT03E2iPok0%252Fimage.png%3Falt%3Dmedia%26token%3D30bb659e-3d7a-4b09-b22b-6121c79c37f2&width=768&dpr=4&quality=100&sign=a641aa5&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FUDUMoGZCFDSSqxBhd0GM%252Fimage.png%3Falt%3Dmedia%26token%3D8693374f-b8eb-4e96-b50e-af73876606b3&width=768&dpr=4&quality=100&sign=436af69b&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FESZJh5W04m5QP0Ariel7%252Fimage.png%3Falt%3Dmedia%26token%3Debb934f2-7f0d-4eec-84a0-42c4628b127b&width=768&dpr=4&quality=100&sign=81637f4c&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F48CUp0mOYo9u8hP7qLrA%252Fimage.png%3Falt%3Dmedia%26token%3Dad3845de-104b-4040-b410-5508e5284960&width=768&dpr=4&quality=100&sign=f1b70b80&sv=2) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0xb55d4267a3565fdc8bada2638f97ed0bb31aa40bf8d4b304086dbdc1ca7d7844EigenPhi](https://bit.ly/3LwFXqE) --- # Conclusion | Head First DeFi: TX & Strategies EigenTx creates these virtual contracts and assets to demonstrate how Uniswap deals with liquidity operations, helping users understand one of the most significant DeFi protocols' mechanisms. With the release of Uniswap V4, EigentTx will keep improving to mirror the latest developments of the incumbent project. [PreviousRemoving Liquidity.](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/removing-liquidity.) [NextLiquidation: A Good Entry Point to Comprehend Internal Accounting Used by Many DeFi Protocols.](/head-first-defi/under-the-hood-of-the-defi-lego/liquidation-a-good-entry-point-to-comprehend-internal-accounting-used-by-many-defi-protocols.) Last updated 1 year ago Was this helpful? --- # Pretend You Are One of the Shareholders of a Bank Branch. | Head First DeFi: TX & Strategies [PreviousWhat's Really Going on When Processing Liquidity in a Uniswap Pool?](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool) [NextLet's Match the Bank Branch to a Uniswap Pool.](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/lets-match-the-bank-branch-to-a-uniswap-pool.) Last updated 1 year ago Was this helpful? First, take a look at the table below, which contains the information that concerns your interests when you become one of the shareholders of the branch. * You put USD and CAD(Canadian dollars) into the branch. In return, you receive shares of the branch. * The bank's database has internal data to store how many USD and CAD this branch owns, marked as "Internal USD" and "Internal CAD." * Meanwhile, to keep your record right, the bank's database also shows how much USD and CAD you have put into the bank, marked as "External USD" and "External CAD." * The bank branch has the data of the total shares of this branch, marked as "Entire Liquidity Share." * Your shares of the branch are recorded as "Shareholder's Share." * Now, when you put your USD and CAD assets into the bank branch as your contribution to the liquidity share of the branch, the amount of your contribution will be reflected as follows: * The amount of Internal USD will increase, adding your USD contribution. * The amount of Internal CAD will increase, adding your CAD contribution. * The amount of External USD is your USD contribution. * The amount of External CAD is your CAD contribution. * The number of Entire Liquidity Shares will increase, adding your shares based on your USD and CAD contribution. * The number of the Shareholder's Shares will increase, adding your shares based on your USD and CAD contributions. * All the operations above will generate an "adding" record of the internal bookkeeping for each operation. * Let's consider what happens when you remove your USD and CAD assets from the bank branch's overall shares. The amount of your removal will be reflected as follows: * The amount of Internal USD will decrease, removing your USD contribution. * The amount of Internal CAD will decrease, removing your CAD contribution. * The amount of External USD is your USD removal. * The amount of External CAD is your CAD removal. * The number of Entire Liquidity Shares will decrease, removing your shares based on your USD and CAD removals. * The number of Shareholder's Shares will be your shares based on your USD and CAD removals. * All the operations above will generate a "removing" record of the internal bookkeeping for each operation. ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F00G3QQtNCdHySBJw4yvM%252F1280X1280%2520%281%29.PNG%3Falt%3Dmedia%26token%3De73129dc-36b4-426e-92c4-c4f06b8b38af&width=768&dpr=4&quality=100&sign=70ee6fcf&sv=2) --- # Let's Match the Bank Branch to a Uniswap Pool. | Head First DeFi: TX & Strategies [PreviousPretend You Are One of the Shareholders of a Bank Branch.](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/pretend-you-are-one-of-the-shareholders-of-a-bank-branch.) [NextAdding Liquidity.](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/adding-liquidity.) Last updated 1 year ago Was this helpful? A Uniswap Pool is like a bank branch. We have a table like this showing an Unsiwap V3 pool trading WBTC and USDC. In this table: * The number 350101 is the liquidity provider's identification number. * "UNI-V3-POS" is the NFT contract used by Uniswap. When a liquidity provider adds WBTC and USDC to the pool, the contract will mint an NFT and send it to the liquidity provider. This is an actual contract that was deployed by the Uniswap team. EigenTx uses this contract to represent the internal records of liquidity providers' contributions. * "UNI-V3-POS-350101" is the actual NFT issued by the aforementioned NFT contract. EigenTx uses it to represent the external records of the liquidity providers' contributions. * Besides the two above, the left contracts are virtual contracts introduced by EigenTx to demonstrate the internal accounting procedure, following the double-entre bookkeeping rules. * EigenTx also uses virtual assets for internal accounting, which can be found in the following example. You can put on the Liquidity Provider hat now. * "virtualOwed0WBTC" and "virtualOwed1USDC" are virtual contracts storing your WBTC and USDC contribution to the pool for internal uses. * "virtualOwed0WBTC-350101" and "virtualOwed1USDC--350101" are virtual contracts storing your WBTC and USDC contribution to the pool for your use. * The pool has the data of the total shares of this pool, marked as "virtualLiquidity." * Your exclusive shares of the pool are recorded in "virtualLiquidity-350101." * EigenTx uses "mint" to show a record of adding one kind of asset or shares, which could be actual or virtual, to a contract. * EigenTx uses "burn" to show a record of removing one kind of asset or shares, which could be actual or virtual, from a contract. We can also match the assets and shares between the bank branch analogy and the pool. ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FI8a1713iyDPa2qz7Fg9y%252F1280X1280%2520%282%29.PNG%3Falt%3Dmedia%26token%3D78135904-d031-4af0-8496-49b8fdca5af0&width=768&dpr=4&quality=100&sign=f4775ca1&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FUqqLOffU1PNvNvTH8pIO%252Fimage.png%3Falt%3Dmedia%26token%3Dc1e82aa2-dc55-460d-bb62-6335a5cc0e8d&width=768&dpr=4&quality=100&sign=65b017ee&sv=2) --- # Liquidity Rebalancing: Moving Around $9.4 Million for More Fee Revenues. | Head First DeFi: TX & Strategies [PreviousA Cross-Chain Arbitrage: The Art of Arbitraging BANANA Cross BSC and Polygon Chains](/head-first-defi/under-the-hood-of-the-defi-lego/a-cross-chain-arbitrage-the-art-of-arbitraging-banana-cross-bsc-and-polygon-chains) [NextRebalancing loan positions utilizing AAVE Flash loan](/head-first-defi/under-the-hood-of-the-defi-lego/rebalancing-loan-positions-utilizing-aave-flash-loan) Last updated 8 months ago Was this helpful? ### [](#strategy-one-liner) Strategy One Liner The market maker rebalanced his liquidity in a Uniswap V3 pool trading USDC & USDT by swapping 4.15 million USDC for USDT via the 1inch aggregator to maximize fee revenues. ### [](#big-picture) Big Picture ### [](#key-steps) Key Steps * Steps 4 and 5: Remove liquidity. 1,626 USDT and 9,409,921 USDC were removed from the Uniswap V3 pool. * Steps 10-31: Rebalance the existing liquidity. 4,150,507 USDC was used to swap for 4,149,601 USDT via 1inch. * Steps 32-35: Add liquidity. 4,148,799 USDT and 5,256,909 USDC were added to the Uniswap V3 pool. ### [](#key-protocols) Key Protocols * Uniswap V3: The largest DEX. * Balancer, Curve, DODO: Other DEXes. * 1inch: An exchange aggregator that scans decentralized exchanges to find the lowest cryptocurrency prices for traders. * MakerDAO: A decentralized organization responsible for creating and managing the DAI stablecoin. In this transaction, it acts as a DEX swapping USDC for DAI. The DAI uses a synthetic algorithm to peg to USD. This is different from custodial stablecoins such as USDT and USDC. ### [](#key-addresses) Key Addresses * The pentagon "from" is the market maker, a.k.a., liquidity provider(LP)'s EOA. * The oval "to" is LP's contract address. * The addresses in the right-bottom box are the addresses of Uniswap V3. You will see their usage in the following Step-by-Step Decoding. So as the addresses in the "Balancer v2" box and the "MakerDAO" box. * The oval "DLP", "DODO", and "Curve Pool" are different DEXes.The oval "0xa45...cba3e" is a contract created by the LP. ### [](#key-assets) Key Assets USDT, USDC, DAI ### [](#simplified-illustration) Simplified Illustration ### [](#step-by-step-decoding) Step-by-step Decoding Steps 1-3: The user was going to remove liquidity. The corresponding virtual liquidities were burned. Steps 4 and 5: Remove liquidity. 1,626 USDT and 9,409,921 USDC were removed. Steps 6 and 7: The virtual USDT corresponding to the 1,626 USDT was removed. Steps 8 and 9: The LP sent 4,150,507 USDC to his own contract. Then, the USDC was sent to 1inch to swap for USDT. Steps 10 and 11: 415,050 USDC were sent to MakerDAO to swap for DAI. Steps 12-15: The DAI was swapped for USDT at DLP and Curve. Step 16: The swap fee was stored at their fund collection address, marked as a leaf node in the figure. Steps 17-29: 2,988,365 USDC were swapped for USDT at Balancer, another DEX. Steps 30 and 31: All the USDTs were aggregated at 1inch Router and then sent to the LP (user). Steps 32-35: Add liquidity. 4,148,799 USDT and 5,256,909 USDC were added into Uniswap V3. ### [](#more-details) More Details The concentrated liquidity of Uniswap V3 comes with a range of benefits that allow liquidity providers and users to manage their liquidity more efficiently. Market makers need to rebalance their positions regularly, and the quality of their rebalancing strategy reflects their level of expertise. ### [](#keywords) Keywords Liquidity Rebalancing, UniswapV3, Concentrated Liquidity, Liquidity Provider Adding and removing liquidity from the Uniswap V3 pool involves a lot of internal accounting operations. Please read to understand how EigenTx can help you get to the bottom of it. For more details about virtual liquidity, please see [What's Really Going on When Processing Liquidity in a Uniswap Pool?](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool) [What's really going on when processing liquidity in a Uniswap Pool?](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0xc0c37f30ef0ebb0606affbd784bf17416250f49179370feb90dc7ff919b2cd86EigenPhi](https://eigenphi.io/mev/eigentx/0xc0c37f30ef0ebb0606affbd784bf17416250f49179370feb90dc7ff919b2cd86?allow-different=0&disable-reverse-debt=0&hide-inter=0&include-gas-fee=0&show-net-asset-flow=1) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F6uHsIyvYJWds9Btng53E%252Feigentx-0xc0c37f30ef0ebb0606affbd784bf17416250f49179370feb90dc7ff919b2cd86%2520%281%29.png%3Falt%3Dmedia%26token%3Df3c2d073-083f-4fd9-8c7a-c73dbaf09336&width=768&dpr=4&quality=100&sign=f898fe80&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FH42pyIz6p27ZHXTmjcnM%252Fimage.png%3Falt%3Dmedia%26token%3De0eebb72-9385-4496-a9e7-1785dfce29c0&width=768&dpr=4&quality=100&sign=a11cb09d&sv=2) --- # The Hidden Tax That You Should Know About | Head First DeFi: TX & Strategies [PreviousWith NFT arbitrage, someone was snipping your Baby Doge.](/head-first-defi/mev-transaction-and-strategy-101/with-nft-arbitrage-someone-was-snipping-your-baby-doge.) [NextMEV-Share, Flashbots' MEV Redistribution Solution](/head-first-defi/mev-transaction-and-strategy-101/mev-share-flashbots-mev-redistribution-solution) Last updated 1 year ago Was this helpful? ### [](#strategy-one-liner) Strategy One Liner Tax tokens may charge users for every transaction. In this case, a user swapped BNB for CUE but was charged a 2.5% tax. ### [](#link-to-the-case) Link To The Case ### [](#key-steps) Key Steps This is an arbitrage on the BNB smart chain; its native cryptocurrency is BNB. 1. Step 0, 3, 4: The user swaps 0.1 BNB for 2.9150 CUE on Pancake. 2. Step 5: The token CUE is a tax token, i.e., there is a fee (tax) for every transaction. In this case, the tax is 0.0747, or 2.5%. ### [](#key-protocols) Key Protocols * Pancake: A major DEX (decentralized exchange). ### [](#key-addresses) Key Addresses * The pentagon marked as _from_ is the user's address, 0x3b48. * The oval _to is_ Pancake's router_._ The router decides the best path for a trade. * The green oval _WBNB_ is Wrapped BNB's contract_._ WBNB is pegged 1:1 with the native Binance Coin (BNB). * The pentagon marked as _leaf_ is CUE's wallet. ### [](#key-assets) Key Assets BNB, WBNB, CUE (tax token!) ### [](#simplified-illustration) Simplified Illustration ### [](#step-by-step-decoding) Step-by-step Decoding Step 0: The user sends 0.1 BNB to the Pancake router, aiming to swap for CUE. Step 1, 2: Panckae router transforms 0.1 BNB to 0.1 WBNB. WBNB is more compatible in the world of decentralized finance. Step 3,4: The 0.1 WBNB is sent to Cake-LP to exchange to 2.9150 CUE. Step 5: A 0.0747 CUE tax is charged for the 2.9150 CUE transaction. Note that 0.0747/(0.0747+2.9150)=2.5%. So, the tax rate is 2.5%. ### [](#more-details) More Details The existence of tax tokens is typical of the lack of standardization of smart contracts. In this transaction, the "from" address swapped 0.1 BNB for 2.9897 CUE at PancakeSwap. However, this swap process is trickier than usual because the CUE contract included a tax collection process. As a result, the user only got 2.9150 CUE, and 0.0747 CUE was transferred to Cue Protocol’s Governance Wallet (leaf). ### [](#keywords) Keywords Tax token, BNB, BNB smart chain Understanding tax tokens from the transaction information displayed on sites like BscScan.io may be challenging. Therefore, we recommend downloading our to visualize the text information better. [EigenTx Chrome extension](https://chrome.google.com/webstore/detail/eigentx/gmjkhhheaknfaekapfiedhohdilpmgci) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0x52a3da176fd917c422462368bd872bcf75b4ff923a686b7d7114487b76736094EigenPhi](https://eigenphi.io/mev/eigentx/0x52a3da176fd917c422462368bd872bcf75b4ff923a686b7d7114487b76736094) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F2ChG9nn0nRCEGeerBe4A%252Fimage.png%3Falt%3Dmedia%26token%3De59c0b8c-876e-46f0-8948-587c018f8e7f&width=768&dpr=4&quality=100&sign=177333e2&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FjBfDxwPvAuuWC9CMmAmR%252Fimage.png%3Falt%3Dmedia%26token%3D5c924705-576a-4f8e-bf1f-65142d5a05d1&width=768&dpr=4&quality=100&sign=bd56006c&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252Fp2J3Vx1rmgKYdD4F9Qrp%252Fimage.png%3Falt%3Dmedia%26token%3D0dd0d51d-7e3e-4823-a884-069fbd772314&width=768&dpr=4&quality=100&sign=e27f4a3d&sv=2) --- # Wallchain's MEV Arbitrage Redistribution | Head First DeFi: TX & Strategies [PreviousUnderstand Back-Run Arbitrages and Their Signals and Join the MEV Game.](/head-first-defi/mev-transaction-and-strategy-101/understand-back-run-arbitrages-and-their-signals-and-join-the-mev-game.) [NextMEV Blocker, the multi-transaction MEV redistribution system that refunds 90% of builder rewards](/head-first-defi/mev-transaction-and-strategy-101/mev-blocker-the-multi-transaction-mev-redistribution-system-that-refunds-90-of-builder-rewards) Last updated 1 year ago Was this helpful? ### [](#strategy-one-liner) **Strategy One-liner** combines swap and profit capturing in a single transaction and shares the profit between the DEX and the user. ### [](#big-picture) **Big Picture** ### [](#key-steps) **Key Steps** **Stage 1: Swap** When a user (from address) submits a swap intention through the ApeSwap DEX, the DEX creates a transaction calling the standard ApeSwap Router to perform the swap. However, instead of sending it directly to a wallet for confirmation, it is sent to Wallchain Service API to check if a profitable upgrade is possible. In this case, the profitable strategy has been found, and an upgraded transaction is sent in response to the API request (Otherwise, the API request will return the original transaction). The upgraded transaction is instead processed through the Wallchain Router, and three parties will receive a Swap Bonus. In the token flow chart, Steps 0-5 correspond to the swap stage, and the user swaps 146 BNB for 24.7033 ETH at PancakeSwap. **Stage 2: Arbitrage** Following the swap stage, ApeSwap DEX's Wallchain Router calls Wallchain Master, 0x178...57bf3, to capture available arbitrage profit in the same transaction. * Steps 6, 10: Wallchain Master borrowed WBNB from Pancakeswap, using flash swap, to gather enough assets for the back-run arbitrage in Steps 7-9. * Steps 7-9: Wallchain Master finished the arbitrage between ApeSwap and PancakeSwap and reaped revenue of 6.1786 WBNB. After deducting the flash loan fee of 0.227787 WBNB paid to Pancake, there is 5.9508 WBNB ($1,267.23 at the time) in the remaining profit available for distribution. **Stage 3: Distribution** In the last stage, Wallchain Master shares arbitrage proceeds with both the swap user and ApeSwap DEX. * Step 11: Wallchain Master distributes 1.785 BNB (30%) to the swap user's from address. * Step 12: Wallchain Master distributes 2.975 BNB (50%) to the ApeSwap treasury. Finally, Wallchain Master keeps 1.190 BNB (20%) as its own reward. And the cost of the whole transaction is only $0.46! ### [](#key-protocols) **Key Protocols** * PancakeSwap: A leading DEX running on L1s like Aptos BNB Smart Chain, Ethereum, Polygon, and L2s like Arbitrum and Base. * ApeSwap: Another leading DEX on BNB Smart Chain, Ethereum, Polygon, and Arbitrum. ### [](#key-addresses) **Key Addresses** * User's EOA, marked as "from" in step 0: 0x5df43Cbb11d1014EA5410E941d94B85c9224b332. * Wallchain Master, in steps 6, 7, and more: 0x178C075a1d413f8637B3C6623c9501167D457bf3 * ApeSwap's treasury wallet receiving arbitrage revenue, marked as "leaf" in step 12: 0x20ef6C5Ecfc0445B06FB70Cf991C6fFF27E09aB5 * ApeSwap Router Manager in step 0: 0x5471F99bCB8F682f4Fd2b463Fd3609DadD56A929 * ApeSwap Router in step 1: 0xcF0feBd3f17CEf5b47b0cD257aCf6025c5BFf3b7 * ApeSwap Liquidity Pool trading ETH and WBNB in step 4: 0xA0C3Ef24414ED9C9B456740128d8E63D016A9e11 * PancakeSwap Liquidity Pool trading ETH and WBNB in step 7: 0x74E4716E431f45807DCF19f284c7aA99F18a4fbc * PancakeSwap Liquidity Pool trading WBNB and CAKE for flash swap, a Flash Loan feature, in step 6: 0x0eD7e52944161450477ee417DE9Cd3a859b14fD0 * BNB Wrapper in step 3: 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c. ### [](#key-assets) **Key Assets** BNB, ETH, WBNB ### [](#simplified-illustration) **Simplified Illustration** The red lines are the arbitrage loop done by Wallchain Master. The yellow lines indicate the flash swap done by Wallchain Master, while the MEV redistribution process by Wallchain Master is exhibited in red lines. ### [](#step-by-step-decoding) **Step-by-step Decoding** Step 0: The user sent 146 BNB to ApeSwap's Route Manager to swap for ETH. Step 1: ApeSwap's Route Manager sent the user's BNB to ApeSwap's router contract. Steps 2 and 3: ApeSwap's router contract wrapped the BNB as WBNB. Step 4: ApeSwap's router contract sent the 146 WBNB to ApeSwap Liquidity Pool trading ETH and WBNB. Step 5: ApeSwap Liquidity Pool trading ETH and WBNB sent the exchanged 24.7033 ETH back to the user. A back-run arbitrage opportunity was created. Step 6. Using the flash swap feature, Wallchain Master borrowed 90.887 WBNB from PancakeSwap Liquidity Pool as the flash loan. Step 7. Combined with its previous WBNB position, Wallchain Master sent 127.8327 WBNB to PancakeSwap Liquidity Pool trading ETH and WBNB. Step 8: Asked by Wallchain Master, PancakeSwap Liquidity Pool trading ETH and WBNB sent 22.6722 ETH to ApeSwap Liquidity Pool trading ETH and WBNB. Step 9: ApeSwap Liquidity Pool trading ETH and WBNB swapped 22.6722 ETH for 134.0113 WBNB and sent it to Wallchain Master. Step 10: Wallchain Master paid back the flash swap with 91.1148 WBNB with the extra fee. Step 11: Wallchain Master sent part of the back-run revenue, 1.7852 WBNB, to the user. Step 12: Wallchain Master sent the left back-run revenue, 2.9754 WBNB, to ApeSwap's treasury wallet. ### [](#more-details) **More Details** We can calculate the revenue of this transaction. * The revenue of the back-run arbitrage is 6.1786 WBNB, resulting from 134.0113 WBNB in step 9 minus 127.8327 WBNB in step 7. * The flash swap cost is 0.2278 WBNB, resulting from 91.1148 WBNB in step 10 minus 90.8870 WBNB in step 6. * The total profit of the back-run arbitrage comes down to 6.4908 WBNB, out of which the user received 1.7852 WBNB, and ApeSwap's treasury wallet received 2.9754 WBNB. Wallchain Master kept 1.1902 WBNB in this case. * MEV Redistribution Profit in total: 5.9508 WBNB. This table shows the MEV redistribution ratio for different parties. Recipient Value MEV Redistribution Ratio The user 1.7852 30% ApeSwap 2.9754 50% Wallchain 1.1902 20% ### [](#keywords) Keywords MEV Redistribution, Wallchain, PancakeSwap, flash swap, ApeSwap Wallchain: A MEV redistribution protocol integrates with DeFi platforms and helps capture these profits by combining user swap and searcher backrunning into a single transaction. Visit. Click the bigger token flow chart. [here to see how it works](https://docs.wallchain.xyz/how-it-works) [the link to view](https://eigenphi.io/mev/eigentx/0xe9b2bc4bae138cce4666b38036b245217b45970cc1634576eb09e907f70fa5fa?rankdir=BT) [Wallchain Transaction Upgrade Service](https://docs.wallchain.xyz/how-it-works) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FjfFaGSq6W7q9f1IoJhL5%252Fimage.png%3Falt%3Dmedia%26token%3D6748ebf0-0bf0-466e-97fc-73b870cb5c77&width=768&dpr=4&quality=100&sign=e1129660&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FvreBk8vXapgofqUWlPpF%252Fimage.png%3Falt%3Dmedia%26token%3D7e68595c-db26-4a8d-a5cb-f82ebf728dc4&width=768&dpr=4&quality=100&sign=399dbf9d&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FjqkJdtP8JvxjucaIumQh%252Fimage.png%3Falt%3Dmedia%26token%3D9e404c1c-bdf2-4f9f-b900-4110922329cf&width=768&dpr=4&quality=100&sign=67b945d4&sv=2) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0xe9b2bc4bae138cce4666b38036b245217b45970cc1634576eb09e907f70fa5faEigenPhi](https://eigenphi.io/mev/eigentx/0xe9b2bc4bae138cce4666b38036b245217b45970cc1634576eb09e907f70fa5fa?rankdir=BT) --- # Rebalancing loan positions utilizing AAVE Flash loan | Head First DeFi: TX & Strategies [PreviousLiquidity Rebalancing: Moving Around $9.4 Million for More Fee Revenues.](/head-first-defi/under-the-hood-of-the-defi-lego/liquidity-rebalancing-moving-around-usd9.4-million-for-more-fee-revenues.) [NextHow Does the Grok Token Exploiter Exploit the X Token By Baking His Own Cake And Eating it?](/head-first-defi/under-the-hood-of-the-defi-lego/how-does-the-grok-token-exploiter-exploit-the-x-token-by-baking-his-own-cake-and-eating-it) Last updated 8 months ago Was this helpful? ### [](#strategy-one-liner) Strategy One Liner The user borrowed 178,963 USDC from AAVE and then repaid 890 USDC and 88 WETH. He used DEXes and Flash loans to rebalance his loan position. ### [](#big-picture) Big Picture ### [](#key-steps) Key Steps * Step 0: The user borrowed 178,963 USDC from AAVE * Step 1: The user sent the borrowed 178,963 USDC to Paraswap, aiming to swap for WETH * Steps 2,3: Paraswap swapped 163,810 USDC for 80.96 WETH for the user at UniswapV3 * Steps 4,5: Paraswap swapped 14,238 USDC for 7.04 WETH for the user at Pancake * Step 7: Paraswap collected a fee of 25.26 USDC * Step 6,8: Paraswap returned 890.3642 USDC and 88 WETH to the user * Step 10,13: The user repaid 890.3642 USDC and 88 WETH to AAVE ### [](#key-protocols) Key Protocols * AAVE: Aave is a decentralized crypto lending platform that lets users borrow and lend crypto. * Paraswap: ParaSwap is a decentralized exchange aggregator, like Booking.com but for DEX. * UniswapV3, Pancake: major DEXs. ### [](#key-addresses) Key Addresses * The solid green pentagon "from" is the user's EOA. * The addresses in the box "AAVE v3" are AAVE's addresses; you can view them as one account. * The oval "Paraswap Augustus Swapper" and the box "ParaSwapDebtSwapAdapterV3GHO" are Paraswap's contracts. * The oval "FeeClaimer" is Paraswap's contract for collecting fees. * The ovals "UniswapV3Pool" and "PancakeV3Pool" are UniswapV3 and Pancake's Pool addresses. ### [](#key-assets) Key Assets USDC, WETH ### [](#simplified-illustration) Simplified Illustration ### [](#step-by-step-decoding) Step-by-step Decoding * Step 0: The user borrowed 178,963 USDC from AAVE * Step 1: The user sent the borrowed 178,963 USDC to Paraswap, aiming to swap for WETH * Steps 2,3: Paraswap swapped 163,810 USDC for 80.96 WETH for the user at UniswapV3 * Steps 4,5: Paraswap swapped 14,238 USDC for 7.04 WETH for the user at Pancake * Step 7: Paraswap collected a fee of 25.26 USDC * Step 6,8: Paraswap returned 890.3642 USDC and 88 WETH to the user * Step 10,13: The user repaid 890.3642 USDC and 88 WETH to AAVE * Step 9,12: 87.96 DebtWETH and 890.36 DebtUSDC were burnt, corresponding to the user's repayment. * Step 11: 178,963 DebtUSDC were mint, corresponding to the borrow in Step 0. ### [](#more-details) More Details There are more similar rebalances like this one, for example, In contrast to other DeFi users, this user uses Flash Loan to rebalance his positions. Debt contracts are tricky to handle, but one can do margin trading and short. Meanwhile, he can also earn a little interest. The rebalance amount is so large that he sometimes becomes the victim of sandwich attacks, for example, ### [](#keywords) Keywords Flash loan, Rebalance [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0x5f6c8b87e1882ea02d09f3e7930bd2ab38170256760ffcf4b09d26a0fb6b1893,0x7535e980032c0476d260f57b1337a264109dfc1cff43f1df9e904d1f2b2feb8a,0x9337174e3120beda8777c921d35573b92cbde5420b88570cbf5bbeb401473782,0xdffc3b0f62396fbcbe8b495d950466fef20cfdd5b3b2cfa1fa3faa687daa2625EigenPhi](https://eigenphi.io/mev/eigentx/0x5f6c8b87e1882ea02d09f3e7930bd2ab38170256760ffcf4b09d26a0fb6b1893,0x7535e980032c0476d260f57b1337a264109dfc1cff43f1df9e904d1f2b2feb8a,0x9337174e3120beda8777c921d35573b92cbde5420b88570cbf5bbeb401473782,0xdffc3b0f62396fbcbe8b495d950466fef20cfdd5b3b2cfa1fa3faa687daa2625) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0x7ea9cce159d379eba23664d4c14eb077d69adfc4beec6d8db367e63848e42082EigenPhi](https://eigenphi.io/mev/eigentx/0x7ea9cce159d379eba23664d4c14eb077d69adfc4beec6d8db367e63848e42082) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0x30d21cde16a6fc54e70cc803ed3fa84252763c30d3a0a80b255806e3b4a51270EigenPhi](https://eigenphi.io/mev/eigentx/0x30d21cde16a6fc54e70cc803ed3fa84252763c30d3a0a80b255806e3b4a51270) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FljK4MEkpmnnVhEz4LiMw%252Fimage.png%3Falt%3Dmedia%26token%3D47168e95-4222-44c1-a83d-ddce87b55966&width=768&dpr=4&quality=100&sign=fa93de4a&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FA2FQgImPMko1R6DH2n2j%252Fimage.png%3Falt%3Dmedia%26token%3Dbc7e7b19-84a0-4b85-af90-b35efb860cea&width=768&dpr=4&quality=100&sign=58f1e06b&sv=2) --- # The Notorious Jaredfromsubway.eth's Sandwich Attack | Head First DeFi: TX & Strategies [PreviousDon't Let Your Trading Become the Recipe of Someone's Sandwich](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich) [NextCombined with Flash Loan, This Leveraged Sandwich Launched the Attack with Millions of Volumes](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/combined-with-flash-loan-this-leveraged-sandwich-launched-the-attack-with-millions-of-volumes) Last updated 1 year ago Was this helpful? ### [](#strategy-one-liner) Strategy One Liner With sophisticated strategies, Jaredfromsubway attacked 5 users who were swapping on Uniswap V2 in a single sandwich attack. ### [](#big-picture) Big Picture ### [](#key-steps) Key Steps 1. Frontrun steps 3,4: buy RG using 1.7380 WETH. As RG is not a popular token, this buying process raises the price of RG by about 1.2%. So later, the victim has to buy RG at a more expensive price, and the price difference is the profit of the sandwich attack. 2. Victim step 5,0: buy 0.24 ETH's RG with a higher price unknown that he has been front-ran. 3. Backrun steps 3,4: sell the exact same amount of RG (4845530.2049 RG) the attacker bought in the frontrun. The gross profit is 0.022 ETH (~$41) with a principle of 1.7380 ETH. ### [](#key-protocols) Key Protocols Uniswap V2: Uniswap is the largest DEX at that time and up to now. ### [](#key-addresses) Key Addresses * The oval marked as _to_ in frontrun and backrun is the attacker's bot (contract) address. * The pentagon marked as _from_ in the victim transaction is the victim's EOA address. * The solid oval with _UNI-V2_ in it is the UniswapV2 DEX address. Users interact with these addresses to swap tokens. * Solid ovals with different colors denote different pools. The pool colors are consistent from frontrun transactions to victim transactions to backrun transactions. ### [](#key-assets) Key Assets WETH, WSB, RG, JUAN, NOPE ### [](#simplified-illustration) Simplified Illustration ### [](#step-by-step-decoding) Step-by-step Decoding 1. Frontrun step 0: the attacker sent to his bot a “password” “365” by a small amount of ETH transaction to initiate the attack. 2. Frontrun steps 3,4: buy RG using WETH. Prepare for the attack against the RG buyer. 3. Fromrun steps 1,2: buy WSB using WETH. Prepare for the attack against the WSB buyers (there are two of them). 4. Frontrun steps 5,6,7,8: buy JUAN, NOPE using WETH. Prepare to attack JUAN, NOPE buyer. 5. Victim step 0: send 0.24 ETH to Uniswap Router, aiming to buy RG. 6. Victim steps 1,2: the Uniswap Router transforms ETH to WETH. 7. Victim step 3: this is an extra transaction written in UniswapV2's contract for the simplicity and robustness of the contract. 8. Victim steps 4,5: send the 0.24 WETH to the Uniswap aggregator and give the RG back to the user. 10. Backrun step 0: send the bot a password "374" to start the backrun. 11. Backrun steps 3,4: swap the RG got in frontrun back to WETH. 12. Backrun steps 1,2,5,6,7,8: swap the WSB, JUAN, and NOPE got from the frontrun back to WETH. ### [](#more-details) More Details ### [](#keywords) Keywords Sandwich attack, Jaredfromsubway, frontrun, backrun There are 4 more victims corresponding to the remaining swaps in frontrun and backrun. Please check for a feeling of how sophisticated Jaredfromsubway.eth is. There are 4 more victims with a similar transaction topology. Please check for more details. Jaredfromsubway.eth is 2023's biggest winner. It can make $1.16 million daily. In this sandwich attack example, he gained 0.0872 ETH with 3.8 ETH's principle. also explains the same attack. [this EigenPhi link](https://eigenphi.io/mev/eigentx/0x71d975686957d1fcb9f0bbc33c98676ab03489e29ce9d166f097e87026a3cbe3,0x98d30515bbdac3294119891720567634791a008328ee5a809506100bc4a4d8be,0xd4d6ad9cd18d509157789fb1e44826f38bbdd1d045cd8b7f86ffaa6a8e6cb56d,0x8d67d8ac76f47d4995cb8972e40e63d75b9ea4aa393cb352ea5aa0e6ec11d5f2,0xabdab0e4c2a4ad10a586784e14011c45c6137e77b2967a5e1a44eab27cf27301,0x5e6ca065a0545daace2edbf6a9a8f1318b850fae488e8e34d06ec8b096b3c9f8,0xab89c015bae4cfda325af89d9061ea99d72873d90b16d485ff38eed6dd48c14b?allow-different=0&disable-reverse-debt=0&hide-inter=0&rankdir=&show-net-asset-flow=0) [EigenPhi's webpage](https://eigenphi.io/mev/eigentx/0x71d975686957d1fcb9f0bbc33c98676ab03489e29ce9d166f097e87026a3cbe3,0x98d30515bbdac3294119891720567634791a008328ee5a809506100bc4a4d8be,0xd4d6ad9cd18d509157789fb1e44826f38bbdd1d045cd8b7f86ffaa6a8e6cb56d,0x8d67d8ac76f47d4995cb8972e40e63d75b9ea4aa393cb352ea5aa0e6ec11d5f2,0xabdab0e4c2a4ad10a586784e14011c45c6137e77b2967a5e1a44eab27cf27301,0x5e6ca065a0545daace2edbf6a9a8f1318b850fae488e8e34d06ec8b096b3c9f8,0xab89c015bae4cfda325af89d9061ea99d72873d90b16d485ff38eed6dd48c14b?allow-different=0&disable-reverse-debt=0&hide-inter=0&rankdir=&show-net-asset-flow=0) [This video](https://www.youtube.com/watch?v=out5n1bm-7c) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0x71d975686957d1fcb9f0bbc33c98676ab03489e29ce9d166f097e87026a3cbe3,0x98d30515bbdac3294119891720567634791a008328ee5a809506100bc4a4d8be,0xd4d6ad9cd18d509157789fb1e44826f38bbdd1d045cd8b7f86ffaa6a8e6cb56d,0x8d67d8ac76f47d4995cb8972e40e63d75b9ea4aa393cb352ea5aa0e6ec11d5f2,0xabdab0e4c2a4ad10a586784e14011c45c6137e77b2967a5e1a44eab27cf27301,0x5e6ca065a0545daace2edbf6a9a8f1318b850fae488e8e34d06ec8b096b3c9f8,0xab89c015bae4cfda325af89d9061ea99d72873d90b16d485ff38eed6dd48c14bEigenPhi](https://eigenphi.io/mev/eigentx/0x71d975686957d1fcb9f0bbc33c98676ab03489e29ce9d166f097e87026a3cbe3,0x98d30515bbdac3294119891720567634791a008328ee5a809506100bc4a4d8be,0xd4d6ad9cd18d509157789fb1e44826f38bbdd1d045cd8b7f86ffaa6a8e6cb56d,0x8d67d8ac76f47d4995cb8972e40e63d75b9ea4aa393cb352ea5aa0e6ec11d5f2,0xabdab0e4c2a4ad10a586784e14011c45c6137e77b2967a5e1a44eab27cf27301,0x5e6ca065a0545daace2edbf6a9a8f1318b850fae488e8e34d06ec8b096b3c9f8,0xab89c015bae4cfda325af89d9061ea99d72873d90b16d485ff38eed6dd48c14b?allow-different=0&disable-reverse-debt=0&hide-inter=0&rankdir=&show-net-asset-flow=0) The Frontrun transaction One of the victim transactions The backrun transaction Simplified Illustration ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F0Jg3Khq6ZiDsCWiWml3D%252Fimage.png%3Falt%3Dmedia%26token%3Dbbac6a08-d11f-4967-899d-96f1b298ae05&width=768&dpr=4&quality=100&sign=e1081e7b&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FU82aWTIL5UD3yeWWwstV%252Fimage.png%3Falt%3Dmedia%26token%3D1df1dd3a-1cd1-4025-84f0-abe3557b71d4&width=768&dpr=4&quality=100&sign=5efd75d3&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FLs5GQ6pcsh7K4Jo2h2dK%252Fimage.png%3Falt%3Dmedia%26token%3D8ec40a6d-b32d-4ef7-9ddf-fa01e958af16&width=768&dpr=4&quality=100&sign=cab51b54&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252Fhl1u7dVjbzQdsSxFp3vs%252Fimage.png%3Falt%3Dmedia%26token%3D7330d3df-406d-4f2b-8d99-a691bfb6b7ff&width=768&dpr=4&quality=100&sign=912d49fc&sv=2) --- # Sandwich Targeting Liquidity Providers | Head First DeFi: TX & Strategies [PreviousCombined with Flash Loan, This Leveraged Sandwich Launched the Attack with Millions of Volumes](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/combined-with-flash-loan-this-leveraged-sandwich-launched-the-attack-with-millions-of-volumes) [NextThe Flash-Loan-Enabled Sandwich Attack against Ethereum Foundation](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich/the-flash-loan-enabled-sandwich-attack-against-ethereum-foundation) Last updated 1 year ago Was this helpful? ### [](#strategy-one-liner) Strategy One Liner Apart from swap transactions, sandwich attacks may also squeeze add-liquidity transactions. Here is a genius example. ### [](#big-picture) Big Picture ### [](#key-steps) Key Steps 1. Frontrun: The sandwich bot swapped 21.4778 WETH to 458,875.7693 SYC through UniswapV2. 2. Victim's Transaction Steps 0,1: A liquidity provider added 15 WETH and 231,712.9637 SYC to UniswapV2 and minted 1,792.6288 UNI-V2 as a voucher. 3. Backrun Steps 0,1: The sandwich bot swapped 458,875.7693 SYC, as obtained in the front-running transaction, back to 22.4006 WETH. 4. Backrun Step 3: The attacker gave the block builder a fee to let him put the three transactions in the block with the order preserved. ### [](#key-protocols) Key Protocols Uniswap: the largest DEX as of press time.WETH: an ERC20 token that is 1:1 to ETH. ### [](#key-addresses) Key Addresses * The solid red oval "UniswapV2Pool" is UniswapV2's SYC/WETH Pool address. * The oval "to" in frontrun and backrun is the attacker's contract address. * The pentagon "from" in the victim transaction is the victim's EOA. ### [](#key-assets) Key Assets WETH, ETH, SYC ### [](#simplified-illustration) Simplified Illustration The UNiswapV2Pool labeled with 🥪 is where the sandwich happened. ### [](#step-by-step-decoding) Step-by-step Decoding 1. Frontrun: The sandwich bot swapped 21.4778 WETH to 458,875.7693 SYC through UniswapV2. 2. Victim's Transaction Step 0: A liquidity provider (LP) sent 15 ETH to UniswapV2 Router. Later, this 15 ETH will be transformed into WETH and added to UniswapPool as Liquidity. 3. Victim's Transaction Step 1: The LP added 231,712.9637 SYC to UniswapV2. 4. Victim's Transaction Steps 2,3,4: UniswapV2 Router transformed the 15 ETH it received from the LP to WETH and added to UniswapPool. 5. Victim's Transaction Step 5: UniswapV2 returned the LP 1,792.6288 UNI-V2 as a voucher. 6. Backrun: The sandwich bot swapped 458,875.7693 SYC, as obtained in the front-running transaction, back to 22.4006 WETH. 7. Backrun Step 3: The attacker gave the block builder a fee to let him put the three transactions in the block with the order preserved. 8. Backrun Step 4: The attacker paid for the gas fee. ### [](#more-details) More Details In the end, the bot made a profit of $35.89. It seems simple. But why was the sandwich bot able to profit from LP’s add-liquidity transaction? Where was the revenue coming from? Was it making the maximum amount of revenue possible? And who was being affected negatively? Let's do it step by step. In the frontrun, the attacker swapped ETH for SYC. So, the price of SYC rose (and rose by 100%!). Then, our poor LP added liquidity with the ratio corresponding to the marginal price after the frontrun. Adding liquidity would stabilize the price at that value, so the attacker would enjoy a smaller slippage when he sells the SYC in the backrun. Finally, the attacker sold SYC to ETH with a higher average price and made a gross profit of nearly 1 ETH. The amount of ETH swapped in the frontrun was carefully calculated to not exceed the thresholds set by LP. In other words, the attacker has reached the maximum amount of revenue possible. **The most important takeaway from this case is that LPs should carefully set thresholds tighter.** ### [](#keywords) Keywords Sandwich attack, Liquidity Provider, Uniswap The attacker first sold ETH to SYC and then, after the price of SYC rose, repurchased ETH using SYC. In a more thorough , we provide a detailed explanation of this strategy and show that all liquidity providers in this pool bear the most significant losses compared to the LP in the victim transaction. [research report](https://eigenphi.substack.com/p/a-brand-new-sandwich-bot-that-could) [![Logo](https://www.eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0x6d174d460f7fc2eec5d851d213c7ae39590bbada768ab40400a97e4fe16f4cdf,0x2d38eeebe9deac4c6a180dc94f04b60c28773a829d432f38a2569817e574aae5,0xc82ed6a0514000c42fa817dbc707f04542bdc7610330c05cbe8059dbd758e7ffEigenPhi](https://www.eigenphi.io/mev/eigentx/0x6d174d460f7fc2eec5d851d213c7ae39590bbada768ab40400a97e4fe16f4cdf,0x2d38eeebe9deac4c6a180dc94f04b60c28773a829d432f38a2569817e574aae5,0xc82ed6a0514000c42fa817dbc707f04542bdc7610330c05cbe8059dbd758e7ff?allow-different=0&disable-reverse-debt=0&hide-inter=0&include-gas-fee=0&rankdir=&show-net-asset-flow=0) The Frontrun The Victim Transaction The Backrun ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FKHLqC62XHfgeB4ggmgDQ%252Fimage.png%3Falt%3Dmedia%26token%3D8d8e5bd6-2322-4420-a0f6-7455751b1b67&width=768&dpr=4&quality=100&sign=f1c90a72&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F1USHCxAhZJZHMoZK7dFo%252Fimage.png%3Falt%3Dmedia%26token%3Df2641aa2-e765-4709-b7c3-b7f469ad5ac8&width=768&dpr=4&quality=100&sign=6db9a439&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FwmhmKYLi3ws0AA6d2qmD%252Fimage.png%3Falt%3Dmedia%26token%3D7d5578bd-93e2-4248-87e1-e6fefbdce8fc&width=768&dpr=4&quality=100&sign=d2549f14&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FUWhYZMvne0Oq3ooBL0jX%252Fimage.png%3Falt%3Dmedia%26token%3D8ab9599d-f0ac-4562-80f5-9d16bcbe3c49&width=768&dpr=4&quality=100&sign=74fc1990&sv=2) --- # Adding Liquidity. | Head First DeFi: TX & Strategies [PreviousLet's Match the Bank Branch to a Uniswap Pool.](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/lets-match-the-bank-branch-to-a-uniswap-pool.) [NextRemoving Liquidity.](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/removing-liquidity.) Last updated 1 year ago Was this helpful? Let's look at shown in EigenTx to understand what's happening. The full token flow chart is here. Dive into the details. Steps 0, 1: You added USDC and WBTC to the pool. Step 2: The "virtualLiquidity," the virtual contract recording the total shares of the pool, minted a certain amount of "virtualLiquidity," to record your adding USDC & WBTC liquidity operation. Here, EigenTx uses "virtualLiquidity" as a voucher. Step 3: The double-entry bookkeeping demands that once a record is added, another record must be added to balance the balance sheet. After step 2, another virtual asset as a voucher, "virtualLiquidity-350101", has to be "minted" to record the shares owned by you now, and it is transferred to your "UNI-V3-POS-350101" NFT contract. Step 4: The actual NFT, UNI-V3-POS-350101, is minted and transferred to you, the liquidity provider, indicating your position/shares in the pool. All the dashed lines in the chart show the connections between these actual and virtual contracts. In comparison with adding liquidity, removing liquidity is more complex. [this add liquidity transaction](https://eigenphi.io/mev/eigentx/0x6fc42e9513ca3704ac388e1a8258c86d33b9e184d31e8ffd6fab2465f5ebfe4b?rankdir=TB) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F3e3ZfwDD0aE24u82kUj4%252Fimage%2520%2837%29.png%3Falt%3Dmedia%26token%3D816a7e98-ab31-4f9b-91f2-fd6c2ef70238&width=768&dpr=4&quality=100&sign=4ebdf85a&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FAwPAYdJsFHtW1vGkAWSI%252Fimage%2520%2838%29.png%3Falt%3Dmedia%26token%3D69bb5bb8-e3c8-43c8-be2d-6ae283010001&width=768&dpr=4&quality=100&sign=977c80b1&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FcW3weRxwBhV1u9C6QVuq%252Fimage%2520%2839%29.png%3Falt%3Dmedia%26token%3D4a0e6a3a-b901-4e42-81c1-5395f8fb1362&width=768&dpr=4&quality=100&sign=f4b20aaa&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FtxQ2l9Qs4lZaKTxiMmCe%252Fimage%2520%2840%29.png%3Falt%3Dmedia%26token%3Dfe656490-9a89-4636-8c87-6fdbee362ba7&width=768&dpr=4&quality=100&sign=fba1275&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FnCaBQqe6TWsSY6axWmnP%252Fimage%2520%2841%29.png%3Falt%3Dmedia%26token%3D6721ce2e-31c2-4cf9-80fd-394c5fa48330&width=768&dpr=4&quality=100&sign=69e63b94&sv=2) --- # Understand Back-Run Arbitrages and Their Signals and Join the MEV Game. | Head First DeFi: TX & Strategies [PreviousA $3.2 Million Profit Arbitrage, the Most Lucrative MEV of 2022](/head-first-defi/mev-transaction-and-strategy-101/a-usd3.2-million-profit-arbitrage-the-most-lucrative-mev-of-2022) [NextWallchain's MEV Arbitrage Redistribution](/head-first-defi/mev-transaction-and-strategy-101/wallchains-mev-arbitrage-redistribution) Last updated 1 year ago Was this helpful? ### [](#strategy-one-liner) Strategy One Liner A hacker exploited 300WBTC from Nomad Bridge and swapped them for ETH (). This massive swap created a huge opportunity for arbitrage. Then, two back-run arbitrages follow. Vetting the connections between them empowers you with the knowledge for future opportunities. ### [](#big-picture) Big Picture This link brings us to the page containing 3 transactions' token flow charts. You can also combine the 3 figures into one, as shown below. * Transfers marked with "A" belong to transaction 0x8c4...997f2 above at Position 3 of Block 15259200. * Transfers marked with "B" belong to transaction 0xb55...d7844 above at Position 5 of Block 15259200. * Transfers marked with "C" belong to transaction 0xba6...e328c above at Position 6 of Block 15259200. * The different colors of the lines/transfers indicate different assets. In this case, the blue lines are ETH-related, the green lines are WBTC-related, and the yellowish-brown lines are WETH-related. * The gas fee payments are not included. ### [](#key-steps) Key Steps We will use the steps in the combined token flow chart, which is more coherent to understand the strategy. * Step A-1: A hacker stole 300 WBTC from Nomad Bridge. * Step A-2 & A-3: the hacker swapped 300 WBTC for 2,224.3015 WETH. This unexpected massive amount of exchange severely impacted the rate between WBTC and WETH, creating the price discrepancy signal of which searchers can take advantage. * Step B-0 to B-3: we discussed this transaction in the $3.2 million profit arbitrage case, which is a transaction back-running the hacker's swapping. * Step C-0 to C-3: the same searcher bot 0xbaD finished another back-run employing the price discrepancy between the Uniswap V2 Pool and the Uniswap V3 Pool. Like the 1.2582 ETH bribe for the builder in transaction B, the searcher paid 0.6814 ETH to the builder in transaction C to ensure the miner included it. ### [](#key-protocols) Key Protocols * Uniswap: The biggest DEX protocol. * Nomad Bridge: Nomad is a bridging protocol supporting Ethereum, Moonbeam, and other chains. Nomad’s bridging protocol is built using both on-chain and off-chain components. ### [](#key-addresses) Key Addresses In Tx A: * EOA 0xb5c is marked as "from," EOA is marked as "leaf" with a leaf icon, and the contract/bot 0x0db is marked as "to"; all three belong to the Nomad hacker. * The contract marked as "Nomad: ERC20 Bridge" is the Nomad Bridge's contract. * Uniswap V2 Liquidity Pool, shown as an oval, trading WBTC and WETH: 0xBb2b8038a1640196FbE3e38816F3e67Cba72D940 In Tx B: * Bot 0xbad is the searcher's back-run arbitrage bot. * Uniswap V2 Liquidity Pool, shown as an oval, trading WBTC and WETH: 0xBb2b8038a1640196FbE3e38816F3e67Cba72D940 * Uniswap V3 Liquidity Pool, shown as an oval, trading WBTC and WETH: 0xCBCdF9626bC03E24f779434178A73a0B4bad62eD n Tx C: * Bot 0xbad is the searcher's back-run arbitrage bot. * Uniswap V2 Liquidity Pool, shown as an oval, trading WBTC and WETH: 0xBb2b8038a1640196FbE3e38816F3e67Cba72D940 * Uniswap V3 Liquidity Pool, shown as an oval, trading WBTC and WETH: 0x4585FE77225b41b697C938B018E2Ac67Ac5a20c0 ### [](#key-assets) Key Assets WBTC, WETH. ### [](#simplified-illustration) Simplified Illustration In the chart below, we combined the Tx B & C together to simplify the process. It's worth noting that 2 Uniswap V3 pools trading WBTC and WETH were involved. ### [](#step-by-step-decoding) Step-by-step Decoding #### [](#tx-a) Tx A Step 0: The Nomad hacker's EOA sent a small amount of ETH to the bot as a way to pass parameters. Sometimes, it's a block number, and sometimes it could also be another meaning. For example, if you check all the transactions to this "to" contract, the amount is always 0**.**00000000000000466 ETH. So, it is likely that 466 is the "password" that the attacker uses to operate his bot. This approach could be cheaper than passing parameters directly. Step 1: The hacker's bot took 300 WBTC from Nomad Bridge's contract. Step 2-3: The bot swapped 300 WBTC for 2,224.3015 WETH in the Uniswap V2 Liquidity Pool trading WBTC and WETH. Step 4-5: The bot unwrapped the WETH as ETH. Step 6: The bot sent the ETH to an EOA of the hacker. * * * #### [](#tx-b) Tx B Step 0: The searcher's bot borrowed 296.835415 WBTC from Uniswap V2's WETH/WBTC pool using Uniswap's flash swap. Step 1-2: The searcher's bot swapped the borrowed WBTC for 4,160.997729 WETH in Uniswap V3's WETH/WBTC pool. Step 3: The searcher's bot returned the borrowed WBTC in 2,193.2113 WETH. Step 4: The searcher burned 0.0072 ETH as a gas fee. Step 5: To ensure the miner accepts the arbitrage, the searcher transferred 1.258 ETH to the miner as a bribe. * * * #### [](#tx-c) Tx C Step 0: The searcher's bot borrowed 75.8357 WBTC from Uniswap V2's WETH/WBTC pool using Uniswap's flash swap. Step 1-2: The searcher's bot swapped the borrowed WBTC for 1070.7816 WETH in Uniswap V3's WETH/WBTC pool. Step 3: The searcher's bot returned the borrowed WBTC in 1064.2104 WETH. Step 4: The searcher burned 0.0090 ETH as a gas fee. Step 5: To ensure the miner accepts the arbitrage, the searcher transferred 0.6814 ETH to the miner as a bribe. ### [](#more-details) More Details #### [](#how-do-we-find-out-the-3-transactions-affiliations-in-the-block) How do we find out the 3 transactions' affiliations in the block? To monetize the pricing discrepancy created by the Nomad hacker, the searcher 0xbad had to put its back-run transactions right after the hack transaction. We can find out the situation using EigenTx's Affiliated Txs tabs. #### [](#how-do-we-combine-the-3-transactions-token-flow-charts-into-one) How do we combine the 3 transactions' token flow charts into one? #### [](#can-we-tell-how-much-the-searcher-made-from-these-2-arbitrages) Can we tell how much the searcher made from these 2 arbitrages? From the last case, we showed you that the searcher reaped 1,967.7864 ETH. The balance table of the combined transactions shows the total profit of the searcher as 1,974.3576 ETH. The difference between these 2 profits is 6.5712 ETH, which is precisely the difference of the swapped ETHs in Tx C: 1070.7816-1064.2104 = 6.5712. #### [](#why-do-we-need-a-combined-token-flow-chart) Why do we need a combined token flow chart? The consolidated token flow chart provides valuable insights into the flow of tokens and transactions, making it easier to follow the path of value and identify potential arbitrage opportunities. ### [](#keywords) Keywords Back-run, Nomad hack, 0xbad. brings you to all the transactions in the same block. To view the combined token flow chart, first for the 3 separated ones. Then click the "View Multi-Txs In one Chart" to get the combined token flow chart. [This link](https://bit.ly/3EO1hEl) [visit this page](https://bit.ly/3PwJKFF) [the hack of Nomad Bridge](https://eigenphi.substack.com/p/the-immediate-arbitrage-effect-of) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0x8c475bff9d0d2f459a603a34c6cdb0a60406fbb8d46c2abbc165b64d9e5997f2,0xb55d4267a3565fdc8bada2638f97ed0bb31aa40bf8d4b304086dbdc1ca7d7844,0xba63bfb285e5639d3456f6f789589b896655c25d39ca30b4af72f1020d0e328cEigenPhi](https://eigenphi.io/mev/eigentx/0x8c475bff9d0d2f459a603a34c6cdb0a60406fbb8d46c2abbc165b64d9e5997f2,0xb55d4267a3565fdc8bada2638f97ed0bb31aa40bf8d4b304086dbdc1ca7d7844,0xba63bfb285e5639d3456f6f789589b896655c25d39ca30b4af72f1020d0e328c) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FpnpK43FcEJTjE7x0lTka%252Fimage.png%3Falt%3Dmedia%26token%3D544b51dd-1cad-46d1-9ee4-3d3c33ee2d61&width=768&dpr=4&quality=100&sign=db0b05d4&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FKpWiMnxJ1usUI69i1dxp%252Fimage.png%3Falt%3Dmedia%26token%3D509225a0-7add-41bd-8534-c59fa0538a52&width=768&dpr=4&quality=100&sign=f7dfc8e3&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FnVScSgjYKBg4lH3haqqI%252Fimage.png%3Falt%3Dmedia%26token%3Dc9cadb09-2ddc-4158-b5c6-48f43f86a4eb&width=768&dpr=4&quality=100&sign=7a0bc2b3&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FwEdEfIqowoWz78CmFmhA%252Fimage.png%3Falt%3Dmedia%26token%3D6da522d3-b657-4ff5-a7af-ed5b4ea2aca4&width=768&dpr=4&quality=100&sign=456d5170&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FMWiuz3oQIG4hhZzfaiN1%252Fimage.png%3Falt%3Dmedia%26token%3D5a7577aa-32e8-439c-90d7-90f08d72f523&width=768&dpr=4&quality=100&sign=3d459b75&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FotEuHaPCw9oRSx7Pcnia%252Fimage.png%3Falt%3Dmedia%26token%3D72345255-46f5-4485-8422-11eabc8821c3&width=768&dpr=4&quality=100&sign=b06e227e&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252Fk3j2l8xRGOiIu1wpPajZ%252Fimage.png%3Falt%3Dmedia%26token%3D6aa8cd6b-94e3-41ec-8688-dbd36e1ad592&width=768&dpr=4&quality=100&sign=8fcbcf61&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FLOo7JFprAnj2FCqrTLGm%252Fimage.png%3Falt%3Dmedia%26token%3D34bc7bba-322e-45f5-9e97-32d6e30856e2&width=768&dpr=4&quality=100&sign=6017028f&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FEZMoaRz80KyytsrO7UuG%252Fimage.png%3Falt%3Dmedia%26token%3Dd55892fa-63ab-4570-8403-a2f152e52426&width=768&dpr=4&quality=100&sign=40543541&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F8t0iRcH605CnIMFYZqXB%252Fimage.png%3Falt%3Dmedia%26token%3Dd168a429-7b59-4ff4-b75a-309b20f5b951&width=768&dpr=4&quality=100&sign=6b8c1035&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2Feigenphi.feishu.cn%2Fspace%2Fapi%2Fbox%2Fstream%2Fdownload%2Fasynccode%2F%3Fcode%3DNGVjZjQxNmU1ODNmOTQwMTgzYzI2OWU5OGFmNmJlYmZfRkszS1RlMXI3cndZUlUyRGxuVjZFdUJVc3F0TlAyTXRfVG9rZW46THRrUmI3RTR2b3hWRFF4YXQ5WmNKR1BXbldmXzE2OTU5OTc3NDM6MTY5NjAwMTM0M19WNA&width=768&dpr=4&quality=100&sign=2b1eed9b&sv=2) --- # Removing Liquidity. | Head First DeFi: TX & Strategies [PreviousAdding Liquidity.](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/adding-liquidity.) [NextConclusion](/head-first-defi/under-the-hood-of-the-defi-lego/whats-really-going-on-when-processing-liquidity-in-a-uniswap-pool/conclusion) Last updated 1 year ago Was this helpful? When removing liquidity from a pool, several things will happen . Remember, you are still the liquidity provider here. Let's use the above tables again for easier understanding. * MOVE 1: Your exclusive shares of the pool in "virtualLiquidity-350101" will be burned to reflect your liquidity removal. This is a virtual shares "burn" operation added by EigenTx to indicate the internal accounting operation. Remember that we've added "minted," 2 virtual shares in the Adding Liquidity transaction. * MOVE 2: The total shares of the pool will remove your shares from the total share "virtualLiquidity." This is also a virtual shares "burn" operation added by EigenTx to indicate the internal accounting operation. * MOVE 3: The internal assets position data will remove your assets. Since we did not mint any virtual assets in the Adding Liquidity transaction, here we need to "mint" the virtual assets first. These are also "virtual" operations. The internal accounting processes of Uniswap and Bank are generally similar, with the difference being that, on Uniswap, after a user deposits money, their assets are mixed with others and follow the changes in currency holdings according to the AMM curve. Therefore, when depositing money, it is not necessary to record how much of each token has been deposited. When the liquidity is removed, Uniswap calculates the specific amount of tokens that can be taken out based on the provider's liquidity shares. * MOVE 4: The removed virtual assets from the pool's internal assets positions will be added to your external position data, which are "mint" operations. These are also "virtual" operations. * MOVE 5: Now, the pool's internal accounting operations have done the removal process. Then, the pool transfers the actual assets to you, including the liquidity fees you earn. * MOVE 6: To keep the sheet balance, the internal and external position data need to "burn" the virtual assets. These are also "virtual" related operations. * MOVE 7: In the end, the Position NFT will be burned to reflect the liquidity removal. Here is the whole token flow chart. It is time to thoroughly break down the steps involved and match the abovementioned moves. Steps 0-1: The two virtual internal assets positions minted virtualOwed0WBTC and virtualOwed1USDC and sent to the actual total internal position contract. MOVE 3. These 2 steps are overlapped in the chart. But you can find the details in the transfer list shown below. Go to the next step. Step 2: The virtual total shares burned your shares. MOVE 2. Step 3: Your exclusive external virtual shares were burned. MOVE 1. Steps 4-5: The two virtual external assets positions minted virtualOwed0WBTC-350101 and virtualOwed1USDC-350101 and sent to the actual total internal position contract. MOVE 4. Steps 6-7: The pool transferred your liquidity and fees you earned back to you. MOVE 5. Steps 8-11: Now that both the internal and external representation of the liquidity provider account should have no balance. UNI-V3-POS and UNI-V3-POS-350101 burned the corresponding balances of virtual assets. MOVE 6. Step 12: This matches the MOVE 7 that burned the position NFT to reflect the liquidity removal. Step 13: The builder was paid. Now, let's look at step by step. [this actual liquidity removal transaction](https://bit.ly/43Q8MoP) [in this transaction](https://eigenphi.io/mev/eigentx/0x01e55eaf91125a5de871595e9601e49853efadf5f10c72fce7b64a443cc327e7?rankdir=LR) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FjgHHhGtWufifOQcPP3xE%252Fimage%2520%2842%29.png%3Falt%3Dmedia%26token%3D93c1fc2f-5e3a-4f8b-8569-c2844fb0a377&width=768&dpr=4&quality=100&sign=cf3bc12a&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FmgDiblvNZEeQRMHkqqwz%252Fimage.png%3Falt%3Dmedia%26token%3Df232463e-b86c-4e32-9dd6-f666c1a112e0&width=768&dpr=4&quality=100&sign=3d58f610&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FGj8VTi8WA85ZBnyu8267%252Fimage.png%3Falt%3Dmedia%26token%3D634886ba-cf0a-4ce6-abc8-1d4ede1610c2&width=768&dpr=4&quality=100&sign=2ff84fca&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FSaqI9PBbVbdX1nYC5p96%252Fimage.png%3Falt%3Dmedia%26token%3D6d685549-7ee4-4c0b-a141-f88581c754b1&width=768&dpr=4&quality=100&sign=5cff9004&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FeMoZf743GPtEBp0K4eiL%252Fimage.png%3Falt%3Dmedia%26token%3D297e890c-f6b3-40ac-81b6-e45d618174eb&width=768&dpr=4&quality=100&sign=7952edcb&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FKvB4wMo599IgPPM4HMjN%252Fimage.png%3Falt%3Dmedia%26token%3Dfcb5750d-afa8-446e-8d84-c3ff9460f652&width=768&dpr=4&quality=100&sign=dc852e8a&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FRfmwKI8tfPLMs2psS7Xx%252Fimage.png%3Falt%3Dmedia%26token%3D9492256e-5208-46ec-bb44-d957e58b38d9&width=768&dpr=4&quality=100&sign=3be4cf2d&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FeZ5oP0X03Oti4tc1Vvpz%252Fimage.png%3Falt%3Dmedia%26token%3D5f17ab1f-9547-4125-9642-fb632517916a&width=768&dpr=4&quality=100&sign=1ede0592&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FpHA9h629exb5fxTdXBBR%252Fimage.png%3Falt%3Dmedia%26token%3D7438d803-bb46-43ca-b234-c55b81567046&width=768&dpr=4&quality=100&sign=79b1017e&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F6ElRxq0H6TfL0wu4FT9e%252Fimage.png%3Falt%3Dmedia%26token%3Df62af8c7-6c0c-4b29-b828-fbf7cfbbf846&width=768&dpr=4&quality=100&sign=bd28acf6&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F1EV8otwBcRyHIh27DwBy%252Fimage.png%3Falt%3Dmedia%26token%3Da64e5cc0-2952-4f02-b8de-04ecb69e30f3&width=768&dpr=4&quality=100&sign=7a6f9630&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FBFWqBPzQIK4LhK2I26KO%252Fimage.png%3Falt%3Dmedia%26token%3Dcdbbe243-7b35-4776-b118-be0b8923d4c1&width=768&dpr=4&quality=100&sign=edfec50a&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252Frg68qrxScXee2ZHx0K7u%252Fimage.png%3Falt%3Dmedia%26token%3D9d96a536-4b01-41d9-8b9e-0ba40b788b9e&width=768&dpr=4&quality=100&sign=22b4dddf&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FYiMARVGAnoN16unXsbkh%252Fimage.png%3Falt%3Dmedia%26token%3D2b29fa50-9dac-4f3c-8c58-3e37cf93dee6&width=768&dpr=4&quality=100&sign=fab5ea7c&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252F62kjmeAaL9YFGSvnJGQR%252Fimage.png%3Falt%3Dmedia%26token%3De704d93f-1bfc-4bcf-af42-55412034cfd2&width=768&dpr=4&quality=100&sign=69115648&sv=2) --- # MEV-Share, Flashbots' MEV Redistribution Solution | Head First DeFi: TX & Strategies [PreviousThe Hidden Tax That You Should Know About](/head-first-defi/mev-transaction-and-strategy-101/the-hidden-tax-that-you-should-know-about) [NextDon't Let Your Trading Become the Recipe of Someone's Sandwich](/head-first-defi/dont-let-your-trading-become-the-recipe-of-someones-sandwich) Last updated 1 year ago Was this helpful? ### [](#strategy-one-liner) **Strategy One-liner** A user swapped ETH for DOBBY, which caused an imbalance in price, leading to an arbitrage opportunity between a Uniswap V3 pool and a Uniswap V2 pool. A searcher took the chance by sending bundle rewards to Flashbots' builder. In the end, the builder refunded 90% of the bundle rewards to the user. ### [](#big-picture) **Big Picture** Here are the token flow charts for the 3 transactions involved. You can see the combined token flow chart here: ### [](#key-steps) **Key Steps** 1. Tx A, Steps 0, 4: The user's swapping ETH and DOBBY in the Uniswap V3 pool caused a price difference between this trading venue (Uniswap V3 Pool) and a Uniswap V2 Pool, making arbitrage between the V2 pool and V3 pool profitable. This is the _signal_ for the back-run, Tx B. 2. Tx B, Steps 3, 5, 6, 7: The searcher finished the back-run arbitrage, taking advantage of the above price difference of DOBBY and WETH between the Uniswap V3 Pool and the Uniswap V2 Pool, both trading DOBBY and WETH. 3. Tx B, Step 10: The searcher sent 0.6696 ETH to Flashbots' builder to let the builder put his back-run arbitrage in the block's top position after the trader's transaction. 4. Tx B, Step 4: DOBBY is a tax token, taking 3% of the total traded DOBBY. 1. Tx C, Step 0: The builder returned 90% of the builder rewards, 0.6024 ETH, to the original trader. This is the refund step, also the goal of the MEV Blocker project. ### [](#key-protocols) **Key Protocols** > The MEV-Share protocol allows users to selectively share data about their transactions with searchers who bid to include them in bundles. By empowering users in this way, MEV-Share enables them to internalize the MEV that they generate while transacting. * Uniswap: The biggest DEX protocol. ### [](#key-addresses) **Key Addresses** #### [](#in-tx-a) In Tx A: * The pentagon marked as "from", 0x896, is the user's EOA. * The oval marked as "UniversalRouter" is the router contract of Uniswap. * "UniswapV3Pool" used in step 4 & 5 is the Uniswap V3 Pool trading DOBBY and WETH, 0x5cE32e6c505EE381A24599e43Ee68FA600E79C88. #### [](#in-tx-b) In Tx B: * The pentagon marked as "from", 0xb82, is the searcher's EOA. * "to" contract, 0x75a, is the bot of the searcher. * "UniswapV3Pool" used in step 6 & 7 is the Uniswap V3 Pool trading DOBBY and WETH, 0x5cE32e6c505EE381A24599e43Ee68FA600E79C88. * "UNI-V2" used in step 3,4, and 5 is the Uniswap V2 Pool trading DOBBY and WETH, 0xe32081A135Fcf8158525125e089DD86b9685424C. * "leaf" used in step 4 is DOBBY's tax collector EOA, 0x36FA1721daFAf6173dFD74a89e6c476B7fA5387f. * "Builder" used in step 10 is the EOA of Flashbots' builder, Flashbots-builder.eth: 0xDAFEA492D9c6733ae3d56b7Ed1ADB60692c98Bc5. #### [](#in-tx-c) In Tx C: * "from Builder 0xdaf...98bc5" is the EOA of Flashbots' builder, Flashbots-builder.eth. * "to leaf 0x896...94510" is the user's EOA. ### [](#key-assets) **Key Assets** DOBBY, WETH ### [](#simplified-illustration) **Simplified Illustration** ### [](#step-by-step-decoding) **Step-by-step Decoding** #### [](#tx-a) Tx A * Step 0: The user transferred 1 ETH to Uniswap's Router to swap for DOBBY. * Steps 1 & 2: The Uniswap Router wrapped the ETH as WETH. * Steps 3, 4 & 5: The Uniswap's Router sent the WETH to the Uniswap V3 pool trading DOBBY and WETH and swapped out 7023315.6073 DOBBY, which was sent back to the user's EOA. #### [](#tx-b) Tx B * Step 0: The searcher sent 3 ETH to its bot for the back-run arbitrage. * Steps 1-2: The bot wrapped the ETH as WETH. * Steps 3, 5: The searcher's bot sent 0.25 WETH to the Uniswap V2 Pool trading DOBBY and WETH and swapped out 6,684,784.828 DOBBY. * Step 4: DOBBY's tax collector took 3% of the trade, 206,745.9225 DOBBY, as the tax. * Steps 6-7: The searcher's bot exchanged 6,684,784.828 DOBBY for 0.9563 WETH in the Uniswap V3 Pool trading DOBBY and WETH. Now, the bot had 3.7063 WETH with 0.7063 WETH as revenue of the arbitrage. * Steps 8-9: The bot unwrapped the WETH as ETH. * Step 10: The bot sent 0.6696 ETH to the builder, Flashbots-builder.eth, as bundle rewards. * Step 11: The bot sent 3.0367 ETH to the searcher's EOA, reaping 0.0367 ETH as the final revenue of the back-run arbitrage. #### [](#tx-c) Tx C * Step 0: The builder refunded 0.6024 ETH to the user, following the rule of MEV-Share. It's 90% of the bundle rewards received from the searcher. ### [](#details) Details It consists of three transactions, leading by the user transaction on position 0, followed by the back-run arbitrage on position 1. In accordance with the agreement, the Flashbots' builder will return a portion of this profit as a rebate to the user who initiated the order flow, happening at position 2. To put all of these together, you can use the "View Multi-Txs in One Chart" function, helping you get a better idea of the whole picture. ### [](#keywords) Keywords MEV redistribution, PBS (proposer-builder separation), MEV-Share, Flashbots, back-run To see how tax tokens work, check out its case study here: **.** MEV-Share: According to: Visit to view more details about these 3 transactions. Let's work out the rebate ratio of this MEV-Share trade. Unlike , where Builder0x69 received the bundle rewards through gas fees, here, the searcher sent 0.6696 ETH directly to the builder using MEV-Share. The builder then returned 0.6024 ETH to the user, accounting for 90% of the bundle rewards. [**The Hidden Tax That You Should Know About**](https://eigenphi-1.gitbook.io/defi-tx-and-strategy-case-studies-by-eigenphi/mev-transaction-and-strategy-101/the-hidden-tax-that-you-should-know-about) [Flashbots](https://collective.flashbots.net/t/announcing-mev-share-beta/1650) [here](https://eigenphi.io/mev/eigentx/0x31248e1ff0b589ec82396941ad42d25d68bd4ce6cdfe1c5a91af455fad058629,0x10681972918ff2b9a67d53e80b4575f8adec05fd3fd3946c65b9d7aa60739083,0xea6df8d018c98a20b4e0e1c19af313aa6a75754d1c3ee9f9986de9e07bc92fbb?tab=block) [the case with MEV Blocker](https://eigenphi-1.gitbook.io/defi-tx-and-strategy-case-studies-by-eigenphi/mev-transaction-and-strategy-101/mev-blocker-the-multi-transaction-mev-redistribution-system-that-refunds-90-of-builder-rewards.) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:0x31248e1ff0b589ec82396941ad42d25d68bd4ce6cdfe1c5a91af455fad058629,0x10681972918ff2b9a67d53e80b4575f8adec05fd3fd3946c65b9d7aa60739083,0xea6df8d018c98a20b4e0e1c19af313aa6a75754d1c3ee9f9986de9e07bc92fbbEigenPhi](https://bit.ly/3QfBprn) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:multi/0xea6df8d018c98a20b4e0e1c19af313aa6a75754d1c3ee9f9986de9e07bc92fbb,0x10681972918ff2b9a67d53e80b4575f8adec05fd3fd3946c65b9d7aa60739083,0x31248e1ff0b589ec82396941ad42d25d68bd4ce6cdfe1c5a91af455fad058629EigenPhi](https://eigenphi.io/mev/eigentx/multi/0xea6df8d018c98a20b4e0e1c19af313aa6a75754d1c3ee9f9986de9e07bc92fbb,0x10681972918ff2b9a67d53e80b4575f8adec05fd3fd3946c65b9d7aa60739083,0x31248e1ff0b589ec82396941ad42d25d68bd4ce6cdfe1c5a91af455fad058629?allow-different=0&disable-reverse-debt=0&hide-inter=0&include-gas-fee=0&rankdir=LR&show-net-asset-flow=0) The Combined Token Flow ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FmKZRPkPNUJdEHvp7f6AY%252Fimage.png%3Falt%3Dmedia%26token%3D665e2c82-0d25-45dc-9152-dffb7aa27533&width=768&dpr=4&quality=100&sign=b293416c&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FdqP9LYAcU3aHJ4aVIfLo%252Fimage.png%3Falt%3Dmedia%26token%3Df1cf152e-ff81-428f-9f21-cd692382a0c2&width=768&dpr=4&quality=100&sign=e1b4da4c&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FoqqHEgK0CqEtgBjtVGmW%252Fimage.png%3Falt%3Dmedia%26token%3De86ea7ab-38cc-4de1-9299-1bc29d317652&width=768&dpr=4&quality=100&sign=c1b6d923&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FJwZ5S7W5qlisQYuebVwh%252Fimage.png%3Falt%3Dmedia%26token%3Dfc33cfa6-33a0-477a-ab39-aaf64a36945a&width=768&dpr=4&quality=100&sign=ceb39eb9&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FOj0e0fDw1dq27PijTSGG%252Fimage.png%3Falt%3Dmedia%26token%3D1bfd8726-5019-4e22-8794-425c42d8590e&width=768&dpr=4&quality=100&sign=d71e5479&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252Fah2lCbFma8ZbxPZgFtOt%252Fimage.png%3Falt%3Dmedia%26token%3D42fca549-ce39-4c2d-ae5e-0939ef3d0b81&width=768&dpr=4&quality=100&sign=adf50ddb&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FODbUSkzcCyaV5gEFFMEB%252Fimage.png%3Falt%3Dmedia%26token%3D99025517-c254-4dc2-bf5a-cde2fb63cfc3&width=768&dpr=4&quality=100&sign=84bbe32e&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FJxCakG2ZRgVgDRajyRtQ%252Fimage.png%3Falt%3Dmedia%26token%3D9c667a54-78d1-435c-a226-4c424649530f&width=768&dpr=4&quality=100&sign=836457be&sv=2) --- # A Cross-Chain Arbitrage: The Art of Arbitraging BANANA Cross BSC and Polygon Chains | Head First DeFi: TX & Strategies [PreviousLiquidation: A Good Entry Point to Comprehend Internal Accounting Used by Many DeFi Protocols.](/head-first-defi/under-the-hood-of-the-defi-lego/liquidation-a-good-entry-point-to-comprehend-internal-accounting-used-by-many-defi-protocols.) [NextLiquidity Rebalancing: Moving Around $9.4 Million for More Fee Revenues.](/head-first-defi/under-the-hood-of-the-defi-lego/liquidity-rebalancing-moving-around-usd9.4-million-for-more-fee-revenues.) Last updated 1 year ago Was this helpful? ### [](#strategy-one-liner) Strategy One Liner Using 4 transactions, the bot completed a cross-chain arbitrage between BNB Smart Chain (BSC) and Polygon, swapping BANANA and other cryptos in 2 minutes, and reaped $28 as revenue. explains the same transaction. ### [](#big-picture) Big Picture This graph combines 4 Txs from 2 Chains, Polygon and BSC, into one chart. One can easily identify the corresponding chains by the chain icon tagged with the token flow. The transaction steps are marked in chronological order of occurrence by capital letter dash number. ### [](#key-steps) Key Steps Steps A-6: The arbitrager swapped 6000 USDC for 3322.9 BANANA on BSC through an aggregator contract 0xbaf…a9643. Step B: The arbitrager transferred 3322.9 BANANA to 0x171...319f1 (Anyswap) on BSC. Step C: The arbitrager received 3322.9 BANANA on Polygon. Steps B and C are the cross-chain transactions. BANANA is transferred from BSC to Polygon in these steps. Steps D-0,14: The arbitrager swapped 3322.9 BANANA for 6028 USDC through an aggregator contract 0x114…17187. ### [](#key-protocols) Key Protocols MultiChain (formerly Anyswap): A decentralized cross-chain swap protocol. ApeSwap: A decentralized exchange (DEX) on multiple chains. UniswapV2: A major DEX. Balancer: Another DEX. ### [](#key-addresses) Key Addresses The pentagon "from 0x9bb...bd255" is the arbitrager's address. The pentagon "from 0x171...319f1" is Anyswap's address. Because this chart combines multiple transactions together, there may be several "from"s. The ovals with "APE\_LP" are ApeSwap's Pools. ApeSwap is a multichain DEX. This graph shows its BNB and Polygon Pools. ### [](#key-assets) Key Assets BANANA, USDC, WETH, WMATIC, DAI ### [](#simplified-illustration) Simplified Illustration The capital letters A-D mark the order of the transactions. ### [](#step-by-step-decoding) Step-by-step Decoding Step A-0: The arbitrager sent 6000 USDC to an aggregator 0xbaf…a9643, aiming to swap for BANANA. Steps A-1,2: The aggregator swapped 6000 USDC to 6000 BUSD. Steps A-3-5: The 6000 BUSD was swapped to 3322.9 BANANA. Step A-6: The arbitrager received 3322.9 BANANA swapped from his 6000 USDC. Step B: The arbitrager transferred 3322.9 BANANA to 0x171...319f1 (Anyswap) on BSC. Step C: The arbitrager received 3322.9 BANANA on Polygon. Steps B and C are the cross-chain transactions. BANANA is transferred from BSC to Polygon in these steps. Step D-0: The arbitrager sent 3322.9 BANANA to an aggregator 0x114…17187, aiming to swap back to USDC. Steps D-1 to D-5: The arbitrage used the aggregator to swap BANANA to WETH, then to DAI then to USDC. Steps D-6 to D-13: First, swap BANANA to WMATIC, then to USDC. Step D-14: Sent all the USDCs swapped from D-1 to D-13 back to the arbitrager. That is a total of 6028 USDC. ### [](#more-details) More Details The bot gained revenue of 28.4604 USDC on Polygon. The entire cross-chain arbitrage process took about 2 minutes, and the total gas cost was about $1.35. Because the assets are moved from one chain to another in the cross-chain arbitrage, the bot would occasionally rebalance assets on these two chains, as shown in the following graph. [This YouTube video](https://www.youtube.com/watch?v=VLuG_3Qw-SQ) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:multi/0x89b6fb2d15832aac4ad7d983d1546b559bfacdddb874eb7ee9786df450d1c1f4,0x6a59a157a3bde09ba4ad93de9860aa1fa88f884357a79668e272a7c00d632b1e,0x385f73521f3a1227f7958d8263a0f7da245448178918d8cb87dd6956c28e4b3d,0xadee80fbf811c3c23c92eeb8ea70dc171a3256f079e1bf1c371e17cd6ac8b4c9EigenPhi](https://eigenphi.io/mev/eigentx/multi/0x89b6fb2d15832aac4ad7d983d1546b559bfacdddb874eb7ee9786df450d1c1f4,0x6a59a157a3bde09ba4ad93de9860aa1fa88f884357a79668e272a7c00d632b1e,0x385f73521f3a1227f7958d8263a0f7da245448178918d8cb87dd6956c28e4b3d,0xadee80fbf811c3c23c92eeb8ea70dc171a3256f079e1bf1c371e17cd6ac8b4c9) [![Logo](https://eigenphi.io/logo192.png)Transaction Flow Chart | EigenTx:multi/0x427d0460abc2a5652418afb37cb70379a2ccd149fce24b77bb64fcd4d3dcac04,0x01bf35b469b408f78956df6df8c35a8d341ff150193c2db674d3996c0f7df925EigenPhi](https://eigenphi.io/mev/eigentx/multi/0x427d0460abc2a5652418afb37cb70379a2ccd149fce24b77bb64fcd4d3dcac04,0x01bf35b469b408f78956df6df8c35a8d341ff150193c2db674d3996c0f7df925) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FMyCMJtsKcBmcgR5DciSs%252Feigentx-0x89b6fb2d15832aac4ad7d983d1546b559bfacdddb874eb7ee9786df450d1c1f4%2520%281%29.png%3Falt%3Dmedia%26token%3D64e56959-050f-4566-aff3-a70cd112fa34&width=768&dpr=4&quality=100&sign=ea9762ef&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252Fl5aFaEi9YyJEUgaG285E%252Fimage.png%3Falt%3Dmedia%26token%3D76b55e8a-59f0-48f4-b2bc-7911dee43c54&width=768&dpr=4&quality=100&sign=8c97c858&sv=2) ![](https://eigenphi-1.gitbook.io/~gitbook/image?url=https%3A%2F%2F2783121027-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252F6mxU4QYtlg9O3vnppqQm%252Fuploads%252FzIokqDXYIlAUrncIhSTp%252Feigentx-0x01bf35b469b408f78956df6df8c35a8d341ff150193c2db674d3996c0f7df925.png%3Falt%3Dmedia%26token%3Da322b33e-88fb-4a18-98f0-df07610c4e9b&width=768&dpr=4&quality=100&sign=f35b648b&sv=2) ---