@predictasiax/api 2.1.0 → 2.4.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
@@ -580,6 +580,95 @@ declare class AccountResource extends Resource {
580
580
  trades(params?: ListTradesParams, opts?: RequestOptions): PagePromise<Trade>;
581
581
  }
582
582
 
583
+ /**
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.
588
+ *
589
+ * GET /v1/audit/status status()
590
+ * GET /v1/audit/batches/latest latestBatch()
591
+ * GET /v1/audit/batches/{num} getBatch(num)
592
+ * GET /v1/audit/events/{seq} getEvent(seq)
593
+ * GET /v1/audit/proof/{seq} getProof(seq)
594
+ * GET /v1/audit/anchor/{num} getAnchor(num)
595
+ *
596
+ * v2.2+ — Polymarket has no equivalent surface. Merkle algo is OpenZeppelin
597
+ * sorted-pair sha256, so Solidity `MerkleProof.verify` can verify proofs
598
+ * on-chain without changes.
599
+ */
600
+
601
+ interface AuditStatus {
602
+ events: {
603
+ total: number;
604
+ first_at: string;
605
+ last_at: string;
606
+ };
607
+ batches: {
608
+ total: number;
609
+ anchored: number;
610
+ };
611
+ latest_batch: AuditBatch | null;
612
+ latest_anchor: Pick<AuditBatch, "batch_num" | "anchored_at" | "anchor_target" | "anchor_ref"> | null;
613
+ anchor_lag_seconds: number | null;
614
+ publisher_mode: string;
615
+ verify_docs: string;
616
+ }
617
+ interface AuditBatch {
618
+ batch_num: number;
619
+ batch_id: string;
620
+ first_seq: number;
621
+ last_seq: number;
622
+ event_count: number;
623
+ merkle_root: string;
624
+ prev_batch_hash: string | null;
625
+ created_at: string;
626
+ anchored_at: string | null;
627
+ anchor_target: string | null;
628
+ anchor_ref: string | null;
629
+ anchor_proof: Record<string, unknown> | null;
630
+ anchor_public_url?: string | null;
631
+ }
632
+ interface AuditEvent {
633
+ event_id: string;
634
+ seq: number;
635
+ event_type: string;
636
+ prev_event_hash: string;
637
+ event_hash: string;
638
+ payload: unknown;
639
+ idempotency_key: string;
640
+ created_at: string;
641
+ emitter: string;
642
+ schema_version: number;
643
+ batch_id: string | null;
644
+ batch_seq: number | null;
645
+ }
646
+ interface MerkleProof {
647
+ seq: number;
648
+ event_hash: string;
649
+ batch: Pick<AuditBatch, "batch_num" | "merkle_root" | "first_seq" | "last_seq" | "anchored_at" | "anchor_target" | "anchor_ref">;
650
+ merkle_proof: string[];
651
+ verify_algo: string;
652
+ verify_snippet: string;
653
+ }
654
+ declare class AuditResource extends Resource {
655
+ status(opts?: RequestOptions): APIPromise<AuditStatus>;
656
+ latestBatch(opts?: RequestOptions): APIPromise<AuditBatch>;
657
+ getBatch(batchNum: number, opts?: RequestOptions): APIPromise<AuditBatch>;
658
+ getEvent(seq: number, opts?: RequestOptions): APIPromise<AuditEvent>;
659
+ getProof(seq: number, opts?: RequestOptions): APIPromise<MerkleProof>;
660
+ getAnchor(batchNum: number, opts?: RequestOptions): APIPromise<AuditBatch>;
661
+ /**
662
+ * Verify a Merkle inclusion proof locally (client-side). Mirrors
663
+ * OpenZeppelin's sorted-pair sha256 algorithm — identical logic to the
664
+ * server-side batcher, so callers can independently confirm inclusion
665
+ * without trusting the API response.
666
+ */
667
+ static verifyProof(leaf: string, root: string, proof: string[]): boolean;
668
+ /** Async variant using WebCrypto — works in browsers, Deno, Bun, edge runtimes. */
669
+ static verifyProofAsync(leaf: string, root: string, proof: string[]): Promise<boolean>;
670
+ }
671
+
583
672
  /**
584
673
  * Fees resource — pre-trade 5-actor split estimator.
585
674
  *
@@ -910,6 +999,48 @@ declare class ApplyResource extends Resource {
910
999
  declare class SandboxResource extends Resource {
911
1000
  }
912
1001
 
1002
+ /**
1003
+ * Settle resource — claim accrued fee revenue (v2.4+).
1004
+ *
1005
+ * Three surfaces:
1006
+ * - `me()` — builder self-serve claim of their own execution +
1007
+ * acquisition builder fees. Uses api-key auth.
1008
+ * - `adminBuilder()` — admin claim of a specific builder's accrued fees.
1009
+ * Requires X-Admin-Key header.
1010
+ * - `adminCreator()` — admin claim of a market creator's FEE_MARKET_CREATOR
1011
+ * fees. Requires X-Admin-Key header.
1012
+ *
1013
+ * All three insert a `withdrawal_state` row with the appropriate source tag
1014
+ * and mark the underlying `financial_event` rows settled. The existing
1015
+ * withdrawal pipeline delivers USDT to the provided address.
1016
+ */
1017
+ interface SettleParams {
1018
+ address: string;
1019
+ asset?: string;
1020
+ network?: string;
1021
+ min_amount?: number;
1022
+ }
1023
+ interface SettleResult {
1024
+ withdrawal_state_id: string;
1025
+ user_id: string;
1026
+ asset: string;
1027
+ amount: number;
1028
+ event_count: number;
1029
+ network: string;
1030
+ address: string;
1031
+ status: string;
1032
+ note?: string;
1033
+ }
1034
+ declare class SettleResource extends Resource {
1035
+ /** Builder self-serve settle — POST /v1/builders/me/settle. */
1036
+ me(params: SettleParams, opts?: RequestOptions): APIPromise<SettleResult>;
1037
+ /** Admin settle a specific builder's fees — POST /v1/admin/builders/{userId}/settle.
1038
+ * Requires X-Admin-Key header. */
1039
+ adminBuilder(userId: string, params: SettleParams, adminKey: string, opts?: RequestOptions): APIPromise<SettleResult>;
1040
+ /** Admin settle a market creator's fees — POST /v1/admin/creators/{userId}/settle. */
1041
+ adminCreator(userId: string, params: SettleParams, adminKey: string, opts?: RequestOptions): APIPromise<SettleResult>;
1042
+ }
1043
+
913
1044
  /**
914
1045
  * Templates resource — parameterized market blueprints.
915
1046
  *
@@ -960,7 +1091,7 @@ declare class TemplatesResource extends Resource {
960
1091
  * }, { idempotencyKey: "ord_1" }).withResponse();
961
1092
  */
962
1093
 
963
- declare const VERSION = "2.1.0";
1094
+ declare const VERSION = "2.2.0";
964
1095
  type PaxClientOptions = HttpClientOptions;
965
1096
  declare class PaxClient {
966
1097
  private readonly _http;
@@ -974,6 +1105,8 @@ declare class PaxClient {
974
1105
  readonly apply: ApplyResource;
975
1106
  readonly grants: GrantsResource;
976
1107
  readonly fees: FeesResource;
1108
+ readonly audit: AuditResource;
1109
+ readonly settle: SettleResource;
977
1110
  constructor(opts: PaxClientOptions);
978
1111
  get baseUrl(): string;
979
1112
  get userAgent(): string;
@@ -1215,4 +1348,4 @@ declare function runWithRetry<T>(fn: () => Promise<T>, opts?: {
1215
1348
  onRetry?: (attempt: number, error: Error) => void;
1216
1349
  }): Promise<T>;
1217
1350
 
1218
- export { APIPromise, type APIResponseInfo, type Account, type AccountBalance, AccountResource, type ApiKey, type ApplicationResult, type ApplicationStatus, type ApplyCreateParams, ApplyResource, 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 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, buildError, buildMessage, computeBackoff, runWithRetry, signRequest };
1351
+ export { APIPromise, type APIResponseInfo, type Account, type AccountBalance, AccountResource, type ApiKey, type ApplicationResult, type ApplicationStatus, type ApplyCreateParams, ApplyResource, 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, buildError, buildMessage, computeBackoff, runWithRetry, signRequest };
package/dist/index.d.ts CHANGED
@@ -580,6 +580,95 @@ declare class AccountResource extends Resource {
580
580
  trades(params?: ListTradesParams, opts?: RequestOptions): PagePromise<Trade>;
581
581
  }
582
582
 
583
+ /**
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.
588
+ *
589
+ * GET /v1/audit/status status()
590
+ * GET /v1/audit/batches/latest latestBatch()
591
+ * GET /v1/audit/batches/{num} getBatch(num)
592
+ * GET /v1/audit/events/{seq} getEvent(seq)
593
+ * GET /v1/audit/proof/{seq} getProof(seq)
594
+ * GET /v1/audit/anchor/{num} getAnchor(num)
595
+ *
596
+ * v2.2+ — Polymarket has no equivalent surface. Merkle algo is OpenZeppelin
597
+ * sorted-pair sha256, so Solidity `MerkleProof.verify` can verify proofs
598
+ * on-chain without changes.
599
+ */
600
+
601
+ interface AuditStatus {
602
+ events: {
603
+ total: number;
604
+ first_at: string;
605
+ last_at: string;
606
+ };
607
+ batches: {
608
+ total: number;
609
+ anchored: number;
610
+ };
611
+ latest_batch: AuditBatch | null;
612
+ latest_anchor: Pick<AuditBatch, "batch_num" | "anchored_at" | "anchor_target" | "anchor_ref"> | null;
613
+ anchor_lag_seconds: number | null;
614
+ publisher_mode: string;
615
+ verify_docs: string;
616
+ }
617
+ interface AuditBatch {
618
+ batch_num: number;
619
+ batch_id: string;
620
+ first_seq: number;
621
+ last_seq: number;
622
+ event_count: number;
623
+ merkle_root: string;
624
+ prev_batch_hash: string | null;
625
+ created_at: string;
626
+ anchored_at: string | null;
627
+ anchor_target: string | null;
628
+ anchor_ref: string | null;
629
+ anchor_proof: Record<string, unknown> | null;
630
+ anchor_public_url?: string | null;
631
+ }
632
+ interface AuditEvent {
633
+ event_id: string;
634
+ seq: number;
635
+ event_type: string;
636
+ prev_event_hash: string;
637
+ event_hash: string;
638
+ payload: unknown;
639
+ idempotency_key: string;
640
+ created_at: string;
641
+ emitter: string;
642
+ schema_version: number;
643
+ batch_id: string | null;
644
+ batch_seq: number | null;
645
+ }
646
+ interface MerkleProof {
647
+ seq: number;
648
+ event_hash: string;
649
+ batch: Pick<AuditBatch, "batch_num" | "merkle_root" | "first_seq" | "last_seq" | "anchored_at" | "anchor_target" | "anchor_ref">;
650
+ merkle_proof: string[];
651
+ verify_algo: string;
652
+ verify_snippet: string;
653
+ }
654
+ declare class AuditResource extends Resource {
655
+ status(opts?: RequestOptions): APIPromise<AuditStatus>;
656
+ latestBatch(opts?: RequestOptions): APIPromise<AuditBatch>;
657
+ getBatch(batchNum: number, opts?: RequestOptions): APIPromise<AuditBatch>;
658
+ getEvent(seq: number, opts?: RequestOptions): APIPromise<AuditEvent>;
659
+ getProof(seq: number, opts?: RequestOptions): APIPromise<MerkleProof>;
660
+ getAnchor(batchNum: number, opts?: RequestOptions): APIPromise<AuditBatch>;
661
+ /**
662
+ * Verify a Merkle inclusion proof locally (client-side). Mirrors
663
+ * OpenZeppelin's sorted-pair sha256 algorithm — identical logic to the
664
+ * server-side batcher, so callers can independently confirm inclusion
665
+ * without trusting the API response.
666
+ */
667
+ static verifyProof(leaf: string, root: string, proof: string[]): boolean;
668
+ /** Async variant using WebCrypto — works in browsers, Deno, Bun, edge runtimes. */
669
+ static verifyProofAsync(leaf: string, root: string, proof: string[]): Promise<boolean>;
670
+ }
671
+
583
672
  /**
584
673
  * Fees resource — pre-trade 5-actor split estimator.
585
674
  *
@@ -910,6 +999,48 @@ declare class ApplyResource extends Resource {
910
999
  declare class SandboxResource extends Resource {
911
1000
  }
912
1001
 
1002
+ /**
1003
+ * Settle resource — claim accrued fee revenue (v2.4+).
1004
+ *
1005
+ * Three surfaces:
1006
+ * - `me()` — builder self-serve claim of their own execution +
1007
+ * acquisition builder fees. Uses api-key auth.
1008
+ * - `adminBuilder()` — admin claim of a specific builder's accrued fees.
1009
+ * Requires X-Admin-Key header.
1010
+ * - `adminCreator()` — admin claim of a market creator's FEE_MARKET_CREATOR
1011
+ * fees. Requires X-Admin-Key header.
1012
+ *
1013
+ * All three insert a `withdrawal_state` row with the appropriate source tag
1014
+ * and mark the underlying `financial_event` rows settled. The existing
1015
+ * withdrawal pipeline delivers USDT to the provided address.
1016
+ */
1017
+ interface SettleParams {
1018
+ address: string;
1019
+ asset?: string;
1020
+ network?: string;
1021
+ min_amount?: number;
1022
+ }
1023
+ interface SettleResult {
1024
+ withdrawal_state_id: string;
1025
+ user_id: string;
1026
+ asset: string;
1027
+ amount: number;
1028
+ event_count: number;
1029
+ network: string;
1030
+ address: string;
1031
+ status: string;
1032
+ note?: string;
1033
+ }
1034
+ declare class SettleResource extends Resource {
1035
+ /** Builder self-serve settle — POST /v1/builders/me/settle. */
1036
+ me(params: SettleParams, opts?: RequestOptions): APIPromise<SettleResult>;
1037
+ /** Admin settle a specific builder's fees — POST /v1/admin/builders/{userId}/settle.
1038
+ * Requires X-Admin-Key header. */
1039
+ adminBuilder(userId: string, params: SettleParams, adminKey: string, opts?: RequestOptions): APIPromise<SettleResult>;
1040
+ /** Admin settle a market creator's fees — POST /v1/admin/creators/{userId}/settle. */
1041
+ adminCreator(userId: string, params: SettleParams, adminKey: string, opts?: RequestOptions): APIPromise<SettleResult>;
1042
+ }
1043
+
913
1044
  /**
914
1045
  * Templates resource — parameterized market blueprints.
915
1046
  *
@@ -960,7 +1091,7 @@ declare class TemplatesResource extends Resource {
960
1091
  * }, { idempotencyKey: "ord_1" }).withResponse();
961
1092
  */
962
1093
 
963
- declare const VERSION = "2.1.0";
1094
+ declare const VERSION = "2.2.0";
964
1095
  type PaxClientOptions = HttpClientOptions;
965
1096
  declare class PaxClient {
966
1097
  private readonly _http;
@@ -974,6 +1105,8 @@ declare class PaxClient {
974
1105
  readonly apply: ApplyResource;
975
1106
  readonly grants: GrantsResource;
976
1107
  readonly fees: FeesResource;
1108
+ readonly audit: AuditResource;
1109
+ readonly settle: SettleResource;
977
1110
  constructor(opts: PaxClientOptions);
978
1111
  get baseUrl(): string;
979
1112
  get userAgent(): string;
@@ -1215,4 +1348,4 @@ declare function runWithRetry<T>(fn: () => Promise<T>, opts?: {
1215
1348
  onRetry?: (attempt: number, error: Error) => void;
1216
1349
  }): Promise<T>;
1217
1350
 
1218
- export { APIPromise, type APIResponseInfo, type Account, type AccountBalance, AccountResource, type ApiKey, type ApplicationResult, type ApplicationStatus, type ApplyCreateParams, ApplyResource, 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 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, buildError, buildMessage, computeBackoff, runWithRetry, signRequest };
1351
+ export { APIPromise, type APIResponseInfo, type Account, type AccountBalance, AccountResource, type ApiKey, type ApplicationResult, type ApplicationStatus, type ApplyCreateParams, ApplyResource, 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, buildError, buildMessage, computeBackoff, runWithRetry, signRequest };
package/dist/index.js CHANGED
Binary file