0xBeans.eth Profile picture
Mar 22 19 tweets 6 min read
Gonna end the $APE content with 1 final thread. Let's dive into how this absolute fucking chad borrowed 5 bored apes, claimed $APE for all of them, returned the apes, and subsequently netted ~600k.

A story of how a bot looked for value where no one else did.
First we have to understand what flash loans are.

Flash loans are a DeFi concept that allow a contract to borrow large sums of money as long as the loan gets paid back within 1 txn.

If the loan isn't paid back in 1 txn, everything is reverted (as if nothing happened).
"How" this all happens in 1 txn is beyond the scope of this thread.

Typically flash loans are used for arbitrage, front running, etc. Here's an example of how you would use a flash loan if you detected an arbitrage opportunity.
Second, we have to understand what NFTX is. I personally haven't used NFTX but "NFTX is a platform for creating liquid markets for illiquid Non-Fungible Tokens (NFTs)".

Essentially its a protocol where you can lock up your NFT in a vault and receive liquid ERC20 tokens back.
For example, you can lock up your BAYC (erc721) in a vault and get 1 vBAYC token (erc20) back. You can redeem an ape from the vault by giving back your vBAYC.

Why does this protocol exist? Out of scope again but essentially gives liquidity (erc20) to non liquid assets (erc721)
So now knowing all this, let's dive into the bot txn.

First, bored ape #1060 was transferred to the bot contract. This ape wasn't borrowed but actually bought from OS. We'll see why the bot bought an ape later in this thread.

(English is hard... "bought" "bot" lmao)
Next, the bot gets a flash loan of 5.2 vBAYC tokens from the NFTX vault.
Next, the bot swaps out its vBAYC tokens for 5 actual apes (5 apes have been transferred to the bot).

Notice the first ape doesnt come from the NFTX vault (since thats the ape the bot actually bought). So by this point, the bot has 6 apes in its possession.
Next, the bot calls to the $APE airdrop contract and claims all the $APE for all 6 apes. Netting ~$600K.
Finally, the bot transfers the apes back to the NFTX vault to redeem back vBAYC tokens to repay the loan.
So why did the bot need to buy its own bored ape?

It's because flash loans have a fee attached to them. Whenever you get a flash loan, you must pay a fee in addition to the original loan.

So the bot swapped its own bored ape (#1060) for vBAYC to pay off the flash loan fee.
The funny thing is, the fee only took a portion of the vBAYC tokens the bot redeemed for its own ape.

Since the bot has no need for extra vBAYC tokens, it just swapped its remaining vBAYC for 14 ETH.
What I find beautiful is that I assume this bot didn't have much competition for this strategy (I may be wrong on this).

MEV is super competitive, it's extremely hard to write a profitable MEV bot to arbitrage/frontrun because so many big brains are in the space (bot vs bot).
However, if you just look at extracting value in a place that no one else is looking at, you win.

Quoting @bertcmiller "If you're thinking about these things or looking for them, which not many ppl are, there's a lot of value to be captured".
The cherry on top is that boy genius @_anishagnihotri wrote this EXACT same strategy that borrowed punks from NFTX to mint Meebits last year.
The sad thing about this whole story is that I read Anish's strategy, thought it was really clever, and completely forgot about it lmao.

Guess Im ngmi in MEV... not big brain enough.
Just because I KNOW Im gonna get a question about this. "Is this ethical and is ethereum doomed".

Whether it's ethical is up for you to decide, but this is an open and permission-less system which not only creates these adversarial environments, but also leads to innovation.
If you really wanted to, there are 1000s of resources online and you can participate it MEV right now - everything is open source. Try asking a hedge fund to let you in on their front running secrets :)

Idk about you but, web3 is the most exciting space in the world.
Whether you find anything ethical or not is your opinion, but I can't think of any other industry where so many big brains are playing in an open field for anyone to spectate or join.

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with 0xBeans.eth

0xBeans.eth Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @0x_Beans

Mar 21
Here's the awaited follow up :)

I'll clarify some questions that people have asked and also go over some easy ways to prevent getting sandwiched.
How does the bot sell their coins at a higher price if the buyer already bought coins?

On DEX's, there is no buyer/seller. You're swapping tokens directly from a liquidity pool based on *math* that makes this profitable (I wont go over how DEX's work, lots of resources online).
Is this the same as front running?

Yes and no. Sandwich attacks are also known as frontrun/backruns (cause you submit 2 txns, 1 ahead and 1 behind the sandwiched txn).

However, there are other front-run attacks.

All sandwiches are frontruns, not all frontruns are sandwiches.
Read 23 tweets
Mar 19
The viral txn of an MEV bot "selling 2.4 $APE for 946 ETH"

A few people asked me how this happened. In short, it didnt happen.

Seems like a lot of people that got hooked on NFTs weren't around during DeFi Summer in 2020 and arent familiar with MEV bots. Let me try to explain :)
This txn is only 1 of 3 that are relevant. The bot didn't make $2.7M (and no trader paid $2.7M).

This is known as a sandwich attack. A lot of smart ppl have explained this, but Ill go over how this works with a real example (Im assuming you know how eth works on a high level).
Every time you send a txn to eth, it doesn't get mined immediately and inserted into the blockchain. Your txn actually gets sent to a pool with other txns - this is known as the mem pool.

Your txn sits idle until a miner decides to pick up your txn and mine it.
Read 19 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(