@liberfi.io/react-predict 0.1.36 → 0.1.38

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.
@@ -674,6 +674,10 @@ interface WsDataMessage<T extends WsChannelEvent = WsChannelEvent> {
674
674
  }
675
675
  /** Union of all messages the server can send. */
676
676
  type WsServerMessage = WsPongMessage | WsSubscribedMessage | WsErrorMessage | WsDataMessage;
677
+ /** Response from the Polymarket tick-size endpoint. */
678
+ interface TickSizeResponse {
679
+ minimum_tick_size: number;
680
+ }
677
681
 
678
682
  /**
679
683
  * HTTP client for the prediction-server REST API.
@@ -795,6 +799,8 @@ declare class PredictClient {
795
799
  * @param headers - Polymarket CLOB auth headers (`POLY_*`).
796
800
  */
797
801
  createPolymarketOrder(input: CreateOrderInput, headers: Record<string, string>): Promise<PredictOrder>;
802
+ /** Maps to `GET /api/v1/polymarket/tick-size?token_id=xxx`. */
803
+ getPolymarketTickSize(tokenId: string): Promise<TickSizeResponse>;
798
804
  /** Maps to `POST /api/v1/orders/kalshi/quote`. */
799
805
  createDFlowQuote(body: DFlowQuoteRequest): Promise<DFlowQuoteResponse>;
800
806
  /** Maps to `POST /api/v1/orders/kalshi/submit`. */
@@ -1346,6 +1352,12 @@ interface OrderMessage {
1346
1352
  * For a SELL order:
1347
1353
  * - `makerAmount` = shares sold (= size)
1348
1354
  * - `takerAmount` = USDC received (cost = size × price)
1355
+ *
1356
+ * Amount rounding follows the official Polymarket CLOB client to guarantee
1357
+ * that `makerAmount / takerAmount` produces a tick-aligned price.
1358
+ * The key invariant: `amountDecimals = sizeDecimals + priceDecimals`, so
1359
+ * `round(size × price, amountDecimals) / round(size, sizeDecimals)` has
1360
+ * exactly `priceDecimals` decimal places.
1349
1361
  */
1350
1362
  declare function buildOrderMessage(input: BuildOrderMessageInput): OrderMessage;
1351
1363
  interface SignedOrder extends OrderMessage {
@@ -1398,4 +1410,4 @@ interface ClobOrderPayload {
1398
1410
  */
1399
1411
  declare function buildClobPayload(signedOrder: SignedOrder, owner: string): ClobOrderPayload;
1400
1412
 
1401
- export { type SettlementSource as $, type WithdrawSubmitResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStatus as E, type WithdrawSubmitRequest as F, type WithdrawStatusResponse as G, type PolymarketDepositAddresses as H, type PolymarketWithdrawResponse as I, type PolymarketWithdrawRequest as J, type WsConnectionStatus as K, type ListEventsParams as L, type MatchesParams as M, type WsDataMessage as N, type Orderbook as O, PredictClient as P, type WsPriceEvent as Q, type WsOrderbookEvent as R, type SimilarEventsParams as S, type WsTradeEvent as T, type CreateOrderInput as U, createPredictClient as V, type WithdrawBuildResponse as W, createPredictWsClient as X, type PredictWsClientConfig as Y, type ProviderMeta as Z, type PredictTag as _, PredictWsClient as a, USDC_ADDRESS as a$, type MarketStatus as a0, type MarketResult as a1, type MarketOutcome as a2, type OrderbookLevel as a3, type TradeType as a4, type EventSummary as a5, type MarketSummary as a6, type PricePoint as a7, type PredictPosition as a8, type OrderStatus as a9, eventQueryKey as aA, fetchEvent as aB, resolveTagSlug as aC, resolveEventsParams as aD, infiniteEventsQueryKey as aE, fetchEventsPage as aF, type ResolveEventsParamsInput as aG, type TagSlugSelection as aH, marketQueryKey as aI, fetchMarket as aJ, matchesQueryKey as aK, matchQueryKey as aL, fetchMatchesPage as aM, matchMarketsQueryKey as aN, fetchMatchMarketsPage as aO, CLOB_AUTH_DOMAIN as aP, CLOB_AUTH_TYPES as aQ, buildClobAuthMessage as aR, hmacSha256Base64 as aS, buildPolymarketL2Headers as aT, derivePolymarketApiKey as aU, type HttpMethod as aV, type PolymarketL2HeadersInput as aW, type PolymarketL2Headers as aX, type BuildClobAuthMessageInput as aY, CTF_EXCHANGE_ADDRESS as aZ, NEG_RISK_CTF_EXCHANGE_ADDRESS as a_, type OrderSide as aa, type DFlowOrderContext as ab, type PolymarketOrderType as ac, type DepositBuildRequest as ad, type DepositBuildResponse as ae, type DepositSubmitRequest as af, type DepositSubmitResponse as ag, type DepositStatusResponse as ah, type UnsignedTx as ai, type MatchStatus as aj, type MatchGroupEntry as ak, type MatchGroupMarket as al, type MatchSortField as am, type MatchesStats as an, type MatchConfidenceTier as ao, type MatchMarketFlat as ap, type WsChannel as aq, type WsChannelEvent as ar, type WsClientMessage as as, type WsSubscribeMessage as at, type WsPingMessage as au, type WsServerMessage as av, type WsPongMessage as aw, type WsSubscribedMessage as ax, type WsErrorCode as ay, type WsErrorMessage as az, type PredictPage as b, POLYGON_CHAIN_ID as b0, buildCtfExchangeDomain as b1, CTF_ORDER_TYPES as b2, ORDER_TYPE as b3, SIDE as b4, buildOrderMessage as b5, buildSignedOrder as b6, buildClobPayload as b7, type ClobOrderPayload as b8, type BuildOrderMessageInput as b9, type OrderMessage as ba, type SignedOrder as bb, DEFAULT_PAGE_SIZE as bc, type PredictEvent as c, type ProviderSource as d, type EventSortField as e, type PredictMarket as f, type ListMarketTradesParams as g, type PredictTrade as h, type PriceHistoryRange as i, type PriceHistoryResponse as j, type ListCandlesticksParams as k, type PositionsResponse as l, type ListOrdersParams as m, type PredictOrder as n, type CancelOrderResult as o, type MatchGroupPage as p, type MatchGroup as q, type MatchMarketParams as r, type MatchMarketPage as s, type ListTradesParams as t, type DFlowQuoteResponse as u, type DFlowSubmitResponse as v, type DFlowSubmitRequest as w, type DFlowKYCStatus as x, type PolymarketSetupStatus as y, type WithdrawBuildRequest as z };
1413
+ export { type PredictTag as $, type WithdrawSubmitResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStatus as E, type WithdrawSubmitRequest as F, type WithdrawStatusResponse as G, type PolymarketDepositAddresses as H, type PolymarketWithdrawResponse as I, type PolymarketWithdrawRequest as J, type WsConnectionStatus as K, type ListEventsParams as L, type MatchesParams as M, type WsDataMessage as N, type Orderbook as O, PredictClient as P, type WsPriceEvent as Q, type WsOrderbookEvent as R, type SimilarEventsParams as S, type TickSizeResponse as T, type WsTradeEvent as U, type CreateOrderInput as V, type WithdrawBuildResponse as W, createPredictClient as X, createPredictWsClient as Y, type PredictWsClientConfig as Z, type ProviderMeta as _, PredictWsClient as a, NEG_RISK_CTF_EXCHANGE_ADDRESS as a$, type SettlementSource as a0, type MarketStatus as a1, type MarketResult as a2, type MarketOutcome as a3, type OrderbookLevel as a4, type TradeType as a5, type EventSummary as a6, type MarketSummary as a7, type PricePoint as a8, type PredictPosition as a9, type WsErrorMessage as aA, eventQueryKey as aB, fetchEvent as aC, resolveTagSlug as aD, resolveEventsParams as aE, infiniteEventsQueryKey as aF, fetchEventsPage as aG, type ResolveEventsParamsInput as aH, type TagSlugSelection as aI, marketQueryKey as aJ, fetchMarket as aK, matchesQueryKey as aL, matchQueryKey as aM, fetchMatchesPage as aN, matchMarketsQueryKey as aO, fetchMatchMarketsPage as aP, CLOB_AUTH_DOMAIN as aQ, CLOB_AUTH_TYPES as aR, buildClobAuthMessage as aS, hmacSha256Base64 as aT, buildPolymarketL2Headers as aU, derivePolymarketApiKey as aV, type HttpMethod as aW, type PolymarketL2HeadersInput as aX, type PolymarketL2Headers as aY, type BuildClobAuthMessageInput as aZ, CTF_EXCHANGE_ADDRESS as a_, type OrderStatus as aa, type OrderSide as ab, type DFlowOrderContext as ac, type PolymarketOrderType as ad, type DepositBuildRequest as ae, type DepositBuildResponse as af, type DepositSubmitRequest as ag, type DepositSubmitResponse as ah, type DepositStatusResponse as ai, type UnsignedTx as aj, type MatchStatus as ak, type MatchGroupEntry as al, type MatchGroupMarket as am, type MatchSortField as an, type MatchesStats as ao, type MatchConfidenceTier as ap, type MatchMarketFlat as aq, type WsChannel as ar, type WsChannelEvent as as, type WsClientMessage as at, type WsSubscribeMessage as au, type WsPingMessage as av, type WsServerMessage as aw, type WsPongMessage as ax, type WsSubscribedMessage as ay, type WsErrorCode as az, type PredictPage as b, USDC_ADDRESS as b0, POLYGON_CHAIN_ID as b1, buildCtfExchangeDomain as b2, CTF_ORDER_TYPES as b3, ORDER_TYPE as b4, SIDE as b5, buildOrderMessage as b6, buildSignedOrder as b7, buildClobPayload as b8, type ClobOrderPayload as b9, type BuildOrderMessageInput as ba, type OrderMessage as bb, type SignedOrder as bc, DEFAULT_PAGE_SIZE as bd, type PredictEvent as c, type ProviderSource as d, type EventSortField as e, type PredictMarket as f, type ListMarketTradesParams as g, type PredictTrade as h, type PriceHistoryRange as i, type PriceHistoryResponse as j, type ListCandlesticksParams as k, type PositionsResponse as l, type ListOrdersParams as m, type PredictOrder as n, type CancelOrderResult as o, type MatchGroupPage as p, type MatchGroup as q, type MatchMarketParams as r, type MatchMarketPage as s, type ListTradesParams as t, type DFlowQuoteResponse as u, type DFlowSubmitResponse as v, type DFlowSubmitRequest as w, type DFlowKYCStatus as x, type PolymarketSetupStatus as y, type WithdrawBuildRequest as z };
@@ -674,6 +674,10 @@ interface WsDataMessage<T extends WsChannelEvent = WsChannelEvent> {
674
674
  }
675
675
  /** Union of all messages the server can send. */
676
676
  type WsServerMessage = WsPongMessage | WsSubscribedMessage | WsErrorMessage | WsDataMessage;
677
+ /** Response from the Polymarket tick-size endpoint. */
678
+ interface TickSizeResponse {
679
+ minimum_tick_size: number;
680
+ }
677
681
 
678
682
  /**
679
683
  * HTTP client for the prediction-server REST API.
@@ -795,6 +799,8 @@ declare class PredictClient {
795
799
  * @param headers - Polymarket CLOB auth headers (`POLY_*`).
796
800
  */
797
801
  createPolymarketOrder(input: CreateOrderInput, headers: Record<string, string>): Promise<PredictOrder>;
802
+ /** Maps to `GET /api/v1/polymarket/tick-size?token_id=xxx`. */
803
+ getPolymarketTickSize(tokenId: string): Promise<TickSizeResponse>;
798
804
  /** Maps to `POST /api/v1/orders/kalshi/quote`. */
799
805
  createDFlowQuote(body: DFlowQuoteRequest): Promise<DFlowQuoteResponse>;
800
806
  /** Maps to `POST /api/v1/orders/kalshi/submit`. */
@@ -1346,6 +1352,12 @@ interface OrderMessage {
1346
1352
  * For a SELL order:
1347
1353
  * - `makerAmount` = shares sold (= size)
1348
1354
  * - `takerAmount` = USDC received (cost = size × price)
1355
+ *
1356
+ * Amount rounding follows the official Polymarket CLOB client to guarantee
1357
+ * that `makerAmount / takerAmount` produces a tick-aligned price.
1358
+ * The key invariant: `amountDecimals = sizeDecimals + priceDecimals`, so
1359
+ * `round(size × price, amountDecimals) / round(size, sizeDecimals)` has
1360
+ * exactly `priceDecimals` decimal places.
1349
1361
  */
1350
1362
  declare function buildOrderMessage(input: BuildOrderMessageInput): OrderMessage;
1351
1363
  interface SignedOrder extends OrderMessage {
@@ -1398,4 +1410,4 @@ interface ClobOrderPayload {
1398
1410
  */
1399
1411
  declare function buildClobPayload(signedOrder: SignedOrder, owner: string): ClobOrderPayload;
1400
1412
 
1401
- export { type SettlementSource as $, type WithdrawSubmitResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStatus as E, type WithdrawSubmitRequest as F, type WithdrawStatusResponse as G, type PolymarketDepositAddresses as H, type PolymarketWithdrawResponse as I, type PolymarketWithdrawRequest as J, type WsConnectionStatus as K, type ListEventsParams as L, type MatchesParams as M, type WsDataMessage as N, type Orderbook as O, PredictClient as P, type WsPriceEvent as Q, type WsOrderbookEvent as R, type SimilarEventsParams as S, type WsTradeEvent as T, type CreateOrderInput as U, createPredictClient as V, type WithdrawBuildResponse as W, createPredictWsClient as X, type PredictWsClientConfig as Y, type ProviderMeta as Z, type PredictTag as _, PredictWsClient as a, USDC_ADDRESS as a$, type MarketStatus as a0, type MarketResult as a1, type MarketOutcome as a2, type OrderbookLevel as a3, type TradeType as a4, type EventSummary as a5, type MarketSummary as a6, type PricePoint as a7, type PredictPosition as a8, type OrderStatus as a9, eventQueryKey as aA, fetchEvent as aB, resolveTagSlug as aC, resolveEventsParams as aD, infiniteEventsQueryKey as aE, fetchEventsPage as aF, type ResolveEventsParamsInput as aG, type TagSlugSelection as aH, marketQueryKey as aI, fetchMarket as aJ, matchesQueryKey as aK, matchQueryKey as aL, fetchMatchesPage as aM, matchMarketsQueryKey as aN, fetchMatchMarketsPage as aO, CLOB_AUTH_DOMAIN as aP, CLOB_AUTH_TYPES as aQ, buildClobAuthMessage as aR, hmacSha256Base64 as aS, buildPolymarketL2Headers as aT, derivePolymarketApiKey as aU, type HttpMethod as aV, type PolymarketL2HeadersInput as aW, type PolymarketL2Headers as aX, type BuildClobAuthMessageInput as aY, CTF_EXCHANGE_ADDRESS as aZ, NEG_RISK_CTF_EXCHANGE_ADDRESS as a_, type OrderSide as aa, type DFlowOrderContext as ab, type PolymarketOrderType as ac, type DepositBuildRequest as ad, type DepositBuildResponse as ae, type DepositSubmitRequest as af, type DepositSubmitResponse as ag, type DepositStatusResponse as ah, type UnsignedTx as ai, type MatchStatus as aj, type MatchGroupEntry as ak, type MatchGroupMarket as al, type MatchSortField as am, type MatchesStats as an, type MatchConfidenceTier as ao, type MatchMarketFlat as ap, type WsChannel as aq, type WsChannelEvent as ar, type WsClientMessage as as, type WsSubscribeMessage as at, type WsPingMessage as au, type WsServerMessage as av, type WsPongMessage as aw, type WsSubscribedMessage as ax, type WsErrorCode as ay, type WsErrorMessage as az, type PredictPage as b, POLYGON_CHAIN_ID as b0, buildCtfExchangeDomain as b1, CTF_ORDER_TYPES as b2, ORDER_TYPE as b3, SIDE as b4, buildOrderMessage as b5, buildSignedOrder as b6, buildClobPayload as b7, type ClobOrderPayload as b8, type BuildOrderMessageInput as b9, type OrderMessage as ba, type SignedOrder as bb, DEFAULT_PAGE_SIZE as bc, type PredictEvent as c, type ProviderSource as d, type EventSortField as e, type PredictMarket as f, type ListMarketTradesParams as g, type PredictTrade as h, type PriceHistoryRange as i, type PriceHistoryResponse as j, type ListCandlesticksParams as k, type PositionsResponse as l, type ListOrdersParams as m, type PredictOrder as n, type CancelOrderResult as o, type MatchGroupPage as p, type MatchGroup as q, type MatchMarketParams as r, type MatchMarketPage as s, type ListTradesParams as t, type DFlowQuoteResponse as u, type DFlowSubmitResponse as v, type DFlowSubmitRequest as w, type DFlowKYCStatus as x, type PolymarketSetupStatus as y, type WithdrawBuildRequest as z };
1413
+ export { type PredictTag as $, type WithdrawSubmitResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStatus as E, type WithdrawSubmitRequest as F, type WithdrawStatusResponse as G, type PolymarketDepositAddresses as H, type PolymarketWithdrawResponse as I, type PolymarketWithdrawRequest as J, type WsConnectionStatus as K, type ListEventsParams as L, type MatchesParams as M, type WsDataMessage as N, type Orderbook as O, PredictClient as P, type WsPriceEvent as Q, type WsOrderbookEvent as R, type SimilarEventsParams as S, type TickSizeResponse as T, type WsTradeEvent as U, type CreateOrderInput as V, type WithdrawBuildResponse as W, createPredictClient as X, createPredictWsClient as Y, type PredictWsClientConfig as Z, type ProviderMeta as _, PredictWsClient as a, NEG_RISK_CTF_EXCHANGE_ADDRESS as a$, type SettlementSource as a0, type MarketStatus as a1, type MarketResult as a2, type MarketOutcome as a3, type OrderbookLevel as a4, type TradeType as a5, type EventSummary as a6, type MarketSummary as a7, type PricePoint as a8, type PredictPosition as a9, type WsErrorMessage as aA, eventQueryKey as aB, fetchEvent as aC, resolveTagSlug as aD, resolveEventsParams as aE, infiniteEventsQueryKey as aF, fetchEventsPage as aG, type ResolveEventsParamsInput as aH, type TagSlugSelection as aI, marketQueryKey as aJ, fetchMarket as aK, matchesQueryKey as aL, matchQueryKey as aM, fetchMatchesPage as aN, matchMarketsQueryKey as aO, fetchMatchMarketsPage as aP, CLOB_AUTH_DOMAIN as aQ, CLOB_AUTH_TYPES as aR, buildClobAuthMessage as aS, hmacSha256Base64 as aT, buildPolymarketL2Headers as aU, derivePolymarketApiKey as aV, type HttpMethod as aW, type PolymarketL2HeadersInput as aX, type PolymarketL2Headers as aY, type BuildClobAuthMessageInput as aZ, CTF_EXCHANGE_ADDRESS as a_, type OrderStatus as aa, type OrderSide as ab, type DFlowOrderContext as ac, type PolymarketOrderType as ad, type DepositBuildRequest as ae, type DepositBuildResponse as af, type DepositSubmitRequest as ag, type DepositSubmitResponse as ah, type DepositStatusResponse as ai, type UnsignedTx as aj, type MatchStatus as ak, type MatchGroupEntry as al, type MatchGroupMarket as am, type MatchSortField as an, type MatchesStats as ao, type MatchConfidenceTier as ap, type MatchMarketFlat as aq, type WsChannel as ar, type WsChannelEvent as as, type WsClientMessage as at, type WsSubscribeMessage as au, type WsPingMessage as av, type WsServerMessage as aw, type WsPongMessage as ax, type WsSubscribedMessage as ay, type WsErrorCode as az, type PredictPage as b, USDC_ADDRESS as b0, POLYGON_CHAIN_ID as b1, buildCtfExchangeDomain as b2, CTF_ORDER_TYPES as b3, ORDER_TYPE as b4, SIDE as b5, buildOrderMessage as b6, buildSignedOrder as b7, buildClobPayload as b8, type ClobOrderPayload as b9, type BuildOrderMessageInput as ba, type OrderMessage as bb, type SignedOrder as bc, DEFAULT_PAGE_SIZE as bd, type PredictEvent as c, type ProviderSource as d, type EventSortField as e, type PredictMarket as f, type ListMarketTradesParams as g, type PredictTrade as h, type PriceHistoryRange as i, type PriceHistoryResponse as j, type ListCandlesticksParams as k, type PositionsResponse as l, type ListOrdersParams as m, type PredictOrder as n, type CancelOrderResult as o, type MatchGroupPage as p, type MatchGroup as q, type MatchMarketParams as r, type MatchMarketPage as s, type ListTradesParams as t, type DFlowQuoteResponse as u, type DFlowSubmitResponse as v, type DFlowSubmitRequest as w, type DFlowKYCStatus as x, type PolymarketSetupStatus as y, type WithdrawBuildRequest as z };
package/dist/server.d.mts CHANGED
@@ -1 +1 @@
1
- export { B as BalanceResponse, aY as BuildClobAuthMessageInput, b9 as BuildOrderMessageInput, aP as CLOB_AUTH_DOMAIN, aQ as CLOB_AUTH_TYPES, aZ as CTF_EXCHANGE_ADDRESS, b2 as CTF_ORDER_TYPES, o as CancelOrderResult, C as Candlestick, b8 as ClobOrderPayload, U as CreateOrderInput, bc as DEFAULT_PAGE_SIZE, ab as DFlowOrderContext, D as DFlowQuoteRequest, u as DFlowQuoteResponse, w as DFlowSubmitRequest, v as DFlowSubmitResponse, ad as DepositBuildRequest, ae as DepositBuildResponse, ah as DepositStatusResponse, af as DepositSubmitRequest, ag as DepositSubmitResponse, e as EventSortField, E as EventStatus, a5 as EventSummary, aV as HttpMethod, k as ListCandlesticksParams, L as ListEventsParams, g as ListMarketTradesParams, m as ListOrdersParams, t as ListTradesParams, a2 as MarketOutcome, a1 as MarketResult, a0 as MarketStatus, a6 as MarketSummary, ao as MatchConfidenceTier, q as MatchGroup, ak as MatchGroupEntry, al as MatchGroupMarket, p as MatchGroupPage, ap as MatchMarketFlat, s as MatchMarketPage, r as MatchMarketParams, am as MatchSortField, aj as MatchStatus, M as MatchesParams, an as MatchesStats, a_ as NEG_RISK_CTF_EXCHANGE_ADDRESS, b3 as ORDER_TYPE, ba as OrderMessage, aa as OrderSide, a9 as OrderStatus, O as Orderbook, a3 as OrderbookLevel, b0 as POLYGON_CHAIN_ID, aX as PolymarketL2Headers, aW as PolymarketL2HeadersInput, ac as PolymarketOrderType, l as PositionsResponse, P as PredictClient, c as PredictEvent, f as PredictMarket, n as PredictOrder, b as PredictPage, a8 as PredictPosition, _ as PredictTag, h as PredictTrade, a as PredictWsClient, Y as PredictWsClientConfig, i as PriceHistoryRange, j as PriceHistoryResponse, a7 as PricePoint, Z as ProviderMeta, d as ProviderSource, aG as ResolveEventsParamsInput, b4 as SIDE, $ as SettlementSource, bb as SignedOrder, S as SimilarEventsParams, aH as TagSlugSelection, a4 as TradeType, a$ as USDC_ADDRESS, ai as UnsignedTx, aq as WsChannel, ar as WsChannelEvent, as as WsClientMessage, K as WsConnectionStatus, N as WsDataMessage, ay as WsErrorCode, az as WsErrorMessage, R as WsOrderbookEvent, au as WsPingMessage, aw as WsPongMessage, Q as WsPriceEvent, av as WsServerMessage, at as WsSubscribeMessage, ax as WsSubscribedMessage, T as WsTradeEvent, aR as buildClobAuthMessage, b7 as buildClobPayload, b1 as buildCtfExchangeDomain, b5 as buildOrderMessage, aT as buildPolymarketL2Headers, b6 as buildSignedOrder, V as createPredictClient, X as createPredictWsClient, aU as derivePolymarketApiKey, aA as eventQueryKey, aB as fetchEvent, aF as fetchEventsPage, aJ as fetchMarket, aO as fetchMatchMarketsPage, aM as fetchMatchesPage, aS as hmacSha256Base64, aE as infiniteEventsQueryKey, aI as marketQueryKey, aN as matchMarketsQueryKey, aL as matchQueryKey, aK as matchesQueryKey, aD as resolveEventsParams, aC as resolveTagSlug } from './server-BOEaPGc-.mjs';
1
+ export { B as BalanceResponse, aZ as BuildClobAuthMessageInput, ba as BuildOrderMessageInput, aQ as CLOB_AUTH_DOMAIN, aR as CLOB_AUTH_TYPES, a_ as CTF_EXCHANGE_ADDRESS, b3 as CTF_ORDER_TYPES, o as CancelOrderResult, C as Candlestick, b9 as ClobOrderPayload, V as CreateOrderInput, bd as DEFAULT_PAGE_SIZE, ac as DFlowOrderContext, D as DFlowQuoteRequest, u as DFlowQuoteResponse, w as DFlowSubmitRequest, v as DFlowSubmitResponse, ae as DepositBuildRequest, af as DepositBuildResponse, ai as DepositStatusResponse, ag as DepositSubmitRequest, ah as DepositSubmitResponse, e as EventSortField, E as EventStatus, a6 as EventSummary, aW as HttpMethod, k as ListCandlesticksParams, L as ListEventsParams, g as ListMarketTradesParams, m as ListOrdersParams, t as ListTradesParams, a3 as MarketOutcome, a2 as MarketResult, a1 as MarketStatus, a7 as MarketSummary, ap as MatchConfidenceTier, q as MatchGroup, al as MatchGroupEntry, am as MatchGroupMarket, p as MatchGroupPage, aq as MatchMarketFlat, s as MatchMarketPage, r as MatchMarketParams, an as MatchSortField, ak as MatchStatus, M as MatchesParams, ao as MatchesStats, a$ as NEG_RISK_CTF_EXCHANGE_ADDRESS, b4 as ORDER_TYPE, bb as OrderMessage, ab as OrderSide, aa as OrderStatus, O as Orderbook, a4 as OrderbookLevel, b1 as POLYGON_CHAIN_ID, aY as PolymarketL2Headers, aX as PolymarketL2HeadersInput, ad as PolymarketOrderType, l as PositionsResponse, P as PredictClient, c as PredictEvent, f as PredictMarket, n as PredictOrder, b as PredictPage, a9 as PredictPosition, $ as PredictTag, h as PredictTrade, a as PredictWsClient, Z as PredictWsClientConfig, i as PriceHistoryRange, j as PriceHistoryResponse, a8 as PricePoint, _ as ProviderMeta, d as ProviderSource, aH as ResolveEventsParamsInput, b5 as SIDE, a0 as SettlementSource, bc as SignedOrder, S as SimilarEventsParams, aI as TagSlugSelection, a5 as TradeType, b0 as USDC_ADDRESS, aj as UnsignedTx, ar as WsChannel, as as WsChannelEvent, at as WsClientMessage, K as WsConnectionStatus, N as WsDataMessage, az as WsErrorCode, aA as WsErrorMessage, R as WsOrderbookEvent, av as WsPingMessage, ax as WsPongMessage, Q as WsPriceEvent, aw as WsServerMessage, au as WsSubscribeMessage, ay as WsSubscribedMessage, U as WsTradeEvent, aS as buildClobAuthMessage, b8 as buildClobPayload, b2 as buildCtfExchangeDomain, b6 as buildOrderMessage, aU as buildPolymarketL2Headers, b7 as buildSignedOrder, X as createPredictClient, Y as createPredictWsClient, aV as derivePolymarketApiKey, aB as eventQueryKey, aC as fetchEvent, aG as fetchEventsPage, aK as fetchMarket, aP as fetchMatchMarketsPage, aN as fetchMatchesPage, aT as hmacSha256Base64, aF as infiniteEventsQueryKey, aJ as marketQueryKey, aO as matchMarketsQueryKey, aM as matchQueryKey, aL as matchesQueryKey, aE as resolveEventsParams, aD as resolveTagSlug } from './server-CYqs2N2z.mjs';
package/dist/server.d.ts CHANGED
@@ -1 +1 @@
1
- export { B as BalanceResponse, aY as BuildClobAuthMessageInput, b9 as BuildOrderMessageInput, aP as CLOB_AUTH_DOMAIN, aQ as CLOB_AUTH_TYPES, aZ as CTF_EXCHANGE_ADDRESS, b2 as CTF_ORDER_TYPES, o as CancelOrderResult, C as Candlestick, b8 as ClobOrderPayload, U as CreateOrderInput, bc as DEFAULT_PAGE_SIZE, ab as DFlowOrderContext, D as DFlowQuoteRequest, u as DFlowQuoteResponse, w as DFlowSubmitRequest, v as DFlowSubmitResponse, ad as DepositBuildRequest, ae as DepositBuildResponse, ah as DepositStatusResponse, af as DepositSubmitRequest, ag as DepositSubmitResponse, e as EventSortField, E as EventStatus, a5 as EventSummary, aV as HttpMethod, k as ListCandlesticksParams, L as ListEventsParams, g as ListMarketTradesParams, m as ListOrdersParams, t as ListTradesParams, a2 as MarketOutcome, a1 as MarketResult, a0 as MarketStatus, a6 as MarketSummary, ao as MatchConfidenceTier, q as MatchGroup, ak as MatchGroupEntry, al as MatchGroupMarket, p as MatchGroupPage, ap as MatchMarketFlat, s as MatchMarketPage, r as MatchMarketParams, am as MatchSortField, aj as MatchStatus, M as MatchesParams, an as MatchesStats, a_ as NEG_RISK_CTF_EXCHANGE_ADDRESS, b3 as ORDER_TYPE, ba as OrderMessage, aa as OrderSide, a9 as OrderStatus, O as Orderbook, a3 as OrderbookLevel, b0 as POLYGON_CHAIN_ID, aX as PolymarketL2Headers, aW as PolymarketL2HeadersInput, ac as PolymarketOrderType, l as PositionsResponse, P as PredictClient, c as PredictEvent, f as PredictMarket, n as PredictOrder, b as PredictPage, a8 as PredictPosition, _ as PredictTag, h as PredictTrade, a as PredictWsClient, Y as PredictWsClientConfig, i as PriceHistoryRange, j as PriceHistoryResponse, a7 as PricePoint, Z as ProviderMeta, d as ProviderSource, aG as ResolveEventsParamsInput, b4 as SIDE, $ as SettlementSource, bb as SignedOrder, S as SimilarEventsParams, aH as TagSlugSelection, a4 as TradeType, a$ as USDC_ADDRESS, ai as UnsignedTx, aq as WsChannel, ar as WsChannelEvent, as as WsClientMessage, K as WsConnectionStatus, N as WsDataMessage, ay as WsErrorCode, az as WsErrorMessage, R as WsOrderbookEvent, au as WsPingMessage, aw as WsPongMessage, Q as WsPriceEvent, av as WsServerMessage, at as WsSubscribeMessage, ax as WsSubscribedMessage, T as WsTradeEvent, aR as buildClobAuthMessage, b7 as buildClobPayload, b1 as buildCtfExchangeDomain, b5 as buildOrderMessage, aT as buildPolymarketL2Headers, b6 as buildSignedOrder, V as createPredictClient, X as createPredictWsClient, aU as derivePolymarketApiKey, aA as eventQueryKey, aB as fetchEvent, aF as fetchEventsPage, aJ as fetchMarket, aO as fetchMatchMarketsPage, aM as fetchMatchesPage, aS as hmacSha256Base64, aE as infiniteEventsQueryKey, aI as marketQueryKey, aN as matchMarketsQueryKey, aL as matchQueryKey, aK as matchesQueryKey, aD as resolveEventsParams, aC as resolveTagSlug } from './server-BOEaPGc-.js';
1
+ export { B as BalanceResponse, aZ as BuildClobAuthMessageInput, ba as BuildOrderMessageInput, aQ as CLOB_AUTH_DOMAIN, aR as CLOB_AUTH_TYPES, a_ as CTF_EXCHANGE_ADDRESS, b3 as CTF_ORDER_TYPES, o as CancelOrderResult, C as Candlestick, b9 as ClobOrderPayload, V as CreateOrderInput, bd as DEFAULT_PAGE_SIZE, ac as DFlowOrderContext, D as DFlowQuoteRequest, u as DFlowQuoteResponse, w as DFlowSubmitRequest, v as DFlowSubmitResponse, ae as DepositBuildRequest, af as DepositBuildResponse, ai as DepositStatusResponse, ag as DepositSubmitRequest, ah as DepositSubmitResponse, e as EventSortField, E as EventStatus, a6 as EventSummary, aW as HttpMethod, k as ListCandlesticksParams, L as ListEventsParams, g as ListMarketTradesParams, m as ListOrdersParams, t as ListTradesParams, a3 as MarketOutcome, a2 as MarketResult, a1 as MarketStatus, a7 as MarketSummary, ap as MatchConfidenceTier, q as MatchGroup, al as MatchGroupEntry, am as MatchGroupMarket, p as MatchGroupPage, aq as MatchMarketFlat, s as MatchMarketPage, r as MatchMarketParams, an as MatchSortField, ak as MatchStatus, M as MatchesParams, ao as MatchesStats, a$ as NEG_RISK_CTF_EXCHANGE_ADDRESS, b4 as ORDER_TYPE, bb as OrderMessage, ab as OrderSide, aa as OrderStatus, O as Orderbook, a4 as OrderbookLevel, b1 as POLYGON_CHAIN_ID, aY as PolymarketL2Headers, aX as PolymarketL2HeadersInput, ad as PolymarketOrderType, l as PositionsResponse, P as PredictClient, c as PredictEvent, f as PredictMarket, n as PredictOrder, b as PredictPage, a9 as PredictPosition, $ as PredictTag, h as PredictTrade, a as PredictWsClient, Z as PredictWsClientConfig, i as PriceHistoryRange, j as PriceHistoryResponse, a8 as PricePoint, _ as ProviderMeta, d as ProviderSource, aH as ResolveEventsParamsInput, b5 as SIDE, a0 as SettlementSource, bc as SignedOrder, S as SimilarEventsParams, aI as TagSlugSelection, a5 as TradeType, b0 as USDC_ADDRESS, aj as UnsignedTx, ar as WsChannel, as as WsChannelEvent, at as WsClientMessage, K as WsConnectionStatus, N as WsDataMessage, az as WsErrorCode, aA as WsErrorMessage, R as WsOrderbookEvent, av as WsPingMessage, ax as WsPongMessage, Q as WsPriceEvent, aw as WsServerMessage, au as WsSubscribeMessage, ay as WsSubscribedMessage, U as WsTradeEvent, aS as buildClobAuthMessage, b8 as buildClobPayload, b2 as buildCtfExchangeDomain, b6 as buildOrderMessage, aU as buildPolymarketL2Headers, b7 as buildSignedOrder, X as createPredictClient, Y as createPredictWsClient, aV as derivePolymarketApiKey, aB as eventQueryKey, aC as fetchEvent, aG as fetchEventsPage, aK as fetchMarket, aP as fetchMatchMarketsPage, aN as fetchMatchesPage, aT as hmacSha256Base64, aF as infiniteEventsQueryKey, aJ as marketQueryKey, aO as matchMarketsQueryKey, aM as matchQueryKey, aL as matchesQueryKey, aE as resolveEventsParams, aD as resolveTagSlug } from './server-CYqs2N2z.js';
package/dist/server.js CHANGED
@@ -281,6 +281,11 @@ var PredictClient = class {
281
281
  const url = `${this.endpoint}/api/v1/orders/polymarket`;
282
282
  return await utils.httpPost(url, input, { headers });
283
283
  }
284
+ /** Maps to `GET /api/v1/polymarket/tick-size?token_id=xxx`. */
285
+ async getPolymarketTickSize(tokenId) {
286
+ const url = `${this.endpoint}/api/v1/polymarket/tick-size?token_id=${encodeURIComponent(tokenId)}`;
287
+ return await utils.httpGet(url);
288
+ }
284
289
  // -------------------------------------------------------------------------
285
290
  // DFlow trading
286
291
  // -------------------------------------------------------------------------
@@ -921,15 +926,15 @@ var ORDER_TYPE = {
921
926
  // Fill-And-Kill
922
927
  };
923
928
  var SIDE = { BUY: 0, SELL: 1 };
924
- var TICK_DECIMALS = {
925
- "0.1": 1,
926
- "0.01": 2,
927
- "0.001": 3,
928
- "0.0001": 4
929
+ var ROUNDING_CONFIG = {
930
+ "0.1": { size: 2, price: 1, amount: 3 },
931
+ "0.01": { size: 2, price: 2, amount: 4 },
932
+ "0.001": { size: 3, price: 3, amount: 6 },
933
+ "0.0001": { size: 4, price: 4, amount: 8 }
929
934
  };
930
- function roundToTick(price, tickSize) {
931
- const decimals = TICK_DECIMALS[tickSize] ?? 2;
932
- return price.toFixed(decimals);
935
+ var DEFAULT_ROUNDING = { size: 2, price: 2, amount: 4 };
936
+ function decimalPlaces(n, d) {
937
+ return parseFloat(n.toFixed(d));
933
938
  }
934
939
  function toMicroUsdc(amount) {
935
940
  return BigInt(Math.round(amount * 1e6));
@@ -942,12 +947,14 @@ function normalizeTokenId(tokenId) {
942
947
  }
943
948
  function buildOrderMessage(input) {
944
949
  const side = input.side === "BUY" ? SIDE.BUY : SIDE.SELL;
945
- const priceStr = roundToTick(input.price, input.tickSize);
946
- const priceNum = parseFloat(priceStr);
947
- const sizeShares = toMicroUsdc(input.size);
948
- const sizeUsdc = toMicroUsdc(input.size * priceNum);
949
- const makerAmount = side === SIDE.BUY ? sizeUsdc.toString() : sizeShares.toString();
950
- const takerAmount = side === SIDE.BUY ? sizeShares.toString() : sizeUsdc.toString();
950
+ const rc = ROUNDING_CONFIG[input.tickSize] ?? DEFAULT_ROUNDING;
951
+ const rawPrice = decimalPlaces(input.price, rc.price);
952
+ const rawSize = decimalPlaces(input.size, rc.size);
953
+ const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
954
+ const sizeInMicro = toMicroUsdc(rawSize);
955
+ const amountInMicro = toMicroUsdc(rawAmount);
956
+ const makerAmount = side === SIDE.BUY ? amountInMicro.toString() : sizeInMicro.toString();
957
+ const takerAmount = side === SIDE.BUY ? sizeInMicro.toString() : amountInMicro.toString();
951
958
  const maker = input.funderAddress ?? input.signerAddress;
952
959
  return {
953
960
  salt: Math.floor(Math.random() * 1e15).toString(),