Repository navigation
Spike 574: flag-gated liquidity pools (phase-182) - #603
Merged
Darkvader-ship-it merged 2 commits intoOct 21, 2026
Merged
Conversation
Add the classic PHASELQ/XLM pool and Soroswap router adapter for spike PHASE-STELLAR#438. What ships now: - lib/liquidity-pool.ts: pool id derived from the pair, Horizon pool record parsing, a constant-product quote with fee/impact/min-out/ quote-hash, a 409 QUOTE_STALE / QUOTE_MISMATCH gate, deposit / withdraw / pool-share trustline builders, a path-payment swap builder, Soroswap config with no default router and router-drift detection, quote-hash intent idempotency, and a pool activity table that labels + excludes self-provision and self-swap volume. - app/api/liquidity-pools/route.ts: quote + prepare (deposit / withdraw / swap / trustline) and a Horizon-verified record action so pool volume can only count after a real successful settlement. - Market reads and offers read pick up spot+execution price in XLM advisory; fails the pool open when the pool is down. - Wash: detectSelfProvisionedPools, detectSelfSwaps, pool counters, getPoolVolumeExcludingWash. - Distributor ledger: additive pool_seed_stroops that is subtracted from availableBalance and from reserveFunds. - distributor-trust-and-payment.ts: pool-share trustline step when LP_POOL_SEED_ENABLED=1. - phase-protocol: set_pool_leg / get_pool_leg / clear_pool_leg plus PoolLegConfig storage (Rust on disk here; not compiled in this env). - i18n, closed-label counters, the feature-flag/security-counter rows, sidecar key, docs/TECHNICAL.md 28, PROJECT_ARCHITECTURE.md §10, and the spike record docs/spikes/574-liquidity-pools-findings.md. - lib/__tests__/liquidity-pool.test.ts: 28 tests. Verification this turn: - tsc --noEmit green. - 56 tests green across liquidity-pool, feature-flag-ops, funnel- retention, xbull-adapter, viewer-signature. - Pre-existing failures remain pre-existing only: client-only browser- module collection failures plus two old assertion-drift bugs (moderation audit redaction, biometric unlock, wallet-history stale-on-error, walletconnect-resilience session persistence). Rollback (from docs/PROJECT_ARCHITECTURE.md §10): unset NEXT_PUBLIC_FEATURE_PHASE_182 / FEATURE_PHASE_182 and restart; liquidity-pool-intents.json, pool_activity, distributor_pool_seed_stroops, and PoolLegConfig stay inert. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@shekwolonathanielbala-cyber Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
Author
|
Please merge |
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.
#438 Spike 574: Integrate Soroswap and Classic DEX Liquidity Pools
Summary
Implement a feature-flagged liquidity pool integration supporting Soroswap and Stellar's classic liquidity pool operations, including PHASELQ-XLM pools and Chamber swaps. This spike establishes a secure, idempotent, and observable end-to-end flow covering funding, pool interactions, settlement, indexing, and UI display.
The implementation addresses existing architectural gaps in settlement accounting, liquidity pool balance handling, trustline preflight checks, reserve and quote retrieval, market pricing, wash-trading detection, and pool seed capital management.
Changes
Security and Reliability
Testing and Validation
Migration and Rollback
All new functionality remains disabled by default until the end-to-end testnet proof and required validation are complete.
Contract upgrades or redeployments, contract ID changes, database migrations, environment updates, and associated documentation must be coordinated. Additive database migrations should preserve existing data, while JSON sidecar data must remain inert when the feature is disabled.
Rollback consists of disabling the new feature flags and reverting the relevant documentation changes. Any on-chain changes, stranded assets, or contract state require an explicit recovery plan because disabling application flags does not reverse blockchain transactions or contract upgrades.
Scope and Limitations
Issue Closure
Closes #438