Skip to content

feat(defi): implement dynamic protocol adapter registry and auto-disc…#16

Merged
memplethee-lab merged 1 commit into
SourceXXL:mainfrom
shadrach68:defiModule
Jun 20, 2026
Merged

feat(defi): implement dynamic protocol adapter registry and auto-disc…#16
memplethee-lab merged 1 commit into
SourceXXL:mainfrom
shadrach68:defiModule

Conversation

@shadrach68

Copy link
Copy Markdown
Contributor

Description

This PR refactors the DeFi protocol adapter registration process to use a dynamic discovery mechanism. Previously, adding a new protocol required manual wiring and constructor updates. This update introduces a plugin-like architecture, allowing the application to auto-discover and expose adapters cleanly.

Changes Made

  • Dynamic Registry: Refactored ProtocolRegistry to allow runtime registration of adapters via a generic register() method and introduced the ProtocolAdapterMetadata interface.
  • Auto-Discovery: Updated DeFiModule to leverage NestJS's DiscoveryService. It now automatically scans and registers any provider implementing the ProtocolAdapter interface during the onModuleInit lifecycle hook.
  • API Exposure: Added a new GET /defi/protocols endpoint in DeFiController that returns a list of all currently supported protocols. It dynamically calculates capabilities based on implemented methods (e.g., borrow, stake, swap).

Impact

Adding a new protocol (e.g., Uniswap, Yearn) to the DeFi module is now completely plug-and-play. Developers only need to:

  1. Create the adapter class.
  2. Add the adapter to the DeFiModule providers array.
    No changes to the registry class or module constructors are required.

Testing

  • Verified AaveAdapter and CompoundAdapter are automatically discovered and registered on application start.
  • Confirmed GET /defi/protocols correctly returns the metadata and capabilities of all registered adapters.

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