rain-sdk-v2 1.0.9 → 1.0.11
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
|
@@ -484,6 +484,19 @@ const yesShares = await rain.getUserOptionShares({
|
|
|
484
484
|
});
|
|
485
485
|
```
|
|
486
486
|
|
|
487
|
+
### `getDynamicPayout(params): Promise<bigint[]>`
|
|
488
|
+
|
|
489
|
+
Get the dynamic payout amounts for a user on a specific option. Returns an array of payout values per side.
|
|
490
|
+
|
|
491
|
+
```typescript
|
|
492
|
+
const payouts = await rain.getDynamicPayout({
|
|
493
|
+
marketContractAddress: '0x...',
|
|
494
|
+
userAddress: '0x...',
|
|
495
|
+
option: 1n, // 1-based option index
|
|
496
|
+
});
|
|
497
|
+
// payouts = [yesPayoutWei, noPayoutWei]
|
|
498
|
+
```
|
|
499
|
+
|
|
487
500
|
### `getUserActiveBuyOrders(params): Promise<bigint>`
|
|
488
501
|
|
|
489
502
|
Get count of user's active buy orders.
|
package/dist/Rain.d.ts
CHANGED
|
@@ -34,6 +34,11 @@ export declare class Rain {
|
|
|
34
34
|
optionSide: number;
|
|
35
35
|
userAddress: `0x${string}`;
|
|
36
36
|
}): Promise<bigint>;
|
|
37
|
+
getDynamicPayout(params: {
|
|
38
|
+
marketContractAddress: `0x${string}`;
|
|
39
|
+
userAddress: `0x${string}`;
|
|
40
|
+
option: bigint;
|
|
41
|
+
}): Promise<bigint[]>;
|
|
37
42
|
buildSplitTx(params: SplitTxParams & {
|
|
38
43
|
walletAddress: `0x${string}`;
|
|
39
44
|
}): Promise<RawTransaction[]>;
|
package/dist/Rain.js
CHANGED
|
@@ -16,6 +16,7 @@ import { ALLOWED_ENVIRONMENTS, ENV_CONFIG, getRandomRpc } from './config/environ
|
|
|
16
16
|
import { loginUser } from './auth/login.js';
|
|
17
17
|
import { getUserOptionLPShares } from './markets/getUserOptionLPShares.js';
|
|
18
18
|
import { getUserOptionShares } from './markets/getUserOptionShares.js';
|
|
19
|
+
import { getDynamicPayout } from './markets/getDynamicPayout.js';
|
|
19
20
|
import { createPublicClient, http, parseAbi } from 'viem';
|
|
20
21
|
import { arbitrum } from 'viem/chains';
|
|
21
22
|
import * as usersApi from './api/users.js';
|
|
@@ -89,6 +90,9 @@ export class Rain {
|
|
|
89
90
|
async getUserOptionShares(params) {
|
|
90
91
|
return getUserOptionShares({ ...params, rpcUrl: this.rpcUrl });
|
|
91
92
|
}
|
|
93
|
+
async getDynamicPayout(params) {
|
|
94
|
+
return getDynamicPayout({ ...params, rpcUrl: this.rpcUrl });
|
|
95
|
+
}
|
|
92
96
|
async buildSplitTx(params) {
|
|
93
97
|
return buildSplitRawTx({ ...params, rpcUrl: this.rpcUrl });
|
|
94
98
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createPublicClient, http, parseAbi } from 'viem';
|
|
2
|
+
import { arbitrum } from 'viem/chains';
|
|
3
|
+
const dynamicPayoutAbi = parseAbi([
|
|
4
|
+
'function getDynamicPayout(address user, uint256 option) view returns (uint256[] dynamicPayout)',
|
|
5
|
+
]);
|
|
6
|
+
export async function getDynamicPayout(params) {
|
|
7
|
+
const { marketContractAddress, userAddress, option, rpcUrl } = params;
|
|
8
|
+
const client = createPublicClient({
|
|
9
|
+
chain: arbitrum,
|
|
10
|
+
transport: http(rpcUrl),
|
|
11
|
+
});
|
|
12
|
+
const payout = await client.readContract({
|
|
13
|
+
address: marketContractAddress,
|
|
14
|
+
abi: dynamicPayoutAbi,
|
|
15
|
+
functionName: 'getDynamicPayout',
|
|
16
|
+
args: [userAddress, option],
|
|
17
|
+
});
|
|
18
|
+
return payout;
|
|
19
|
+
}
|
|
@@ -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 < 1 || marketOptions.length > 50) {
|
|
15
|
+
throw new Error("options must be between 1 and 50");
|
|
16
16
|
}
|
|
17
17
|
if (marketOptions.some(opt => !opt?.toString().trim())) {
|
|
18
18
|
throw new Error("options cannot contain empty values");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rain-sdk-v2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
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",
|