rain-sdk-v2 2.0.4 → 2.0.6
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
CHANGED
|
@@ -187,7 +187,7 @@ const txsRain = await rain.buildCreateMarketTx({
|
|
|
187
187
|
| `inputAmountWei` | `bigint` | Initial liquidity in base token wei |
|
|
188
188
|
| `disputeTimer` | `number` | Oracle end time duration in seconds (e.g. 259200 = 3 days). Auto-set from environment config |
|
|
189
189
|
| `barValues` | `number[]` | Probability distribution (0-100 scale) |
|
|
190
|
-
| `initialYesPrices` | `bigint[]` | *(Optional)* Initial Yes prices per option in 1e18 scale (e.g. `500000000000000000n` = 50%). Defaults to 50% for AMM
|
|
190
|
+
| `initialYesPrices` | `bigint[]` | *(Optional)* Initial Yes prices per option in 1e18 scale (e.g. `500000000000000000n` = 50%). Defaults to 50% for both AMM and OrderBook |
|
|
191
191
|
| `baseToken` | `0x${string}` | Base token address (USDT or RAIN) |
|
|
192
192
|
| `tradingModel` | `TradingModel` | `AMM (0)` or `OrderBook (1)` |
|
|
193
193
|
| `marketImage` | `string` | Market image URL (required) |
|
|
@@ -531,6 +531,17 @@ const claimed = await rain.getOptionClaimed({
|
|
|
531
531
|
// true if already claimed, false otherwise
|
|
532
532
|
```
|
|
533
533
|
|
|
534
|
+
### `getDisputeWindow(params): Promise<bigint>`
|
|
535
|
+
|
|
536
|
+
Get the dispute window duration (in seconds) for a market contract.
|
|
537
|
+
|
|
538
|
+
```typescript
|
|
539
|
+
const window = await rain.getDisputeWindow({
|
|
540
|
+
marketContractAddress: '0x...',
|
|
541
|
+
});
|
|
542
|
+
// window = dispute window in seconds (e.g. 7200n = 2 hours)
|
|
543
|
+
```
|
|
544
|
+
|
|
534
545
|
### `getDynamicPayout(params): Promise<bigint[]>`
|
|
535
546
|
|
|
536
547
|
Get the dynamic payout amounts for a user on a specific option. Returns an array of payout values per side.
|
package/dist/Rain.d.ts
CHANGED
|
@@ -51,6 +51,9 @@ export declare class Rain {
|
|
|
51
51
|
option: bigint;
|
|
52
52
|
userAddress: `0x${string}`;
|
|
53
53
|
}): Promise<boolean>;
|
|
54
|
+
getDisputeWindow(params: {
|
|
55
|
+
marketContractAddress: `0x${string}`;
|
|
56
|
+
}): Promise<bigint>;
|
|
54
57
|
getDynamicPayout(params: {
|
|
55
58
|
marketContractAddress: `0x${string}`;
|
|
56
59
|
userAddress: `0x${string}`;
|
package/dist/Rain.js
CHANGED
|
@@ -19,6 +19,7 @@ import { getUserOptionShares } from './markets/getUserOptionShares.js';
|
|
|
19
19
|
import { getDynamicPayout } from './markets/getDynamicPayout.js';
|
|
20
20
|
import { getUserSharesInEscrow } from './markets/getUserSharesInEscrow.js';
|
|
21
21
|
import { getOptionClaimed } from './markets/getOptionClaimed.js';
|
|
22
|
+
import { getDisputeWindow } from './markets/getDisputeWindow.js';
|
|
22
23
|
import { createPublicClient, http, parseAbi } from 'viem';
|
|
23
24
|
import { arbitrum } from 'viem/chains';
|
|
24
25
|
import * as usersApi from './api/users.js';
|
|
@@ -123,6 +124,9 @@ export class Rain {
|
|
|
123
124
|
async getOptionClaimed(params) {
|
|
124
125
|
return getOptionClaimed({ ...params, rpcUrl: this.rpcUrl });
|
|
125
126
|
}
|
|
127
|
+
async getDisputeWindow(params) {
|
|
128
|
+
return getDisputeWindow({ ...params, rpcUrl: this.rpcUrl });
|
|
129
|
+
}
|
|
126
130
|
async getDynamicPayout(params) {
|
|
127
131
|
return getDynamicPayout({ ...params, rpcUrl: this.rpcUrl });
|
|
128
132
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createPublicClient, http } from 'viem';
|
|
2
|
+
import { arbitrum } from 'viem/chains';
|
|
3
|
+
import { MarketsAbi } from '../abi/MarketsAbi.js';
|
|
4
|
+
export async function getDisputeWindow(params) {
|
|
5
|
+
const { marketContractAddress, rpcUrl } = params;
|
|
6
|
+
const client = createPublicClient({
|
|
7
|
+
chain: arbitrum,
|
|
8
|
+
transport: http(rpcUrl),
|
|
9
|
+
});
|
|
10
|
+
const disputeWindow = await client.readContract({
|
|
11
|
+
address: marketContractAddress,
|
|
12
|
+
abi: MarketsAbi,
|
|
13
|
+
functionName: 'DISPUTE_WINDOW',
|
|
14
|
+
});
|
|
15
|
+
return disputeWindow;
|
|
16
|
+
}
|
|
@@ -37,13 +37,10 @@ export async function buildCreateMarketRawTx(params) {
|
|
|
37
37
|
ipfsUri: ipfsUrl,
|
|
38
38
|
initialLiquidity: inputAmountWei,
|
|
39
39
|
liquidityPercentages,
|
|
40
|
-
initialYesPrices:
|
|
41
|
-
? liquidityPercentages.map(() => 0n)
|
|
42
|
-
: (params.initialYesPrices ?? liquidityPercentages.map(() => 500000000000000000n)),
|
|
40
|
+
initialYesPrices: params.initialYesPrices ?? liquidityPercentages.map(() => 500000000000000000n),
|
|
43
41
|
baseToken,
|
|
44
42
|
tradingModel: tradingModel ?? 0,
|
|
45
43
|
};
|
|
46
|
-
console.log('createMarketParams: ', createMarketParams);
|
|
47
44
|
createMarketTransactions.push({
|
|
48
45
|
to: factoryContractAddress,
|
|
49
46
|
data: encodeFunctionData({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rain-sdk-v2",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
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",
|