Skip to main content

LLAMMA and Controller

AMM.vy & Controller.vy

The source code for both contracts, AMM.vy and Controller.vy, can be found on GitHub. The contracts are written using Vyper version 0.3.10.

Llamalend uses Controller V3 — the same blueprint that powers the latest crvUSD mint markets (weETH, cbBTC, LBTC). The Controller and AMM contracts originated in the crvUSD system and were extended for lending use. For a full version history including the evolution from crvUSD V1 through V3, see the crvUSD Overview.

Because Curve Lending operates very similarly to the system for minting crvUSD, both Controller.vy and AMM.vy can be used for lending markets. To ensure full compatibility with both systems, several modifications were made in V3:

AMM.vy (LLAMMA)

The core contract AMM.vy (LLAMMA) remains exactly the same as in the crvUSD system. No changes were needed for lending.

Full LLAMMA Documentation
Controller.vy

The Controller has been modified for lending with changes to token decimal handling, fee collection, and ETH transfer behavior.

Full Controller Documentation

Changes to Controller.vy

The changes made to the codebase of the Controller contract are mainly under-the-hood changes, which do not significantly affect how users interact with the contract. External functions like create_loan, repay, etc., work the same way as before.

The following changes have been made:

  • The Controller now has the ability to handle not only 18-digit tokens (like crvUSD) but also tokens with any number of digits. For this, there were multiple changes to ensure rounding always rounds up in favor of the existing borrowers.

  • The collect_fees() method will not work in lending. Admin fees are set to zero, and all the interest will go to the vault depositors. Moreover, AMM admin fees cannot be charged: their claim would fail too. The system is designed to make money on fees generated by crvUSD itself.

  • The contract that creates the Controller has collateral_token() and borrowed_token() public methods instead of a stablecoin() method. This keeps the code clean and understandable when a stablecoin is collateral, not the borrowed asset. However, compatibility with the stablecoin() method is preserved.

  • Transfers of native ETH are removed for safety. To enhance safety with unknown variables, automatic wrapping of ETH is disabled permanently.