- Create virtual environment:
uv venv - Activate virtual environment:
source .venv/bin/activate(On Windows:.venv\Scripts\activate) - Install dependencies:
- Regular installation:
uv pip install . - Development installation:
uv pip install -e ".[dev]"
- Regular installation:
- Environment setup:
cp .env.example .env(then edit with your API keys)
- Run script:
python <protocol>/main.py- Example:
python aave/main.py
- Example:
- Format code:
uv run ruff format . - Lint code:
uv run ruff check . - Fix fixable lint issues:
uv run ruff check --fix . - Type checking:
uv run mypy . - use .env file to load API keys and other environment variables
- Always pull latest main branch
- Imports: Use ruff for organizing imports (stdlib, third-party, local)
- Formatting: Use ruff format with line length 120
- Typing: Use type hints for all functions (parameters and return values)
- Docstrings: Google style docstrings for all functions and classes
- Naming:
- Snake case for functions/variables (
process_assets) - UPPER_CASE for constants (
THRESHOLD_UR) - PascalCase for classes (
ChainManager)
- Snake case for functions/variables (
- Error handling: Use specific exceptions with meaningful error messages
- Web3: Use ChainManager for connections, batch requests whenever possible
- Configuration: Move hardcoded values to configuration files or env variables
- Logging: Use structured logging instead of print statements
- Testing: Write unit tests for utility functions and integration tests for protocols
- Create custom exception types for domain-specific errors
- Extract repeated patterns into utility functions. Try to keep utility functions small and focused on a single task and store in utils folder.
- Use dataclasses for structured data
- Add proper type annotations to improve IDE support and catch errors
- Keep files small and focused on a single task. If a file is too large, split it into smaller files.
- Ask questions if you are not sure about the code. Ask for clarification if needed before writing the code.
- always print full addresses with links instead of truncated ones.