It’s flying a bit under the radar, but Llama Lend is coming SOON™️!
This has been the subject of a little WEN-ning?
A few WENs here or there, but mostly the hype has been a bit more subdued compared to the prior $crvUSD launch.
Perhaps the community expects months or years may elapse between the first audit and launch season? Or perhaps bagholders are fearful, knowing that $CRV price tends to drop on innovations that uniformly increase the value of veCRV?
Regardless of the effect on speculative token values, we can look forward to one potential practical upshot: the launch of Llama Lend should theoretically neutralize the “mansion” FUD popular among the anti-$CRV NPCs.
Assuming a new lending market is launched, where Mich can partake in reindeer games with his ample $CRV stash, it should further undermine the perpetually debunked arguments of team “Death Spiral.” Their tortured logic goes something like:
Price goes down
Mich gets liquidated
????
Curve ends somehow
Once Llama Lend launches, borrowers like Mich would benefit from $crvUSD soft liquidation protections. While this wouldn’t completely remove the threat of a liquidation, it would make it far simpler for a savvy operator like Mich to dodge the threat.
Checkmate for team Death Spiral?
In our view, Llama will be quite unlikely to silence the critics, who are often underinformed on Curve developments.
“Logic” and “facts” have traditionally carried little purchase among the most diehard Curve haters. We have little doubt the tired FUD will continue apace, if not crescendo.
However, at least Llama Lend will usher in a world where:
We can try to parlay FUDsters’ superior reach into an opportunity to educate the broader community about the “soft liquidation” protections that render their lukewarm takes even more ridiculous.
veCRV holders will more directly profit from futile attempts to death spiral $CRV
Like a proper judo master, Mich is using his opponents’ momentum against them. Well played, ser, you’ve certainly earned yourself an annex to your mansion!
Llama Lend Overview
With the Github repository now in an audit-ready state, let’s walk through the current repository.
You know the work is near its conclusion when Mich turns to adding documentation. Helpfully, the Lending.md markdown describes the changes in great detail. Also quite useful is the Github comparison between the two branches.
The guts of the core $crvUSD infrastructure remain largely unchanged. Within every market on $crvUSD, you may have observed a few key contracts linked in the UI.
The AMM and Controller contracts are deployed from templates by the $crvUSD factory to handle each particular $crvUSD market.
The Monetary Policy contracts are a bit different. Each market points to a Monetary Policy contract, but in some cases they are reused among markets.
The core logic winds up needing few changes to prepare themselves for the isolated lending markets. This compatibility is a big reason the new system could be spun up relatively quickly.
AMM
The AMM contract in particular required almost no changes.
As you can see, very minor tweaks to the contract to touch up the behavior around the output token, which may be an arbitrary token at this point. Otherwise, it is fully backward compatible to the $crvUSD AMM.
Controller
The Controller, the contract you interact with to create and manage your loan, required a few more adjustments, but these are mostly minor.
Eyeballing the repo, you can see a lot of changes on the Controller.vy contract. Much of the functionality remains about the same, but you can see a lot of red lines removing the functionality for transferring native ETH (to reduce hack risks). The prior contract hard-coded a “STABLECOIN” variable referring to $crvUSD, but now the logic is adjusted to point to a more generic “BORROWED_TOKEN”
There are a few functionally important changes related to the PRECISION of the token — $crvUSD was 18 digits, but other tokens may have arbitrary digits (Tether uses 6 digits, WBTC uses 8).
This is a critical piece — the recent Wise Lending market exploit was due to flawed logic related to precisions.
Monetary Policy
As mentioned above, all $crvUSD markets point to a Monetary Policy contract. For the case of $crvUSD, the Monetary Policy contract would whipsaw the borrow rate (often quite violently) depending on the $crvUSD peg.
Since the new Llama Lend markets do not care so much about the health of $crvUSD, they introduce a brand new Semilog Monetary Policy contract that computes the market’s rate as a function of the market’s utilization.
The specific math here:
Vault
Another new feature of Llama Lend is implementation of the ERC-4626 lending vaults standard to serve as the various lending markets. This adheres to the ERC-4626 standard, and supplements it with some helpful view functions.
The Vault contract therefore may become a useful template for users hoping to code their own ERC-4626 compatible contract using Vyper.
Of interest to some, the Vault contract uses the DEAD_SHARES approach to mitigate potential inflation attacks.
Lending Factory
Finally, there needs to be a way to create these new vaults, which comes via the new Lending Factory contract.
The big thing to note is the presence of the `stablecoin` variable here. The lending markets require new vaults to contain the `stablecoin` ($crvUSD) as either the token that is borrowed or the token that serves as collateral.
In other words, you won’t see anybody creating a market to lend $CRV to receive $BobrCRV directly. Instead one could lend $CRV to borrow $crvUSD through one market, and then lend $crvUSD to borrow $BobrCRV in a separate market.
This reliance on $crvUSD within the markets is useful for creating more supply sinks for $crvUSD, which will be helpful towards keeping the $crvUSD peg stable and therefore helping ease borrow rates. It’s a big reason why Llama Lend is forecast to have a bigger effect on $crvUSD supply than opening new collateral markets.
Another notable feature of the factory is the requirement that it contain a working price oracle in order to create the pool.
This means in many cases it may not be possible to directly create a lending market — for example, $BobrCRV directly has no price function.
However, newer generation Curve pools (ie Stableswap-NG) do have a functional price oracle built-in, so it’s possible to create a market by launching a Curve pool with the target asset.
Incidentally, this points to another new contract, which is the CryptoFromPool.vy which is a price oracle contract responsible for reading the price from a Curve Pool.
These are the crux of the changes, although there’s plenty of additional tweaks (for instance, additional new tests for the new suite).
We’d encourage you to read through the codebase yourself and ask questions or drop your own comments!