The system follows a modular architecture where each protocol integration is implemented as a separate module. This design ensures:
- Isolation of protocol-specific code
- Easy maintenance and updates
- Independent deployment capabilities
- Clear separation of concerns
Each module (protocol) must follow this minimal structure:
your-module/
├── functions/
│ ├── index.ts
│ ├── your-function.ts
├── index.ts
├── package.json
├── tools.ts
└── README.md
-
functions/
: Core implementation- One function per file
- Clear single responsibility
- Standardized error handling
- Example:
depositTokens.ts
,withdrawTokens.ts
-
Root Files:
tools.ts
: LLM function definitionsindex.ts
: Public module APIREADME.md
: Documentation and examples
- Single Responsibility: Each function should have a single purpose.
- Consistency: Follow the same patterns and structures as existing modules.
- Reusability: Utilize shared utilities and types to avoid duplication.
- Error Handling: Centralize error handling using
toResult
and consistent messaging.