Liquidating a whale by hand, 22 times

Liquidating a whale by hand, 22 times
Financial leverage turns out to be simple division, and that’s enough to follow a DeFi meltdown where a whale’s debt got liquidated by hand, 22 times.

Patrick McKenzie (patio11) reads his 2022 Bits About Money essay demystifying financial leverage, starting from the balance sheet math that lets you work out in your head how big a drop in asset value wipes out a firm’s equity: add one to the leverage ratio and take the reciprocal. A firm levered ten to one is gone after a loss of about 9%. 

He walks through how brokerages manage customer leverage with margin calls, and why paying down the loan lowers your risk more than depositing the same amount in shares. He then tells the story of a whale’s account blowing up on the DeFi lending protocol Solend during the FTX collapse. Solend pushed the interest rate on SOL deposits to 2,600% and still couldn’t attract enough, and Patrick spent an evening in Tokyo liquidating the whale’s debt by hand, 22 times, through software that crashed about 70% of the time.

Postscripts cover Solend’s rebrand to Save, what 2x leverage on Google would have earned since the essay was written, and why today he would just have an AI agent write the liquidation bot.

Presenting Sponsor: Mercury
Complex Systems is presented by Mercury. Mercury Payroll puts payroll, benefits, and compliance right inside your Mercury account. An in-house team backed by AI registers you in new states, files and remits your payroll taxes, and handles the notices, so you don’t have to copy from PDFs to Excel to web portals. Setup takes minutes, and Mercury Payroll is free for eligible Mercury customers through the end of 2026 at mercury.com/payroll

Timestamps:

(00:00) Intro
(01:06) Basic balance sheet math
(02:20) Why leverage as a concept is useful
(03:55) Managing leverage of one’s customers
(07:40) Mismanaging customer leverage
(09:10) Decentralized finance innovations in leverage management
(09:48) Sponsor: Mercury
(12:13) Solend and the whale
(21:31) Closing thoughts
(22:03) Wrap

Transcript

Patrick: Welcome to Complex Systems, where we discuss the technical, organizational, and human factors underpinning why the world works the way it does.

Hideho, everyone. My name is Patrick McKenzie, better known as patio11 on the Internet. So I'm reading S-1s this week about IPOs that are in progress, and while we'll discuss that S-1 in more detail in the future, when I can have a guest on who is very comfortable narrating the mechanics, it puts me in the mind of complex financial transactions, which is one of my great joys in life.

[Patrick notes: Due to the vagaries of scheduling my episode with Zvi Mowshowitz about the Anthropic S-1 aired prior to this one.]

And so I thought I would read a classic essay, "Demystifying financial leverage," originally published in Bits about Money on November 11th, 2022.

One of the hardest concepts for non-specialists to wrap their heads around in finance is leverage. It is a bit arcane, requires some facility with math, sounds vaguely spooky, and routinely finds itself near a smoking crater asking, "Did I do that?"

Financial leverage is much easier to understand than many people believe it to be.

Basic balance sheet math

Every business has a balance sheet, which contrasts its assets (valuable things it owns) against liabilities (valuable things it owes to other people). The difference between assets and liabilities is equity.

Financial businesses will frequently have non-financial assets and liabilities. Ignore those for the sake of simplicity. Ignore the nice building, the computers, the payroll due on Friday for work which has already been completed. Focus on just the financial assets and liabilities, things like mortgages our bank owns (asset) and deposits from customers (liability).

Leverage is the ratio of your liabilities to your equity. Simple division, fourth-grade math. If you have $110 million in assets and $100 million in liabilities, you, by subtraction, have $10 million in equity against your $100 million in liabilities. You are said to be levered 10:1.

Note, as an aside: the great thing about conventions is that there are so many to choose from, and I don't want you to get tripped up if you read about this elsewhere. I'm using debt to equity, liabilities divided by equity. Many people, especially when discussing banks and funds, divide assets by equity instead.

These numbers tend to converge when the equity cushion is wafer-thin, which is generally the case in the most common place people read about 30x levered banks: immediately after the disaster.

Why leverage as a concept is useful

Finance is in the business of teleporting value over time and space. This is an enormously useful business to be in, but it requires taking various risks. Leverage provides a quick way to know how much risk a financial business is taking on.

This is easiest to understand in the banking example. Imagine the simplest possible toy version of a bank, which offers only two products: checking accounts and mortgages.

The bank's primary source of value as a business is maturity transformation. It teleports value over time to allow someone whose checking account currently has much less in it than the cost of a house to buy a house anyway and gain the benefit of living in it. It does this by putting a bit of the bank's capital at risk and levering that capital using the deposits in the checking accounts.

This bank is exposed to a variety of risks. One is that, because people can ask for money from their checking account at any time, impecunious operation of the bank could cause trouble if the value of the mortgages is impaired just a tiny bit at a time when people need most of the value in their checking accounts.

This has killed many, many banks. Values of mortgages sometimes decline both for easy-to-understand reasons, like the homeowner suddenly not wanting to pay it back, and for reasons which are striking to many non-specialists, like prevailing interest rates increasing. This is a long story, which we will not tell today.

Back to leverage. How much impairment to assets can the bank take before its equity is exhausted? If you know the leverage ratio, you can mental math out an approximation trivially. Add one to the leverage ratio, take the reciprocal. Bam. That's how much of a decline in the value of the assets wipes out the equity.

A 10:1 levered firm is wiped out if assets lose one-eleventh, about 9.09%, of their value.

Managing leverage of one's customers

Many financial firms are leveraged as a matter of course; it's required to do the work. Interestingly, their customers are also often levered. A homeowner who has just made their 20% down payment is levered 4:1.

Financial firms frequently have to manage the leverage of their customers, because just like a financial firm gets riskier as the leverage ratios go up, so do their customer accounts. Past a certain point, the financial firm will take painful actions to delever you.

I'm about to discuss an example which was approximately correct contemporaneously, when the essay was written, but is increasingly incorrect given the run-up in tech stocks and the decline in the dollar over the last couple of years. The current price of Google is about $300 a share, but we'll go with $100 just to keep the math easy.

Consider the example of margin accounts at stock brokerages. Google costs about $100 a share these days, so you could buy about 10 shares for $1,000 at your brokerage of choice.

Your stock brokerage, though, is willing to offer you leverage on your assets. In return for a fee, and to gain your business, because this is considered a high-saliency feature for the customers of brokerages, they will lend you money against your assets, allowing you to buy more Google than you had cash for.

They might allow you 2:1 leverage when you buy stock. Your $1,000 buys 20 shares now. Why would you want that? Because you like Google and want more exposure to it than you can afford. In future worlds where Google successfully sells ads and cancels chat apps, you'd make even more money that way.

As an aside, and indeed, the people who have held Google for the intervening years with 2x leverage have gotten 5x returns rather than 2x returns.

[Patrick notes: I said different, incorrect numbers live. Mea maxima culpa. Also, this assumes zero margin interest, which is not particularly likely, but makes the math easier.]

There’s another path dependency to take note of, though, because it is basically the canonical way to get wrecked by margin even when one’s investment thesis is right over the long term:

If you held 1% of your portfolio in 2X leveraged Google, then yes, you got 5X returns on that 1%. If you held 100% of your portfolio, there existed some chance each day that you’d fall below acceptable levels of equity (that you’d be overlevered) and be issued a margin call. This would decrease how much Google you owned, potentially even below the amount you’d have been counterfactually able to purchase with cash on the first day, depending on the exact price trajectory.

Backtesting that against Google’s actual performance is trickier than this comment warrants.]

So the brokerage lent you money (where it comes from is a wonderful topic for another day) to match your money. And then you sent all that money to the person who previously owned those 20 shares, and now they are all yours.

But you now owe $1,000 to your brokerage and are 1:1 levered. And this is fine, for now. In some unfortunate future universes, perhaps one in which Google runs out of chat apps to cancel, the price of Google drops by more than 50%. In this case, the value of your stock is now below your debt to the brokerage.

Your equity has been vaporized. But let's not go immediately to that calamitous case. Googlers are even now working on more chat apps to refill the cancelable chat app inventory. Perf is just around the corner. Say the price of Google is now $80. It only took a moderate hit. Now your brokerage has a few choices, and none of them are fun, because someone has lost money, and that can never be made fun.

The value destruction has already happened, principally at Google. The results of that destruction are being communicated to you because you chose to be a part-owner of their business, partially using other people's money. One thing your brokerage could do is ask you nicely to delever. You're no longer 1:1 levered, which is relatively safe.

You've got $1,600 in assets against $1,000 in debt, so $600 in equity, so about 1.67:1 levered. To bring that leverage ratio down, the brokerage could potentially issue a margin call. This is anachronistic lingo (you, if you are reading this and do not work in finance, are unlikely to actually get a telephone call) to require you to either deposit more cash or sell stock. Either of these will decrease your leverage ratio.

If you sell $400 worth of stock, you'll now have $1,200 in assets against $600 in debt. This is 1:1 leverage. If you deposit $400 of shares, you'll now have $2,000 in assets against $1,000 in debt. You'll go back to 1:1 leverage. If you deposit $400 and pay back the loan, you'll have $1,600 in assets against $600 in debt. You're now 0.6:1 levered, even safer than 1:1.

Why the discrepancy in the impact of $400? Because leverage measures risk, and depositing $400 in shares dilutes your risk by adding assets that are themselves an incremental source of risk. Repaying the loan, on the other hand, strictly decreases your risk.

Mismanaging customer leverage

Why do brokerages care about customer leverage? Because if they do not promptly de-leverage customers, the margin loans are unlikely to get repaid. The risk of the stock decline has effectively been transferred from the customer to the broker. The losses it is incurring are eating into the equity of the brokerage right now.

In principle, brokerages can pursue customers for bad margin debt. In practice, this is rarely going to restore them to whole, particularly not for retail customers, because the financial picture of someone whose brokerage account has lost all value is rarely rosy elsewhere. Brokerages take substantial efforts to avoid losing money on margin accounts.

In addition to the capitalistic reason to do this, their regulators are acutely aware of the risk that overextended customers pose to the brokerage. You can sort of think of society as being the broker's broker: if we do not manage your leverage, because you do not manage your customer's leverage, your losses eat into our equity. So we're supportive of you taking a carefully measured amount of risk, because risk makes your business possible. But we'll be cross if you take an impecunious amount and then stick us with the losses.

Brokerages really do lose money on margin accounts sometimes. It's relatively rare. Large losses usually have a complicated story, and I link in the show notes to one which involved speculation by someone who was likely an insider with respect to a closely held Chinese stock, conducted on an American brokerage.

But since they happen, brokerages spend a lot of effort carefully managing their balance sheets such that one hit does not impair their solvency.

Decentralized finance innovations in leverage management

I was recently playing around with a decentralized finance (DeFi) protocol. I am notoriously crypto-skeptic and do not perceive there to be much value in DeFi, but a friend won me over with this argument:

You believe Tether is a fraud. You want to short them, but do not trust cryptocurrency exchanges, so short them using DeFi. In worlds where you are right about Tether, you will make money and feel vindicated. In worlds where you are wrong about Tether, you will feel appropriately chastened. But you think basically no worlds like that exist, so what do you care? And in worlds where the DeFi protocol blows up due to any of a long list of causes, you'll get a great story out of it.

Solend and the whale

So let me tell you a story about Solend this week.

Postscript to the essay: Solend has since rebranded as Save, because Solend lost a lot of people's money and then predictably lost share in the renting-out-leverage-for-money game in DeFi.

[Patrick notes: The situation is slightly more complicated than I explained here, in part because loss allocation during credit events gets messy. Formally, the protocol (this is DeFi for “sponsoring firm”) had accrued bad debt on behalf of users, which would have made them unable to withdraw their deposited assets, causing an economic loss. The project treasury (another DeFi-ism for “sponsoring firm”) reimbursed the bad debt, which notionally covers the anticipated economic loss. However, at least some users may have made rational decisions to exit their deposits via e.g. borrowing an available token (prior to that being banned), taking a haircut for certainty of recovery. Others had deposited volatile assets and were unable to withdraw them due to illiquidity in the pool, with the eventual restoration of those assets being positive but not making them counterfactually whole.

This is spiritually similar to issues in calculating the true magnitude of the FTX malfeasance. It is generally quoted at $8 billion, due to the calculation done and then frozen in amber on the day of bankruptcy filing. This understates any true accounting, however, since the filing followed several days of market volatility (to the downside) caused by the same malfeasance. That broad decrease in token prices, substantially caused by FTX’s actions, has the tendency to minimize the “official” amount of economic harm attributed to the conspirators.

But that, too, is a complicated thing to say with full confidence, because another valid perspective is that crypto token prices in early November 2022 were a mirage; they were trading high because marginal trades were being made with stolen money. Traders during the Mt. Gox era benefitted from trading against a not-too-sophisticated counterparty who was, essentially, embezzling the funds with which they were making irrational trades; traders in 2022 benefitted from the same with different names.]

Why did they have to rebrand? Well, the following discussion will make it reasonably clear to you. A bunch of Solend depositors who thought they were doing a deposit product came to the realization that they were actually buying tradable shares in hedge funds and were capable of having those hedge fund shares get wiped out.

And so Solend lost share in the market of renting leverage to DeFi speculators over the ensuing years and then needed to do a rebrand.

[Patrick notes: What do interest rates in crypto lending protocols represent? Mostly, in the approximate words of the general partner of a crypto fund who pitched me on participating: “[Our] compensation for lending capital to degenerate gamblers speculating in shitcoins.”

There is very, very little usage of crypto lending protocols to support the real economy. This is sometimes phrased as an argument in their favor: look, you can earn rates of return higher than almost any fixed income product in the real economy! (Sporadically true, depending on present demand levels for leverage in speculation.) 

The example crypto aficionados reach for is asset-backed lending to allow Bitcoin and Ethereum OGs to fund consumption without selling the holding that makes them rich, which would realize the gain (and thus cause the OG to owe taxes, assuming they are diligently complying with a tax regime which taxes capital gains as of realization). This is, I will concede, as legitimate a use case for financial services as buy-borrow-die typically is for e.g. founders and employees of startups who decide to never sell. It isn’t very compelling as a pitch for growth of the lending market, though, because the number of OGs is effectively fixed, they’re more-than-adequately liquid now, and no one expects Satoshi to end his silence by calling up crypto investment banks and asking for loans. Crypto lending for consumer credit is not an investable business but if you want to invest in it anyway there are many teams that would happily take your call.]

Solend would be described by many people as operating a decentralized protocol. I would describe it as an API with an ops team attached, but whatever, not germane to the following.

Solend lets you deposit assets that are on the Solana slow database, earn interest, and withdraw assets that other people have deposited back to the Solana slow database, paying interest for the privilege. This allows you to do things like, for example, lever up on buying the Solana token.

In my case, the specific use case was: deposit USDC, a stablecoin that I have some degree of trust for. Borrow Tether. Use a separate DeFi program to sell Tether for USDC. Wait for the price of Tether to decline, buy the now-cheaper Tether with the USDC, repay the Tether-denominated loan to Solend, profit according to the degree of decline, less the net interest paid over the interval.

Now, a funny thing happened while I was patiently waiting for Tether to blow up: global systemic crypto calamity. Somehow this was not caused by Tether. Dang it, they can't get anything right.

So for people who don't remember November 2022, this was the collapse of FTX, which disrupted a huge amount of the cryptocurrency markets.

That quickly became relevant to my interests, because there was another borrower on Solend. Let's call him the whale. Said entity is knowable, but not germane to this story. The whale had previously deposited a lot of Solana tokens, SOL, to Solend, and withdrawn a lot of USDC stablecoins back when the price of Solana was much higher. At that point, he was conservatively leveraged. What did he do with the stablecoins? Who cares? They're money.

The price of SOL declined precipitously recently. Solend, the computer program, and Solend, the team, had planned for this eventuality, and the program started doing what it was designed to do. The design was: make some of the whale's debts assumable by third parties, if and only if those third parties ask for that to happen, in return for an incentive payment of the whale's collateral.

The idea was that fast-acting bots, operating in a tight loop and incentivized by the juicy 5% discount to the market price of SOL, would quickly eat the collateral, de-leveraging the account and bringing it back into a healthy state. A small detail: a portion of that 5% would get paid by the bot back to the Solend team, partly as compensation for their efforts, and partly to help build a buffer against bad debt.

That didn't happen. Why not? Well, the whale is much, much bigger than the bots, and it was out of their price range to liquidate it in one go. Instead, they'd have to chip away at it, buying up all the USDC they were willing to spend with their little bot brains, getting attractively priced SOL, selling the SOL for even more USDC, and repeating.

And with the price of SOL in free fall, some of the bots, or the operators of the bots, couldn't find liquidity at attractive prices for people wanting to buy their SOL. This resulted in them being unable to loop. So the price of SOL kept falling, and the whale went from conservatively leveraged to dangerously leveraged to insolvent.

Many people in DeFi believe that if this happens, you can basically just walk away from your collateral, and that is the end of it. I take no position on that point of view or the righteousness of it. It's just very different from the default expectation for traditional finance. Given that the whale was assumed likely able to just walk away, the hole in the balance sheet is now someone else's problem, and it grew as SOL declined.

How did this present to users of the protocol? Well, Solend was owed USDC, and it had SOL. But one thing people like doing when the price of an asset is in free fall is borrowing it to short it. So other users borrowed all the whale's SOL and sold it somewhere. Now the protocol had no SOL and a claim against USDC from a whale that was in another ocean.

And so if you liquidated the whale now, you would not get SOL for your USDC. You would get a wrapped token, an extremely technologically sophisticated IOU, instead, entitling you to some future SOL from Solend whenever they had the SOL to give you and you asked for it.

So Solend, the people, not the computer program, did some active liquidity management by tweaking parameters to their program, causing the offered interest rate for SOL deposits to be 2,400% to 2,600% on an annual basis.

In the midst of the market contagion, even 2,600% was insufficient to attract lots of SOL, for a long list of market microstructure reasons. Many of the bots were off, and their creators went to bed worrying that Solend would have an even larger hole in it when they woke up.

Who pays for that hole? The default answer is the people who deposited other assets in the same pool but will not be able to withdraw them, even if they repaid their loans, because their collateral is swimming with the whale in another ocean.

A frequent addendum to this answer in DeFi is: and since people would be really annoyed in that circumstance, there exists a side pocket of money, the project treasury, which would step in to make depositors less damaged in the circumstance. Of course, if the treasury is exhausted, well, that would be bad. You can read Solend's official write-ups for what they decided to do here.

But as the price of SOL kept going down, the hole kept getting deeper, and some combination of depositors and the project treasury was hemorrhaging money. So they kept doing things to entice liquidators, and they banned people from further borrowings of any assets because, well, you can predict the logic, right?

Playing liquidator by hand

A funny thing happens when you create incentive systems. For example, you might induce a technically proficient financial columnist to spend a few hours playing a very boring video game for money. Perhaps he knows enough about slow databases to understand how the words "epoch" and "unstaking" relate to each other, and to know what this implied for the difficulty level of a video game in the early Tokyo evening.

That video game, in lieu of being able to quickly program a bot, was taking a trivial amount of USDC, waiting for more SOL to be deposited in response to the 2,600% interest rate offered, and quickly liquidating as much of the whale's debt as the program would let me. The video game crashed about 70% of the time I tried to do this, but I pressed on.

Then I'd use my 5%-cheaper-than-the-market-price-recently SOL and use a different video game to convert that into USDC, tolerating both the high risk of the video game crashing and the very real risk of slippage in the price of SOL between when the slow database first detected me buying it and when the slow database would allow me to sell it.

This Solana slow database is a fast database as far as slow databases go, but due to market conditions, both it and some other necessary technological infrastructure were having a very bad day. What sounds like "click two buttons in a web app with a barely perceptible lag between them" took between 3 and 12 minutes per iteration.

As an aside, the notion that much financial infrastructure falls over during adverse market events is something which is extremely well-understood in the traditional finance community, and something that is largely designed around.

And so I round-tripped that transaction 22 times, each with more money used to liquidate. Then people in other time zones woke up, looked at market conditions, and turned their bots back on. Once that happened, AI stole my button-pushing job.

As an aside, while that was a joke a couple of years ago, I would absolutely have had an AI agent just code up a bot to do this in the status quo, because the AI agents do speak whatever the JavaScript derivative that Solend runs on is, whereas I was not nearly confident enough in my ability to successfully understand how to write code against that virtual machine and then have two blockchains interface with each other, which is something that I think was necessary to get this all to work.

Now, you might naively think that I roughly tripled my starting capital, because 1.05 raised to the 22nd power, but the combination of slippage and the fees I was paying to the designers of the video games meant it was actually more like a 50% gain. I made more money than I typically would playing poker for two hours, while probably at worse risk, and would probably choose to play Dyson Sphere Program or Factorio in the future.

But Outsourced APAC DeFi Defaulting Accounts Risk Manager did push my buttons for a few hours. Well, I pushed its buttons, at any rate.

What can be learned from this experience

What can we learn from this experience? The source of the payment for my button pushing was the built-in incentive to deleverage, via forced liquidation, the defaulting account.

The programmers chose to build in that incentive so that someone (and they had, sensibly, no idea that it would be me, or operate any way like how I chose to operate) would save them the downside risk of a defaulting borrower's collateral continuing to fall.

Was this the only thing that happened to Solend on the day? Oh no, feel free to read their official spaces for details. I've successfully mined the anecdote for my teachable moment now.

Am I a DeFi fan as a result of this experience? Not so much, no. But at least in reinventing things from first principles, the folks seem to have created a very concrete demonstration of what leverage management and mismanagement looks like.

Closing thoughts

Hopefully that helps demystify leverage and leverage management to you. You will, in both the near future and long after that, read a lot about leverage and how it blew someone up. And hopefully you'll remember that it's not some dark art only accessible to the high priests of finance.

And now you know enough to understand what I'm saying with an otherwise opaque statement like, "Tether is 35:1 levered on risky assets during market contagion."

I will say, as an aside, Tether keeps getting away with it. One of these days, one of these days. But that, if it ever happens, will be a very different episode.

Thanks very much for listening to Complex Systems this week, and we'll see you next week.