I don't usually write about cryptocurrency because I think there's a ton of very healthy skepticism about it and I'm not trying to sell anything. But something really weird, even by cryptocurrency standards, popped up in the last few weeks and it's breaking my brain, so I want to write it down.
The thing that popped up is called "flash loans" which are loans that are repaid, with interest, in the same transaction that they're lent out. From the lender's perspective, one minute they have some money in their account, and then a single transaction happens, which is them getting more money. On the borrower side, they've constructed a single transaction where they can make money and pay back the interest. Wait, what?
Okay, so if you think about a "transaction" with normal money, it means that money was debited from one place and credited somewhere else. Like if you hand me a $20 bill, $20 has been debited from your hand and credited to mine. There are some weird in-between moments (who has the $20 if we're each holding one end of the same bill?) but none of them are particularly useful.
But in Ethereum, a "transaction" is a Turing-complete instruction to the network, so it can be programmed to do anything. The only constraint is that the transaction has to complete in the ~15 seconds it takes for a block to be mined. And all of the operations in a transaction either complete together or they're all cancelled. So an Ethereum transaction can take the form of:
<aside> ⌛ Borrow $$ —> Use the $$ for 15 seconds —> Give $$ and interest back
</aside>
If there's any way for you to make money in that 15 seconds, it's yours. If you fail, the whole transaction is cancelled and you never really borrowed the money anyway. That last part is weird because outcomes don't usually work retroactively.
So yeah it's cool that maybe you could use this to make some money, if you were good at writing smart contracts and analyzing arbitrage opportunities, or whatever, sure. But the thing that I can't get over is how this creates a kind of Schrödinger's Money, where the money exists in two places at once for the duration of the block, and we actually only know where it was in retrospect. And it's not just two places, there could be 10 smart contracts all using the same money to run their 15 second schemes and then only the most profitable one completes and the rest fail. So we've created this probabilistic cloud around a dollar balance where the dollar used to be like, a physical piece of paper that you could actually touch.
When I was in high school, learning about how electrons behaved in the double split experiment (from this video actually) completely blew my mind. The idea is that electrons exist in a "possibility cloud" where they could be in position A or in position B and they don't really decide until they're observed. Weirdest of all, electrons interact with all of the other possible positions and create an interference pattern, even though only one electron actually exists. A single electron behaves as if it's surrounded by a cloud of other electrons, because it interacts with all of it's own possible paths. 🤯
So as I'm thinking about flash loans, I'm realizing that a similar thing could happen. If several transactions are running, trying to profit from the same balance, they might interact with one another mid-transaction and create interference patterns. Still, only one transaction will actually exist at the end of the block, but it will have interacted with all of it's own possible paths along the way. In a competitive environment, flash loan transactions need to be written to account for that interference, so they'll have this property even if there aren't other transactions competing for the same block.
I've spent a lot of time thinking about "programmable money", but I've only had mental models to think about how we would program payments at the level of point to point transactions. But the concept of flash loans has blown open the "transaction" for me, and now I feel like I'm looking inside of an atom. It is REALLY weird in there. Maybe it's always been weird in there, but it's just been hard to observe, or maybe this is a new property for blockchain transactions specifically.
Anyway, this is breaking my brain and I'm dying to talk about it more so if it's breaking your brain too, hit me up! I'm not sure if flash loans will be a good thing for the world or a bad thing, they might very well be a bad thing. But, I want to leave you with B's Law about these quantum transactions:
<aside> 💡 If you're lending via flash loans then you are both a billionaire and completely broke until you check your ETH wallet.
</aside>