Developers

Authentication

EIP-712 typed-data intents, nonces, and optional trading-session tokens.

EIP-712 domain

All Amplifi intents use the same domain:

{
  "name": "Amplifi",
  "version": "1",
  "chainId": 137,
  "verifyingContract": "<POLYMARKET_LENDING_POOL_ADDRESS for the VM>"
}

The verifying contract is the lending pool address on the VM the integrator is talking to — fetch it once from the /polymarket/positions/nonce/... or /polymarket/nonce/... endpoints; never hard-code it. (GET /health also reports addresses in its body.)

Intent types

Intents are nonced per user, per intent type. Each intent type has its own counter:

Intent type slugEIP-712 primary typeUsed by
openOpenPositionIntentPOST /polymarket/positions/open
closeClosePositionIntentPOST /polymarket/positions/{id}/close
cancel_orderCancelOrderIntentPOST /polymarket/orders/{id}/cancel
withdrawWithdrawalIntentPOST /polymarket/withdrawals
sessionTradingSessionIntentPOST /auth/trading-session
apply_referralApplyReferralIntentPOST /referral/apply
admin_closeAdminClosePositionIntentOperator endpoint (allowlisted)
delegate_debug_keyDelegateDebugKeyRead-only debug DB API (operator-only)

Get the next nonce + domain + types

For deposits (separate nonce space):

GET /polymarket/nonce/{userAddress}
→ { "nonce": 5, "domain": { … }, "types": { "DepositIntent": [ … ] } }

For everything else:

GET /polymarket/positions/nonce/{intentType}/{userAddress}
→ { "nonce": 12, "domain": { … }, "types": { "OpenPositionIntent": [ … ] } }

intentType is one of: open, close, cancel_order, withdraw, session, apply_referral, admin_close, delegate_debug_key, repay.

A signed intent is valid until the first of:

  1. deadline (unix seconds) elapses,
  2. The nonce is consumed by a successful request (one-time use), or
  3. A later request consumes a higher nonce for the same (user, intent type) (nonces are strictly monotonic per type).

A deadline more than one hour ahead of the server clock is rejected with 400 Signature deadline too far ahead; sign a few minutes ahead and re-sign on expiry.

Trading session (optional)

If the integrator wants to skip per-action signing for the lifetime of the session:

POST /auth/trading-session
{
  "userAddress": "0x…",
  "durationSeconds": 86400,        // optional; default + max = 7 days
  "nonce":   <from GET nonce/session/…>,
  "deadline": <unix seconds>,
  "signature": "0x…"               // signs TradingSessionIntent
}
→ { "token": "…", "expiresAt": 1234567890 }

Then for every subsequent POST /polymarket/positions/open, …/close, POST /polymarket/orders, POST /polymarket/orders/{id}/cancel, or take-profit endpoint, send the token either as:

  • Body field sessionToken: "…", or
  • Header x-trading-session: …

When sessionToken is present in the body and matches userAddress, the EIP-712 fields (signature, nonce, deadline) are not required.

Revoke explicitly: DELETE /auth/trading-session with body { "token": "…" } or the header. Check validity: GET /auth/trading-session/status with header x-trading-session: ….

Limit orders (POST /polymarket/orders) currently require a trading session — signed placement is not yet implemented. Cancel works with either.

Access codes

Production may gate signup with access codes. Check with GET /auth/config — if accessCodeRequired: true, bind a code to a wallet via POST /auth/submit-code before doing anything else. Rate-limited to 10 attempts per 15 minutes per IP.