You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-1Lines changed: 23 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -230,6 +230,28 @@ GET /api/v1/prices
230
230
231
231
# Portfolio analysis
232
232
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 inhistory and API responses.
254
+
233
255
Configuration
234
256
Environment Variables
235
257
Backend (.env):
@@ -308,7 +330,7 @@ Phase 1 (Current)
308
330
309
331
Phase 2 (Next)
310
332
311
-
🔄 Real DEX integration
333
+
✅ Real DEX integration (live DEX trades with slippage & risk controls)
0 commit comments