Skip to content

Feat/sprint stability#49

Merged
noymaxx merged 15 commits into
developfrom
feat/sprint-stability
Mar 29, 2026
Merged

Feat/sprint stability#49
noymaxx merged 15 commits into
developfrom
feat/sprint-stability

Conversation

@noymaxx
Copy link
Copy Markdown
Contributor

@noymaxx noymaxx commented Mar 29, 2026

Summary

Stabilization sprint covering execution reliability, structured errors, cross-chain prep, security foundations, and release discipline.

Execution Stability (H1, H2, H3)

  • RPC Failover: replaced single rpcUrl with rpcUrls[] array + sequential failover with 3.5s timeout per endpoint, parallel race on fallback. Supports Base + Avalanche
  • Serialize-by-user middleware: queues concurrent requests per wallet address (1 execution at a time per user). Bypasses idempotent reads (GET/HEAD/OPTIONS) and /prepare-* routes. 30s queue timeout
  • Execution timeout middleware: 15s hard deadline on all 17 prepare/quote endpoints across 6 route files. Returns 504 with EXECUTION_TIMEOUT code. Patches res.json/res.send to no-op after timeout

Structured Error Handling (H4)

  • 8 new error codes: INSUFFICIENT_BALANCE, INSUFFICIENT_LP_BALANCE, NO_LIQUIDITY, NO_LP_POSITION, NO_REWARDS, EXECUTOR_NOT_CONFIGURED, ORDER_UNAUTHORIZED, ORDER_INACTIVE
  • Converted 11 usecase/service files from raw throw new Error() to throw new AppError() with semantic HTTP status codes (400/403/404/502 instead of generic 500)

Demo & Environment (H5, H6)

  • config/demo.ts: pinned contract addresses, canonical demo flow (ETH swap → Add Liquidity → Stake → Claim → Exit), isDemoMode() helper, wider timeouts (20s/5s), 2% slippage
  • .env.example updated with BASE_RPC_URLS, AVAX_RPC_URLS, DEMO_MODE, ALLOWED_ORIGINS
  • Resolved develop→main merge conflicts, established branch discipline

Cross-Chain & Routing Prep (H9, G9)

  • CrossChainMessagingPort interface: getRoutes(), estimateFee(), executeRoute(), getMessageStatus() — abstracts Wormhole/CCIP/LayerZero
  • RoutingPort interface: multi-protocol aggregator for future LI.FI integration
  • Full type definitions: MessagingProtocol, MessageStatus, CrossChainRoute, CrossChainFee, ExecuteRouteResult

Security & Wallet Structure (H10)

  • WalletRole enum: USER, USER_ADAPTER, DCA_EXECUTOR, TREASURY
  • EXECUTION_LIMITS: 0.5 ETH max single tx, 5 ETH per session, 50 executions/session, 1h session duration
  • ExecutionAuditEntry interface for post-hoc audit trail

Release Discipline (H11)

  • DEPLOY_CHECKLIST.md: pre-deploy verification (contract addresses, RPC endpoints, schema alignment, rate limits), deploy steps, rollback procedure

noymaxx and others added 15 commits March 23, 2026 19:32
Revert "cache and fallbacks in rpc"
Adds executionTimeout() route-level middleware that enforces a 15s
hard deadline on prepare/quote handlers. If the handler doesn't
respond within the timeout, a 504 EXECUTION_TIMEOUT is sent.

Applied to 17 endpoints across 6 route files:
- swap: /quote, /prepare
- staking: /prepare-enter, /prepare-exit, /prepare-claim
- avax-swap: /quote, /prepare
- avax-lending: /prepare-supply, /prepare-redeem, /prepare-borrow, /prepare-repay
- avax-liquid-staking: /prepare-stake, /prepare-request-unlock, /prepare-redeem
- dca: /prepare-create, /prepare-cancel

Prevents silent hangs when RPCs are congested and never respond.
…ross all Base chain modules

Adds 8 new error codes to errorCodes.ts:
- INSUFFICIENT_BALANCE (400), INSUFFICIENT_LP_BALANCE (400)
- NO_LIQUIDITY (400), NO_LP_POSITION (400), NO_REWARDS (400)
- EXECUTOR_NOT_CONFIGURED (500)
- ORDER_UNAUTHORIZED (403), ORDER_INACTIVE (400)

Converts ~20 raw throw new Error() to throw new AppError() in:
- prepare-enter-strategy, prepare-exit-strategy, prepare-claim-rewards
- get-quote, prepare-cancel-order, get-orders
- aerodrome-swap, aerodrome.service, swap-provider, protocols

Before: all Base chain errors returned generic 500 INTERNAL_ERROR.
After: semantic HTTP status codes (400/403/404/502) with structured
error bodies matching the Avalanche modules pattern.
Adds config/demo.ts with:
- Pinned contract addresses (Executor, Adapter, DCAVault)
- Pinned Aerodrome protocol addresses (Router, Factory, Voter)
- Canonical demo flow: ETH swap → Add Liquidity → Stake → Claim → Exit
- Demo tokens and pool references for WETH/USDC volatile
- isDemoMode() helper (NODE_ENV=demo or DEMO_MODE=true)
- Wider timeouts (20s exec, 5s RPC) and slippage (2%) for live demos

Updates .env.example with:
- BASE_RPC_URLS / AVAX_RPC_URLS multi-RPC documentation
- AVAX_EXECUTOR_ADDRESS placeholder
- NODE_ENV options (development/demo/production)
- DEMO_MODE flag
- ALLOWED_ORIGINS documentation
Adds hexagonal architecture ports for future bridge integration:

types/cross-chain.ts — Shared types:
  - MessagingProtocol (wormhole | ccip | layerzero | lifi)
  - MessageStatus (pending → confirming → relayed → executed | failed)
  - CrossChainRoute, CrossChainFee, ExecuteRouteResult, etc.

domain/ports/CrossChainMessagingPort.ts — Single protocol adapter:
  - getRoutes(): find routes for a source→dest transfer
  - estimateFee(): lightweight fee estimation
  - executeRoute(): prepare unsigned transactions
  - getMessageStatus(): track in-flight messages

domain/ports/RoutingPort.ts — Multi-protocol aggregator:
  - getRoutes(): queries all messaging adapters, returns best route
  - executeRoute(): delegates to the correct adapter
  - getRouteStatus(): track status

Interface only — no implementation. Future adapters (Wormhole, CCIP,
LayerZero, LI.FI) will implement CrossChainMessagingPort.
H10 — config/wallet-roles.ts:
  - Documents 4 wallet roles: USER, USER_ADAPTER, DCA_EXECUTOR, TREASURY
  - Defines per-transaction limits for DCA executor (0.5 ETH max single, 5 ETH session)
  - ExecutionAuditEntry interface for DCA action logging

H11 — DEPLOY_CHECKLIST.md:
  - Pre-deploy: contract addresses, RPC endpoints, schema alignment, rate limits
  - Deploy steps: tag, build, health check, smoke test
  - Post-deploy: verification steps and rollback procedure
@noymaxx noymaxx self-assigned this Mar 29, 2026
@noymaxx noymaxx merged commit df7251f into develop Mar 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants