rain-sdk-v2 1.0.2 → 1.0.4
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/README.md +76 -21
- package/dist/Rain.d.ts +16 -5
- package/dist/Rain.js +17 -3
- package/dist/auth/signMessage.d.ts +6 -0
- package/dist/auth/signMessage.js +12 -0
- package/dist/config/environments.d.ts +20 -5
- package/dist/config/environments.js +34 -15
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/tx/CreateMarket/createMarketValidation.js +6 -4
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,14 +23,21 @@ import { arbitrum } from 'viem/chains';
|
|
|
23
23
|
|
|
24
24
|
// Initialize SDK
|
|
25
25
|
const rain = new Rain({
|
|
26
|
-
environment: 'development', // 'development' | 'stage'
|
|
26
|
+
environment: 'development', // 'development' | 'stage'
|
|
27
27
|
rpcUrl: 'https://arb1.arbitrum.io/rpc', // optional, uses random public RPC if omitted
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// Get environment config
|
|
31
31
|
const config = rain.getEnvironmentConfig();
|
|
32
|
-
console.log(config.usdt_token); // USDT contract address
|
|
33
32
|
console.log(config.market_factory_address); // Factory contract
|
|
33
|
+
console.log(config.tokens.usdt.address); // USDT token address
|
|
34
|
+
console.log(config.tokens.rain.address); // RAIN token address
|
|
35
|
+
console.log(config.tokens.usdt.decimals); // 6
|
|
36
|
+
console.log(config.tokens.rain.decimals); // 18
|
|
37
|
+
|
|
38
|
+
// Get token config by address
|
|
39
|
+
const tokenInfo = rain.getTokenConfig('0x...');
|
|
40
|
+
console.log(tokenInfo?.decimals, tokenInfo?.symbol);
|
|
34
41
|
```
|
|
35
42
|
|
|
36
43
|
---
|
|
@@ -49,7 +56,7 @@ const rain = new Rain(config?: RainCoreConfig);
|
|
|
49
56
|
|
|
50
57
|
| Parameter | Type | Default | Description |
|
|
51
58
|
|-----------|------|---------|-------------|
|
|
52
|
-
| `environment` | `'development' \| 'stage'
|
|
59
|
+
| `environment` | `'development' \| 'stage'` | `'development'` | Target environment |
|
|
53
60
|
| `rpcUrl` | `string` | Random public RPC | Custom Arbitrum RPC URL |
|
|
54
61
|
| `apiUrl` | `string` | From environment | Custom API URL |
|
|
55
62
|
|
|
@@ -130,9 +137,12 @@ interface RawTransaction {
|
|
|
130
137
|
Creates a new prediction market. Returns approval TX (if needed) + createPool TX.
|
|
131
138
|
|
|
132
139
|
```typescript
|
|
140
|
+
const config = rain.getEnvironmentConfig();
|
|
141
|
+
|
|
142
|
+
// Create market with USDT (6 decimals)
|
|
133
143
|
const txs = await rain.buildCreateMarketTx({
|
|
134
144
|
marketQuestion: 'Will ETH reach $5000 by end of 2025?',
|
|
135
|
-
marketOptions: ['Yes', 'No'
|
|
145
|
+
marketOptions: ['Yes', 'No'],
|
|
136
146
|
marketTags: ['crypto'],
|
|
137
147
|
marketDescription: 'Prediction on ETH price target',
|
|
138
148
|
isPublic: true,
|
|
@@ -140,21 +150,29 @@ const txs = await rain.buildCreateMarketTx({
|
|
|
140
150
|
creator: '0x...', // smart account or EOA address
|
|
141
151
|
startTime: BigInt(Math.floor(Date.now() / 1000) + 120), // 2 min from now
|
|
142
152
|
endTime: BigInt(Math.floor(Date.now() / 1000) + 86400), // 24h from now
|
|
143
|
-
no_of_options:
|
|
153
|
+
no_of_options: 2n,
|
|
144
154
|
disputeTimer: 60, // seconds (set by SDK from environment)
|
|
145
|
-
inputAmountWei: parseUnits('10', 6), // 10 USDT
|
|
146
|
-
barValues: [
|
|
147
|
-
baseToken: config.
|
|
155
|
+
inputAmountWei: parseUnits('10', 6), // 10 USDT
|
|
156
|
+
barValues: [50, 50], // probability distribution (0-100, sums to 100)
|
|
157
|
+
baseToken: config.tokens.usdt.address, // USDT
|
|
148
158
|
tradingModel: TradingModel.AMM, // AMM = 0, OrderBook = 1
|
|
149
159
|
});
|
|
150
160
|
|
|
161
|
+
// Create market with RAIN token (18 decimals)
|
|
162
|
+
const txsRain = await rain.buildCreateMarketTx({
|
|
163
|
+
...params,
|
|
164
|
+
inputAmountWei: parseUnits('10', 18), // 10 RAIN
|
|
165
|
+
baseToken: config.tokens.rain.address, // RAIN token
|
|
166
|
+
});
|
|
167
|
+
|
|
151
168
|
// Approval amount = liquidity + (oracleFixedFeePerOption * numberOfOptions)
|
|
169
|
+
// Oracle fee is automatically calculated based on the token's decimals
|
|
152
170
|
```
|
|
153
171
|
|
|
154
172
|
| Parameter | Type | Description |
|
|
155
173
|
|-----------|------|-------------|
|
|
156
174
|
| `marketQuestion` | `string` | The market question |
|
|
157
|
-
| `marketOptions` | `string[]` | Option labels (
|
|
175
|
+
| `marketOptions` | `string[]` | Option labels (2-26 options) |
|
|
158
176
|
| `marketTags` | `string[]` | Tags (1-3) |
|
|
159
177
|
| `marketDescription` | `string` | Description |
|
|
160
178
|
| `isPublic` | `boolean` | Public market |
|
|
@@ -408,7 +426,7 @@ Build an ERC20 approve transaction.
|
|
|
408
426
|
|
|
409
427
|
```typescript
|
|
410
428
|
const tx = rain.buildApprovalTx({
|
|
411
|
-
tokenAddress: config.
|
|
429
|
+
tokenAddress: config.tokens.usdt.address,
|
|
412
430
|
spender: '0x...', // market contract address
|
|
413
431
|
amount: parseUnits('100', 6), // 100 USDT
|
|
414
432
|
});
|
|
@@ -424,7 +442,7 @@ Check current ERC20 allowance.
|
|
|
424
442
|
|
|
425
443
|
```typescript
|
|
426
444
|
const allowance = await rain.getTokenAllowance({
|
|
427
|
-
tokenAddress: config.
|
|
445
|
+
tokenAddress: config.tokens.usdt.address,
|
|
428
446
|
owner: '0x...', // your address
|
|
429
447
|
spender: '0x...', // market contract
|
|
430
448
|
});
|
|
@@ -534,9 +552,22 @@ const result = await rain.checkOrderExists({
|
|
|
534
552
|
|
|
535
553
|
Wallet-based login to the Rain backend.
|
|
536
554
|
|
|
555
|
+
#### `signLoginMessage(walletClient, walletAddress)`
|
|
556
|
+
|
|
557
|
+
Signs the lowercased wallet address using `personal_sign`. This signature is required for login.
|
|
558
|
+
|
|
559
|
+
```typescript
|
|
560
|
+
import { signLoginMessage } from 'rain-sdk-v2';
|
|
561
|
+
|
|
562
|
+
const walletClient = createWalletClient({ chain: arbitrum, transport: custom(window.ethereum) });
|
|
563
|
+
const signature = await signLoginMessage(walletClient, '0x...' as `0x${string}`);
|
|
564
|
+
```
|
|
565
|
+
|
|
566
|
+
#### `login(params)`
|
|
567
|
+
|
|
537
568
|
```typescript
|
|
538
569
|
const result = await rain.login({
|
|
539
|
-
signature
|
|
570
|
+
signature, // from signLoginMessage
|
|
540
571
|
walletAddress: '0x...', // EOA address
|
|
541
572
|
smartWalletAddress: '0x...', // Smart account address
|
|
542
573
|
referredBy: 'CODE', // optional referral code
|
|
@@ -564,10 +595,17 @@ Returns:
|
|
|
564
595
|
| `apiUrl` | Backend API URL |
|
|
565
596
|
| `market_factory_address` | Factory contract address |
|
|
566
597
|
| `dispute_initial_timer` | Dispute timer in seconds |
|
|
567
|
-
| `
|
|
568
|
-
| `
|
|
569
|
-
|
|
570
|
-
|
|
598
|
+
| `tokens.usdt` | USDT token config (`address`, `symbol`, `decimals`, `oracle_fixed_fee_per_option`) |
|
|
599
|
+
| `tokens.rain` | RAIN token config (`address`, `symbol`, `decimals`, `oracle_fixed_fee_per_option`) |
|
|
600
|
+
|
|
601
|
+
### `getTokenConfig(tokenAddress)`
|
|
602
|
+
|
|
603
|
+
Looks up token configuration by contract address. Returns `TokenConfig` or `null`.
|
|
604
|
+
|
|
605
|
+
```typescript
|
|
606
|
+
const tokenInfo = rain.getTokenConfig('0x...');
|
|
607
|
+
// { address, symbol, decimals, oracle_fixed_fee_per_option }
|
|
608
|
+
```
|
|
571
609
|
|
|
572
610
|
---
|
|
573
611
|
|
|
@@ -595,11 +633,28 @@ enum OptionSide {
|
|
|
595
633
|
|
|
596
634
|
## Environments
|
|
597
635
|
|
|
598
|
-
| Environment | API | Factory |
|
|
599
|
-
|
|
600
|
-
| `development` | `https://
|
|
601
|
-
| `stage` | `https://
|
|
602
|
-
|
|
636
|
+
| Environment | API | Factory | USDT | RAIN |
|
|
637
|
+
|-------------|-----|---------|------|------|
|
|
638
|
+
| `development` | `https://dev2-api.rain.one` | `0xBD99...0adE` | 6 decimals | 18 decimals |
|
|
639
|
+
| `stage` | `https://stg2-api.rain.one` | `0x4b93...2884` | 6 decimals | 18 decimals |
|
|
640
|
+
|
|
641
|
+
### Supported Tokens
|
|
642
|
+
|
|
643
|
+
Each environment includes token configs for both **USDT** (6 decimals) and **RAIN** (18 decimals). The SDK automatically handles decimal conversions for oracle fees and minimum liquidity validation based on the token used.
|
|
644
|
+
|
|
645
|
+
```typescript
|
|
646
|
+
const config = rain.getEnvironmentConfig();
|
|
647
|
+
|
|
648
|
+
// USDT
|
|
649
|
+
config.tokens.usdt.address // Token contract address
|
|
650
|
+
config.tokens.usdt.decimals // 6
|
|
651
|
+
config.tokens.usdt.symbol // "USDTm" (dev) or "USD₮0" (stage)
|
|
652
|
+
|
|
653
|
+
// RAIN
|
|
654
|
+
config.tokens.rain.address // Token contract address
|
|
655
|
+
config.tokens.rain.decimals // 18
|
|
656
|
+
config.tokens.rain.symbol // "RAIN"
|
|
657
|
+
```
|
|
603
658
|
|
|
604
659
|
---
|
|
605
660
|
|
package/dist/Rain.d.ts
CHANGED
|
@@ -8,9 +8,12 @@ export declare class Rain {
|
|
|
8
8
|
private readonly marketFactory;
|
|
9
9
|
private readonly apiUrl;
|
|
10
10
|
private readonly distute_initial_timer;
|
|
11
|
-
private readonly oracleFixedFeePerOption;
|
|
12
11
|
private readonly rpcUrl?;
|
|
13
12
|
constructor(config?: RainCoreConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Get token config by address. Returns decimals, symbol, and oracle fee.
|
|
15
|
+
*/
|
|
16
|
+
getTokenConfig(tokenAddress: `0x${string}`): import("./config/environments.js").TokenConfig | null;
|
|
14
17
|
buildApprovalTx(params: ApproveTxParams): RawTransaction;
|
|
15
18
|
buildCreateMarketTx(params: CreateMarketTxParams): Promise<RawTransaction[]>;
|
|
16
19
|
buildEnterOptionTx(params: EnterOptionTxParams): RawTransaction;
|
|
@@ -89,10 +92,18 @@ export declare class Rain {
|
|
|
89
92
|
readonly apiUrl: "https://dev2-api.rain.one";
|
|
90
93
|
readonly market_factory_address: `0x${string}`;
|
|
91
94
|
readonly dispute_initial_timer: number;
|
|
92
|
-
readonly
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
readonly tokens: {
|
|
96
|
+
readonly usdt: import("./config/environments.js").TokenConfig;
|
|
97
|
+
readonly rain: import("./config/environments.js").TokenConfig;
|
|
98
|
+
};
|
|
99
|
+
} | {
|
|
100
|
+
readonly apiUrl: "https://stg2-api.rain.one";
|
|
101
|
+
readonly market_factory_address: `0x${string}`;
|
|
102
|
+
readonly dispute_initial_timer: number;
|
|
103
|
+
readonly tokens: {
|
|
104
|
+
readonly usdt: import("./config/environments.js").TokenConfig;
|
|
105
|
+
readonly rain: import("./config/environments.js").TokenConfig;
|
|
106
|
+
};
|
|
96
107
|
};
|
|
97
108
|
private cfg;
|
|
98
109
|
findUserByWalletAddress(params: {
|
package/dist/Rain.js
CHANGED
|
@@ -36,7 +36,6 @@ export class Rain {
|
|
|
36
36
|
marketFactory;
|
|
37
37
|
apiUrl;
|
|
38
38
|
distute_initial_timer;
|
|
39
|
-
oracleFixedFeePerOption;
|
|
40
39
|
rpcUrl;
|
|
41
40
|
constructor(config = {}) {
|
|
42
41
|
const { environment = "development", rpcUrl, apiUrl } = config;
|
|
@@ -52,13 +51,28 @@ export class Rain {
|
|
|
52
51
|
this.marketFactory = envConfig.market_factory_address;
|
|
53
52
|
this.apiUrl = apiUrl ?? envConfig.apiUrl;
|
|
54
53
|
this.distute_initial_timer = envConfig.dispute_initial_timer;
|
|
55
|
-
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get token config by address. Returns decimals, symbol, and oracle fee.
|
|
57
|
+
*/
|
|
58
|
+
getTokenConfig(tokenAddress) {
|
|
59
|
+
const envConfig = ENV_CONFIG[this.environment];
|
|
60
|
+
const tokens = envConfig.tokens;
|
|
61
|
+
for (const key of Object.keys(tokens)) {
|
|
62
|
+
if (tokens[key].address.toLowerCase() === tokenAddress.toLowerCase()) {
|
|
63
|
+
return tokens[key];
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
56
67
|
}
|
|
57
68
|
buildApprovalTx(params) {
|
|
58
69
|
return buildApproveRawTx(params);
|
|
59
70
|
}
|
|
60
71
|
buildCreateMarketTx(params) {
|
|
61
|
-
|
|
72
|
+
const tokenConfig = this.getTokenConfig(params.baseToken);
|
|
73
|
+
const oracleFixedFeePerOption = tokenConfig?.oracle_fixed_fee_per_option ?? 1000000n;
|
|
74
|
+
const tokenDecimals = params.tokenDecimals ?? tokenConfig?.decimals ?? 6;
|
|
75
|
+
return buildCreateMarketRawTx({ ...params, tokenDecimals, factoryContractAddress: this.marketFactory, apiUrl: this.apiUrl, rpcUrl: this.rpcUrl, disputeTimer: this.distute_initial_timer, oracleFixedFeePerOption });
|
|
62
76
|
}
|
|
63
77
|
buildEnterOptionTx(params) {
|
|
64
78
|
return buildEnterOptionRawTx(params);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WalletClient } from 'viem';
|
|
2
|
+
/**
|
|
3
|
+
* Signs the lowercased wallet address using personal_sign.
|
|
4
|
+
* This signature is required for the Rain login API.
|
|
5
|
+
*/
|
|
6
|
+
export declare function signLoginMessage(walletClient: WalletClient, walletAddress: `0x${string}`): Promise<string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Signs the lowercased wallet address using personal_sign.
|
|
3
|
+
* This signature is required for the Rain login API.
|
|
4
|
+
*/
|
|
5
|
+
export async function signLoginMessage(walletClient, walletAddress) {
|
|
6
|
+
const message = walletAddress.toLowerCase();
|
|
7
|
+
const signature = await walletClient.signMessage({
|
|
8
|
+
account: walletAddress,
|
|
9
|
+
message,
|
|
10
|
+
});
|
|
11
|
+
return signature;
|
|
12
|
+
}
|
|
@@ -1,15 +1,30 @@
|
|
|
1
|
-
export declare const ALLOWED_ENVIRONMENTS: readonly ["development"];
|
|
1
|
+
export declare const ALLOWED_ENVIRONMENTS: readonly ["development", "stage"];
|
|
2
2
|
export declare const DEFAULT_RPCS: string[];
|
|
3
3
|
export declare function getRandomRpc(): string;
|
|
4
4
|
export declare const USDT_SYMBOL_DEV = "USDTm";
|
|
5
|
+
export interface TokenConfig {
|
|
6
|
+
address: `0x${string}`;
|
|
7
|
+
symbol: string;
|
|
8
|
+
decimals: number;
|
|
9
|
+
oracle_fixed_fee_per_option: bigint;
|
|
10
|
+
}
|
|
5
11
|
export declare const ENV_CONFIG: {
|
|
6
12
|
readonly development: {
|
|
7
13
|
readonly apiUrl: "https://dev2-api.rain.one";
|
|
8
14
|
readonly market_factory_address: `0x${string}`;
|
|
9
15
|
readonly dispute_initial_timer: number;
|
|
10
|
-
readonly
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
readonly tokens: {
|
|
17
|
+
readonly usdt: TokenConfig;
|
|
18
|
+
readonly rain: TokenConfig;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
readonly stage: {
|
|
22
|
+
readonly apiUrl: "https://stg2-api.rain.one";
|
|
23
|
+
readonly market_factory_address: `0x${string}`;
|
|
24
|
+
readonly dispute_initial_timer: number;
|
|
25
|
+
readonly tokens: {
|
|
26
|
+
readonly usdt: TokenConfig;
|
|
27
|
+
readonly rain: TokenConfig;
|
|
28
|
+
};
|
|
14
29
|
};
|
|
15
30
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const ALLOWED_ENVIRONMENTS = ["development"];
|
|
1
|
+
export const ALLOWED_ENVIRONMENTS = ["development", "stage"];
|
|
2
2
|
export const DEFAULT_RPCS = [
|
|
3
3
|
"https://arb1.arbitrum.io/rpc",
|
|
4
4
|
"https://arbitrum-one.publicnode.com",
|
|
@@ -9,26 +9,45 @@ export function getRandomRpc() {
|
|
|
9
9
|
return DEFAULT_RPCS[index];
|
|
10
10
|
}
|
|
11
11
|
export const USDT_SYMBOL_DEV = "USDTm";
|
|
12
|
-
// export const USDT_SYMBOL_PROD = "USD₮0";
|
|
13
12
|
export const ENV_CONFIG = {
|
|
14
13
|
development: {
|
|
15
14
|
apiUrl: "https://dev2-api.rain.one",
|
|
16
15
|
market_factory_address: "0xBD99441C4116b85dFecA2d6521EC0e2Eb62F0adE",
|
|
17
16
|
dispute_initial_timer: 1 * 60,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
tokens: {
|
|
18
|
+
usdt: {
|
|
19
|
+
address: "0xCa4f77A38d8552Dd1D5E44e890173921B67725F4",
|
|
20
|
+
symbol: USDT_SYMBOL_DEV,
|
|
21
|
+
decimals: 6,
|
|
22
|
+
oracle_fixed_fee_per_option: 1000000n, // $1 in 6 decimals
|
|
23
|
+
},
|
|
24
|
+
rain: {
|
|
25
|
+
address: "0x25118290e6A5f4139381D072181157035864099d",
|
|
26
|
+
symbol: "RAIN",
|
|
27
|
+
decimals: 18,
|
|
28
|
+
oracle_fixed_fee_per_option: 1000000000000000000n, // $1 in 18 decimals
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
stage: {
|
|
33
|
+
apiUrl: "https://stg2-api.rain.one",
|
|
34
|
+
market_factory_address: "0x4b936AB5114F3DFa2A010117Afeb47F746842884",
|
|
35
|
+
dispute_initial_timer: 1 * 60,
|
|
36
|
+
tokens: {
|
|
37
|
+
usdt: {
|
|
38
|
+
address: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9",
|
|
39
|
+
symbol: "USD₮0",
|
|
40
|
+
decimals: 6,
|
|
41
|
+
oracle_fixed_fee_per_option: 1000000n,
|
|
42
|
+
},
|
|
43
|
+
rain: {
|
|
44
|
+
address: "0x43976a124e6834b541840Ce741243dAD3dd538DA",
|
|
45
|
+
symbol: "RAIN",
|
|
46
|
+
decimals: 18,
|
|
47
|
+
oracle_fixed_fee_per_option: 1000000000000000000n,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
22
50
|
},
|
|
23
|
-
// stage: {
|
|
24
|
-
// apiUrl: "https://stg-api.rain.one",
|
|
25
|
-
// market_factory_address: "0xD4900CA167228365806FBA4cB21f7EAe8b6d96BE" as `0x${string}`,
|
|
26
|
-
// dispute_initial_timer: 1 * 60,
|
|
27
|
-
// oracle_fixed_fee_per_option: 1_000_000n, // $1 per option (6 decimals)
|
|
28
|
-
// usdt_symbol: USDT_SYMBOL_PROD,
|
|
29
|
-
// usdt_token: "0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9" as `0x${string}`,
|
|
30
|
-
// rain_token: "0x43976a124e6834b541840Ce741243dAD3dd538DA" as `0x${string}`,
|
|
31
|
-
// },
|
|
32
51
|
// production: {
|
|
33
52
|
// apiUrl: "https://prod-api.rain.one",
|
|
34
53
|
// market_factory_address: "0xA8640B62D755e42C9ed6A86d0fc65CE09e31F264" as `0x${string}`,
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from './types.js';
|
|
|
4
4
|
export { TradingModel, OptionSide } from './tx/types.js';
|
|
5
5
|
export type { CreateMarketTxParams, EnterOptionTxParams, AddLiquidityTxParams, RemoveLiquidityTxParams, SplitTxParams, MergeTxParams, ClosePoolAITxParams, ClosePoolManualTxParams, ChooseWinnerTxParams, PlaceBuyOrderTxParams, PlaceSellOrderTxParams, OpenDisputeTxParams, ClaimTxParams, CancelBuyOrdersTxParams, CancelSellOrdersTxParams, RawTransaction, ApproveTxParams } from './tx/types.js';
|
|
6
6
|
export type { LoginParams, LoginResult } from './auth/types.js';
|
|
7
|
+
export { signLoginMessage } from './auth/signMessage.js';
|
|
8
|
+
export type { TokenConfig } from './config/environments.js';
|
|
7
9
|
export * from './api/index.js';
|
|
8
10
|
export { RainSocket } from './socket/RainSocket.js';
|
|
9
11
|
export type { RainSocketEvent, EnterOptionEventData, ExitOptionEventData, LiquidityEventData, SplitEventData, MergeEventData, RemoveLiquidityEventData, SyncPriceEventData, OrderCreatedEventData, OrderCancelledEventData, OrderFilledEventData, PoolClosedEventData, PoolEventData, WinnerEventData, DisputeOpenedEventData, OracleCreatedEventData, AppealOpenedEventData, DisputeWinnerEventData, AppealWinnerEventData, ClaimRewardEventData, DisputeRefundEventData } from './socket/RainSocket.js';
|
package/dist/index.js
CHANGED
|
@@ -2,5 +2,6 @@ export { Rain } from './Rain.js';
|
|
|
2
2
|
export { RainAA } from './RainAA.js';
|
|
3
3
|
export * from './types.js';
|
|
4
4
|
export { TradingModel, OptionSide } from './tx/types.js';
|
|
5
|
+
export { signLoginMessage } from './auth/signMessage.js';
|
|
5
6
|
export * from './api/index.js';
|
|
6
7
|
export { RainSocket } from './socket/RainSocket.js';
|
|
@@ -11,8 +11,8 @@ export function validateCreateMarketParams(params) {
|
|
|
11
11
|
throw new Error("question is required");
|
|
12
12
|
if (!marketDescription)
|
|
13
13
|
throw new Error("description is required");
|
|
14
|
-
if (!Array.isArray(marketOptions) || marketOptions.length <
|
|
15
|
-
throw new Error("options must be between
|
|
14
|
+
if (!Array.isArray(marketOptions) || marketOptions.length < 2 || marketOptions.length > 26) {
|
|
15
|
+
throw new Error("options must be between 2 and 26");
|
|
16
16
|
}
|
|
17
17
|
if (marketOptions.some(opt => !opt?.toString().trim())) {
|
|
18
18
|
throw new Error("options cannot contain empty values");
|
|
@@ -39,8 +39,10 @@ export function validateCreateMarketParams(params) {
|
|
|
39
39
|
throw new Error("factoryContractAddress is required");
|
|
40
40
|
const decimals = tokenDecimals ?? 6;
|
|
41
41
|
const oneTokenInWei = 10n ** BigInt(decimals);
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
// $0.1 minimum for dev/stage, validation for production handled separately
|
|
43
|
+
const minAmount = oneTokenInWei / 10n; // 0.1 token
|
|
44
|
+
if (inputAmountWei < minAmount) {
|
|
45
|
+
throw new Error("Market cannot be opened: inputAmountWei must be at least $0.1");
|
|
44
46
|
}
|
|
45
47
|
if (startTime >= endTime)
|
|
46
48
|
throw new Error("startTime must be earlier than endTime");
|
package/dist/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface RainConfig {
|
|
|
7
7
|
chain: Chain;
|
|
8
8
|
rpcUrl?: string;
|
|
9
9
|
}
|
|
10
|
-
export type RainEnvironment = "development";
|
|
10
|
+
export type RainEnvironment = "development" | "stage";
|
|
11
11
|
export interface RainCoreConfig {
|
|
12
12
|
environment?: RainEnvironment;
|
|
13
13
|
rpcUrl?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rain-sdk-v2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rain SDK V2 — TypeScript SDK for Rain prediction markets on Arbitrum. Market creation, trading, liquidity, order book, split/merge, dispute, and smart account support.",
|
|
6
6
|
"main": "dist/index.js",
|