### Install with Foundry Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Install the Aave Address Book library using Foundry. ```bash forge install aave-dao/aave-address-book ``` -------------------------------- ### Solidity Import Example Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Demonstrates how to import and use Aave V3 addresses directly within Solidity contracts. This example shows how to get the Aave V3 Ethereum pool address. ```solidity import { AaveV3Ethereum } from "aave-address-book/AaveV3Ethereum.sol"; contract MyContract { function executeOnPool() external { address pool = AaveV3Ethereum.POOL; // Use pool address... } } ``` -------------------------------- ### Run Development Server Source: https://github.com/aave-dao/aave-address-book/blob/main/ui/README.md Use these commands to start the development server for the AAVE Address Book UI. Ensure you have Node.js and a package manager (npm, yarn, pnpm, or bun) installed. ```bash npm run dev ``` ```bash yarn dev ``` ```bash pnpm dev ``` ```bash bun dev ``` -------------------------------- ### Install Aave Address Book Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/README.md Install the Aave Address Book library using npm. This is the first step to using the library in your project. ```bash npm install @aave-dao/aave-address-book ``` -------------------------------- ### Full Governance Setup Import Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import governance modules and ABIs together for comprehensive governance interactions. ```typescript import { GovernanceV3Ethereum, GovernanceV3Polygon, GovernanceV3Arbitrum, } from "@aave/aave-address-book"; import { IGovernanceCore_ABI } from "@aave/aave-address-book/abis"; // Use together for governance interactions const governance = GovernanceV3Ethereum.GOVERNANCE; const abi = IGovernanceCore_ABI; ``` -------------------------------- ### Install Aave Address Book with Foundry Source: https://github.com/aave-dao/aave-address-book/blob/main/README.md Use this command to install the Aave Address Book package if you are using Foundry for your smart contract development. ```sh forge install aave-dao/aave-address-book ``` -------------------------------- ### Multi-Network Support Example Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Import and utilize network configurations for different Aave V3 networks like Ethereum, Polygon, and Arbitrum. This example shows how to access pool addresses and dynamically select a pool based on chain ID. ```typescript import { AaveV3Ethereum, AaveV3Polygon, AaveV3Arbitrum, } from "@aave-dao/aave-address-book"; const ethereumPool = AaveV3Ethereum.POOL; const polygonPool = AaveV3Polygon.POOL; const arbitrumPool = AaveV3Arbitrum.POOL; // Use with network-aware logic const getPool = (chainId: number) => { const networks = [AaveV3Ethereum, AaveV3Polygon, AaveV3Arbitrum]; return networks.find(n => n.CHAIN_ID === chainId)?.POOL; }; ``` -------------------------------- ### Viem Integration Example Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/abis.md Demonstrates how to integrate Aave ABIs with Viem to create a public client and interact with the Aave V3 Ethereum pool to retrieve the list of reserves. ```typescript import { createPublicClient, http } from 'viem'; import { ethereum } from 'viem/chains'; import { AaveV3Ethereum } from '@aave-dao/aave-address-book'; import { IPool_ABI } from '@aave-dao/aave-address-book/abis'; // Create client const client = createPublicClient({ chain: ethereum, transport: http(), }); // Read pool data const reserves = await client.readContract({ address: AaveV3Ethereum.POOL, abi: IPool_ABI, functionName: 'getReservesList', }); ``` -------------------------------- ### Main Entry Point Re-export Example Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Illustrates how the main entry point re-exports all submodules, allowing for cleaner imports. ```typescript // Main export file structure export * as GovernanceV3Ethereum from './GovernanceV3Ethereum'; export * as AaveV3Ethereum from './AaveV3Ethereum'; export * as MiscEthereum from './MiscEthereum'; // ... 100+ modules ``` ```typescript import { AaveV3Ethereum } from "@aave/aave-address-book"; // instead of import { AaveV3Ethereum } from "@aave/aave-address-book/AaveV3Ethereum"; ``` -------------------------------- ### Example: Static aTokens WETH Token Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/token-list.md An example of a static aToken entry for Aave Ethereum Static WETH on chain ID 1, tagged for Aave V3 and staticAT. ```typescript { chainId: 1, address: "0x252231882FB38481497f3C767469106297c8d93b", name: "Aave Ethereum Static WETH", decimals: 18, symbol: "staticAEthWETH", tags: ["staticAT", "aaveV3"], logoURI: "https://raw.githubusercontent.com/bgd-labs/web3-icons/main/icons/full/aaweth.svg" } ``` -------------------------------- ### Example: Wrapped Static aTokens WETH Token Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/token-list.md An example of a wrapped static aToken (Stata) entry for Aave Ethereum StataWETH on chain ID 1, tagged for Aave V3 and stataToken. ```typescript { chainId: 1, address: "0x0bfc9d54Fc184518A81162F8fB99c2eACa081202", name: "Aave Ethereum StataWETH", decimals: 18, symbol: "stataEthWETH", tags: ["stataToken", "aaveV3"], logoURI: "https://raw.githubusercontent.com/bgd-labs/web3-icons/main/icons/full/stata.svg" } ``` -------------------------------- ### Example: USD Coin (USDC) Token Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/token-list.md An example of an underlying asset token entry for USD Coin (USDC) on chain ID 1. ```typescript { chainId: 1, address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", name: "USD Coin", decimals: 6, symbol: "USDC", tags: ["underlying"], logoURI: "https://raw.githubusercontent.com/bgd-labs/web3-icons/main/icons/full/usdc.svg" } ``` -------------------------------- ### Example: Wrapped Ether (WETH) Token Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/token-list.md An example of an underlying asset token entry for Wrapped Ether (WETH) on chain ID 1. ```typescript { chainId: 1, address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", name: "Wrapped Ether", decimals: 18, symbol: "WETH", tags: ["underlying"], logoURI: "https://raw.githubusercontent.com/bgd-labs/web3-icons/main/icons/full/weth.svg" } ``` -------------------------------- ### Install Aave Address Book with Node.js Source: https://github.com/aave-dao/aave-address-book/blob/main/README.md Use this command to install the Aave Address Book package for your Node.js or TypeScript projects. ```sh npm install @aave-dao/aave-address-book ``` -------------------------------- ### Example: Aave Ethereum WETH (aEthWETH) Token Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/token-list.md An example of an interest-bearing token (aToken) entry for Aave Ethereum WETH on chain ID 1, tagged for Aave V3. ```typescript { chainId: 1, address: "0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8", name: "Aave Ethereum WETH", decimals: 18, symbol: "aEthWETH", tags: ["aTokenV3", "aaveV3"], logoURI: "https://raw.githubusercontent.com/bgd-labs/web3-icons/main/icons/full/aweth.svg" } ``` -------------------------------- ### Import Governance V3 Modules for Multiple Networks Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/supported-networks.md Import Governance V3 modules for various EVM-compatible networks. This example shows imports for Ethereum, Polygon, Arbitrum, and Base. ```typescript // All networks with Governance V3 import { GovernanceV3Ethereum, GovernanceV3Polygon, GovernanceV3Arbitrum, GovernanceV3Base, // ... etc } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Correct Asset Access After Checking Network Support Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Shows the correct approach to accessing assets by first ensuring the asset exists on the target network, preventing errors and undefined values. This example accesses the LINK asset on Ethereum V3. ```typescript const asset = AaveV3Ethereum.ASSETS.LINK; // ✓ exists ``` -------------------------------- ### Incorrect Import Example Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Demonstrates incorrect ways to import from the address book, which will result in undefined values or syntax errors. ```typescript // Default export does not exist import addressBook from "@aave/aave-address-book"; addressBook.AaveV3Ethereum; // undefined // Wrong syntax import AaveV3Ethereum from "@aave/aave-address-book"; ``` -------------------------------- ### Example: Variable Debt WETH Token Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/token-list.md An example of a debt token entry for Aave Ethereum Variable Debt WETH on chain ID 1, tagged for Aave V3. ```typescript { chainId: 1, address: "0xeA51d7853EEFb32b6ee06b1C12E6dcCA88Be0fFE", name: "Aave Ethereum Variable Debt WETH", decimals: 18, symbol: "variableDebtEthWETH", tags: ["debtToken", "aaveV3"], logoURI: "https://raw.githubusercontent.com/bgd-labs/web3-icons/main/icons/full/vweth.svg" } ``` -------------------------------- ### Example: Aave Ethereum USDC (aEthUSDC) Token Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/token-list.md An example of an interest-bearing token (aToken) entry for Aave Ethereum USDC on chain ID 1, tagged for Aave V3. ```typescript { chainId: 1, address: "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c", name: "Aave Ethereum USDC", decimals: 6, symbol: "aEthUSDC", tags: ["aTokenV3", "aaveV3"], logoURI: "https://raw.githubusercontent.com/bgd-labs/web3-icons/main/icons/full/ausdc.svg" } ``` -------------------------------- ### ABI Structure Example Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/abis.md Illustrates the standard structure of an ABI export from the Aave Address Book, including function, event, and error definitions. ```typescript export const [CONTRACT_NAME]_ABI = [ { type: 'function', name: 'functionName', inputs: [ { name: 'param1', type: 'uint256', internalType: 'uint256' }, // ... ], outputs: [ { name: '', type: 'address', internalType: 'address' }, // ... ], stateMutability: 'nonpayable' | 'payable' | 'pure' | 'view', }, // ... more functions { type: 'event', name: 'EventName', inputs: [ { name: 'indexed_param', type: 'address', indexed: true }, // ... ], }, // ... more events { type: 'error', name: 'ErrorName', inputs: [/* ... */], }, ]; ``` -------------------------------- ### Example: Staked Aave (stkAAVE) Token Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/token-list.md An example of a staking token entry for Aave staked Aave on chain ID 1, tagged as stkToken. ```typescript { chainId: 1, address: "0x4da27a545c0c5B758a6BA100e3a049001de870f5", name: "Aave staked Aave", decimals: 18, symbol: "stkAAVE", tags: ["stkToken"], logoURI: "https://raw.githubusercontent.com/bgd-labs/web3-icons/main/icons/full/stkaave.svg" } ``` -------------------------------- ### Checking Available Assets Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Shows how to get a list of available asset symbols for a specific network module (e.g., Aave V3 Ethereum) by accessing the keys of the `ASSETS` object. This helps in understanding which assets are supported. ```typescript const symbols = Object.keys(AaveV3Ethereum.ASSETS); console.log(symbols); // ['WETH', 'USDC', 'DAI', ...] ``` -------------------------------- ### Access Asset Configuration Details Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Get configuration details for a specific asset, such as USDC, including its underlying token, aToken, vToken addresses, and decimals. ```typescript const usdcConfig = AaveV3Ethereum.ASSETS.USDC; const usdcAddress = usdcConfig.UNDERLYING; // 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 const aUsdcAddress = usdcConfig.A_TOKEN; // 0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c const vUsdcAddress = usdcConfig.V_TOKEN; // 0x72E95b8931767C79bA4EeE721354d6E99a61D004 const decimals = usdcConfig.decimals; // 6 ``` -------------------------------- ### Import Protocol Versions for Ethereum and Polygon Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/supported-networks.md Import specific Aave protocol versions for Ethereum and Polygon networks. Ensure the '@aave-dao/aave-address-book' package is installed. ```typescript // Ethereum import { AaveV3Ethereum, AaveV2Ethereum } from "@aave-dao/aave-address-book"; // Polygon import { AaveV3Polygon, AaveV2Polygon } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Type-Safe Contract Interaction with Viem Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/abis.md Shows how Viem infers return types from ABIs, enabling type-safe contract calls. This example retrieves user account data from the Aave V3 Ethereum pool. ```typescript import { AaveV3Ethereum } from '@aave-dao/aave-address-book'; import { IPool_ABI } from '@aave-dao/aave-address-book/abis'; // Viem automatically infers return types from ABI const result = await client.readContract({ address: AaveV3Ethereum.POOL, abi: IPool_ABI, functionName: 'getUserAccountData', args: ['0x...'], // ^? Type: readonly [bigint, bigint, bigint, bigint, bigint, number] }); ``` -------------------------------- ### Getting a Contract Reference Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/COMPLETION_SUMMARY.txt Shows how to use the `getContractReference` utility function to retrieve a standardized reference for a contract, including its address and ABI. This is useful for consistent contract handling. ```typescript import { getContractReference } from "@aave/address-book"; const poolReference = getContractReference("AAVEPool", "ethereum"); console.log(poolReference); ``` -------------------------------- ### Get Address Book References Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/utilities.md Searches the address book for all entries matching a given address and chain ID. Use this to find all known roles or references for a specific address on a particular network. ```typescript import { getAddressBookReferences } from "@aave-dao/aave-address-book/utils"; // Find where Aave V3 Ethereum pool is referenced const references = getAddressBookReferences( "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", 1 ); // Output: ["AaveV3Ethereum.POOL"] // Find all references to a USDC address const usdcReferences = getAddressBookReferences( "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", 1 ); // Output: [ // "AaveV3Ethereum.ASSETS.USDC.UNDERLYING", // "AaveV2Ethereum.ASSETS.USDC.UNDERLYING", // ... other references // ] // Non-existent address returns empty array const empty = getAddressBookReferences( "0x0000000000000000000000000000000000000000", 1 ); // Output: [] ``` -------------------------------- ### Build Project with npm and forge Source: https://github.com/aave-dao/aave-address-book/blob/main/README.md Commands to build the project using npm for JavaScript/TypeScript dependencies and forge for Solidity contracts. ```sh npm run build ``` ```sh forge build ``` -------------------------------- ### Using the Token List Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/COMPLETION_SUMMARY.txt Shows how to import and utilize the token list, which contains metadata for various tokens supported by Aave. This is useful for DApp and wallet integrations. ```typescript import { tokenList } from "@aave/token-list"; const usdcToken = tokenList.find((token) => token.symbol === "USDC"); console.log(usdcToken); ``` -------------------------------- ### Correct Module Import (Exact Names) Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Demonstrates the correct way to import modules using their exact, case-sensitive names. This ensures that the specified contracts and configurations are correctly loaded. ```typescript import { AaveV3Ethereum } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Namespace Import for Utilities Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/utilities.md Illustrates importing all available utility functions from the module using a namespace import. ```typescript import * as utils from "@aave-dao/aave-address-book/utils"; utils.getAddressBookReferences(address, chainId); ``` -------------------------------- ### Configure RPC Connections with .env file Source: https://github.com/aave-dao/aave-address-book/blob/main/README.md Set up environment variables in a .env file to configure reliable RPC connections for different networks. This is useful for overriding default public RPCs. ```sh ETHERSCAN_API_KEY=your_key_here EXPLORER_PROXY=your_proxy ## RPC configuration # Per default the package uses the public rpcs available via viem # You can opt in to use private/different rpcs by setting the following environment variables RPC_=your_rpc_url ALCHEMY_API_KEY=your_key_here QUICKNODE_ENDPOINT_NAME=your_quicknode_endpoint_name QUICKNODE_TOKEN=your_quicknode_token ``` -------------------------------- ### Namespace Import for ABIs Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/abis.md Shows how to import all ABIs under a namespace using `import * as ABIs from '@aave-dao/aave-address-book/abis';`, allowing access to individual ABIs like `ABIs.IPool_ABI`. ```typescript import * as ABIs from '@aave-dao/aave-address-book/abis'; const poolAbi = ABIs.IPool_ABI; const aclAbi = ABIs.IACLManager_ABI; ``` -------------------------------- ### Price Feeds (Chainlink) Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Get addresses for Chainlink price feeds for common currency pairs like ETH/USD, USDC/USD, and AAVE/USD on Ethereum. ```typescript const ETH_USD = ChainlinkEthereum.ETH__USD; const USDC_USD = ChainlinkEthereum.USDC__USD; const AAVE_USD = ChainlinkEthereum.AAVE__USD; ``` -------------------------------- ### Importing Specific Modules Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Demonstrates the recommended practice of importing only the specific modules or contracts you need from the address book to improve build performance and reduce bundle size. ```typescript // ✅ Good import { AaveV3Ethereum } from "@aave-dao/aave-address-book"; // ❌ Avoid import * as addressBook from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Import Individual ABIs Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/abis.md Demonstrates importing specific ABIs, such as IPool_ABI and IACLManager_ABI, directly from the '@aave-dao/aave-address-book/abis' path. ```typescript import { IPool_ABI } from '@aave-dao/aave-address-book/abis'; import { IACLManager_ABI } from '@aave-dao/aave-address-book/abis'; ``` -------------------------------- ### Run Tests with npm and forge Source: https://github.com/aave-dao/aave-address-book/blob/main/README.md Commands to execute the test suites for the Aave Address Book using npm for node tests and forge for Solidity tests. ```sh npm test ``` ```sh forge test ``` -------------------------------- ### Getting a Specific Token from the List Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/COMPLETION_SUMMARY.txt Demonstrates how to retrieve a specific token's details from the Aave token list using its symbol. This is helpful for displaying token information in a user interface. ```typescript import { getToken } from "@aave/token-list"; const usdc = getToken("USDC", "ethereum"); console.log(usdc); ``` -------------------------------- ### Viem Address Type Definition Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Defines the `Address` type used throughout the library, which is an alias for Viem's `Address` type, representing a checksummed hexadecimal string starting with '0x'. ```typescript type Address = `0x${string}`; ``` -------------------------------- ### Importing Contract ABIs Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/INDEX.md Illustrates how to import specific contract ABIs (Application Binary Interfaces) from the address book. This is necessary for interacting with smart contracts using libraries like ethers.js or web3.js. ```typescript import { IPool_ABI } from "@aave-dao/aave-address-book/abis"; ``` -------------------------------- ### CommonJS Import for Utilities Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/utilities.md Shows how to import the `getAddressBookReferences` function in a CommonJS environment. ```javascript const { getAddressBookReferences } = require("@aave-dao/aave-address-book/utils"); ``` -------------------------------- ### Get Recent Supply Events from Aave V3 Ethereum Pool Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/abis.md This snippet shows how to retrieve recent 'Supply' events from the Aave V3 Ethereum pool using Viem and the Aave Address Book. ```typescript import { AaveV3Ethereum } from '@aave-dao/aave-address-book'; import { IPool_ABI } from '@aave-dao/aave-address-book/abis'; // Get recent deposits const logs = await client.getLogs({ address: AaveV3Ethereum.POOL, abi: IPool_ABI, eventName: 'Supply', fromBlock: 'latest' as const, }); ``` -------------------------------- ### Direct Import for ABIs Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Recommends importing specific ABIs directly rather than loading all ABIs from the abis module. This practice optimizes performance by only loading necessary data. ```typescript // ✅ Good - specific import import { IPool_ABI } from "@aave-dao/aave-address-book/abis"; // ❌ Avoid - loading all ABIs import * as ABIs from "@aave-dao/aave-address-book/abis"; ``` -------------------------------- ### Environment Variables Configuration Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/README.md Optional environment variables for configuring Etherscan API key, explorer proxy, RPC endpoints, and Alchemy/QuickNode providers. ```bash ETHERSCAN_API_KEY=your_key # For address verification EXPLORER_PROXY=proxy_url # Explorer access RPC_ETHEREUM=rpc_url # Network-specific RPC ALCHEMY_API_KEY=key # Alchemy provider QUICKNODE_API_KEY=key # QuickNode provider QUICKNODE_ENDPOINT_NAME=name # QuickNode provider QUICKNODE_TOKEN=token # QuickNode token ``` -------------------------------- ### Accessing Ecosystem Reserve Addresses Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/infrastructure-addresses.md Demonstrates how to import and access ecosystem reserve addresses for different networks like Ethereum and Arbitrum. ```typescript import { MiscEthereum, MiscArbitrum } from "@aave-dao/aave-address-book"; const ethReserve = MiscEthereum.ECOSYSTEM_RESERVE; const arbReserve = MiscArbitrum.ECOSYSTEM_RESERVE; ``` -------------------------------- ### Validating Address Format with Viem Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Demonstrates how to use Viem's `getAddress` function to ensure that an address obtained from the address book is correctly formatted and checksummed. This is a crucial step for address validation. ```typescript import { getAddress } from "viem"; const poolAddress = AaveV3Ethereum.POOL; const checksummed = getAddress(poolAddress); console.log(checksummed); // 0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2 ``` -------------------------------- ### Accessing Asset Addresses in Solidity Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Demonstrates how to import and use specific Aave V3 Ethereum addresses for assets and the pool in Solidity. Ensure you have the correct contract interfaces imported. ```solidity import { AaveV3Ethereum } from "aave-address-book/AaveV3Ethereum.sol"; contract Deposit { function depositUSDC(uint256 amount) external { address usdc = AaveV3Ethereum.ASSETS.USDC.UNDERLYING; address pool = AaveV3Ethereum.POOL; IERC20(usdc).approve(pool, amount); IPool(pool).supply(usdc, amount, msg.sender, 0); } } ``` -------------------------------- ### Importing Main Modules (CommonJS and ES Module) Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import Aave V3 and V2 Ethereum addresses using require for CommonJS or import for ES Modules. ```typescript const { AaveV3Ethereum, AaveV2Ethereum } = require("@aave-dao/aave-address-book"); // or import { AaveV3Ethereum, AaveV2Ethereum } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Import Infrastructure Modules (Misc, Chainlink, Safety Module, GHO) Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/supported-networks.md Import various infrastructure modules like Misc, Chainlink, Safety Module, and GHO. Note that some modules, like Safety Module, are network-specific (Ethereum only). ```typescript // All networks have Misc modules import { MiscEthereum, MiscPolygon, MiscArbitrum } from "@aave-dao/aave-address-book"; // Chainlink available on most networks import { ChainlinkEthereum, ChainlinkArbitrum } from "@aave-dao/aave-address-book"; // Safety Module (Ethereum only) import { AaveSafetyModule } from "@aave-dao/aave-address-book"; // GHO on specific networks import { GhoEthereum, GhoBase, GhoArbitrum } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Wildcard Import of All Utilities Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import all utilities using a wildcard import. ```typescript import * as utils from "@aave-dao/aave-address-book/utils"; const refs = utils.getAddressBookReferences(address, chainId); ``` -------------------------------- ### Combined Address and ABI Import Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/abis.md Illustrates importing both contract addresses (e.g., AaveV3Ethereum) and their corresponding ABIs (e.g., IPool_ABI) for contract interaction. ```typescript import { AaveV3Ethereum } from '@aave-dao/aave-address-book'; import { IPool_ABI } from '@aave-dao/aave-address-book/abis'; // Use together for contract interaction const poolAddress = AaveV3Ethereum.POOL; const poolAbi = IPool_ABI; ``` -------------------------------- ### Accessing Contract ABIs Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/COMPLETION_SUMMARY.txt Demonstrates how to access the Application Binary Interfaces (ABIs) for Aave protocol contracts. This is crucial for interacting with contracts using libraries like Viem. ```typescript import { getContract } from "@aave/contract-helpers"; import { getAddressBook } from "@aave/address-book"; import { Viem } from "@aave/contract-helpers"; const addressBook = getAddressBook("ethereum"); const provider = new Viem({ rpc: "YOUR_RPC_URL", }); const lendingPoolAbi = addressBook.abis.lendingPool; const lendingPoolContract = getContract({ address: addressBook.poolAddresses.AAVEPool, abi: lendingPoolAbi, provider, }); console.log(lendingPoolContract); ``` -------------------------------- ### Access Governance V3 Networks Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/supported-networks.md Lists governance networks and demonstrates accessing the voting machine for cross-chain voting. Ensure the relevant governance modules are imported. ```typescript const governanceNetworks = [ GovernanceV3Ethereum, GovernanceV3Polygon, GovernanceV3Arbitrum, // ... all others ]; // Cross-chain voting const voting = GovernanceV3Ethereum.VOTING_MACHINE; ``` -------------------------------- ### Solidity Integration for Contract Interaction Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/README.md Shows how to directly import Aave protocol addresses into Solidity contracts for use in smart contract development. ```solidity import { AaveV3Ethereum } from "aave-address-book/AaveV3Ethereum.sol"; contract MyContract { function depositToAave() external { address pool = AaveV3Ethereum.POOL; // Use pool address... } } ``` -------------------------------- ### Infrastructure Utilities Import Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import infrastructure utilities like miscellaneous contracts and price feed addresses for combined usage. ```typescript import { MiscEthereum, ChainlinkEthereum, } from "@aave/aave-address-book"; import { getAddressBookReferences } from "@aave/aave-address-book/utils"; // Combined utilities and infrastructure const reserve = MiscEthereum.ECOSYSTEM_RESERVE; const oracle = ChainlinkEthereum.ETH__USD; ``` -------------------------------- ### Correct Usage of V3 Governance Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Demonstrates the correct way to import and use V3 governance contracts, ensuring you are using the current and supported versions for operations like accessing the voting machine. ```typescript import { GovernanceV3Ethereum } from "@aave-dao/aave-address-book"; const voting = GovernanceV3Ethereum.VOTING_MACHINE; ``` -------------------------------- ### Generate Addresses with npm script Source: https://github.com/aave-dao/aave-address-book/blob/main/README.md Run this npm script to fetch and generate the latest smart contract addresses from various on-chain registries. This is part of the development workflow. ```sh npm run generate:addresses ``` -------------------------------- ### Importing Address Book Modules Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/COMPLETION_SUMMARY.txt Demonstrates how to import specific modules from the Aave Address Book. This is useful for organizing your project and only importing necessary components. ```typescript import { getAddressBook } from "@aave/address-book"; const addressBook = getAddressBook(); ``` -------------------------------- ### Import Token List Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/overview.md Import the standardized ERC-1077 token list format, which includes metadata for all Aave-related tokens. ```typescript import tokenList from "@aave-dao/aave-address-book/tokenlist"; ``` -------------------------------- ### Named Import for Utilities Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/utilities.md Demonstrates how to import the `getAddressBookReferences` function using a named import. ```typescript import { getAddressBookReferences } from "@aave-dao/aave-address-book/utils"; ``` -------------------------------- ### Importing Addresses for Multiple Networks Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/INDEX.md Shows how to import contract addresses for multiple networks simultaneously. This is useful when your application needs to support or reference addresses across different chains. ```typescript import { AaveV3Ethereum, AaveV3Polygon } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Multi-Network Import Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import modules for multiple networks simultaneously and iterate over them for cross-chain operations. ```typescript import { AaveV3Ethereum, AaveV3Polygon, AaveV3Arbitrum, } from "@aave/aave-address-book"; const networks = [ { module: AaveV3Ethereum, chainId: 1 }, { module: AaveV3Polygon, chainId: 137 }, { module: AaveV3Arbitrum, chainId: 42161 }, ]; networks.forEach(({ module, chainId }) => { console.log(`Chain ${chainId}: ${module.POOL}`); }); ``` -------------------------------- ### Deposit to Aave V3 Ethereum Pool Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/abis.md This snippet demonstrates how to approve a token for deposit into the Aave V3 Ethereum pool using Viem and the Aave Address Book. ```typescript import { publicClient, walletClient } from './viem'; import { AaveV3Ethereum } from '@aave-dao/aave-address-book'; import { IAToken_ABI } from '@aave-dao/aave-address-book/abis'; // Deposit to aToken const hash = await walletClient.writeContract({ address: AaveV3Ethereum.ASSETS.USDC.A_TOKEN, abi: IAToken_ABI, functionName: 'approve', args: [AaveV3Ethereum.POOL, 1000n * 10n ** 6n], account: userAddress, }); ``` -------------------------------- ### Importing ABI Module Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import contract ABIs from the ABIs sub-export for type-safe contract interactions. ```typescript import { IPool_ABI, IAToken_ABI, IGovernanceCore_ABI, // ... 50+ contract ABIs } from "@aave-dao/aave-address-book/abis"; ``` -------------------------------- ### Importing Utilities Module Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import the getAddressBookReferences function from the utilities sub-export to retrieve address book references. ```typescript import { getAddressBookReferences } from "@aave-dao/aave-address-book/utils"; // Import type import type { Address } from "viem"; const references = getAddressBookReferences( "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2", 1 ); ``` -------------------------------- ### Import Legacy Governance V2 Module Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/supported-networks.md Import the legacy Governance V2 module, which is specific to the Ethereum network. ```typescript // Legacy Governance V2 (Ethereum only) import { AaveGovernanceV2 } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Wildcard Import of All ABIs Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import all contract ABIs using a wildcard import. This is acceptable for bulk ABI imports. ```typescript import * as ABIs from "@aave-dao/aave-address-book/abis"; const poolAbi = ABIs.IPool_ABI; const tokenAbi = ABIs.IAToken_ABI; ``` -------------------------------- ### Aave Contract Interaction with Viem Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/README.md Interact with Aave contracts by reading data, such as the list of reserves, using Viem and the provided contract ABIs. Ensure you have a Viem public client and the relevant ABI imported. ```typescript import { publicClient } from "viem"; import { AaveV3Ethereum } from "@aave-dao/aave-address-book"; import { IPool_ABI } from "@aave-dao/aave-address-book/abis"; const reserves = await publicClient.readContract({ address: AaveV3Ethereum.POOL, abi: IPool_ABI, functionName: "getReservesList", }); ``` -------------------------------- ### Wildcard Import of All Address Modules Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import all address modules using a wildcard import. This is not recommended for production use. ```typescript import * as addressBook from "@aave-dao/aave-address-book"; const pool = addressBook.AaveV3Ethereum.POOL; const gov = addressBook.GovernanceV3Ethereum.GOVERNANCE; ``` -------------------------------- ### Asset Configuration Structure Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Defines the structure for asset configurations, including decimals, IDs, and addresses for underlying tokens, aTokens, vTokens, and other related contracts. Also includes interest rate strategy, oracle, and static aToken details. ```typescript ASSETS: { SYMBOL: { decimals: 6 | 18, // Token decimals id: 0, // Internal ID UNDERLYING: "0x...", // Token address A_TOKEN: "0x...", // Deposit receipt V_TOKEN: "0x...", // Variable debt S_TOKEN?: "0x...", // Stable debt (optional) INTEREST_RATE_STRATEGY: "0x...", // Rate model ORACLE: "0x...", // Price feed STATIC_A_TOKEN?: "0x...", // ERC-4626 wrapped STATA_TOKEN?: "0x...", // Wrapped static } } ``` -------------------------------- ### Lookup Asset Configuration Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/overview.md Retrieve the configuration for a specific asset, including its deposit/borrow token addresses and other relevant details. This allows for easy access to asset-specific contract information. ```typescript // Get deposit token address for USDC const usdcConfig = AaveV3Ethereum.ASSETS.USDC; const aUSDCAddress = usdcConfig.A_TOKEN; ``` -------------------------------- ### Importing Protocol Module Addresses Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import contract addresses and asset configurations for specific Aave protocol versions and networks. ```typescript import { AaveV3Ethereum, AaveV3Polygon, AaveV3Arbitrum, AaveV2Ethereum, AaveV4Ethereum, } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Correct Named Export Usage Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Demonstrates the correct way to use named exports from the Aave Address Book library and its sub-modules. ```typescript import { AaveV3Ethereum } from "@aave-dao/aave-address-book"; import { IPool_ABI } from "@aave-dao/aave-address-book/abis"; import { getAddressBookReferences } from "@aave-dao/aave-address-book/utils"; ``` -------------------------------- ### Import and Use Aave Addresses in Solidity Source: https://github.com/aave-dao/aave-address-book/blob/main/README.md Import specific Aave protocol versions and contracts to access their addresses within your Solidity smart contracts. Ensure the correct import path is used. ```solidity import { AaveV3Ethereum } from "aave-address-book/AaveV3Ethereum.sol"; import { AaveV2Avalanche } from "aave-address-book/AaveV2Avalanche.sol"; import { AaveGovernanceV2 } from "aave-address-book/AaveGovernanceV2.sol"; contract Example { function execute() external { address pool = AaveV3Ethereum.POOL; // ... } } ``` -------------------------------- ### Import Protocol Versions for Layer 2 Networks Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/supported-networks.md Import Aave V3 protocol versions for various Layer 2 networks. This pattern applies to networks like Arbitrum, Optimism, and Base. ```typescript // All Layer 2s import { AaveV3Arbitrum, AaveV3Optimism, AaveV3Base } from "@aave-dao/aave-address-book"; ``` -------------------------------- ### Minimal Import of Aave Address Book Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/INDEX.md Demonstrates how to import and access a specific contract address (POOL) for a given network (AaveV3Ethereum). This is useful for direct contract interaction. ```typescript import { AaveV3Ethereum } from "@aave-dao/aave-address-book"; const pool = AaveV3Ethereum.POOL; ``` -------------------------------- ### Looking Up a Specific Address Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/COMPLETION_SUMMARY.txt Illustrates how to find the address of a specific contract, like the AAVE Pool on Ethereum Mainnet. This is a common task when interacting with Aave protocol contracts. ```typescript import { getAddressBook } from "@aave/address-book"; const addresses = getAddressBook("ethereum"); const aavePoolAddress = addresses.poolAddresses.AAVEPool; console.log(aavePoolAddress); ``` -------------------------------- ### Importing Token List Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import the standard ERC-1077 token list from the tokenlist sub-export. ```typescript import tokenList from "@aave-dao/aave-address-book/tokenlist"; // Object with standard token list structure console.log(tokenList.name); // "Aave token list" console.log(tokenList.tokens); // Array of token definitions ``` -------------------------------- ### Minimal Production Import Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Import only the specific module you need for production use to minimize bundle size. ```typescript // Only import what you need import { AaveV3Ethereum } from "@aave/aave-address-book"; const poolAddress = AaveV3Ethereum.POOL; ``` -------------------------------- ### Importing Sub-Module Exports Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/README.md Importing utility functions, contract ABIs, and token lists from specific sub-modules of the Aave Address Book library. ```typescript import { getAddressBookReferences } from "@aave-dao/aave-address-book/utils"; import { IPool_ABI } from "@aave-dao/aave-address-book/abis"; import tokenList from "@aave-dao/aave-address-book/tokenlist"; ``` -------------------------------- ### Caching Module References Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/quick-reference.md Illustrates a performance tip by caching frequently used contract addresses or constants at the module level to avoid repeated lookups within functions. This improves efficiency. ```typescript // ✅ Good - cache at module level const POOL = AaveV3Ethereum.POOL; // ❌ Avoid - repeated lookups function getPool() { return AaveV3Ethereum.POOL; // redundant lookup } ``` -------------------------------- ### Module Structure Exports Source: https://github.com/aave-dao/aave-address-book/blob/main/_autodocs/imports-and-exports.md Shows the typical structure of exports within a protocol module, including smart contract addresses, asset configurations, and network identifiers. ```typescript // Smart contract addresses export const POOL = "0x..."; export const ORACLE = "0x..."; export const POOL_ADDRESSES_PROVIDER = "0x..."; // ... more addresses // Asset configurations export const ASSETS = { USDC: { decimals: 6, id: 3, UNDERLYING: "0x...", A_TOKEN: "0x...", V_TOKEN: "0x...", INTEREST_RATE_STRATEGY: "0x...", ORACLE: "0x...", STATIC_A_TOKEN?: "0x...", STATA_TOKEN?: "0x...", }, // ... more assets }; // Network identifier export const CHAIN_ID = 1; ```