Skip to content

feat: protocol adapter registry & strategy discovery#344

Merged
OthmanImam merged 1 commit into
StellAIverse:mainfrom
Ibinola:feat/issue-298-protocol-adapter-registry
Jun 23, 2026
Merged

feat: protocol adapter registry & strategy discovery#344
OthmanImam merged 1 commit into
StellAIverse:mainfrom
Ibinola:feat/issue-298-protocol-adapter-registry

Conversation

@Ibinola

@Ibinola Ibinola commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the Protocol Adapter Registry and Strategy Discovery pattern for the defi module as required by issue #298.

Implementation Details

New Files

  • src/defi/protocols/protocol-registry.service.ts — New ProtocolRegistry service with:
    • register(adapter) — registers any ProtocolAdapter by its name
    • getAdapter(protocolName: string) — string-based runtime lookup
    • getAllAdapters() — returns all registered adapters
    • listProtocols() — returns ProtocolAdapterMetadata[] for the endpoint
    • isSupported(protocolName) — check support by name

Modified Files

  • src/defi/protocols/protocol-adapter.interface.ts — Added ProtocolAdapterMetadata interface and metadata field to ProtocolAdapter
  • src/defi/protocols/aave.adapter.ts — Implements metadata with name, chains, capabilities
  • src/defi/protocols/compound.adapter.ts — Implements metadata with name, chains, capabilities
  • src/defi/protocols/protocol-registry.ts — Replaced with re-export to maintain backward compatibility for existing service imports
  • src/defi/defi.module.ts — Implements OnModuleInit: auto-registers AaveAdapter and CompoundAdapter via ProtocolRegistry.register()
  • src/defi/defi.controller.ts — Added GET /defi/protocols endpoint returning available protocols

Adding a New Protocol

To add a new adapter (e.g., Uniswap), only two steps are needed:

  1. Create src/defi/protocols/uniswap.adapter.ts implementing ProtocolAdapter
  2. Add it to DeFiModule providers and inject + register in onModuleInit()

No changes to ProtocolRegistry required.

Validation Results

  • npm run build — webpack compiled successfully

Closes

Closes #298

- Add ProtocolAdapterMetadata interface to protocol-adapter.interface.ts
- Create ProtocolRegistry service with register(), getAdapter(string),
  getAllAdapters(), listProtocols(), and isSupported() methods
- Add metadata property to AaveAdapter and CompoundAdapter
- Wire DeFiModule.onModuleInit() to auto-register all adapters
- Add GET /defi/protocols endpoint listing available protocols
- Keep old protocol-registry.ts as re-export for backward compat
@OthmanImam
OthmanImam merged commit 8a7fc34 into StellAIverse:main Jun 23, 2026
1 check passed
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.

Align defi Module — Protocol Adapter Registry & Strategy Discovery

2 participants