Wednesday, February 21, 2024

Academic CLOB Model

Last week, I commented on the University of Chicago professor Eric Budish et al.'s hedge fund sniping model but neglected a more significant point. To recap, Budish modeled a scenario likened to a Centralized Limit Order Book (CLOB), where liquidity providers (LPs) post bids and asks, and takers then take those orders (link). Assuming several high-frequency traders (HFTs) are posting the bids and asks, for any resting lone bid or ask, a stale quote will generate a race between the lone HFT LP and several HFTs acting as takers. If the race winner is random, the odds are the LP posting the order will lose. This is the latency race deadweight loss. He estimates this symmetric information adverse selection adds 0.4 basis points (0.004%) to the bid-ask spread. When you apply that number to all the stocks traded worldwide, you get $40B. We would save the world $40B if we switched to sequential auctions. In his words, "continuous markets don't 'work' in continuous time." 

The craziest thing about this argument is that he applies this to a novel market mechanism that lowered costs by over 90% after nearly a century of stasis. In the first chart, we see the spread was constant from 1900 to 1990 at around 60 basis points, making some think it was some fundamental equilibrium. The internet enabled an alternative way to trade stocks, the electronic trading revolution from firms like Island, BATS, Archipelago, Instinet, etc. The second chart shows that it fell still lower from 2001 through 2006. The second chart is in different units and breaks it up by size groupings, but the point is the decline continued and was permanent. The current spread is about 3 basis points. 60 to 3.

Jones Trading Costs 1900-2000

Jones, Hendershott and Menkveld (2008)

In that context, advocating a wholesale change in market structure to eliminate a remaining 0.4 basis point of that spread is a classic example of letting perfection be the enemy of the good. This sort of economic ingratitude is standard, as no matter how much GDP grows, someone can point out something wrong and suggest we replace capitalism with a centrally planned economy, one that, unlike any of the past centrally planned economies, will work better than decentralized economies.

In spite of economics as seeming laissez-faire, most economists have been progressives (e.g., founder of the AEA Robert T. Ely, JM Keynes), viewing competitive behavior as wasteful, a criticism shared by industry leaders who appreciate it as a powerful cartelization device. The essence of free markets is private property and liberty. If people can make unfettered decisions about themselves and their property, it promotes prosperity. There is no trade-off between freedom and prosperity; they go hand in hand. Alas, most people, especially academics, don't trust decentralized results. Since Plato's Republic, they have always thought they could design a better world if given the mandate. Hubris and pride were prominent human vices in the Classical and Biblical canon because of their perennial, pervasive, and pernicious nature. It's a constant battle.

Back to Budish's model, he looks at some data circa 2015 on the London Stock Exchange, back when they timestamped in microseconds (now nano) and focuses on trades where several HFTs were taking or canceling a particular offer (e.g., bid for 100 @ 99.32) within 500 microseconds of each other. He figures the takes that got there before the LP canceled were unfairly robbing the poor HFT LP, which happened 90% of the time. Indeed, cancel orders were not recorded most of the time in these races, but if several HFTs tried to take simultaneously, he figured the LP probably wanted to.

This inference is silly for several reasons. First, It depends on who is trading and why. This was highlighted by Holmstrom and Myerson (1981): planners do not know everything in an economy with incomplete information, something economists often forget when looking down at their models like God. Many sniped orders were from retail traders who thought they would post a buy order one tick above the best buy instead of crossing the spread. They get up and go to the kitchen, and when they come back, they are filled, though the market has moved much lower. If the retail trader instead sent a market order and bought at a higher price, they would have a bigger loss. This is not a deadweight loss.

Another type of trader is the HFT, who merely wants to change their inventory, including rectifying a short position (moving from -100 to -90). In that case, they would be willing to cross the spread or post an aggressive limit order; they are not trading for arbitrage, where one tries to buy below the mid, etc. When one posts an aggressive resting limit order above the current best bid, one knows that they are not guaranteed a fill with the price not moving, as otherwise, no one would cross the spread. Marking such resting limit order trades to the mid-price will make it look like a loss to the LP, but it should be marked relative to the alternative, which is crossing the spread.

Another significant problem in his model is that this is not so much an exogenous cost born by HFT LPs, just an intra-HFT transfer. Only a dozen firms dominate HFT, as is usual in elite competitions. Those playing the game are taking and posting resting limit orders probabilistically. Such an order may be taken by a retail rube immediately, sniped by an HFT, and sometimes, their bid will sit there, and the price will move, and then they will become the top of a large queue, the perfect place for a positive expected value order. If you only count those times they get picked off as a loss and consider that an exogenous expense to be eliminated, you are simplifying the game in a way that mischaracterizes it completely.

His batch auction alternative is efficient when one thinks about a one-period scenario where people have private valuations for an object. With repeated auctions for equities, we must incorporate the complexity of updating valuations based on other valuations, inventory situations, and time preferences. As the other players are doing the same thing, we must update the priors of other people's priors, ad infinitum. There is also the possibility of collusion, like playing poker with two players sharing information, which would radically alter one's interpretation of market orders. His simple model is an excellent way of illustrating a particular problem, but to presume this is sufficient justification for a policy suggestion, let alone a radical new regulatory mandate, is absurd. The state space quickly becomes beyond any closed-form solution.

He also says the market can't fix itself like it's stuck in the bad Nash equilibrium and mentions two examples. First, he objects to letting the broker get two cents for their trades from an HFT who processes the orders rather than an explicit two-cent fee charged to the retail trader. The broker gets two cents in either case, but the trader may feel like he is getting a better deal. Retail flow is considered uninformed, as it will always have high latency, so HFT LPs can assume it is not filled with adverse selection and charge a lower spread, creating positive gains from trade. Allowing the broker to swap an explicit fee for an implicit fee via the rebate given by HFTs is an efficient way to capture this. His example of an HFT problem is the sort of fix markets make.

Budish also mentions co-location as a cost of HFTs because many millions are spent by HFTs wishing to be the fastest. This is perverse because providing privileged but open access, where everyone is treated the same, down to a couple of nanoseconds, is undoubtedly more efficient than distributing this privilege off the books. The latency advantage will exist in any modestly continuous market, so the question is how to administer this. Backroom deals encourage corruption and are cancerous. What Budish presents as a problem and something markets cannot fix is actually an efficient market solution. He has it backward.

During the 90 years of bid-ask stasis, the country was transformed by the telephone, radio, and TV, which radically altered the speed of information flow across the country. Yet it was only with the internet that outsiders could create an alternative to the closed, heavily regulated specialist equity trading system. Consider the NYSE's alternative, Nasdaq, was found to collude, quoting highly liquid stocks in ¼, ½, etc., but rarely, 1/8, 3/8, etc., artificially increasing the bid-ask spread. There were more Nasdaq dealers competing for quotes than on the NYSE, but the NYSE was a more efficient mechanism. Those just counting the number of players, as many naively do (Herfindahl index, Nakamoto number), would have never guessed that. Such are the game theoretic equilibria in complicated real-world games.

Instead, Budish emphasizes state coercion, ignoring the precedent of a 90-year regulatory-enforced inefficient market. In his paper, Will the Market Fix the Market, he favorably quotes a top regulator for writing, "Without changing [the] incentives, we cannot and should not expect the market to fix the market." This na├»ve and hubristic view is natural because big institutions are not going to fly him around to tell them that markets are doing well, though there's an edge case where you get adverse selection without asymmetric information. He created a model that theoretically proved a new inefficiency exists, and he also empirically proved billions of dollars in waste. 

Luckily, this policy does not look like it is gaining ground, as Taiwan recently moved away from a batched auction market to a standard CLOB. A simple solution, liberty, implies its best if we generally ignore economists when they come up with specific policies.

Monday, February 19, 2024

Hyperliquid's CLOB

 The latest horrid DEX simulacrum is Hyperlink, a perp CLOB emphasizing shit coins. It runs on its own dapp-specific L1 using a version of Tendermint, the favorite consensus mechanism for those prioritizing speed. 

I listened to a Flirting with Models podcast with founder Jeff Yan, where he spoke with Corey Hoffstein, a quantitative long-term equity portfolio manager. Hoffstein's background and demeanor prevented him from calling out Yan's BS, which is fine because most good podcast hosts are credulous and agreeable; otherwise, no one would go on their shows. Yan spouts many typical crypto/market maker cliches among those trying to impress people who are vaguely familiar with the issues. For example, when talking about his earlier trading experience, he said he 'was surprised how inefficient markets were.' This is a great phrase because it implies one was outsmarting people, an alpha generator, and it does exist, so it is possible.

Yet, one should provide several good examples to demonstrate you are more than just bloviating. In crypto, there was the famous Kimchi premium, where coins traded at 10% in Asian countries. This inefficiency persisted because it required trusted partners in the US and Japan or Korea to make the trade, which is non-trivial. In any case, it was over by early 2018 and required connections instead of savvy. Nonetheless, many Sam Bankman-Fried interviewers were blown away by SBF's singular arbitrage example, presumably one of his many clever trades. Looking back at Alameda's tax returns and the fact that most FTX traders left FTX throughout 2018 (no bonus pool), this was likely his only profitable trade outside of buying coins in the 2021 bubble with customer funds (see here for more). Thus, we have FTX exec Sam Trabucco bragging about their other genius trade idea, buying Doge when Elon Musk tweeted about it. The Kimchi premium was the only inefficiency Yan mentioned on the podcast.

When Yan was asked about the difference between maker and taker high-frequency strategies, Yan stated that a taker strategy might make only one trade a day. An HFT taker strategy involves sniping the top of the book before an LP can cancel. By definition, it can't do this to a large volume, as the top of the book is not big. The edge is the spread at best. That's a large amount of risk and capital, adding up to a couple of bucks per day. He described a strategy that has never existed because it makes no sense: a once-a-day HFT taker strategy.

Yan highlighted that Hyperlink's L1 can do things that would otherwise be impossible and emphasized updating a perp account for hourly funding payments. This is pointless. Given the horizon of perp traders—days, weeks—crediting their accounts hourly instead of waiting until the position is closed is pointless. A 50% funding rate is a 1% potential boost for a week-long position, which would be long for perps. No rational trader will be excited by having that trivial amount accelerated into hourly payments. Again, this highlights Yan's cluelessness.

Yan says he then decided to build an exchange on his own L1 because of the Impermanent Loss problem in AMMs. I agree that Uniswap's AMMs are unsustainable because they lose more money to this expense, but CLOBs on blockchains are not the solution. A fast L1 will still be slow because the CEXs are centralized, and co-located servers can respond to exchange messages within 5 microseconds. A centralized L1 is pointless, like a private permissioned blockchain. With decentralization, you have geographic diversity among validators, which takes you to 100 milliseconds if you restrict yourself to one hemisphere. It will always be a price follower for coins listed on CEXs, so its market makers will be scalped just like they are on AMMs. However, their select market makers will make money, but not for the reasons they state. [As for the unlisted coins, there is no need for speed, as they are less correlated with the big two that move secondary crypto coins around (ETH and BTC). The only people who should be market making shit coins are their insiders]

The main problem with a dapp-specific L1 is that the chain validators and the protocol are equal partners, as the gas and trade fees all support that one dapp. The incentives of the DEX and L1 insiders are perfectly aligned, so insider collusion is the default assumption. They probably give insiders a latency advantage by giving them effective co-location, and prioritization in sequencing transactions within a block. However, as officially a decentralized L1, this would be unacknowledged.  As LP cancellations are explicitly prioritized over trades, the Hyperlink insiders can make consistent money-making markets, unlike in Uniswap. 

Hyperlink conspicuously claims to be decentralized. Yet they currently have centralized control over their L1 validators, bridge, their oracle, and whoever is running their primary market-making strategy (currently working pro bono because that's what trustless anonymous crypto insiders do!). They restrict IP access to avoid US regulators, which would not be possible on a genuinely decentralized dapp. While Binance and Bitmex almost surely have insiders making their markets with privileged access, they at least have the decency not to pretend these are decentralized exchanges.

Its disingenuous design encourages the worst in crypto, which is saying something. For example, it wasn't until SBF created his unregulated offshore exchange FTX that things took off for SBF. He claimed to be trading $300MM/day when he approached VCs for funding in July 2019, though you won't find more than a handful of mentions about their exchange on Reddit or other forums where people talk about their crypto activities. FTX released a White Paper on how many crypto exchanges were faking volume to boost interest, which is a great way to learn about these tactics—and what not to do—and disarm people who might accuse you of faking your trading metrics. As we now know, SBF and his team were like Alex Mashinsky, liars who emphasized their unique integrity and decentralization, making them safer and morally superior to his competitors. We should not be surprised that SBF and Mashinsky moved on to stealing customer funds to gamble on shit coins because that's what liars do, like the scorpion on the frog; it's in their nature.

Their L1 does not have a native token, so it just takes USDC collateral from Arbitrum to bridge to their chain. Users thus have the hacking risk of the Arbitrum and Hyperlink bridge and worry about USDC censorship (if you get flagged, your USDC is effectively zeroed out). With just their trusted version of USDC, the famously fraudulent perp finance rate is the only mechanism that ties their perp prices to spot prices on off-chain assets. Yan mentioned this was discovered in trad-fi, indicating he probably heard stories about how Nobel Laureate Robert Shiller introduced a different version in 1991. He probably does not realize that the Bitmex perp/spot funding rate mechanism is nothing like Shiller's perpetual real-estate futures contract, which, in any case, never caught on in trad-fi because it was fatally flawed. Many perps work fine without the perp/spot funding rate ruse, highlighting its irrelevance. The perp funding rate mechanism is just an excuse to comfort traders to believe these perp prices are not mere Shelling points but are tied down by arbitrage (see here for more on that).

If you go to Hyperliquid's Discord or search them on YouTube, most of the content is focused on schemes to get free money via rewards, giving them tokens from their airdrop. Everyone is wash trading to collect points, as there are no fees or gas costs. There's also a referral program, and I'm sure many have gamed that, as it's easy to create seemingly unrelated accounts on the blockchain. Their fake trading is already twice that of Bitmex and ten times that of GMX ($1B/day—heh).

If you stick around for the airdrop, take your money and run. 

Tuesday, February 13, 2024

Budish's Plan to Replace CLOBs

I don't keep up with the latest economics journals because I've learned that very little of it is fruitful. Like many subjects, the basics are valuable, but the marginal returns are small with the exponential rise in academic output. We aren't in the golden age of economics if there ever was one.

Yet, I am still fond of economic models that illustrate a point clearly and succinctly, and I stumbled across a model that applies to an area where I have first-hand knowledge. I worked on high-frequency trading algorithms to execute our hedges for an electronic equity-options market maker. We were not at the bleeding edge of high-speed trading, so I am not privy to the tactics used by Renaissance, etc., but no one from those firms will talk about what they do anyway. If someone does talk about what they did, they are invariably a smokescreen.

Further, many high-frequency clients want stupid things, like different models for when the market is trending vs. staying in a range. This is a stupid idea because if one knew we were in a trading range, there would be better things to do than apply nuances to a VWAP algorithm. However, if customers want to pay for it, you might as well sell it, and the best snake-oil salesmen believe in their product. Thus, many great firms with access to the best of the best employ deluded people to create and sell such products, useful idiots. They often speak at conferences.

Experienced private sector people discussing bleeding-edge high-frequency traders (HFTs) are generally deluded or deceptive. This leaves a hole filled by people with no experience, like Michael Lewis. Thus, I am qualified as anyone who will talk about these matters, even if I am not and have never worked on a successful worm-hole arb-bot from New York to Tokyo. Indeed, one might say my experience in HFT was a failure, as we couldn't compete, and I was part of that. I haven't worked on that problem directly since 2013. However, like a second-stringer, I can better appreciate what doesn't work, which is easy to miss if you are making bank because you aren't constantly looking for ways to fix things.

Budish at a16z

Eric Budish is a professor at the University of Chicago and the coauthor of several papers on 'hedge fund sniping' on limit order books, most conspicuously Budish, Cramton, and Shim (2015), and Aquila, Budish, and O'Neill (2022). I do not want to dismiss his coauthors or put all the blame on Budish, but for simplicity, I will present this work as being Budish's singular work. This work has been popular, as it was mentioned in the press, sponsored by significant financial regulators like the FCA and BIS, and was the basis for talks last year at the NBER (here) and the crypto VC a16z (here).

His work highlights the best and worst parts of economics. He presents a model that highlights the assumptions required, the mechanism, and then tries to support it with data. That makes it subject to rational criticism, unlike most work in the social sciences. On the bad side, it follows in a tradition from Frederick Taylor, the original McKinsey/Harvard MBA, who wrote about Henry Ford's assembly line as if his analytical approach was relevant to a famous business method (assembly line) and generated insights into other areas. It doesn't. 

Budish's big insight is that a profound flaw in Centralized Limit Order Books (CLOBs) generates a deadweight loss. When HFTs compete on CLOBs, they often engage in speed races that inflict costs on LPs (aka, liquidity providers, market makers). What is new is that this form of adverse selection is not generated by asymmetric information but by the nature of the CLOB. If the top HFTs are within a Plank-length of each other as far as the exchange is concerned, the fastest is arbitrarily chosen. However, in high-frequency trading, the fastest wins, and the losers get nothing (a Glenn Gary-Glenn Ross tournament).

An HFT would only snipe the best bid or offer if it made them money, and for HFTs, this is a zero-sum game, so the poor liquidity provider suffers losses. While the LP can try to cancel, he is one, and those who are not him are more than one, so when thrown into the micro-second blender behind an exchanges gateway, the LP will lose the race to cancel before he gets sniped. In equilibrium, the LP passes that cost off to customers.

His solution is to replace the continuous limit order book with one with discrete auctions. This allows players to compete on price instead of time because, in each period, they will all be represented, not just the first one, and the snipers will compete away the profit that was generating a loss for the LP.

Primer on Adverse Selection

In standard models of LPs, there is the LP who sets bids and offers. He will buy your shares for 99 and sell them to you for 101, a two-sided market. Liquidity traders come along and buy at 101 and sell at 99. If we defined the spread as the difference between the bid and ask (101 – 99), the LP's spread is 2; his profit is spread/2, or the price relative to the mid. The LP's profit transacting with liquidity traders is the number of shares he trades times half the spread.

There are also informed traders with private information about the value of their assets in the future. This also goes by the phrase adverse selection because conditional upon trading, the LP loses money with informed traders. These LPs trades are selecting trades that are adverse to their bottom line.

But, the nice thing is that the informed traders discipline the LP, setting the price at its true market clearing price. Liquidity traders pay a fee to the LP via the spread for the convenience of instant transformation from cash into asset or vice versa. The LP has to balance the profits from the liquidity traders with the losses to the informed traders so that the benefits of liquidity traders offset the costs of adverse selection.

If we assume profits are zero, the greater the adverse selection, the greater the spread, but this is a real cost, so such is life. Information is costly to aggregate when dispersed unevenly across an economy. However, to the degree we can lower asymmetric information, we can lower the spread. In Budish's model, his toxic flow is not informed, just lucky, but the gist is that these traders are imparting adverse selection costs onto LPs just like informed traders in previous models.

Budish, Cramton, Shim model

I will simplify the BCS model to make it easier to read by removing notation and subtleties required in an academic journal but a distraction for my purposes. Hopefully, I will capture its essence without omitting any crucial subtleties. Let us define S as the spread, so S/2 is half the spread. This is the profit the LP makes off liquidity traders.[eg, if bid-ask is 99-101, the spread is 2 and S/2 is 1, so the profit per trade is 1].

 Let us define J as the absolute size of the price change that is revealed to the HFTs, a number larger than S/2. It can be positive or negative, but all that matters for the LP is its size relative to S/2, because the profit for the sniping HFT will be J – S/2 (eg, buys at p+S/2, now worth p+J, for a profit of J – S/2) and the LP loses (J - S/2). In the following trade, either J is revealed, a jump event, or it is not, and the liquidity trader trades. If the liquidity trader trades, the profit is S/2.

The next trade will come from a liquidity trader or a sniper. As the probability of the sum is 1, we can simplify this to being prob(jump) and 1-prob(jump). Assume there are N HFTs; one decides to be an LP, and the others decide to be snipers, picking off the LP who posts the resting limit orders if a jump event occurs. All of the HFTs are equally fast, so once their orders are sent to the exchange's firewall for processing, it is purely random which order gets slotted first. Thus, the sniper's expected profit each period is

That is, the probability of getting a signal, Pr(jump), times the profit, J – S/2, times the probability the sniper wins the lottery among his N peers.

For the LP, the main difference is that he only loses if the other HFTs snipe him. He tries to cancel, avoiding a loss and making zero. We can ignore that probability because it is multiplied by zero. But the probability he loses is (N-1)/N. This is the crucial point: The upside for snipers is small per sniper, as it is divided by 1/N, but it is large for the LP, multiplied by (N-1)/N. To this loss, we add the expected profit from the liquidity traders. The profitability of the LP is thus

The HFT chooses between being a sniper or an LP, where only one can be an LP. In equilibrium, the profitability of both roles must be equivalent.


Solving for S, we get

The profit should be zero in the standard case with perfect competition and symmetric information. The spread is positive even with symmetric information because the lottery is rigged against the LP. It seems we could devise a way to eliminate it, as it seems inefficient to have liquidity traders pay a spread when no one here is providing private or costly information. The 'hedge fund sniping' effect comes from the race conditions, in that any poor LP is exposed to losses in a jump event, as there are more snipers (N-1) than LPs (1).

When you add the costs of speed technology, such as the Chicago-New York fiber optic tunnel, these HFTs must recover this cost, which adds another nice result in that speed costs increase the spread. Now, we have the profitability of the sniper after investing in technology. Here, we will set the profitability of the sniping HFTs to zero.

This implies

Now we take the equilibrium condition that the profitability of the sniper equals the profitability of the LP

And while the c cancels out, we can replace Pr(jump)*(J – S/2) with C*N to get

In this case, the N is endogenous and would depend on the function c, so the spread is not exactly a linear function in c. Given the various flaws in this model discussed below, elaborating this result is not interesting. The main point is that S is positively related to C, which is intuitive. Again, even in the absence of asymmetric information, we have a large spread that seems arbitrary, which seems like an inefficiency economists can solve.


Budish presents two sets of data to support his model. In 2014, he noted the occasional crossing of the SP500 futures (ES) in Chicago with the SPY index traded in New York. This arbitrage is famous because there have been a few times when HFTs spent hundreds of millions of dollars creating straighter lines between Chicago and New York, getting the latency down from 16 to 13 to 9, and currently, with microwaves, we are at five milliseconds. I don't think it's possible to get it down further, but weather can affect microwaves, so perhaps there is still money to be spent. In any case, it's a conspicuous expenditure that seems absurd to many.

There's a slight difference in the futures and the SPY ETF, but this is stable and effectively a constant over the day. The bottom line is that the correlation is effectively perfect over frequencies greater than a day. Over shorter durations, however, the correlations have been rising, and the correlation at one nanosecond has and will always be zero because the speed of light sets a lower bound on how quickly information can travel between Chicago and New York of 4ms. One can imagine various reasons why the markets could become disentangled briefly. Thus, when we look at prices over 250-millisecond intervals, there were periods, almost always less than 50 milliseconds, where it was possible to buy futures and sell the ETF for an instant profit. This did not happen frequently, but it generated arbitrage profits when it did.

ES vs. SPY over 250 ms
ES vs. SPY over 250 ms

Buddish assumes traders can buy and sell the other whenever these markets cross for more than 4 milliseconds. In his 2015 paper, his data sample of 2005-2011 generated an average of 800 opportunities per day for an average profit of $79k per day.

In 2020, he presented data on the London Stock Exchange stocks and used it to estimate latency races cost investors $5B a year worldwide. It made quite a splash and was picked up by many prominent media outlets such as the Financial Times, Wall Street Journal, and CNBC. Unlike the ES-SPY data, this one does not involve strict arbitrage but statistical arbitrage. Using message data from 40 days from the LSE in the fall of 2015, they can see trades and cancellations and those transactions that were not executed because they were late. This gets at the cost of latency. Budish highlights that he can isolate orders sent at approximately the same time, where one order was executed merely due to chance, and all the others miss out. More importantly, the limit orders are sniped by the faster trades (which can be limit or IOC, immediate or cancel, orders that take liquidity), which is the essence of the BCS model.

He isolated clusters of orders within 500 microseconds, or 0.5 milliseconds, that targeted the same passive liquidity (quantity & price). Most data involved 3 trades, but only 10% included a cancel. As a failed take order implies no more quantity at this price, these were all relevant to taking out a small queue. For example, here's a hypothetical case where there is a small limit to buy at 99 and a larger offer to sell at 103, for a midprice of 101.


Note that if the sniper takes out the limit order to buy at 99, he sells below the midprice before and after the trade. As the sniper is selling here, they define 'price impact' as how much the mid moves after the trade in the direction of the trade, here, +1 unit; he pushes the price down by 1. The 'race profit' compares the trade price to the after-trade mid; in this case, it is -1 unit because the selling price of 99 is one unit below the new midprice of 100; his profit is -1.

A case where the sniper would profit could look like the figure below. Here, the sell moves the mid down by 2 in the direction of the trade for a price impact of +2. The race profit here is positive, as the sniper sold for 101, which is +1 over the new midprice.


 By definition, the price impact will be positive because it takes out the best bid or offer. If the best bid or offer remained, the sniper would not win the race, as there would be no loser.

Applied to their set of 40 days on liquid LSE stocks, they estimate these latency races are involved in 20% of all LSE volume. So, while they only last 79 microseconds, they apply to 1000 trades per ticker daily. They estimate an average race profit of 0.5 basis points on a set of stocks where the average spread is 3.0 basis points. Applying that to all stocks traded generates $5B.


I sense that no one criticizes this work much because it's a parochial problem involving data that requires money and a lot of time. As even economists specialize, and many do not examine CLOBs, they ignore the Murray Gell-Mann amnesia effect, so Michael Lewis's Flash Boys informs even academic economic opinion on this issue, as evidenced by Budish's frequent mention. The SBF debacle highlighted Lewis doesn't have the discernment to realize when he is dealing with complete frauds whose primary business was making markets, which should hopefully warn economists not to take Flash Boys seriously when trying to understand modern markets.

Either/Or vs. Both/And

My first issue is where the HFTs sort themselves into two roles: ex-ante, one chooses to be the liquidity provider, the others as stale-quote snipers. Most HFTs run a combo strategy of sniping and LPing. If we look at the scenario he outlines as sniping at the LSE, we can see that they are sniping aggressive quotes. An aggressive quote is essential for getting to the top of a queue and making money as an LP.

Generally, a resting order at the top of the queue has a positive value, while one at the bottom does not. Investing in speed infrastructure is the only way to get to the top of the queue. Consider the LOB below. Here, the top of the bid queue is in yellow at a price of 98. That queue position has a positive value. At the end of the queue, the position in dark blue generally has a negative value. While there are various scenarios where it pays to stay at the end, the bottom line is that you generally want to get to yellow, but to do so implies one first takes a stab at a new, aggressive level. The yellow ask at the price of 102 is how that happens.


As noted in their paper on the LSE, the top 3 firms win about 55% of races and lose about 66% of races. The figures for the top 6 firms combined are 82% and 87%.  Thus, getting to the top of a queue with several LPs is an important and probabilistic game. Budish did not look at those races. It seems they would most likely be competing for queues and, if they lose, sniping those queues. Both rely on a sizeable specialized investment.

Only a handful of firms are playing this game on the LSE in Budish's data, and they are playing with each other. To the extent the stale quotes are from other HFTs, they are playing a zero-sum game among themselves. However, likely, these stale quotes are usually from non-HFTs, such as retail traders with their E-Trade platforms. That most stale quotes are not in the HFT club is consistent with the fact that only 10% of Budish's data included cancel orders.

Even if we assume the sniping only affects fellow HFTs, the latency tax disappears when we think of them probabilistically sniping or posting resting limit orders. Assume each of N HFT traders has a 1/N chance of sniping the newest bid-ask level, which is necessary for getting to the top of the next queue, the cost of sniping cancels out. That is, there are two symmetric probabilities applied here, one to becoming the lead on a new tick, the other reacting to the jump event. The resulting equilibrium equation (without c) is just


So, when providing liquidity, the probability of getting sniped is (N-1)/N, but now this is multiplied by the probability of being on the new aggressive bid, 1/N; the probability of winning the snipe is 1/N, which is now multiplied by the probability of being a sniper, (N-1)/N. This cancels out the cost from the latency race, so it need not be passed off to liquidity traders via a spread. S=0. 

BCS states that it does not matter whether one always chooses to be the liquidity provider or they chooses so stochastically. I suspect they think it does not matter because the expected profit of posting liquidity and sniping is equal in equilibrium. However, that assumes the HFTs make a fresh decision as if they were certain to become the top of the next queue. In practice, they will have to try to be the lead LP on a queue, and their success will be stochastic, so they evaluate the LP and sniping role as a package deal and apply probabilities to both roles instead of in isolation.

Misspecified Objective Function

Another issue is that sniped quotes are assumed to be losses by marking them relative to a future mid-price. This would be true for a pure LP/sniper; however, many HFTs can provide complementary services like implementing VWAP trading algos for large buy-side clients. A VWAP strategy does not simply cross the spread or jump on the best bid-offer, but employs both tactics when they find either attractive. It can include posting aggressive bids that are immediately taken or taking new aggressive bids as an alternative to merely crossing the spread. A resting order subject to HFT sniping leans on HFT liquidity; these other HFTs assist the LP in efficiently implementing their VWAP strategy.

An HFT is in a good position to sell $X of Apple stock at tomorrow's VWAP plus a fee that covers the expected trading fees, price impact, and spread. They profit if they can implement that strategy at a lower cost. Thus, a subset of an HFT's orders may target minimizing trading costs instead of making a profit. How much of an HFT's limit order trading involves this complementary tactic? Who knows, but the fact that Budish has offered no estimate or even mentioned it is a significantly omitted variable.

Sequential 100 ms Auctions are Complicated

As for the alternative, frequent batch auctions held every 100 ms, this is a solution only an academic could love. The current system works very well, as evidenced by the dramatic reduction in spreads and fees since electronic market making arose (no thanks to academics, except Christie and Schultz).

The novel gaming strategies created by this mechanism are not well specified. The model does not even consider the standard case where trades happen on large queues, which is most of the time. One could easily imagine an endgame like the California Electricity market debacle circa 2000-2001, where a poorly implemented auction market was gamed, revealed, and then everyone blamed 'the market.'

Could LPs keep tight markets across instruments and market centers if matching were queued and pulsed like a lighthouse?  All exchanges would have to become frequent batch auctions and have the auctions synchronized within 1 ms for the discrete-time auction model to work. The Solana blockchain, which tries to synchronize at a 100-fold higher latency, goes down frequently. On the world equity market, such failures would generate chaos.

The Randomizer Alternative

In BCS, they briefly address the alternative mechanism, adding randomized delay. They note it does not affect the race to the top. However, it affects the amount they should be willing to pay for speed. For example, if new orders added a delay of 0 to 100 ms, the benefits of shaving 3 ms off the route from Chicago to New York would be negligible, as it would increase one's chance of winning a latency race by a mere 1% as opposed to 100%, reducing the benefit 100-fold. In their own model, eliminating these investments directly lowers the spread. If one had to change CLOBs to reduce the allure of wasteful investments in speed, this would be a much simpler and safer approach.

Talk about Stale Data

The data driving his extrapolated costs are from 2005-2011 for the ES-SPY data and 2015 for the LSE. Strangely, his recent 2023 presentations at a16z and the NBER did not update the data. Remember your cell phone capabilities circa 2005-11? Currently, the major exchanges all generate multiple hardware timestamps and correctly sequence incoming orders within 5 nanoseconds. If he is confident that his mechanism can save the world $5B a year, getting data from the 2020s would seem obvious. While technology has improved significantly, so have the tactics. No one in this field thinks a strategy backtested on message data from before 2022 is relevant. This is clearly an academic idea.

Co-located Level 2 Tactics != Regional Arbitrage

The microsecond speed race in their LSE data differs significantly from the ES-SPY arbitrage game. Co-located servers involve a trivial expense and are a massive improvement in efficiency. With co-location, you can have hundreds of investors at precisely the same distance with a leveled plain field. Without co-location, the competition for closest access will be discrete and more subject to corruption; the playing field will not be leveled, their costs will be higher, and they will have to maintain their own little data center. The costs and tactics for co-location vs regional arbitrage are incomparable, and we should not encourage regulators to treat them the same way.


As mentioned, the nice thing about this proposal is that it is clear enough to highlight its flaws. Those who just want to add a stamp tax to fund all of college (or health care, etc.) don't even try to justify it with a model; they just know its costs would tax people in ways that most voters would not feel directly. Nonetheless, like cash-for-clunkers, this is not an economic policy that will do any good.

Thursday, February 08, 2024

Uniswap V2 Made Money. What Happened?

 I was surprised to see a tweet by @AnthonyLeeZhang that referenced a short paper showing liquidity providers (LPs) making money on Uniswap's ETH-USDC pool, as I have noted that Uniswap LPs have been losing money consistently since they began. I initially thought there was a mistake, but found his metric of PNL is ultimately identical to mine. 

Specifically, he used Milionis, Moallemi, Roughgarden, and Zhang's pnl formulation, which they call Hedged LP PnL. This is the LP profit after accounting for impermanent loss (aka, loss vs. rebalancing, LvR, convexity costs).

HedgedLpPnL = fees - LvR = Vt - V(t-1) - mints + burns + hedgePnL

Here, V(t) is the value of the pool's reserves.  If we use the ETH-USDC pool, where p(t) is the ETH price is USDC, we get

V(t) = USDC(t) + ETH(t)*p(t)

V(t-1) = USDC(t-1) + ETH(t-1)*p(t-1)

The difference in the value of reserves is affected by the price change and the changes in USDC and ETH that come from mints (LP deposits), burns (LP withdrawals), trades, and fees. The ETH and USDC coming into the pool contain both fees and the tokens traders sell (swap into the pool), so this implies

USDC(t)=USDC(t-1) + mints(t, t-1) - burn(t, t-1) + NetUsdcIn(t, t-1)

ETH(t) = ETH(t-1) + mints(t, t-1) + burns(t, t-1) + NetEthIn(t, t-1)

[note: (t, t-1) is the flow in the period from t-1 to t]. This reduces to just valuing the pool's net USDC and ETH reflected in trader swap event logs, valued at the end of the period. There is a slight difference created by ignoring the prices when mints and burns happen, but both approaches make assumptions that make these PnL calculations approximations, and the differences are insignificant. I prefer this formulation because it requires less data.

Hedged LPpnl = NetUsdcIn(t, t-1) + NetEthIn(t, t-1)*p(t)

While one can use periods of arbitrary duration, in the limit, it does not matter, and as a practical matter, pulling this by calendar day works well for seeing trends, as well as avoiding trading costs if one were to actually hedge their LP pool position.  

More importantly, this introduced me to the fact that Uniswap's v2, the old capital-inefficient automated market maker (AMM), makes money for its LPs. I figured it was obviously worse in every way, which is why its flagship ETH-USDC 30bp fee (basis points, 0.3%) pool has about 2% of the volume of the ETH-USDC 5bp v3 pool, which is about half of the unpopular 30bp v3 pool. 

ETH-USDC pools

Uniswap's v2 started in May 2020, and volume peaked when Uniswap's upgraded v3 pools started in May 2021.  Not only did their v2 LPs make money in the past, but they have continued to make LP profits to this day. In its first year, 2020, Uniswap's v2 pool was making $100k+ per day for the pool, which annualized to a sweet 30%+ annual return on total value locked in the pool (after accounting for impermanent loss/LvR/convexity costs). 

Uniswap v2 ETH-USDC pool

Currently, there is about $100MM worth of tokens in the ETH-USDC v2 pool, and it generates a modest, but still positive, 3% APY all-in. On a PnL/USD traded basis, it has been more impressive, showing stable profitability (see below). In contrast, the v3 pools have lost money from inception. While v3 LPs make money twice as many days as they lose money, the problem with selling gamma (having a negative convexity) is that the losses are relatively large when they happen. Unfortunately, this leads many scammers and fools to think that they only need to time or size their bets better.

ETH-USDC pools

This is quite an interesting equilibrium.  The 30bp-fee v3 pool corresponds to the 30bp-fee v2 pool, yet the v3 LPs lose money while the v2 LPs make money.  The problem is that the v3 pools have too much liquidity relative to the total amounts traded. If the pool is near the 'true' price as reflected on Binance, etc., standard fluctuations imply a certain amount of trading. Specifically, over short frequencies, the percent change in price relates to an amount traded relative to the liquidity. Remember that in an AMM liquidity is defined as

liquidity = sqrt(USDCinPool * ETHinPool)

Applying AMM math, we get

return% = 2 * DUSDC/(liquidity * sqrt(p))

If we take daily volatility to be 5%, the standard deviation every five minutes is 0.3%. If arbitrageurs pushed the price by an average of 0.3% every five minutes, that's a total of 85% that needs to be effected. This implies the amount traded for arbitrage or price setting is a linear function of liquidity.

DUSDC(from arbs) = 0.85 * liquidity * sqrt(p) / 2

If LPs need a certain ratio of liquidity traders relative to arbitrage traders, then if the ratio of (USDC traded / liquidity) is lower for a pool with the same fee, it will make less money, if not lose money. The 5bp pool needs at least 6 times more USDC traded per unit of liquidity. 

We see that for the v3 5 bp pool, volume/liquidity has been 2.5 times higher than in the v2 pool, far lower than the 6 times it needs. In the v3 30bp pool, the ratio is about 50% of the v2 pool. The flagship AMM for the flagship dapp on the flagship blockchain has been and continues to be a loser. This is an existential problem for AMMs because large users are constrained to centralized exchanges without a sustainable, liquid AMM. These centralized exchanges are necessary but cannot be essential for large trades if crypto is to avoid outside attacks by the institutions that control the major fiat currencies.

ETH-USDC pools

I can only speculate as to why v3 fails so spectacularly relative to the v2 AMM. I suspect the cause is based on LPs not appreciating LP convexity cost. If you scroll through Reddit's Uniswap thread, you will see occasional posts inquiring about how to measure or hedge the LP's negative convexity, and banter is similar to when college freshmen discuss macroeconomic issues: strong, ignorant opinions. Most do not even realize the convexity cost. Those who do acknowledge it think it can be overcome by judicious timing, lower latency, or rewards programs that solve the chicken-and-egg problem. Others think the solution is to buy volatility as a hedge, which in the context of the blockchain is not only capital inefficient (you can't get cross-collateralization), but if you are selling volatility below actual volatility as with these v3 LPs, hedging it on centralized exchanges will just lock in your losses. 

With the v2 pool, there is one common cost for the LPs they all can intuit: capital. Every LP is treated pro-rata based on their stake in the AMM's pool. In contrast, many v3 LPs think that they get ahead of their fellow LPs by concentrating their liquidity in a narrow band or adjusting their ranges based on current volatility. The effect of extra liquidity never occurs to them. The end result is a persistent excess of liquidity that does not just dilute profits; it turns them into losses. The greater the liquidity, the greater the convexity cost, which, unlike merely adding shares to a stock, affects the sign of net income. 

Many have written about how adding money to a v3 pool is obviously a better strategy than LPing for a v2 pool because by restricting a range to a generous 20% up and down, they could deploy the same amount of liquidity with only 8% of the capital they would need for a v2 pool. They never considered the consequences if everyone else came to the same conclusion, leading to an excess of liquidity that is linearly related to the pool's convexity cost. As most people do not understand, let alone measure, convexity costs, they blithely deposit capital into these pools, ignorant of the equilibrium effect on costs that affect their bottom line.

This unfortunate situation could persist in that my spam folder is filled with the same scams that were a cliche in the 1990s. Yet, while the weiner enlargement pill industry is persistent, it isn't growing. For a contract on the blockchain to work, it has to go beyond gimmicks like token rewards (which just dilute LP fees) or leverage via using collateral tokens as collateral ad infinitum. Unfortunately, the investors that generated massive profits in 2021 and avoided prosecution or bankruptcy--probably out of pure luck--are the primary VCs directing our current development. They have a lot of money they do not want to report and nothing else to do with it. They know the shibboleths but do not understand gamma in particular or mechanism design in general.