About Polymarket Squads
Inspiration
Polymarket has revolutionized trading, but it can feel isolated. I wanted to create a social layer that turns prediction market trading into a competitive, collaborative experience with friends. The idea came from seeing how fantasy sports leagues make watching games more engaging, why not apply the same concept to prediction markets?
What it does
Polymarket Squads transforms solo trading into a social competition:
- Create or join trading squads with friends using simple invite codes
- Real-time leaderboards that track everyone's P&L and highlight top performing positions
- Automated trade notifications - a bot monitors all squad members' Polymarket activity and posts trade alerts to group chat
- Live group chat for instant communication and trash talk
How I built it
Architecture:
- Authentication: Simple Polymarket address-based login (for demo, production would use better auth)
- Real-time Chat: Socket.IO handles instant messaging with JWT authentication
- Trading Bot: Background polling service that monitors Polymarket API for new trades and automatically posts to squad chats
- Leaderboard System: Fetches live P&L data from Polymarket's positions and value endpoints, with 30-second caching for performance
- Database: PostgreSQL stores users, squads, memberships, chat history, and bot state
Challenges I faced
1. Real-time trade tracking: The Polymarket API doesn't provide webhooks(to my knowledge), so I built a polling system that checks for new trades every 5 seconds. To avoid duplicate notifications, I implemented hash-based deduplication that tracks the last seen trade for each user.
2. P&L calculations: Combining realized P&L from closed positions with unrealized P&L from open positions required careful data aggregation from multiple API endpoints. I added caching to prevent rate limiting while keeping leaderboards accurate.
3. Socket.IO authentication: Securing real-time connections required implementing JWT validation at the Socket.IO middleware level, ensuring users can only access squads they're members of.
4. Schema migration: Mid-development, I realized the dual EVM/Polymarket address system was confusing. Migrating to a single Polymarket address as the primary key simplified authentication significantly.
What I learned
- Building real-time applications with Socket.IO and handling connection lifecycle events
- Working with external APIs that lack webhooks (polling strategies, rate limiting, caching)
- Designing social features that enhance rather than distract from the core trading experience
- Redbulls can keep you awake for a long time
What's next
- Achievements & Badges: Unlock rewards for trading milestones (first win, 10-trade streak, etc.)
- Squad Analytics: Historical charts showing squad performance over time
- Integration with Polymarket OAuth: Replace demo login with proper Polymarket account integration
- Squad Rewards: Have an NFT minted to your Polymarket address when you top the PnL leaderboard
Built With
- express.js
- javascript
- next.js
- node.js
- polymarket
- postgresql
- react
- socket.io
- sql
- tailwind
- typescript
Log in or sign up for Devpost to join the conversation.