Last time we unpacked the secret of a flashloan-supported arbitrage, a method to “get everything for nothing.”
In this article, we will explore the hidden features of dYdX, a decentralized exchange for advanced traders, when digging into another arbitrage earning 113 $DAI made by the same #MEV 🤖, which was also started with flash loans from dYdX.
We also welcome you to contribute fantastic and complicated transactions like these to our community, where you can earn USDT at our AwesomeTx bounty.
Stakeholders
Address
From: an EOA account, 0xffFf14106945bCB267B34711c416AA3085B8865F ("0xffFf" in Figure 1)
To: MEV 🤖, 0xEdE2faFBa9e23418485f49f052D0e1d332853E0F ("to" in Figure 1)
Contract: 0xF2F400C138F9fb900576263af0BC7fCde2B1b8a8("0xF2F4" in Figure 1, 1inch)
Leaf: 0x5E029792d2850B60b8c0C86c07854f520a8d8485("0x5e02" in Figure 1)
Protocol
AAVE V2 Collector: a decentralized non-custodial liquidity markets protocol where users can participate as depositors or borrowers. In AAVE Protocol V2, debt positions are tokenized, so borrowers will receive tokens that represent their debt.
dYdX: a decentralized exchange for advanced traders. It has some advanced features like margin trading and synthetic assets that can track the performance of other assets, like Bitcoin. dYdX also provides flash loans, but it has several hidden features that few may know about.
1inch: a DEX aggregator with a discovery and routing algorithm, which offers asset exchanges at the best rates on the market.
DoDo: a decentralized exchange built on the proactive market maker (PMM) algorithm. DODO provides competitive prices for DEX traders and reduced impermanent loss (IL) for liquidity providers.
Balancer: a community-driven protocol, automated portfolio manager, liquidity provider, and price sensor that empowers decentralized exchange and the automated portfolio management of tokens on the Ethereum blockchain and other EVM-compatible systems.
MakerDAO: the platform through which anyone, anywhere, can generate the Dai stablecoin against crypto collateral assets.
Tokens
aTokens: tokens minted and burnt upon supply and withdrawal of assets to an Aave market. More details can be found in Aave's documentation.
aUSDT: AAVE $USDT
WaUSDT: Balancer $aUSDT
Walkthrough
Let’s dissect the arbitrage with a flow chart.
You can also rotate your device counterclockwise if you are reading the chart on mobile:
The #MEV 🤖 flash loaned (⚡️) 1499999 $DAI from dYdX (Step 1),and transferred 1250 $WETH to the contract 0xF2F4 (2).
The contract 0xF2F4 (1inch) deposited 1499999 $DAI to MakerDAO (3), MakerDAO converted 1499999 $DAI 1:1 to 1499999 $USDC and transfers it to the contract 0xF2F4 (5).
The contract 0xF2F4 (1inch) deposited 1499999 $USDC to Balancer and exchanged 150033 $USDT through AAVE V2 (6 ~ 14), The gas fee was 6.0072 $aUSDT (13).
The contract 0xF2F4 (1inch) deposited 150033$USDT to DoDo and exchanged 1500119$USDC (16,17), the fee was 30.0029$USDC (18).
The contract 0xF2F4 (1inch) deposited 1500119 $USDC to MakerDAO (19), MakerDAO converted 1500119 $USDC 1:1 to 1500119 $DAI and then transfers it to the contract 0xF2F4 (20).
The contract 0xF2F4 (1inch) transferred 1500119 $DAI to the #MEV 🤖 (21,22).
The #MEV 🤖 repaid 1499999 $DAI of flash loan (⚡️) to dYdX (23).
The #MEV 🤖 collected 113.4851$DAI income to 0x5e02 Leaf(24).
0xffFf address (From) payed miner 0.0348$ETH via the #MEV 🤖(0,25).
With dYdX flash loans, the MEV 🤖 has gained 113.4851 DAI in revenue in this arbitrage while paying the gas fee (6.0072 $aUSDT & 30.0029 $USDC) and the miner tips (0.0348$ETH).
Highlight
On the pros side:
There’s no charge on dYdX. That’s a really big bonus!
You can use the flash loan money for arbitrages on dYdX itself.
On the cons side:
Limited choice of tokens.
You cannot borrow ETH directly. Instead, you’ll get WETH (Wrapped Ether), which is less convenient for making deals.
It’s complex to integrate with their system of actions, and they don’t have proper documentation for their hidden flash loan system.
Summary
The searcher flash loaned $DAI through dYdX and routed multiple swaps on the 1inch aggregator platform, and then returned the $DAI to the dYdX platform. In the end, the searcher received 113 $DAI and spent near $36 as gas fee and 0.0348$ETH as the miner tips.
Arbitrages like this one happened almost every day. Wanna become one of the advanced searchers who practically take advantage of flash loans? Please follow us to get more flash loan MEV examples, 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: