@liberfi.io/react-predict 0.1.51 → 0.1.53

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.
@@ -217,6 +217,19 @@ interface ListTradesParams {
217
217
  type?: string;
218
218
  side?: string;
219
219
  }
220
+ /**
221
+ * Query parameters for `GET /api/v1/trades` in multi-wallet mode.
222
+ * Each provider uses its own wallet address (e.g. Solana for Kalshi, EVM for Polymarket).
223
+ */
224
+ interface ListTradesMultiParams {
225
+ kalshi_user?: string;
226
+ polymarket_user?: string;
227
+ limit?: number;
228
+ cursor?: string;
229
+ /** Comma-separated trade types. */
230
+ type?: string;
231
+ side?: string;
232
+ }
220
233
  /** A single price-history data point. */
221
234
  interface PricePoint {
222
235
  /** Unix seconds. */
@@ -584,13 +597,26 @@ interface DFlowSubmitResponse {
584
597
  }
585
598
  /** Order type for Polymarket CLOB. */
586
599
  type PolymarketOrderType = "GTC" | "FOK" | "GTD" | "FAK";
587
- /** Input for creating a Polymarket limit order. */
600
+ /**
601
+ * Input for creating a Polymarket order (limit or market).
602
+ * @see https://docs.polymarket.com/trading/orders/create
603
+ */
588
604
  interface CreateOrderInput {
589
605
  /** Token ID (outcome asset ID) from market provider_meta. */
590
606
  tokenId: string;
591
607
  /** Price in range [0.01, 0.99]. */
592
608
  price: number;
593
- /** Order size in USDC. */
609
+ /**
610
+ * Order size — meaning depends on order type:
611
+ * - **Market BUY (FOK/FAK)**: USDC dollar amount to spend.
612
+ * - **Market SELL (FOK/FAK)**: Number of shares to sell.
613
+ * - **Limit BUY/SELL (GTC/GTD)**: Number of shares.
614
+ *
615
+ * This matches the official Polymarket SDK where `createMarketOrder` takes
616
+ * `amount` (USDC for buy, shares for sell), while `createOrder` (limit)
617
+ * takes `size` (always shares).
618
+ * @see https://docs.polymarket.com/trading/orders/create#market-orders
619
+ */
594
620
  size: number;
595
621
  side: OrderSide;
596
622
  orderType?: PolymarketOrderType;
@@ -908,6 +934,8 @@ declare class PredictClient {
908
934
  listMatchMarkets(params?: MatchMarketParams): Promise<MatchMarketPage>;
909
935
  /** Maps to `GET /api/v1/trades?source=...&wallet=...`. */
910
936
  listTrades(params: ListTradesParams): Promise<PredictPage<PredictTrade>>;
937
+ /** Maps to `GET /api/v1/trades?kalshi_user=...&polymarket_user=...`. */
938
+ listTradesMulti(params: ListTradesMultiParams): Promise<PredictPage<PredictTrade>>;
911
939
  /** Maps to `POST /api/v1/withdraw/build`. */
912
940
  withdrawBuild(body: WithdrawBuildRequest): Promise<WithdrawBuildResponse>;
913
941
  /** Maps to `POST /api/v1/withdraw/submit`. */
@@ -1314,9 +1342,22 @@ declare function derivePolymarketApiKey(address: string, signature: string, time
1314
1342
  * Neg-Risk CTF Exchange contracts (Polygon mainnet).
1315
1343
  *
1316
1344
  * References:
1317
- * https://github.com/Polymarket/clob-client/blob/main/src/order-builder/builder.ts
1318
- * https://github.com/Polymarket/clob-client/blob/main/src/order-builder/helpers.ts
1319
- * https://docs.polymarket.com/#create-order
1345
+ * - Official docs (order creation):
1346
+ * https://docs.polymarket.com/trading/orders/create
1347
+ * - Official TS CLOB client (order builder / helpers):
1348
+ * https://github.com/Polymarket/clob-client/blob/main/src/order-builder/builder.ts
1349
+ * https://github.com/Polymarket/clob-client/blob/main/src/order-builder/helpers.ts
1350
+ * - Official Python CLOB client (order builder — has `get_market_order_amounts`):
1351
+ * https://github.com/Polymarket/py-clob-client/blob/main/py_clob_client/order_builder/builder.py
1352
+ *
1353
+ * Market order (FOK/FAK) precision limits — NOT documented in official docs,
1354
+ * enforced server-side and discovered via API error messages:
1355
+ * - makerAmount: max 2 decimal places (human-readable)
1356
+ * - takerAmount: max 4 decimal places (human-readable)
1357
+ * - GitHub issues tracking this undocumented constraint:
1358
+ * https://github.com/Polymarket/py-clob-client/issues/121
1359
+ * https://github.com/Polymarket/py-clob-client/issues/253
1360
+ * https://github.com/Polymarket/rs-clob-client/issues/261
1320
1361
  */
1321
1362
 
1322
1363
  /** Polymarket CTF Exchange contract (standard markets). */
@@ -1398,36 +1439,55 @@ interface BuildOrderMessageInput extends CreateOrderInput {
1398
1439
  }
1399
1440
  interface OrderMessage {
1400
1441
  salt: string;
1442
+ /** Funder address that holds the collateral (USDC.e or outcome tokens). */
1401
1443
  maker: string;
1444
+ /** Signer address that signs the EIP-712 order. */
1402
1445
  signer: string;
1446
+ /** Taker address (0x0 = any counterparty). */
1403
1447
  taker: string;
1404
1448
  tokenId: string;
1449
+ /**
1450
+ * Amount the maker provides (micro-USDC, 6 decimals).
1451
+ * BUY: USDC spent. SELL: shares sold.
1452
+ */
1405
1453
  makerAmount: string;
1454
+ /**
1455
+ * Amount the taker provides (micro-USDC, 6 decimals).
1456
+ * BUY: shares received. SELL: USDC received.
1457
+ */
1406
1458
  takerAmount: string;
1407
1459
  expiration: string;
1408
1460
  nonce: string;
1409
1461
  feeRateBps: string;
1462
+ /** 0 = BUY, 1 = SELL (matches CTFExchange.sol). */
1410
1463
  side: number;
1464
+ /** 0 = EOA, 1 = POLY_PROXY, 2 = POLY_GNOSIS_SAFE. */
1411
1465
  signatureType: number;
1412
1466
  }
1413
1467
  /**
1414
- * Build the EIP-712 typed data value for a Polymarket limit order.
1468
+ * Build the EIP-712 typed data value for a Polymarket order.
1469
+ *
1470
+ * All amounts are in micro-USDC / micro-shares (1 unit = 1 000 000).
1415
1471
  *
1416
- * All amounts are in micro-USDC (1 USDC = 1 000 000).
1472
+ * Maker/taker semantics:
1473
+ * BUY: makerAmount = USDC spent, takerAmount = shares received
1474
+ * SELL: makerAmount = shares sold, takerAmount = USDC received
1417
1475
  *
1418
- * For a BUY order:
1419
- * - `makerAmount` = USDC spent (cost = size × price)
1420
- * - `takerAmount` = shares received (= size)
1476
+ * Input `size` semantics depend on order type:
1477
+ * Market BUY (FOK/FAK): size = USDC dollar amount to spend
1478
+ * Market SELL (FOK/FAK): size = number of shares to sell
1479
+ * Limit BUY (GTC/GTD): size = number of shares to buy
1480
+ * Limit SELL (GTC/GTD): size = number of shares to sell
1421
1481
  *
1422
- * For a SELL order:
1423
- * - `makerAmount` = shares sold (= size)
1424
- * - `takerAmount` = USDC received (cost = size × price)
1482
+ * Precision:
1483
+ * Market orders → makerAmount 2 decimals, takerAmount ≤ 4 decimals
1484
+ * Limit orders determined by tick-size ROUNDING_CONFIG (no API cap)
1425
1485
  *
1426
- * Amount rounding follows the official Polymarket CLOB client to guarantee
1427
- * that `makerAmount / takerAmount` produces a tick-aligned price.
1428
- * The key invariant: `amountDecimals = sizeDecimals + priceDecimals`, so
1429
- * `round(size × price, amountDecimals) / round(size, sizeDecimals)` has
1430
- * exactly `priceDecimals` decimal places.
1486
+ * Rounding direction:
1487
+ * Market BUY: maker = floor (spend less), taker = floor (fewer shares)
1488
+ * Market SELL: maker = floor (sell fewer), taker = ceil (receive more)
1489
+ * Limit BUY: size = round (tick-align), amount = round
1490
+ * Limit SELL: size = floor (avoid overselling), amount = round
1431
1491
  */
1432
1492
  declare function buildOrderMessage(input: BuildOrderMessageInput): OrderMessage;
1433
1493
  interface SignedOrder extends OrderMessage {
@@ -1480,4 +1540,4 @@ interface ClobOrderPayload {
1480
1540
  */
1481
1541
  declare function buildClobPayload(signedOrder: SignedOrder, owner: string): ClobOrderPayload;
1482
1542
 
1483
- export { createPredictClient as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStats as E, type DFlowKYCStatus as F, type PolymarketSetupStatus as G, type WithdrawBuildRequest as H, type WithdrawSubmitResponse as I, type WithdrawSubmitRequest as J, type WithdrawStatusResponse as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketDepositAddresses as N, type Orderbook as O, PredictClient as P, type PolymarketWithdrawResponse as Q, type PolymarketWithdrawRequest as R, type SimilarEventsParams as S, type TickSizeResponse as T, type WsConnectionStatus as U, type WsDataMessage as V, type WithdrawBuildResponse as W, type WsPriceEvent as X, type WsOrderbookEvent as Y, type WsTradeEvent as Z, type CreateOrderInput as _, PredictWsClient as a, type PolymarketL2HeadersInput as a$, createPredictWsClient as a0, type PredictWsClientConfig as a1, type ProviderMeta as a2, type PredictTag as a3, type SettlementSource as a4, type MarketStatus as a5, type MarketResult as a6, type MarketOutcome as a7, type OrderbookLevel as a8, type TradeType as a9, type WsServerMessage as aA, type WsPongMessage as aB, type WsSubscribedMessage as aC, type WsErrorCode as aD, type WsErrorMessage as aE, eventQueryKey as aF, fetchEvent as aG, resolveTagSlug as aH, resolveEventsParams as aI, infiniteEventsQueryKey as aJ, fetchEventsPage as aK, type ResolveEventsParamsInput as aL, type TagSlugSelection as aM, marketQueryKey as aN, fetchMarket as aO, matchesQueryKey as aP, matchQueryKey as aQ, fetchMatchesPage as aR, matchMarketsQueryKey as aS, fetchMatchMarketsPage as aT, CLOB_AUTH_DOMAIN as aU, CLOB_AUTH_TYPES as aV, buildClobAuthMessage as aW, hmacSha256Base64 as aX, buildPolymarketL2Headers as aY, derivePolymarketApiKey as aZ, type HttpMethod as a_, type EventSummary as aa, type MarketSummary as ab, type PricePoint as ac, type PredictPosition as ad, type OrderStatus as ae, type OrderSide as af, type DFlowOrderContext as ag, type PolymarketOrderType as ah, type DepositBuildRequest as ai, type DepositBuildResponse as aj, type DepositSubmitRequest as ak, type DepositSubmitResponse as al, type DepositStatusResponse as am, type UnsignedTx as an, type MatchStatus as ao, type MatchGroupEntry as ap, type MatchGroupMarket as aq, type MatchSortField as ar, type MatchesStats as as, type MatchConfidenceTier as at, type MatchMarketFlat as au, type WsChannel as av, type WsChannelEvent as aw, type WsClientMessage as ax, type WsSubscribeMessage as ay, type WsPingMessage as az, type PredictPage as b, type PolymarketL2Headers as b0, type BuildClobAuthMessageInput as b1, CTF_EXCHANGE_ADDRESS as b2, NEG_RISK_CTF_EXCHANGE_ADDRESS as b3, USDC_ADDRESS as b4, POLYGON_CHAIN_ID as b5, buildCtfExchangeDomain as b6, CTF_ORDER_TYPES as b7, ORDER_TYPE as b8, SIDE as b9, buildOrderMessage as ba, buildSignedOrder as bb, buildClobPayload as bc, type ClobOrderPayload as bd, type BuildOrderMessageInput as be, type OrderMessage as bf, type SignedOrder as bg, DEFAULT_PAGE_SIZE as bh, 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 ListOrdersMultiParams as p, type PredictOrdersResponse as q, type CancelOrderResult as r, type MatchGroupPage as s, type MatchGroup as t, type MatchMarketParams as u, type MatchMarketPage as v, type ListTradesParams as w, type DFlowQuoteResponse as x, type DFlowSubmitResponse as y, type DFlowSubmitRequest as z };
1543
+ export { type CreateOrderInput as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStats as E, type DFlowSubmitRequest as F, type DFlowKYCStatus as G, type PolymarketSetupStatus as H, type WithdrawBuildRequest as I, type WithdrawSubmitResponse as J, type WithdrawSubmitRequest as K, type ListEventsParams as L, type MatchesParams as M, type WithdrawStatusResponse as N, type Orderbook as O, PredictClient as P, type PolymarketDepositAddresses as Q, type PolymarketWithdrawResponse as R, type SimilarEventsParams as S, type PolymarketWithdrawRequest as T, type TickSizeResponse as U, type WsConnectionStatus as V, type WithdrawBuildResponse as W, type WsDataMessage as X, type WsPriceEvent as Y, type WsOrderbookEvent as Z, type WsTradeEvent as _, PredictWsClient as a, type HttpMethod as a$, createPredictClient as a0, createPredictWsClient as a1, type PredictWsClientConfig as a2, type ProviderMeta as a3, type PredictTag as a4, type SettlementSource as a5, type MarketStatus as a6, type MarketResult as a7, type MarketOutcome as a8, type OrderbookLevel as a9, type WsPingMessage as aA, type WsServerMessage as aB, type WsPongMessage as aC, type WsSubscribedMessage as aD, type WsErrorCode as aE, type WsErrorMessage as aF, eventQueryKey as aG, fetchEvent as aH, resolveTagSlug as aI, resolveEventsParams as aJ, infiniteEventsQueryKey as aK, fetchEventsPage as aL, type ResolveEventsParamsInput as aM, type TagSlugSelection as aN, marketQueryKey as aO, fetchMarket as aP, matchesQueryKey as aQ, matchQueryKey as aR, fetchMatchesPage as aS, matchMarketsQueryKey as aT, fetchMatchMarketsPage as aU, CLOB_AUTH_DOMAIN as aV, CLOB_AUTH_TYPES as aW, buildClobAuthMessage as aX, hmacSha256Base64 as aY, buildPolymarketL2Headers as aZ, derivePolymarketApiKey as a_, type TradeType as aa, type EventSummary as ab, type MarketSummary as ac, type PricePoint as ad, type PredictPosition as ae, type OrderStatus as af, type OrderSide as ag, type DFlowOrderContext as ah, type PolymarketOrderType as ai, type DepositBuildRequest as aj, type DepositBuildResponse as ak, type DepositSubmitRequest as al, type DepositSubmitResponse as am, type DepositStatusResponse as an, type UnsignedTx as ao, type MatchStatus as ap, type MatchGroupEntry as aq, type MatchGroupMarket as ar, type MatchSortField as as, type MatchesStats as at, type MatchConfidenceTier as au, type MatchMarketFlat as av, type WsChannel as aw, type WsChannelEvent as ax, type WsClientMessage as ay, type WsSubscribeMessage as az, type PredictPage as b, type PolymarketL2HeadersInput as b0, type PolymarketL2Headers as b1, type BuildClobAuthMessageInput as b2, CTF_EXCHANGE_ADDRESS as b3, NEG_RISK_CTF_EXCHANGE_ADDRESS as b4, USDC_ADDRESS as b5, POLYGON_CHAIN_ID as b6, buildCtfExchangeDomain as b7, CTF_ORDER_TYPES as b8, ORDER_TYPE as b9, SIDE as ba, buildOrderMessage as bb, buildSignedOrder as bc, buildClobPayload as bd, type ClobOrderPayload as be, type BuildOrderMessageInput as bf, type OrderMessage as bg, type SignedOrder as bh, DEFAULT_PAGE_SIZE as bi, 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 ListOrdersMultiParams as p, type PredictOrdersResponse as q, type CancelOrderResult as r, type MatchGroupPage as s, type MatchGroup as t, type MatchMarketParams as u, type MatchMarketPage as v, type ListTradesParams as w, type ListTradesMultiParams as x, type DFlowQuoteResponse as y, type DFlowSubmitResponse as z };
@@ -217,6 +217,19 @@ interface ListTradesParams {
217
217
  type?: string;
218
218
  side?: string;
219
219
  }
220
+ /**
221
+ * Query parameters for `GET /api/v1/trades` in multi-wallet mode.
222
+ * Each provider uses its own wallet address (e.g. Solana for Kalshi, EVM for Polymarket).
223
+ */
224
+ interface ListTradesMultiParams {
225
+ kalshi_user?: string;
226
+ polymarket_user?: string;
227
+ limit?: number;
228
+ cursor?: string;
229
+ /** Comma-separated trade types. */
230
+ type?: string;
231
+ side?: string;
232
+ }
220
233
  /** A single price-history data point. */
221
234
  interface PricePoint {
222
235
  /** Unix seconds. */
@@ -584,13 +597,26 @@ interface DFlowSubmitResponse {
584
597
  }
585
598
  /** Order type for Polymarket CLOB. */
586
599
  type PolymarketOrderType = "GTC" | "FOK" | "GTD" | "FAK";
587
- /** Input for creating a Polymarket limit order. */
600
+ /**
601
+ * Input for creating a Polymarket order (limit or market).
602
+ * @see https://docs.polymarket.com/trading/orders/create
603
+ */
588
604
  interface CreateOrderInput {
589
605
  /** Token ID (outcome asset ID) from market provider_meta. */
590
606
  tokenId: string;
591
607
  /** Price in range [0.01, 0.99]. */
592
608
  price: number;
593
- /** Order size in USDC. */
609
+ /**
610
+ * Order size — meaning depends on order type:
611
+ * - **Market BUY (FOK/FAK)**: USDC dollar amount to spend.
612
+ * - **Market SELL (FOK/FAK)**: Number of shares to sell.
613
+ * - **Limit BUY/SELL (GTC/GTD)**: Number of shares.
614
+ *
615
+ * This matches the official Polymarket SDK where `createMarketOrder` takes
616
+ * `amount` (USDC for buy, shares for sell), while `createOrder` (limit)
617
+ * takes `size` (always shares).
618
+ * @see https://docs.polymarket.com/trading/orders/create#market-orders
619
+ */
594
620
  size: number;
595
621
  side: OrderSide;
596
622
  orderType?: PolymarketOrderType;
@@ -908,6 +934,8 @@ declare class PredictClient {
908
934
  listMatchMarkets(params?: MatchMarketParams): Promise<MatchMarketPage>;
909
935
  /** Maps to `GET /api/v1/trades?source=...&wallet=...`. */
910
936
  listTrades(params: ListTradesParams): Promise<PredictPage<PredictTrade>>;
937
+ /** Maps to `GET /api/v1/trades?kalshi_user=...&polymarket_user=...`. */
938
+ listTradesMulti(params: ListTradesMultiParams): Promise<PredictPage<PredictTrade>>;
911
939
  /** Maps to `POST /api/v1/withdraw/build`. */
912
940
  withdrawBuild(body: WithdrawBuildRequest): Promise<WithdrawBuildResponse>;
913
941
  /** Maps to `POST /api/v1/withdraw/submit`. */
@@ -1314,9 +1342,22 @@ declare function derivePolymarketApiKey(address: string, signature: string, time
1314
1342
  * Neg-Risk CTF Exchange contracts (Polygon mainnet).
1315
1343
  *
1316
1344
  * References:
1317
- * https://github.com/Polymarket/clob-client/blob/main/src/order-builder/builder.ts
1318
- * https://github.com/Polymarket/clob-client/blob/main/src/order-builder/helpers.ts
1319
- * https://docs.polymarket.com/#create-order
1345
+ * - Official docs (order creation):
1346
+ * https://docs.polymarket.com/trading/orders/create
1347
+ * - Official TS CLOB client (order builder / helpers):
1348
+ * https://github.com/Polymarket/clob-client/blob/main/src/order-builder/builder.ts
1349
+ * https://github.com/Polymarket/clob-client/blob/main/src/order-builder/helpers.ts
1350
+ * - Official Python CLOB client (order builder — has `get_market_order_amounts`):
1351
+ * https://github.com/Polymarket/py-clob-client/blob/main/py_clob_client/order_builder/builder.py
1352
+ *
1353
+ * Market order (FOK/FAK) precision limits — NOT documented in official docs,
1354
+ * enforced server-side and discovered via API error messages:
1355
+ * - makerAmount: max 2 decimal places (human-readable)
1356
+ * - takerAmount: max 4 decimal places (human-readable)
1357
+ * - GitHub issues tracking this undocumented constraint:
1358
+ * https://github.com/Polymarket/py-clob-client/issues/121
1359
+ * https://github.com/Polymarket/py-clob-client/issues/253
1360
+ * https://github.com/Polymarket/rs-clob-client/issues/261
1320
1361
  */
1321
1362
 
1322
1363
  /** Polymarket CTF Exchange contract (standard markets). */
@@ -1398,36 +1439,55 @@ interface BuildOrderMessageInput extends CreateOrderInput {
1398
1439
  }
1399
1440
  interface OrderMessage {
1400
1441
  salt: string;
1442
+ /** Funder address that holds the collateral (USDC.e or outcome tokens). */
1401
1443
  maker: string;
1444
+ /** Signer address that signs the EIP-712 order. */
1402
1445
  signer: string;
1446
+ /** Taker address (0x0 = any counterparty). */
1403
1447
  taker: string;
1404
1448
  tokenId: string;
1449
+ /**
1450
+ * Amount the maker provides (micro-USDC, 6 decimals).
1451
+ * BUY: USDC spent. SELL: shares sold.
1452
+ */
1405
1453
  makerAmount: string;
1454
+ /**
1455
+ * Amount the taker provides (micro-USDC, 6 decimals).
1456
+ * BUY: shares received. SELL: USDC received.
1457
+ */
1406
1458
  takerAmount: string;
1407
1459
  expiration: string;
1408
1460
  nonce: string;
1409
1461
  feeRateBps: string;
1462
+ /** 0 = BUY, 1 = SELL (matches CTFExchange.sol). */
1410
1463
  side: number;
1464
+ /** 0 = EOA, 1 = POLY_PROXY, 2 = POLY_GNOSIS_SAFE. */
1411
1465
  signatureType: number;
1412
1466
  }
1413
1467
  /**
1414
- * Build the EIP-712 typed data value for a Polymarket limit order.
1468
+ * Build the EIP-712 typed data value for a Polymarket order.
1469
+ *
1470
+ * All amounts are in micro-USDC / micro-shares (1 unit = 1 000 000).
1415
1471
  *
1416
- * All amounts are in micro-USDC (1 USDC = 1 000 000).
1472
+ * Maker/taker semantics:
1473
+ * BUY: makerAmount = USDC spent, takerAmount = shares received
1474
+ * SELL: makerAmount = shares sold, takerAmount = USDC received
1417
1475
  *
1418
- * For a BUY order:
1419
- * - `makerAmount` = USDC spent (cost = size × price)
1420
- * - `takerAmount` = shares received (= size)
1476
+ * Input `size` semantics depend on order type:
1477
+ * Market BUY (FOK/FAK): size = USDC dollar amount to spend
1478
+ * Market SELL (FOK/FAK): size = number of shares to sell
1479
+ * Limit BUY (GTC/GTD): size = number of shares to buy
1480
+ * Limit SELL (GTC/GTD): size = number of shares to sell
1421
1481
  *
1422
- * For a SELL order:
1423
- * - `makerAmount` = shares sold (= size)
1424
- * - `takerAmount` = USDC received (cost = size × price)
1482
+ * Precision:
1483
+ * Market orders → makerAmount 2 decimals, takerAmount ≤ 4 decimals
1484
+ * Limit orders determined by tick-size ROUNDING_CONFIG (no API cap)
1425
1485
  *
1426
- * Amount rounding follows the official Polymarket CLOB client to guarantee
1427
- * that `makerAmount / takerAmount` produces a tick-aligned price.
1428
- * The key invariant: `amountDecimals = sizeDecimals + priceDecimals`, so
1429
- * `round(size × price, amountDecimals) / round(size, sizeDecimals)` has
1430
- * exactly `priceDecimals` decimal places.
1486
+ * Rounding direction:
1487
+ * Market BUY: maker = floor (spend less), taker = floor (fewer shares)
1488
+ * Market SELL: maker = floor (sell fewer), taker = ceil (receive more)
1489
+ * Limit BUY: size = round (tick-align), amount = round
1490
+ * Limit SELL: size = floor (avoid overselling), amount = round
1431
1491
  */
1432
1492
  declare function buildOrderMessage(input: BuildOrderMessageInput): OrderMessage;
1433
1493
  interface SignedOrder extends OrderMessage {
@@ -1480,4 +1540,4 @@ interface ClobOrderPayload {
1480
1540
  */
1481
1541
  declare function buildClobPayload(signedOrder: SignedOrder, owner: string): ClobOrderPayload;
1482
1542
 
1483
- export { createPredictClient as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStats as E, type DFlowKYCStatus as F, type PolymarketSetupStatus as G, type WithdrawBuildRequest as H, type WithdrawSubmitResponse as I, type WithdrawSubmitRequest as J, type WithdrawStatusResponse as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketDepositAddresses as N, type Orderbook as O, PredictClient as P, type PolymarketWithdrawResponse as Q, type PolymarketWithdrawRequest as R, type SimilarEventsParams as S, type TickSizeResponse as T, type WsConnectionStatus as U, type WsDataMessage as V, type WithdrawBuildResponse as W, type WsPriceEvent as X, type WsOrderbookEvent as Y, type WsTradeEvent as Z, type CreateOrderInput as _, PredictWsClient as a, type PolymarketL2HeadersInput as a$, createPredictWsClient as a0, type PredictWsClientConfig as a1, type ProviderMeta as a2, type PredictTag as a3, type SettlementSource as a4, type MarketStatus as a5, type MarketResult as a6, type MarketOutcome as a7, type OrderbookLevel as a8, type TradeType as a9, type WsServerMessage as aA, type WsPongMessage as aB, type WsSubscribedMessage as aC, type WsErrorCode as aD, type WsErrorMessage as aE, eventQueryKey as aF, fetchEvent as aG, resolveTagSlug as aH, resolveEventsParams as aI, infiniteEventsQueryKey as aJ, fetchEventsPage as aK, type ResolveEventsParamsInput as aL, type TagSlugSelection as aM, marketQueryKey as aN, fetchMarket as aO, matchesQueryKey as aP, matchQueryKey as aQ, fetchMatchesPage as aR, matchMarketsQueryKey as aS, fetchMatchMarketsPage as aT, CLOB_AUTH_DOMAIN as aU, CLOB_AUTH_TYPES as aV, buildClobAuthMessage as aW, hmacSha256Base64 as aX, buildPolymarketL2Headers as aY, derivePolymarketApiKey as aZ, type HttpMethod as a_, type EventSummary as aa, type MarketSummary as ab, type PricePoint as ac, type PredictPosition as ad, type OrderStatus as ae, type OrderSide as af, type DFlowOrderContext as ag, type PolymarketOrderType as ah, type DepositBuildRequest as ai, type DepositBuildResponse as aj, type DepositSubmitRequest as ak, type DepositSubmitResponse as al, type DepositStatusResponse as am, type UnsignedTx as an, type MatchStatus as ao, type MatchGroupEntry as ap, type MatchGroupMarket as aq, type MatchSortField as ar, type MatchesStats as as, type MatchConfidenceTier as at, type MatchMarketFlat as au, type WsChannel as av, type WsChannelEvent as aw, type WsClientMessage as ax, type WsSubscribeMessage as ay, type WsPingMessage as az, type PredictPage as b, type PolymarketL2Headers as b0, type BuildClobAuthMessageInput as b1, CTF_EXCHANGE_ADDRESS as b2, NEG_RISK_CTF_EXCHANGE_ADDRESS as b3, USDC_ADDRESS as b4, POLYGON_CHAIN_ID as b5, buildCtfExchangeDomain as b6, CTF_ORDER_TYPES as b7, ORDER_TYPE as b8, SIDE as b9, buildOrderMessage as ba, buildSignedOrder as bb, buildClobPayload as bc, type ClobOrderPayload as bd, type BuildOrderMessageInput as be, type OrderMessage as bf, type SignedOrder as bg, DEFAULT_PAGE_SIZE as bh, 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 ListOrdersMultiParams as p, type PredictOrdersResponse as q, type CancelOrderResult as r, type MatchGroupPage as s, type MatchGroup as t, type MatchMarketParams as u, type MatchMarketPage as v, type ListTradesParams as w, type DFlowQuoteResponse as x, type DFlowSubmitResponse as y, type DFlowSubmitRequest as z };
1543
+ export { type CreateOrderInput as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStats as E, type DFlowSubmitRequest as F, type DFlowKYCStatus as G, type PolymarketSetupStatus as H, type WithdrawBuildRequest as I, type WithdrawSubmitResponse as J, type WithdrawSubmitRequest as K, type ListEventsParams as L, type MatchesParams as M, type WithdrawStatusResponse as N, type Orderbook as O, PredictClient as P, type PolymarketDepositAddresses as Q, type PolymarketWithdrawResponse as R, type SimilarEventsParams as S, type PolymarketWithdrawRequest as T, type TickSizeResponse as U, type WsConnectionStatus as V, type WithdrawBuildResponse as W, type WsDataMessage as X, type WsPriceEvent as Y, type WsOrderbookEvent as Z, type WsTradeEvent as _, PredictWsClient as a, type HttpMethod as a$, createPredictClient as a0, createPredictWsClient as a1, type PredictWsClientConfig as a2, type ProviderMeta as a3, type PredictTag as a4, type SettlementSource as a5, type MarketStatus as a6, type MarketResult as a7, type MarketOutcome as a8, type OrderbookLevel as a9, type WsPingMessage as aA, type WsServerMessage as aB, type WsPongMessage as aC, type WsSubscribedMessage as aD, type WsErrorCode as aE, type WsErrorMessage as aF, eventQueryKey as aG, fetchEvent as aH, resolveTagSlug as aI, resolveEventsParams as aJ, infiniteEventsQueryKey as aK, fetchEventsPage as aL, type ResolveEventsParamsInput as aM, type TagSlugSelection as aN, marketQueryKey as aO, fetchMarket as aP, matchesQueryKey as aQ, matchQueryKey as aR, fetchMatchesPage as aS, matchMarketsQueryKey as aT, fetchMatchMarketsPage as aU, CLOB_AUTH_DOMAIN as aV, CLOB_AUTH_TYPES as aW, buildClobAuthMessage as aX, hmacSha256Base64 as aY, buildPolymarketL2Headers as aZ, derivePolymarketApiKey as a_, type TradeType as aa, type EventSummary as ab, type MarketSummary as ac, type PricePoint as ad, type PredictPosition as ae, type OrderStatus as af, type OrderSide as ag, type DFlowOrderContext as ah, type PolymarketOrderType as ai, type DepositBuildRequest as aj, type DepositBuildResponse as ak, type DepositSubmitRequest as al, type DepositSubmitResponse as am, type DepositStatusResponse as an, type UnsignedTx as ao, type MatchStatus as ap, type MatchGroupEntry as aq, type MatchGroupMarket as ar, type MatchSortField as as, type MatchesStats as at, type MatchConfidenceTier as au, type MatchMarketFlat as av, type WsChannel as aw, type WsChannelEvent as ax, type WsClientMessage as ay, type WsSubscribeMessage as az, type PredictPage as b, type PolymarketL2HeadersInput as b0, type PolymarketL2Headers as b1, type BuildClobAuthMessageInput as b2, CTF_EXCHANGE_ADDRESS as b3, NEG_RISK_CTF_EXCHANGE_ADDRESS as b4, USDC_ADDRESS as b5, POLYGON_CHAIN_ID as b6, buildCtfExchangeDomain as b7, CTF_ORDER_TYPES as b8, ORDER_TYPE as b9, SIDE as ba, buildOrderMessage as bb, buildSignedOrder as bc, buildClobPayload as bd, type ClobOrderPayload as be, type BuildOrderMessageInput as bf, type OrderMessage as bg, type SignedOrder as bh, DEFAULT_PAGE_SIZE as bi, 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 ListOrdersMultiParams as p, type PredictOrdersResponse as q, type CancelOrderResult as r, type MatchGroupPage as s, type MatchGroup as t, type MatchMarketParams as u, type MatchMarketPage as v, type ListTradesParams as w, type ListTradesMultiParams as x, type DFlowQuoteResponse as y, type DFlowSubmitResponse as z };
package/dist/server.d.mts CHANGED
@@ -1 +1 @@
1
- export { B as BalanceResponse, b1 as BuildClobAuthMessageInput, be as BuildOrderMessageInput, aU as CLOB_AUTH_DOMAIN, aV as CLOB_AUTH_TYPES, b2 as CTF_EXCHANGE_ADDRESS, b7 as CTF_ORDER_TYPES, r as CancelOrderResult, C as Candlestick, bd as ClobOrderPayload, _ as CreateOrderInput, bh as DEFAULT_PAGE_SIZE, ag as DFlowOrderContext, D as DFlowQuoteRequest, x as DFlowQuoteResponse, z as DFlowSubmitRequest, y as DFlowSubmitResponse, ai as DepositBuildRequest, aj as DepositBuildResponse, am as DepositStatusResponse, ak as DepositSubmitRequest, al as DepositSubmitResponse, f as EventSortField, e as EventStatus, aa as EventSummary, a_ as HttpMethod, l as ListCandlesticksParams, L as ListEventsParams, h as ListMarketTradesParams, n as ListOrdersParams, w as ListTradesParams, a7 as MarketOutcome, a6 as MarketResult, a5 as MarketStatus, ab as MarketSummary, at as MatchConfidenceTier, t as MatchGroup, ap as MatchGroupEntry, aq as MatchGroupMarket, s as MatchGroupPage, au as MatchMarketFlat, v as MatchMarketPage, u as MatchMarketParams, ar as MatchSortField, ao as MatchStatus, M as MatchesParams, as as MatchesStats, b3 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b8 as ORDER_TYPE, bf as OrderMessage, af as OrderSide, ae as OrderStatus, O as Orderbook, a8 as OrderbookLevel, b5 as POLYGON_CHAIN_ID, b0 as PolymarketL2Headers, a$ as PolymarketL2HeadersInput, ah as PolymarketOrderType, m as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, o as PredictOrder, b as PredictPage, ad as PredictPosition, a3 as PredictTag, i as PredictTrade, a as PredictWsClient, a1 as PredictWsClientConfig, j as PriceHistoryRange, k as PriceHistoryResponse, ac as PricePoint, a2 as ProviderMeta, d as ProviderSource, aL as ResolveEventsParamsInput, b9 as SIDE, a4 as SettlementSource, bg as SignedOrder, S as SimilarEventsParams, aM as TagSlugSelection, a9 as TradeType, b4 as USDC_ADDRESS, an as UnsignedTx, av as WsChannel, aw as WsChannelEvent, ax as WsClientMessage, U as WsConnectionStatus, V as WsDataMessage, aD as WsErrorCode, aE as WsErrorMessage, Y as WsOrderbookEvent, az as WsPingMessage, aB as WsPongMessage, X as WsPriceEvent, aA as WsServerMessage, ay as WsSubscribeMessage, aC as WsSubscribedMessage, Z as WsTradeEvent, aW as buildClobAuthMessage, bc as buildClobPayload, b6 as buildCtfExchangeDomain, ba as buildOrderMessage, aY as buildPolymarketL2Headers, bb as buildSignedOrder, $ as createPredictClient, a0 as createPredictWsClient, aZ as derivePolymarketApiKey, aF as eventQueryKey, aG as fetchEvent, aK as fetchEventsPage, aO as fetchMarket, aT as fetchMatchMarketsPage, aR as fetchMatchesPage, aX as hmacSha256Base64, aJ as infiniteEventsQueryKey, aN as marketQueryKey, aS as matchMarketsQueryKey, aQ as matchQueryKey, aP as matchesQueryKey, aI as resolveEventsParams, aH as resolveTagSlug } from './server-eKqIns8z.mjs';
1
+ export { B as BalanceResponse, b2 as BuildClobAuthMessageInput, bf as BuildOrderMessageInput, aV as CLOB_AUTH_DOMAIN, aW as CLOB_AUTH_TYPES, b3 as CTF_EXCHANGE_ADDRESS, b8 as CTF_ORDER_TYPES, r as CancelOrderResult, C as Candlestick, be as ClobOrderPayload, $ as CreateOrderInput, bi as DEFAULT_PAGE_SIZE, ah as DFlowOrderContext, D as DFlowQuoteRequest, y as DFlowQuoteResponse, F as DFlowSubmitRequest, z as DFlowSubmitResponse, aj as DepositBuildRequest, ak as DepositBuildResponse, an as DepositStatusResponse, al as DepositSubmitRequest, am as DepositSubmitResponse, f as EventSortField, e as EventStatus, ab as EventSummary, a$ as HttpMethod, l as ListCandlesticksParams, L as ListEventsParams, h as ListMarketTradesParams, n as ListOrdersParams, w as ListTradesParams, a8 as MarketOutcome, a7 as MarketResult, a6 as MarketStatus, ac as MarketSummary, au as MatchConfidenceTier, t as MatchGroup, aq as MatchGroupEntry, ar as MatchGroupMarket, s as MatchGroupPage, av as MatchMarketFlat, v as MatchMarketPage, u as MatchMarketParams, as as MatchSortField, ap as MatchStatus, M as MatchesParams, at as MatchesStats, b4 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b9 as ORDER_TYPE, bg as OrderMessage, ag as OrderSide, af as OrderStatus, O as Orderbook, a9 as OrderbookLevel, b6 as POLYGON_CHAIN_ID, b1 as PolymarketL2Headers, b0 as PolymarketL2HeadersInput, ai as PolymarketOrderType, m as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, o as PredictOrder, b as PredictPage, ae as PredictPosition, a4 as PredictTag, i as PredictTrade, a as PredictWsClient, a2 as PredictWsClientConfig, j as PriceHistoryRange, k as PriceHistoryResponse, ad as PricePoint, a3 as ProviderMeta, d as ProviderSource, aM as ResolveEventsParamsInput, ba as SIDE, a5 as SettlementSource, bh as SignedOrder, S as SimilarEventsParams, aN as TagSlugSelection, aa as TradeType, b5 as USDC_ADDRESS, ao as UnsignedTx, aw as WsChannel, ax as WsChannelEvent, ay as WsClientMessage, V as WsConnectionStatus, X as WsDataMessage, aE as WsErrorCode, aF as WsErrorMessage, Z as WsOrderbookEvent, aA as WsPingMessage, aC as WsPongMessage, Y as WsPriceEvent, aB as WsServerMessage, az as WsSubscribeMessage, aD as WsSubscribedMessage, _ as WsTradeEvent, aX as buildClobAuthMessage, bd as buildClobPayload, b7 as buildCtfExchangeDomain, bb as buildOrderMessage, aZ as buildPolymarketL2Headers, bc as buildSignedOrder, a0 as createPredictClient, a1 as createPredictWsClient, a_ as derivePolymarketApiKey, aG as eventQueryKey, aH as fetchEvent, aL as fetchEventsPage, aP as fetchMarket, aU as fetchMatchMarketsPage, aS as fetchMatchesPage, aY as hmacSha256Base64, aK as infiniteEventsQueryKey, aO as marketQueryKey, aT as matchMarketsQueryKey, aR as matchQueryKey, aQ as matchesQueryKey, aJ as resolveEventsParams, aI as resolveTagSlug } from './server-DUc4MoLH.mjs';
package/dist/server.d.ts CHANGED
@@ -1 +1 @@
1
- export { B as BalanceResponse, b1 as BuildClobAuthMessageInput, be as BuildOrderMessageInput, aU as CLOB_AUTH_DOMAIN, aV as CLOB_AUTH_TYPES, b2 as CTF_EXCHANGE_ADDRESS, b7 as CTF_ORDER_TYPES, r as CancelOrderResult, C as Candlestick, bd as ClobOrderPayload, _ as CreateOrderInput, bh as DEFAULT_PAGE_SIZE, ag as DFlowOrderContext, D as DFlowQuoteRequest, x as DFlowQuoteResponse, z as DFlowSubmitRequest, y as DFlowSubmitResponse, ai as DepositBuildRequest, aj as DepositBuildResponse, am as DepositStatusResponse, ak as DepositSubmitRequest, al as DepositSubmitResponse, f as EventSortField, e as EventStatus, aa as EventSummary, a_ as HttpMethod, l as ListCandlesticksParams, L as ListEventsParams, h as ListMarketTradesParams, n as ListOrdersParams, w as ListTradesParams, a7 as MarketOutcome, a6 as MarketResult, a5 as MarketStatus, ab as MarketSummary, at as MatchConfidenceTier, t as MatchGroup, ap as MatchGroupEntry, aq as MatchGroupMarket, s as MatchGroupPage, au as MatchMarketFlat, v as MatchMarketPage, u as MatchMarketParams, ar as MatchSortField, ao as MatchStatus, M as MatchesParams, as as MatchesStats, b3 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b8 as ORDER_TYPE, bf as OrderMessage, af as OrderSide, ae as OrderStatus, O as Orderbook, a8 as OrderbookLevel, b5 as POLYGON_CHAIN_ID, b0 as PolymarketL2Headers, a$ as PolymarketL2HeadersInput, ah as PolymarketOrderType, m as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, o as PredictOrder, b as PredictPage, ad as PredictPosition, a3 as PredictTag, i as PredictTrade, a as PredictWsClient, a1 as PredictWsClientConfig, j as PriceHistoryRange, k as PriceHistoryResponse, ac as PricePoint, a2 as ProviderMeta, d as ProviderSource, aL as ResolveEventsParamsInput, b9 as SIDE, a4 as SettlementSource, bg as SignedOrder, S as SimilarEventsParams, aM as TagSlugSelection, a9 as TradeType, b4 as USDC_ADDRESS, an as UnsignedTx, av as WsChannel, aw as WsChannelEvent, ax as WsClientMessage, U as WsConnectionStatus, V as WsDataMessage, aD as WsErrorCode, aE as WsErrorMessage, Y as WsOrderbookEvent, az as WsPingMessage, aB as WsPongMessage, X as WsPriceEvent, aA as WsServerMessage, ay as WsSubscribeMessage, aC as WsSubscribedMessage, Z as WsTradeEvent, aW as buildClobAuthMessage, bc as buildClobPayload, b6 as buildCtfExchangeDomain, ba as buildOrderMessage, aY as buildPolymarketL2Headers, bb as buildSignedOrder, $ as createPredictClient, a0 as createPredictWsClient, aZ as derivePolymarketApiKey, aF as eventQueryKey, aG as fetchEvent, aK as fetchEventsPage, aO as fetchMarket, aT as fetchMatchMarketsPage, aR as fetchMatchesPage, aX as hmacSha256Base64, aJ as infiniteEventsQueryKey, aN as marketQueryKey, aS as matchMarketsQueryKey, aQ as matchQueryKey, aP as matchesQueryKey, aI as resolveEventsParams, aH as resolveTagSlug } from './server-eKqIns8z.js';
1
+ export { B as BalanceResponse, b2 as BuildClobAuthMessageInput, bf as BuildOrderMessageInput, aV as CLOB_AUTH_DOMAIN, aW as CLOB_AUTH_TYPES, b3 as CTF_EXCHANGE_ADDRESS, b8 as CTF_ORDER_TYPES, r as CancelOrderResult, C as Candlestick, be as ClobOrderPayload, $ as CreateOrderInput, bi as DEFAULT_PAGE_SIZE, ah as DFlowOrderContext, D as DFlowQuoteRequest, y as DFlowQuoteResponse, F as DFlowSubmitRequest, z as DFlowSubmitResponse, aj as DepositBuildRequest, ak as DepositBuildResponse, an as DepositStatusResponse, al as DepositSubmitRequest, am as DepositSubmitResponse, f as EventSortField, e as EventStatus, ab as EventSummary, a$ as HttpMethod, l as ListCandlesticksParams, L as ListEventsParams, h as ListMarketTradesParams, n as ListOrdersParams, w as ListTradesParams, a8 as MarketOutcome, a7 as MarketResult, a6 as MarketStatus, ac as MarketSummary, au as MatchConfidenceTier, t as MatchGroup, aq as MatchGroupEntry, ar as MatchGroupMarket, s as MatchGroupPage, av as MatchMarketFlat, v as MatchMarketPage, u as MatchMarketParams, as as MatchSortField, ap as MatchStatus, M as MatchesParams, at as MatchesStats, b4 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b9 as ORDER_TYPE, bg as OrderMessage, ag as OrderSide, af as OrderStatus, O as Orderbook, a9 as OrderbookLevel, b6 as POLYGON_CHAIN_ID, b1 as PolymarketL2Headers, b0 as PolymarketL2HeadersInput, ai as PolymarketOrderType, m as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, o as PredictOrder, b as PredictPage, ae as PredictPosition, a4 as PredictTag, i as PredictTrade, a as PredictWsClient, a2 as PredictWsClientConfig, j as PriceHistoryRange, k as PriceHistoryResponse, ad as PricePoint, a3 as ProviderMeta, d as ProviderSource, aM as ResolveEventsParamsInput, ba as SIDE, a5 as SettlementSource, bh as SignedOrder, S as SimilarEventsParams, aN as TagSlugSelection, aa as TradeType, b5 as USDC_ADDRESS, ao as UnsignedTx, aw as WsChannel, ax as WsChannelEvent, ay as WsClientMessage, V as WsConnectionStatus, X as WsDataMessage, aE as WsErrorCode, aF as WsErrorMessage, Z as WsOrderbookEvent, aA as WsPingMessage, aC as WsPongMessage, Y as WsPriceEvent, aB as WsServerMessage, az as WsSubscribeMessage, aD as WsSubscribedMessage, _ as WsTradeEvent, aX as buildClobAuthMessage, bd as buildClobPayload, b7 as buildCtfExchangeDomain, bb as buildOrderMessage, aZ as buildPolymarketL2Headers, bc as buildSignedOrder, a0 as createPredictClient, a1 as createPredictWsClient, a_ as derivePolymarketApiKey, aG as eventQueryKey, aH as fetchEvent, aL as fetchEventsPage, aP as fetchMarket, aU as fetchMatchMarketsPage, aS as fetchMatchesPage, aY as hmacSha256Base64, aK as infiniteEventsQueryKey, aO as marketQueryKey, aT as matchMarketsQueryKey, aR as matchQueryKey, aQ as matchesQueryKey, aJ as resolveEventsParams, aI as resolveTagSlug } from './server-DUc4MoLH.js';
package/dist/server.js CHANGED
@@ -426,6 +426,12 @@ var PredictClient = class {
426
426
  const url = `${this.endpoint}/api/v1/trades${query}`;
427
427
  return await utils.httpGet(url);
428
428
  }
429
+ /** Maps to `GET /api/v1/trades?kalshi_user=...&polymarket_user=...`. */
430
+ async listTradesMulti(params) {
431
+ const query = buildQuery(params);
432
+ const url = `${this.endpoint}/api/v1/trades${query}`;
433
+ return await utils.httpGet(url);
434
+ }
429
435
  // -------------------------------------------------------------------------
430
436
  // Withdraw
431
437
  // -------------------------------------------------------------------------
@@ -989,6 +995,16 @@ function floorDecimalPlaces(n, d) {
989
995
  const factor = 10 ** d;
990
996
  return Math.floor(n * factor) / factor;
991
997
  }
998
+ function ceilDecimalPlaces(n, d) {
999
+ const factor = 10 ** d;
1000
+ return Math.ceil(n * factor) / factor;
1001
+ }
1002
+ function countDecimalPlaces(n) {
1003
+ const s = n.toString();
1004
+ const dot = s.indexOf(".");
1005
+ if (dot === -1) return 0;
1006
+ return s.length - dot - 1;
1007
+ }
992
1008
  function toMicroUsdc(amount) {
993
1009
  return BigInt(Math.round(amount * 1e6));
994
1010
  }
@@ -998,16 +1014,48 @@ function normalizeTokenId(tokenId) {
998
1014
  }
999
1015
  return tokenId;
1000
1016
  }
1001
- function buildOrderMessage(input) {
1002
- const side = input.side === "BUY" ? SIDE.BUY : SIDE.SELL;
1003
- const rc = ROUNDING_CONFIG[input.tickSize] ?? DEFAULT_ROUNDING;
1004
- const rawPrice = decimalPlaces(input.price, rc.price);
1005
- const rawSize = side === SIDE.SELL ? floorDecimalPlaces(input.size, rc.size) : decimalPlaces(input.size, rc.size);
1017
+ var MARKET_MAKER_MAX_DECIMALS = 2;
1018
+ var MARKET_TAKER_MAX_DECIMALS = 4;
1019
+ function getMarketOrderAmounts(side, size, price, rc) {
1020
+ const rawPrice = decimalPlaces(price, rc.price);
1021
+ const makerDecimals = Math.min(rc.size, MARKET_MAKER_MAX_DECIMALS);
1022
+ const takerDecimals = Math.min(rc.amount, MARKET_TAKER_MAX_DECIMALS);
1023
+ if (side === SIDE.BUY) {
1024
+ const rawMakerAmt2 = floorDecimalPlaces(size, makerDecimals);
1025
+ let rawTakerAmt2 = rawMakerAmt2 / rawPrice;
1026
+ if (countDecimalPlaces(rawTakerAmt2) > takerDecimals) {
1027
+ rawTakerAmt2 = floorDecimalPlaces(rawTakerAmt2, takerDecimals);
1028
+ }
1029
+ return {
1030
+ makerAmount: toMicroUsdc(rawMakerAmt2).toString(),
1031
+ takerAmount: toMicroUsdc(rawTakerAmt2).toString()
1032
+ };
1033
+ }
1034
+ const rawMakerAmt = floorDecimalPlaces(size, makerDecimals);
1035
+ let rawTakerAmt = rawMakerAmt * rawPrice;
1036
+ if (countDecimalPlaces(rawTakerAmt) > takerDecimals) {
1037
+ rawTakerAmt = ceilDecimalPlaces(rawTakerAmt, takerDecimals);
1038
+ }
1039
+ return {
1040
+ makerAmount: toMicroUsdc(rawMakerAmt).toString(),
1041
+ takerAmount: toMicroUsdc(rawTakerAmt).toString()
1042
+ };
1043
+ }
1044
+ function getLimitOrderAmounts(side, size, price, rc) {
1045
+ const rawPrice = decimalPlaces(price, rc.price);
1046
+ const rawSize = side === SIDE.SELL ? floorDecimalPlaces(size, rc.size) : decimalPlaces(size, rc.size);
1006
1047
  const sizeInMicro = toMicroUsdc(rawSize);
1007
1048
  const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
1008
1049
  const amountInMicro = toMicroUsdc(rawAmount);
1009
1050
  const makerAmount = side === SIDE.BUY ? amountInMicro.toString() : sizeInMicro.toString();
1010
1051
  const takerAmount = side === SIDE.BUY ? sizeInMicro.toString() : amountInMicro.toString();
1052
+ return { makerAmount, takerAmount };
1053
+ }
1054
+ function buildOrderMessage(input) {
1055
+ const side = input.side === "BUY" ? SIDE.BUY : SIDE.SELL;
1056
+ const rc = ROUNDING_CONFIG[input.tickSize] ?? DEFAULT_ROUNDING;
1057
+ const isMarketOrder = input.orderType === "FOK" || input.orderType === "FAK";
1058
+ const { makerAmount, takerAmount } = isMarketOrder ? getMarketOrderAmounts(side, input.size, input.price, rc) : getLimitOrderAmounts(side, input.size, input.price, rc);
1011
1059
  const maker = input.funderAddress ?? input.signerAddress;
1012
1060
  return {
1013
1061
  salt: Math.floor(Math.random() * 1e15).toString(),