Skip to content

feat: add flexible BaseExecutor and BaseLeverageExecutor contracts#88

Open
Schlagonia wants to merge 1 commit intomasterfrom
feat/base-executor-contracts
Open

feat: add flexible BaseExecutor and BaseLeverageExecutor contracts#88
Schlagonia wants to merge 1 commit intomasterfrom
feat/base-executor-contracts

Conversation

@Schlagonia
Copy link
Collaborator

Summary

This PR introduces flexible base contracts for strategies that need to perform complex operations through arbitrary calldata execution, particularly for leverage looping and borrowing activities.

Changes

  • BaseExecutor: Minimal generic execution framework with customizable hooks
  • BaseLeverageExecutor: Extends BaseExecutor with leverage-specific functionality
  • Comprehensive interfaces for both contracts
  • Documentation: Detailed README with usage examples and security guide

Architecture

BaseHealthCheck
    └── BaseExecutor (generic execution with hooks)
            ├── YourCustomStrategy (for non-leverage strategies)
            └── BaseLeverageExecutor (adds leverage features)
                    └── YourLeverageStrategy

Key Features

BaseExecutor

  • Simple target whitelisting via boolean mapping
  • Pre/post execution hooks for custom verification
  • Batch execution support with configurable failure handling
  • Executor role management for external callers
  • Emergency pause mechanism

BaseLeverageExecutor

  • Leverage ratio tracking and enforcement (max/target ratios)
  • Automated leverage verification after execution
  • Total assets monitoring with configurable loss protection
  • Emergency deleveraging capabilities
  • Minimum asset balance requirements

Security Features

  • ✅ Strict target whitelisting (management-only configuration)
  • ✅ ReentrancyGuard on all execution functions
  • ✅ Customizable verification through hooks
  • ✅ Executor role access control
  • ✅ Emergency pause and deleverage functions
  • ✅ No hardcoded routes or logic - fully flexible

Testing Checklist

  • Test target whitelisting works correctly
  • Test execution fails for non-whitelisted targets
  • Test pause mechanism blocks all executions
  • Test executor role permissions
  • Test leverage limits are enforced (BaseLeverageExecutor)
  • Test custom verification hooks trigger correctly
  • Test batch execution with mixed success/failure scenarios
  • Test emergency functions under stress conditions
  • Fuzz test with random calldata to whitelisted targets

Notes

The design intentionally separates generic execution logic (BaseExecutor) from leverage-specific functionality (BaseLeverageExecutor) to provide maximum flexibility. Strategies can choose which base to inherit from based on their needs.

🤖 Generated with Claude Code

- BaseExecutor: Minimal generic execution framework with hooks
  - Simple target whitelisting via boolean mapping
  - Pre/post execution hooks for custom verification
  - Batch execution support with failure handling
  - Executor role management for external callers
  - Emergency pause mechanism

- BaseLeverageExecutor: Extends BaseExecutor for leverage strategies
  - Leverage ratio tracking and enforcement
  - Automated leverage verification after execution
  - Total assets monitoring with loss protection
  - Emergency deleveraging capabilities
  - Configurable min asset balance and max execution loss

- Comprehensive interfaces for both contracts
- Detailed README with usage examples and security guide

Security features:
- Strict target whitelisting
- ReentrancyGuard on all execution functions
- Customizable verification hooks
- Management-only configuration
- Emergency controls

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant