feat: protocol adapter registry & strategy discovery#344
Merged
OthmanImam merged 1 commit intoJun 23, 2026
Merged
Conversation
- 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
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the Protocol Adapter Registry and Strategy Discovery pattern for the
defimodule as required by issue #298.Implementation Details
New Files
src/defi/protocols/protocol-registry.service.ts— NewProtocolRegistryservice with:register(adapter)— registers anyProtocolAdapterby itsnamegetAdapter(protocolName: string)— string-based runtime lookupgetAllAdapters()— returns all registered adapterslistProtocols()— returnsProtocolAdapterMetadata[]for the endpointisSupported(protocolName)— check support by nameModified Files
src/defi/protocols/protocol-adapter.interface.ts— AddedProtocolAdapterMetadatainterface andmetadatafield toProtocolAdaptersrc/defi/protocols/aave.adapter.ts— Implementsmetadatawith name, chains, capabilitiessrc/defi/protocols/compound.adapter.ts— Implementsmetadatawith name, chains, capabilitiessrc/defi/protocols/protocol-registry.ts— Replaced with re-export to maintain backward compatibility for existing service importssrc/defi/defi.module.ts— ImplementsOnModuleInit: auto-registersAaveAdapterandCompoundAdapterviaProtocolRegistry.register()src/defi/defi.controller.ts— AddedGET /defi/protocolsendpoint returning available protocolsAdding a New Protocol
To add a new adapter (e.g., Uniswap), only two steps are needed:
src/defi/protocols/uniswap.adapter.tsimplementingProtocolAdapterDeFiModuleproviders and inject + register inonModuleInit()No changes to
ProtocolRegistryrequired.Validation Results
npm run build— webpack compiled successfullyCloses
Closes #298