feat: introduce route optimizer for swaps and LP #36#56
Open
JerryIdoko wants to merge 1 commit intoStellar-Tools:mainfrom
Open
feat: introduce route optimizer for swaps and LP #36#56JerryIdoko wants to merge 1 commit intoStellar-Tools:mainfrom
JerryIdoko wants to merge 1 commit intoStellar-Tools:mainfrom
Conversation
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.
This PR introduces a StellarOptimizationService to handle efficient asset swaps and Liquidity Provider (LP) interactions within the Stellar/Soroban ecosystem. Previously, the agent lacked routing logic, leading to suboptimal trade execution.
This implementation enables the best-route strategy by dynamically querying liquidity pools and calculating the most cost-effective path for users.
Key Changes
Routing Engine: Implemented logic to fetch and compare multiple pool rates.
Path Selection: Developed an algorithm to choose the optimal path (direct vs. multi-hop) to minimize slippage.
Agent Integration: Updated the agent's swap method to support the { strategy: "best-route" } configuration.
Stellar Integration: Utilizes Soroban smart contract interactions to ensure real-time pool data accuracy.
Technical Depth (Quality Assurance)
Complexity: Moves beyond simple API calls by implementing a comparison engine for decentralized liquidity pools.
Impact: Reduces capital inefficiency for users interacting with Stellar-native protocols.
Performance: Optimized pool querying to ensure the "best-route" calculation does not introduce significant latency.
Related Issues
Closes #36
Summary by cubic
Introduces a
RouteOptimizerthat selects the best swap route (Classic DEX/AMM first, Soroban placeholder) and adds a new "best-route" strategy toagent.swap()while keeping legacy Soroban swaps intact.RouteOptimizer(lib/route.ts) to quote and execute best-route swaps via Classic DEX (quoteSwap/swapBestRoute); Soroban routing is scaffolded for future support.agent.swap()withstrategy: "best-route" | "soroban", supportingfromAsset,toAsset,amount,mode(strict-send/strict-receive), optionalslippageBps, anddestination.strategy: "best-route".tests/unit/lib/route.test.ts).Written for commit 6d00203. Summary will update on new commits.