@liberfi.io/react-predict 0.1.49 → 0.1.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +64 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -15
- package/dist/index.mjs.map +1 -1
- package/dist/{server-rYuNULuJ.d.mts → server-CaB0XJAa.d.mts} +23 -1
- package/dist/{server-rYuNULuJ.d.ts → server-CaB0XJAa.d.ts} +23 -1
- package/dist/server.d.mts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +30 -14
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +30 -14
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -690,6 +690,16 @@ interface EventStats {
|
|
|
690
690
|
avg_liquidity: number;
|
|
691
691
|
active_sources: number;
|
|
692
692
|
}
|
|
693
|
+
/** Response from the available-shares endpoint. */
|
|
694
|
+
interface AvailableSharesResponse {
|
|
695
|
+
source: ProviderSource;
|
|
696
|
+
market: string;
|
|
697
|
+
side: string;
|
|
698
|
+
total_shares: number;
|
|
699
|
+
active_order_shares: number;
|
|
700
|
+
available_shares: number;
|
|
701
|
+
precision: number;
|
|
702
|
+
}
|
|
693
703
|
|
|
694
704
|
/**
|
|
695
705
|
* HTTP client for the prediction-server REST API.
|
|
@@ -770,6 +780,18 @@ declare class PredictClient {
|
|
|
770
780
|
kalshi_user?: string;
|
|
771
781
|
polymarket_user?: string;
|
|
772
782
|
}, source?: ProviderSource): Promise<PositionsResponse>;
|
|
783
|
+
/**
|
|
784
|
+
* Get the number of shares available for selling, accounting for active orders.
|
|
785
|
+
*
|
|
786
|
+
* Maps to `GET /api/v1/available-shares?source=...&user=...&market=...&side=...`.
|
|
787
|
+
*
|
|
788
|
+
* @param source - Provider source.
|
|
789
|
+
* @param user - Wallet address.
|
|
790
|
+
* @param market - Market slug.
|
|
791
|
+
* @param side - Position side ("yes" or "no").
|
|
792
|
+
* @param headers - Optional extra headers (e.g. Polymarket POLY_* HMAC headers).
|
|
793
|
+
*/
|
|
794
|
+
getAvailableShares(source: ProviderSource, user: string, market: string, side: string, headers?: Record<string, string>): Promise<AvailableSharesResponse>;
|
|
773
795
|
/**
|
|
774
796
|
* Get the on-chain USDC balance for a wallet.
|
|
775
797
|
*
|
|
@@ -1433,4 +1455,4 @@ interface ClobOrderPayload {
|
|
|
1433
1455
|
*/
|
|
1434
1456
|
declare function buildClobPayload(signedOrder: SignedOrder, owner: string): ClobOrderPayload;
|
|
1435
1457
|
|
|
1436
|
-
export { type
|
|
1458
|
+
export { type PredictWsClientConfig as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStats as E, type WithdrawBuildRequest as F, type WithdrawSubmitResponse as G, type WithdrawSubmitRequest as H, type WithdrawStatusResponse as I, type PolymarketDepositAddresses as J, type PolymarketWithdrawResponse as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketWithdrawRequest as N, type Orderbook as O, PredictClient as P, type WsConnectionStatus as Q, type WsDataMessage as R, type SimilarEventsParams as S, type TickSizeResponse as T, type WsPriceEvent as U, type WsOrderbookEvent as V, type WithdrawBuildResponse as W, type WsTradeEvent as X, type CreateOrderInput as Y, createPredictClient as Z, createPredictWsClient as _, PredictWsClient as a, type BuildClobAuthMessageInput as a$, type ProviderMeta as a0, type PredictTag as a1, type SettlementSource as a2, type MarketStatus as a3, type MarketResult as a4, type MarketOutcome as a5, type OrderbookLevel as a6, type TradeType as a7, type EventSummary as a8, type MarketSummary as a9, type WsSubscribedMessage as aA, type WsErrorCode as aB, type WsErrorMessage as aC, eventQueryKey as aD, fetchEvent as aE, resolveTagSlug as aF, resolveEventsParams as aG, infiniteEventsQueryKey as aH, fetchEventsPage as aI, type ResolveEventsParamsInput as aJ, type TagSlugSelection as aK, marketQueryKey as aL, fetchMarket as aM, matchesQueryKey as aN, matchQueryKey as aO, fetchMatchesPage as aP, matchMarketsQueryKey as aQ, fetchMatchMarketsPage as aR, CLOB_AUTH_DOMAIN as aS, CLOB_AUTH_TYPES as aT, buildClobAuthMessage as aU, hmacSha256Base64 as aV, buildPolymarketL2Headers as aW, derivePolymarketApiKey as aX, type HttpMethod as aY, type PolymarketL2HeadersInput as aZ, type PolymarketL2Headers as a_, type PricePoint as aa, type PredictPosition as ab, type OrderStatus as ac, type OrderSide as ad, type DFlowOrderContext as ae, type PolymarketOrderType as af, type DepositBuildRequest as ag, type DepositBuildResponse as ah, type DepositSubmitRequest as ai, type DepositSubmitResponse as aj, type DepositStatusResponse as ak, type UnsignedTx as al, type MatchStatus as am, type MatchGroupEntry as an, type MatchGroupMarket as ao, type MatchSortField as ap, type MatchesStats as aq, type MatchConfidenceTier as ar, type MatchMarketFlat as as, type WsChannel as at, type WsChannelEvent as au, type WsClientMessage as av, type WsSubscribeMessage as aw, type WsPingMessage as ax, type WsServerMessage as ay, type WsPongMessage as az, type PredictPage as b, CTF_EXCHANGE_ADDRESS as b0, NEG_RISK_CTF_EXCHANGE_ADDRESS as b1, USDC_ADDRESS as b2, POLYGON_CHAIN_ID as b3, buildCtfExchangeDomain as b4, CTF_ORDER_TYPES as b5, ORDER_TYPE as b6, SIDE as b7, buildOrderMessage as b8, buildSignedOrder as b9, buildClobPayload as ba, type ClobOrderPayload as bb, type BuildOrderMessageInput as bc, type OrderMessage as bd, type SignedOrder as be, DEFAULT_PAGE_SIZE as bf, type PredictEvent as c, type ProviderSource as d, type EventStatus as e, type EventSortField as f, type PredictMarket as g, type ListMarketTradesParams as h, type PredictTrade as i, type PriceHistoryRange as j, type PriceHistoryResponse as k, type ListCandlesticksParams as l, type PositionsResponse as m, type ListOrdersParams as n, type PredictOrder as o, type CancelOrderResult as p, type MatchGroupPage as q, type MatchGroup as r, type MatchMarketParams as s, type MatchMarketPage as t, type ListTradesParams as u, type DFlowQuoteResponse as v, type DFlowSubmitResponse as w, type DFlowSubmitRequest as x, type DFlowKYCStatus as y, type PolymarketSetupStatus as z };
|
|
@@ -690,6 +690,16 @@ interface EventStats {
|
|
|
690
690
|
avg_liquidity: number;
|
|
691
691
|
active_sources: number;
|
|
692
692
|
}
|
|
693
|
+
/** Response from the available-shares endpoint. */
|
|
694
|
+
interface AvailableSharesResponse {
|
|
695
|
+
source: ProviderSource;
|
|
696
|
+
market: string;
|
|
697
|
+
side: string;
|
|
698
|
+
total_shares: number;
|
|
699
|
+
active_order_shares: number;
|
|
700
|
+
available_shares: number;
|
|
701
|
+
precision: number;
|
|
702
|
+
}
|
|
693
703
|
|
|
694
704
|
/**
|
|
695
705
|
* HTTP client for the prediction-server REST API.
|
|
@@ -770,6 +780,18 @@ declare class PredictClient {
|
|
|
770
780
|
kalshi_user?: string;
|
|
771
781
|
polymarket_user?: string;
|
|
772
782
|
}, source?: ProviderSource): Promise<PositionsResponse>;
|
|
783
|
+
/**
|
|
784
|
+
* Get the number of shares available for selling, accounting for active orders.
|
|
785
|
+
*
|
|
786
|
+
* Maps to `GET /api/v1/available-shares?source=...&user=...&market=...&side=...`.
|
|
787
|
+
*
|
|
788
|
+
* @param source - Provider source.
|
|
789
|
+
* @param user - Wallet address.
|
|
790
|
+
* @param market - Market slug.
|
|
791
|
+
* @param side - Position side ("yes" or "no").
|
|
792
|
+
* @param headers - Optional extra headers (e.g. Polymarket POLY_* HMAC headers).
|
|
793
|
+
*/
|
|
794
|
+
getAvailableShares(source: ProviderSource, user: string, market: string, side: string, headers?: Record<string, string>): Promise<AvailableSharesResponse>;
|
|
773
795
|
/**
|
|
774
796
|
* Get the on-chain USDC balance for a wallet.
|
|
775
797
|
*
|
|
@@ -1433,4 +1455,4 @@ interface ClobOrderPayload {
|
|
|
1433
1455
|
*/
|
|
1434
1456
|
declare function buildClobPayload(signedOrder: SignedOrder, owner: string): ClobOrderPayload;
|
|
1435
1457
|
|
|
1436
|
-
export { type
|
|
1458
|
+
export { type PredictWsClientConfig as $, type AvailableSharesResponse as A, type BalanceResponse as B, type Candlestick as C, type DFlowQuoteRequest as D, type EventStats as E, type WithdrawBuildRequest as F, type WithdrawSubmitResponse as G, type WithdrawSubmitRequest as H, type WithdrawStatusResponse as I, type PolymarketDepositAddresses as J, type PolymarketWithdrawResponse as K, type ListEventsParams as L, type MatchesParams as M, type PolymarketWithdrawRequest as N, type Orderbook as O, PredictClient as P, type WsConnectionStatus as Q, type WsDataMessage as R, type SimilarEventsParams as S, type TickSizeResponse as T, type WsPriceEvent as U, type WsOrderbookEvent as V, type WithdrawBuildResponse as W, type WsTradeEvent as X, type CreateOrderInput as Y, createPredictClient as Z, createPredictWsClient as _, PredictWsClient as a, type BuildClobAuthMessageInput as a$, type ProviderMeta as a0, type PredictTag as a1, type SettlementSource as a2, type MarketStatus as a3, type MarketResult as a4, type MarketOutcome as a5, type OrderbookLevel as a6, type TradeType as a7, type EventSummary as a8, type MarketSummary as a9, type WsSubscribedMessage as aA, type WsErrorCode as aB, type WsErrorMessage as aC, eventQueryKey as aD, fetchEvent as aE, resolveTagSlug as aF, resolveEventsParams as aG, infiniteEventsQueryKey as aH, fetchEventsPage as aI, type ResolveEventsParamsInput as aJ, type TagSlugSelection as aK, marketQueryKey as aL, fetchMarket as aM, matchesQueryKey as aN, matchQueryKey as aO, fetchMatchesPage as aP, matchMarketsQueryKey as aQ, fetchMatchMarketsPage as aR, CLOB_AUTH_DOMAIN as aS, CLOB_AUTH_TYPES as aT, buildClobAuthMessage as aU, hmacSha256Base64 as aV, buildPolymarketL2Headers as aW, derivePolymarketApiKey as aX, type HttpMethod as aY, type PolymarketL2HeadersInput as aZ, type PolymarketL2Headers as a_, type PricePoint as aa, type PredictPosition as ab, type OrderStatus as ac, type OrderSide as ad, type DFlowOrderContext as ae, type PolymarketOrderType as af, type DepositBuildRequest as ag, type DepositBuildResponse as ah, type DepositSubmitRequest as ai, type DepositSubmitResponse as aj, type DepositStatusResponse as ak, type UnsignedTx as al, type MatchStatus as am, type MatchGroupEntry as an, type MatchGroupMarket as ao, type MatchSortField as ap, type MatchesStats as aq, type MatchConfidenceTier as ar, type MatchMarketFlat as as, type WsChannel as at, type WsChannelEvent as au, type WsClientMessage as av, type WsSubscribeMessage as aw, type WsPingMessage as ax, type WsServerMessage as ay, type WsPongMessage as az, type PredictPage as b, CTF_EXCHANGE_ADDRESS as b0, NEG_RISK_CTF_EXCHANGE_ADDRESS as b1, USDC_ADDRESS as b2, POLYGON_CHAIN_ID as b3, buildCtfExchangeDomain as b4, CTF_ORDER_TYPES as b5, ORDER_TYPE as b6, SIDE as b7, buildOrderMessage as b8, buildSignedOrder as b9, buildClobPayload as ba, type ClobOrderPayload as bb, type BuildOrderMessageInput as bc, type OrderMessage as bd, type SignedOrder as be, DEFAULT_PAGE_SIZE as bf, type PredictEvent as c, type ProviderSource as d, type EventStatus as e, type EventSortField as f, type PredictMarket as g, type ListMarketTradesParams as h, type PredictTrade as i, type PriceHistoryRange as j, type PriceHistoryResponse as k, type ListCandlesticksParams as l, type PositionsResponse as m, type ListOrdersParams as n, type PredictOrder as o, type CancelOrderResult as p, type MatchGroupPage as q, type MatchGroup as r, type MatchMarketParams as s, type MatchMarketPage as t, type ListTradesParams as u, type DFlowQuoteResponse as v, type DFlowSubmitResponse as w, type DFlowSubmitRequest as x, type DFlowKYCStatus as y, type PolymarketSetupStatus as z };
|
package/dist/server.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BalanceResponse,
|
|
1
|
+
export { B as BalanceResponse, a$ as BuildClobAuthMessageInput, bc as BuildOrderMessageInput, aS as CLOB_AUTH_DOMAIN, aT as CLOB_AUTH_TYPES, b0 as CTF_EXCHANGE_ADDRESS, b5 as CTF_ORDER_TYPES, p as CancelOrderResult, C as Candlestick, bb as ClobOrderPayload, Y as CreateOrderInput, bf as DEFAULT_PAGE_SIZE, ae as DFlowOrderContext, D as DFlowQuoteRequest, v as DFlowQuoteResponse, x as DFlowSubmitRequest, w as DFlowSubmitResponse, ag as DepositBuildRequest, ah as DepositBuildResponse, ak as DepositStatusResponse, ai as DepositSubmitRequest, aj as DepositSubmitResponse, f as EventSortField, e as EventStatus, a8 as EventSummary, aY as HttpMethod, l as ListCandlesticksParams, L as ListEventsParams, h as ListMarketTradesParams, n as ListOrdersParams, u as ListTradesParams, a5 as MarketOutcome, a4 as MarketResult, a3 as MarketStatus, a9 as MarketSummary, ar as MatchConfidenceTier, r as MatchGroup, an as MatchGroupEntry, ao as MatchGroupMarket, q as MatchGroupPage, as as MatchMarketFlat, t as MatchMarketPage, s as MatchMarketParams, ap as MatchSortField, am as MatchStatus, M as MatchesParams, aq as MatchesStats, b1 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b6 as ORDER_TYPE, bd as OrderMessage, ad as OrderSide, ac as OrderStatus, O as Orderbook, a6 as OrderbookLevel, b3 as POLYGON_CHAIN_ID, a_ as PolymarketL2Headers, aZ as PolymarketL2HeadersInput, af as PolymarketOrderType, m as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, o as PredictOrder, b as PredictPage, ab as PredictPosition, a1 as PredictTag, i as PredictTrade, a as PredictWsClient, $ as PredictWsClientConfig, j as PriceHistoryRange, k as PriceHistoryResponse, aa as PricePoint, a0 as ProviderMeta, d as ProviderSource, aJ as ResolveEventsParamsInput, b7 as SIDE, a2 as SettlementSource, be as SignedOrder, S as SimilarEventsParams, aK as TagSlugSelection, a7 as TradeType, b2 as USDC_ADDRESS, al as UnsignedTx, at as WsChannel, au as WsChannelEvent, av as WsClientMessage, Q as WsConnectionStatus, R as WsDataMessage, aB as WsErrorCode, aC as WsErrorMessage, V as WsOrderbookEvent, ax as WsPingMessage, az as WsPongMessage, U as WsPriceEvent, ay as WsServerMessage, aw as WsSubscribeMessage, aA as WsSubscribedMessage, X as WsTradeEvent, aU as buildClobAuthMessage, ba as buildClobPayload, b4 as buildCtfExchangeDomain, b8 as buildOrderMessage, aW as buildPolymarketL2Headers, b9 as buildSignedOrder, Z as createPredictClient, _ as createPredictWsClient, aX as derivePolymarketApiKey, aD as eventQueryKey, aE as fetchEvent, aI as fetchEventsPage, aM as fetchMarket, aR as fetchMatchMarketsPage, aP as fetchMatchesPage, aV as hmacSha256Base64, aH as infiniteEventsQueryKey, aL as marketQueryKey, aQ as matchMarketsQueryKey, aO as matchQueryKey, aN as matchesQueryKey, aG as resolveEventsParams, aF as resolveTagSlug } from './server-CaB0XJAa.mjs';
|
package/dist/server.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { B as BalanceResponse,
|
|
1
|
+
export { B as BalanceResponse, a$ as BuildClobAuthMessageInput, bc as BuildOrderMessageInput, aS as CLOB_AUTH_DOMAIN, aT as CLOB_AUTH_TYPES, b0 as CTF_EXCHANGE_ADDRESS, b5 as CTF_ORDER_TYPES, p as CancelOrderResult, C as Candlestick, bb as ClobOrderPayload, Y as CreateOrderInput, bf as DEFAULT_PAGE_SIZE, ae as DFlowOrderContext, D as DFlowQuoteRequest, v as DFlowQuoteResponse, x as DFlowSubmitRequest, w as DFlowSubmitResponse, ag as DepositBuildRequest, ah as DepositBuildResponse, ak as DepositStatusResponse, ai as DepositSubmitRequest, aj as DepositSubmitResponse, f as EventSortField, e as EventStatus, a8 as EventSummary, aY as HttpMethod, l as ListCandlesticksParams, L as ListEventsParams, h as ListMarketTradesParams, n as ListOrdersParams, u as ListTradesParams, a5 as MarketOutcome, a4 as MarketResult, a3 as MarketStatus, a9 as MarketSummary, ar as MatchConfidenceTier, r as MatchGroup, an as MatchGroupEntry, ao as MatchGroupMarket, q as MatchGroupPage, as as MatchMarketFlat, t as MatchMarketPage, s as MatchMarketParams, ap as MatchSortField, am as MatchStatus, M as MatchesParams, aq as MatchesStats, b1 as NEG_RISK_CTF_EXCHANGE_ADDRESS, b6 as ORDER_TYPE, bd as OrderMessage, ad as OrderSide, ac as OrderStatus, O as Orderbook, a6 as OrderbookLevel, b3 as POLYGON_CHAIN_ID, a_ as PolymarketL2Headers, aZ as PolymarketL2HeadersInput, af as PolymarketOrderType, m as PositionsResponse, P as PredictClient, c as PredictEvent, g as PredictMarket, o as PredictOrder, b as PredictPage, ab as PredictPosition, a1 as PredictTag, i as PredictTrade, a as PredictWsClient, $ as PredictWsClientConfig, j as PriceHistoryRange, k as PriceHistoryResponse, aa as PricePoint, a0 as ProviderMeta, d as ProviderSource, aJ as ResolveEventsParamsInput, b7 as SIDE, a2 as SettlementSource, be as SignedOrder, S as SimilarEventsParams, aK as TagSlugSelection, a7 as TradeType, b2 as USDC_ADDRESS, al as UnsignedTx, at as WsChannel, au as WsChannelEvent, av as WsClientMessage, Q as WsConnectionStatus, R as WsDataMessage, aB as WsErrorCode, aC as WsErrorMessage, V as WsOrderbookEvent, ax as WsPingMessage, az as WsPongMessage, U as WsPriceEvent, ay as WsServerMessage, aw as WsSubscribeMessage, aA as WsSubscribedMessage, X as WsTradeEvent, aU as buildClobAuthMessage, ba as buildClobPayload, b4 as buildCtfExchangeDomain, b8 as buildOrderMessage, aW as buildPolymarketL2Headers, b9 as buildSignedOrder, Z as createPredictClient, _ as createPredictWsClient, aX as derivePolymarketApiKey, aD as eventQueryKey, aE as fetchEvent, aI as fetchEventsPage, aM as fetchMarket, aR as fetchMatchMarketsPage, aP as fetchMatchesPage, aV as hmacSha256Base64, aH as infiniteEventsQueryKey, aL as marketQueryKey, aQ as matchMarketsQueryKey, aO as matchQueryKey, aN as matchesQueryKey, aG as resolveEventsParams, aF as resolveTagSlug } from './server-CaB0XJAa.js';
|
package/dist/server.js
CHANGED
|
@@ -212,6 +212,28 @@ var PredictClient = class {
|
|
|
212
212
|
return await utils.httpGet(url);
|
|
213
213
|
}
|
|
214
214
|
// -------------------------------------------------------------------------
|
|
215
|
+
// Available shares (for sell flow)
|
|
216
|
+
// -------------------------------------------------------------------------
|
|
217
|
+
/**
|
|
218
|
+
* Get the number of shares available for selling, accounting for active orders.
|
|
219
|
+
*
|
|
220
|
+
* Maps to `GET /api/v1/available-shares?source=...&user=...&market=...&side=...`.
|
|
221
|
+
*
|
|
222
|
+
* @param source - Provider source.
|
|
223
|
+
* @param user - Wallet address.
|
|
224
|
+
* @param market - Market slug.
|
|
225
|
+
* @param side - Position side ("yes" or "no").
|
|
226
|
+
* @param headers - Optional extra headers (e.g. Polymarket POLY_* HMAC headers).
|
|
227
|
+
*/
|
|
228
|
+
async getAvailableShares(source, user, market, side, headers) {
|
|
229
|
+
const query = buildQuery({ source, user, market, side });
|
|
230
|
+
const url = `${this.endpoint}/api/v1/available-shares${query}`;
|
|
231
|
+
return await utils.httpGet(
|
|
232
|
+
url,
|
|
233
|
+
headers ? { headers } : void 0
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
// -------------------------------------------------------------------------
|
|
215
237
|
// Balance
|
|
216
238
|
// -------------------------------------------------------------------------
|
|
217
239
|
/**
|
|
@@ -947,17 +969,13 @@ var DEFAULT_ROUNDING = { size: 2, price: 2, amount: 4 };
|
|
|
947
969
|
function decimalPlaces(n, d) {
|
|
948
970
|
return parseFloat(n.toFixed(d));
|
|
949
971
|
}
|
|
972
|
+
function floorDecimalPlaces(n, d) {
|
|
973
|
+
const factor = 10 ** d;
|
|
974
|
+
return Math.floor(n * factor) / factor;
|
|
975
|
+
}
|
|
950
976
|
function toMicroUsdc(amount) {
|
|
951
977
|
return BigInt(Math.round(amount * 1e6));
|
|
952
978
|
}
|
|
953
|
-
function ceilMicro(raw, maxDecimals) {
|
|
954
|
-
const factor = BigInt(10 ** (6 - maxDecimals));
|
|
955
|
-
return (raw + factor - 1n) / factor * factor;
|
|
956
|
-
}
|
|
957
|
-
function floorMicro(raw, maxDecimals) {
|
|
958
|
-
const factor = BigInt(10 ** (6 - maxDecimals));
|
|
959
|
-
return raw / factor * factor;
|
|
960
|
-
}
|
|
961
979
|
function normalizeTokenId(tokenId) {
|
|
962
980
|
if (tokenId.startsWith("0x") || tokenId.startsWith("0X")) {
|
|
963
981
|
return BigInt(tokenId).toString(10);
|
|
@@ -968,14 +986,12 @@ function buildOrderMessage(input) {
|
|
|
968
986
|
const side = input.side === "BUY" ? SIDE.BUY : SIDE.SELL;
|
|
969
987
|
const rc = ROUNDING_CONFIG[input.tickSize] ?? DEFAULT_ROUNDING;
|
|
970
988
|
const rawPrice = decimalPlaces(input.price, rc.price);
|
|
971
|
-
const rawSize = decimalPlaces(input.size, rc.size);
|
|
972
|
-
const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
|
|
989
|
+
const rawSize = side === SIDE.SELL ? floorDecimalPlaces(input.size, rc.size) : decimalPlaces(input.size, rc.size);
|
|
973
990
|
const sizeInMicro = toMicroUsdc(rawSize);
|
|
991
|
+
const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
|
|
974
992
|
const amountInMicro = toMicroUsdc(rawAmount);
|
|
975
|
-
const
|
|
976
|
-
const
|
|
977
|
-
const makerAmount = side === SIDE.BUY ? usdcMicro.toString() : sharesMicro.toString();
|
|
978
|
-
const takerAmount = side === SIDE.BUY ? sharesMicro.toString() : usdcMicro.toString();
|
|
993
|
+
const makerAmount = side === SIDE.BUY ? amountInMicro.toString() : sizeInMicro.toString();
|
|
994
|
+
const takerAmount = side === SIDE.BUY ? sizeInMicro.toString() : amountInMicro.toString();
|
|
979
995
|
const maker = input.funderAddress ?? input.signerAddress;
|
|
980
996
|
return {
|
|
981
997
|
salt: Math.floor(Math.random() * 1e15).toString(),
|