Skip to content

feat: resolve stale odds refresh, concurrent payouts, and dev faucet funding#573

Open
Themancalledpg wants to merge 295 commits intoHahfyeex:mainfrom
Themancalledpg:feat/market-reliability-dev-faucet
Open

feat: resolve stale odds refresh, concurrent payouts, and dev faucet funding#573
Themancalledpg wants to merge 295 commits intoHahfyeex:mainfrom
Themancalledpg:feat/market-reliability-dev-faucet

Conversation

@Themancalledpg
Copy link
Copy Markdown

Summary

Validation

px --workspace frontend jest --config jest.temp.config.js src/hooks/tests/useMarkets.test.ts src/components/tests/MarketCard.test.tsx src/components/tests/MarketCard.interactions.test.tsx src/components/tests/MarketCard.volatility.test.tsx src/components/tests/OddsTicker.test.tsx --runInBand --coverage=false --silent

pm --workspace backend test -- src/routes/tests/dev-faucet.test.js src/routes/tests/bets.payout-concurrency.test.js

Notes

  • frontend workspace jest.config.js currently has a pre-existing syntax error, so frontend tests were run with a temporary config file for verification.

Closes #491
Closes #492
Closes #495

Just-Bamford and others added 30 commits March 25, 2026 02:51
…roduce a worker to consume these events, and update .gitignore.
- Implement comprehensive stress test suite with 3 scenarios:
  * 500 concurrent users placing bets (p95 < 2s, error rate < 1%)
  * 50 simultaneous market resolutions (p95 < 5s)
  * 1000 concurrent WebSocket connections (99%+ success rate)

- Add Taurus configuration (stress-test.yml) with performance thresholds
- Create Python test runner (run-stress-test.py) with dependency checks
- Integrate stress tests into GitHub Actions CI pipeline
- Add comprehensive documentation:
  * STRESS_TEST_README.md - Full testing guide (2000+ lines)
  * STRESS_TEST_BOTTLENECKS.md - Bottleneck analysis with fixes (1500+ lines)
  * STRESS_TEST_QUICK_REFERENCE.md - Quick command reference (500+ lines)
  * STRESS_TEST_PR_SUMMARY.md - PR summary and validation checklist

- Document 8 identified bottlenecks with priority matrix:
  * P0: Database connection pool exhaustion, missing indexes, no rate limiting
  * P1: Synchronous operations, no caching, WebSocket limits
  * P2: Inefficient JSON parsing, unoptimized logging

- Add Python dependencies (requirements.txt): bzt>=1.16.0, requests>=2.31.0
- Update README.md with stress testing section
- Update .gitignore to exclude test results and Python artifacts

Performance targets:
- Throughput: 8-10 RPS baseline, 15-20 RPS after optimizations
- p95 Latency: < 2000ms (< 5000ms for resolutions)
- Error Rate: < 1%
- Concurrent Users: 500+ supported

CI/CD integration:
- Runs on every PR to main/Default branches
- Fails if performance thresholds exceeded
- Uploads test results as artifacts
- Includes cargo audit for Rust security checks

Closes Hahfyeex#165
…board

Portfolio Dashboard – Active Bets & PnL Command Center
- Implement comprehensive validation middleware with 4 rules:
  * Description length: minimum 50 characters for context
  * Outcome count: 2-5 outcomes (binary or multi-choice)
  * End date: must be future date within 1 year
  * Duplicate check: case-insensitive unique question validation

- Add Redis-based rate limiting:
  * 3 markets per wallet per 24 hours
  * Distributed rate limiting with automatic TTL
  * Specific error codes with retry-after headers
  * Graceful fallback if Redis unavailable

- Create validation middleware (backend/src/middleware/marketValidation.js):
  * validateMarket() function with detailed error responses
  * rateLimitMarketCreation() middleware with Redis INCR
  * Specific error codes for each validation failure
  * Comprehensive inline documentation

- Add Redis client utility (backend/src/utils/redis.js):
  * Connection handling with retry strategy
  * Event logging for monitoring
  * Graceful shutdown on SIGTERM

- Update market creation endpoint (backend/src/routes/markets.js):
  * Apply validation and rate limiting middleware
  * Instant publishing without admin approval
  * Enhanced logging for permissionless markets
  * Structured error responses

- Add comprehensive unit tests (>90% coverage target):
  * marketValidation.test.js: 50+ test cases for all validation rules
  * rateLimiting.test.js: 20+ test cases for rate limiting logic
  * Mock database and Redis for isolated testing
  * Edge cases and error handling covered

- Add Redis to docker-compose.yml:
  * Redis 7 Alpine image
  * Persistent volume for data
  * Health check configuration
  * Port 6379 exposed

- Update environment configuration:
  * Add REDIS_HOST, REDIS_PORT, REDIS_PASSWORD to .env.example
  * Document Redis configuration requirements

- Add comprehensive documentation:
  * PERMISSIONLESS_LAUNCH_README.md: Complete guide (4000+ lines)
    - Detailed validation rules with examples
    - Rate limiting explanation
    - API usage with curl examples
    - Error response formats
    - Setup and configuration
    - Troubleshooting guide
  * PERMISSIONLESS_LAUNCH_QUICK_REFERENCE.md: Quick reference
    - Validation rules summary table
    - Error codes reference
    - Common commands
    - Testing checklist

- Update main README.md:
  * Add permissionless market creation section
  * Link to detailed documentation
  * Update "How It Works" section

- Add ioredis dependency to package.json

Error codes implemented:
- DESCRIPTION_TOO_SHORT (400): Question < 50 characters
- INVALID_OUTCOME_COUNT (400): Not 2-5 outcomes
- INVALID_END_DATE (400): Past date or > 1 year future
- DUPLICATE_MARKET (409): Question already exists
- RATE_LIMIT_EXCEEDED (429): 3 markets in 24 hours
- MISSING_WALLET_ADDRESS (400): No wallet provided

Features:
- Instant market publishing without admin approval
- Automated metadata verification on submission
- Specific actionable error messages per validation failure
- Rate limit headers (X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset)
- Retry-After header when rate limit exceeded
- Case-insensitive duplicate detection with whitespace trimming
- Structured logging for all validation events
- Redis connection resilience with fallback behavior

Testing:
- 70+ unit tests covering all validation scenarios
- Edge cases: null values, empty strings, boundary conditions
- Error handling: database errors, Redis failures
- Rate limiting: multiple wallets, TTL expiration, header validation
- Mock-based testing for isolation

Closes Hahfyeex#164
…launch

feat: implement permissionless market creation with automated validation
…ss-test

test: add Taurus throughput stress test suite with CI integration
…hanism

feat: implement Dispute & Bond mechanism in Soroban contract
Emmanuelluxury and others added 30 commits March 28, 2026 12:58
- Implement useVolatilityPulse hook to track odds changes
- Trigger pulse animation when odds change by >5% within 60 seconds
- Green pulse for rising YES odds, red pulse for falling YES odds
- Animation runs exactly 3 cycles (1.5s total) then stops cleanly
- Add CSS @Keyframes pulseGreen and pulseRed with directional colors
- Integrate volatility pulse into MarketCard component
- Add comprehensive unit tests (>90% coverage)
- Add component integration tests
- Document feature with detailed README

Closes Hahfyeex#463

Co-authored-by: blackghost <blackghost@example.com>
* feat: Market Detail Page (Issue Hahfyeex#77) - probability chart, trade modal, comments, related markets carousel

* feat(Hahfyeex#77): Market Detail page with probability chart, trade modal, social sentiment, related markets carousel

- Add /markets/[id] route with full deep-dive market view
- ProbabilityChart: large area chart (Price vs Time) with 1H/6H/24H/7D/ALL range selector, touch-swipe on mobile
- TradeModal: sticky sidebar trade panel (Issue Hahfyeex#102 ref) with outcome selection, amount input, slippage, WhatIfSimulator
- SocialSentiment: community lean bar derived from pool distribution
- RelatedMarketsCarousel: horizontally scrollable footer carousel with snap scrolling
- MarketCard: add eye-icon link to /markets/:id detail page
- PR_MARKET_DETAIL.md: mini-README with Information Hierarchy breakdown
- All components use dark-mode design tokens (bg-gray-9xx/border-gray-8xx)

* docs(Hahfyeex#77): full PR description with Information Hierarchy mini-README and HTML preview

---------

Co-authored-by: Hahfyeez <36053600+Hahfyeex@users.noreply.github.com>
* feat: implement two-step admin transfer with pending confirmation

- Add DataKey::PendingAdmin to Instance storage
- Add propose_admin_transfer(caller, new_admin): gated to current admin,
  stores PendingAdmin and extends TTL
- Add accept_admin_transfer(new_admin): requires new_admin auth, asserts
  PendingAdmin matches, updates DataKey::Admin, clears PendingAdmin,
  emits AdminTransferred event
- Add EventAdminTransferred struct and emit_admin_transferred helper in events.rs
- Add set_paused, set_global_status, get_global_status public methods
- Fix duplicate DataKey::Admin variant (removed legacy alias)
- Fix instance extend_ttl calls (remove key arg — Instance TTL is global)
- Align soroban-sdk dependency to 25.3.0 across [dependencies] and [dev-dependencies]
- Fix test helpers: setup() now returns admin as 3rd element
- Remove misplaced #[test] inside #[contractimpl] block
- Deduplicate test functions and fix arg-count mismatches throughout test suite

Closes Hahfyeex#394

* feat: Implement Two-step Admin Transfer with Pending Confirmation

---------

Co-authored-by: macnelson9 <michaelofatu@gmail.com>
…monitoring (Hahfyeex#517)

* fix: create missing notifications route file and database table

* feat: implement soft delete for markets with audit endpoint

* feat: implement Redis-backed idempotency keys for bet submission

* feat: implement database connection pool monitoring with Prometheus metrics
…dge (Hahfyeex#516)

* feat: refactor MarketCard with typed props, skeleton, and resolved badge

- Add isError + onRetry props for error state with Retry button
- Add keyboard navigation (Enter/Space → market detail page)
- Add role=article, tabIndex=0, aria-label for accessibility
- Add useRouter import for keyboard nav
- Export MarketCardSkeleton as named + default export
- Add comprehensive test suite covering all 4 render states:
  loading (skeleton), error, resolved, active
- Tests cover keyboard nav, Resolved badge, error Retry, bet input visibility

Closes Hahfyeex#393

* feat: refactor MarketCard with typed props, skeleton, and resolved badge
* feat: implement Firebase App Check for API protection (Hahfyeex#62)

* feat: add Semgrep + secret scanning CI pipeline for security

* feat: add category filter chips with URL sync (closes Hahfyeex#201)

---------

Co-authored-by: Hahfyeez <36053600+Hahfyeex@users.noreply.github.com>
…ex#524)

- Preset buttons: 10, 50, 100, 500 XLM for quick bet placement
- Max button calculates wallet balance minus 0.5 XLM gas buffer
- Active preset highlighted with brand color (bg-blue-600)
- Typing custom amount deselects all presets
- Configurable preset values via BET_PRESETS constant array
- Values displayed in XLM (not stroops) for user-friendly UX
- Integrated in TradeModal and TradeDrawer components
- Reduces friction especially on mobile devices

Closes Hahfyeex#508
…es (Hahfyeex#523)

- Add DISPUTE_OPENED notification type with warning icon
- Update API calls to use correct endpoints (GET /api/notifications?wallet=ADDRESS)
- Implement mark-as-read via POST /api/notifications/mark-read
- Implement clear all via DELETE /api/notifications/clear
- Add deep link navigation to relevant market pages
- Maintain 30-second polling interval with React Query
- Show unread count badge on bell icon
- Display distinct icons for each notification type (checkmark, coins, clock, warning)

Closes Hahfyeex#503
…yeex#521)

- Add trustline verification for custom Stellar assets (non-XLM)
- Query Horizon API to check wallet balances for required asset
- Cache trustline check results in Redis for 5 minutes per wallet/asset
- Return 400 error if trustline missing with helpful message
- Skip verification for native XLM markets
- Gracefully handle API errors to avoid blocking bets

Closes Hahfyeex#502
)

- Desktop: 65/35 two-column grid with sticky bet form in right column
- Mobile: single-column stacked layout
- Add bet history table showing recent bets
- Sticky bet form stays visible while scrolling on desktop (top-20)
- Back button navigates to markets list
- Maintain Recharts AreaChart for odds visualization
- Follow 4px spacing grid and Stella Polymarket color palette

Closes Hahfyeex#504
* fix: add zero-amount guard and post-transfer balance check to place_bet function

* fix: resolve issues Hahfyeex#487, Hahfyeex#499, Hahfyeex#500, Hahfyeex#501

Issue Hahfyeex#487 - Zero-amount bet guard in smart contract:
- Add require!(amount > 0) guard in internal_place_bet
- Add post-transfer balance check to confirm received tokens

Issue Hahfyeex#499 - Admin audit trail:
- Add logAdminAction utility writing to admin_audit_log table
- Wire audit logging into POST /api/admin/markets/:id/resolve
- Add GET /api/admin/audit-log with actionType/date/pagination filters

Issue Hahfyeex#500 - Stellar Horizon transaction verification on bet placement:
- Validate Stellar wallet address format before inserting bet
- Fetch and verify transaction from Horizon API (source_account + amount)
- Redis deduplication to prevent replayed transaction hashes

Issue Hahfyeex#501 - Dispute window for market resolution:
- Set dispute_window_ends_at on market resolution (default 24h)
- Block POST /api/markets/payout/:id during open dispute window
- Add GET /api/markets/:id/dispute-status endpoint

Tests: Add unit tests for all backend changes (admin, bets, markets)
* fix: disable bet form during pending transaction to prevent double submission

* feat: fix accessibility violations and add ARIA labels across all components

---------

Co-authored-by: keengfk <fkimole@gmail.com>
…bmission (Hahfyeex#527)

Co-authored-by: keengfk <fkimole@gmail.com>
* feat: implement WebSocket server for real-time market updates (Hahfyeex#415)

* feat: broadcast BET_PLACED events to WebSocket clients (Hahfyeex#415)

* feat: add Soroban client for on-chain market status checks (Hahfyeex#435)

* feat: implement admin dashboard API endpoints with role-based access (Hahfyeex#418)

* feat: implement leaderboard API with accuracy, volume, and winnings rankings (Hahfyeex#420)

* test: add comprehensive test coverage for all four features (>95% coverage)
* feat: implement skeleton loading screens for all data-dependent pages

- Add MarketListSkeleton (6-card grid matching markets list layout)
- Add MarketDetailSkeleton (two-column layout with chart, prices, trade panel)
- Add PortfolioSkeleton (profile card + 4 stat cards + 5-row activity table)
- Add LeaderboardSkeleton (3 stat cards + 10-row table)
- Wire MarketListSkeleton into home page (replaces 4-card spinner)
- Wire MarketDetailSkeleton into markets/[id] page (replaces blank loading)
- Wire PortfolioSkeleton into profile page (replaces animate-pulse text)
- Wire LeaderboardSkeleton into leaderboard page (adds useQuery + skeleton)
- All skeletons use .skeleton class with 1.5s shimmer animation from globals.css
- Zero CLS: skeleton dimensions exactly match loaded content layout
- 31 unit tests covering all 4 new skeleton variants (100% pass)

Closes Hahfyeex#482

* feat: implement market share card generator with PNG export and Twitter share

* feat: implement keyboard shortcuts for power users with help modal

* feat: implement 4-step onboarding wizard for new users
* feat: implement skeleton loading screens for all data-dependent pages

- Add MarketListSkeleton (6-card grid matching markets list layout)
- Add MarketDetailSkeleton (two-column layout with chart, prices, trade panel)
- Add PortfolioSkeleton (profile card + 4 stat cards + 5-row activity table)
- Add LeaderboardSkeleton (3 stat cards + 10-row table)
- Wire MarketListSkeleton into home page (replaces 4-card spinner)
- Wire MarketDetailSkeleton into markets/[id] page (replaces blank loading)
- Wire PortfolioSkeleton into profile page (replaces animate-pulse text)
- Wire LeaderboardSkeleton into leaderboard page (adds useQuery + skeleton)
- All skeletons use .skeleton class with 1.5s shimmer animation from globals.css
- Zero CLS: skeleton dimensions exactly match loaded content layout
- 31 unit tests covering all 4 new skeleton variants (100% pass)

Closes Hahfyeex#482

* feat: implement market share card generator with PNG export and Twitter share

* feat: implement keyboard shortcuts for power users with help modal

---------

Co-authored-by: Hahfyeez <36053600+Hahfyeex@users.noreply.github.com>
* feat: implement skeleton loading screens for all data-dependent pages

- Add MarketListSkeleton (6-card grid matching markets list layout)
- Add MarketDetailSkeleton (two-column layout with chart, prices, trade panel)
- Add PortfolioSkeleton (profile card + 4 stat cards + 5-row activity table)
- Add LeaderboardSkeleton (3 stat cards + 10-row table)
- Wire MarketListSkeleton into home page (replaces 4-card spinner)
- Wire MarketDetailSkeleton into markets/[id] page (replaces blank loading)
- Wire PortfolioSkeleton into profile page (replaces animate-pulse text)
- Wire LeaderboardSkeleton into leaderboard page (adds useQuery + skeleton)
- All skeletons use .skeleton class with 1.5s shimmer animation from globals.css
- Zero CLS: skeleton dimensions exactly match loaded content layout
- 31 unit tests covering all 4 new skeleton variants (100% pass)

Closes Hahfyeex#482

* feat: implement market share card generator with PNG export and Twitter share

---------

Co-authored-by: Hahfyeez <36053600+Hahfyeex@users.noreply.github.com>
…Hahfyeex#534)

- Add MarketListSkeleton (6-card grid matching markets list layout)
- Add MarketDetailSkeleton (two-column layout with chart, prices, trade panel)
- Add PortfolioSkeleton (profile card + 4 stat cards + 5-row activity table)
- Add LeaderboardSkeleton (3 stat cards + 10-row table)
- Wire MarketListSkeleton into home page (replaces 4-card spinner)
- Wire MarketDetailSkeleton into markets/[id] page (replaces blank loading)
- Wire PortfolioSkeleton into profile page (replaces animate-pulse text)
- Wire LeaderboardSkeleton into leaderboard page (adds useQuery + skeleton)
- All skeletons use .skeleton class with 1.5s shimmer animation from globals.css
- Zero CLS: skeleton dimensions exactly match loaded content layout
- 31 unit tests covering all 4 new skeleton variants (100% pass)

Closes Hahfyeex#482
…id] (Hahfyeex#531)

Co-authored-by: Hahfyeez <36053600+Hahfyeex@users.noreply.github.com>
* implementing the task

* implementing the component

* implementing the component

* chore: add issue creation script for all 40 backlog issues

* chore: add issue body files and Python patch script

* feat: implement Go ledger event scraper with goroutine parallelism (Hahfyeex#190)

Add independent Go service that scrapes Stellar ledger events:
- Main loop iterating ledger sequences via Horizon API
- Filter operations by contract address
- Goroutine worker pool (10 concurrent) with sync.WaitGroup
- PostgreSQL storage for archived events
- Catch-up mode via --start-ledger CLI flag
- Resume from last processed ledger on restart
- 7 unit tests covering filtering, concurrency, catch-up, and resume

Closes Hahfyeex#151

* feat: implement immutable audit logging with IPFS and on-chain hashes (Hahfyeex#189)

Backend:
- AuditLogger service: serialize entries to JSON, pin to IPFS via Pinata
- Non-blocking: IPFS failures logged but don't break operations
- GET /api/audit-logs and GET /api/audit-logs/:id endpoints
- POST /api/audit-logs to create entries
- DB migration for audit_logs table

Contract:
- store_audit_hash — admin stores IPFS CID hash on-chain
- get_audit_hash / get_audit_log_count — retrieve stored hashes
- Verification: fetch CID from chain, retrieve from IPFS, confirm match

Frontend:
- AuditLogViewer component with table display and IPFS links

Closes Hahfyeex#153

* feat: add market share URI shortener (Hahfyeex#187)

Add lightweight short URL service for social sharing:
- POST /api/short-url — generate 6-char short code for a market
- GET /s/:code — 301 redirect to full market URL
- GET /api/short-url/:code — get short URL info

Uses safe alphabet (excludes 0,O,I,l), rejects offensive patterns.
Includes DB migration and 16 tests with 100% coverage on hashing
and redirection logic.

Closes Hahfyeex#34

* Hahfyeex#129 [FE] Hahfyeex#139 - IPFS Resolver

---------

Co-authored-by: nafiuishaaq <nafiuig@gmail.com>
Co-authored-by: Hahfyeez <36053600+Hahfyeex@users.noreply.github.com>
Co-authored-by: hahfyeez <tunmisehassan@gmail.com>
Co-authored-by: Akpolo Ogagaoghene Prince <104951733+ogazboiz@users.noreply.github.com>
… and frontend (Hahfyeex#261)

Co-authored-by: Hahfyeez <36053600+Hahfyeex@users.noreply.github.com>
…ahfyeex#114)

Implement WhitelistedTokens storage in the Soroban smart contract so
that only approved tokens (e.g. XLM, USDC, ARST) can be used as
collateral for prediction-market bets.

Contract changes (contracts/prediction_market/src/lib.rs):
- Add WhitelistedTokens variant to DataKey enum
- Initialize empty whitelist on contract init
- Add admin-only add/remove/query/check functions for the whitelist
- Enforce whitelist in create_market (reject non-whitelisted tokens)
- Enforce whitelist in place_bet (reject bets after token delisting)
- Add 12 comprehensive tests covering all whitelist paths, including
  rejection with de-listed tokens and visual-validation logging

Backend changes:
- Add whitelisted_tokens DB table with migration (002)
- Add token whitelist check in POST /api/bets before accepting a bet
- Add /api/whitelisted-tokens CRUD routes for admin management
- Add 18 unit tests for whitelist validation logic

Note: cargo clippy skipped due to pre-existing Rust toolchain
incompatibility (1.79.0 vs base64ct edition2024 requirement).

Closes Hahfyeex#16

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Hahfyeez <36053600+Hahfyeex@users.noreply.github.com>
* feat: Implement Dynamic Market Detail Page (Hahfyeex#12)

* feat(contracts): Automated Market Settlement Logic (Hahfyeex#11)
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.