flashfish Profile picture
Apr 19 16 tweets 4 min read
Before my current life I was deep into MEV (back before it was called MEV). I feel it was long enough ago that the omertà has expired.

So here is the first of some threads on ancient alpha. MEV from > a year ago.

First up - Compound liquidations
On Compound if you take one step over the line you can be liquidated for 50% of your entire collateral at a 5% discount.

For example. If you have $200k collateral you can be liquidated for $100k at the price of $95k.  $5k profit minus costs to the liquidator
The transaction is fairly simple and can be done with only gas costs. Flashloan the debt token, liquidate the target and swap their collateral to pay off the flashloan.

Your account can be liquidated when the oracle says you have too much debt to be covered by your collateral.
Prior to August 2020, Compound's oracle was centralised and updated by a privileged tx. As a liquidator we would monitor the pending transaction mempool looking for the oracle update.

When we see it we would liquidate any account which was profitable.
Now onto the fun stuff. Only the first person to liquidate after the oracle update wins.

At the time miners would sort same price txs randomly. If you sent a liquidation at the same gas price as the oracle update there was a 50% chance of being placed after the update
Now we're into a maths problem with some game theory.

Each liquidator would spam txs at the same gas price as the oracle update. Hoping to win the liquidation without spending too much on failed txs.
Below is a screenshot showing some of this spam. Two liquidators are competing, spamming cheap-to-fail txs with green winning the prize.

So how much do you choose to spam?

Well we know the revenue from the liquidation, but not the odds of winning as that depends on others' spam
The block isn't finalised until it is mined. So every moment that the block is not mined, more spam enters the mempool. Changing the odds of the spam already there.

You cannot cancel. Once you commit your spam the cost is sunk.
It is in everyone's interest to collaborate - the less spam the less of the revenue goes to miners - but how?

It was a constant game. Our algo would monitor the mempool deciding what to do as spam came in.

Then after it was over we'd analyse and adjust our tactic for next time
On August 11th 2020 Geth released v1.9.19. Changing the game. Same priced txs would now be ordered by arrival times.

Meaning that if the block was mined by a 1.9.19 geth miner the first tx to arrive after the oracle update would win
This makes the game theory even more complicated. Suddenly geolocation and speed of getting txs out becomes much more important. While also playing the old game.

10 days later 80% of miners were running geth with 20% of them on 1.9.19.
On August 17th everything changed again. Compound moved to a more decentralised oracle system. Initially relying on an offchain Coinbase oracle.

This was the end of spam. Instead you monitor coinbase and combine the on-chain oracle price update with your liquidations transaction
The change meant that instead of sending lots of transactions. You would send one tx. Then monitor the mempool to see if anyone tried to liquidate with a higher gas price than you, and if they do you outbid them.
I call this gas racing and it formed the foundation of a lot of MEV competition before private mempools.

You each consistently outbid each other until someone bails (replaces their liquidation tx with a cheap transaction) or the block gets mined and a winner is declared.
To be competitive you need the simplest and cheapest liquidation transaction possible. No flash loans. No swaps.

The goal was be able to race to a higher price than others while squeezing out some profit.
It wasn't long after this that I stopped competing for liquidations on Compound. There were greener pastures elsewhere and the competition plus capital requirements were too high.

• • •

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

Keep Current with flashfish

flashfish 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 @flashfish0x

Nov 15, 2021
Strategies and Yearn, a thread.

Yearn has $4b in their v2 vaults and anyone can code a strategy and earn 10% of the profits. There is no interview process. Just create the strategy and follow these steps.

So how do you actually get a strategy to prod and scaled to > $100m?
1 - Find a big farm

Finding farms that can safely take >100m is hard.

Yield normally comes from gov token farming and when we add our funds we dilute the distribution.

So if APR is 100% and there is 10m in there already, by adding another 90m we crush the yield to 10% APR
That yield is based on the current spot price of the gov token. If we take too large a share of the distribution we can crash the price crushing our yield further.

And most yield farming is now more complicated than just locking USDC for a gov token.
Read 19 tweets
Nov 2, 2021
Here's the theory behind the Cream attack, a thread:

You need a token that can be borrowed, used as collateral and have its value increased in the same transaction.

Uni Lps, xSushi, yVault tokens. Any will do
Then you flash loan a shit ton of money and lend it out on your target protocol. Borrow all the exploitable tokens available and send them to your second wallet.

Lend them back to the protocol.

Then borrow again on wallet 1 and repeat.

And keep repeating
Ratchet up to way higher than the market cap of the vulnerable token.

Here is what your position might look like. You have $500m collateral for only $200m borrowing power. Safe you might think.

Unless we increase the value of vulnerable asset
Read 7 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!

:(