pmxt-core 2.49.10 → 2.50.2

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 (35) hide show
  1. package/dist/exchanges/kalshi/api.d.ts +1 -1
  2. package/dist/exchanges/kalshi/api.js +1 -1
  3. package/dist/exchanges/limitless/api.d.ts +1 -1
  4. package/dist/exchanges/limitless/api.js +1 -1
  5. package/dist/exchanges/myriad/api.d.ts +1 -1
  6. package/dist/exchanges/myriad/api.js +1 -1
  7. package/dist/exchanges/opinion/api.d.ts +1 -1
  8. package/dist/exchanges/opinion/api.js +1 -1
  9. package/dist/exchanges/polymarket/api-clob.d.ts +1 -1
  10. package/dist/exchanges/polymarket/api-clob.js +1 -1
  11. package/dist/exchanges/polymarket/api-data.d.ts +1 -1
  12. package/dist/exchanges/polymarket/api-data.js +1 -1
  13. package/dist/exchanges/polymarket/api-gamma.d.ts +1 -1
  14. package/dist/exchanges/polymarket/api-gamma.js +1 -1
  15. package/dist/exchanges/probable/api.d.ts +1 -1
  16. package/dist/exchanges/probable/api.js +1 -1
  17. package/dist/exchanges/rain/auth.d.ts +25 -0
  18. package/dist/exchanges/rain/auth.js +72 -0
  19. package/dist/exchanges/rain/errors.d.ts +5 -0
  20. package/dist/exchanges/rain/errors.js +11 -0
  21. package/dist/exchanges/rain/fetcher.d.ts +51 -0
  22. package/dist/exchanges/rain/fetcher.js +183 -0
  23. package/dist/exchanges/rain/index.d.ts +43 -0
  24. package/dist/exchanges/rain/index.js +515 -0
  25. package/dist/exchanges/rain/normalizer.d.ts +33 -0
  26. package/dist/exchanges/rain/normalizer.js +289 -0
  27. package/dist/exchanges/rain/utils.d.ts +20 -0
  28. package/dist/exchanges/rain/utils.js +91 -0
  29. package/dist/exchanges/rain/websocket.d.ts +21 -0
  30. package/dist/exchanges/rain/websocket.js +98 -0
  31. package/dist/index.d.ts +4 -0
  32. package/dist/index.js +5 -1
  33. package/dist/server/exchange-factory.js +15 -0
  34. package/dist/server/openapi.yaml +12 -0
  35. package/package.json +7 -6
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
3
- * Generated at: 2026-06-12T14:23:28.945Z
3
+ * Generated at: 2026-06-15T08:24:27.002Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const kalshiApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.kalshiApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/kalshi/Kalshi.yaml
6
- * Generated at: 2026-06-12T14:23:28.945Z
6
+ * Generated at: 2026-06-15T08:24:27.002Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.kalshiApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
3
- * Generated at: 2026-06-12T14:23:29.001Z
3
+ * Generated at: 2026-06-15T08:24:27.043Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const limitlessApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.limitlessApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/limitless/Limitless.yaml
6
- * Generated at: 2026-06-12T14:23:29.001Z
6
+ * Generated at: 2026-06-15T08:24:27.043Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.limitlessApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
3
- * Generated at: 2026-06-12T14:23:29.015Z
3
+ * Generated at: 2026-06-15T08:24:27.053Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const myriadApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.myriadApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/myriad/myriad.yaml
6
- * Generated at: 2026-06-12T14:23:29.015Z
6
+ * Generated at: 2026-06-15T08:24:27.053Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.myriadApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
3
- * Generated at: 2026-06-12T14:23:29.018Z
3
+ * Generated at: 2026-06-15T08:24:27.056Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const opinionApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.opinionApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/opinion/opinion-openapi.yaml
6
- * Generated at: 2026-06-12T14:23:29.018Z
6
+ * Generated at: 2026-06-15T08:24:27.056Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.opinionApiSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
3
- * Generated at: 2026-06-12T14:23:28.956Z
3
+ * Generated at: 2026-06-15T08:24:27.010Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketClobSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketClobSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketClobAPI.yaml
6
- * Generated at: 2026-06-12T14:23:28.956Z
6
+ * Generated at: 2026-06-15T08:24:27.010Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketClobSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
3
- * Generated at: 2026-06-12T14:23:28.975Z
3
+ * Generated at: 2026-06-15T08:24:27.021Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketDataSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketDataSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/Polymarket_Data_API.yaml
6
- * Generated at: 2026-06-12T14:23:28.975Z
6
+ * Generated at: 2026-06-15T08:24:27.021Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketDataSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
3
- * Generated at: 2026-06-12T14:23:28.971Z
3
+ * Generated at: 2026-06-15T08:24:27.019Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const polymarketGammaSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.polymarketGammaSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/polymarket/PolymarketGammaAPI.yaml
6
- * Generated at: 2026-06-12T14:23:28.971Z
6
+ * Generated at: 2026-06-15T08:24:27.019Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.polymarketGammaSpec = {
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
3
- * Generated at: 2026-06-12T14:23:29.007Z
3
+ * Generated at: 2026-06-15T08:24:27.049Z
4
4
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
5
5
  */
6
6
  export declare const probableApiSpec: {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.probableApiSpec = void 0;
4
4
  /**
5
5
  * Auto-generated from /home/runner/work/pmxt/pmxt/core/specs/probable/probable.yaml
6
- * Generated at: 2026-06-12T14:23:29.007Z
6
+ * Generated at: 2026-06-15T08:24:27.049Z
7
7
  * Do not edit manually -- run "npm run fetch:openapi" to regenerate.
8
8
  */
9
9
  exports.probableApiSpec = {
@@ -0,0 +1,25 @@
1
+ import { ExchangeCredentials } from '../../BaseExchange';
2
+ import { type WalletClient, type PublicClient } from 'viem';
3
+ export interface RainCredentials extends ExchangeCredentials {
4
+ privateKey?: string;
5
+ walletAddress?: string;
6
+ subgraphUrl?: string;
7
+ subgraphApiKey?: string;
8
+ wsRpcUrl?: string;
9
+ rpcUrl?: string;
10
+ environment?: 'development' | 'stage' | 'production';
11
+ }
12
+ export declare class RainAuth {
13
+ readonly creds: RainCredentials;
14
+ private wallet?;
15
+ private publicClient?;
16
+ private signerAddress?;
17
+ constructor(creds: RainCredentials);
18
+ get walletAddress(): string | undefined;
19
+ get privateKey(): string | undefined;
20
+ private deriveAddress;
21
+ resolveAddress(): string | undefined;
22
+ requireWalletAddress(method: string): string;
23
+ ensureWalletClient(): WalletClient;
24
+ ensurePublicClient(): PublicClient;
25
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RainAuth = void 0;
4
+ const errors_1 = require("../../errors");
5
+ const viem_1 = require("viem");
6
+ const accounts_1 = require("viem/accounts");
7
+ const chains_1 = require("viem/chains");
8
+ const DEFAULT_ARBITRUM_RPC = 'https://arb1.arbitrum.io/rpc';
9
+ class RainAuth {
10
+ creds;
11
+ wallet;
12
+ publicClient;
13
+ signerAddress;
14
+ constructor(creds) {
15
+ this.creds = creds;
16
+ }
17
+ get walletAddress() {
18
+ return this.creds.walletAddress ?? this.deriveAddress();
19
+ }
20
+ get privateKey() {
21
+ return this.creds.privateKey;
22
+ }
23
+ deriveAddress() {
24
+ if (this.signerAddress)
25
+ return this.signerAddress;
26
+ if (!this.creds.privateKey)
27
+ return undefined;
28
+ const pk = this.creds.privateKey.startsWith('0x')
29
+ ? this.creds.privateKey
30
+ : `0x${this.creds.privateKey}`;
31
+ this.signerAddress = (0, accounts_1.privateKeyToAccount)(pk).address;
32
+ return this.signerAddress;
33
+ }
34
+ resolveAddress() {
35
+ return this.walletAddress;
36
+ }
37
+ requireWalletAddress(method) {
38
+ const addr = this.resolveAddress();
39
+ if (!addr) {
40
+ throw new errors_1.AuthenticationError(`${method} requires a wallet address. Pass { walletAddress } or { privateKey } in credentials.`, 'Rain');
41
+ }
42
+ return addr;
43
+ }
44
+ ensureWalletClient() {
45
+ if (this.wallet)
46
+ return this.wallet;
47
+ if (!this.creds.privateKey) {
48
+ throw new errors_1.AuthenticationError('Trading requires a privateKey. Initialize RainExchange with { privateKey } in credentials.', 'Rain');
49
+ }
50
+ const pk = this.creds.privateKey.startsWith('0x')
51
+ ? this.creds.privateKey
52
+ : `0x${this.creds.privateKey}`;
53
+ const account = (0, accounts_1.privateKeyToAccount)(pk);
54
+ this.signerAddress = account.address;
55
+ this.wallet = (0, viem_1.createWalletClient)({
56
+ account,
57
+ chain: chains_1.arbitrum,
58
+ transport: (0, viem_1.http)(this.creds.rpcUrl ?? DEFAULT_ARBITRUM_RPC),
59
+ });
60
+ return this.wallet;
61
+ }
62
+ ensurePublicClient() {
63
+ if (this.publicClient)
64
+ return this.publicClient;
65
+ this.publicClient = (0, viem_1.createPublicClient)({
66
+ chain: chains_1.arbitrum,
67
+ transport: (0, viem_1.http)(this.creds.rpcUrl ?? DEFAULT_ARBITRUM_RPC),
68
+ });
69
+ return this.publicClient;
70
+ }
71
+ }
72
+ exports.RainAuth = RainAuth;
@@ -0,0 +1,5 @@
1
+ import { ErrorMapper } from '../../utils/error-mapper';
2
+ export declare class RainErrorMapper extends ErrorMapper {
3
+ constructor();
4
+ }
5
+ export declare const rainErrorMapper: RainErrorMapper;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rainErrorMapper = exports.RainErrorMapper = void 0;
4
+ const error_mapper_1 = require("../../utils/error-mapper");
5
+ class RainErrorMapper extends error_mapper_1.ErrorMapper {
6
+ constructor() {
7
+ super('Rain');
8
+ }
9
+ }
10
+ exports.RainErrorMapper = RainErrorMapper;
11
+ exports.rainErrorMapper = new RainErrorMapper();
@@ -0,0 +1,51 @@
1
+ type RainSdk = typeof import('@buidlrrr/rain-sdk');
2
+ type RainClient = InstanceType<RainSdk['Rain']>;
3
+ export interface RainFetcherConfig {
4
+ environment?: 'development' | 'stage' | 'production';
5
+ subgraphUrl?: string;
6
+ subgraphApiKey?: string;
7
+ rpcUrl?: string;
8
+ wsRpcUrl?: string;
9
+ }
10
+ export type RainRawMarket = Awaited<ReturnType<RainClient['getPublicMarkets']>>[number];
11
+ export type RainRawMarketDetails = Awaited<ReturnType<RainClient['getMarketDetails']>>;
12
+ export type RainRawOptionPrice = Awaited<ReturnType<RainClient['getMarketPrices']>>[number];
13
+ export type RainRawPositions = Awaited<ReturnType<RainClient['getPositions']>>;
14
+ export type RainRawBalance = Awaited<ReturnType<RainClient['getSmartAccountBalance']>>;
15
+ export type RainRawPriceHistory = Awaited<ReturnType<RainClient['getPriceHistory']>>;
16
+ export type RainRawTransactions = Awaited<ReturnType<RainClient['getTransactions']>>;
17
+ export type RainRawMarketTransactions = Awaited<ReturnType<RainClient['getMarketTransactions']>>;
18
+ export interface RainMarketWithDetails {
19
+ market: RainRawMarket;
20
+ details?: RainRawMarketDetails;
21
+ }
22
+ export declare class RainFetcher {
23
+ private readonly config;
24
+ private client?;
25
+ constructor(config: RainFetcherConfig);
26
+ private getClient;
27
+ /**
28
+ * List markets. Enriches the first `DETAIL_ENRICHMENT_LIMIT` with on-chain
29
+ * details (options + prices) in bounded-parallel batches. Beyond that, only
30
+ * the basic list-view fields are populated. ponytail: N+1 enrichment is
31
+ * fine for the typical 25-market view; switch to a multicall bundler if a
32
+ * larger feed needs full options on every row.
33
+ */
34
+ fetchRawMarkets(params?: {
35
+ limit?: number;
36
+ offset?: number;
37
+ sortBy?: 'Liquidity' | 'Volumn' | 'latest';
38
+ status?: string;
39
+ }): Promise<RainMarketWithDetails[]>;
40
+ fetchRawMarket(marketId: string): Promise<RainMarketWithDetails | null>;
41
+ fetchRawOHLCV(marketId: string, optionIndex: number, interval: string, limit?: number): Promise<RainRawPriceHistory | null>;
42
+ fetchRawPositions(walletAddress: string): Promise<RainRawPositions>;
43
+ fetchRawBalance(walletAddress: string, tokenAddresses: string[]): Promise<RainRawBalance>;
44
+ fetchRawMarketTrades(marketAddress: string, limit?: number): Promise<RainRawMarketTransactions | null>;
45
+ fetchRawUserTrades(walletAddress: string, marketAddress?: string, limit?: number): Promise<RainRawTransactions | null>;
46
+ /** Expose the underlying SDK client for trade-tx builders in index.ts. */
47
+ sdkClient(): Promise<RainClient>;
48
+ private safeFetchDetails;
49
+ close(): Promise<void>;
50
+ }
51
+ export {};
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ // Thin wrapper around @buidlrrr/rain-sdk. SDK is ESM-only; we use dynamic
3
+ // import() to stay CJS-friendly. All methods return raw Rain SDK types;
4
+ // the normalizer maps them into the Unified schema.
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.RainFetcher = void 0;
7
+ const errors_1 = require("./errors");
8
+ const logger_1 = require("../../utils/logger");
9
+ const esmImportRainSdk = new Function('return import("@buidlrrr/rain-sdk")');
10
+ let sdkPromise;
11
+ function loadSdk() {
12
+ if (!sdkPromise)
13
+ sdkPromise = esmImportRainSdk();
14
+ return sdkPromise;
15
+ }
16
+ const DETAIL_ENRICHMENT_LIMIT = 25;
17
+ const DETAIL_PARALLEL_BATCH = 5;
18
+ class RainFetcher {
19
+ config;
20
+ client;
21
+ constructor(config) {
22
+ this.config = config;
23
+ }
24
+ async getClient() {
25
+ if (!this.client) {
26
+ const sdk = await loadSdk();
27
+ this.client = new sdk.Rain({
28
+ environment: this.config.environment ?? 'production',
29
+ rpcUrl: this.config.rpcUrl,
30
+ subgraphUrl: this.config.subgraphUrl,
31
+ subgraphApiKey: this.config.subgraphApiKey,
32
+ wsRpcUrl: this.config.wsRpcUrl,
33
+ });
34
+ }
35
+ return this.client;
36
+ }
37
+ /**
38
+ * List markets. Enriches the first `DETAIL_ENRICHMENT_LIMIT` with on-chain
39
+ * details (options + prices) in bounded-parallel batches. Beyond that, only
40
+ * the basic list-view fields are populated. ponytail: N+1 enrichment is
41
+ * fine for the typical 25-market view; switch to a multicall bundler if a
42
+ * larger feed needs full options on every row.
43
+ */
44
+ async fetchRawMarkets(params) {
45
+ try {
46
+ const client = await this.getClient();
47
+ const markets = await client.getPublicMarkets({
48
+ limit: params?.limit,
49
+ offset: params?.offset,
50
+ sortBy: params?.sortBy ?? 'Liquidity',
51
+ status: params?.status,
52
+ });
53
+ const enrichUpTo = Math.min(markets.length, DETAIL_ENRICHMENT_LIMIT);
54
+ const enriched = [];
55
+ const resolveId = (m) => m?._id ?? m?.id;
56
+ for (let i = 0; i < enrichUpTo; i += DETAIL_PARALLEL_BATCH) {
57
+ const batch = markets.slice(i, i + DETAIL_PARALLEL_BATCH);
58
+ const details = await Promise.all(batch.map((m) => {
59
+ const mid = resolveId(m);
60
+ return mid ? this.safeFetchDetails(client, mid) : Promise.resolve(undefined);
61
+ }));
62
+ batch.forEach((m, j) => enriched.push({ market: m, details: details[j] }));
63
+ }
64
+ for (let i = enrichUpTo; i < markets.length; i++) {
65
+ enriched.push({ market: markets[i] });
66
+ }
67
+ return enriched;
68
+ }
69
+ catch (error) {
70
+ throw errors_1.rainErrorMapper.mapError(error);
71
+ }
72
+ }
73
+ async fetchRawMarket(marketId) {
74
+ try {
75
+ const client = await this.getClient();
76
+ const details = await client.getMarketDetails(marketId);
77
+ if (!details)
78
+ return null;
79
+ return {
80
+ market: {
81
+ id: details.id,
82
+ title: details.title,
83
+ totalVolume: '0',
84
+ status: details.status,
85
+ contractAddress: details.contractAddress,
86
+ },
87
+ details,
88
+ };
89
+ }
90
+ catch (error) {
91
+ throw errors_1.rainErrorMapper.mapError(error);
92
+ }
93
+ }
94
+ async fetchRawOHLCV(marketId, optionIndex, interval, limit) {
95
+ if (!this.config.subgraphUrl)
96
+ return null;
97
+ try {
98
+ const client = await this.getClient();
99
+ return await client.getPriceHistory({
100
+ marketId,
101
+ optionIndex,
102
+ interval: interval,
103
+ limit,
104
+ });
105
+ }
106
+ catch (error) {
107
+ throw errors_1.rainErrorMapper.mapError(error);
108
+ }
109
+ }
110
+ async fetchRawPositions(walletAddress) {
111
+ try {
112
+ const client = await this.getClient();
113
+ return await client.getPositions(walletAddress);
114
+ }
115
+ catch (error) {
116
+ throw errors_1.rainErrorMapper.mapError(error);
117
+ }
118
+ }
119
+ async fetchRawBalance(walletAddress, tokenAddresses) {
120
+ try {
121
+ const client = await this.getClient();
122
+ return await client.getSmartAccountBalance({
123
+ address: walletAddress,
124
+ tokenAddresses: tokenAddresses,
125
+ });
126
+ }
127
+ catch (error) {
128
+ throw errors_1.rainErrorMapper.mapError(error);
129
+ }
130
+ }
131
+ async fetchRawMarketTrades(marketAddress, limit) {
132
+ if (!this.config.subgraphUrl)
133
+ return null;
134
+ try {
135
+ const client = await this.getClient();
136
+ return await client.getMarketTransactions({
137
+ marketAddress: marketAddress,
138
+ first: limit,
139
+ });
140
+ }
141
+ catch (error) {
142
+ throw errors_1.rainErrorMapper.mapError(error);
143
+ }
144
+ }
145
+ async fetchRawUserTrades(walletAddress, marketAddress, limit) {
146
+ if (!this.config.subgraphUrl)
147
+ return null;
148
+ try {
149
+ const client = await this.getClient();
150
+ return await client.getTransactions({
151
+ address: walletAddress,
152
+ first: limit,
153
+ marketAddress: marketAddress,
154
+ });
155
+ }
156
+ catch (error) {
157
+ throw errors_1.rainErrorMapper.mapError(error);
158
+ }
159
+ }
160
+ /** Expose the underlying SDK client for trade-tx builders in index.ts. */
161
+ async sdkClient() {
162
+ return this.getClient();
163
+ }
164
+ async safeFetchDetails(client, marketId) {
165
+ try {
166
+ return await client.getMarketDetails(marketId);
167
+ }
168
+ catch (err) {
169
+ logger_1.logger.warn('RainFetcher: getMarketDetails failed', { marketId, error: String(err) });
170
+ return undefined;
171
+ }
172
+ }
173
+ async close() {
174
+ if (this.client && typeof this.client.destroyWebSocket === 'function') {
175
+ try {
176
+ await this.client.destroyWebSocket();
177
+ }
178
+ catch { /* ignore */ }
179
+ }
180
+ this.client = undefined;
181
+ }
182
+ }
183
+ exports.RainFetcher = RainFetcher;
@@ -0,0 +1,43 @@
1
+ import { PredictionMarketExchange, MarketFilterParams, EventFetchParams, OHLCVParams, TradesParams, MyTradesParams, HistoryFilterParams } from '../../BaseExchange';
2
+ import { UnifiedMarket, UnifiedEvent, PriceCandle, OrderBook, Trade, UserTrade, Position, Balance, Order, CreateOrderParams, BuiltOrder } from '../../types';
3
+ import { RainCredentials } from './auth';
4
+ export declare class RainExchange extends PredictionMarketExchange {
5
+ protected readonly capabilityOverrides: {
6
+ fetchSeries: false;
7
+ fetchOrderBook: "emulated";
8
+ watchOrderBook: "emulated";
9
+ watchTrades: "emulated";
10
+ fetchOpenOrders: "emulated";
11
+ fetchClosedOrders: "emulated";
12
+ fetchOrder: "emulated";
13
+ };
14
+ private readonly auth;
15
+ private readonly fetcher;
16
+ private readonly normalizer;
17
+ private ws?;
18
+ constructor(credentials?: RainCredentials);
19
+ get name(): string;
20
+ protected fetchMarketsImpl(params?: MarketFilterParams): Promise<UnifiedMarket[]>;
21
+ protected fetchEventsImpl(params: EventFetchParams): Promise<UnifiedEvent[]>;
22
+ fetchOHLCV(outcomeId: string, params: OHLCVParams): Promise<PriceCandle[]>;
23
+ fetchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
24
+ fetchTrades(outcomeId: string, params: TradesParams | HistoryFilterParams): Promise<Trade[]>;
25
+ fetchMyTrades(params?: MyTradesParams): Promise<UserTrade[]>;
26
+ fetchPositions(address?: string): Promise<Position[]>;
27
+ fetchBalance(address?: string): Promise<Balance[]>;
28
+ buildOrder(params: CreateOrderParams): Promise<BuiltOrder>;
29
+ submitOrder(built: BuiltOrder): Promise<Order>;
30
+ createOrder(params: CreateOrderParams): Promise<Order>;
31
+ cancelOrder(orderId: string): Promise<Order>;
32
+ fetchOrder(orderId: string): Promise<Order>;
33
+ fetchOpenOrders(marketId?: string): Promise<Order[]>;
34
+ private parseChoiceIndex;
35
+ private toBaseWei;
36
+ private toPrice1e18;
37
+ private resolveContractFor;
38
+ private ensureApproval;
39
+ private ensureWebSocket;
40
+ watchOrderBook(outcomeId: string, _limit?: number, _params?: Record<string, any>): Promise<OrderBook>;
41
+ watchTrades(outcomeId: string): Promise<Trade[]>;
42
+ close(): Promise<void>;
43
+ }