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: docs/CONTRACT_DEPLOYMENT_CHECKLIST.md
+56Lines changed: 56 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -244,6 +244,14 @@ Use this for testing with real Stellar testnet infrastructure.
244
244
--id $CONTRACT_ID \
245
245
--network testnet
246
246
```
247
+
-[ ] Verify `capability_summary` output matches the expected capability set for this release (see [Capability Summary Verification](#capability-summary-verification)):
248
+
```bash
249
+
soroban contract invoke \
250
+
--id $CONTRACT_ID \
251
+
--source deployer \
252
+
--network testnet \
253
+
-- capability_summary
254
+
```
247
255
248
256
### Initialize
249
257
@@ -372,6 +380,14 @@ Use this for pre-production testing on testnet.
372
380
```bash
373
381
export STAGING_CONTRACT_ID=C...
374
382
```
383
+
-[ ] Verify `capability_summary` output matches the expected capability set for this release (see [Capability Summary Verification](#capability-summary-verification)):
384
+
```bash
385
+
soroban contract invoke \
386
+
--id $STAGING_CONTRACT_ID \
387
+
--source staging-deployer \
388
+
--network testnet \
389
+
-- capability_summary
390
+
```
375
391
376
392
### Initialize
377
393
@@ -506,6 +522,14 @@ Use this for mainnet deployment. **This is irreversible and uses real XLM.**
506
522
--id $PROD_CONTRACT_ID \
507
523
--network mainnet
508
524
```
525
+
-[ ] Verify `capability_summary` output matches the expected capability set for this release (see [Capability Summary Verification](#capability-summary-verification)) — **do not proceed to Initialize if this fails**:
526
+
```bash
527
+
soroban contract invoke \
528
+
--id $PROD_CONTRACT_ID \
529
+
--source prod-deployer \
530
+
--network mainnet \
531
+
-- capability_summary
532
+
```
509
533
510
534
### Initialize
511
535
@@ -570,6 +594,38 @@ Use this for mainnet deployment. **This is irreversible and uses real XLM.**
570
594
571
595
---
572
596
597
+
## Capability Summary Verification
598
+
599
+
Every deployment (testnet, staging, and production) must be verified post-deploy by calling the read-only `capability_summary` contract method (`contracts/CONTRACT_ABI.md`) before initialization or traffic cutover. This is the single cheapest way to confirm the deployed WASM matches the intended release — a stale or mismatched deploy is caught here before it reaches `initialize` or the auto-rebalancer.
600
+
601
+
An automated equivalent of this check is planned for the contract-deploy pipeline (`deployment/contract-deploy.sh`), which would fail the deployment job automatically if `capability_summary` doesn't match expectations after `soroban contract deploy`. Until that automation lands, the manual checklist step above is required for every environment.
> These values are sourced from `contracts/src/types.rs` and `contracts/src/lib.rs` (`capabilities()`). Update this table whenever a contract release changes `CONTRACT_VERSION`, `CONTRACT_EVENT_SCHEMA_VERSION`, adds a `CapabilityFlag` variant, or changes any of the min/max constants.
617
+
618
+
### Escalation path on verification failure
619
+
620
+
If `capability_summary` does not match the expected values above:
621
+
622
+
1.**Do not** proceed to `initialize` or cut over traffic to the new contract ID.
623
+
2. Re-check that the deployed WASM matches the intended release commit (`soroban contract info --wasm <path>` hash vs. the release's recorded hash from `make hash`).
624
+
3. If the mismatch is unexplained, halt the deployment and escalate to the team in the deployment channel/wiki (see [Documentation](#documentation) steps) before retrying.
625
+
4. Once resolved, redeploy and re-verify `capability_summary` before continuing.
626
+
627
+
---
628
+
573
629
## Rollback Procedure
574
630
575
631
If production deployment fails or needs to be reverted:
Copy file name to clipboardExpand all lines: docs/FEATURE_FLAGS.md
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,17 @@ Public copies of the main booleans are exposed on `GET /api/v1/system/status` un
32
32
|`VITE_ENABLE_API_DEBUG_LOGS`| Verbose API logging via `frontend/src/utils/debug.ts`. |
33
33
|`API_CONFIG.USE_BROWSER_PRICES`|**Code flag** in `frontend/src/config/api.ts` (currently `true`): GET `/prices` uses `browserPriceService` in the browser instead of the backend envelope. |
34
34
35
+
## Planned Flags (Not Yet Implemented)
36
+
37
+
The following flags do not exist in code yet — no environment variable is currently read for them. They are documented here ahead of implementation so the naming and rollout plan are agreed before the toggles are wired up. Update this section (move entries into [Backend](#backend-node--api)) once each flag lands in `backend/src/config/featureFlags.ts`.
|`ENABLE_DCA_STRATEGY`|`false`|`false`| Would gate DCA (dollar-cost averaging) rebalance strategy support described conceptually in [`docs/REBALANCING_STRATEGIES.md`](REBALANCING_STRATEGIES.md). No DCA strategy code exists yet — the flag is a placeholder for the eventual rollout. |
42
+
|`ENABLE_BULK_IMPORT`|`true`|`false`| Would gate the portfolio bulk import endpoint (`POST /api/v1/portfolio/import`, implemented in `backend/src/api/portfolioImportRoutes.ts` / `backend/src/services/portfolioImportService.ts`). Today this endpoint is **always enabled** and reads no feature flag; this entry documents the intended flag name for adding a kill switch. |
43
+
44
+
**Local toggling (once implemented):** set the variable in `backend/.env` (or `config/feature-flags.staging.json` via `FEATURE_FLAGS_FILE`, see [File-Based Overrides](#file-based-overrides-staging--local)) the same way as any other backend boolean flag, then restart the backend.
> **Nota:** Esta traducción puede estar una versión por detrás del README en inglés. Consulte el [README principal](../README.md) para obtener la información más actualizada.
Los nuevos contribuidores deben leer el glosario antes de profundizar en la configuración o el trabajo con el contrato.
61
+
62
+
-**Portfolio (Cartera)**: El objeto de asignación gestionado por el usuario, identificado por `portfolio_id`.
63
+
-**Target Allocation, Rebalance Threshold y Slippage Tolerance**: Los principales parámetros del contrato para el rebalanceo automatizado.
64
+
-**Reflector Oracle**: La fuente de precios que usa el contrato para decidir sobre desviación (drift) y rebalanceo.
65
+
-**Cooldown Period y Emergency Stop**: Controles de seguridad integrados para los rebalanceos.
66
+
67
+
📘 **Acceso al Glosario:** Consulte [docs/GLOSSARY.md](GLOSSARY.md) para el glosario central y enlaces cruzados a la documentación de contrato, API y despliegue.
Referencia completa del entorno del backend: [`docs/ENVIRONMENT.md`](ENVIRONMENT.md)
70
121
122
+
**Versionado de la API:** El cliente HTTP del frontend apunta a `/api/v1/*` para las rutas de recursos de forma predeterminada (`VITE_API_VERSION=v1` en `frontend/.env.example`). La autenticación JWT sigue usando `/api/auth/*`. Consulte [API.md](API.md) para detalles completos de versionado.
123
+
124
+
**Ejemplos de Cliente API:** Consulte el ejemplo de cliente API en Python (o el archivo de ejemplos correspondiente) para ver integraciones de referencia.
125
+
126
+
### Configuración de la Base de Datos
127
+
128
+
Las migraciones de PostgreSQL están disponibles para entornos configurados con `DATABASE_URL` o las variables `PGHOST` / `PGDATABASE` / `PGUSER`.
129
+
130
+
```bash
131
+
cd backend
132
+
npm run db:migrate # Aplicar migraciones
133
+
npm run db:migrate -- --dry-run # Previsualizar migraciones
134
+
```
135
+
136
+
**Desarrollo local:** Para el desarrollo local con SQLite, deje las variables de PostgreSQL sin definir y use `DB_PATH` en su lugar. La ruta predeterminada es `backend/data/portfolio.db`. El backend crea el archivo de la base de datos y su directorio padre automáticamente al iniciar. Los clones nuevos no deben incluir archivos `.db`, `.db-wal` o `.db-shm` preconstruidos.
137
+
138
+
**Siembra de demo:** Los datos de demostración de SQLite solo aparecen cuando la siembra de demo está habilitada mediante `ENABLE_DEMO_DB_SEED` o el Modo Demo. De lo contrario, la base de datos local inicia vacía y se inicializa a partir del esquema y las fuentes de semillas registradas en el repositorio.
139
+
140
+
### Notificaciones por Correo (Opcional)
141
+
142
+
Ejemplo de configuración con Gmail:
143
+
144
+
```env
145
+
SMTP_HOST=smtp.gmail.com
146
+
SMTP_PORT=587
147
+
SMTP_SECURE=false
148
+
SMTP_USER=your-email@gmail.com
149
+
SMTP_PASS=your-app-password
150
+
SMTP_FROM=your-email@gmail.com
151
+
```
152
+
153
+
También se admiten otros proveedores como SendGrid, Mailgun y AWS SES.
154
+
155
+
Prueba de notificaciones:
156
+
157
+
```bash
158
+
curl -X POST http://localhost:3001/api/v1/notifications/subscribe \
Ejemplo de dirección de contrato: `CCQ4LISQJFTZJKQDRJHRLXQ2UML45GVXUECN5NGSQKAT55JKAK2JAX7I`
205
+
206
+
Para un checklist completo por entorno (local, testnet, staging, producción), vea [Contract Deployment Checklist](CONTRACT_DEPLOYMENT_CHECKLIST.md).
207
+
208
+
### Verificación del Hash WASM
209
+
210
+
Antes de desplegar, puede calcular y auditar el hash SHA-256 canónico del contrato WASM compilado para garantizar la reproducibilidad y la seguridad:
211
+
212
+
```bash
213
+
cd contracts
214
+
make hash
215
+
```
216
+
217
+
Este target genera el hash tanto del WASM de release como del WASM optimizado (si está disponible). El mismo cálculo de hash se ejecuta automáticamente en las compilaciones de release/PR para simplificar las auditorías de despliegue.
218
+
219
+
**Recursos para desarrolladores:**
220
+
221
+
- Referencia de la interfaz del contrato (funciones, errores, notas de tipos): [contracts/CONTRACT_ABI.md](../contracts/CONTRACT_ABI.md)
222
+
- Comandos y ejemplos comunes de invocación de Soroban: [docs/soroban-cookbook.md](soroban-cookbook.md)
223
+
- Matriz de compatibilidad y capacidades del frontend (mapeo de degradación): [docs/CONTRACT_CAPABILITY_MATRIX.md](CONTRACT_CAPABILITY_MATRIX.md)
224
+
225
+
---
226
+
227
+
## Uso
228
+
229
+
📸 ¿Nuevo en la plataforma? Consulte nuestro [Recorrido Visual de la Demo](DEMO_WALKTHROUGH.md) con capturas de pantalla paso a paso y explicaciones detalladas.
230
+
231
+
### Flujo Rápido
89
232
90
233
1. Conecte su billetera Stellar
91
234
2. Cree una cartera y establezca las asignaciones objetivo (la suma debe ser 100%, máximo 10 activos por cartera)
92
235
3. Configure los umbrales de rebalanceo (1–50%)
93
236
4. Active/desactive el rebalanceo automático
94
237
5. Envíe la transacción
95
238
239
+
**Detección de Volatilidad:** Pausa el rebalanceo durante condiciones de mercado extremas.
240
+
241
+
**Límites de Concentración:** Evita la sobreasignación a un único activo.
242
+
243
+
**Circuit Breakers:** Múltiples verificaciones de seguridad antes de ejecutar operaciones.
244
+
245
+
### Notificaciones
246
+
247
+
Notificaciones por correo electrónico y webhook para eventos de rebalanceo.
248
+
249
+
Tipos de evento: rebalanceo, circuit breaker, movimiento de precio, cambios de riesgo.
250
+
251
+
Configurable por usuario.
252
+
96
253
---
97
254
98
255
## Referencia de la API
@@ -115,6 +272,9 @@ GET /api/v1/portfolio/:id
115
272
# Ejecutar rebalanceo
116
273
POST /api/v1/portfolio/:id/rebalance
117
274
275
+
# Simulación de rebalanceo (plan de solo lectura, sin escrituras en BD ni llamada al contrato)
276
+
POST /api/v1/portfolio/:id/rebalance/dry-run
277
+
118
278
# Estado del rebalanceo
119
279
GET /api/v1/portfolio/:id/rebalance-status
120
280
```
@@ -135,6 +295,14 @@ GET /api/v1/prices
135
295
GET /api/v1/portfolio/:id/rebalance-plan
136
296
```
137
297
298
+
### Integración con Stellar DEX
299
+
300
+
Operaciones reales ejecutadas en la testnet de Stellar usando `@stellar/stellar-sdk`.
301
+
302
+
Ejecución con conciencia de slippage, ejecuciones parciales y reversión (rollback) automatizada.
303
+
304
+
El historial de rebalanceos registra los resultados y las métricas explícitas de slippage.
docker compose -f deployment/docker-compose.yml up --build -d
151
332
```
152
333
153
334
---
@@ -165,10 +346,37 @@ Pasos rápidos:
165
346
2. Cree una rama de funcionalidad: `git checkout -b feature/funcionalidad-increible`
166
347
3. Siga la configuración en [docs/CONTRIBUTING.md](CONTRIBUTING.md)
167
348
4. Asegúrese de que las pruebas pasen: `cd backend && npm test && cd ../frontend && npm test`
168
-
5. Abra un Pull Request
349
+
5. Abra un Pull Request bien documentado
350
+
351
+
---
352
+
353
+
## Solución de Problemas
354
+
355
+
### Problemas con la Billetera
356
+
357
+
¿Tiene problemas para conectar su billetera Stellar? Consulte las [Preguntas Frecuentes de Solución de Problemas de Billetera](WALLET_TROUBLESHOOTING.md) para soluciones paso a paso de:
358
+
359
+
- Errores de "la billetera no está instalada"
360
+
- Tiempos de espera y rechazos de conexión
361
+
- Fallos en la firma de transacciones
362
+
- Discrepancia de red entre la billetera y la aplicación
363
+
- Peculiaridades específicas de cada billetera (Freighter, Rabet, xBull)
364
+
365
+
### Problemas Comunes de Configuración
366
+
367
+
Consulte CONTRIBUTING.md §10 "Common setup failures" para problemas de backend, base de datos y entorno.
169
368
170
369
---
171
370
172
371
## Licencia
173
372
174
373
Este proyecto está licenciado bajo la [Licencia MIT](https://opensource.org/licenses/MIT).
0 commit comments