Curve Finance’s current near-death expertise (and its averted propagation) might seem to be a blur in Web3’s rear-view mirror, but it surely’s truly one thing that retains taking place within the trade. It’s not the primary time {that a} decentralized finance protocol — or any decentralized app for that matter — has been affected by an assault that’s completely authorized inside its personal code. Extra so, the disaster might’ve been prevented if on-chain danger administration existed.
All of this factors to a broader downside in Web3. That’s the downside of restricted expressivity and assets that exist in its growth environments and the way it impacts safety total.
Hack or exploit?
When the Curve Finance attacker was in a position to retrieve US$61.7 million in property from Curve Finance’s good contracts, many media shops and commentators known as the occasion a “hack.” However this was not a hack — it was an exploit. The distinction right here is essential.
On this context, a hack would’ve taken place if the attacker had someway bypassed or damaged an present safety measure. However the assault on Curve was an exploit. Nothing that occurred that was out of the abnormal when it comes to what the protocol’s Vyper code allowed for. The looter merely took benefit of how the protocol’s design labored.
Who’s responsible for this? Nobody. Curve’s Vyper code, like many of the (Solidity) code that’s utilized in Web3 purposes, is severely restricted in its capability to precise complexity past comparatively easy transaction logic.
This makes it exhausting for anybody to design safety measures that will forestall this or every other assaults. Extra worryingly, it additionally makes it exhausting for anybody to correctly design instruments to stop their unfold throughout DeFi’s huge and composable liquidity panorama.
On-chain danger evaluation
However it doesn’t imply there was nothing Curve might do to stop this assault and its unfold throughout DeFi. A easy instance of an answer can be on-chain danger evaluation.
The generalized model of a problematic sample that could possibly be solved may be summarized in a hypothetical scenario like this one:
Dangerous actor Bob buys $5 million price of the extremely risky $RISKY token through a flashloan.The worth of $RISKY token is successfully pumped by Bob after the acquisition. Bob takes out a $100 million mortgage on Naive Finance backed by $RISKY.Naive Finance checks the worth of $RISKY and confirms that Bob is “good” for the cash.Bob runs.When Naive Finance liquidates $RISKY it’s only price $5 million.
(One other instance of this basic sample may be discovered within the Euler hack from March.)
Historically, this downside is solved by danger evaluation options that decide how good of a assure an asset may be. In the event that they existed on-chain, Naive Finance might examine statistical estimations primarily based on the token’s historic worth earlier than approving the mortgage. The protocol would’ve seen via the pump and denied Bob the $100 million.
DeFi is missing this sort of on-chain danger evaluation and administration.
Going again to Curve Finance, an expansion might’ve been prevented if Aave and Frax had an automatic, on-chain restrict on mortgage approvals once they move a share of the collateral token’s circulating provide. This could’ve been a safer and fewer stress-inducing scenario for everyone.
Restricted expressivity and assets
The true downside right here is that present Web3 ecosystems can’t assist one thing like this on-chain danger evaluation resolution. They’re restricted by the sort of libraries and frameworks which are obtainable in digital machines just like the Ethereum Digital Machine. They’re additionally restricted when it comes to the assets at their disposal.
As a way to develop one thing like this danger evaluation and administration resolution, a decentralized app would want to rely on coding libraries which have capabilities for no less than primary mathematical ideas like logarithms and others.
This isn’t the case in Web3 as a result of dApps don’t have entry to NumPy, the mathematics module in Python, for instance. The standard toolbox isn’t there and builders need to reinvent the wheel as an alternative.
Then we now have one other downside. Even when they’d these libraries, they might be too costly to code. Actually costly. The Ethereum Digital Machine is designed in order that there’s a worth for each computation.
Whereas there are legitimate causes for this, resembling stopping infinite loops and such, it additionally creates a useful resource limitation for dApps which may must scale computationally with out incurring unreasonable prices. One might simply see how a danger administration resolution would value extra to run than what it’s in a position to save in funds.
Specializing in the correct issues
At a localized degree, the unfold of the Curve Finance deadlock might’ve been prevented with on-chain danger administration. At a basic degree, this entire class of assaults could possibly be prevented with extra expressivity and assets in Web3.
These are two facets of blockchain scalability which have lengthy been missed as a result of they transcend affording extra shared block house for dApps. They really contain the creation of growth environments in Web3 that emulate these of Web2. They’re about computational scalability and programmability, not simply scaling the quantity of knowledge that’s obtainable on-chain.
Maybe if protocol builders at Curve, Aave or Frax had the flexibility to rely on a greater toolbox and extra assets, these and future exploits could possibly be averted altogether. Possibly we might begin with on-chain danger administration.