@liberfi.io/react-predict 0.1.48 → 0.1.50
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/dist/index.d.mts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +68 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -17
- package/dist/index.mjs.map +1 -1
- package/dist/{server-Curi-jN1.d.mts → server-CaB0XJAa.d.mts} +33 -1
- package/dist/{server-Curi-jN1.d.ts → server-CaB0XJAa.d.ts} +33 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +34 -16
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +34 -16
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -142,6 +142,11 @@ interface ListEventsParams {
|
|
|
142
142
|
* (i.e. the event closes within the specified window).
|
|
143
143
|
*/
|
|
144
144
|
end_before?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Max number of markets per event (sorted by volume DESC).
|
|
147
|
+
* `0` means no limit. Defaults to `3` when set via `resolveEventsParams`.
|
|
148
|
+
*/
|
|
149
|
+
markets_limit?: number;
|
|
145
150
|
}
|
|
146
151
|
/** Single price level in an order book. */
|
|
147
152
|
interface OrderbookLevel {
|
|
@@ -685,6 +690,16 @@ interface EventStats {
|
|
|
685
690
|
avg_liquidity: number;
|
|
686
691
|
active_sources: number;
|
|
687
692
|
}
|
|
693
|
+
/** Response from the available-shares endpoint. */
|
|
694
|
+
interface AvailableSharesResponse {
|
|
695
|
+
source: ProviderSource;
|
|
696
|
+
market: string;
|
|
697
|
+
side: string;
|
|
698
|
+
total_shares: number;
|
|
699
|
+
active_order_shares: number;
|
|
700
|
+
available_shares: number;
|
|
701
|
+
precision: number;
|
|
702
|
+
}
|
|
688
703
|
|
|
689
704
|
/**
|
|
690
705
|
* HTTP client for the prediction-server REST API.
|
|
@@ -765,6 +780,18 @@ declare class PredictClient {
|
|
|
765
780
|
kalshi_user?: string;
|
|
766
781
|
polymarket_user?: string;
|
|
767
782
|
}, source?: ProviderSource): Promise<PositionsResponse>;
|
|
783
|
+
/**
|
|
784
|
+
* Get the number of shares available for selling, accounting for active orders.
|
|
785
|
+
*
|
|
786
|
+
* Maps to `GET /api/v1/available-shares?source=...&user=...&market=...&side=...`.
|
|
787
|
+
*
|
|
788
|
+
* @param source - Provider source.
|
|
789
|
+
* @param user - Wallet address.
|
|
790
|
+
* @param market - Market slug.
|
|
791
|
+
* @param side - Position side ("yes" or "no").
|
|
792
|
+
* @param headers - Optional extra headers (e.g. Polymarket POLY_* HMAC headers).
|
|
793
|
+
*/
|
|
794
|
+
getAvailableShares(source: ProviderSource, user: string, market: string, side: string, headers?: Record<string, string>): Promise<AvailableSharesResponse>;
|
|
768
795
|
/**
|
|
769
796
|
* Get the on-chain USDC balance for a wallet.
|
|
770
797
|
*
|
|
@@ -1082,6 +1109,11 @@ interface ResolveEventsParamsInput {
|
|
|
1082
1109
|
* "1d" = events closing within 24 h, "7d" = 7 days, "30d" = 30 days.
|
|
1083
1110
|
*/
|
|
1084
1111
|
timeRemaining?: string;
|
|
1112
|
+
/**
|
|
1113
|
+
* Max number of markets per event (sorted by volume DESC).
|
|
1114
|
+
* Defaults to `3` in `resolveEventsParams`.
|
|
1115
|
+
*/
|
|
1116
|
+
markets_limit?: number;
|
|
1085
1117
|
}
|
|
1086
1118
|
/**
|
|
1087
1119
|
* Build a clean `ListEventsParams` from loose user inputs.
|
|
@@ -1423,4 +1455,4 @@ interface ClobOrderPayload {
|
|
|
1423
1455
|
*/
|
|
1424
1456
|
declare function buildClobPayload(signedOrder: SignedOrder, owner: string): ClobOrderPayload;
|
|
1425
1457
|
|
|
1426
|
-
export { type
|
|
1458
|
+
export { type PredictWsClientConfig as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStats as E, type WithdrawBuildRequest as F, type WithdrawSubmitResponse as G, type WithdrawSubmitRequest as H, type WithdrawStatusResponse as I, type PolymarketDepositAddresses as J, type PolymarketWithdrawResponse as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketWithdrawRequest as N, type Orderbook as O, PredictClient as P, type WsConnectionStatus as Q, type WsDataMessage as R, type SimilarEventsParams as S, type TickSizeResponse as T, type WsPriceEvent as U, type WsOrderbookEvent as V, type WithdrawBuildResponse as W, type WsTradeEvent as X, type CreateOrderInput as Y, createPredictClient as Z, createPredictWsClient as _, PredictWsClient as a, type BuildClobAuthMessageInput as a$, type ProviderMeta as a0, type PredictTag as a1, type SettlementSource as a2, type MarketStatus as a3, type MarketResult as a4, type MarketOutcome as a5, type OrderbookLevel as a6, type TradeType as a7, type EventSummary as a8, type MarketSummary as a9, type WsSubscribedMessage as aA, type WsErrorCode as aB, type WsErrorMessage as aC, eventQueryKey as aD, fetchEvent as aE, resolveTagSlug as aF, resolveEventsParams as aG, infiniteEventsQueryKey as aH, fetchEventsPage as aI, type ResolveEventsParamsInput as aJ, type TagSlugSelection as aK, marketQueryKey as aL, fetchMarket as aM, matchesQueryKey as aN, matchQueryKey as aO, fetchMatchesPage as aP, matchMarketsQueryKey as aQ, fetchMatchMarketsPage as aR, CLOB_AUTH_DOMAIN as aS, CLOB_AUTH_TYPES as aT, buildClobAuthMessage as aU, hmacSha256Base64 as aV, buildPolymarketL2Headers as aW, derivePolymarketApiKey as aX, type HttpMethod as aY, type PolymarketL2HeadersInput as aZ, type PolymarketL2Headers as a_, type PricePoint as aa, type PredictPosition as ab, type OrderStatus as ac, type OrderSide as ad, type DFlowOrderContext as ae, type PolymarketOrderType as af, type DepositBuildRequest as ag, type DepositBuildResponse as ah, type DepositSubmitRequest as ai, type DepositSubmitResponse as aj, type DepositStatusResponse as ak, type UnsignedTx as al, type MatchStatus as am, type MatchGroupEntry as an, type MatchGroupMarket as ao, type MatchSortField as ap, type MatchesStats as aq, type MatchConfidenceTier as ar, type MatchMarketFlat as as, type WsChannel as at, type WsChannelEvent as au, type WsClientMessage as av, type WsSubscribeMessage as aw, type WsPingMessage as ax, type WsServerMessage as ay, type WsPongMessage as az, type PredictPage as b, CTF_EXCHANGE_ADDRESS as b0, NEG_RISK_CTF_EXCHANGE_ADDRESS as b1, USDC_ADDRESS as b2, POLYGON_CHAIN_ID as b3, buildCtfExchangeDomain as b4, CTF_ORDER_TYPES as b5, ORDER_TYPE as b6, SIDE as b7, buildOrderMessage as b8, buildSignedOrder as b9, buildClobPayload as ba, type ClobOrderPayload as bb, type BuildOrderMessageInput as bc, type OrderMessage as bd, type SignedOrder as be, DEFAULT_PAGE_SIZE as bf, type PredictEvent as c, type ProviderSource as d, type EventStatus as e, type EventSortField as f, type PredictMarket as g, type ListMarketTradesParams as h, type PredictTrade as i, type PriceHistoryRange as j, type PriceHistoryResponse as k, type ListCandlesticksParams as l, type PositionsResponse as m, type ListOrdersParams as n, type PredictOrder as o, type CancelOrderResult as p, type MatchGroupPage as q, type MatchGroup as r, type MatchMarketParams as s, type MatchMarketPage as t, type ListTradesParams as u, type DFlowQuoteResponse as v, type DFlowSubmitResponse as w, type DFlowSubmitRequest as x, type DFlowKYCStatus as y, type PolymarketSetupStatus as z };
|
|
@@ -142,6 +142,11 @@ interface ListEventsParams {
|
|
|
142
142
|
* (i.e. the event closes within the specified window).
|
|
143
143
|
*/
|
|
144
144
|
end_before?: string;
|
|
145
|
+
/**
|
|
146
|
+
* Max number of markets per event (sorted by volume DESC).
|
|
147
|
+
* `0` means no limit. Defaults to `3` when set via `resolveEventsParams`.
|
|
148
|
+
*/
|
|
149
|
+
markets_limit?: number;
|
|
145
150
|
}
|
|
146
151
|
/** Single price level in an order book. */
|
|
147
152
|
interface OrderbookLevel {
|
|
@@ -685,6 +690,16 @@ interface EventStats {
|
|
|
685
690
|
avg_liquidity: number;
|
|
686
691
|
active_sources: number;
|
|
687
692
|
}
|
|
693
|
+
/** Response from the available-shares endpoint. */
|
|
694
|
+
interface AvailableSharesResponse {
|
|
695
|
+
source: ProviderSource;
|
|
696
|
+
market: string;
|
|
697
|
+
side: string;
|
|
698
|
+
total_shares: number;
|
|
699
|
+
active_order_shares: number;
|
|
700
|
+
available_shares: number;
|
|
701
|
+
precision: number;
|
|
702
|
+
}
|
|
688
703
|
|
|
689
704
|
/**
|
|
690
705
|
* HTTP client for the prediction-server REST API.
|
|
@@ -765,6 +780,18 @@ declare class PredictClient {
|
|
|
765
780
|
kalshi_user?: string;
|
|
766
781
|
polymarket_user?: string;
|
|
767
782
|
}, source?: ProviderSource): Promise<PositionsResponse>;
|
|
783
|
+
/**
|
|
784
|
+
* Get the number of shares available for selling, accounting for active orders.
|
|
785
|
+
*
|
|
786
|
+
* Maps to `GET /api/v1/available-shares?source=...&user=...&market=...&side=...`.
|
|
787
|
+
*
|
|
788
|
+
* @param source - Provider source.
|
|
789
|
+
* @param user - Wallet address.
|
|
790
|
+
* @param market - Market slug.
|
|
791
|
+
* @param side - Position side ("yes" or "no").
|
|
792
|
+
* @param headers - Optional extra headers (e.g. Polymarket POLY_* HMAC headers).
|
|
793
|
+
*/
|
|
794
|
+
getAvailableShares(source: ProviderSource, user: string, market: string, side: string, headers?: Record<string, string>): Promise<AvailableSharesResponse>;
|
|
768
795
|
/**
|
|
769
796
|
* Get the on-chain USDC balance for a wallet.
|
|
770
797
|
*
|
|
@@ -1082,6 +1109,11 @@ interface ResolveEventsParamsInput {
|
|
|
1082
1109
|
* "1d" = events closing within 24 h, "7d" = 7 days, "30d" = 30 days.
|
|
1083
1110
|
*/
|
|
1084
1111
|
timeRemaining?: string;
|
|
1112
|
+
/**
|
|
1113
|
+
* Max number of markets per event (sorted by volume DESC).
|
|
1114
|
+
* Defaults to `3` in `resolveEventsParams`.
|
|
1115
|
+
*/
|
|
1116
|
+
markets_limit?: number;
|
|
1085
1117
|
}
|
|
1086
1118
|
/**
|
|
1087
1119
|
* Build a clean `ListEventsParams` from loose user inputs.
|
|
@@ -1423,4 +1455,4 @@ interface ClobOrderPayload {
|
|
|
1423
1455
|
*/
|
|
1424
1456
|
declare function buildClobPayload(signedOrder: SignedOrder, owner: string): ClobOrderPayload;
|
|
1425
1457
|
|
|
1426
|
-
export { type
|
|
1458
|
+
export { type PredictWsClientConfig as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStats as E, type WithdrawBuildRequest as F, type WithdrawSubmitResponse as G, type WithdrawSubmitRequest as H, type WithdrawStatusResponse as I, type PolymarketDepositAddresses as J, type PolymarketWithdrawResponse as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketWithdrawRequest as N, type Orderbook as O, PredictClient as P, type WsConnectionStatus as Q, type WsDataMessage as R, type SimilarEventsParams as S, type TickSizeResponse as T, type WsPriceEvent as U, type WsOrderbookEvent as V, type WithdrawBuildResponse as W, type WsTradeEvent as X, type CreateOrderInput as Y, createPredictClient as Z, createPredictWsClient as _, PredictWsClient as a, type BuildClobAuthMessageInput as a$, type ProviderMeta as a0, type PredictTag as a1, type SettlementSource as a2, type MarketStatus as a3, type MarketResult as a4, type MarketOutcome as a5, type OrderbookLevel as a6, type TradeType as a7, type EventSummary as a8, type MarketSummary as a9, type WsSubscribedMessage as aA, type WsErrorCode as aB, type WsErrorMessage as aC, eventQueryKey as aD, fetchEvent as aE, resolveTagSlug as aF, resolveEventsParams as aG, infiniteEventsQueryKey as aH, fetchEventsPage as aI, type ResolveEventsParamsInput as aJ, type TagSlugSelection as aK, marketQueryKey as aL, fetchMarket as aM, matchesQueryKey as aN, matchQueryKey as aO, fetchMatchesPage as aP, matchMarketsQueryKey as aQ, fetchMatchMarketsPage as aR, CLOB_AUTH_DOMAIN as aS, CLOB_AUTH_TYPES as aT, buildClobAuthMessage as aU, hmacSha256Base64 as aV, buildPolymarketL2Headers as aW, derivePolymarketApiKey as aX, type HttpMethod as aY, type PolymarketL2HeadersInput as aZ, type PolymarketL2Headers as a_, type PricePoint as aa, type PredictPosition as ab, type OrderStatus as ac, type OrderSide as ad, type DFlowOrderContext as ae, type PolymarketOrderType as af, type DepositBuildRequest as ag, type DepositBuildResponse as ah, type DepositSubmitRequest as ai, type DepositSubmitResponse as aj, type DepositStatusResponse as ak, type UnsignedTx as al, type MatchStatus as am, type MatchGroupEntry as an, type MatchGroupMarket as ao, type MatchSortField as ap, type MatchesStats as aq, type MatchConfidenceTier as ar, type MatchMarketFlat as as, type WsChannel as at, type WsChannelEvent as au, type WsClientMessage as av, type WsSubscribeMessage as aw, type WsPingMessage as ax, type WsServerMessage as ay, type WsPongMessage as az, type PredictPage as b, CTF_EXCHANGE_ADDRESS as b0, NEG_RISK_CTF_EXCHANGE_ADDRESS as b1, USDC_ADDRESS as b2, POLYGON_CHAIN_ID as b3, buildCtfExchangeDomain as b4, CTF_ORDER_TYPES as b5, ORDER_TYPE as b6, SIDE as b7, buildOrderMessage as b8, buildSignedOrder as b9, buildClobPayload as ba, type ClobOrderPayload as bb, type BuildOrderMessageInput as bc, type OrderMessage as bd, type SignedOrder as be, DEFAULT_PAGE_SIZE as bf, type PredictEvent as c, type ProviderSource as d, type EventStatus as e, type EventSortField as f, type PredictMarket as g, type ListMarketTradesParams as h, type PredictTrade as i, type PriceHistoryRange as j, type PriceHistoryResponse as k, type ListCandlesticksParams as l, type PositionsResponse as m, type ListOrdersParams as n, type PredictOrder as o, type CancelOrderResult as p, type MatchGroupPage as q, type MatchGroup as r, type MatchMarketParams as s, type MatchMarketPage as t, type ListTradesParams as u, type DFlowQuoteResponse as v, type DFlowSubmitResponse as w, type DFlowSubmitRequest as x, type DFlowKYCStatus as y, type PolymarketSetupStatus as z };
|
package/dist/server.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BalanceResponse,
|
|
1
|
+
export { B as BalanceResponse, a$ as BuildClobAuthMessageInput, bc as BuildOrderMessageInput, aS as CLOB_AUTH_DOMAIN, aT as CLOB_AUTH_TYPES, b0 as CTF_EXCHANGE_ADDRESS, b5 as CTF_ORDER_TYPES, p as CancelOrderResult, C as Candlestick, bb as ClobOrderPayload, Y as CreateOrderInput, bf as DEFAULT_PAGE_SIZE, ae as DFlowOrderContext, D as DFlowQuoteRequest, v as DFlowQuoteResponse, x as DFlowSubmitRequest, w as DFlowSubmitResponse, ag as DepositBuildRequest, ah as DepositBuildResponse, ak as DepositStatusResponse, ai as DepositSubmitRequest, aj as DepositSubmitResponse, f as EventSortField, e as EventStatus, a8 as EventSummary, aY as HttpMethod, l as ListCandlesticksParams, L as ListEventsParams, h as ListMarketTradesParams, n as ListOrdersParams, u as ListTradesParams, a5 as MarketOutcome, a4 as MarketResult, a3 as MarketStatus, a9 as MarketSummary, ar as MatchConfidenceTier, r as MatchGroup, an as MatchGroupEntry, ao as MatchGroupMarket, q as MatchGroupPage, as as MatchMarketFlat, t as MatchMarketPage, s as MatchMarketParams, ap as MatchSortField, am as MatchStatus, M as MatchesParams, aq as MatchesStats, b1 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b6 as ORDER_TYPE, bd as OrderMessage, ad as OrderSide, ac as OrderStatus, O as Orderbook, a6 as OrderbookLevel, b3 as POLYGON_CHAIN_ID, a_ as PolymarketL2Headers, aZ as PolymarketL2HeadersInput, af as PolymarketOrderType, m as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, o as PredictOrder, b as PredictPage, ab as PredictPosition, a1 as PredictTag, i as PredictTrade, a as PredictWsClient, $ as PredictWsClientConfig, j as PriceHistoryRange, k as PriceHistoryResponse, aa as PricePoint, a0 as ProviderMeta, d as ProviderSource, aJ as ResolveEventsParamsInput, b7 as SIDE, a2 as SettlementSource, be as SignedOrder, S as SimilarEventsParams, aK as TagSlugSelection, a7 as TradeType, b2 as USDC_ADDRESS, al as UnsignedTx, at as WsChannel, au as WsChannelEvent, av as WsClientMessage, Q as WsConnectionStatus, R as WsDataMessage, aB as WsErrorCode, aC as WsErrorMessage, V as WsOrderbookEvent, ax as WsPingMessage, az as WsPongMessage, U as WsPriceEvent, ay as WsServerMessage, aw as WsSubscribeMessage, aA as WsSubscribedMessage, X as WsTradeEvent, aU as buildClobAuthMessage, ba as buildClobPayload, b4 as buildCtfExchangeDomain, b8 as buildOrderMessage, aW as buildPolymarketL2Headers, b9 as buildSignedOrder, Z as createPredictClient, _ as createPredictWsClient, aX as derivePolymarketApiKey, aD as eventQueryKey, aE as fetchEvent, aI as fetchEventsPage, aM as fetchMarket, aR as fetchMatchMarketsPage, aP as fetchMatchesPage, aV as hmacSha256Base64, aH as infiniteEventsQueryKey, aL as marketQueryKey, aQ as matchMarketsQueryKey, aO as matchQueryKey, aN as matchesQueryKey, aG as resolveEventsParams, aF as resolveTagSlug } from './server-CaB0XJAa.mjs';
|
package/dist/server.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BalanceResponse,
|
|
1
|
+
export { B as BalanceResponse, a$ as BuildClobAuthMessageInput, bc as BuildOrderMessageInput, aS as CLOB_AUTH_DOMAIN, aT as CLOB_AUTH_TYPES, b0 as CTF_EXCHANGE_ADDRESS, b5 as CTF_ORDER_TYPES, p as CancelOrderResult, C as Candlestick, bb as ClobOrderPayload, Y as CreateOrderInput, bf as DEFAULT_PAGE_SIZE, ae as DFlowOrderContext, D as DFlowQuoteRequest, v as DFlowQuoteResponse, x as DFlowSubmitRequest, w as DFlowSubmitResponse, ag as DepositBuildRequest, ah as DepositBuildResponse, ak as DepositStatusResponse, ai as DepositSubmitRequest, aj as DepositSubmitResponse, f as EventSortField, e as EventStatus, a8 as EventSummary, aY as HttpMethod, l as ListCandlesticksParams, L as ListEventsParams, h as ListMarketTradesParams, n as ListOrdersParams, u as ListTradesParams, a5 as MarketOutcome, a4 as MarketResult, a3 as MarketStatus, a9 as MarketSummary, ar as MatchConfidenceTier, r as MatchGroup, an as MatchGroupEntry, ao as MatchGroupMarket, q as MatchGroupPage, as as MatchMarketFlat, t as MatchMarketPage, s as MatchMarketParams, ap as MatchSortField, am as MatchStatus, M as MatchesParams, aq as MatchesStats, b1 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b6 as ORDER_TYPE, bd as OrderMessage, ad as OrderSide, ac as OrderStatus, O as Orderbook, a6 as OrderbookLevel, b3 as POLYGON_CHAIN_ID, a_ as PolymarketL2Headers, aZ as PolymarketL2HeadersInput, af as PolymarketOrderType, m as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, o as PredictOrder, b as PredictPage, ab as PredictPosition, a1 as PredictTag, i as PredictTrade, a as PredictWsClient, $ as PredictWsClientConfig, j as PriceHistoryRange, k as PriceHistoryResponse, aa as PricePoint, a0 as ProviderMeta, d as ProviderSource, aJ as ResolveEventsParamsInput, b7 as SIDE, a2 as SettlementSource, be as SignedOrder, S as SimilarEventsParams, aK as TagSlugSelection, a7 as TradeType, b2 as USDC_ADDRESS, al as UnsignedTx, at as WsChannel, au as WsChannelEvent, av as WsClientMessage, Q as WsConnectionStatus, R as WsDataMessage, aB as WsErrorCode, aC as WsErrorMessage, V as WsOrderbookEvent, ax as WsPingMessage, az as WsPongMessage, U as WsPriceEvent, ay as WsServerMessage, aw as WsSubscribeMessage, aA as WsSubscribedMessage, X as WsTradeEvent, aU as buildClobAuthMessage, ba as buildClobPayload, b4 as buildCtfExchangeDomain, b8 as buildOrderMessage, aW as buildPolymarketL2Headers, b9 as buildSignedOrder, Z as createPredictClient, _ as createPredictWsClient, aX as derivePolymarketApiKey, aD as eventQueryKey, aE as fetchEvent, aI as fetchEventsPage, aM as fetchMarket, aR as fetchMatchMarketsPage, aP as fetchMatchesPage, aV as hmacSha256Base64, aH as infiniteEventsQueryKey, aL as marketQueryKey, aQ as matchMarketsQueryKey, aO as matchQueryKey, aN as matchesQueryKey, aG as resolveEventsParams, aF as resolveTagSlug } from './server-CaB0XJAa.js';
|
package/dist/server.js
CHANGED
|
@@ -24,7 +24,8 @@ function resolveEventsParams(input = {}) {
|
|
|
24
24
|
sort_asc,
|
|
25
25
|
minVolume,
|
|
26
26
|
minLiquidity,
|
|
27
|
-
timeRemaining
|
|
27
|
+
timeRemaining,
|
|
28
|
+
markets_limit = 3
|
|
28
29
|
} = input;
|
|
29
30
|
const tag_slug = resolveTagSlug(tagSlugSelection);
|
|
30
31
|
const min_volume = minVolume !== void 0 && minVolume !== "" ? Number(minVolume) : void 0;
|
|
@@ -40,7 +41,8 @@ function resolveEventsParams(input = {}) {
|
|
|
40
41
|
...sort_asc !== void 0 ? { sort_asc } : {},
|
|
41
42
|
...min_volume !== void 0 && !isNaN(min_volume) ? { min_volume } : {},
|
|
42
43
|
...min_liquidity !== void 0 && !isNaN(min_liquidity) ? { min_liquidity } : {},
|
|
43
|
-
...end_before ? { end_before } : {}
|
|
44
|
+
...end_before ? { end_before } : {},
|
|
45
|
+
...markets_limit ? { markets_limit } : {}
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
48
|
function infiniteEventsQueryKey(params) {
|
|
@@ -210,6 +212,28 @@ var PredictClient = class {
|
|
|
210
212
|
return await utils.httpGet(url);
|
|
211
213
|
}
|
|
212
214
|
// -------------------------------------------------------------------------
|
|
215
|
+
// Available shares (for sell flow)
|
|
216
|
+
// -------------------------------------------------------------------------
|
|
217
|
+
/**
|
|
218
|
+
* Get the number of shares available for selling, accounting for active orders.
|
|
219
|
+
*
|
|
220
|
+
* Maps to `GET /api/v1/available-shares?source=...&user=...&market=...&side=...`.
|
|
221
|
+
*
|
|
222
|
+
* @param source - Provider source.
|
|
223
|
+
* @param user - Wallet address.
|
|
224
|
+
* @param market - Market slug.
|
|
225
|
+
* @param side - Position side ("yes" or "no").
|
|
226
|
+
* @param headers - Optional extra headers (e.g. Polymarket POLY_* HMAC headers).
|
|
227
|
+
*/
|
|
228
|
+
async getAvailableShares(source, user, market, side, headers) {
|
|
229
|
+
const query = buildQuery({ source, user, market, side });
|
|
230
|
+
const url = `${this.endpoint}/api/v1/available-shares${query}`;
|
|
231
|
+
return await utils.httpGet(
|
|
232
|
+
url,
|
|
233
|
+
headers ? { headers } : void 0
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
// -------------------------------------------------------------------------
|
|
213
237
|
// Balance
|
|
214
238
|
// -------------------------------------------------------------------------
|
|
215
239
|
/**
|
|
@@ -945,17 +969,13 @@ var DEFAULT_ROUNDING = { size: 2, price: 2, amount: 4 };
|
|
|
945
969
|
function decimalPlaces(n, d) {
|
|
946
970
|
return parseFloat(n.toFixed(d));
|
|
947
971
|
}
|
|
972
|
+
function floorDecimalPlaces(n, d) {
|
|
973
|
+
const factor = 10 ** d;
|
|
974
|
+
return Math.floor(n * factor) / factor;
|
|
975
|
+
}
|
|
948
976
|
function toMicroUsdc(amount) {
|
|
949
977
|
return BigInt(Math.round(amount * 1e6));
|
|
950
978
|
}
|
|
951
|
-
function ceilMicro(raw, maxDecimals) {
|
|
952
|
-
const factor = BigInt(10 ** (6 - maxDecimals));
|
|
953
|
-
return (raw + factor - 1n) / factor * factor;
|
|
954
|
-
}
|
|
955
|
-
function floorMicro(raw, maxDecimals) {
|
|
956
|
-
const factor = BigInt(10 ** (6 - maxDecimals));
|
|
957
|
-
return raw / factor * factor;
|
|
958
|
-
}
|
|
959
979
|
function normalizeTokenId(tokenId) {
|
|
960
980
|
if (tokenId.startsWith("0x") || tokenId.startsWith("0X")) {
|
|
961
981
|
return BigInt(tokenId).toString(10);
|
|
@@ -966,14 +986,12 @@ function buildOrderMessage(input) {
|
|
|
966
986
|
const side = input.side === "BUY" ? SIDE.BUY : SIDE.SELL;
|
|
967
987
|
const rc = ROUNDING_CONFIG[input.tickSize] ?? DEFAULT_ROUNDING;
|
|
968
988
|
const rawPrice = decimalPlaces(input.price, rc.price);
|
|
969
|
-
const rawSize = decimalPlaces(input.size, rc.size);
|
|
970
|
-
const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
|
|
989
|
+
const rawSize = side === SIDE.SELL ? floorDecimalPlaces(input.size, rc.size) : decimalPlaces(input.size, rc.size);
|
|
971
990
|
const sizeInMicro = toMicroUsdc(rawSize);
|
|
991
|
+
const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
|
|
972
992
|
const amountInMicro = toMicroUsdc(rawAmount);
|
|
973
|
-
const
|
|
974
|
-
const
|
|
975
|
-
const makerAmount = side === SIDE.BUY ? usdcMicro.toString() : sharesMicro.toString();
|
|
976
|
-
const takerAmount = side === SIDE.BUY ? sharesMicro.toString() : usdcMicro.toString();
|
|
993
|
+
const makerAmount = side === SIDE.BUY ? amountInMicro.toString() : sizeInMicro.toString();
|
|
994
|
+
const takerAmount = side === SIDE.BUY ? sizeInMicro.toString() : amountInMicro.toString();
|
|
977
995
|
const maker = input.funderAddress ?? input.signerAddress;
|
|
978
996
|
return {
|
|
979
997
|
salt: Math.floor(Math.random() * 1e15).toString(),
|