Skip to content

fixing - polymarket.py#220

Open
kursadaydin wants to merge 1 commit intoPolymarket:mainfrom
kursadaydin:fix-polymarket.py
Open

fixing - polymarket.py#220
kursadaydin wants to merge 1 commit intoPolymarket:mainfrom
kursadaydin:fix-polymarket.py

Conversation

@kursadaydin
Copy link
Copy Markdown

@kursadaydin kursadaydin commented Mar 24, 2026

fixing - geth_poa_middleware
creating self.creds
fixing - _init_api_keys
fixing - MarketOrderArgs in execute_market_order def


Note

Medium Risk
Medium risk because it changes how the Polymarket CLOB client is authenticated/funded and how market orders are constructed, which can affect live trading behavior and transaction signing.

Overview
Polymarket agent setup is updated to work with newer dependencies and Polymarket CLOB auth. It replaces direct geth_poa_middleware usage with a version-compatible POA middleware import and injection.

CLOB client initialization now supports proxy funding and explicit API credentials. The agent reads PROXY_ADDRESS plus POLY_API_KEY/POLY_API_SECRET/POLY_API_PASSPHRASE from env, builds ApiCreds, and passes signature_type=2, funder, and creds into ClobClient.

Market order execution is adjusted. execute_market_order now accepts an optional side parameter and maps it to MarketOrderArgs.side (BUY/SELL).

Written by Cursor Bugbot for commit b2ea664. This will update automatically on new commits. Configure here.

fixing  - geth_poa_middleware
creating self.creds
fixing - _init_api_keys
fixing -  MarketOrderArgs in execute_market_order def
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Polymarket Agents. Thank you for creating your first PR. Cheers!

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.


self.web3 = Web3(Web3.HTTPProvider(self.polygon_rpc))
self.web3.middleware_onion.inject(geth_poa_middleware, layer=0)
self.w3.middleware_onion.inject(poa_middleware, layer=0)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

POA middleware injected into wrong Web3 instance

High Severity

The POA middleware is injected into self.w3 (created on line 53) but all contract interactions (self.usdc, self.ctf) and _init_approvals use self.web3 (created on line 64). The original code correctly called self.web3.middleware_onion.inject(...) — the change to self.w3 means self.web3 no longer has the POA middleware, which will cause failures when interacting with the Polygon PoA chain.

Additional Locations (1)
Fix in Cursor Fix in Web

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