Skip to content

[DOCS]: DeFi protocols — DEX aggregator and Soroswap integration guide#200

Merged
KevinMB0220 merged 1 commit intoGalaxy-KJ:mainfrom
ryzen-xp:docs/DeFi-protocols
Mar 29, 2026
Merged

[DOCS]: DeFi protocols — DEX aggregator and Soroswap integration guide#200
KevinMB0220 merged 1 commit intoGalaxy-KJ:mainfrom
ryzen-xp:docs/DeFi-protocols

Conversation

@ryzen-xp
Copy link
Copy Markdown
Contributor

@ryzen-xp ryzen-xp commented Mar 29, 2026

Pull Request

📋 Description

Added comprehensive documentation around the DexAggregatorService and its integration with the Soroswap protocol. This provides a central guide for routing strategies, handling quotes, and understanding the overarching aggregation strategy within the DevKit.

Includes:

  • Package overview in packages/core/defi/README.md
  • Complete DEX aggregator instructions in docs/defi/aggregator-guide.md
  • Soroswap protocol-specific integration details and mocking guides in docs/defi/soroswap-integration.md

🔗 Related Issues

🧪 Testing

  • Unit tests added/updated (N/A - docs only)
  • Integration tests added/updated (N/A - docs only)
  • Manual testing completed
  • All tests passing locally

📚 Documentation Updates (Required)

  • Updated API reference in relevant package README
  • Added/updated code examples
  • Updated ROADMAP.md progress (mark issue as completed)

Documentation Checklist by Component:

If you modified packages/core/defi/ and docs/defi/:

  • Updated packages/core/defi/README.md
  • Added protocol integration guide (docs/defi/soroswap-integration.md)
  • Updated DeFi architecture section (via docs/defi/aggregator-guide.md)

🤖 AI-Friendly Documentation

New Files Created

  • packages/core/defi/README.md - Defi package overview highlighting the DexAggregatorService.
  • docs/defi/aggregator-guide.md - Guide bridging quote fetching, price comparison, executing swaps, and handling path payment responses plus Soroswap execution.
  • docs/defi/soroswap-integration.md - Steps to wire Soroswap up as a liquidity source, mocking its behavior, and returning XDR to the caller.

Key Functions/Classes Added

class DexAggregatorService {
  getAggregatedQuote(params: AggregateQuoteParams): Promise<AggregatedQuote>
  comparePrices(assetIn: Asset, assetOut: Asset, amountIn: string, sources?: LiquiditySource[]): Promise<PriceComparison>
  executeAggregatedSwap(params: AggregateSwapParams): Promise<AggregatedSwapResult>
}

Patterns Used

  • Interfacing multiple distinct liquidity systems (SDEX Horizon path-payments & AMM Smart Contracts) under a single uniform interface (RouteQuote).
  • Leaving XDR execution unsigned through aggregator returns so the client (via Smart Wallet passkeys) is solely responsible for signatures.
  • Mocking the factory-based instantiation logic via Jest (ProtocolFactory.getInstance().createProtocol()).

📸 Screenshots (if applicable)

N/A

⚠️ Breaking Changes

  • No breaking changes

🔄 Deployment Notes

None

✅ Final Checklist

  • Code follows project style guidelines
  • Self-review completed
  • No console.log or debug code left
  • Error handling implemented
  • Performance considered
  • Security reviewed
  • Documentation updated (required)
  • ROADMAP.md updated with progress

By submitting this PR, I confirm that:

  • ✅ I have updated all relevant documentation
  • ✅ AI.md includes new patterns from my changes
  • ✅ Examples are provided for new features
  • ✅ The documentation is accurate and helpful for AI assistants and developers

Summary by CodeRabbit

  • Documentation
    • Added comprehensive guides for DEX aggregator functionality, including service usage and quote execution workflows.
    • Added Soroswap protocol integration documentation and guidance for extending the aggregator with new liquidity sources.
    • Added package overview documentation for the DeFi module.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 29, 2026

📝 Walkthrough

Walkthrough

Three new documentation files added to the Galaxy DevKit: packages/core/defi/README.md provides a package overview, docs/defi/aggregator-guide.md documents the DexAggregatorService with usage examples and swap execution flows, and docs/defi/soroswap-integration.md describes Soroswap protocol integration including quote fetching, transaction building, and extension patterns.

Changes

Cohort / File(s) Summary
DeFi Documentation
docs/defi/aggregator-guide.md, docs/defi/soroswap-integration.md, packages/core/defi/README.md
Added comprehensive documentation covering DexAggregatorService functionality (quote aggregation, concurrent liquidity source querying, swap execution), Soroswap integration details (protocol factory initialization, quote/swap transaction building), extension guidance for adding new liquidity sources, Jest mocking examples, and package-level overview with structural references.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • KevinMB0220

Poem

🐰 Hops through the docs with glee so bright,
DEX aggregators now in sight!
Soroswap routes and quotes aligned,
Developers' hearts and code entwined! 📚✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: comprehensive documentation for DeFi protocols, DEX aggregator, and Soroswap integration.
Description check ✅ Passed The description covers all required sections with clear documentation structure, related issue reference, testing checklist, and AI-friendly documentation with file listings and patterns.
Linked Issues check ✅ Passed All nine content requirements from issue #182 are met: package overview, DexAggregatorService explanation, Soroswap integration, quote flow, swap execution, protocol extension guide, Smart Wallet integration, error handling, and testing guidance with examples across three files.
Out of Scope Changes check ✅ Passed All changes are in-scope documentation additions directly aligned with issue #182 objectives; no unrelated code modifications or scope creep detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/defi/soroswap-integration.md`:
- Line 19: Fix the typo in the section heading "## Testing and Mocking Protocal
Responses" by updating the word "Protocal" to "Protocol" so the heading reads
"## Testing and Mocking Protocol Responses"; locate and edit that heading in
docs/defi/soroswap-integration.md (the heading text string "Testing and Mocking
Protocal Responses").
- Line 8: Update the wording in the docs where buildSoroswapSwapTransaction is
described: replace "returning the transaction hash (XDR)" with a clear term such
as "returning the unsigned transaction XDR" or "returning the XDR envelope" to
reflect that buildSoroswapSwapTransaction calls the protocol's swap method and
returns the serialized transaction XDR (not a cryptographic hash); reference
buildSoroswapSwapTransaction and the protocol.swap usage and align with
terminology used in aggregator-guide.md.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 16e0cbd2-8daf-46f0-993c-23e37b8c6919

📥 Commits

Reviewing files that changed from the base of the PR and between 32dda93 and 18f87c3.

📒 Files selected for processing (3)
  • docs/defi/aggregator-guide.md
  • docs/defi/soroswap-integration.md
  • packages/core/defi/README.md


## How it is Integrated
1. **Pricing:** The `fetchSoroswapQuote` method initializes the protocol via `ProtocolFactory` and calls `getSwapQuote(assetIn, assetOut, amountIn)`.
2. **Execution:** The `buildSoroswapSwapTransaction` calls the `swap` method on the protocol, returning the transaction hash (XDR) ready for signing.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify terminology: "transaction hash" vs XDR.

The phrase "returning the transaction hash (XDR)" is misleading. A transaction hash is typically a cryptographic identifier, while XDR is the serialized transaction envelope. Based on the implementation and usage in aggregator-guide.md, this should be "returning the unsigned transaction XDR" or "returning the XDR envelope".

📝 Proposed fix for clarity
-2. **Execution:** The `buildSoroswapSwapTransaction` calls the `swap` method on the protocol, returning the transaction hash (XDR) ready for signing.
+2. **Execution:** The `buildSoroswapSwapTransaction` calls the `swap` method on the protocol, returning the unsigned transaction XDR ready for signing.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
2. **Execution:** The `buildSoroswapSwapTransaction` calls the `swap` method on the protocol, returning the transaction hash (XDR) ready for signing.
2. **Execution:** The `buildSoroswapSwapTransaction` calls the `swap` method on the protocol, returning the unsigned transaction XDR ready for signing.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/defi/soroswap-integration.md` at line 8, Update the wording in the docs
where buildSoroswapSwapTransaction is described: replace "returning the
transaction hash (XDR)" with a clear term such as "returning the unsigned
transaction XDR" or "returning the XDR envelope" to reflect that
buildSoroswapSwapTransaction calls the protocol's swap method and returns the
serialized transaction XDR (not a cryptographic hash); reference
buildSoroswapSwapTransaction and the protocol.swap usage and align with
terminology used in aggregator-guide.md.

3. **Execution:** Implement a `build<Protocol>SwapTransaction(params)` method to return an unsigned XDR string.
4. **Registration:** Update the switch-cases inside `fetchQuoteFromSource` and `buildSwapTransaction`.

## Testing and Mocking Protocal Responses
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix typo in section heading.

The word "Protocal" should be "Protocol".

📝 Proposed fix
-## Testing and Mocking Protocal Responses
+## Testing and Mocking Protocol Responses
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
## Testing and Mocking Protocal Responses
## Testing and Mocking Protocol Responses
🧰 Tools
🪛 LanguageTool

[grammar] ~19-~19: Ensure spelling is correct
Context: ...apTransaction`. ## Testing and Mocking Protocal Responses To unit test the aggregator w...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/defi/soroswap-integration.md` at line 19, Fix the typo in the section
heading "## Testing and Mocking Protocal Responses" by updating the word
"Protocal" to "Protocol" so the heading reads "## Testing and Mocking Protocol
Responses"; locate and edit that heading in docs/defi/soroswap-integration.md
(the heading text string "Testing and Mocking Protocal Responses").

@KevinMB0220 KevinMB0220 merged commit 84934e9 into Galaxy-KJ:main Mar 29, 2026
7 checks 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.

[DOCS] DeFi protocols — DEX aggregator and Soroswap integration guide

2 participants