Skip to content

Add an opt-in local Polymarket trading pilot - #22

Open
gilbertsahumada wants to merge 44 commits into
mainfrom
codex/polymarket-live-trading
Open

gilbertsahumada wants to merge 44 commits into
mainfrom
codex/polymarket-live-trading

Conversation

@gilbertsahumada

Copy link
Copy Markdown
Contributor

Research and paper trading previously had no real Polymarket execution adapter. This adds a separately opt-in local Node pilot that prepares manual purchases and executes eligible, policy-approved NFL research through the pinned official SDK. Existing agents remain disabled and no signing tool is exposed to the model.

  • Add the polymarket-trading plugin, strict tenant API/CLI contracts, explicit local wallet/setup commands, and environment examples. Operator setup can deploy a Deposit Wallet; approvals require the explicit --approvals flag.
  • Persist account identity, idempotent order intents, unsent ownership leases and a shared lifetime 10 pUSD collateral ceiling: one manual and one agent-origin purchase, at most 5 each. Changing account identity cannot reset the budget.
  • Refresh scope/quote/permissions before submission, use BUY/FOK with bounded spend and price, and store the deterministic exchange order hash before posting. Ambiguous submissions retain reservations and are reconciled without replacement orders. Require confirmed trades plus the matching position before recording a confirmed purchase.
  • Keep conservative costUpperBound separate from actual fee accounting. Plugin revocation blocks new purchases while read-only reconciliation preserves external facts. Cloudflare composition explicitly disables the signing runtime.
  • Add migration 0005, controlled tests and English operating instructions in apps/agent-service/LIVE-TRADING.md and affected AGENTS.md files.

Validation:

  • Formatting, lint and typecheck passed.
  • Full PostgreSQL suite: 141 passed; local Supabase suite: 141 passed. Migrations ran only in disposable test databases.
  • Workspace build and both Cloudflare dry-run bundles passed.
  • Controlled tests cover competing consumers, idempotency, tenant isolation, stale leases, revocation, lost-response recovery, manual/agent shared budget, signature-envelope hashing, SDK order limits, depth/minimum size, settlement evidence and local credential-file preservation.

Live acceptance is still pending: no actual pilot wallet was generated or funded, no approvals or live bets were sent, no automatic mode was enabled, and no remote deployment occurred. Wallet/setup/execution commands are for explicit operator use. Exact paid fee accounting, sales, redemption and production custody are outside this delivery.

Stacked on codex/market-categories while #20 remains open. Contains one commit per file. No merge requested.

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.

1 participant