@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.
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +71 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +70 -6
- package/dist/index.mjs.map +1 -1
- package/dist/{server-eKqIns8z.d.mts → server-DUc4MoLH.d.mts} +79 -19
- package/dist/{server-eKqIns8z.d.ts → server-DUc4MoLH.d.ts} +79 -19
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +53 -5
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +53 -5
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
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
|
|
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
|
-
*
|
|
1472
|
+
* Maker/taker semantics:
|
|
1473
|
+
* BUY: makerAmount = USDC spent, takerAmount = shares received
|
|
1474
|
+
* SELL: makerAmount = shares sold, takerAmount = USDC received
|
|
1417
1475
|
*
|
|
1418
|
-
*
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
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
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
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
|
-
*
|
|
1427
|
-
*
|
|
1428
|
-
*
|
|
1429
|
-
*
|
|
1430
|
-
*
|
|
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 {
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
*
|
|
1318
|
-
*
|
|
1319
|
-
*
|
|
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
|
|
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
|
-
*
|
|
1472
|
+
* Maker/taker semantics:
|
|
1473
|
+
* BUY: makerAmount = USDC spent, takerAmount = shares received
|
|
1474
|
+
* SELL: makerAmount = shares sold, takerAmount = USDC received
|
|
1417
1475
|
*
|
|
1418
|
-
*
|
|
1419
|
-
*
|
|
1420
|
-
*
|
|
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
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
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
|
-
*
|
|
1427
|
-
*
|
|
1428
|
-
*
|
|
1429
|
-
*
|
|
1430
|
-
*
|
|
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 {
|
|
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,
|
|
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,
|
|
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
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
const rawPrice = decimalPlaces(
|
|
1005
|
-
const
|
|
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(),
|