@veilo/sdk-core 0.5.0 → 0.6.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 (236) hide show
  1. package/README.md +237 -19
  2. package/accounts.d.ts +2 -0
  3. package/accounts.js +3 -0
  4. package/cloak.d.ts +2 -0
  5. package/cloak.js +3 -0
  6. package/config.d.ts +2 -0
  7. package/config.js +3 -0
  8. package/dist/cjs/events/index.d.ts +6 -0
  9. package/dist/cjs/events/index.js +22 -0
  10. package/dist/cjs/events/parsing.d.ts +25 -0
  11. package/dist/cjs/events/parsing.js +158 -0
  12. package/dist/cjs/events/position.d.ts +26 -0
  13. package/dist/cjs/events/position.js +53 -0
  14. package/dist/cjs/events/recovery.d.ts +87 -0
  15. package/dist/cjs/events/recovery.js +281 -0
  16. package/dist/cjs/events/scanning.d.ts +35 -0
  17. package/dist/cjs/events/scanning.js +98 -0
  18. package/dist/cjs/events/tree.d.ts +27 -0
  19. package/dist/cjs/events/tree.js +63 -0
  20. package/dist/cjs/events/types.d.ts +39 -0
  21. package/dist/cjs/events/types.js +2 -0
  22. package/dist/cjs/events.d.ts +1 -77
  23. package/dist/cjs/events.js +6 -154
  24. package/dist/cjs/identity/encoding.d.ts +9 -0
  25. package/dist/cjs/identity/encoding.js +85 -0
  26. package/dist/cjs/identity/index.d.ts +4 -0
  27. package/dist/cjs/identity/index.js +20 -0
  28. package/dist/cjs/identity/noteKey.d.ts +33 -0
  29. package/dist/cjs/identity/noteKey.js +97 -0
  30. package/dist/cjs/identity/spending.d.ts +18 -0
  31. package/dist/cjs/identity/spending.js +46 -0
  32. package/dist/cjs/identity/viewKey.d.ts +38 -0
  33. package/dist/cjs/identity/viewKey.js +105 -0
  34. package/dist/cjs/idl/index.d.ts +18 -0
  35. package/dist/cjs/idl/index.js +24 -0
  36. package/dist/cjs/idl/privacy_pool.json +9907 -9907
  37. package/dist/cjs/idl/privacy_pool_legacy.d.ts +5 -0
  38. package/dist/cjs/idl/privacy_pool_legacy.js +3307 -0
  39. package/dist/cjs/idl/privacy_pool_legacy.json +2302 -0
  40. package/dist/cjs/idl/privacy_pool_legacy2.d.ts +5 -0
  41. package/dist/cjs/idl/privacy_pool_legacy2.js +3397 -0
  42. package/dist/cjs/idl/privacy_pool_legacy2.json +2376 -0
  43. package/dist/cjs/index.d.ts +8 -3
  44. package/dist/cjs/index.js +12 -2
  45. package/dist/cjs/notes/amount.d.ts +2 -0
  46. package/dist/cjs/notes/amount.js +21 -0
  47. package/dist/cjs/notes/index.d.ts +3 -0
  48. package/dist/cjs/notes/index.js +3 -0
  49. package/dist/cjs/notes/recovery.d.ts +16 -6
  50. package/dist/cjs/notes/recovery.js +33 -16
  51. package/dist/cjs/notes/selection.d.ts +77 -0
  52. package/dist/cjs/notes/selection.js +193 -0
  53. package/dist/cjs/notes/spent.d.ts +60 -0
  54. package/dist/cjs/notes/spent.js +101 -0
  55. package/dist/cjs/perps/constants.d.ts +16 -0
  56. package/dist/cjs/perps/constants.js +52 -0
  57. package/dist/cjs/perps/index.d.ts +5 -0
  58. package/dist/cjs/perps/index.js +21 -0
  59. package/dist/cjs/perps/keys.d.ts +16 -0
  60. package/dist/cjs/perps/keys.js +43 -0
  61. package/dist/cjs/perps/pdas.d.ts +29 -0
  62. package/dist/cjs/perps/pdas.js +55 -0
  63. package/dist/cjs/perps/relayer.d.ts +9 -0
  64. package/dist/cjs/perps/relayer.js +35 -0
  65. package/dist/cjs/perps/types.d.ts +126 -0
  66. package/dist/cjs/perps/types.js +2 -0
  67. package/dist/cjs/positions/index.d.ts +4 -0
  68. package/dist/cjs/positions/index.js +20 -0
  69. package/dist/cjs/positions/keys.d.ts +29 -0
  70. package/dist/cjs/positions/keys.js +71 -0
  71. package/dist/cjs/positions/pdas.d.ts +15 -0
  72. package/dist/cjs/positions/pdas.js +54 -0
  73. package/dist/cjs/positions/relayer.d.ts +4 -0
  74. package/dist/cjs/positions/relayer.js +15 -0
  75. package/dist/cjs/positions/types.d.ts +97 -0
  76. package/dist/cjs/positions/types.js +2 -0
  77. package/dist/cjs/predictions/client.d.ts +41 -0
  78. package/dist/cjs/predictions/client.js +147 -0
  79. package/dist/cjs/predictions/index.d.ts +5 -0
  80. package/dist/cjs/predictions/index.js +21 -0
  81. package/dist/cjs/predictions/keys.d.ts +14 -0
  82. package/dist/cjs/predictions/keys.js +40 -0
  83. package/dist/cjs/predictions/pdas.d.ts +6 -0
  84. package/dist/cjs/predictions/pdas.js +13 -0
  85. package/dist/cjs/predictions/relayer.d.ts +3 -0
  86. package/dist/cjs/predictions/relayer.js +11 -0
  87. package/dist/cjs/predictions/types.d.ts +178 -0
  88. package/dist/cjs/predictions/types.js +2 -0
  89. package/dist/cjs/program.d.ts +2 -0
  90. package/dist/cjs/program.js +8 -7
  91. package/dist/cjs/prover.d.ts +27 -4
  92. package/dist/cjs/prover.js +107 -48
  93. package/dist/cjs/relayer/api.d.ts +31 -0
  94. package/dist/cjs/relayer/api.js +86 -0
  95. package/dist/cjs/relayer/client.d.ts +29 -17
  96. package/dist/cjs/relayer/client.js +72 -17
  97. package/dist/cjs/relayer/errors.d.ts +1 -1
  98. package/dist/cjs/relayer/errors.js +1 -1
  99. package/dist/cjs/relayer/index.d.ts +4 -1
  100. package/dist/cjs/relayer/index.js +1 -1
  101. package/dist/cjs/relayer/internal-config.d.ts +36 -0
  102. package/dist/cjs/relayer/internal-config.js +9 -0
  103. package/dist/cjs/relayer/internal.d.ts +6 -0
  104. package/dist/cjs/relayer/internal.js +14 -0
  105. package/dist/cjs/relayer/transport.d.ts +4 -2
  106. package/dist/cjs/relayer/transport.js +10 -5
  107. package/dist/cjs/relayer/types.d.ts +9 -10
  108. package/dist/cjs/relayer/types.js +1 -1
  109. package/dist/cjs/shield/owner.js +1 -4
  110. package/dist/esm/events/index.d.ts +6 -0
  111. package/dist/esm/events/index.js +6 -0
  112. package/dist/esm/events/parsing.d.ts +25 -0
  113. package/dist/esm/events/parsing.js +120 -0
  114. package/dist/esm/events/position.d.ts +26 -0
  115. package/dist/esm/events/position.js +48 -0
  116. package/dist/esm/events/recovery.d.ts +87 -0
  117. package/dist/esm/events/recovery.js +237 -0
  118. package/dist/esm/events/scanning.d.ts +35 -0
  119. package/dist/esm/events/scanning.js +92 -0
  120. package/dist/esm/events/tree.d.ts +27 -0
  121. package/dist/esm/events/tree.js +58 -0
  122. package/dist/esm/events/types.d.ts +39 -0
  123. package/dist/esm/events/types.js +1 -0
  124. package/dist/esm/events.d.ts +1 -77
  125. package/dist/esm/events.js +3 -129
  126. package/dist/esm/identity/encoding.d.ts +9 -0
  127. package/dist/esm/identity/encoding.js +75 -0
  128. package/dist/esm/identity/index.d.ts +4 -0
  129. package/dist/esm/identity/index.js +4 -0
  130. package/dist/esm/identity/noteKey.d.ts +33 -0
  131. package/dist/esm/identity/noteKey.js +91 -0
  132. package/dist/esm/identity/spending.d.ts +18 -0
  133. package/dist/esm/identity/spending.js +35 -0
  134. package/dist/esm/identity/viewKey.d.ts +38 -0
  135. package/dist/esm/identity/viewKey.js +96 -0
  136. package/dist/esm/idl/index.d.ts +18 -0
  137. package/dist/esm/idl/index.js +18 -0
  138. package/dist/esm/idl/privacy_pool.json +9907 -9907
  139. package/dist/esm/idl/privacy_pool_legacy.d.ts +5 -0
  140. package/dist/esm/idl/privacy_pool_legacy.js +3305 -0
  141. package/dist/esm/idl/privacy_pool_legacy.json +2302 -0
  142. package/dist/esm/idl/privacy_pool_legacy2.d.ts +5 -0
  143. package/dist/esm/idl/privacy_pool_legacy2.js +3395 -0
  144. package/dist/esm/idl/privacy_pool_legacy2.json +2376 -0
  145. package/dist/esm/index.d.ts +8 -3
  146. package/dist/esm/index.js +8 -3
  147. package/dist/esm/notes/amount.d.ts +2 -0
  148. package/dist/esm/notes/amount.js +18 -0
  149. package/dist/esm/notes/index.d.ts +3 -0
  150. package/dist/esm/notes/index.js +3 -0
  151. package/dist/esm/notes/recovery.d.ts +16 -6
  152. package/dist/esm/notes/recovery.js +33 -16
  153. package/dist/esm/notes/selection.d.ts +77 -0
  154. package/dist/esm/notes/selection.js +188 -0
  155. package/dist/esm/notes/spent.d.ts +60 -0
  156. package/dist/esm/notes/spent.js +96 -0
  157. package/dist/esm/perps/constants.d.ts +16 -0
  158. package/dist/esm/perps/constants.js +48 -0
  159. package/dist/esm/perps/index.d.ts +5 -0
  160. package/dist/esm/perps/index.js +5 -0
  161. package/dist/esm/perps/keys.d.ts +16 -0
  162. package/dist/esm/perps/keys.js +35 -0
  163. package/dist/esm/perps/pdas.d.ts +29 -0
  164. package/dist/esm/perps/pdas.js +47 -0
  165. package/dist/esm/perps/relayer.d.ts +9 -0
  166. package/dist/esm/perps/relayer.js +25 -0
  167. package/dist/esm/perps/types.d.ts +126 -0
  168. package/dist/esm/perps/types.js +1 -0
  169. package/dist/esm/positions/index.d.ts +4 -0
  170. package/dist/esm/positions/index.js +4 -0
  171. package/dist/esm/positions/keys.d.ts +29 -0
  172. package/dist/esm/positions/keys.js +65 -0
  173. package/dist/esm/positions/pdas.d.ts +15 -0
  174. package/dist/esm/positions/pdas.js +44 -0
  175. package/dist/esm/positions/relayer.d.ts +4 -0
  176. package/dist/esm/positions/relayer.js +10 -0
  177. package/dist/esm/positions/types.d.ts +97 -0
  178. package/dist/esm/positions/types.js +1 -0
  179. package/dist/esm/predictions/client.d.ts +41 -0
  180. package/dist/esm/predictions/client.js +141 -0
  181. package/dist/esm/predictions/index.d.ts +5 -0
  182. package/dist/esm/predictions/index.js +5 -0
  183. package/dist/esm/predictions/keys.d.ts +14 -0
  184. package/dist/esm/predictions/keys.js +33 -0
  185. package/dist/esm/predictions/pdas.d.ts +6 -0
  186. package/dist/esm/predictions/pdas.js +10 -0
  187. package/dist/esm/predictions/relayer.d.ts +3 -0
  188. package/dist/esm/predictions/relayer.js +7 -0
  189. package/dist/esm/predictions/types.d.ts +178 -0
  190. package/dist/esm/predictions/types.js +1 -0
  191. package/dist/esm/program.d.ts +2 -0
  192. package/dist/esm/program.js +4 -3
  193. package/dist/esm/prover.d.ts +27 -4
  194. package/dist/esm/prover.js +106 -15
  195. package/dist/esm/relayer/api.d.ts +31 -0
  196. package/dist/esm/relayer/api.js +55 -0
  197. package/dist/esm/relayer/client.d.ts +29 -17
  198. package/dist/esm/relayer/client.js +72 -17
  199. package/dist/esm/relayer/errors.d.ts +1 -1
  200. package/dist/esm/relayer/errors.js +1 -1
  201. package/dist/esm/relayer/index.d.ts +4 -1
  202. package/dist/esm/relayer/index.js +1 -1
  203. package/dist/esm/relayer/internal-config.d.ts +36 -0
  204. package/dist/esm/relayer/internal-config.js +6 -0
  205. package/dist/esm/relayer/internal.d.ts +6 -0
  206. package/dist/esm/relayer/internal.js +10 -0
  207. package/dist/esm/relayer/transport.d.ts +4 -2
  208. package/dist/esm/relayer/transport.js +10 -5
  209. package/dist/esm/relayer/types.d.ts +9 -10
  210. package/dist/esm/relayer/types.js +1 -1
  211. package/dist/esm/shield/owner.js +1 -4
  212. package/identity.d.ts +2 -0
  213. package/identity.js +3 -0
  214. package/idl.d.ts +2 -0
  215. package/idl.js +3 -0
  216. package/notes.d.ts +2 -0
  217. package/notes.js +3 -0
  218. package/package.json +85 -3
  219. package/perps.d.ts +2 -0
  220. package/perps.js +3 -0
  221. package/poseidon.d.ts +2 -0
  222. package/poseidon.js +3 -0
  223. package/positions.d.ts +2 -0
  224. package/positions.js +3 -0
  225. package/predictions.d.ts +2 -0
  226. package/predictions.js +3 -0
  227. package/proof.d.ts +2 -0
  228. package/proof.js +3 -0
  229. package/prover.d.ts +2 -0
  230. package/prover.js +3 -0
  231. package/relayer.d.ts +2 -0
  232. package/relayer.js +3 -0
  233. package/shield.d.ts +2 -0
  234. package/shield.js +3 -0
  235. package/transactions.d.ts +2 -0
  236. package/transactions.js +3 -0
@@ -0,0 +1,97 @@
1
+ import type { TransactNote } from "../relayer/types.js";
2
+ /** Client-derived public material for a new private position note. */
3
+ export interface NewPositionKeys {
4
+ /** Position owner field element, decimal. */
5
+ pubkey: string;
6
+ /** Position blinding, 32-byte hex. */
7
+ blinding: string;
8
+ /** Position PDA key, 32-byte hex. */
9
+ pdaKey: string;
10
+ /** Deterministic claimant public key, base58. */
11
+ claimantPublicKey: string;
12
+ }
13
+ /** Spendable private-position note passed back to the relayer. */
14
+ export interface PositionNotePayload {
15
+ amount: string;
16
+ commitment: string;
17
+ privateKey: string;
18
+ publicKey: string;
19
+ blinding: string;
20
+ leafIndex: number;
21
+ positionPdaKey: string;
22
+ mint: string;
23
+ isToken2022: boolean;
24
+ treeId: number;
25
+ }
26
+ export interface OpenPositionRequest {
27
+ notes: TransactNote[];
28
+ sourceMintAddress: string;
29
+ destMintAddress: string;
30
+ swapAmountRaw: string;
31
+ slippageBps: number;
32
+ userPublicKey: string;
33
+ veiloPublicKey: string;
34
+ position: NewPositionKeys;
35
+ positionTreeId?: number;
36
+ isToken2022?: boolean;
37
+ dexes?: string;
38
+ pumpDirect?: boolean;
39
+ }
40
+ export interface OpenPositionResponse {
41
+ success: boolean;
42
+ message: string;
43
+ data?: {
44
+ txSignature: string;
45
+ positionAmount: string;
46
+ changeAmount: string;
47
+ positionPda: string;
48
+ mint: string;
49
+ positionCommitment: string;
50
+ positionLeafIndex: number;
51
+ positionTreeId: number;
52
+ isToken2022: boolean;
53
+ };
54
+ }
55
+ export interface ClosePositionRequest {
56
+ positionNote: PositionNotePayload;
57
+ destMintAddress: string;
58
+ slippageBps: number;
59
+ userPublicKey: string;
60
+ veiloPublicKey: string;
61
+ /** Base58-encoded deterministic claimant secret key. */
62
+ claimantSecretKey: string;
63
+ dexes?: string;
64
+ staged?: boolean;
65
+ }
66
+ export interface ClosePositionResponse {
67
+ success: boolean;
68
+ message: string;
69
+ data?: {
70
+ txSignature: string;
71
+ outputAmount: string;
72
+ feeRaw: string;
73
+ destMint: string;
74
+ };
75
+ }
76
+ export interface MergePositionsRequest {
77
+ positionNotes: [PositionNotePayload, PositionNotePayload];
78
+ mint: string;
79
+ userPublicKey: string;
80
+ veiloPublicKey: string;
81
+ newPosition: NewPositionKeys;
82
+ /** Base58 claimant secret shared by both input PositionPDAs. */
83
+ claimantSecretKey: string;
84
+ }
85
+ export interface MergePositionsResponse {
86
+ success: boolean;
87
+ message: string;
88
+ data?: {
89
+ txSignature: string;
90
+ mergedAmount: string;
91
+ newPositionPda: string;
92
+ mergedCommitment: string;
93
+ mergedLeafIndex: number;
94
+ positionTreeId: number;
95
+ mint: string;
96
+ };
97
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,41 @@
1
+ import { VersionedTransaction } from "@solana/web3.js";
2
+ import type { PlacePredictionOrderRequest, PlacePredictionOrderResponse, PredictionEvent, PredictionHistoryEvent, PredictionOrderStatusResponse, PredictionPosition, PredictionPriceInterval, PredictionPricePoint, PredictionTransactionResponse } from "./types.js";
3
+ export declare const JUPITER_PREDICTION_API_URL = "https://api.jup.ag/prediction/v1";
4
+ export declare const POLYMARKET_CLOB_API_URL = "https://clob.polymarket.com";
5
+ export interface JupiterPredictionClientConfig {
6
+ apiKey: string;
7
+ baseUrl?: string;
8
+ polymarketBaseUrl?: string;
9
+ fetch?: typeof fetch;
10
+ }
11
+ export declare class JupiterPredictionApiError extends Error {
12
+ readonly status: number;
13
+ readonly code?: string;
14
+ readonly responseBody: unknown;
15
+ constructor(status: number, responseBody: unknown);
16
+ }
17
+ /** Typed client for the unsigned Jupiter Prediction transaction API. */
18
+ export declare class JupiterPredictionClient {
19
+ private readonly apiKey;
20
+ private readonly baseUrl;
21
+ private readonly polymarketBaseUrl;
22
+ private readonly fetcher;
23
+ constructor(config: JupiterPredictionClientConfig);
24
+ listEvents(params?: {
25
+ category?: string;
26
+ status?: string;
27
+ }): Promise<PredictionEvent[]>;
28
+ getEvent(eventId: string): Promise<PredictionEvent>;
29
+ listPositions(ownerPubkey: string): Promise<PredictionPosition[]>;
30
+ listHistory(ownerPubkey: string): Promise<PredictionHistoryEvent[]>;
31
+ getPosition(positionPubkey: string): Promise<PredictionPosition>;
32
+ placeOrder(request: PlacePredictionOrderRequest): Promise<PlacePredictionOrderResponse>;
33
+ getOrderStatus(orderPubkey: string): Promise<PredictionOrderStatusResponse>;
34
+ closePosition(positionPubkey: string, ownerPubkey: string): Promise<PredictionTransactionResponse>;
35
+ closeAllPositions(ownerPubkey: string, minSellPriceSlippageBps?: number): Promise<PredictionTransactionResponse>;
36
+ claimPosition(positionPubkey: string, ownerPubkey: string): Promise<PredictionTransactionResponse>;
37
+ getPriceHistory(clobTokenId: string, interval: PredictionPriceInterval): Promise<PredictionPricePoint[]>;
38
+ private request;
39
+ }
40
+ /** Decode an unsigned transaction returned by Jupiter for wallet signing. */
41
+ export declare function deserializePredictionTransaction(response: PredictionTransactionResponse): VersionedTransaction;
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.JupiterPredictionClient = exports.JupiterPredictionApiError = exports.POLYMARKET_CLOB_API_URL = exports.JUPITER_PREDICTION_API_URL = void 0;
4
+ exports.deserializePredictionTransaction = deserializePredictionTransaction;
5
+ const web3_js_1 = require("@solana/web3.js");
6
+ exports.JUPITER_PREDICTION_API_URL = "https://api.jup.ag/prediction/v1";
7
+ exports.POLYMARKET_CLOB_API_URL = "https://clob.polymarket.com";
8
+ class JupiterPredictionApiError extends Error {
9
+ constructor(status, responseBody) {
10
+ const body = typeof responseBody === "object" && responseBody !== null
11
+ ? responseBody
12
+ : undefined;
13
+ const message = typeof responseBody === "string" && responseBody
14
+ ? responseBody
15
+ : typeof body?.message === "string"
16
+ ? body.message
17
+ : typeof body?.error === "string"
18
+ ? body.error
19
+ : `Jupiter Prediction API request failed: ${status}`;
20
+ super(message);
21
+ this.name = "JupiterPredictionApiError";
22
+ this.status = status;
23
+ this.code = typeof body?.error === "string" ? body.error : undefined;
24
+ this.responseBody = responseBody;
25
+ }
26
+ }
27
+ exports.JupiterPredictionApiError = JupiterPredictionApiError;
28
+ /** Typed client for the unsigned Jupiter Prediction transaction API. */
29
+ class JupiterPredictionClient {
30
+ constructor(config) {
31
+ this.apiKey = config.apiKey;
32
+ this.baseUrl = normalizeBaseUrl(config.baseUrl ?? exports.JUPITER_PREDICTION_API_URL, "baseUrl");
33
+ this.polymarketBaseUrl = normalizeBaseUrl(config.polymarketBaseUrl ?? exports.POLYMARKET_CLOB_API_URL, "polymarketBaseUrl");
34
+ this.fetcher = config.fetch ?? fetch;
35
+ }
36
+ async listEvents(params = {}) {
37
+ const query = new URLSearchParams({ status: params.status ?? "live" });
38
+ if (params.category)
39
+ query.set("category", params.category);
40
+ return (await this.request(`/events?${query}`)).data;
41
+ }
42
+ async getEvent(eventId) {
43
+ return this.request(`/events/${encodeURIComponent(eventId)}`);
44
+ }
45
+ async listPositions(ownerPubkey) {
46
+ return (await this.request(`/positions?ownerPubkey=${encodeURIComponent(ownerPubkey)}`)).data;
47
+ }
48
+ async listHistory(ownerPubkey) {
49
+ return (await this.request(`/history?ownerPubkey=${encodeURIComponent(ownerPubkey)}`)).data;
50
+ }
51
+ async getPosition(positionPubkey) {
52
+ return this.request(`/positions/${encodeURIComponent(positionPubkey)}`);
53
+ }
54
+ async placeOrder(request) {
55
+ return this.request("/orders", { method: "POST", body: request });
56
+ }
57
+ async getOrderStatus(orderPubkey) {
58
+ return this.request(`/orders/status/${encodeURIComponent(orderPubkey)}`);
59
+ }
60
+ async closePosition(positionPubkey, ownerPubkey) {
61
+ return this.request(`/positions/${encodeURIComponent(positionPubkey)}`, {
62
+ method: "DELETE",
63
+ body: { ownerPubkey },
64
+ });
65
+ }
66
+ async closeAllPositions(ownerPubkey, minSellPriceSlippageBps = 300) {
67
+ return this.request("/positions", {
68
+ method: "DELETE",
69
+ body: { ownerPubkey, minSellPriceSlippageBps },
70
+ });
71
+ }
72
+ async claimPosition(positionPubkey, ownerPubkey) {
73
+ return this.request(`/positions/${encodeURIComponent(positionPubkey)}/claim`, { method: "POST", body: { ownerPubkey } });
74
+ }
75
+ async getPriceHistory(clobTokenId, interval) {
76
+ const fidelity = {
77
+ "1d": 5,
78
+ "1w": 30,
79
+ "1m": 180,
80
+ max: 180,
81
+ };
82
+ const query = new URLSearchParams({
83
+ market: clobTokenId,
84
+ interval,
85
+ fidelity: String(fidelity[interval]),
86
+ });
87
+ const response = await this.fetcher(`${this.polymarketBaseUrl}/prices-history?${query}`);
88
+ const body = await readResponseBody(response);
89
+ if (!response.ok) {
90
+ throw new JupiterPredictionApiError(response.status, body);
91
+ }
92
+ return body.history ?? [];
93
+ }
94
+ async request(path, options = {}) {
95
+ const response = await this.fetcher(`${this.baseUrl}${path}`, {
96
+ method: options.method ?? "GET",
97
+ headers: {
98
+ "x-api-key": this.apiKey,
99
+ ...(options.body === undefined
100
+ ? {}
101
+ : { "Content-Type": "application/json" }),
102
+ },
103
+ body: options.body === undefined ? undefined : JSON.stringify(options.body),
104
+ });
105
+ const body = await readResponseBody(response);
106
+ if (!response.ok) {
107
+ throw new JupiterPredictionApiError(response.status, body);
108
+ }
109
+ return body;
110
+ }
111
+ }
112
+ exports.JupiterPredictionClient = JupiterPredictionClient;
113
+ /** Decode an unsigned transaction returned by Jupiter for wallet signing. */
114
+ function deserializePredictionTransaction(response) {
115
+ if (!response.transaction) {
116
+ throw new TypeError("Prediction transaction must not be empty");
117
+ }
118
+ return web3_js_1.VersionedTransaction.deserialize(decodeBase64(response.transaction));
119
+ }
120
+ function normalizeBaseUrl(value, label) {
121
+ const normalized = value.trim().replace(/\/+$/, "");
122
+ if (!normalized)
123
+ throw new TypeError(`${label} must not be empty`);
124
+ return normalized;
125
+ }
126
+ async function readResponseBody(response) {
127
+ const body = await response.text();
128
+ if (!body)
129
+ return {};
130
+ try {
131
+ return JSON.parse(body);
132
+ }
133
+ catch {
134
+ return body;
135
+ }
136
+ }
137
+ function decodeBase64(encoded) {
138
+ if (typeof Buffer !== "undefined") {
139
+ return new Uint8Array(Buffer.from(encoded, "base64"));
140
+ }
141
+ const binary = atob(encoded);
142
+ const bytes = new Uint8Array(binary.length);
143
+ for (let index = 0; index < binary.length; index++) {
144
+ bytes[index] = binary.charCodeAt(index);
145
+ }
146
+ return bytes;
147
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./types.js";
2
+ export * from "./keys.js";
3
+ export * from "./pdas.js";
4
+ export * from "./client.js";
5
+ export * from "./relayer.js";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types.js"), exports);
18
+ __exportStar(require("./keys.js"), exports);
19
+ __exportStar(require("./pdas.js"), exports);
20
+ __exportStar(require("./client.js"), exports);
21
+ __exportStar(require("./relayer.js"), exports);
@@ -0,0 +1,14 @@
1
+ import { Keypair } from "@solana/web3.js";
2
+ export interface PredictionKeyBundle {
3
+ withdrawalId: Uint8Array;
4
+ withdrawalIdHex: string;
5
+ ephemeral: Keypair;
6
+ claimantPublicKey: string;
7
+ claimantSecretKey: string;
8
+ }
9
+ export declare function derivePredictionEphemeralKeypair(spendingKey: Uint8Array, nonce: number): Keypair;
10
+ export declare function derivePredictionWithdrawalId(spendingKey: Uint8Array, nonce: number): Uint8Array;
11
+ export declare function predictionWithdrawalIdToHex(withdrawalId: Uint8Array): string;
12
+ export declare function predictionWithdrawalIdFromHex(value: string): Uint8Array;
13
+ /** Derive every client-held key field needed across a prediction lifecycle. */
14
+ export declare function derivePredictionKeyBundle(spendingKey: Uint8Array, nonce: number): PredictionKeyBundle;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.derivePredictionEphemeralKeypair = derivePredictionEphemeralKeypair;
4
+ exports.derivePredictionWithdrawalId = derivePredictionWithdrawalId;
5
+ exports.predictionWithdrawalIdToHex = predictionWithdrawalIdToHex;
6
+ exports.predictionWithdrawalIdFromHex = predictionWithdrawalIdFromHex;
7
+ exports.derivePredictionKeyBundle = derivePredictionKeyBundle;
8
+ const sha256_1 = require("@noble/hashes/sha256");
9
+ const web3_js_1 = require("@solana/web3.js");
10
+ const encoding_js_1 = require("../identity/encoding.js");
11
+ function derivePredictionEphemeralKeypair(spendingKey, nonce) {
12
+ (0, encoding_js_1.assertBytes)(spendingKey, 32, "spending key");
13
+ if (!Number.isSafeInteger(nonce) || nonce < 0) {
14
+ throw new RangeError("prediction nonce must be a non-negative safe integer");
15
+ }
16
+ return web3_js_1.Keypair.fromSeed((0, sha256_1.sha256)((0, encoding_js_1.concatBytes)((0, encoding_js_1.utf8)("prediction_ephemeral"), spendingKey, (0, encoding_js_1.uint64Le)(BigInt(nonce), "prediction nonce"))));
17
+ }
18
+ function derivePredictionWithdrawalId(spendingKey, nonce) {
19
+ (0, encoding_js_1.assertBytes)(spendingKey, 32, "spending key");
20
+ return (0, sha256_1.sha256)((0, encoding_js_1.concatBytes)((0, encoding_js_1.utf8)("prediction_withdrawal_v1"), spendingKey, (0, encoding_js_1.uint32Le)(nonce, "prediction nonce")));
21
+ }
22
+ function predictionWithdrawalIdToHex(withdrawalId) {
23
+ (0, encoding_js_1.assertBytes)(withdrawalId, 32, "prediction withdrawal ID");
24
+ return (0, encoding_js_1.bytesToHex)(withdrawalId);
25
+ }
26
+ function predictionWithdrawalIdFromHex(value) {
27
+ return (0, encoding_js_1.hexToBytes)(value, 32, "prediction withdrawal ID");
28
+ }
29
+ /** Derive every client-held key field needed across a prediction lifecycle. */
30
+ function derivePredictionKeyBundle(spendingKey, nonce) {
31
+ const withdrawalId = derivePredictionWithdrawalId(spendingKey, nonce);
32
+ const ephemeral = derivePredictionEphemeralKeypair(spendingKey, nonce);
33
+ return {
34
+ withdrawalId,
35
+ withdrawalIdHex: predictionWithdrawalIdToHex(withdrawalId),
36
+ ephemeral,
37
+ claimantPublicKey: ephemeral.publicKey.toBase58(),
38
+ claimantSecretKey: (0, encoding_js_1.encodeBase58)(ephemeral.secretKey),
39
+ };
40
+ }
@@ -0,0 +1,6 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ export declare function derivePredictionSlotPda(params: {
3
+ programId: PublicKey;
4
+ mint: PublicKey;
5
+ withdrawalId: Uint8Array;
6
+ }): PublicKey;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.derivePredictionSlotPda = derivePredictionSlotPda;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const encoding_js_1 = require("../identity/encoding.js");
6
+ function derivePredictionSlotPda(params) {
7
+ (0, encoding_js_1.assertBytes)(params.withdrawalId, 32, "prediction withdrawal ID");
8
+ return web3_js_1.PublicKey.findProgramAddressSync([
9
+ (0, encoding_js_1.utf8)("prediction_slot_v1"),
10
+ params.mint.toBytes(),
11
+ params.withdrawalId,
12
+ ], params.programId)[0];
13
+ }
@@ -0,0 +1,3 @@
1
+ import type { PredictionOpenRequest, PredictionOpenResponse, PredictionReissueRequest, PredictionReissueResponse } from "./types.js";
2
+ export declare function submitPredictionOpen(data: PredictionOpenRequest): Promise<PredictionOpenResponse>;
3
+ export declare function submitPredictionReissue(data: PredictionReissueRequest): Promise<PredictionReissueResponse>;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.submitPredictionOpen = submitPredictionOpen;
4
+ exports.submitPredictionReissue = submitPredictionReissue;
5
+ const internal_js_1 = require("../relayer/internal.js");
6
+ function submitPredictionOpen(data) {
7
+ return (0, internal_js_1.getInternalRelayerClient)().submitPredictionOpen(data);
8
+ }
9
+ function submitPredictionReissue(data) {
10
+ return (0, internal_js_1.getInternalRelayerClient)().submitPredictionReissue(data);
11
+ }
@@ -0,0 +1,178 @@
1
+ import type { TransactNote } from "../relayer/types.js";
2
+ export interface PredictionOpenRequest {
3
+ notes: TransactNote[];
4
+ /** USDC stake, raw 6-decimal units. */
5
+ depositAmount: string;
6
+ /** 32-byte prediction-slot withdrawal ID, hex. */
7
+ withdrawalId: string;
8
+ /** Deterministic ephemeral wallet and open-proof claimant, base58. */
9
+ claimantPublicKey: string;
10
+ userPublicKey: string;
11
+ }
12
+ export interface PredictionOpenResponse {
13
+ success: boolean;
14
+ message: string;
15
+ data?: {
16
+ txSignature: string;
17
+ ephemeralWallet: string;
18
+ ephemeralTokenAccount: string;
19
+ changeAmount: string;
20
+ fee: string;
21
+ feeBps: number;
22
+ totalDebited: string;
23
+ };
24
+ }
25
+ export interface PredictionReissueRequest {
26
+ withdrawalId: string;
27
+ claimantSecretKey: string;
28
+ /** Kept for API compatibility; the relayer reads the real chain balance. */
29
+ reissueAmount: string;
30
+ veiloPublicKey: string;
31
+ userPublicKey: string;
32
+ }
33
+ export interface PredictionReissueResponse {
34
+ success: boolean;
35
+ message: string;
36
+ data?: {
37
+ txSignature: string | null;
38
+ reissueAmount: string;
39
+ fee?: string;
40
+ tradeHappened?: boolean;
41
+ };
42
+ }
43
+ export interface PredictionMarketPricing {
44
+ buyYesPriceUsd: number;
45
+ sellYesPriceUsd: number;
46
+ buyNoPriceUsd: number;
47
+ sellNoPriceUsd: number;
48
+ volume: number;
49
+ }
50
+ export interface PredictionMarket {
51
+ provider: string;
52
+ marketId: string;
53
+ status: "open" | "closed" | "cancelled";
54
+ result: string | null;
55
+ title: string;
56
+ openTime: number;
57
+ closeTime: number;
58
+ rulesPrimary?: string;
59
+ imageUrl?: string;
60
+ clobTokenIds?: string[];
61
+ pricing: PredictionMarketPricing;
62
+ }
63
+ export interface PredictionEvent {
64
+ eventId: string;
65
+ isActive: boolean;
66
+ isLive: boolean;
67
+ category: string;
68
+ subcategory: string;
69
+ tags: string[];
70
+ metadata: {
71
+ title: string;
72
+ closeTime: string;
73
+ imageUrl?: string;
74
+ series?: string;
75
+ slug?: string;
76
+ };
77
+ volumeUsd: string;
78
+ volume24hr: string;
79
+ closeCondition?: string;
80
+ markets: PredictionMarket[];
81
+ }
82
+ export interface PredictionPosition {
83
+ pubkey: string;
84
+ owner: string;
85
+ marketId: string;
86
+ isYes: boolean;
87
+ contracts: string;
88
+ contractsDecimal: string;
89
+ totalCostUsd: string;
90
+ sizeUsd: string;
91
+ valueUsd: string;
92
+ avgPriceUsd: string;
93
+ markPriceUsd: string;
94
+ pnlUsd: string;
95
+ pnlUsdPercent: number;
96
+ feesPaidUsd: string;
97
+ claimed: boolean;
98
+ claimable: boolean;
99
+ payoutUsd: string;
100
+ sellPriceUsd: string;
101
+ settlementDate: number;
102
+ eventMetadata: {
103
+ title: string;
104
+ category: string;
105
+ imageUrl?: string;
106
+ };
107
+ marketMetadata: {
108
+ title: string;
109
+ result: string | null;
110
+ status: string;
111
+ };
112
+ }
113
+ export interface PlacePredictionOrderRequest {
114
+ ownerPubkey: string;
115
+ marketId: string;
116
+ isYes: boolean;
117
+ isBuy: true;
118
+ depositAmount: string;
119
+ depositMint: string;
120
+ }
121
+ export interface PredictionTransactionResponse {
122
+ transaction: string;
123
+ txMeta: {
124
+ blockhash: string;
125
+ lastValidBlockHeight: number;
126
+ };
127
+ }
128
+ export interface PlacePredictionOrderResponse extends PredictionTransactionResponse {
129
+ order: {
130
+ orderPubkey: string;
131
+ positionPubkey: string;
132
+ contracts: number;
133
+ };
134
+ }
135
+ export type PredictionOrderStatus = "pending" | "filled" | "partiallyfilled" | "failed";
136
+ export interface PredictionOrderStatusResponse {
137
+ orderPubkey: string;
138
+ status: PredictionOrderStatus;
139
+ latestEventType: string;
140
+ latestSignature: string;
141
+ history: Array<{
142
+ eventType: string;
143
+ status: string;
144
+ rawStatus: string;
145
+ timestamp: number;
146
+ signature: string;
147
+ }>;
148
+ }
149
+ export interface PredictionHistoryEvent {
150
+ id: number;
151
+ eventType: string;
152
+ signature: string;
153
+ timestamp: number;
154
+ marketId: string;
155
+ isYes: boolean;
156
+ isBuy: boolean;
157
+ contractsDecimal: string;
158
+ avgFillPriceUsd?: string;
159
+ totalCostUsd?: string;
160
+ netProceedsUsd?: string;
161
+ realizedPnl?: string;
162
+ payoutAmountUsd?: string;
163
+ eventMetadata: {
164
+ title: string;
165
+ category?: string;
166
+ imageUrl?: string;
167
+ };
168
+ marketMetadata: {
169
+ title: string;
170
+ result: string | null;
171
+ status: string;
172
+ };
173
+ }
174
+ export type PredictionPriceInterval = "1d" | "1w" | "1m" | "max";
175
+ export interface PredictionPricePoint {
176
+ t: number;
177
+ p: number;
178
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,8 @@
1
1
  import { Program, Idl, Wallet } from "@coral-xyz/anchor";
2
2
  import { Connection, PublicKey } from "@solana/web3.js";
3
+ import { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY2_IDL, PRIVACY_POOL_LEGACY_IDL } from "./idl/index.js";
3
4
  export declare const PRIVACY_POOL_IDL: Idl;
5
+ export { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY_IDL, PRIVACY_POOL_LEGACY2_IDL, };
4
6
  /** Deployed program ID extracted from the bundled IDL. */
5
7
  export declare const PRIVACY_POOL_PROGRAM_ID: PublicKey;
6
8
  /**
@@ -1,18 +1,19 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PRIVACY_POOL_PROGRAM_ID = exports.PRIVACY_POOL_IDL = void 0;
3
+ exports.PRIVACY_POOL_PROGRAM_ID = exports.PRIVACY_POOL_LEGACY2_IDL = exports.PRIVACY_POOL_LEGACY_IDL = exports.PRIVACY_POOL_IDLS = exports.PRIVACY_POOL_CURRENT_IDL = exports.PRIVACY_POOL_IDL = void 0;
7
4
  exports.createVeiloProgram = createVeiloProgram;
8
5
  exports.createReadonlyVeiloProgram = createReadonlyVeiloProgram;
9
6
  const anchor_1 = require("@coral-xyz/anchor");
10
7
  const web3_js_1 = require("@solana/web3.js");
11
- const privacy_pool_js_1 = __importDefault(require("./idl/privacy_pool.js"));
8
+ const index_js_1 = require("./idl/index.js");
9
+ Object.defineProperty(exports, "PRIVACY_POOL_CURRENT_IDL", { enumerable: true, get: function () { return index_js_1.PRIVACY_POOL_CURRENT_IDL; } });
10
+ Object.defineProperty(exports, "PRIVACY_POOL_IDLS", { enumerable: true, get: function () { return index_js_1.PRIVACY_POOL_IDLS; } });
11
+ Object.defineProperty(exports, "PRIVACY_POOL_LEGACY2_IDL", { enumerable: true, get: function () { return index_js_1.PRIVACY_POOL_LEGACY2_IDL; } });
12
+ Object.defineProperty(exports, "PRIVACY_POOL_LEGACY_IDL", { enumerable: true, get: function () { return index_js_1.PRIVACY_POOL_LEGACY_IDL; } });
12
13
  // Re-export so consumers can access the raw IDL if needed
13
- exports.PRIVACY_POOL_IDL = privacy_pool_js_1.default;
14
+ exports.PRIVACY_POOL_IDL = index_js_1.PRIVACY_POOL_CURRENT_IDL;
14
15
  /** Deployed program ID extracted from the bundled IDL. */
15
- exports.PRIVACY_POOL_PROGRAM_ID = new web3_js_1.PublicKey(privacy_pool_js_1.default.address);
16
+ exports.PRIVACY_POOL_PROGRAM_ID = new web3_js_1.PublicKey(index_js_1.PRIVACY_POOL_CURRENT_IDL.address);
16
17
  /**
17
18
  * Create an Anchor `Program` instance for the Veilo Privacy Pool.
18
19
  *