rain-sdk-v2 2.0.10 → 2.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 +11 -0
- package/dist/Rain.d.ts +3 -1
- package/dist/Rain.js +6 -0
- package/dist/api/investments.d.ts +3 -1
- package/dist/api/investments.js +15 -0
- package/dist/api/types.d.ts +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1017,6 +1017,17 @@ const count = await rain.getUserInvestedLivePoolsCount(accessToken);
|
|
|
1017
1017
|
|
|
1018
1018
|
// Calculate user open interest
|
|
1019
1019
|
const oi = await rain.calculateUserOpenInterest(accessToken);
|
|
1020
|
+
|
|
1021
|
+
// Get the authenticated user's positions in a specific subPool
|
|
1022
|
+
// (per-side net shares, weighted average buy price, projected payout on win)
|
|
1023
|
+
const positions = await rain.getUserPositions(
|
|
1024
|
+
{ poolId: '...', subPoolIndex: 1 },
|
|
1025
|
+
accessToken
|
|
1026
|
+
);
|
|
1027
|
+
|
|
1028
|
+
// Get the authenticated user's open positions across all subPools of a pool
|
|
1029
|
+
// (one entry per (subPool, side) the user still holds; excludes claimed / losing sides)
|
|
1030
|
+
const open = await rain.getOpenPositions({ poolId: '...' }, accessToken);
|
|
1020
1031
|
```
|
|
1021
1032
|
|
|
1022
1033
|
### Orders
|
package/dist/Rain.d.ts
CHANGED
|
@@ -4,7 +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 { EntrySharesResult } from './markets/getEntryShares.js';
|
|
7
|
-
import type { UserProfileUpdateParams, UserHistoryParams, CreateCommentParams, CommentsListingParams, UpdateCommentParams, CommentCountParams, PublicPoolsParams, PrivatePoolsParams, PoolListingByCreatorParams, VerifyAccessCodeParams, PoolTotalParticipantsParams, SearchPoolParams, RelatedPoolsParams, UpdateStreamingParams, UpdatePoolResolutionTimeParams, FindPoolFallbackParams, SignOraclesExtendTimeParams, UserTotalInvestmentParams, OptionsTotalVolumeParams, PoolActivityParams, TopHoldersParams, UserInvestedPoolsParams, InvestmentVolumeGraphParams, UserPnlGraphParams, TopWinnersLosersParams, PnlByPoolIdParams, PriceDataParams, AddReviewParams, GetUserOrdersParams, OrderBookParams, GetUserOrderByPoolIdParams, OrdersListingByPoolParams, AddUserPointsParams, UserOnboardingParams, PointsGraphParams, GetNotificationsParams, MarkNotificationAsReadParams, CreateDisputeMessageParams, GetPoolDisputeConvoParams, FollowToggleParams, FollowCheckParams, FollowListParams, FollowStatsParams, RainBurnPerPoolParams } from './api/types.js';
|
|
7
|
+
import type { UserProfileUpdateParams, UserHistoryParams, CreateCommentParams, CommentsListingParams, UpdateCommentParams, CommentCountParams, PublicPoolsParams, PrivatePoolsParams, PoolListingByCreatorParams, VerifyAccessCodeParams, PoolTotalParticipantsParams, SearchPoolParams, RelatedPoolsParams, UpdateStreamingParams, UpdatePoolResolutionTimeParams, FindPoolFallbackParams, SignOraclesExtendTimeParams, UserTotalInvestmentParams, OptionsTotalVolumeParams, PoolActivityParams, TopHoldersParams, UserInvestedPoolsParams, InvestmentVolumeGraphParams, UserPnlGraphParams, TopWinnersLosersParams, PnlByPoolIdParams, UserPositionsParams, OpenPositionsParams, PriceDataParams, AddReviewParams, GetUserOrdersParams, OrderBookParams, GetUserOrderByPoolIdParams, OrdersListingByPoolParams, AddUserPointsParams, UserOnboardingParams, PointsGraphParams, GetNotificationsParams, MarkNotificationAsReadParams, CreateDisputeMessageParams, GetPoolDisputeConvoParams, FollowToggleParams, FollowCheckParams, FollowListParams, FollowStatsParams, RainBurnPerPoolParams } from './api/types.js';
|
|
8
8
|
export declare class Rain {
|
|
9
9
|
readonly environment: RainEnvironment;
|
|
10
10
|
private readonly marketFactory;
|
|
@@ -244,6 +244,8 @@ export declare class Rain {
|
|
|
244
244
|
getPlatformVolume(accessToken?: string): Promise<import("./api/types.js").ApiResponse<unknown>>;
|
|
245
245
|
getUserInvestedLivePoolsCount(accessToken: string): Promise<import("./api/types.js").ApiResponse<unknown>>;
|
|
246
246
|
calculateUserOpenInterest(accessToken: string): Promise<import("./api/types.js").ApiResponse<unknown>>;
|
|
247
|
+
getUserPositions(params: UserPositionsParams, accessToken: string): Promise<import("./api/types.js").ApiResponse<unknown>>;
|
|
248
|
+
getOpenPositions(params: OpenPositionsParams, accessToken: string): Promise<import("./api/types.js").ApiResponse<unknown>>;
|
|
247
249
|
getPriceData(params: PriceDataParams, accessToken?: string): Promise<import("./api/types.js").ApiResponse<unknown>>;
|
|
248
250
|
addReview(params: AddReviewParams, accessToken: string): Promise<import("./api/types.js").ApiResponse<unknown>>;
|
|
249
251
|
getUserReviews(accessToken: string): Promise<import("./api/types.js").ApiResponse<unknown>>;
|
package/dist/Rain.js
CHANGED
|
@@ -382,6 +382,12 @@ export class Rain {
|
|
|
382
382
|
async calculateUserOpenInterest(accessToken) {
|
|
383
383
|
return investmentsApi.calculateUserOpenInterest(this.cfg(accessToken));
|
|
384
384
|
}
|
|
385
|
+
async getUserPositions(params, accessToken) {
|
|
386
|
+
return investmentsApi.getUserPositions(params, this.cfg(accessToken));
|
|
387
|
+
}
|
|
388
|
+
async getOpenPositions(params, accessToken) {
|
|
389
|
+
return investmentsApi.getOpenPositions(params, this.cfg(accessToken));
|
|
390
|
+
}
|
|
385
391
|
// ─── Price Data ──────────────────────────────────────────────────────────────
|
|
386
392
|
async getPriceData(params, accessToken) {
|
|
387
393
|
return priceDataApi.getPriceData(params, this.cfg(accessToken));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiConfig, ApiResponse, UserTotalInvestmentParams, OptionsTotalVolumeParams, PoolActivityParams, TopHoldersParams, UserInvestedPoolsParams, InvestmentVolumeGraphParams, UserPnlGraphParams, TopWinnersLosersParams, PnlByPoolIdParams } from './types.js';
|
|
1
|
+
import { ApiConfig, ApiResponse, UserTotalInvestmentParams, OptionsTotalVolumeParams, PoolActivityParams, TopHoldersParams, UserInvestedPoolsParams, InvestmentVolumeGraphParams, UserPnlGraphParams, TopWinnersLosersParams, PnlByPoolIdParams, UserPositionsParams, OpenPositionsParams } from './types.js';
|
|
2
2
|
export declare function getUserTotalInvestment(params: UserTotalInvestmentParams, config: ApiConfig): Promise<ApiResponse>;
|
|
3
3
|
export declare function getOptionsTotalVolume(params: OptionsTotalVolumeParams, config: ApiConfig): Promise<ApiResponse>;
|
|
4
4
|
export declare function getPoolActivity(params: PoolActivityParams, config: ApiConfig): Promise<ApiResponse>;
|
|
@@ -19,3 +19,5 @@ export declare function getUserOverallInvestment(config: ApiConfig): Promise<Api
|
|
|
19
19
|
export declare function getPlatformVolume(config: ApiConfig): Promise<ApiResponse>;
|
|
20
20
|
export declare function getUserInvestedLivePoolsCount(config: ApiConfig): Promise<ApiResponse>;
|
|
21
21
|
export declare function calculateUserOpenInterest(config: ApiConfig): Promise<ApiResponse>;
|
|
22
|
+
export declare function getUserPositions(params: UserPositionsParams, config: ApiConfig): Promise<ApiResponse>;
|
|
23
|
+
export declare function getOpenPositions(params: OpenPositionsParams, config: ApiConfig): Promise<ApiResponse>;
|
package/dist/api/investments.js
CHANGED
|
@@ -133,3 +133,18 @@ export async function calculateUserOpenInterest(config) {
|
|
|
133
133
|
});
|
|
134
134
|
return handleResponse(res);
|
|
135
135
|
}
|
|
136
|
+
export async function getUserPositions(params, config) {
|
|
137
|
+
const qs = buildQuery({ subPoolIndex: params.subPoolIndex });
|
|
138
|
+
const res = await fetch(`${config.apiUrl}/investments/${encodeURIComponent(params.poolId)}/user-positions${qs}`, {
|
|
139
|
+
method: 'GET',
|
|
140
|
+
headers: buildHeaders(config),
|
|
141
|
+
});
|
|
142
|
+
return handleResponse(res);
|
|
143
|
+
}
|
|
144
|
+
export async function getOpenPositions(params, config) {
|
|
145
|
+
const res = await fetch(`${config.apiUrl}/investments/${encodeURIComponent(params.poolId)}/open-positions`, {
|
|
146
|
+
method: 'GET',
|
|
147
|
+
headers: buildHeaders(config),
|
|
148
|
+
});
|
|
149
|
+
return handleResponse(res);
|
|
150
|
+
}
|
package/dist/api/types.d.ts
CHANGED
|
@@ -192,6 +192,13 @@ export interface TopWinnersLosersParams {
|
|
|
192
192
|
export interface PnlByPoolIdParams {
|
|
193
193
|
poolId: string;
|
|
194
194
|
}
|
|
195
|
+
export interface UserPositionsParams {
|
|
196
|
+
poolId: string;
|
|
197
|
+
subPoolIndex: number;
|
|
198
|
+
}
|
|
199
|
+
export interface OpenPositionsParams {
|
|
200
|
+
poolId: string;
|
|
201
|
+
}
|
|
195
202
|
export interface PriceDataParams {
|
|
196
203
|
contractAddress: string;
|
|
197
204
|
side: 1 | 2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rain-sdk-v2",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.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",
|