@proof-labs/trading-sdk 4.2.0 → 5.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.
Files changed (61) hide show
  1. package/README.md +57 -7
  2. package/dist/client.d.ts +95 -39
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +412 -202
  5. package/dist/client.js.map +1 -1
  6. package/dist/codec-adapter.d.ts.map +1 -1
  7. package/dist/codec-adapter.js +8 -3
  8. package/dist/codec-adapter.js.map +1 -1
  9. package/dist/crypto.d.ts +20 -0
  10. package/dist/crypto.d.ts.map +1 -1
  11. package/dist/crypto.js +39 -0
  12. package/dist/crypto.js.map +1 -1
  13. package/dist/errors.d.ts +26 -3
  14. package/dist/errors.d.ts.map +1 -1
  15. package/dist/errors.js +111 -15
  16. package/dist/errors.js.map +1 -1
  17. package/dist/feed-types.d.ts +76 -0
  18. package/dist/feed-types.d.ts.map +1 -0
  19. package/dist/feed-types.js +2 -0
  20. package/dist/feed-types.js.map +1 -0
  21. package/dist/feed.d.ts +158 -0
  22. package/dist/feed.d.ts.map +1 -0
  23. package/dist/feed.js +474 -0
  24. package/dist/feed.js.map +1 -0
  25. package/dist/gateway-reads.d.ts +74 -0
  26. package/dist/gateway-reads.d.ts.map +1 -0
  27. package/dist/gateway-reads.js +91 -0
  28. package/dist/gateway-reads.js.map +1 -0
  29. package/dist/governance-query.d.ts +6 -16
  30. package/dist/governance-query.d.ts.map +1 -1
  31. package/dist/governance-query.js +80 -93
  32. package/dist/governance-query.js.map +1 -1
  33. package/dist/history.d.ts +17 -0
  34. package/dist/history.d.ts.map +1 -0
  35. package/dist/history.js +150 -0
  36. package/dist/history.js.map +1 -0
  37. package/dist/index.d.ts +9 -3
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +5 -3
  40. package/dist/index.js.map +1 -1
  41. package/dist/market-snapshot.d.ts.map +1 -1
  42. package/dist/market-snapshot.js +4 -5
  43. package/dist/market-snapshot.js.map +1 -1
  44. package/dist/oracle-price-history.d.ts +30 -0
  45. package/dist/oracle-price-history.d.ts.map +1 -0
  46. package/dist/oracle-price-history.js +108 -0
  47. package/dist/oracle-price-history.js.map +1 -0
  48. package/dist/portfolio-history.d.ts +21 -0
  49. package/dist/portfolio-history.d.ts.map +1 -0
  50. package/dist/portfolio-history.js +49 -0
  51. package/dist/portfolio-history.js.map +1 -0
  52. package/dist/tx-result.d.ts +6 -0
  53. package/dist/tx-result.d.ts.map +1 -1
  54. package/dist/tx-result.js +42 -0
  55. package/dist/tx-result.js.map +1 -1
  56. package/dist/types.d.ts +160 -134
  57. package/dist/types.d.ts.map +1 -1
  58. package/dist/types.js +11 -7
  59. package/dist/types.js.map +1 -1
  60. package/dist/wasm/proof_trading_sdk_wasm_bg.wasm +0 -0
  61. package/package.json +5 -1
package/dist/types.d.ts CHANGED
@@ -70,13 +70,17 @@ export declare const ActionType: {
70
70
  readonly ApproveAgent: 12;
71
71
  /** Revoke a previously approved agent wallet. */
72
72
  readonly RevokeAgent: 13;
73
- /** Create a 5-book impact-market family (admin). */
74
- readonly CreateImpactMarket: 14;
75
- /** Resolve an impact-market family with an outcome (admin). DEC-149: was
76
- * `ResolveEvent`; the standalone-event resolve is `ResolveEvent` (0x27). */
77
- readonly ResolveImpactMarket: 15;
78
- /** Resolve a standalone event with a YES/NO outcome (0x27, DEC-149). */
73
+ /** Resolve an event with a YES/NO outcome (0x27). */
79
74
  readonly ResolveEvent: 39;
75
+ /** Create a derived sub-account under the signing master (0x28). Dormant
76
+ * behind the sub-account activation: refused as `SubAccountsInactive`. */
77
+ readonly CreateSubAccount: 40;
78
+ /** Move balance between a master and one of its sub-accounts (0x29);
79
+ * dormant like `CreateSubAccount`. */
80
+ readonly SubAccountTransfer: 41;
81
+ /** Acquire the single-holder Solana payout lease on a pending withdrawal
82
+ * (0x2e). Custody-authorized watchers only. */
83
+ readonly ClaimWithdrawalPayout: 46;
80
84
  /** Update a subset of `MarketConfig` tunables on a live market (admin).
81
85
  * Fee tiering, funding-rate cap tightening, position-limit updates
82
86
  * without a chain rebase. */
@@ -567,7 +571,7 @@ export declare enum Branch {
567
571
  Yes = 1,
568
572
  No = 2
569
573
  }
570
- /** Outcome of an impact-market event. */
574
+ /** Outcome of an event. */
571
575
  export declare enum Outcome {
572
576
  Yes = 1,
573
577
  No = 2,
@@ -583,8 +587,8 @@ export declare enum Outcome {
583
587
  */
584
588
  export type PriceComparison = "GreaterThan" | "LessThan" | "GreaterThanOrEqual" | "LessThanOrEqual";
585
589
  /**
586
- * BE-54: how an impact-market event's YES/NO outcome is determined at
587
- * deadline. Carried optionally on `CreateImpactMarket`; `undefined`
590
+ * How an event's YES/NO outcome is determined at settlement. Carried
591
+ * optionally on `CreateEvent`; `undefined`
588
592
  * (the wire `nil`) means `RelayerAttested` — the legacy default where
589
593
  * the resolver supplies the outcome and the engine trusts it. The two
590
594
  * auto-resolve modes derive YES/NO from an on-chain oracle reading and
@@ -604,45 +608,51 @@ export type EventOracleSource = {
604
608
  } | {
605
609
  kind: "RelayerAttested";
606
610
  };
607
- /** Create an impact-market family with 4 child books (CPY/CPN/EBY/EBN). */
608
- export interface CreateImpactMarket {
609
- impactMarketId: number;
611
+ /**
612
+ * Attach a conditional to an existing event (admin-actions inner tag `0x0a`):
613
+ * the YES conditional book at `childMarketBase` and the NO book at +1, on
614
+ * `underlyingMarket`, recorded on the event's attachment list and settling
615
+ * through the event's two binaries. Governance-only: the embedded `signer`
616
+ * must be zero.
617
+ */
618
+ export interface AttachConditional {
619
+ eventId: number;
620
+ /** An existing perpetual, not yet attached to this event. */
610
621
  underlyingMarket: number;
622
+ /** `childMarketBase` = CPY, +1 = CPN; both ids must be free. */
611
623
  childMarketBase: number;
612
- question: string;
613
- deadlineMs: bigint;
614
- resolutionWindowMs: bigint;
615
624
  imBps: number;
616
625
  mmBps: number;
617
626
  takerFeeBps: number;
618
627
  makerFeeBps: number;
619
- fundingIntervalMs: bigint;
620
- maxFundingRateBps: number;
621
628
  signer: Address;
622
- /**
623
- * BE-54: how this event's YES/NO outcome is determined at deadline.
624
- * Optional — `undefined` (the wire `nil`) means `RelayerAttested`,
625
- * which preserves the legacy behavior where the resolver supplies the
626
- * outcome and the engine trusts it. Setting `UnderlyingPriceVsStrike`
627
- * or `MarketOracle` makes the resolution self-verifying: the engine
628
- * derives YES/NO from the named oracle's reading and rejects any
629
- * `ResolveEvent` whose `outcome` doesn't match. `Outcome.Void`
630
- * overrides the auto-derivation in either auto-resolve mode (operator
631
- * escape hatch for unresolvable events).
632
- */
633
- oracleSource?: EventOracleSource;
634
- /** Optional event body text for frontend detail pages. Encodes as "" when
635
- * absent (matches the engine's `serde(default)`). */
636
- description?: string;
637
- /** Optional resolution criteria text. Encodes as "" when absent (matches
638
- * the engine's `serde(default)`). */
639
- rules?: string;
629
+ /** Open-interest cap for each of the two conditional books, in the
630
+ * underlying's size scale; `undefined` or `0n` = uncapped (encodes as 0). */
631
+ maxOpenInterest?: bigint;
640
632
  }
641
- /** Resolve an impact-market family (DEC-149: formerly `ResolveEvent`, 0x0f). */
642
- export interface ResolveImpactMarket {
643
- impactMarketId: number;
644
- outcome: Outcome;
645
- signer: Address;
633
+ /** Create a derived sub-account under the signing master (0x28). */
634
+ export interface CreateSubAccount {
635
+ /** The master account (20-byte address). */
636
+ owner: Address;
637
+ /** Non-zero id, unique per master. */
638
+ subAccountId: number;
639
+ /** 32-byte display name, zero-padded. */
640
+ name: Uint8Array;
641
+ }
642
+ /** Move balance between a master and one of its sub-accounts (0x29). One
643
+ * side must be the master; the other a derived child. */
644
+ export interface SubAccountTransfer {
645
+ owner: Address;
646
+ from: Address;
647
+ to: Address;
648
+ /** Micro-USDC, greater than zero. */
649
+ amount: bigint;
650
+ }
651
+ /** Acquire the single-holder Solana payout lease on a pending withdrawal
652
+ * (0x2e). `holder` is the claiming watcher's own address. */
653
+ export interface ClaimWithdrawalPayout {
654
+ withdrawalId: bigint;
655
+ holder: Address;
646
656
  }
647
657
  /** Resolve a standalone event (0x27). YES/NO only — the engine rejects `Void`. */
648
658
  export interface ResolveEvent {
@@ -672,8 +682,19 @@ export interface CreateEvent {
672
682
  description?: string;
673
683
  /** Optional resolution criteria; encodes as "" when absent. */
674
684
  rules?: string;
685
+ /** Open-interest cap for each of the event's two binary books, in
686
+ * contracts; `undefined` or `0n` = uncapped (encodes as 0). */
687
+ maxOpenInterest?: bigint;
675
688
  }
676
- /** Stored record for a standalone event — the `get_event` read model (G17). */
689
+ /** One conditional attached to an event: the underlying perpetual and the
690
+ * YES/NO conditional books that settle against it. */
691
+ export interface AttachedConditional {
692
+ underlyingMarket: number;
693
+ cpyMarket: number;
694
+ cpnMarket: number;
695
+ }
696
+ /** Stored record for an event — the `get_event` read model: its two binary
697
+ * books and every conditional attached to it. */
677
698
  export interface EventInfo {
678
699
  eventId: number;
679
700
  ebyMarket: number;
@@ -681,11 +702,13 @@ export interface EventInfo {
681
702
  question: string;
682
703
  settlementMs: bigint;
683
704
  resolutionWindowMs: bigint;
684
- status: ImpactMarketStatus;
705
+ status: EventStatus;
685
706
  createdMs: bigint;
686
707
  resolvedMs: bigint;
687
708
  /** `undefined` (wire `nil`) means `RelayerAttested`. */
688
709
  oracleSource?: EventOracleSource;
710
+ /** Every attachment, in attachment order; empty for a binary-only event. */
711
+ attachedConditionals: AttachedConditional[];
689
712
  }
690
713
  /**
691
714
  * Update a subset of `MarketConfig` fields on an existing market.
@@ -802,8 +825,9 @@ export interface UpdateMarketFees {
802
825
  */
803
826
  maxOpenInterest?: bigint | null;
804
827
  }
805
- /** Lifecycle status of an impact-market family. */
806
- export type ImpactMarketStatus = {
828
+ /** Lifecycle status of an event: `Trading` until its settlement time,
829
+ * `Resolved(outcome)` once settled. */
830
+ export type EventStatus = {
807
831
  kind: "Trading";
808
832
  } | {
809
833
  kind: "PreResolution";
@@ -811,29 +835,6 @@ export type ImpactMarketStatus = {
811
835
  kind: "Resolved";
812
836
  outcome: Outcome;
813
837
  };
814
- /** On-chain info for an impact-market family. */
815
- export interface ImpactMarketInfo {
816
- impactMarketId: number;
817
- underlyingMarket: number;
818
- cpyMarket: number;
819
- cpnMarket: number;
820
- ebyMarket: number;
821
- ebnMarket: number;
822
- question: string;
823
- deadlineMs: bigint;
824
- resolutionWindowMs: bigint;
825
- status: ImpactMarketStatus;
826
- createdMs: bigint;
827
- resolvedMs: bigint;
828
- /** BE-54: how the YES/NO outcome is determined at deadline. `undefined`
829
- * (older gateways / pre-BE-54 records) means `RelayerAttested`. */
830
- oracleSource?: EventOracleSource;
831
- /** Event body text; `""` when the record has none. `undefined` only on
832
- * gateways older than admin-actions v2 (field not served). */
833
- description?: string;
834
- /** Resolution criteria text; same shipping note as `description`. */
835
- rules?: string;
836
- }
837
838
  /** Pick a per-account override on the initial-margin ratio for one
838
839
  * market. Engine takes max(market.imBps, userImBps), so users can
839
840
  * deleverage but not exceed the market's risk floor. `userImBps == 0`
@@ -940,6 +941,12 @@ export type TraderAction = {
940
941
  } | {
941
942
  type: "CancelPositionTriggers";
942
943
  data: CancelPositionTriggers;
944
+ } | {
945
+ type: "CreateSubAccount";
946
+ data: CreateSubAccount;
947
+ } | {
948
+ type: "SubAccountTransfer";
949
+ data: SubAccountTransfer;
943
950
  };
944
951
  /**
945
952
  * Operator actions — privileged infrastructure submitted by the operator's
@@ -986,15 +993,12 @@ export type OperatorAction = {
986
993
  } | {
987
994
  type: "AuthorizeWithdrawal";
988
995
  data: AuthorizeWithdrawal;
989
- } | {
990
- type: "CreateImpactMarket";
991
- data: CreateImpactMarket;
992
- } | {
993
- type: "ResolveImpactMarket";
994
- data: ResolveImpactMarket;
995
996
  } | {
996
997
  type: "ResolveEvent";
997
998
  data: ResolveEvent;
999
+ } | {
1000
+ type: "ClaimWithdrawalPayout";
1001
+ data: ClaimWithdrawalPayout;
998
1002
  } | {
999
1003
  type: "UpdateMarketFees";
1000
1004
  data: UpdateMarketFees;
@@ -1027,11 +1031,8 @@ export type AdminBatchItem = {
1027
1031
  kind: "CreateMarket";
1028
1032
  value: CreateMarket;
1029
1033
  } | {
1030
- kind: "CreateImpactMarket";
1031
- value: CreateImpactMarket;
1032
- } | {
1033
- kind: "CreateEvent";
1034
- value: CreateEvent;
1034
+ kind: "AttachConditional";
1035
+ value: AttachConditional;
1035
1036
  };
1036
1037
  /**
1037
1038
  * Governance cancel of every resting order one account holds, optionally
@@ -1046,15 +1047,35 @@ export interface CancelAllOrdersForAccount {
1046
1047
  /** Confine the cancel to one market; omit to sweep every market. */
1047
1048
  market?: number | null;
1048
1049
  }
1050
+ /** One operator-authority allowlist an `UpdateAuthoritySet` action targets.
1051
+ * Externally tagged on the wire, so the domain arrives as this bare
1052
+ * string, never a numeric discriminant. `Custody`/`MarketParams`/
1053
+ * `ScheduledOps` are the capability-split sets; `Oracle`/`CexComposite`/
1054
+ * `Relayer` are the genesis-seeded presence sets. */
1055
+ export type AuthorityDomain = "Oracle" | "CexComposite" | "Relayer" | "Custody" | "MarketParams" | "ScheduledOps";
1056
+ /**
1057
+ * Governance addition/removal of members in one privileged authorization
1058
+ * set (inner tag `0x07`). `add` and `remove` are each canonically sorted,
1059
+ * duplicate-free, and disjoint; the engine refuses a proposal that would
1060
+ * leave the domain's net set empty.
1061
+ */
1062
+ export interface UpdateAuthoritySet {
1063
+ domain: AuthorityDomain;
1064
+ /** Addresses to add to the domain (each a 20-byte address). */
1065
+ add: Address[];
1066
+ /** Addresses to remove from the domain (each a 20-byte address). */
1067
+ remove: Address[];
1068
+ }
1049
1069
  /**
1050
1070
  * Closed, typed set of operations executable through the multisig. The
1051
- * embedded `CreateMarket.signer` / `CreateImpactMarket.signer` must be
1071
+ * embedded `CreateMarket.signer` / `AttachConditional.signer` must be
1052
1072
  * zero — governance supplies the authorization, not the embedded address.
1053
1073
  *
1054
1074
  * `Batch` executes its items atomically in order against one overlay:
1055
1075
  * all succeed or the proposal fails with no partial state. Admitted on
1056
- * chain only once admin-actions v2 activates (`CreateImpactMarket`
1057
- * likewise); the engine refuses the tags below the activation height.
1076
+ * chain only once admin-actions v2 activates; `CreateEvent` and
1077
+ * `AttachConditional` ride the standalone-events activation. The engine
1078
+ * refuses every tag below its activation height.
1058
1079
  */
1059
1080
  export type AdminAction = {
1060
1081
  kind: "CancelAllOrdersForAccount";
@@ -1068,12 +1089,12 @@ export type AdminAction = {
1068
1089
  } | {
1069
1090
  kind: "UpdateAdminSignerRegistry";
1070
1091
  value: UpdateAdminSignerRegistry;
1071
- } | {
1072
- kind: "CreateImpactMarket";
1073
- value: CreateImpactMarket;
1074
1092
  } | {
1075
1093
  kind: "CreateEvent";
1076
1094
  value: CreateEvent;
1095
+ } | {
1096
+ kind: "AttachConditional";
1097
+ value: AttachConditional;
1077
1098
  } | {
1078
1099
  kind: "Batch";
1079
1100
  value: AdminBatchItem[];
@@ -1083,14 +1104,9 @@ export type AdminAction = {
1083
1104
  } | {
1084
1105
  kind: "UnpauseBridge";
1085
1106
  } | {
1086
- kind: "CancelAllOrdersForAccount";
1087
- value: CancelAllOrdersForAccount;
1107
+ kind: "UpdateAuthoritySet";
1108
+ value: UpdateAuthoritySet;
1088
1109
  };
1089
- /** Governance cancel of a wallet's resting orders, optionally one market (tag 8). */
1090
- export interface CancelAllOrdersForAccount {
1091
- owner: Address;
1092
- market?: number | null;
1093
- }
1094
1110
  /** Authenticated relay attestation, not a cryptographic provider-proof verifier.
1095
1111
  * Price and confidence are integers in the policy's normalized micro unit. */
1096
1112
  export interface SubmitOracleObservation {
@@ -1539,8 +1555,9 @@ export type ExchangeEvent = OrderPlacedEvent | OrderCancelledEvent | TradeExecut
1539
1555
  * - `"engine"` — the engine rejected it with an `ExecError` (`code` 1..53/255);
1540
1556
  * see {@link TxResult.error} for the decoded name/description.
1541
1557
  * - `"transport"` — a gateway/HTTP-level failure (auth, rate-limit, body too
1542
- * large, 5xx, non-JSON body). `code` is the synthesized HTTP
1543
- * status, not an engine code.
1558
+ * large, or a structured pre-admission refusal at HTTP
1559
+ * 200/503). `code` is synthetic (1 for HTTP 200), not an
1560
+ * engine code. Unrecognized 5xx responses stay `timeout`.
1544
1561
  * - `"timeout"` — no final chain verdict is available yet (`code === -1`):
1545
1562
  * either the gateway returned a hash-only ambiguous response
1546
1563
  * or inclusion polling expired. The tx may still land.
@@ -1577,6 +1594,8 @@ export interface TxResult {
1577
1594
  height?: number;
1578
1595
  /** Human-readable log message (populated on error). */
1579
1596
  log?: string;
1597
+ /** Optional ABCI diagnostic info, preserved without interpretation. */
1598
+ info?: string;
1580
1599
  /** ABCI events emitted by the transaction. */
1581
1600
  events?: TxEvent[];
1582
1601
  }
@@ -1925,40 +1944,33 @@ export interface PositionInfo {
1925
1944
  * trigger placement rather than guess `1`. */
1926
1945
  positionEpoch?: bigint;
1927
1946
  }
1928
- /** One entry per active impact market the account touches. Tuple of
1929
- * (impactMarketId, branch) where branch is "Yes" or "No". Ordering is
1930
- * ascending by impactMarketId (deterministic across nodes).
1947
+ /** One entry per active event the account touches through a conditional.
1948
+ * Tuple of (eventId, branch) where branch is "Yes" or "No". Ordering is
1949
+ * ascending by eventId (deterministic across nodes).
1931
1950
  *
1932
1951
  * See AccountInfo.bindingScenario for semantics. */
1933
1952
  export interface BindingScenarioEntry {
1934
- impactMarketId: number;
1953
+ eventId: number;
1935
1954
  branch: "Yes" | "No";
1936
1955
  }
1937
- /** One row of the per-user deposit/withdraw cash-flow log. Covers four
1938
- * event kinds — see the `kind` field. Feeds the Portfolio EquityChart
1939
- * "equity over time" reconstruction (Jesse's P2 #6).
1940
- *
1941
- * Returned by `GET /v1/history/deposits/{address}` and `GET
1942
- * /v1/history/withdrawals/{address}`, and by the `historyDeposits` /
1943
- * `historyWithdrawals` InfoRequests. Shipped 2026-04-24. */
1956
+ /** One deposit/withdrawal event from owner- and event-filtered
1957
+ * `/v1/history/account-events` pages. */
1944
1958
  export interface HistoryCashFlow {
1945
- /** One of the four Rust event kinds. */
1946
- kind: "deposit_confirmed" | "withdraw_requested" | "withdrawal_confirmed" | "withdrawal_failed";
1959
+ /** Original engine event kind, including direct relayer credits/debits. */
1960
+ kind: "deposited" | "withdrawn" | "deposit_confirmed" | "withdraw_requested" | "withdrawal_confirmed" | "withdrawal_failed";
1947
1961
  /** 20-byte owner address as hex. */
1948
1962
  owner: string;
1949
- /** Amount in µUSDC (always positive). Use `signedDelta` for signed
1950
- * balance-change reconstruction. May be empty for
1951
- * `withdrawal_confirmed` (engine doesn't emit amount on ack). */
1963
+ /** Principal amount in micro-USDC. Custody requests/refunds omit fees.
1964
+ * Empty on owner-scoped confirmations from compatible deployments; the
1965
+ * current indexer omits ownerless withdrawal_confirmed events entirely. */
1952
1966
  amount: string;
1953
- /** Signed balance delta for this event:
1954
- * +amount for deposit_confirmed + withdrawal_failed (credit)
1955
- * -amount for withdraw_requested (debit)
1956
- * "0" for withdrawal_confirmed (no change) */
1967
+ /** Exact event balance delta: deposit amount, negated direct withdrawal
1968
+ * amount, or "0" on confirmation. Empty on withdrawal request/failure:
1969
+ * their payloads omit the custody fee included in the actual debit/refund. */
1957
1970
  signedDelta: string;
1958
- /** Post-event balance. Available for deposit/request/failed;
1959
- * empty for confirmed (no balance change on that event). */
1971
+ /** Post-event balance when emitted; empty when absent from the event. */
1960
1972
  newBalance: string;
1961
- /** Present on withdrawal events (request, confirmed, failed). */
1973
+ /** Present on custody withdrawal events (request, confirmed, failed). */
1962
1974
  withdrawalId: string;
1963
1975
  /** Present on deposit_confirmed + withdrawal_confirmed. */
1964
1976
  solanaTxSig: string;
@@ -1981,8 +1993,8 @@ export interface HistoryCashFlow {
1981
1993
  export interface HistoryResolution {
1982
1994
  /** One of "conditional_settled" | "conditional_voided" | "prediction_settled". */
1983
1995
  kind: "conditional_settled" | "conditional_voided" | "prediction_settled";
1984
- /** Impact-market family ID the resolved position belonged to. */
1985
- impactMarketId: string;
1996
+ /** Event the resolved position belonged to, as a decimal string. */
1997
+ eventId: string;
1986
1998
  /** Child market ID (CPY/CPN or EBY/EBN). */
1987
1999
  market: string;
1988
2000
  /** 20-byte owner address as hex. */
@@ -2004,24 +2016,19 @@ export interface HistoryResolution {
2004
2016
  /** Unix milliseconds. */
2005
2017
  timestamp: number;
2006
2018
  }
2007
- /** One row of the per-user position-history snapshot log. Each entry is
2008
- * a point-in-time snapshot of a position written after each fill that
2009
- * changes its state (open → grow → reduce → close). When `size` is "0"
2010
- * the snapshot represents a CLOSE event; the immediately preceding
2011
- * non-zero snapshot for the same `(owner, market, side)` carries the
2012
- * weighted-average entry price.
2013
- *
2014
- * Returned by `GET /v1/history/positions/{address}` and the
2015
- * `historyPositions` InfoRequest. The HTTP endpoint accepts optional
2016
- * `?market=&from=&to=&limit=` filters; results are newest-first. */
2019
+ /** Compatibility row from queryHistoryPositions(). A zero size is a closed
2020
+ * position; absent side/entry price become empty strings and block time is
2021
+ * projected to milliseconds. Use queryHistoryPositionsPage() for exact times,
2022
+ * nullable fields and pagination. */
2017
2023
  export interface HistoryPositionSnapshot {
2018
2024
  /** 20-byte owner address as hex. */
2019
2025
  owner: string;
2020
2026
  /** Market ID as a decimal string. */
2021
2027
  market: string;
2022
- /** Position side: "Buy" = long, "Sell" = short. */
2028
+ /** Position side as served; empty when a closed position has no side.
2029
+ * Use HistoryPosition for the nullable representation. */
2023
2030
  side: string;
2024
- /** Weighted-average entry price in µUSDC at the time of the snapshot. */
2031
+ /** Entry price in micro-USDC, or empty when absent on a close. */
2025
2032
  entryPrice: string;
2026
2033
  /** Absolute position size in contracts. "0" = closed. */
2027
2034
  size: string;
@@ -2030,6 +2037,24 @@ export interface HistoryPositionSnapshot {
2030
2037
  /** Unix milliseconds. */
2031
2038
  timestamp: number;
2032
2039
  }
2040
+ /** Indexer position snapshot with exact timestamp and absent close fields retained. */
2041
+ export interface HistoryPosition {
2042
+ owner: string;
2043
+ market: number;
2044
+ side: string | null;
2045
+ /** Micro-USDC decimal text; null when the closed position has no entry price. */
2046
+ entryPrice: string | null;
2047
+ /** Integer contracts as decimal text; zero denotes a closed position. */
2048
+ size: string;
2049
+ blockHeight: number;
2050
+ /** RFC 3339 timestamp, retaining the indexer's fractional-second precision. */
2051
+ blockTime: string;
2052
+ }
2053
+ /** One newest-first page. An empty nextCursor means there are no further rows. */
2054
+ export interface HistoryPositionsPage {
2055
+ positions: HistoryPosition[];
2056
+ nextCursor: string;
2057
+ }
2033
2058
  /** One executed fill from `/v1/history/fills/{owner}` (or `/v1/fills`). */
2034
2059
  export interface HistoryFill {
2035
2060
  /** Unsigned 64-bit fill identifier as a decimal string. NOTE: the indexer
@@ -2077,7 +2102,7 @@ export interface AccountInfo {
2077
2102
  /** [5] Margin ratio in basis points (equity / total notional * 10000). */
2078
2103
  marginRatioBps: bigint;
2079
2104
  /** [6] Resolution scenario that maximizes totalMm — the "binding" outcome.
2080
- * One entry per active impact market, ascending by impactMarketId.
2105
+ * One entry per active event, ascending by eventId.
2081
2106
  * Empty for perp-only accounts. Undefined on responses from gateways
2082
2107
  * older than 2026-04-24 (backward compat — the SDK decoder reads
2083
2108
  * msgpack arrays by index). See Jesse's P1 #3 in docs/api-scope.md. */
@@ -2095,8 +2120,8 @@ export interface AccountInfo {
2095
2120
  }
2096
2121
  /** Market kind discriminator. Wire shape mirrors the Rust `MarketKind`
2097
2122
  * enum exactly: `"Perp"` is a bare string, the parameterised variants
2098
- * are `{ ConditionalPerp: [impactId, branch] }` /
2099
- * `{ PredictionBinary: [impactId, branch] }`. */
2123
+ * are `{ ConditionalPerp: [eventId, branch] }` /
2124
+ * `{ PredictionBinary: [eventId, branch] }` — both keyed by the event. */
2100
2125
  export type MarketKind = "Perp" | {
2101
2126
  ConditionalPerp: [number, "Yes" | "No"];
2102
2127
  } | {
@@ -2113,7 +2138,8 @@ export interface MarketsSnapshot {
2113
2138
  chainId: Uint8Array;
2114
2139
  height: bigint;
2115
2140
  markets: MarketConfig[];
2116
- impactMarkets: ImpactMarketInfo[];
2141
+ /** Every event with its binaries and attached conditionals. */
2142
+ events: EventInfo[];
2117
2143
  }
2118
2144
  export interface MarketConfig {
2119
2145
  /** [0] Market identifier (unique integer). */