Skip to content

Commit 8063c37

Browse files
docs: document Stellar DEX integration (#82)
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 9aa67b9 commit 8063c37

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,28 @@ GET /api/v1/prices
230230

231231
# Portfolio analysis
232232
GET /api/v1/portfolio/:id/rebalance-plan
233+
234+
### Stellar DEX integration
235+
236+
The rebalancer now executes **real trades on the Stellar DEX** (testnet or mainnet, depending on configuration) using the `@stellar/stellar-sdk`:
237+
238+
- **Price discovery & risk checks**:
239+
- `StellarDEXService` reads live **orderbooks** to derive reference prices, spreads, and liquidity coverage.
240+
- Trades are rejected up‑front when spread or liquidity are outside configurable bounds (see `REBALANCE_MAX_SPREAD_BPS`, `REBALANCE_MIN_LIQUIDITY_COVERAGE`).
241+
- **Slippage‑aware execution**:
242+
- Each rebalance trade is submitted as a real `manageSellOffer` transaction with a limit price derived from the portfolio’s **slippage tolerance**.
243+
- During execution, the service tracks per‑trade and cumulative slippage and aborts the rebalance if configured limits are exceeded.
244+
- **Partial fills, rollbacks and failures**:
245+
- After submission, the engine compares open offers before/after the transaction to infer filled vs remaining amounts, marking trades as `executed`, `partial`, or `failed`.
246+
- Optional rollback trades attempt to unwind partially executed sequences when a rebalance fails mid‑way.
247+
- All outcomes (including slippage metrics and failure reasons) are recorded in **rebalance history** for observability.
248+
249+
This behavior satisfies the core goals of issue **#82 (Complete DEX integration for real trade execution)**:
250+
251+
- Real trades execute on Stellar testnet via Horizon transactions.
252+
- Path selection and slippage controls optimize for price within configured risk limits.
253+
- Failed or partially filled trades are handled and surfaced cleanly in history and API responses.
254+
233255
Configuration
234256
Environment Variables
235257
Backend (.env):
@@ -308,7 +330,7 @@ Phase 1 (Current)
308330

309331
Phase 2 (Next)
310332

311-
🔄 Real DEX integration
333+
Real DEX integration (live DEX trades with slippage & risk controls)
312334
🔄 Advanced rebalancing strategies
313335
🔄 Portfolio analytics and backtesting
314336
🔄 Mobile application

0 commit comments

Comments
 (0)