Get Everything for Nothing: How to Use Flash Loans to Launch an Arbitrage?
A flash loan is a type of uncollateralized lending across DeFi protocols. In the MEV world, starting an arbitrage using flash loans might be one of the quickest and most cost-effective ways to “get everything for nothing.”
However, transactions involving flash loans are complicated and hard to decipher. If you see any trading alike, or anything transactions you deem complicated and interesting, just submit them to our AwesomeTx bounty and earn USDT.
Here we will dissect how an MEV arbitrage earned 1,180 $USDC in a transaction with flash loans from the dYdX Margin Trading Protocol.
Let's start with the roles involved in this transaction:
Address
From: an EOA account, 0xffFf14106945bCB267B34711c416AA3085B8865F.
To: MEV 🤖, 0xEdE2faFBa9e23418485f49f052D0e1d332853E0F.
0x1ce9: an EOA account, 0x1ce943e573041463202090cf662490c95585a046.
Protocol
dYdX Solo Margin: a decentralized trading platform that currently supports margin trading, spot trading, lending, and borrowing.
1inch/1inch V4 Router: DeFi exchange aggregator.
Curve Pool: Decentralized exchange (DEX)/ Automated Market Maker (AMM)
Uniswap V3: DEX/AMM
MakerDAO PSM/DssPsm: Maker's Peg Stability Module (PSM). A Peg Stability Module (PSM) allows users to swap a given collateral type directly for DAI at a fixed rate rather than borrowing DAI. Users can swap USDC, USDP, and GUSD for Dai and vice versa through the PSM.
Token
$DAI: a stablecoin pegged to the US dollar, issued by MakerDAO.
$WETC: Wrapped Bitcoin, an ERC20 token backed 1:1 with Bitcoin.
$USDC: a stablecoin pegged to the US dollar, issued by Circle.
$USDT: a stablecoin pegged to the US dollar, issued by Tether.
How it works
Let’s rotate the figure for mobile.
As shown in Figure 1:
First, the MEV 🤖 0xEdE2 ("to" in Figure 1) borrowed 1.5M $USDC from dYdX (Step 1)
Then, the MEV 🤖 0xEdE2 sent the borrowed 1.5M $USDC to 1inch (Step 2), and swapped the 💰 to 1.5M $DAI through the MakerDAO PSM (Step 3,4,5).
Subsequently, the MEV 🤖 0xEdE2 sent 1.5M $DAI again to 1inch (Step 6), which helped carry out two swaps.
450,000 $DAI.
With the help of 1inch, the MEV 🤖 swapped 450,000 $DAI for 449,826 $USDT in Curve Pool (Step 7,8). Then the 449,826 $USDT were swapped for 18.97 $WBTC with 0x1ce9 (Step 9,10), which were soon used to buy 451,242 $USDC in Uniswap V3 (Step 11,12).1,050,000 $DAI.
The MEV 🤖 swapped 1,050,000 $DAI to 1,050,000 $USDC (Step 13,14,15).
The total 1,501,242 $USDC got from two swaps was sent back to the MEV 🤖 through 1inch V4 Router (Step 16,17).
The MEV 🤖 repaid the 1.5M $USDC flash loan to dYdX (Step 18).
The MEV 🤖 earned 1,180 $USDC in total (Step 19), with paying 0.4883 $ETH to the miner (Step 20).
Highlight
The 1,050,000 $DAI of the total 1.5M $DAI was not used indeed (see grey part of Figure 2), which was eventually repaid to dYdX.
Summary
Overall, the MEV 🤖 did not have a considerate amount of initial capital through this flash loan arbitrage. After paying 0.4883 $ETH miner tips, the arbitrage made a profit of 1,180 $USDC.
As you can see, flash loans can be extremely useful in certain instances, such as for traders looking to quickly profit from arbitrage opportunities from different token exchange rates in two trading markets.
Wanna keep an eye on more flash loan MEV examples? Please follow us to keep updated with the MEV world, and please let me know if you are interested in the tool that generated the flow charts above.
And don’t miss our Awesome Transaction Bounty!
Follow us via these to dig more hidden wisdom of DeFi:
am interested in this tool ...emmytwinchimdiebere@gmail.com