rain-sdk-v2 2.1.4 → 2.1.5
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 +90 -0
- package/dist/Rain.d.ts +33 -0
- package/dist/Rain.js +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/markets/getDisputeState.d.ts +24 -0
- package/dist/markets/getDisputeState.js +69 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -661,6 +661,96 @@ const payouts = await rain.getDynamicPayout({
|
|
|
661
661
|
// payouts = [yesPayoutWei, noPayoutWei]
|
|
662
662
|
```
|
|
663
663
|
|
|
664
|
+
### `getResolverBondAmount(params): Promise<bigint>`
|
|
665
|
+
|
|
666
|
+
Get the bond amount (in base-token wei) a resolver must post to propose a resolution for an option.
|
|
667
|
+
|
|
668
|
+
```typescript
|
|
669
|
+
const bond = await rain.getResolverBondAmount({
|
|
670
|
+
marketContractAddress: '0x...',
|
|
671
|
+
option: 1n, // 1-based option index
|
|
672
|
+
});
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
### `getDisputeAppealFee(params): Promise<bigint>`
|
|
676
|
+
|
|
677
|
+
Get the fee (in base-token wei) required to open a dispute or appeal on an option.
|
|
678
|
+
|
|
679
|
+
```typescript
|
|
680
|
+
const fee = await rain.getDisputeAppealFee({
|
|
681
|
+
marketContractAddress: '0x...',
|
|
682
|
+
option: 1n,
|
|
683
|
+
});
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
### `optionResolverBond(params): Promise<bigint>`
|
|
687
|
+
|
|
688
|
+
Get the resolver bond currently posted on an option (0n if no resolution has been proposed).
|
|
689
|
+
|
|
690
|
+
```typescript
|
|
691
|
+
const bond = await rain.optionResolverBond({
|
|
692
|
+
marketContractAddress: '0x...',
|
|
693
|
+
option: 1n,
|
|
694
|
+
});
|
|
695
|
+
```
|
|
696
|
+
|
|
697
|
+
### `optionResolutionProposer(params): Promise<`0x${string}`>`
|
|
698
|
+
|
|
699
|
+
Get the address that proposed the resolution for an option (zero address if none).
|
|
700
|
+
|
|
701
|
+
```typescript
|
|
702
|
+
const proposer = await rain.optionResolutionProposer({
|
|
703
|
+
marketContractAddress: '0x...',
|
|
704
|
+
option: 1n,
|
|
705
|
+
});
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
### `isOptionDisputed(params): Promise<boolean>`
|
|
709
|
+
|
|
710
|
+
Check whether an option's resolution has been disputed.
|
|
711
|
+
|
|
712
|
+
```typescript
|
|
713
|
+
const disputed = await rain.isOptionDisputed({
|
|
714
|
+
marketContractAddress: '0x...',
|
|
715
|
+
option: 1n,
|
|
716
|
+
});
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
### `isOptionAppealed(params): Promise<boolean>`
|
|
720
|
+
|
|
721
|
+
Check whether an option's dispute resolution has been appealed.
|
|
722
|
+
|
|
723
|
+
```typescript
|
|
724
|
+
const appealed = await rain.isOptionAppealed({
|
|
725
|
+
marketContractAddress: '0x...',
|
|
726
|
+
option: 1n,
|
|
727
|
+
});
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
### `optionDispute(params): Promise<OptionDisputeInfo>`
|
|
731
|
+
|
|
732
|
+
Get the dispute details for an option: fee paid, the winner claimed by the disputer, the disputer address, and the dispute resolver.
|
|
733
|
+
|
|
734
|
+
```typescript
|
|
735
|
+
const dispute = await rain.optionDispute({
|
|
736
|
+
marketContractAddress: '0x...',
|
|
737
|
+
option: 1n,
|
|
738
|
+
});
|
|
739
|
+
// { disputeFee: bigint, disputedWinner: bigint, disputer: '0x...', disputeResolver: '0x...' }
|
|
740
|
+
```
|
|
741
|
+
|
|
742
|
+
### `optionAppeal(params): Promise<OptionAppealInfo>`
|
|
743
|
+
|
|
744
|
+
Get the appeal details for an option: fee paid, the winner claimed by the appellant, the disputer address, and the appeal resolver.
|
|
745
|
+
|
|
746
|
+
```typescript
|
|
747
|
+
const appeal = await rain.optionAppeal({
|
|
748
|
+
marketContractAddress: '0x...',
|
|
749
|
+
option: 1n,
|
|
750
|
+
});
|
|
751
|
+
// { disputeFee: bigint, disputedWinner: bigint, disputer: '0x...', appealResolver: '0x...' }
|
|
752
|
+
```
|
|
753
|
+
|
|
664
754
|
### `getUserActiveBuyOrders(params): Promise<bigint>`
|
|
665
755
|
|
|
666
756
|
Get count of user's active buy orders.
|
package/dist/Rain.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ExtendTimeTxParams } from './tx/buildExtendTimeRawTx.js';
|
|
|
4
4
|
import { RainCoreConfig, RainEnvironment } from './types.js';
|
|
5
5
|
import { LoginParams, LoginResult } from './auth/types.js';
|
|
6
6
|
import { SellProceedsResult } from './markets/getSellProceeds.js';
|
|
7
|
+
import { OptionDisputeInfo, OptionAppealInfo } from './markets/getDisputeState.js';
|
|
7
8
|
import { EntrySharesResult } from './markets/getEntryShares.js';
|
|
8
9
|
import type { UserProfileUpdateParams, UserHistoryParams, CreateCommentParams, CommentsListingParams, UpdateCommentParams, CommentCountParams, PublicPoolsParams, PrivatePoolsParams, PoolListingByCreatorParams, VerifyAccessCodeParams, PoolTotalParticipantsParams, SearchPoolParams, RelatedPoolsParams, UpdateStreamingParams, UpdatePoolResolutionTimeParams, FindPoolFallbackParams, SignOraclesExtendTimeParams, TrendingTagsParams, UserTotalInvestmentParams, OptionsTotalVolumeParams, PoolActivityParams, TopHoldersParams, UserInvestedPoolsParams, InvestmentVolumeGraphParams, UserPnlGraphParams, TopWinnersLosersParams, PnlByPoolIdParams, UserPositionsParams, OpenPositionsParams, UserSharePositionsParams, SearchInvestedPoolsParams, PriceDataParams, AddReviewParams, GetUserOrdersParams, OrderBookParams, GetUserOrderByPoolIdParams, OrdersListingByPoolParams, AddUserPointsParams, UserOnboardingParams, PointsGraphParams, GetNotificationsParams, MarkNotificationAsReadParams, CreateDisputeMessageParams, GetPoolDisputeConvoParams, FollowToggleParams, FollowCheckParams, FollowListParams, FollowStatsParams, RainBurnPerPoolParams, ToggleBookmarkParams, GetBookmarksParams, CheckBookmarkParams, LeaderboardParams, LeaderboardSearchParams, TraderRecentTradesParams } from './api/types.js';
|
|
9
10
|
export declare class Rain {
|
|
@@ -58,6 +59,38 @@ export declare class Rain {
|
|
|
58
59
|
getDisputeWindow(params: {
|
|
59
60
|
marketContractAddress: `0x${string}`;
|
|
60
61
|
}): Promise<bigint>;
|
|
62
|
+
getResolverBondAmount(params: {
|
|
63
|
+
marketContractAddress: `0x${string}`;
|
|
64
|
+
option: bigint;
|
|
65
|
+
}): Promise<bigint>;
|
|
66
|
+
getDisputeAppealFee(params: {
|
|
67
|
+
marketContractAddress: `0x${string}`;
|
|
68
|
+
option: bigint;
|
|
69
|
+
}): Promise<bigint>;
|
|
70
|
+
optionResolverBond(params: {
|
|
71
|
+
marketContractAddress: `0x${string}`;
|
|
72
|
+
option: bigint;
|
|
73
|
+
}): Promise<bigint>;
|
|
74
|
+
optionResolutionProposer(params: {
|
|
75
|
+
marketContractAddress: `0x${string}`;
|
|
76
|
+
option: bigint;
|
|
77
|
+
}): Promise<`0x${string}`>;
|
|
78
|
+
isOptionDisputed(params: {
|
|
79
|
+
marketContractAddress: `0x${string}`;
|
|
80
|
+
option: bigint;
|
|
81
|
+
}): Promise<boolean>;
|
|
82
|
+
isOptionAppealed(params: {
|
|
83
|
+
marketContractAddress: `0x${string}`;
|
|
84
|
+
option: bigint;
|
|
85
|
+
}): Promise<boolean>;
|
|
86
|
+
optionDispute(params: {
|
|
87
|
+
marketContractAddress: `0x${string}`;
|
|
88
|
+
option: bigint;
|
|
89
|
+
}): Promise<OptionDisputeInfo>;
|
|
90
|
+
optionAppeal(params: {
|
|
91
|
+
marketContractAddress: `0x${string}`;
|
|
92
|
+
option: bigint;
|
|
93
|
+
}): Promise<OptionAppealInfo>;
|
|
61
94
|
getEntryShares(params: {
|
|
62
95
|
marketContractAddress: `0x${string}`;
|
|
63
96
|
option: bigint;
|
package/dist/Rain.js
CHANGED
|
@@ -24,6 +24,9 @@ import { getSellProceeds } from './markets/getSellProceeds.js';
|
|
|
24
24
|
import { getUserSharesInEscrow } from './markets/getUserSharesInEscrow.js';
|
|
25
25
|
import { getOptionClaimed } from './markets/getOptionClaimed.js';
|
|
26
26
|
import { getDisputeWindow } from './markets/getDisputeWindow.js';
|
|
27
|
+
import { getResolverBondAmount } from './markets/getResolverBondAmount.js';
|
|
28
|
+
import { getDisputeAppealFee } from './markets/getDisputeFee.js';
|
|
29
|
+
import { optionResolverBond, optionResolutionProposer, isOptionDisputed, isOptionAppealed, optionDispute, optionAppeal } from './markets/getDisputeState.js';
|
|
27
30
|
import { getEntryShares } from './markets/getEntryShares.js';
|
|
28
31
|
import { createPublicClient, http, parseAbi } from 'viem';
|
|
29
32
|
import { arbitrum } from 'viem/chains';
|
|
@@ -137,6 +140,30 @@ export class Rain {
|
|
|
137
140
|
async getDisputeWindow(params) {
|
|
138
141
|
return getDisputeWindow({ ...params, rpcUrl: this.rpcUrl });
|
|
139
142
|
}
|
|
143
|
+
async getResolverBondAmount(params) {
|
|
144
|
+
return getResolverBondAmount({ ...params, rpcUrl: this.rpcUrl });
|
|
145
|
+
}
|
|
146
|
+
async getDisputeAppealFee(params) {
|
|
147
|
+
return getDisputeAppealFee({ ...params, rpcUrl: this.rpcUrl });
|
|
148
|
+
}
|
|
149
|
+
async optionResolverBond(params) {
|
|
150
|
+
return optionResolverBond({ ...params, rpcUrl: this.rpcUrl });
|
|
151
|
+
}
|
|
152
|
+
async optionResolutionProposer(params) {
|
|
153
|
+
return optionResolutionProposer({ ...params, rpcUrl: this.rpcUrl });
|
|
154
|
+
}
|
|
155
|
+
async isOptionDisputed(params) {
|
|
156
|
+
return isOptionDisputed({ ...params, rpcUrl: this.rpcUrl });
|
|
157
|
+
}
|
|
158
|
+
async isOptionAppealed(params) {
|
|
159
|
+
return isOptionAppealed({ ...params, rpcUrl: this.rpcUrl });
|
|
160
|
+
}
|
|
161
|
+
async optionDispute(params) {
|
|
162
|
+
return optionDispute({ ...params, rpcUrl: this.rpcUrl });
|
|
163
|
+
}
|
|
164
|
+
async optionAppeal(params) {
|
|
165
|
+
return optionAppeal({ ...params, rpcUrl: this.rpcUrl });
|
|
166
|
+
}
|
|
140
167
|
async getEntryShares(params) {
|
|
141
168
|
return getEntryShares({ ...params, rpcUrl: this.rpcUrl });
|
|
142
169
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { signLoginMessage } from './auth/signMessage.js';
|
|
|
8
8
|
export type { ExtendTimeTxParams } from './tx/buildExtendTimeRawTx.js';
|
|
9
9
|
export type { CalculateWinnerTxParams } from './tx/buildCalculateWinnerRawTx.js';
|
|
10
10
|
export type { TokenConfig } from './config/environments.js';
|
|
11
|
+
export type { OptionDisputeInfo, OptionAppealInfo } from './markets/getDisputeState.js';
|
|
11
12
|
export * from './api/index.js';
|
|
12
13
|
export { RainSocket } from './socket/RainSocket.js';
|
|
13
14
|
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';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface OptionDisputeInfo {
|
|
2
|
+
disputeFee: bigint;
|
|
3
|
+
disputedWinner: bigint;
|
|
4
|
+
disputer: `0x${string}`;
|
|
5
|
+
disputeResolver: `0x${string}`;
|
|
6
|
+
}
|
|
7
|
+
export interface OptionAppealInfo {
|
|
8
|
+
disputeFee: bigint;
|
|
9
|
+
disputedWinner: bigint;
|
|
10
|
+
disputer: `0x${string}`;
|
|
11
|
+
appealResolver: `0x${string}`;
|
|
12
|
+
}
|
|
13
|
+
interface OptionReadParams {
|
|
14
|
+
marketContractAddress: `0x${string}`;
|
|
15
|
+
option: bigint;
|
|
16
|
+
rpcUrl: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function optionResolverBond(params: OptionReadParams): Promise<bigint>;
|
|
19
|
+
export declare function optionResolutionProposer(params: OptionReadParams): Promise<`0x${string}`>;
|
|
20
|
+
export declare function isOptionDisputed(params: OptionReadParams): Promise<boolean>;
|
|
21
|
+
export declare function isOptionAppealed(params: OptionReadParams): Promise<boolean>;
|
|
22
|
+
export declare function optionDispute(params: OptionReadParams): Promise<OptionDisputeInfo>;
|
|
23
|
+
export declare function optionAppeal(params: OptionReadParams): Promise<OptionAppealInfo>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createPublicClient, http } from 'viem';
|
|
2
|
+
import { arbitrum } from 'viem/chains';
|
|
3
|
+
import { MarketsAbi } from '../abi/MarketsAbi.js';
|
|
4
|
+
function client(rpcUrl) {
|
|
5
|
+
return createPublicClient({
|
|
6
|
+
chain: arbitrum,
|
|
7
|
+
transport: http(rpcUrl),
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export async function optionResolverBond(params) {
|
|
11
|
+
const { marketContractAddress, option, rpcUrl } = params;
|
|
12
|
+
const bond = await client(rpcUrl).readContract({
|
|
13
|
+
address: marketContractAddress,
|
|
14
|
+
abi: MarketsAbi,
|
|
15
|
+
functionName: 'optionResolverBond',
|
|
16
|
+
args: [option],
|
|
17
|
+
});
|
|
18
|
+
return bond;
|
|
19
|
+
}
|
|
20
|
+
export async function optionResolutionProposer(params) {
|
|
21
|
+
const { marketContractAddress, option, rpcUrl } = params;
|
|
22
|
+
const proposer = await client(rpcUrl).readContract({
|
|
23
|
+
address: marketContractAddress,
|
|
24
|
+
abi: MarketsAbi,
|
|
25
|
+
functionName: 'optionResolutionProposer',
|
|
26
|
+
args: [option],
|
|
27
|
+
});
|
|
28
|
+
return proposer;
|
|
29
|
+
}
|
|
30
|
+
export async function isOptionDisputed(params) {
|
|
31
|
+
const { marketContractAddress, option, rpcUrl } = params;
|
|
32
|
+
const disputed = await client(rpcUrl).readContract({
|
|
33
|
+
address: marketContractAddress,
|
|
34
|
+
abi: MarketsAbi,
|
|
35
|
+
functionName: 'isOptionDisputed',
|
|
36
|
+
args: [option],
|
|
37
|
+
});
|
|
38
|
+
return disputed;
|
|
39
|
+
}
|
|
40
|
+
export async function isOptionAppealed(params) {
|
|
41
|
+
const { marketContractAddress, option, rpcUrl } = params;
|
|
42
|
+
const appealed = await client(rpcUrl).readContract({
|
|
43
|
+
address: marketContractAddress,
|
|
44
|
+
abi: MarketsAbi,
|
|
45
|
+
functionName: 'isOptionAppealed',
|
|
46
|
+
args: [option],
|
|
47
|
+
});
|
|
48
|
+
return appealed;
|
|
49
|
+
}
|
|
50
|
+
export async function optionDispute(params) {
|
|
51
|
+
const { marketContractAddress, option, rpcUrl } = params;
|
|
52
|
+
const [disputeFee, disputedWinner, disputer, disputeResolver] = await client(rpcUrl).readContract({
|
|
53
|
+
address: marketContractAddress,
|
|
54
|
+
abi: MarketsAbi,
|
|
55
|
+
functionName: 'optionDispute',
|
|
56
|
+
args: [option],
|
|
57
|
+
});
|
|
58
|
+
return { disputeFee, disputedWinner, disputer, disputeResolver };
|
|
59
|
+
}
|
|
60
|
+
export async function optionAppeal(params) {
|
|
61
|
+
const { marketContractAddress, option, rpcUrl } = params;
|
|
62
|
+
const [disputeFee, disputedWinner, disputer, appealResolver] = await client(rpcUrl).readContract({
|
|
63
|
+
address: marketContractAddress,
|
|
64
|
+
abi: MarketsAbi,
|
|
65
|
+
functionName: 'optionAppeal',
|
|
66
|
+
args: [option],
|
|
67
|
+
});
|
|
68
|
+
return { disputeFee, disputedWinner, disputer, appealResolver };
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rain-sdk-v2",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.5",
|
|
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",
|