Skip to content

fix(gemini-titan): add terms acceptance flow before order submission#1326

Open
AbhilashG12 wants to merge 2 commits into
pmxt-dev:mainfrom
AbhilashG12:fix/gemini-terms-acceptance
Open

fix(gemini-titan): add terms acceptance flow before order submission#1326
AbhilashG12 wants to merge 2 commits into
pmxt-dev:mainfrom
AbhilashG12:fix/gemini-terms-acceptance

Conversation

@AbhilashG12

Copy link
Copy Markdown
Contributor

What this PR does

Adds automatic terms acceptance for Gemini-Titan orders.

The problem

Gemini now requires users to accept their Prediction Markets terms before placing orders. New API keys can't place any orders until terms are accepted.

The fix

PMXT now:

  1. Checks if terms are accepted before placing an order
  2. Auto-accepts terms if needed
  3. Then places the order

Changes

  • Added 3 new endpoints for terms management
  • Updated order flow to check terms first
  • Added unit tests (14 tests passing)

Fixes #1068

- Add getTerms(), getTermsStatus(), acceptTerms() methods
- Auto-check and accept terms before placing orders
- Add error mapping for terms rejection
- Update OpenAPI spec with new endpoints
- Add unit tests with mocks

Fixes pmxt-dev#1068
@realfishsam

Copy link
Copy Markdown
Contributor

PR Review: FAIL

What This Does

Adds a Gemini Titan terms-acceptance preflight before submitOrder, plus new terms helpers and tests. This matters to SDK consumers because Gemini Titan order submission would now perform an extra venue-authenticated terms status/acceptance flow before submitting the order.

Blast Radius

Gemini Titan trading path only: GeminiFetcher.submitRawOrder() now calls ensureTermsAccepted() before /v1/prediction-markets/order. The change also adds Gemini terms endpoints to a new venue spec file and changes Gemini error mapping/export surface.

Consumer Verification

Before (base branch):
No terms preflight exists; submitRawOrder() directly posts the order payload to /v1/prediction-markets/order.

// base core/src/exchanges/gemini-titan/fetcher.ts
async submitRawOrder(payload) {
  return this.postAuthenticated('/v1/prediction-markets/order', payload);
}

After (PR branch):
The order path now calls ensureTermsAccepted(), but the preflight uses postAuthenticated() for the terms status endpoint:

// PR core/src/exchanges/gemini-titan/fetcher.ts:155-164
async getTermsStatus() {
  return this.postAuthenticated('/v1/prediction-markets/terms/status', {});
}

The same PR's OpenAPI/spec declares that endpoint as GET /v1/prediction-markets/terms/status (core/specs/gemini-titan/GeminiTitan.yaml:124-126). I could not verify against live Gemini credentials in this cron environment, but the code/spec mismatch means the consumer order path is very likely to send the wrong HTTP verb during the new preflight.

Test Results

  • Build: PASS (npm run build --workspace=pmxt-core)
  • Unit tests: PASS (6 passed, 0 failed via npm test --workspace=pmxt-core -- --runTestsByPath test/exchanges/gemini-titan-terms.test.ts --runInBand)
  • Server starts: NOT VERIFIED (not needed to identify the blocking method/verb mismatch)
  • E2E smoke: NOT VERIFIED (Gemini trading requires live venue credentials; not available in cron)

Findings

  1. core/src/exchanges/gemini-titan/fetcher.ts:160getTermsStatus() sends POST /v1/prediction-markets/terms/status, while the PR's own spec defines GET /v1/prediction-markets/terms/status at core/specs/gemini-titan/GeminiTitan.yaml:124-126. Because submitRawOrder() now always runs this preflight first (fetcher.ts:212-214), a venue that only supports the documented GET status endpoint will reject the preflight before every order. The new Jest test does not catch this because it mocks getTermsStatus() instead of asserting the HTTP method/path used by the real implementation.
  2. core/src/exchanges/gemini-titan/fetcher.ts:145-149getTerms() has the same verb mismatch: the PR spec defines GET /v1/prediction-markets/terms (GeminiTitan.yaml:99-101), but the implementation uses postAuthenticated(). This makes the new helper unusable if the venue follows the documented spec.

PMXT Pipeline Check

  • Field propagation (3-layer): N/A
  • OpenAPI sync: ISSUE — the added spec and implementation disagree on HTTP verbs for read-only terms endpoints.
  • Financial precision: N/A
  • Type safety: OK — core TypeScript build passed.
  • Auth safety: OK — no credentials are logged; however, the new success/warn console output is noisy for library consumers.

Semver Impact

patch -- intended Gemini Titan trading bug fix with no SDK API break.

Risk

The preflight is on the order-submission path, so if Gemini's terms status endpoint is GET-only, all Gemini Titan order submissions will fail before reaching /order even for users whose terms are already accepted.

- Properly mock GeminiAuth
- Fix http client mock
- Use as any for private method spying
- Reset termsAccepted flag in tests

Fixes pmxt-dev#1068
@AbhilashG12

Copy link
Copy Markdown
Contributor Author

PR Updated ✅

Fix applied:

  • getTerms() now uses GET (was POST)
  • getTermsStatus() now uses GET (was POST)
  • acceptTerms() remains POST ✅
  • Unit tests updated to verify HTTP methods

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.

Spec drift: gemini-titan — terms acceptance gate blocks all order submissions for new API keys

2 participants