# LLAMMA and Controller

Source: [https://docs.curve.finance/developer/lending/contracts/controller-llamma](https://docs.curve.finance/developer/lending/contracts/controller-llamma)

warning

This page documents the LlamaLend v1 Controller V3 and AMM contracts. For LlamaLend v2, use the [LendController](https://docs.curve.finance/developer/llamalend-v2/lend-controller.md) and [AMM](https://docs.curve.finance/developer/llamalend-v2/amm.md) references.

`AMM.vy` & `Controller.vy`

The source code for both contracts, `AMM.vy` and `Controller.vy`, can be found on [GitHub](https://github.com/curvefi/curve-stablecoin/tree/master/curve_stablecoin). The contracts are written using [Vyper](https://github.com/vyperlang/vyper) version `0.3.10`.

LlamaLend v1 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](https://docs.curve.finance/developer/crvusd/overview.md#controller--amm-versions).

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](https://docs.curve.finance/developer/crvusd/amm.md)

`Controller.vy`

* * *

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

[→ Full Controller Documentation](https://docs.curve.finance/developer/crvusd/controller.md)

* * *

<a id="changes-to-controllervy"></a>

## 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.
