@predictasiax/api 2.5.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -329,17 +329,26 @@ interface RequestOptions {
329
329
  * - `Cache-Control: no-store` on every request — prevents intermediary caches
330
330
  * retaining authenticated responses
331
331
  * - `Referrer-Policy` compatible via `no-referrer` header
332
- * - HMAC clock skew adjustment via client option
332
+ * - HMAC (PAX-* headers) re-signed per attempt; clock offset via client option
333
333
  * - CR/LF injection on user headers rejected in mergeHeaders
334
334
  * - `redirect: manual` — refuses server-initiated redirects that could
335
335
  * downgrade to plaintext or cross-origin
336
336
  */
337
337
 
338
+ declare const DEFAULT_BASE_URL = "https://api.predictasiax.com";
339
+ /** Strip a trailing slash and a trailing `/v1` so paths never double to /v1/v1. */
340
+ declare function normalizeBaseUrl(url: string): string;
338
341
  interface HttpClientOptions {
342
+ /** `sk_live_...` key. Alone: sent as `Authorization: Bearer`. With `keyId`: HMAC signing key. */
339
343
  apiKey?: string;
344
+ /** Key id (`api_...`). Enables HMAC request signing with PAX-* headers. */
345
+ keyId?: string;
346
+ bearerToken?: string;
347
+ /** @deprecated Not part of the PAX API; passing it throws. Use `keyId` + `apiKey`. */
340
348
  secret?: string;
349
+ /** @deprecated Not part of the PAX API; passing it throws. Use `keyId` + `apiKey`. */
341
350
  passphrase?: string;
342
- bearerToken?: string;
351
+ /** Accepted for compatibility; every env uses the same host. */
343
352
  env?: Env;
344
353
  baseUrl?: string;
345
354
  timeoutMs?: number;
@@ -357,7 +366,7 @@ interface HttpClientOptions {
357
366
  */
358
367
  maxResponseBytes?: number;
359
368
  /**
360
- * Auto-generate `Idempotency-Key` on POST/PUT/PATCH when caller does not
369
+ * Auto-generate `Idempotency-Key` on POST/PUT/PATCH/DELETE when caller does not
361
370
  * provide one. Same key is reused across all retries of a single call.
362
371
  * Default: `true`. Set to `false` to require callers to always provide
363
372
  * their own key.
@@ -366,7 +375,7 @@ interface HttpClientOptions {
366
375
  /**
367
376
  * Milliseconds added to `Date.now()` when constructing HMAC timestamps.
368
377
  * Use to compensate for a locally-drifted clock (e.g. from `serverTime - Date.now()`).
369
- * Server accepts ±30 s skew, so a value beyond that will fail regardless.
378
+ * The gateway accepts ±300 s.
370
379
  */
371
380
  clockOffsetMs?: number;
372
381
  /**
@@ -385,9 +394,10 @@ interface RawResponse<T> {
385
394
  declare class HttpClient {
386
395
  readonly baseUrl: string;
387
396
  readonly userAgent: string;
397
+ /** "hmac" | "api_key" | "bearer" | "none" */
398
+ get authMode(): string;
388
399
  private readonly apiKey?;
389
- private readonly secret?;
390
- private readonly passphrase?;
400
+ private readonly keyId?;
391
401
  private readonly bearerToken?;
392
402
  private readonly timeoutMs;
393
403
  private readonly maxRetries;
@@ -562,29 +572,24 @@ declare abstract class Resource {
562
572
  }
563
573
 
564
574
  /**
565
- * Account resource — balances, positions, your trade history.
575
+ * Account resource (scope portfolio:read).
566
576
  *
567
- * GET /v1/account retrieve()
568
- * GET /v1/account/positions positions()
569
- * GET /v1/account/trades trades()
577
+ * GET /v1/balance balance()
578
+ * GET /v1/portfolio portfolio() positions + balances
579
+ * GET /v1/positions positions()
570
580
  */
571
581
 
572
- interface ListTradesParams {
573
- cursor?: string;
574
- limit?: number;
575
- marketId?: string;
576
- }
577
582
  declare class AccountResource extends Resource {
578
- retrieve(opts?: RequestOptions): APIPromise<Account>;
579
- positions(opts?: RequestOptions): APIPromise<Position[]>;
580
- trades(params?: ListTradesParams, opts?: RequestOptions): PagePromise<Trade>;
583
+ balance(opts?: RequestOptions): APIPromise<unknown>;
584
+ /** @deprecated Use balance(). Kept as an alias. */
585
+ retrieve(opts?: RequestOptions): APIPromise<unknown>;
586
+ portfolio(opts?: RequestOptions): APIPromise<unknown>;
587
+ positions(opts?: RequestOptions): APIPromise<unknown>;
581
588
  }
582
589
 
583
590
  /**
584
- * Audit resource — public no-auth verifier over PAX's hash-chained event
585
- * log + Merkle-batched anchor chain. Any third party (auditor, investor,
586
- * external verifier) can independently reconstruct + verify without trusting
587
- * PAX at all.
591
+ * Audit resource — public, no-auth access to the hash-chained event log and
592
+ * its Merkle batches, plus offline verifiers.
588
593
  *
589
594
  * GET /v1/audit/status status()
590
595
  * GET /v1/audit/batches/latest latestBatch()
@@ -592,44 +597,67 @@ declare class AccountResource extends Resource {
592
597
  * GET /v1/audit/events/{seq} getEvent(seq)
593
598
  * GET /v1/audit/proof/{seq} getProof(seq)
594
599
  * GET /v1/audit/anchor/{num} getAnchor(num)
600
+ * (client-side) verify(seq), verifyEvent(), verifyEventHash(), verifyProof()
595
601
  *
596
- * v2.2+ — Public Merkle audit chain surface. Algorithm is sorted-pair SHA-256
597
- * over the raw 32-byte digests (OpenZeppelin-style pair ordering, hashed with
598
- * SHA-256 — NOT keccak256). On-chain, verify with a SHA-256 sorted-pair verifier
599
- * (e.g. sha256(abi.encodePacked(a, b))); stock OZ `MerkleProof.verify` hashes
600
- * with keccak256 and will not match these roots.
602
+ * Checks:
603
+ * 1. event_hash == sha256_hex(utf8(prev_event_hash + canonical)); `canonical`
604
+ * is returned verbatim by getEvent().
605
+ * 2. Merkle inclusion: leaf = event_hash; each level is SHA-256 over the
606
+ * sorted pair of RAW 32-byte digests (not keccak256, not hex strings); an
607
+ * odd level duplicates its last node.
608
+ * 3. Proof length: a batch of n leaves needs exactly expectedProofLength(n)
609
+ * siblings. Any other length is rejected, so an interior node cannot be
610
+ * presented as a leaf (second-preimage).
611
+ *
612
+ * A root read from this API proves internal consistency only; compare it with
613
+ * the batch's external anchor (getAnchor) for an independent check.
601
614
  */
602
615
 
603
616
  interface AuditStatus {
604
617
  events: {
605
618
  total: number;
606
- first_at: string;
607
- last_at: string;
619
+ first_at_ms: number;
620
+ last_at_ms: number;
608
621
  };
609
622
  batches: {
610
623
  total: number;
611
624
  anchored: number;
612
625
  };
613
626
  latest_batch: AuditBatch | null;
614
- latest_anchor: Pick<AuditBatch, "batch_num" | "anchored_at" | "anchor_target" | "anchor_ref"> | null;
627
+ latest_anchor: {
628
+ batch_num: number;
629
+ anchored_at_ms: number | null;
630
+ anchor_target: string | null;
631
+ anchor_ref: string | null;
632
+ } | null;
615
633
  anchor_lag_seconds: number | null;
616
634
  publisher_mode: string;
617
635
  verify_docs: string;
618
636
  }
619
637
  interface AuditBatch {
620
638
  batch_num: number;
621
- batch_id: string;
639
+ batch_id?: string;
622
640
  first_seq: number;
623
641
  last_seq: number;
624
642
  event_count: number;
625
643
  merkle_root: string;
626
644
  prev_batch_hash: string | null;
627
- created_at: string;
628
- anchored_at: string | null;
645
+ created_at_ms: number;
646
+ anchored_at_ms: number | null;
647
+ anchor_target: string | null;
648
+ anchor_ref?: string | null;
649
+ anchor_proof?: Record<string, unknown> | null;
650
+ anchor_public_url?: string | null;
651
+ }
652
+ /** GET /v1/audit/anchor/{num} */
653
+ interface AuditAnchor {
654
+ batch_num: number;
655
+ merkle_root: string;
629
656
  anchor_target: string | null;
630
657
  anchor_ref: string | null;
658
+ anchored_at_ms: number | null;
631
659
  anchor_proof: Record<string, unknown> | null;
632
- anchor_public_url?: string | null;
660
+ anchor_public_url: string | null;
633
661
  }
634
662
  interface AuditEvent {
635
663
  event_id: string;
@@ -637,37 +665,80 @@ interface AuditEvent {
637
665
  event_type: string;
638
666
  prev_event_hash: string;
639
667
  event_hash: string;
668
+ /** Display copy of the payload; numbers may be stringified. Hash `canonical`, not this. */
640
669
  payload: unknown;
641
670
  idempotency_key: string;
642
- created_at: string;
671
+ created_at_ms: number;
643
672
  emitter: string;
644
673
  schema_version: number;
645
674
  batch_id: string | null;
646
675
  batch_seq: number | null;
676
+ /** The exact string that was hashed: event_hash = sha256(prev_event_hash + canonical). */
677
+ canonical: string;
678
+ hash_recipe?: string;
647
679
  }
648
680
  interface MerkleProof {
649
681
  seq: number;
650
682
  event_hash: string;
651
- batch: Pick<AuditBatch, "batch_num" | "merkle_root" | "first_seq" | "last_seq" | "anchored_at" | "anchor_target" | "anchor_ref">;
683
+ batch: {
684
+ batch_num: number;
685
+ merkle_root: string;
686
+ first_seq: number;
687
+ last_seq: number;
688
+ anchored_at_ms?: number | null;
689
+ anchor_target?: string | null;
690
+ anchor_public_url?: string | null;
691
+ };
652
692
  merkle_proof: string[];
653
- verify_algo: string;
654
- verify_snippet: string;
693
+ leaf_index?: number;
694
+ leaf_count?: number;
695
+ expected_proof_length?: number;
696
+ verify_algo?: string;
697
+ verify_snippet?: string;
698
+ }
699
+ interface AuditVerification {
700
+ ok: boolean;
701
+ checks: Record<string, boolean>;
702
+ leafCount?: number;
703
+ expectedProofLength?: number;
704
+ reason: string | null;
655
705
  }
706
+ /** Number of siblings in a valid proof for a batch of `leafCount` leaves. */
707
+ declare function expectedProofLength(leafCount: number): number;
656
708
  declare class AuditResource extends Resource {
657
709
  status(opts?: RequestOptions): APIPromise<AuditStatus>;
658
710
  latestBatch(opts?: RequestOptions): APIPromise<AuditBatch>;
659
711
  getBatch(batchNum: number, opts?: RequestOptions): APIPromise<AuditBatch>;
660
712
  getEvent(seq: number, opts?: RequestOptions): APIPromise<AuditEvent>;
661
713
  getProof(seq: number, opts?: RequestOptions): APIPromise<MerkleProof>;
662
- getAnchor(batchNum: number, opts?: RequestOptions): APIPromise<AuditBatch>;
714
+ getAnchor(batchNum: number, opts?: RequestOptions): APIPromise<AuditAnchor>;
663
715
  /**
664
- * Verify a Merkle inclusion proof locally (client-side). Sorted-pair SHA-256
665
- * over the raw 32-byte digests — identical logic to the server-side batcher,
666
- * so callers can independently confirm inclusion without trusting the API.
716
+ * Fetch event + proof for `seq` and run every offline check (event hash,
717
+ * same event, seq in batch, proof length, Merkle root). Pass `root` (e.g.
718
+ * the anchored root) for a check independent of this API's batch record.
667
719
  */
668
- static verifyProof(leaf: string, root: string, proof: string[]): boolean;
669
- /** Async variant using WebCrypto — works in browsers, Deno, Bun, edge runtimes. */
670
- static verifyProofAsync(leaf: string, root: string, proof: string[]): Promise<boolean>;
720
+ verify(seq: number, options?: {
721
+ root?: string;
722
+ } & RequestOptions): Promise<AuditVerification>;
723
+ /** Number of siblings in a valid proof for a batch of `leafCount` leaves. */
724
+ static expectedProofLength(leafCount: number): number;
725
+ /** Recompute event_hash = sha256(prev_event_hash + canonical) and check canonical.seq. */
726
+ static verifyEventHash(event: Pick<AuditEvent, "seq" | "prev_event_hash" | "event_hash" | "canonical">): boolean;
727
+ /** Run all checks for one event given getEvent() + getProof() data. */
728
+ static verifyEvent(event: AuditEvent, proof: MerkleProof, root?: string): AuditVerification;
729
+ /**
730
+ * Verify a Merkle inclusion proof locally. Synchronous and isomorphic
731
+ * (node:crypto when a sync `require` exists, else a built-in SHA-256).
732
+ *
733
+ * @param leaf the event's event_hash (64 hex chars)
734
+ * @param root the batch merkle_root (64 hex chars)
735
+ * @param proof sibling hashes, leaf level first (64 hex chars each)
736
+ * @param expectedLength expectedProofLength(leafCount) — required; any other
737
+ * proof length is rejected (second-preimage guard)
738
+ */
739
+ static verifyProof(leaf: string, root: string, proof: string[], expectedLength: number): boolean;
740
+ /** WebCrypto variant of verifyProof (same rules, including expectedLength). */
741
+ static verifyProofAsync(leaf: string, root: string, proof: string[], expectedLength: number): Promise<boolean>;
671
742
  }
672
743
 
673
744
  /**
@@ -770,174 +841,128 @@ declare class GrantsResource extends Resource {
770
841
  }
771
842
 
772
843
  /**
773
- * Keys resource — programmatic API-key management.
844
+ * Markets resource.
774
845
  *
775
- * POST /v1/keys create()
776
- * GET /v1/keys list()
777
- * DELETE /v1/keys/{id} revoke()
778
- *
779
- * `secret` is returned only on `create()` and is never shown again — store
780
- * it securely at that moment.
781
- */
782
-
783
- interface CreateKeyParams {
784
- name?: string;
785
- scopes?: KeyScope[];
786
- }
787
- declare class KeysResource extends Resource {
788
- create(params?: CreateKeyParams, opts?: RequestOptions): APIPromise<ApiKey>;
789
- list(opts?: RequestOptions): APIPromise<ApiKey[]>;
790
- revoke(keyId: string, opts?: RequestOptions): APIPromise<{
791
- revoked: boolean;
792
- }>;
793
- }
794
-
795
- /**
796
- * Markets resource — discovery, candles, orderbook, public trades, creation.
797
- *
798
- * Endpoints wrapped:
799
- * GET /v1/markets list()
846
+ * GET /v1/markets list() paginated
800
847
  * GET /v1/markets/{id} retrieve()
801
- * POST /v1/markets create()
802
- * GET /v1/candles/{market_id} candles()
803
- * GET /v1/orderbook/{market_id} orderbook()
804
- * GET /v1/trades/{market_id} trades() (public tape)
848
+ * GET /v1/markets/categories categories()
849
+ * GET /v1/markets/{id}/orderbook orderbook() public
850
+ * GET /v1/markets/{id}/price-history priceHistory() public
851
+ * GET /v1/markets/{id}/resolution resolution() public
852
+ * POST /v1/composer/markets create()
805
853
  */
806
854
 
807
855
  interface ListMarketsParams {
808
- category?: Category;
809
- marketType?: MarketType;
810
- status?: MarketStatus;
856
+ category?: string;
857
+ q?: string;
811
858
  cursor?: string;
812
859
  limit?: number;
813
860
  }
814
861
  interface CreateMarketParams {
815
- templateId: string;
816
- params: Record<string, unknown>;
817
- creatorMetadata?: Record<string, unknown>;
818
- }
819
- interface CandlesParams {
820
- outcomeId: string;
821
- interval?: CandleInterval;
822
- fromMs?: number;
823
- toMs?: number;
824
- limit?: number;
825
- }
826
- interface OrderbookParams {
827
- outcomeId: string;
828
- depth?: number;
829
- }
830
- interface MarketTradesParams {
831
- outcomeId?: string;
832
- cursor?: string;
833
- limit?: number;
862
+ title: string;
863
+ rulesText: string;
864
+ resolutionRule: string;
865
+ /** https:// URL of an allow-listed public data publisher. */
866
+ primarySourceUrl: string;
867
+ backupSourceUrls?: string[];
868
+ cutoffTimeMs: number;
869
+ resolutionDeadlineMs: number;
870
+ edgeCasesText?: string;
871
+ description?: string;
834
872
  }
873
+ type PriceHistoryRange = "1h" | "6h" | "1d" | "7d" | "30d" | "90d";
835
874
  declare class MarketsResource extends Resource {
836
- /** List markets — auto-paginates. Iterate with `for await (const m of ...)`. */
837
- list(params?: ListMarketsParams, opts?: RequestOptions): PagePromise<Market>;
838
- retrieve(marketId: string, opts?: RequestOptions): APIPromise<Market>;
839
- create(params: CreateMarketParams, opts?: RequestOptions): APIPromise<Market>;
840
- candles(marketId: string, params: CandlesParams, opts?: RequestOptions): APIPromise<Candle[]>;
841
- orderbook(marketId: string, params: OrderbookParams, opts?: RequestOptions): APIPromise<Orderbook>;
842
- /** Public trade tape for a market (all fills, not your fills). */
843
- trades(marketId: string, params?: MarketTradesParams, opts?: RequestOptions): PagePromise<Trade>;
844
- private _buildListQuery;
875
+ /** List markets; iterate every page with `for await (const m of pax.markets.list())`. */
876
+ list(params?: ListMarketsParams, opts?: RequestOptions): PagePromise<Record<string, unknown>>;
877
+ retrieve(marketId: string, opts?: RequestOptions): APIPromise<Record<string, unknown>>;
878
+ categories(opts?: RequestOptions): APIPromise<unknown>;
879
+ orderbook(marketId: string, opts?: RequestOptions): APIPromise<unknown>;
880
+ priceHistory(marketId: string, params?: {
881
+ range?: PriceHistoryRange;
882
+ }, opts?: RequestOptions): APIPromise<unknown>;
883
+ resolution(marketId: string, opts?: RequestOptions): APIPromise<unknown>;
884
+ create(params: CreateMarketParams, opts?: RequestOptions): APIPromise<unknown>;
845
885
  }
846
886
 
847
887
  /**
848
- * Orders resource — your orders (single + batch).
888
+ * Orders resource.
849
889
  *
850
- * POST /v1/orders place()
851
- * DELETE /v1/orders/{id} cancel()
852
- * GET /v1/account/orders list()
853
- * POST /v1/orders/batch placeBatch() — v2.1+, up to 25 orders
854
- * DELETE /v1/orders/batch cancelBatch() — v2.1+, up to 50 orders
890
+ * POST /v1/orders place() limit BUY of one outcome
891
+ * POST /v1/orders/batch placeBatch()
892
+ * GET /v1/orders list() your most recent orders
893
+ * GET /v1/orders/history history()
894
+ * DELETE /v1/orders/{id} cancel()
895
+ * POST /v1/orders/cancel-all cancelAll() all resting orders, or one market's
855
896
  */
856
897
 
857
898
  interface PlaceOrderParams {
858
899
  marketId: string;
859
- outcomeId: string;
860
- side: Side;
861
- orderType: OrderType;
900
+ /** The outcome to buy. */
901
+ side: "yes" | "no";
902
+ /** Limit price, 0.01..0.99. */
903
+ price: Decimal | number;
904
+ /** Shares, > 0. */
862
905
  size: Decimal | number;
863
- price?: Decimal | number;
906
+ /**
907
+ * Engine-side dedupe key. Generated once per call when omitted, so a retry
908
+ * of the same call can never place a second order.
909
+ */
864
910
  clientOrderId?: string;
865
- timeInForce?: TimeInForce;
911
+ fundingMode?: string;
866
912
  }
867
913
  interface ListOrdersParams {
868
- status?: OrderStatus;
869
- cursor?: string;
870
914
  limit?: number;
871
915
  }
872
- /** Per-item result inside a batch response — one entry per input order. */
916
+ interface OrderHistoryParams {
917
+ limit?: number;
918
+ cursor?: string;
919
+ }
920
+ interface OrderRow {
921
+ id: string;
922
+ market_id: string;
923
+ side: string;
924
+ action: string;
925
+ kind: string;
926
+ price: string;
927
+ size: string;
928
+ filled_size: string;
929
+ status: string;
930
+ created_at: string;
931
+ updated_at: string;
932
+ [k: string]: unknown;
933
+ }
934
+ interface OrderList {
935
+ orders: OrderRow[];
936
+ count: number;
937
+ }
873
938
  interface BatchOrderResultItem {
874
939
  ok: boolean;
875
940
  index: number;
876
941
  client_order_id: string | null;
877
942
  data?: unknown;
878
- attribution?: {
879
- execution_builder_id?: string;
880
- acquisition_builder_id?: string | null;
881
- order_id?: string | null;
882
- write?: {
883
- ok: boolean;
884
- rowCount?: number;
885
- reason?: string;
886
- };
887
- };
888
943
  error?: {
889
944
  code: string;
890
945
  message: string;
891
946
  };
892
947
  }
893
- interface BatchOrderSummary {
894
- submitted: number;
895
- succeeded: number;
896
- failed: number;
897
- duration_ms: number;
898
- }
899
948
  interface BatchOrdersResult {
900
949
  results: BatchOrderResultItem[];
901
- summary: BatchOrderSummary;
902
- }
903
- interface BatchCancelResultItem {
904
- ok: boolean;
905
- index: number;
906
- order_id?: string;
907
- data?: unknown;
908
- error?: {
909
- code: string;
910
- message: string;
950
+ summary: {
951
+ submitted: number;
952
+ succeeded: number;
953
+ failed: number;
954
+ duration_ms: number;
911
955
  };
912
956
  }
913
- interface BatchCancelResult {
914
- results: BatchCancelResultItem[];
915
- summary: BatchOrderSummary;
916
- }
917
957
  declare class OrdersResource extends Resource {
918
- place(params: PlaceOrderParams, opts?: RequestOptions): APIPromise<Order>;
919
- cancel(orderId: string, opts?: RequestOptions): APIPromise<Order>;
920
- list(params?: ListOrdersParams, opts?: RequestOptions): PagePromise<Order>;
921
- /**
922
- * Place multiple orders in a single request (up to 25 per batch).
923
- *
924
- * Each order is processed sequentially by the CLOB engine (single-writer per
925
- * market). Response contains a `results` array with one entry per input order
926
- * (indexed) plus a `summary` with counts + duration. One bad order does not
927
- * fail the whole batch — inspect `results[i].ok` per item.
928
- *
929
- * Batch cap is env-tunable server-side (BATCH_ORDERS_MAX, default 25). Exceeding
930
- * returns `413 BATCH_TOO_LARGE`.
931
- */
958
+ place(params: PlaceOrderParams, opts?: RequestOptions): APIPromise<unknown>;
932
959
  placeBatch(orders: PlaceOrderParams[], opts?: RequestOptions): APIPromise<BatchOrdersResult>;
933
- /**
934
- * Cancel multiple orders in a single request (up to 50 per batch).
935
- *
936
- * Each cancel is processed sequentially by the CLOB engine. Response mirrors
937
- * `placeBatch` shape — inspect `results[i].ok` per item. Batch cap env-tunable
938
- * server-side (BATCH_CANCEL_MAX, default 50).
939
- */
940
- cancelBatch(orderIds: string[], opts?: RequestOptions): APIPromise<BatchCancelResult>;
960
+ list(params?: ListOrdersParams, opts?: RequestOptions): APIPromise<OrderList>;
961
+ history(params?: OrderHistoryParams, opts?: RequestOptions): APIPromise<unknown>;
962
+ cancel(orderId: string, opts?: RequestOptions): APIPromise<unknown>;
963
+ cancelAll(params?: {
964
+ marketId?: string;
965
+ }, opts?: RequestOptions): APIPromise<unknown>;
941
966
  }
942
967
 
943
968
  /**
@@ -956,7 +981,7 @@ declare class OrdersResource extends Resource {
956
981
 
957
982
  interface SandboxKeyMintParams {
958
983
  orgName: string;
959
- contactEmail?: string;
984
+ contactHandle?: string;
960
985
  }
961
986
  interface ApplyCreateParams {
962
987
  /**
@@ -1003,15 +1028,10 @@ declare class SandboxResource extends Resource {
1003
1028
  /**
1004
1029
  * Settle resource — claim accrued fee revenue (v2.4+).
1005
1030
  *
1006
- * Three surfaces:
1007
- * - `me()` — builder self-serve claim of their own execution +
1008
- * acquisition builder fees. Uses api-key auth.
1009
- * - `adminBuilder()` — admin claim of a specific builder's accrued fees.
1010
- * Requires X-Admin-Key header.
1011
- * - `adminCreator()` — admin claim of a market creator's FEE_MARKET_CREATOR
1012
- * fees. Requires X-Admin-Key header.
1031
+ * - `me()` — POST /v1/builders/me/settle: builder self-serve claim of their
1032
+ * own execution + acquisition builder fees.
1013
1033
  *
1014
- * All three insert a `withdrawal_state` row with the appropriate source tag
1034
+ * Inserts a `withdrawal_state` row with the appropriate source tag
1015
1035
  * and mark the underlying `financial_event` rows settled. The existing
1016
1036
  * withdrawal pipeline delivers USDT to the provided address.
1017
1037
  */
@@ -1035,11 +1055,6 @@ interface SettleResult {
1035
1055
  declare class SettleResource extends Resource {
1036
1056
  /** Builder self-serve settle — POST /v1/builders/me/settle. */
1037
1057
  me(params: SettleParams, opts?: RequestOptions): APIPromise<SettleResult>;
1038
- /** Admin settle a specific builder's fees — POST /v1/admin/builders/{userId}/settle.
1039
- * Requires X-Admin-Key header. */
1040
- adminBuilder(userId: string, params: SettleParams, adminKey: string, opts?: RequestOptions): APIPromise<SettleResult>;
1041
- /** Admin settle a market creator's fees — POST /v1/admin/creators/{userId}/settle. */
1042
- adminCreator(userId: string, params: SettleParams, adminKey: string, opts?: RequestOptions): APIPromise<SettleResult>;
1043
1058
  }
1044
1059
 
1045
1060
  /**
@@ -1060,39 +1075,25 @@ declare class TemplatesResource extends Resource {
1060
1075
  }
1061
1076
 
1062
1077
  /**
1063
- * PaxClient — top-level entry point.
1064
- *
1065
- * Auth modes (auto-detected from constructor):
1066
- * 1. HMAC — pass `apiKey` + `secret` + `passphrase`. Every request
1067
- * signed with 5 POLY_* headers. Use for high-security trading.
1068
- * 2. API Key — pass only `apiKey`. Sent via `X-Api-Key` header.
1069
- * 3. Bearer — pass `bearerToken`. Session-based, browser/mobile.
1078
+ * PaxClient — top-level entry point for https://api.predictasiax.com.
1070
1079
  *
1071
- * Resources hang off the client, e.g. `pax.markets.list()`, following
1072
- * the Stripe/OpenAI/Anthropic convention.
1080
+ * Credentials (pick one; none is fine for public endpoints):
1081
+ * - `apiKey: "sk_live_..."` → Authorization: Bearer sk_live_...
1082
+ * - `apiKey: "sk_live_...", keyId: "api_..."` → HMAC request signing (PAX-* headers)
1083
+ * - `bearerToken: "..."` → session / OAuth token
1073
1084
  *
1074
1085
  * @example
1075
1086
  * import { PaxClient } from "@predictasiax/api";
1076
1087
  *
1077
- * // Mint an anonymous sandbox key first (30 sec, no email):
1078
- * // curl -X POST https://api.predictasiax.com/v1/sandbox-keys \
1079
- * // -H 'Content-Type: application/json' -d '{"org_name":"my-app"}'
1080
- * // → { api_key: "sk_live_...", tier: "self_serve", ... }
1081
- * const pax = new PaxClient({ apiKey: "sk_live_..." });
1082
- * const account = await pax.account.retrieve();
1083
- *
1084
- * for await (const market of pax.markets.list({ category: "crypto" })) {
1085
- * console.log(market.id, market.title);
1086
- * }
1088
+ * const pub = new PaxClient();
1089
+ * const check = await pub.audit.verify(1866215); // offline audit checks
1087
1090
  *
1088
- * const { data, response, requestId } =
1089
- * await pax.orders.place({
1090
- * marketId: "m_abc", outcomeId: "yes",
1091
- * side: "buy", orderType: "market", size: "10",
1092
- * }, { idempotencyKey: "ord_1" }).withResponse();
1091
+ * const pax = new PaxClient({ apiKey: "sk_live_...", keyId: "api_..." });
1092
+ * await pax.account.balance();
1093
+ * await pax.orders.place({ marketId: "hadjar-f1-2026", side: "yes", price: "0.05", size: "10" });
1093
1094
  */
1094
1095
 
1095
- declare const VERSION = "2.2.0";
1096
+ declare const VERSION = "3.0.0";
1096
1097
  type PaxClientOptions = HttpClientOptions;
1097
1098
  declare class PaxClient {
1098
1099
  private readonly _http;
@@ -1100,7 +1101,6 @@ declare class PaxClient {
1100
1101
  readonly templates: TemplatesResource;
1101
1102
  readonly orders: OrdersResource;
1102
1103
  readonly account: AccountResource;
1103
- readonly keys: KeysResource;
1104
1104
  readonly sandbox: SandboxResource;
1105
1105
  readonly sandboxKeys: SandboxKeysResource;
1106
1106
  readonly apply: ApplyResource;
@@ -1108,9 +1108,10 @@ declare class PaxClient {
1108
1108
  readonly fees: FeesResource;
1109
1109
  readonly audit: AuditResource;
1110
1110
  readonly settle: SettleResource;
1111
- constructor(opts: PaxClientOptions);
1111
+ constructor(opts?: PaxClientOptions);
1112
1112
  get baseUrl(): string;
1113
1113
  get userAgent(): string;
1114
+ get authMode(): string;
1114
1115
  /** GET /v1/health — top-level, not paginated, always safe. */
1115
1116
  health(opts?: RequestOptions): APIPromise<HealthStatus>;
1116
1117
  }
@@ -1285,51 +1286,48 @@ declare class PaxWSClient {
1285
1286
  }
1286
1287
 
1287
1288
  /**
1288
- * HMAC signing helpers — 5-header pattern with PAX-ADDRESS, PAX-TIMESTAMP, PAX-NONCE, PAX-SIGNATURE plus Content-Type.
1289
+ * HMAC request signing for the PAX API gateway (https://api.predictasiax.com).
1289
1290
  *
1290
- * Signature construction:
1291
- * message = timestamp_ms + method_upper + path_with_query + body
1292
- * signature = base64(HMAC-SHA256(secret, message))
1291
+ * What the gateway verifies:
1293
1292
  *
1294
- * Headers sent:
1295
- * POLY_ACCESS_KEY: <key_id>
1296
- * POLY_TIMESTAMP: <ms epoch>
1297
- * POLY_PASSPHRASE: <passphrase>
1298
- * POLY_SIGNATURE: <base64 sig>
1293
+ * canonical = timestamp + "\n" + nonce + "\n" + METHOD + "\n" + pathWithQuery + "\n" + body
1294
+ * signature = base64(HMAC-SHA256(key = apiKey, msg = canonical))
1299
1295
  *
1300
- * Server rejects with 401 INVALID_SIGNATURE if timestamp is more than
1301
- * ±30 seconds from server clock — sync your machine via NTP.
1296
+ * PAX-ADDRESS: <key id, e.g. api_0123456789ab>
1297
+ * PAX-TIMESTAMP: <unix seconds> accepted window: ±300 s
1298
+ * PAX-NONCE: <random, single use> remembered for 600 s per key
1299
+ * PAX-SIGNATURE: <base64 signature>
1302
1300
  *
1303
- * Runtime support:
1304
- * - Node.js 18+ / Bun / Deno → node:crypto (via createHmac)
1305
- * - Browser / Cloudflare Workers / Vercel Edge → WebCrypto (subtle.sign)
1301
+ * `apiKey` is the full `sk_live_...` string shown once at mint time; the key
1302
+ * itself is never sent. `pathWithQuery` includes `/v1` and the query string.
1303
+ * Sign every attempt afresh (new timestamp + nonce), retries included.
1306
1304
  *
1307
- * `signRequest` is async because WebCrypto's subtle.sign is async.
1305
+ * Runtime: WebCrypto when available (browsers, edge, Node 18+), else node:crypto.
1308
1306
  */
1309
1307
  interface HmacHeaders {
1310
- POLY_ACCESS_KEY: string;
1311
- POLY_TIMESTAMP: string;
1312
- POLY_PASSPHRASE: string;
1313
- POLY_SIGNATURE: string;
1308
+ "PAX-ADDRESS": string;
1309
+ "PAX-TIMESTAMP": string;
1310
+ "PAX-NONCE": string;
1311
+ "PAX-SIGNATURE": string;
1314
1312
  }
1315
1313
  interface SignInput {
1316
1314
  method: string;
1317
- path: string;
1315
+ /** Path including `/v1` and the query string, exactly as sent. */
1316
+ pathWithQuery: string;
1317
+ /** Raw body exactly as sent ("" when there is none). */
1318
1318
  body: string;
1319
+ /** Key id (`api_...`), sent as PAX-ADDRESS. */
1319
1320
  keyId: string;
1320
- secret: string;
1321
- passphrase: string;
1322
- timestampMs?: number;
1323
- }
1324
- /** Return the canonical signing message (exposed for debugging). */
1325
- declare function buildMessage(method: string, path: string, body: string, timestampMs: number): string;
1326
- /**
1327
- * Sign a PAX request. Returns the four POLY_* headers.
1328
- *
1329
- * On Node this uses `node:crypto`; on browser / edge runtimes it falls back
1330
- * to WebCrypto. Both paths are byte-for-byte identical because HMAC-SHA256
1331
- * is deterministic.
1332
- */
1321
+ /** Full `sk_live_...` key, used as the HMAC key. */
1322
+ apiKey: string;
1323
+ /** Unix seconds override (tests only). */
1324
+ timestampSec?: number;
1325
+ /** Nonce override (tests only). Never reuse a nonce. */
1326
+ nonce?: string;
1327
+ }
1328
+ /** Return the exact string the gateway signs (exposed for debugging). */
1329
+ declare function buildCanonical(timestamp: string | number, nonce: string, method: string, pathWithQuery: string, body: string): string;
1330
+ /** Build the four PAX-* headers for one request attempt. */
1333
1331
  declare function signRequest(input: SignInput): Promise<HmacHeaders>;
1334
1332
 
1335
1333
  /**
@@ -1423,4 +1421,4 @@ declare function runWithRetry<T>(fn: () => Promise<T>, opts?: {
1423
1421
  onRetry?: (attempt: number, error: Error) => void;
1424
1422
  }): Promise<T>;
1425
1423
 
1426
- export { APIPromise, type APIResponseInfo, type Account, type AccountBalance, AccountResource, type ApiKey, type ApplicationResult, type ApplicationStatus, type ApplyCreateParams, ApplyResource, type AttachRefOptions, type AttachRefResult, type AuditBatch, type AuditEvent, AuditResource, type AuditStatus, type BatchCancelResult, type BatchCancelResultItem, type BatchOrderResultItem, type BatchOrderSummary, type BatchOrdersResult, type Candle, type CandleInterval, type CandlesParams, type Category, type CreateKeyParams, type CreateMarketParams, CursorPage, type CursorPageInit, type CursorPageParams, type Decimal, type Env, type Envelope, type FeeEstimate, type FeeEstimateParams, FeesResource, type GrantClaimResult, type GrantEvent, type GrantEventType, type GrantPhase, type GrantTier, type GrantVesting, GrantsResource, type HealthStatus, type HmacHeaders, type HttpClientOptions, type KeyScope, KeysResource, type ListEnvelope, type ListMarketsParams, type ListOrdersParams, type ListTemplatesParams, type ListTradesParams, type Market, type MarketStatus, type MarketTemplate, type MarketTradesParams, type MarketType, MarketsResource, type MerkleProof, type Order, type OrderStatus, type OrderType, type Orderbook, type OrderbookLevel, type OrderbookParams, OrdersResource, type Outcome, PagePromise, PaxAuthError, PaxCircuitBreakerError, PaxClient, type PaxClientOptions, PaxConflictError, PaxError, type PaxErrorDetails, type PaxErrorPayload, PaxNotFoundError, PaxRateLimitError, PaxReadOnlyModeError, PaxSandboxOnlyError, PaxServerError, PaxValidationError, PaxWSClient, type PaxWSClientOptions, PaxWrongEnvKeyError, type PlaceOrderParams, type Position, type RequestOptions, type ResponseMeta, type SandboxKeyMintParams, type SandboxKeyResult, SandboxKeysResource, SandboxResource, type Side, type SignInput, TemplatesResource, type Tier, type TierLimits, type TimeInForce, type TokenGrant, type Trade, VERSION, type WithResponseResult, type WsEvent, type WsHandler, attachRef, buildError, buildMessage, clearRef, computeBackoff, runWithRetry, signRequest };
1424
+ export { APIPromise, type APIResponseInfo, type Account, type AccountBalance, AccountResource, type ApiKey, type ApplicationResult, type ApplicationStatus, type ApplyCreateParams, ApplyResource, type AttachRefOptions, type AttachRefResult, type AuditAnchor, type AuditBatch, type AuditEvent, AuditResource, type AuditStatus, type AuditVerification, type BatchOrderResultItem, type BatchOrdersResult, type Candle, type CandleInterval, type Category, type CreateMarketParams, CursorPage, type CursorPageInit, type CursorPageParams, DEFAULT_BASE_URL, type Decimal, type Env, type Envelope, type FeeEstimate, type FeeEstimateParams, FeesResource, type GrantClaimResult, type GrantEvent, type GrantEventType, type GrantPhase, type GrantTier, type GrantVesting, GrantsResource, type HealthStatus, type HmacHeaders, type HttpClientOptions, type KeyScope, type ListEnvelope, type ListMarketsParams, type ListOrdersParams, type ListTemplatesParams, type Market, type MarketStatus, type MarketTemplate, type MarketType, MarketsResource, type MerkleProof, type Order, type OrderHistoryParams, type OrderList, type OrderRow, type OrderStatus, type OrderType, type Orderbook, type OrderbookLevel, OrdersResource, type Outcome, PagePromise, PaxAuthError, PaxCircuitBreakerError, PaxClient, type PaxClientOptions, PaxConflictError, PaxError, type PaxErrorDetails, type PaxErrorPayload, PaxNotFoundError, PaxRateLimitError, PaxReadOnlyModeError, PaxSandboxOnlyError, PaxServerError, PaxValidationError, PaxWSClient, type PaxWSClientOptions, PaxWrongEnvKeyError, type PlaceOrderParams, type Position, type PriceHistoryRange, type RequestOptions, type ResponseMeta, type SandboxKeyMintParams, type SandboxKeyResult, SandboxKeysResource, SandboxResource, SettleResource, type Side, type SignInput, TemplatesResource, type Tier, type TierLimits, type TimeInForce, type TokenGrant, type Trade, VERSION, type WithResponseResult, type WsEvent, type WsHandler, attachRef, buildCanonical, buildError, clearRef, computeBackoff, expectedProofLength, normalizeBaseUrl, runWithRetry, signRequest };