@liberfi.io/react-predict 0.1.52 → 0.1.54
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 +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +50 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +50 -5
- package/dist/index.mjs.map +1 -1
- package/dist/{server-BPTOChEG.d.mts → server-DUc4MoLH.d.mts} +63 -18
- package/dist/{server-BPTOChEG.d.ts → server-DUc4MoLH.d.ts} +63 -18
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +47 -5
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +47 -5
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as Orderbook, h as ListMarketTradesParams, i as PredictTrade, j as PriceHistoryRange, k as PriceHistoryResponse, l as ListCandlesticksParams, C as Candlestick, m as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, n as ListOrdersParams, o as PredictOrder, p as ListOrdersMultiParams, q as PredictOrdersResponse, r as CancelOrderResult, M as MatchesParams, s as MatchGroupPage, t as MatchGroup, u as MatchMarketParams, v as MatchMarketPage, w as ListTradesParams, x as ListTradesMultiParams, D as DFlowQuoteRequest, y as DFlowQuoteResponse, z as DFlowSubmitResponse, F as DFlowSubmitRequest, G as DFlowKYCStatus, H as PolymarketSetupStatus, W as WithdrawBuildResponse, I as WithdrawBuildRequest, J as WithdrawSubmitResponse, K as WithdrawSubmitRequest, N as WithdrawStatusResponse, Q as PolymarketDepositAddresses, R as PolymarketWithdrawResponse, T as PolymarketWithdrawRequest, U as TickSizeResponse, V as WsConnectionStatus, X as WsDataMessage, Y as WsPriceEvent, Z as WsOrderbookEvent, _ as WsTradeEvent, $ as CreateOrderInput } from './server-
|
|
2
|
-
export { 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, be as ClobOrderPayload, ah as DFlowOrderContext, aj as DepositBuildRequest, ak as DepositBuildResponse, an as DepositStatusResponse, al as DepositSubmitRequest, am as DepositSubmitResponse, ab as EventSummary, a$ as HttpMethod, a8 as MarketOutcome, a7 as MarketResult, a6 as MarketStatus, ac as MarketSummary, au as MatchConfidenceTier, aq as MatchGroupEntry, ar as MatchGroupMarket, av as MatchMarketFlat, as as MatchSortField, ap as MatchStatus, at as MatchesStats, b4 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b9 as ORDER_TYPE, bg as OrderMessage, ag as OrderSide, af as OrderStatus, a9 as OrderbookLevel, b6 as POLYGON_CHAIN_ID, b1 as PolymarketL2Headers, b0 as PolymarketL2HeadersInput, ai as PolymarketOrderType, ae as PredictPosition, a4 as PredictTag, a2 as PredictWsClientConfig, ad as PricePoint, a3 as ProviderMeta, aM as ResolveEventsParamsInput, ba as SIDE, a5 as SettlementSource, bh as SignedOrder, aN as TagSlugSelection, aa as TradeType, b5 as USDC_ADDRESS, ao as UnsignedTx, aw as WsChannel, ax as WsChannelEvent, ay as WsClientMessage, aE as WsErrorCode, aF as WsErrorMessage, aA as WsPingMessage, aC as WsPongMessage, aB as WsServerMessage, az as WsSubscribeMessage, aD as WsSubscribedMessage, 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-
|
|
1
|
+
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as Orderbook, h as ListMarketTradesParams, i as PredictTrade, j as PriceHistoryRange, k as PriceHistoryResponse, l as ListCandlesticksParams, C as Candlestick, m as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, n as ListOrdersParams, o as PredictOrder, p as ListOrdersMultiParams, q as PredictOrdersResponse, r as CancelOrderResult, M as MatchesParams, s as MatchGroupPage, t as MatchGroup, u as MatchMarketParams, v as MatchMarketPage, w as ListTradesParams, x as ListTradesMultiParams, D as DFlowQuoteRequest, y as DFlowQuoteResponse, z as DFlowSubmitResponse, F as DFlowSubmitRequest, G as DFlowKYCStatus, H as PolymarketSetupStatus, W as WithdrawBuildResponse, I as WithdrawBuildRequest, J as WithdrawSubmitResponse, K as WithdrawSubmitRequest, N as WithdrawStatusResponse, Q as PolymarketDepositAddresses, R as PolymarketWithdrawResponse, T as PolymarketWithdrawRequest, U as TickSizeResponse, V as WsConnectionStatus, X as WsDataMessage, Y as WsPriceEvent, Z as WsOrderbookEvent, _ as WsTradeEvent, $ as CreateOrderInput } from './server-DUc4MoLH.mjs';
|
|
2
|
+
export { 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, be as ClobOrderPayload, ah as DFlowOrderContext, aj as DepositBuildRequest, ak as DepositBuildResponse, an as DepositStatusResponse, al as DepositSubmitRequest, am as DepositSubmitResponse, ab as EventSummary, a$ as HttpMethod, a8 as MarketOutcome, a7 as MarketResult, a6 as MarketStatus, ac as MarketSummary, au as MatchConfidenceTier, aq as MatchGroupEntry, ar as MatchGroupMarket, av as MatchMarketFlat, as as MatchSortField, ap as MatchStatus, at as MatchesStats, b4 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b9 as ORDER_TYPE, bg as OrderMessage, ag as OrderSide, af as OrderStatus, a9 as OrderbookLevel, b6 as POLYGON_CHAIN_ID, b1 as PolymarketL2Headers, b0 as PolymarketL2HeadersInput, ai as PolymarketOrderType, ae as PredictPosition, a4 as PredictTag, a2 as PredictWsClientConfig, ad as PricePoint, a3 as ProviderMeta, aM as ResolveEventsParamsInput, ba as SIDE, a5 as SettlementSource, bh as SignedOrder, aN as TagSlugSelection, aa as TradeType, b5 as USDC_ADDRESS, ao as UnsignedTx, aw as WsChannel, ax as WsChannelEvent, ay as WsClientMessage, aE as WsErrorCode, aF as WsErrorMessage, aA as WsPingMessage, aC as WsPongMessage, aB as WsServerMessage, az as WsSubscribeMessage, aD as WsSubscribedMessage, 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';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { PropsWithChildren } from 'react';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as Orderbook, h as ListMarketTradesParams, i as PredictTrade, j as PriceHistoryRange, k as PriceHistoryResponse, l as ListCandlesticksParams, C as Candlestick, m as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, n as ListOrdersParams, o as PredictOrder, p as ListOrdersMultiParams, q as PredictOrdersResponse, r as CancelOrderResult, M as MatchesParams, s as MatchGroupPage, t as MatchGroup, u as MatchMarketParams, v as MatchMarketPage, w as ListTradesParams, x as ListTradesMultiParams, D as DFlowQuoteRequest, y as DFlowQuoteResponse, z as DFlowSubmitResponse, F as DFlowSubmitRequest, G as DFlowKYCStatus, H as PolymarketSetupStatus, W as WithdrawBuildResponse, I as WithdrawBuildRequest, J as WithdrawSubmitResponse, K as WithdrawSubmitRequest, N as WithdrawStatusResponse, Q as PolymarketDepositAddresses, R as PolymarketWithdrawResponse, T as PolymarketWithdrawRequest, U as TickSizeResponse, V as WsConnectionStatus, X as WsDataMessage, Y as WsPriceEvent, Z as WsOrderbookEvent, _ as WsTradeEvent, $ as CreateOrderInput } from './server-
|
|
2
|
-
export { 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, be as ClobOrderPayload, ah as DFlowOrderContext, aj as DepositBuildRequest, ak as DepositBuildResponse, an as DepositStatusResponse, al as DepositSubmitRequest, am as DepositSubmitResponse, ab as EventSummary, a$ as HttpMethod, a8 as MarketOutcome, a7 as MarketResult, a6 as MarketStatus, ac as MarketSummary, au as MatchConfidenceTier, aq as MatchGroupEntry, ar as MatchGroupMarket, av as MatchMarketFlat, as as MatchSortField, ap as MatchStatus, at as MatchesStats, b4 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b9 as ORDER_TYPE, bg as OrderMessage, ag as OrderSide, af as OrderStatus, a9 as OrderbookLevel, b6 as POLYGON_CHAIN_ID, b1 as PolymarketL2Headers, b0 as PolymarketL2HeadersInput, ai as PolymarketOrderType, ae as PredictPosition, a4 as PredictTag, a2 as PredictWsClientConfig, ad as PricePoint, a3 as ProviderMeta, aM as ResolveEventsParamsInput, ba as SIDE, a5 as SettlementSource, bh as SignedOrder, aN as TagSlugSelection, aa as TradeType, b5 as USDC_ADDRESS, ao as UnsignedTx, aw as WsChannel, ax as WsChannelEvent, ay as WsClientMessage, aE as WsErrorCode, aF as WsErrorMessage, aA as WsPingMessage, aC as WsPongMessage, aB as WsServerMessage, az as WsSubscribeMessage, aD as WsSubscribedMessage, 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-
|
|
1
|
+
import { P as PredictClient, a as PredictWsClient, L as ListEventsParams, b as PredictPage, c as PredictEvent, d as ProviderSource, E as EventStats, e as EventStatus, f as EventSortField, S as SimilarEventsParams, g as PredictMarket, O as Orderbook, h as ListMarketTradesParams, i as PredictTrade, j as PriceHistoryRange, k as PriceHistoryResponse, l as ListCandlesticksParams, C as Candlestick, m as PositionsResponse, A as AvailableSharesResponse, B as BalanceResponse, n as ListOrdersParams, o as PredictOrder, p as ListOrdersMultiParams, q as PredictOrdersResponse, r as CancelOrderResult, M as MatchesParams, s as MatchGroupPage, t as MatchGroup, u as MatchMarketParams, v as MatchMarketPage, w as ListTradesParams, x as ListTradesMultiParams, D as DFlowQuoteRequest, y as DFlowQuoteResponse, z as DFlowSubmitResponse, F as DFlowSubmitRequest, G as DFlowKYCStatus, H as PolymarketSetupStatus, W as WithdrawBuildResponse, I as WithdrawBuildRequest, J as WithdrawSubmitResponse, K as WithdrawSubmitRequest, N as WithdrawStatusResponse, Q as PolymarketDepositAddresses, R as PolymarketWithdrawResponse, T as PolymarketWithdrawRequest, U as TickSizeResponse, V as WsConnectionStatus, X as WsDataMessage, Y as WsPriceEvent, Z as WsOrderbookEvent, _ as WsTradeEvent, $ as CreateOrderInput } from './server-DUc4MoLH.js';
|
|
2
|
+
export { 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, be as ClobOrderPayload, ah as DFlowOrderContext, aj as DepositBuildRequest, ak as DepositBuildResponse, an as DepositStatusResponse, al as DepositSubmitRequest, am as DepositSubmitResponse, ab as EventSummary, a$ as HttpMethod, a8 as MarketOutcome, a7 as MarketResult, a6 as MarketStatus, ac as MarketSummary, au as MatchConfidenceTier, aq as MatchGroupEntry, ar as MatchGroupMarket, av as MatchMarketFlat, as as MatchSortField, ap as MatchStatus, at as MatchesStats, b4 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b9 as ORDER_TYPE, bg as OrderMessage, ag as OrderSide, af as OrderStatus, a9 as OrderbookLevel, b6 as POLYGON_CHAIN_ID, b1 as PolymarketL2Headers, b0 as PolymarketL2HeadersInput, ai as PolymarketOrderType, ae as PredictPosition, a4 as PredictTag, a2 as PredictWsClientConfig, ad as PricePoint, a3 as ProviderMeta, aM as ResolveEventsParamsInput, ba as SIDE, a5 as SettlementSource, bh as SignedOrder, aN as TagSlugSelection, aa as TradeType, b5 as USDC_ADDRESS, ao as UnsignedTx, aw as WsChannel, ax as WsChannelEvent, ay as WsClientMessage, aE as WsErrorCode, aF as WsErrorMessage, aA as WsPingMessage, aC as WsPongMessage, aB as WsServerMessage, az as WsSubscribeMessage, aD as WsSubscribedMessage, 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';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { PropsWithChildren } from 'react';
|
package/dist/index.js
CHANGED
|
@@ -2008,6 +2008,16 @@ function floorDecimalPlaces(n, d) {
|
|
|
2008
2008
|
const factor = 10 ** d;
|
|
2009
2009
|
return Math.floor(n * factor) / factor;
|
|
2010
2010
|
}
|
|
2011
|
+
function ceilDecimalPlaces(n, d) {
|
|
2012
|
+
const factor = 10 ** d;
|
|
2013
|
+
return Math.ceil(n * factor) / factor;
|
|
2014
|
+
}
|
|
2015
|
+
function countDecimalPlaces(n) {
|
|
2016
|
+
const s = n.toString();
|
|
2017
|
+
const dot = s.indexOf(".");
|
|
2018
|
+
if (dot === -1) return 0;
|
|
2019
|
+
return s.length - dot - 1;
|
|
2020
|
+
}
|
|
2011
2021
|
function toMicroUsdc(amount) {
|
|
2012
2022
|
return BigInt(Math.round(amount * 1e6));
|
|
2013
2023
|
}
|
|
@@ -2017,16 +2027,48 @@ function normalizeTokenId(tokenId) {
|
|
|
2017
2027
|
}
|
|
2018
2028
|
return tokenId;
|
|
2019
2029
|
}
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
const rawPrice = decimalPlaces(
|
|
2024
|
-
const
|
|
2030
|
+
var MARKET_MAKER_MAX_DECIMALS = 2;
|
|
2031
|
+
var MARKET_TAKER_MAX_DECIMALS = 4;
|
|
2032
|
+
function getMarketOrderAmounts(side, size, price, rc) {
|
|
2033
|
+
const rawPrice = decimalPlaces(price, rc.price);
|
|
2034
|
+
const makerDecimals = Math.min(rc.size, MARKET_MAKER_MAX_DECIMALS);
|
|
2035
|
+
const takerDecimals = Math.min(rc.amount, MARKET_TAKER_MAX_DECIMALS);
|
|
2036
|
+
if (side === SIDE.BUY) {
|
|
2037
|
+
const rawMakerAmt2 = floorDecimalPlaces(size, makerDecimals);
|
|
2038
|
+
let rawTakerAmt2 = rawMakerAmt2 / rawPrice;
|
|
2039
|
+
if (countDecimalPlaces(rawTakerAmt2) > takerDecimals) {
|
|
2040
|
+
rawTakerAmt2 = floorDecimalPlaces(rawTakerAmt2, takerDecimals);
|
|
2041
|
+
}
|
|
2042
|
+
return {
|
|
2043
|
+
makerAmount: toMicroUsdc(rawMakerAmt2).toString(),
|
|
2044
|
+
takerAmount: toMicroUsdc(rawTakerAmt2).toString()
|
|
2045
|
+
};
|
|
2046
|
+
}
|
|
2047
|
+
const rawMakerAmt = floorDecimalPlaces(size, makerDecimals);
|
|
2048
|
+
let rawTakerAmt = rawMakerAmt * rawPrice;
|
|
2049
|
+
if (countDecimalPlaces(rawTakerAmt) > takerDecimals) {
|
|
2050
|
+
rawTakerAmt = ceilDecimalPlaces(rawTakerAmt, takerDecimals);
|
|
2051
|
+
}
|
|
2052
|
+
return {
|
|
2053
|
+
makerAmount: toMicroUsdc(rawMakerAmt).toString(),
|
|
2054
|
+
takerAmount: toMicroUsdc(rawTakerAmt).toString()
|
|
2055
|
+
};
|
|
2056
|
+
}
|
|
2057
|
+
function getLimitOrderAmounts(side, size, price, rc) {
|
|
2058
|
+
const rawPrice = decimalPlaces(price, rc.price);
|
|
2059
|
+
const rawSize = side === SIDE.SELL ? floorDecimalPlaces(size, rc.size) : decimalPlaces(size, rc.size);
|
|
2025
2060
|
const sizeInMicro = toMicroUsdc(rawSize);
|
|
2026
2061
|
const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
|
|
2027
2062
|
const amountInMicro = toMicroUsdc(rawAmount);
|
|
2028
2063
|
const makerAmount = side === SIDE.BUY ? amountInMicro.toString() : sizeInMicro.toString();
|
|
2029
2064
|
const takerAmount = side === SIDE.BUY ? sizeInMicro.toString() : amountInMicro.toString();
|
|
2065
|
+
return { makerAmount, takerAmount };
|
|
2066
|
+
}
|
|
2067
|
+
function buildOrderMessage(input) {
|
|
2068
|
+
const side = input.side === "BUY" ? SIDE.BUY : SIDE.SELL;
|
|
2069
|
+
const rc = ROUNDING_CONFIG[input.tickSize] ?? DEFAULT_ROUNDING;
|
|
2070
|
+
const isMarketOrder = input.orderType === "FOK" || input.orderType === "FAK";
|
|
2071
|
+
const { makerAmount, takerAmount } = isMarketOrder ? getMarketOrderAmounts(side, input.size, input.price, rc) : getLimitOrderAmounts(side, input.size, input.price, rc);
|
|
2030
2072
|
const maker = input.funderAddress ?? input.signerAddress;
|
|
2031
2073
|
return {
|
|
2032
2074
|
salt: Math.floor(Math.random() * 1e15).toString(),
|
|
@@ -2141,6 +2183,9 @@ function useCreatePolymarketOrder(mutationOptions = {}) {
|
|
|
2141
2183
|
}
|
|
2142
2184
|
function computeOrderCost(input) {
|
|
2143
2185
|
if (input.side === "SELL") return "0";
|
|
2186
|
+
if (input.orderType === "FOK" || input.orderType === "FAK") {
|
|
2187
|
+
return input.size.toFixed(6);
|
|
2188
|
+
}
|
|
2144
2189
|
return (input.price * input.size).toFixed(6);
|
|
2145
2190
|
}
|
|
2146
2191
|
async function pollTxConfirmed(fetchStatus, txHash) {
|