# Aave V2

## Resources

- [Contract Addresses](../../reference/addresses)
- [Source Code](https://github.com/aave/protocol-v2)
- [Subgraphs](https://github.com/aave/protocol-subgraphs)
- [JavaScript SDK](https://github.com/aave/aave-utilities)
- [Interface](https://app.aave.com)
- [Whitepaper](https://github.com/aave/protocol-v2/blob/master/aave-v2-whitepaper.pdf)

## Architecture

### LendingPool

The main entry point into the Aave Protocol. Most interactions with Aave will happen via the `LendingPool`, including:

- `deposit()`
- `borrow()`
- `repay()`
- `setUserUseReserveAsCollateral()`
- `withdraw()`
- `flashLoan()`
- `liquidationCall()`

### LendingPoolAddressesProvider

The main addresses register of the protocol, for particular markets. The latest contract addresses should be retrieved from this contract by making the appropriate calls.

### LendingPoolAddressesProviderRegistry

Contains a list of active `LendingPoolAddressesProvider` addresses, for different markets.

### aTokens

The yield-generating, tokenized representation of supplies used throughout the Aave protocol. They implement most of the standard ERC-20 token methods with slight modifications, as well as Aave-specific methods including:

- `scaledBalanceOf()`
- `getScaledUserBalanceAndSupply()`
- `scaledTotalSupply()`

All aTokens also implement EIP-2612, which via the `permit()` function enables single transaction approve + actions.

### Debt Tokens

The tokenized borrow positions used throughout the Aave protocol, issued as variable debt tokens and stable debt tokens. Most of the standard ERC-20 methods are disabled since debt tokens are non-transferable.

### Supporting Contracts

The following contracts should generally not be interacted with directly, but are used throughout the Aave Protocol via contract calls.

#### LendingPoolCollateralManager

Using `delegatecall` via the `LendingPool` contract, the `LendingPoolCollateralManager` implements actions involving the management of collateral in the protocol, including:

- `liquidationCall()`

This function should only be called via the main `LendingPool` contract.

#### LendingPoolConfigurator

Provides configuration functions for the `LendingPool` contract. It has a number of important functions, such as:

- Activates / Deactivates reserves
- Enables / Disables borrowing for a reserve
- Enables / Disables using a reserve as collateral
- Enables / Disables stable rate borrowing for a reserve
- Freezes / Unfreezes reserves
- Updates a reserve’s Loan to Value
- Updates a reserve’s liquidation threshold
- Updates a reserve’s liquidation bonus
- Updates a reserve’s decimals
- Updates a reserve’s interest rate strategy address
- Activates / Deactivates all functions of a Pool in emergencies

For all of the above functions, relevant events are emitted to the blockchain. Anyone can monitor these changes to know when values have been modified or added/removed.

#### Interest Rate Strategy

Holds the information needed to calculate and update the interest rates of specific reserves. Each contract stores the optimized base curves using the corresponding parameters of each currency. The parameters for the optimized base curves are:

- `baseVariableBorrowRate`
- `variableRateSlope1`
- `variableRateSlope2`
- `stableRateSlope1`
- `stableRateSlope2`

The interest rates are calculated depending on the available liquidity and the total borrowed amount.
