Implement Polymarket Arbitrage Agent with Cross-Market Strategy#384
Open
Jay-Sojitra wants to merge 28 commits intoEmberAGI:nextfrom
Open
Implement Polymarket Arbitrage Agent with Cross-Market Strategy#384Jay-Sojitra wants to merge 28 commits intoEmberAGI:nextfrom
Jay-Sojitra wants to merge 28 commits intoEmberAGI:nextfrom
Conversation
…arket with simple strategy
… and price rounding functionality - Added a new function to fetch markets and their prices for the Polymarket agent. - Implemented price rounding to the market's tick size to prevent invalid tick size errors. - Updated the agent context to dynamically route to the correct agent based on the URL. - Adjusted the API route to handle multiple agents and improved error handling for agent name extraction. - Refactored the agent connection logic to ensure proper remounting when switching agents.
…itrum-vibekit into agent-polymarket
…on to edit config of user
…itrum-vibekit into agent-polymarket
…ithout explicit web dependency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
High-Level Goal
Build a complete Polymarket arbitrage trading system:
Requirements
1. Polymarket Client Implementation
2. Agent Workflow (LangGraph)
Strategy:
1) Intra-market arbitrage (YES+NO < $1.00)
2) Cross-market arbitrage (logical relationship violations)
Lifecycle Management:
disabled→waiting-funds→running→stopping→stoppedhire,fire,sync,cycle,updateApprovalExecution:
3. Frontend Integration
Implementation Details
Architecture
Frontend (Next.js)
↓ (triggers cycle via runCommand)
LangGraph Workflow (15 nodes)
↓ (calls client methods)
Polymarket Client (Direct API Integration)
↓ (HTTP + blockchain calls)
Polymarket APIs (Gamma, CLOB, Data) + Polygon
Key Files
apps/agent-polymarket/src/clients/polymarketClient.ts- Direct API clientapps/agent-polymarket/src/clients/approvals.ts- USDC/CTF approval logicapps/agent-polymarket/src/agent.ts- LangGraph workflow (15 nodes)apps/agent-polymarket/src/strategy/*- Scanner, evaluator, executor, relationship detectorapps/web/src/components/polymarket/*- Frontend UI componentsapps/web/src/hooks/usePolymarketPolling.ts- Frontend polling hookEnvironment Variables Required
Backend (
apps/agent-polymarket/.env):A2A_TEST_AGENT_NODE_PRIVATE_KEY- Wallet for signing tradesPOLY_FUNDER_ADDRESS- Wallet addressOPENAI_API_KEY- For LLM relationship detectionPOLYGON_RPC_URL- Polygon RPC endpointFrontend (
apps/web/.env):NEXT_PUBLIC_POLY_POLL_INTERVAL_MS- Polling interval(default: 180000ms = 3 min)
Success Criteria
Steps to Run:
1. Setup environment
cd apps/agent-polymarket
cp .env.example .env and configure all variables
2. Setup web frontend
cd apps/web
Edit .env: Set NEXT_PUBLIC_POLY_POLL_INTERVAL_MS=180000 # 3 minutes
(default)
3. run from web-ag-ui
pnpm install
pnpm dev
4. Test agent
Checklists
Code Quality
Documentation
flow)
Agent Specific
limits)
Breaking Changes:
Additional Context
Architecture:
Frontend (Next.js) → LangGraph Agent → Polymarket Client →
Polymarket APIs + Polygon
↑ ↓ ↓
└────────────── State Sync ──────────────┘
Why Direct Client vs Plugin:
Key Features:
Documentation Added: