|
1 | 1 | # Aave V4 |
2 | 2 |
|
| 3 | +[](https://codecov.io/gh/aave/aave-v4) |
| 4 | + |
| 5 | +A unified liquidity layer and modular architecture that enhances capital efficiency, scalability, and risk management. |
| 6 | + |
| 7 | +## Table of Contents |
| 8 | + |
| 9 | +- [Documentation](#documentation) |
| 10 | +- [Architecture](#architecture) |
| 11 | +- [Repository Structure](#repository-structure) |
| 12 | +- [Dependencies](#dependencies) |
| 13 | +- [Development](#development) |
| 14 | +- [Security](#security) |
| 15 | + |
| 16 | +## Documentation |
| 17 | + |
| 18 | +- [Aave V4 Overview](./docs/overview.md) |
| 19 | + |
| 20 | +## Architecture |
| 21 | + |
| 22 | +The Aave V4 architecture follows a modular **hub-and-spoke design** that separates liquidity management from user-facing operations and collateralization. |
| 23 | + |
| 24 | +## Repository Structure |
| 25 | + |
| 26 | +``` |
| 27 | +aave-v4/ |
| 28 | +├── src/ # Main source code |
| 29 | +│ ├── hub/ # Hub contracts and interfaces |
| 30 | +│ ├── spoke/ # Spoke contracts and interfaces |
| 31 | +│ ├── position-manager/ # Position Managers, including gateway contracts |
| 32 | +│ ├── libraries/ # Shared libraries (math, types) |
| 33 | +│ ├── utils/ # Utility contracts (Multicall, etc.) |
| 34 | +│ └── dependencies/ # Dependencies (Chainlink, OpenZeppelin, etc.) |
| 35 | +├── tests/ # Test suite |
| 36 | +│ ├── unit/ # Unit tests |
| 37 | +│ ├── gas/ # Gas snapshot tests |
| 38 | +│ ├── invariant/ # Invariant tests |
| 39 | +│ ├── misc/ # Symbolic tests, prototype development |
| 40 | +│ └── Base.t.sol # Base test setup |
| 41 | +├── scripts/ # Deployment scripts |
| 42 | +├── snapshots/ # Gas snapshots |
| 43 | +└── lib/ # Foundry dependencies |
| 44 | +``` |
| 45 | + |
3 | 46 | ## Dependencies |
4 | 47 |
|
5 | | -- Foundry, [how-to install](https://book.getfoundry.sh/getting-started/installation) (we recommend also update to the last version with `foundryup`) |
6 | | -- Node, [how-to install](https://nodejs.org/en/download) |
7 | | -- Lcov |
8 | | - - Optional, only needed for coverage testing |
9 | | - - For Ubuntu, you can install via `apt install lcov` |
10 | | - - For Mac, you can install via `brew install lcov` |
| 48 | +### Required |
| 49 | + |
| 50 | +- **[Foundry](https://book.getfoundry.sh/getting-started/installation)** - Development framework |
| 51 | + ```bash |
| 52 | + curl -L https://foundry.paradigm.xyz | bash |
| 53 | + foundryup # Update to latest version |
| 54 | + ``` |
| 55 | +- **[Node.js](https://nodejs.org/en/download)** - For linting and tooling |
| 56 | + |
| 57 | + ```bash |
| 58 | + # Verify installation |
| 59 | + node --version |
| 60 | + yarn --version |
| 61 | + # Install dependencies |
| 62 | + yarn install |
| 63 | + ``` |
| 64 | + |
| 65 | +### Optional |
| 66 | + |
| 67 | +- **Lcov** - For coverage reports |
| 68 | + |
| 69 | + ```bash |
| 70 | + # Ubuntu |
| 71 | + sudo apt install lcov |
| 72 | + |
| 73 | + # macOS |
| 74 | + brew install lcov |
| 75 | + ``` |
| 76 | + |
| 77 | +### Dependency Strategy |
| 78 | + |
| 79 | +Dependencies are located in the `src/dependencies` subfolder rather than managed through external package managers. This approach: |
| 80 | + |
| 81 | +- Mitigates supply chain attack vectors |
| 82 | +- Ensures dependency immutability |
| 83 | +- Minimizes installation overhead |
| 84 | +- Provides simplified version control and auditability |
11 | 85 |
|
12 | | -## Setup |
| 86 | +## Quickstart |
13 | 87 |
|
14 | | -```sh |
| 88 | +### 1. Clone the Repository |
| 89 | + |
| 90 | +```bash |
| 91 | +git clone https://github.com/aave/aave-v4.git |
| 92 | +cd aave-v4 |
| 93 | +``` |
| 94 | + |
| 95 | +### 2. Install Dependencies |
| 96 | + |
| 97 | +```bash |
| 98 | +# Copy environment template and populate |
15 | 99 | cp .env.example .env |
| 100 | + |
| 101 | +# Install Foundry dependencies |
16 | 102 | forge install |
17 | | -# required for linting |
| 103 | + |
| 104 | +# Install Node.js dependencies (required for linting) |
18 | 105 | yarn install |
19 | 106 | ``` |
20 | 107 |
|
21 | | -## Tests |
| 108 | +### 3. Build Contracts |
| 109 | + |
| 110 | +```bash |
| 111 | +forge build |
| 112 | +``` |
| 113 | + |
| 114 | +## Development |
| 115 | + |
| 116 | +### Testing |
| 117 | + |
| 118 | +- **Run full test suite**: `make test` or `forge test -vvv` |
| 119 | +- **Run specific test file**: `forge test --match-contract ...` |
| 120 | +- **Run with gas reporting**: `make gas-report` |
| 121 | +- **Generate coverage report**: `make coverage` |
| 122 | + |
| 123 | +### Code Quality |
| 124 | + |
| 125 | +- **Check contract sizes**: `forge build --sizes` |
| 126 | +- **Check linting**: `yarn lint` |
| 127 | +- **Fix linting issues**: `yarn lint:fix` |
| 128 | +- **Generate Rust bindings**: `yarn rs:generate` |
| 129 | + |
| 130 | +### Gas Snapshots |
| 131 | + |
| 132 | +Gas snapshots are automatically generated and stored in the `snapshots/` directory. To update snapshots: |
| 133 | + |
| 134 | +```bash |
| 135 | +make gas-report |
| 136 | +``` |
| 137 | + |
| 138 | +Snapshot files generated: |
| 139 | + |
| 140 | +- `Hub.Operations.json`: Gas for Hub actions or treasury operations invoked by Spokes. |
| 141 | +- `Spoke.Operations.json`: Gas for user-facing Spoke operations. |
| 142 | +- `Spoke.Operations.ZeroRiskPremium.json`: Same scenarios as `Spoke.Operations.json` but with Collateral Risk set to 0, to show baseline gas excluding risk-premium computation. |
| 143 | +- `Spoke.Getters.json`: Gas for getters across different combinations of supplies/borrows. |
| 144 | +- `NativeTokenGateway.Operations.json`: Gas for native-asset (ETH) gateway flows. |
| 145 | +- `SignatureGateway.Operations.json`: Gas for EIP-712 meta-transactions. |
| 146 | + |
| 147 | +## Security |
22 | 148 |
|
23 | | -- To run the full test suite: `make test` |
24 | | -- To re-generate the coverage report: `make coverage` |
| 149 | +- **Audit Reports**: [TBD] |
| 150 | +- **Security Policy**: [TBD] |
| 151 | +- **Bug Bounty**: [TBD] |
0 commit comments