crv.mktcap.eth

Share this post

Sept. 6, 2022: curve-stablecoin.js πŸ¦™πŸ’΅

curve.substack.com

Sept. 6, 2022: curve-stablecoin.js πŸ¦™πŸ’΅

What we can infer about $crvUSD from the newly public Curve repo

crv.mktcap.eth
Sep 6, 2022
7
Share this post

Sept. 6, 2022: curve-stablecoin.js πŸ¦™πŸ’΅

curve.substack.com

Livestream at 8:30 AM PT

Twitter avatar for @chago0x
Chago @chago0x
Today, crvUSD was born. @CurveFinance πŸ‘Ά github.com/curvefi/curve-…
github.comGitHub - curvefi/curve-stablecoin-js: JavaScript library for Curve StablecoinJavaScript library for Curve Stablecoin. Contribute to curvefi/curve-stablecoin-js development by creating an account on GitHub.
7:41 PM βˆ™ Sep 5, 2022
275Likes50Retweets

The $crvUSD Javascript library, which will connect a frontend to the smart contract infrastructure, is finally public. This gives us the most information yet about $crvUSD, although the backend has yet to launch.

crv.mktcap.eth is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

Twitter avatar for @CFrogE1
MoonFrog || $CRV Booster || ve(πŸ‘‘,πŸ‘‘) @CFrogE1
@0xc4ad, you know what to do. Release the contracts. 🐸πŸ€ͺ🌈
Twitter avatar for @bneiluj
Julien Bouteloup @bneiluj
go easy degens with that news...no smart-contracts but a good sign for incoming CRVUSD with its js api a little bit more than 2y after $CRV deployment. You can grasp a good portion of the tech from its interface in alpha commit before $LLAMA being deployed https://t.co/djZNEO6wWp https://t.co/MFjspETh4e https://t.co/yky8DXNzPs
11:55 PM βˆ™ Sep 5, 2022
6Likes2Retweets

Along with a well documented README file, the repository includes tests for common actions and two ABIs for backend contracts. These ABIs in particular give us the best glimpse into the backend.

Sleuths have already ripped through the codebase and unpacked the details:

Twitter avatar for @0x_zeno
0xZeno.eth @0x_zeno
crvUSD JS integration library πŸš€ $CRV $CVX - Llama Wallet - add collateral - borrow - repay - health of loan - self-liquidation βœ… - swap πŸ€” could mean swapping between collateral types.
Twitter avatar for @TaikiMaeda2
Taiki Maeda @TaikiMaeda2
Any gigabrains understand this? https://t.co/uFWPYye1EB
8:30 PM βˆ™ Sep 5, 2022
27Likes9Retweets
Twitter avatar for @nagakingg
nagaking @nagakingg
Some sort of on-chain llama herding mechanism πŸ€” Surprising pivot into animal husbandry by @CurveFinance https://t.co/Ri2zb2z0Od
Twitter avatar for @TaikiMaeda2
Taiki Maeda @TaikiMaeda2
Any gigabrains understand this? https://t.co/uFWPYye1EB
9:34 PM βˆ™ Sep 5, 2022
3Likes1Retweet

Here’s a list of six things from the codebase that caught our eye.

LLAMMA

The engimatic LLAMMA [sic] reasserts itself prominently in this repo. The name was first leaked by 0xLlam4, where it featured prominently in the redacted copy of the yet-to-be-released white paper.

Twitter avatar for @0xLlam4
0xLlama @0xLlam4
You didn't think the @CurveFinance stable was going to be just another collateralized stablecoin, did you?
Image
8:13 PM βˆ™ Jul 22, 2022
560Likes69Retweets

Yesterday we also received confirmation LLAMMA is an acronym for β€œLending-Liquidating AMM Algorithm.”

Twitter avatar for @bneiluj
Julien Bouteloup @bneiluj
LLAMMA stands for lending-liquidating AMM algorithm
Image
10:22 PM βˆ™ Sep 5, 2022
56Likes10Retweets

LLAMMA appears frequently throughout the codebase, so we know it’s central to the operation. The repository also contains the full ABI for the actual LLAMMA contract. While we don’t know what’s going on inside the black box, we know the public endpoints in the contract’s interface.

Of the 44 functions, 9 are state modifying, the remainder are views. These view functions contain a lot of heavy math… functions like rate_mul, get_y_up, get_sum_xy, get_dxdy, sqrt_band_ratio… we can surmise Curve’s trademark advanced math will be quite prominent within the LLAMMA-verse.

Among the functions that modify the state are:

  • constructor

  • initialize

  • deposit_range

  • withdraw

  • exchange

  • set_rate

  • set_fee

  • set_admin_fee

  • set_price_oracle

In the codebase, this. is abstracted by calling crvUSD.getLlamma(id) on the crvUSD stablecoin object.

Note the llamma object has a unique Controller address. This references the other ABI included in the repository.

The controller contract contains far more modifying functions, and the sorts of functions one might expect from a typical lending protocol: ie create_loan, add_collateral, borrow_more, repay, liquidate, et al. When users directly create or manage the loan, they generally do so through the Controller contract, not directly to the Llamma contract.

One can extrapolate an architecture in which each form of collateral has a Llamma contract that runs the higher level math aggregated across all positions. Users can manage their specific position within this Llamma contract using its associated Controller contract.

Lending

The first β€œL” in llama stands for β€œLending.” What is being lent?

The only asset referenced throughout this codebase is eth. Does this mean that $crvUSD will only be backed by Ethereum?

Twitter avatar for @JordiMorris1
jordi Morris Β―\_(ツ)_/Β― (πŸ§™β€β™€οΈ,πŸ§™β€β™€οΈ) @JordiMorris1
@chago0x @CurveFinance only 'eth' as collateral?
1:20 AM βˆ™ Sep 6, 2022

Based on some context clues in the codebase, there is reason to suspect it actually supports a wider range of assets than just ETH. If $crvUSD only accepted ETH, there would be no reason to specify an id, it would just be hard-coded. The β€œcollateral token” is a value set in the Controller constructor, which implies multiple contracts may be deployed and instantiated with different collateral.

Further, we also see a reference in the Controller contract ABI to a tokens_to_liquidate function. Such a function might be unnecessary if ETH was the only token to liquidate. Finally, the Curve saave pool is referenced in the README in what appears to be a typo, possibly a Freudian slip.

The opposing case would be that the functionality to include multiple different LLAMMA ids was included simply to allow room for future expansion. The contract could plausibly launch with ETH as its only collateral, and task the DAO or devs with other future sources.

Otherwise, we see from the README, tests, and Controller ABI that this functions like a normal lending protocol… functions to create a loan, add collateral, borrow more, repay, or check loan health.

There’s also a function in the Controller ABI called β€œset_monetary_policy” that sounds interesting but is not referenced elsewhere.

Liquidation

Previous leaks describe that the stablecoin will feature a β€œnovel liquidation mechanism.” Yesterday’s code drop doesn’t provide too much detail on liquidation mechanics, but we can note at least two liquidation mechanisms.

First is triggering a liquidation externally. The example demonstrates a random account triggering a liquidation on an account with 2751 $crvUSD and >$3K in debt. The liquidator appears to be any account that closes the position and receives the collateral.

The other liquidation mechanism described is β€œself-liquidation,” in which the user deposits the missing balance and receives their collateral.

Several other protocols use such mechanisms, so this doesn’t yet fit the category of β€œnovel” liquidation mechanism. However, perhaps the next functionality detailed offers a bit of a clue.

Swap

One feature that may be unique to the $crvUSD functionality is the fact that it includes a native β€œswap” feature. This is demonstrated in which a user calls a series of swap functions which adjusts their stablecoin/collateral balance:

This appears to be a prominent feature, in that there’s significant functionality built into the ABIs and the frontend to manage this. This includes functions for measuring the price impact of making these swaps, calculating the outputs, and protecting against possible slippage.

Here we start to see how an AMM fits into LLAMMA.

Oracle

Curve has never relied on external price oracles, but several times throughout the codebase the LLAMMA is referencing oracle prices or setting oracle contracts. Both ABIs reference an oracle. The templates pay particular attention to whether the oracle price is increasing or decreasing.

Will Curve be utilizing Chainlink for oracle pricing? Curve v2 pools? A new mechanic? Very unclear at this point.

Ticks/Bands

Throughout the repository we see frequent references to β€œticks” and β€œbands.” The LLAMMA ABI has a function to allow you to β€œdeposit_range.” This concept is quite fundamental to establishing a loan:

We observe in the stats the bands (perhaps a related concept):

Observe above band 11 all balances are fully collateral. The active band (11) has a mix of collateral and stablecoin.

This seems to evoke Uniswap v3 price ranges, and may offer a clue about some of the mechanics under the hood. Carving up prices into ranges may be a core feature of $crvUSD to keep an eye on going forward.


Disclaimers! Note: Although author has seen the full white paper, this article contains no alfa beyond what has been presented publicly. Author also hates Javascript, so may have butchered some details.

crv.mktcap.eth is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.

Share this post

Sept. 6, 2022: curve-stablecoin.js πŸ¦™πŸ’΅

curve.substack.com
Comments
TopNewCommunity

No posts

Ready for more?

Β© 2023 crv.mktcap.eth
Privacy βˆ™ Terms βˆ™ Collection notice
Start WritingGet the app
SubstackΒ is the home for great writing