Why DeFi Trading is So Expensive (and how we fix it)
In finance, being able to profit from information without taking any risk is something of a holy grail. This is why you’ve heard stories about the lengths that hedge funds and high-frequency traders will go to in order to gain just a little bit of advantage–whether it’s laying fiber-optic cable through mountains or becoming best buddies with an insider at a public firm.
There are a lot of ways to do it, but in this article we’ll focus on the two that are most relevant to DeFi, and explain how Krypton solves for these problems–and make no mistake, it is a problem. Even in traditional finance, the market inefficiencies that result from these trading behaviors are extremely costly, and it’s even more expensive in DeFi.
(Quick note: This article goes into a fair bit of detail. If you have any questions at all, please reach out to us via Twitter. Good communication is important to us, so your feedback would be really helpful.)
At Krypton, we group traders into three general categories:
The first information-based strategy we’ll talk about is front-running, which happens when an informed trader has access to incoming trade data and is in a position to place their own trades to take advantage of it (we’ll get into a detailed example of how this works later on).
In DeFi, front-running is related to price slippage: Because miners or validators (block producers) can see incoming order flow data and squeeze in their own orders, you end up paying your maximum slippage tolerance on every single trade. This is an added cost to trading.¹
Informed traders may also take advantage of short-term information signals that spot actual or potential short-term mis-pricing of assets. In DeFi, you’re most likely to see this as mis-pricing between trading venues, namely between AMMs and centralized exchanges (more on this in a moment).
In DeFi, informed trading gives rise to impermanent loss for liquidity providers. Impermanent loss is described as adverse selection in traditional finance, which describes the risk/cost to market makers of being on the losing side of a trade against a more informed trader.²
Adverse selection is an important factor in determining bid-ask spreads, which is the difference between a market maker’s quote to buy a security (the bid) and the quote to sell a security (the ask). The wider the spread, the worse for regular traders like you and me.
Price slippage and wider spreads affect all traders in the market–basically, the cost of front-running and adverse selection is passed on to the rest of the market.
Impermanent loss acutely affects liquidity providers. Here’s an analysis of liquidity provider losses for ETH/USDC pools on Uniswap v3. By this estimate, even after accounting for the fees liquidity providers earn, in total they have lost over $115 million (as of this writing) in this single trading pair alone. They eat these costs because they have no way to update their bid-ask spreads–not a great business model for LPs.
The key innovation at Krypton was the realization that all of these problems stem from one source: The way that trades are executed. Let’s get into it.
First, it’s important to note that there are two parts to a trade: The assignment of value (the determination of who is entitled to what) and the settlement of the transaction (the actual transfer of value). For our purposes, settlement occurs via an ERC-20 token transfer, i.e., via the transfer function. This isn’t something we need to change or influence.
However, the assignment of value is something we can and should influence, as this is what ultimately impacts the price. At Krypton, what we’ve adjusted is the speed at which a trader becomes entitled to their tokens. This is a subtle but incredibly powerful innovation that stops all of the above issues in their tracks.
In a traditional trade, the assignment of value–the exchange–occurs instantly, in a single burst. I sell you X amount of Y token, and bam, that full amount no longer belongs to me and now belongs to you. Essentially, we are either not trading at all, or we’re trading a lump sum in a flash.
Every single trade happens in this way, so visually a series of transactions would appear as a bunch of individual bursts over a period of time.
At Krypton, we use a continuous flow system, so each individual trade isn’t executed in a discrete burst but rather in a flow over a period of time. You can liken this to pouring water from one bucket to another versus throwing a ball to someone nearby. Once the ball leaves your hand, it’s all gone, but it takes time to pour the water.
A key feature of this approach is that the transaction requires an agreed-upon speed. That also means that our supply and demand curves look different — rather than clearing at a price vs. quantity, the Krypton market clears at a price vs. trading speed.
Let’s walk through how this works with an example. First, consider the mechanics of your trade on an AMM or a central limit order book:
Suppose I want to buy a token and I know that right now the price is $100, and that there is some price impact from my trading activity (i.e., the token price is affected by the transaction³). Let’s say in this example my “buy” trade will drive up the price by $5, so if I were to start buying at the current market price of $100, the price would rise to $105 by the time I’m done trading, with an average price of $102.50.
This all occurs in a single transaction on the blockchain. Now, in a single block there can be many transactions. Let’s say for the sake of simplicity that my trade occurs in block 1,000 at transaction index 50.
If someone could see that trade go into the memory pool and place the exact same trade as me at transaction index 49, then they would start buying at $100, and drive up the price to $105. By the time my trade pops up at transaction index 50, the price is already $105 and by the time I’m done, the price will be $110.
So, in this situation, instead of buying at an average price of $102.50, I bought for an average price of $107.50.
If that same trader could then get another transaction in at transaction index 51, they could start selling at $110 (the new market price). Say when they finish selling the price has dropped back down to $105, for an average price of $107.50.
The results: My average cost went up by $5 and they scored an average profit of $5.⁴ This maneuver, called sandwiching, artificially pumps up the price for the trader in question at the expense of me and other market participants.
This is a huge problem in DeFi. The order in which transactions enter a block are determined by a block producer, and today the majority of block producers run a modified Ethereum mining client that helps to maximize opportunities to profit in this way (Flashbots being far and away the most prominent).⁵
But on Krypton, the ordering of transactions within a block doesn’t matter.
This is because of the way that Krypton interprets the passage of time on the blockchain: Krypton views transactions in the same block as having occurred at the same point in time. Every trade that happens at the same point in time has to execute at the same price.⁶ Thus, if someone tries to front-run you by getting their transaction at an earlier index in the same block, they end up moving the price against themselves as much as they move it against you.
In the example above, the trader who comes in at transaction index 49 and pushes the price up to $105 thus moves the price for both of us.
In other words, it makes this kind of front-running unprofitable.
But wait, you might be saying, what if they try to censor my trade from appearing in a specific block and put their trade into that block instead? To do that, they’d have to buy out the entire block via Flashbots to make this work, which is likely very expensive or even practically impossible.
Depending on my trading speed and the settlement cycle, this trade would have to work very hard and pay potentially a very high cost just to front-run a portion of my trade. Furthermore, when my trade arrives in the next block, they need to immediately cancel their trade and put on a trade in the opposite direction. But they would have to do so at a lower speed since they would otherwise drive the price to a point where their sandwich is losing. In addition, I can drive down their gains and lower my losses by simply reducing my trading speed.
What we’ve done here is architect a system that just makes it really expensive to pick off these kinds of profits, which means it’s an unappealing if not outright impossible place for a front-runner to be.
In both traditional finance and in crypto, market makers (or liquidity providers as we call them on AMMs) act as a kind of instant-counterparty to a trade. The way they make money is through the bid-ask spread: the difference in the price at which they’re willing to buy and the price at which they’re willing to sell.
Market makers are as a general rule always available. On an order book exchange, they keep active bids/asks in the order book. On an AMM, the liquidity provider pledges their tokens and transactions are executed according to a simple pricing formula (often of the constant product type).⁷
Sometimes, a sophisticated, informed trader obtains and processes some kind of price-relevant information a short time before others do so, and this trader will want to trade against the market maker/liquidity pool before they can update their prices. That way, they can monetize that information before the market price reflects it.
Market makers know this is always a possibility, so in setting their bid-ask spreads they account for the risk of trading against someone more informed. In practice, this means bid-ask spreads are often higher than they should be.
But what if a market maker could protect themselves against informed traders and thus offer better pricing to the rest of us?
This is another place where the Krypton approach shines. For an informed trader, speed is critically important because it’s usually only a matter of time before someone else (or the whole market) finds out about it. So, if the price is going to rise from $100 to $105, informed traders have an incentive to buy up all resting inventory priced below $105 in order to get the maximum quantity (and thus profit) possible.
On Krypton, that means they’d need to buy fast. They’d choose the highest trading speed they can get in order to obtain the highest number of tokens they can in the shortest amount of time. But this drives up the price.
High trading speed also alerts the market that something is going on. Even if a market maker has no idea what the information is, they can see that someone needs to trade very fast and is happy to massively move the price against themselves to do so. This is a dead-giveaway that someone is out to monetize short-lived information. The market maker can thus respond by widening out the bid-ask spread and lowering their cap on trading speed.
This way, even if the informed trader was able to monetize information for a block–or even a few blocks–they’d get stopped relatively quickly. Again, at best, only a portion would be transferred at a disadvantageous price. That means market makers are protected in exactly those situations that are typically the most costly to them: when a large chunk of price-relevant information comes out in a very short amount of time.
On Krypton, due to its continuous-flow trading, the moment that market makers notice a price and trading speed jump, the damage to them only begins to get done — they can react.
In all traditional trading mechanisms which trade at infinite speed, when the public observes that prices have massively jumped and a large quantity has been transferred, it is already too late for the market makers. The damage has been done. What Krypton effectively does is to turn trading speed into a publicly digestible signal and forces toxic traders to send that signal which market makers can interpret as a code red for adverse selection to close their city gates until the zombie horde has passed.
Krypton’s trading mechanism creates a major disincentive for adverse selection based on a short-lived signal. It just doesn’t make sense to do informed trading on a platform where you can’t effectively monetize it.
For the vast majority of traders, a continuous flow trade that executes over a period of 1 second or 10 seconds or even 5 minutes isn’t going to make a difference in terms of the information you’re trading on. But where it does make a difference is in the costs you pay to get that transaction. By making it unprofitable to carry out front-running and information-based trades, Krypton protects other market participants from the costs of these actions.
That means a more fair and efficient exchange in which the market price and the price you pay are almost the same.
This is a system that could work in any kind of centralized or decentralized setting. But the benefits to DeFi in particular are huge: With the ability to trade efficiently and without the risk of predatory actors, we hope to unlock the incredible potential of DeFi for other applications that rely on functioning exchange in order to work, like asset management.
We can’t wait to build that future with you.
Krypton is dedicated to the idea that functional markets are fair markets, where you can get the trade you want at a cost that makes sense. Our academic roots are the foundation of our novel approach to solving the challenges of building a decentralized financial system, and we’re proud to offer a truly novel approach to exchange architecture with the Krypton DEX.
¹Of course, this assumes that the profit from front-running exceeds protocol and gas fees. Since gas fees are coming down by virtue of scaling solutions, you can expect ever more trades–even small ones–to be front-run.
²AMMs are particularly susceptible to this risk because prices on an AMM only update through executed transactions on the AMM–they have no way of “learning” the market price other than through the liquidity pool buying or selling at unfavorable prices. In other words, liquidity providers are basically guaranteed to be the victims of adverse selection.
³Price impact should be differentiated from price slippage: Price impact is what you expect you would get given the shape of the demand or supply curve (or, the state of the order book or the state of the liquidity pool on an AMM) if your trade were executed right away.
⁴The difference between the price I thought I’d get ($102.50) and the price I got ($107.50) is described as price slippage.
⁵In traditional finance, latency advantage is associated with high-frequency traders, who try to capitalize on information by being a few milliseconds (or even microseconds) faster than others.
⁶That’s because we use a continuous batch auction (we will address this another time as it is beyond the scope of this article).
⁷We won’t get into this in detail here, but please let us know if you’d like to learn about it!