@liberfi.io/ui-predict 4.0.44 → 4.0.46

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 CHANGED
@@ -298,6 +298,7 @@ type TradeSide = "buy" | "sell";
298
298
  type OrderType = "market" | "limit";
299
299
  type ExpirationPreset = "5m" | "1h" | "12h" | "24h" | "eod" | "custom";
300
300
  type DurationUnit = "minutes" | "hours" | "days";
301
+ type OddsFormatter = (price: number) => string;
301
302
  interface TradeFormValidation {
302
303
  isValid: boolean;
303
304
  errors: string[];
@@ -311,6 +312,49 @@ declare function roundToTickSize(price: number, tickSize: string): number;
311
312
  * Floor a number to the given number of decimal places (never rounds up).
312
313
  */
313
314
  declare function floorToDecimals(value: number, decimals: number): number;
315
+ /**
316
+ * Price-dependent factor in Polymarket's taker-fee formula:
317
+ * `min(1, (1 − price) / price)` (equivalently `min(price, 1−price) / price`).
318
+ * Capped at 1 (the worst case, reached when `price ≤ 0.5`). Falls back to the
319
+ * worst case (1) when the price is unknown/degenerate.
320
+ */
321
+ declare function polymarketFeeFactor(pricePerShare: number): number;
322
+ interface ComputeMaxBuyAmountParams {
323
+ source: string;
324
+ usdcBalance: number | null | undefined;
325
+ safetyBufferUsd?: number;
326
+ /**
327
+ * Polymarket base fee in basis points (from `GET /fee-rate/{token_id}`).
328
+ * Polymarket reserves a taker fee on top of the order amount, so the largest
329
+ * spendable amount must leave room for it. Defaults to 0 (fee-free markets).
330
+ */
331
+ feeRateBps?: number;
332
+ /**
333
+ * Per-share price (0–1) used to price the fee precisely. Omit to reserve the
334
+ * worst-case fee (factor = 1). Safe for buys: adverse fills push the price up,
335
+ * which only lowers the fee factor.
336
+ */
337
+ pricePerShare?: number;
338
+ }
339
+ declare function computeMaxBuyAmount({ source, usdcBalance, safetyBufferUsd, feeRateBps, pricePerShare, }: ComputeMaxBuyAmountParams): number;
340
+ interface EstimatePolymarketBuyFeeParams {
341
+ /** USDC amount the user intends to spend. */
342
+ usdcAmount: number;
343
+ /** Per-share execution price (0–1). */
344
+ pricePerShare: number;
345
+ /** Base fee in basis points (from `GET /fee-rate/{token_id}`). */
346
+ feeRateBps: number;
347
+ }
348
+ /**
349
+ * Estimate the Polymarket taker fee (USDC) for a buy, mirroring Polymarket's
350
+ * fee formula:
351
+ *
352
+ * fee = baseFeeRate × min(price, 1 − price) × shares, shares = amount / price
353
+ *
354
+ * which simplifies to `amount × r × min(1, (1 − price) / price)`. When the
355
+ * price is unknown/degenerate we fall back to the worst case (`amount × r`).
356
+ */
357
+ declare function estimatePolymarketBuyFee({ usdcAmount, pricePerShare, feeRateBps, }: EstimatePolymarketBuyFeeParams): number;
314
358
  /**
315
359
  * Parse a Polymarket CLOB API error message into a user-friendly string.
316
360
  * Falls back to the raw message (with order-hash stripped) if no pattern matches.
@@ -355,6 +399,11 @@ interface UseTradeFormResult {
355
399
  limitPrice: number;
356
400
  shares: number;
357
401
  estimatedCost: number;
402
+ /**
403
+ * Estimated Polymarket taker fee (USDC) reserved on top of the order amount.
404
+ * 0 for fee-free markets and for non-Polymarket sources.
405
+ */
406
+ estimatedFee: number;
358
407
  potentialPayout: number;
359
408
  potentialProfit: number;
360
409
  /**
@@ -363,6 +412,8 @@ interface UseTradeFormResult {
363
412
  */
364
413
  pricePerShare: number;
365
414
  usdcBalance: number | null;
415
+ maxBuyAmount: number;
416
+ spendableUsdcBalance: number | null;
366
417
  isBalanceLoading: boolean;
367
418
  isMarketDataLoading: boolean;
368
419
  isSubmitting: boolean;
@@ -529,8 +580,10 @@ interface EventMarketDetailWidgetProps {
529
580
  * `h-[262px]` so the widget can fill a flexible parent (e.g. `h-full`).
530
581
  */
531
582
  className?: string;
583
+ /** Optional formatter for display-only orderbook price labels. */
584
+ oddsFormatter?: OddsFormatter;
532
585
  }
533
- declare function EventMarketDetailWidget({ market, outcome, onTradeAction, initialViewMode, className, }: EventMarketDetailWidgetProps): react_jsx_runtime.JSX.Element;
586
+ declare function EventMarketDetailWidget({ market, outcome, onTradeAction, initialViewMode, className, oddsFormatter, }: EventMarketDetailWidgetProps): react_jsx_runtime.JSX.Element;
534
587
 
535
588
  interface EventPriceChartProps {
536
589
  event: PredictEvent;
@@ -688,6 +741,8 @@ interface TradeFormUIProps {
688
741
  limitPrice: number;
689
742
  shares: number;
690
743
  estimatedCost: number;
744
+ /** Estimated Polymarket taker fee (USDC). 0 hides the fee row. */
745
+ estimatedFee?: number;
691
746
  potentialPayout: number;
692
747
  potentialProfit: number;
693
748
  isMarketDataLoading: boolean;
@@ -703,6 +758,7 @@ interface TradeFormUIProps {
703
758
  /** Invoked when the user presses submit while balance is insufficient. */
704
759
  onInsufficientBalance?: () => void;
705
760
  supportsLimitOrder: boolean;
761
+ maxBuyAmount?: number;
706
762
  kycRequired: boolean;
707
763
  /** True when the user must complete KYC before the deposit flow is allowed. */
708
764
  needsKyc: boolean;
@@ -713,6 +769,8 @@ interface TradeFormUIProps {
713
769
  expirationPreset: ExpirationPreset;
714
770
  customDuration: number;
715
771
  customDurationUnit: DurationUnit;
772
+ /** Optional formatter for display-only odds/price labels. Defaults to cents/probability text. */
773
+ oddsFormatter?: OddsFormatter;
716
774
  onOutcomeChange: (outcome: TradeOutcome) => void;
717
775
  onOrderTypeChange: (type: OrderType) => void;
718
776
  onQuantityChange: (quantity: number) => void;
@@ -723,7 +781,7 @@ interface TradeFormUIProps {
723
781
  onCustomDurationUnitChange: (u: DurationUnit) => void;
724
782
  onSubmit: () => void;
725
783
  }
726
- declare function TradeFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, shares, potentialProfit, potentialPayout, estimatedCost, usdcBalance, isBalanceLoading, isMarketDataLoading, isSubmitting, authStatus, isValid, validationErrors, isInsufficientBalance, onInsufficientBalance, supportsLimitOrder, kycRequired, needsKyc, needsSetup, kycUrl, expirationEnabled, expirationPreset, customDuration, customDurationUnit, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: TradeFormUIProps): react_jsx_runtime.JSX.Element;
784
+ declare function TradeFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, shares, potentialProfit, potentialPayout, estimatedCost, estimatedFee, usdcBalance, isBalanceLoading, isMarketDataLoading, isSubmitting, authStatus, isValid, validationErrors, isInsufficientBalance, onInsufficientBalance, supportsLimitOrder, maxBuyAmount, kycRequired, needsKyc, needsSetup, kycUrl, expirationEnabled, expirationPreset, customDuration, customDurationUnit, oddsFormatter, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: TradeFormUIProps): react_jsx_runtime.JSX.Element;
727
785
 
728
786
  interface TradeFormWidgetProps {
729
787
  event?: PredictEvent;
@@ -744,8 +802,10 @@ interface TradeFormWidgetProps {
744
802
  onInsufficientBalance?: (source: ProviderSource) => void;
745
803
  /** Called whenever the user switches between YES and NO. */
746
804
  onOutcomeChange?: (outcome: TradeOutcome) => void;
805
+ /** Optional formatter for display-only odds/price labels. */
806
+ oddsFormatter?: OddsFormatter;
747
807
  }
748
- declare function TradeFormWidget({ event, market, variant, initialOutcome, chain, slippageBps, onInsufficientBalance, onOutcomeChange, }: TradeFormWidgetProps): react_jsx_runtime.JSX.Element;
808
+ declare function TradeFormWidget({ event, market, variant, initialOutcome, chain, slippageBps, onInsufficientBalance, onOutcomeChange, oddsFormatter, }: TradeFormWidgetProps): react_jsx_runtime.JSX.Element;
749
809
 
750
810
  type PredictSellModalParams = {
751
811
  event: PredictEvent;
@@ -862,6 +922,8 @@ interface SellFormUIProps {
862
922
  expirationPreset: ExpirationPreset;
863
923
  customDuration: number;
864
924
  customDurationUnit: DurationUnit;
925
+ /** Optional formatter for display-only odds/price labels. Defaults to cents/probability text. */
926
+ oddsFormatter?: OddsFormatter;
865
927
  onOutcomeChange: (outcome: TradeOutcome) => void;
866
928
  onOrderTypeChange: (type: OrderType) => void;
867
929
  onQuantityChange: (quantity: number) => void;
@@ -873,7 +935,7 @@ interface SellFormUIProps {
873
935
  onCustomDurationUnitChange: (u: DurationUnit) => void;
874
936
  onSubmit: () => void;
875
937
  }
876
- declare function SellFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, estimatedReturn, isMarketDataLoading, isSubmitting, authStatus, isValid, validationErrors, supportsLimitOrder, kycRequired, needsKyc, needsSetup, onSetupRequired, kycUrl, totalShares, activeOrderShares, availableShares, isAvailableLoading, precision, expirationEnabled, expirationPreset, customDuration, customDurationUnit, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onSellAll, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: SellFormUIProps): react_jsx_runtime.JSX.Element;
938
+ declare function SellFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, estimatedReturn, isMarketDataLoading, isSubmitting, authStatus, isValid, validationErrors, supportsLimitOrder, kycRequired, needsKyc, needsSetup, onSetupRequired, kycUrl, totalShares, activeOrderShares, availableShares, isAvailableLoading, precision, expirationEnabled, expirationPreset, customDuration, customDurationUnit, oddsFormatter, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onSellAll, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: SellFormUIProps): react_jsx_runtime.JSX.Element;
877
939
 
878
940
  interface SellFormWidgetProps {
879
941
  event?: PredictEvent;
@@ -896,8 +958,10 @@ interface SellFormWidgetProps {
896
958
  onSetupRequired?: () => void;
897
959
  /** Called after a sell order completes successfully (e.g. to close a modal). */
898
960
  onSuccess?: () => void;
961
+ /** Optional formatter for display-only odds/price labels. */
962
+ oddsFormatter?: OddsFormatter;
899
963
  }
900
- declare function SellFormWidget({ event, market, variant, initialOutcome, chain, slippageBps, onOutcomeChange, onSetupRequired, onSuccess, }: SellFormWidgetProps): react_jsx_runtime.JSX.Element;
964
+ declare function SellFormWidget({ event, market, variant, initialOutcome, chain, slippageBps, onOutcomeChange, onSetupRequired, onSuccess, oddsFormatter, }: SellFormWidgetProps): react_jsx_runtime.JSX.Element;
901
965
 
902
966
  type PredictRedeemModalParams = {
903
967
  event: PredictEvent;
@@ -1366,4 +1430,4 @@ type PredictWalletProviderProps = PropsWithChildren<{
1366
1430
  }>;
1367
1431
  declare function PredictWalletProvider({ pollingInterval, enabled, enableKalshi, children, }: PredictWalletProviderProps): react_jsx_runtime.JSX.Element;
1368
1432
 
1369
- export { CHART_RANGE_DURATION, CHART_RANGE_PERIOD, CHART_RANGE_SAMPLE_INTERVAL, CandlestickPeriod, type CandlestickPeriodType, CategoriesSkeleton, CategoriesUI, type CategoriesUIProps, CategoriesWidget, type CategoriesWidgetProps, type CategoryItem, type CategoryListItem, type CategoryTagItem, ChartRange, type ChartRangeType, CommentItemUI, type CommentItemUIProps, DEFAULT_CHART_RANGE, DEFAULT_FILTER_STATE, DEFAULT_PAGE_SIZE, DEFAULT_PRICE_HISTORY_INTERVAL, type DepthLevel, type DepthSlot, type DurationUnit, EventCommentsWidget, type EventCommentsWidgetProps, EventDetailPage, type EventDetailPageProps, EventDetailSkeleton, type EventDetailSkeletonProps, EventDetailUI, type EventDetailUIProps, EventDetailWidget, type EventDetailWidgetProps, EventItem, type EventItemProps, EventMarketDepthChartUI, type EventMarketDepthChartUIProps, EventMarketDetailWidget, type EventMarketDetailWidgetProps, EventPriceChart, type EventPriceChartProps, type EventsFilterState, EventsFilterUI, type EventsFilterUIProps, EventsHero, type EventsHeroProps, EventsPage, type EventsPageProps, EventsPageSkeleton, type EventsPageSkeletonProps, EventsSkeleton, type EventsSkeletonProps, EventsToolbarUI, type EventsToolbarUIProps, EventsUI, type EventsUIProps, EventsWidget, type EventsWidgetProps, type ExpirationPreset, KycModal, type KycModalProps, MAX_PRICE_HISTORY_MARKETS, MatchGroupCard, type MatchGroupCardProps, MatchMarketCard, type MatchMarketCardProps, MatchesFilterBar, type MatchesFilterBarProps, MatchesHero, type MatchesHeroProps, type MatchesHeroStats, MatchesPage, type MatchesPageProps, MatchesStatsBar, type MatchesStatsBarProps, MatchesWidget, type MatchesWidgetProps, type MatchesWidgetRef, ORDER_MAX_PRICE, ORDER_MIN_PRICE, ORDER_MIN_QUANTITY, ORDER_MIN_USDC, ORDER_PRICE_STEP, type OrderType, PREDICT_REDEEM_MODAL_ID, PREDICT_SEARCH_MODAL_ID, PREDICT_SELL_MODAL_ID, PREDICT_TRADE_MODAL_ID, PRICE_HISTORY_SAMPLE_INTERVAL, PredictRedeemModal, type PredictRedeemModalParams, type PredictRedeemModalResult, PredictSearchModal, type PredictSearchModalParams, type PredictSearchModalResult, PredictSellModal, type PredictSellModalParams, type PredictSellModalResult, PredictTradeModal, type PredictTradeModalParams, type PredictTradeModalResult, type PredictWalletContextValue, PredictWalletProvider, type PredictWalletProviderProps, PriceHistoryInterval, type PriceHistoryIntervalType, ProfilePage, type ProfilePageProps, RedeemFormWidget, type RedeemFormWidgetProps, SORT_PRESETS, STATIC_CATEGORIES, SearchEventsButton, type SearchEventsButtonProps, SearchHistoryUI, type SearchHistoryUIProps, SearchHistoryWidget, type SearchHistoryWidgetProps, SearchInputUI, type SearchInputUIProps, SearchResultItemUI, type SearchResultItemUIProps, SearchResultListWidget, type SearchResultListWidgetProps, SearchWidget, type SearchWidgetProps, SellFormUI, type SellFormUIProps, SellFormWidget, type SellFormWidgetProps, SetupModal, type SetupModalProps, SimilarEventCard, type SimilarEventCardProps, SimilarEventsSection, type SimilarEventsSectionProps, type SortPreset, SourceBadge, type SourceBadgeProps, SpreadIndicator, type SpreadIndicatorProps, type TagItem, type TagSlugSelection, TradeFormSkeleton, TradeFormUI, type TradeFormUIProps, type TradeFormValidation, TradeFormWidget, type TradeFormWidgetProps, type TradeOutcome, type TradeSide, type UseEventDetailParams, type UseEventsInfiniteParams, type UseEventsInfiniteResult, type UseSearchResultListScriptParams, type UseSearchScriptParams, type UseSellFormParams, type UseSellFormResult, type UseTradeFormParams, type UseTradeFormResult, UserActivitySection, type UserActivitySectionProps, countActiveFilters, fireCelebration, floorToDecimals, formatKMB, formatShares, getSourceMeta, parsePolymarketError, resolveExpiration, roundToTickSize, useEventDetail, useEventsInfinite, usePredictSearchHistory, usePredictWallet, useSearchResultListScript, useSearchScript, useSellForm, useTradeForm };
1433
+ export { CHART_RANGE_DURATION, CHART_RANGE_PERIOD, CHART_RANGE_SAMPLE_INTERVAL, CandlestickPeriod, type CandlestickPeriodType, CategoriesSkeleton, CategoriesUI, type CategoriesUIProps, CategoriesWidget, type CategoriesWidgetProps, type CategoryItem, type CategoryListItem, type CategoryTagItem, ChartRange, type ChartRangeType, CommentItemUI, type CommentItemUIProps, type ComputeMaxBuyAmountParams, DEFAULT_CHART_RANGE, DEFAULT_FILTER_STATE, DEFAULT_PAGE_SIZE, DEFAULT_PRICE_HISTORY_INTERVAL, type DepthLevel, type DepthSlot, type DurationUnit, type EstimatePolymarketBuyFeeParams, EventCommentsWidget, type EventCommentsWidgetProps, EventDetailPage, type EventDetailPageProps, EventDetailSkeleton, type EventDetailSkeletonProps, EventDetailUI, type EventDetailUIProps, EventDetailWidget, type EventDetailWidgetProps, EventItem, type EventItemProps, EventMarketDepthChartUI, type EventMarketDepthChartUIProps, EventMarketDetailWidget, type EventMarketDetailWidgetProps, EventPriceChart, type EventPriceChartProps, type EventsFilterState, EventsFilterUI, type EventsFilterUIProps, EventsHero, type EventsHeroProps, EventsPage, type EventsPageProps, EventsPageSkeleton, type EventsPageSkeletonProps, EventsSkeleton, type EventsSkeletonProps, EventsToolbarUI, type EventsToolbarUIProps, EventsUI, type EventsUIProps, EventsWidget, type EventsWidgetProps, type ExpirationPreset, KycModal, type KycModalProps, MAX_PRICE_HISTORY_MARKETS, MatchGroupCard, type MatchGroupCardProps, MatchMarketCard, type MatchMarketCardProps, MatchesFilterBar, type MatchesFilterBarProps, MatchesHero, type MatchesHeroProps, type MatchesHeroStats, MatchesPage, type MatchesPageProps, MatchesStatsBar, type MatchesStatsBarProps, MatchesWidget, type MatchesWidgetProps, type MatchesWidgetRef, ORDER_MAX_PRICE, ORDER_MIN_PRICE, ORDER_MIN_QUANTITY, ORDER_MIN_USDC, ORDER_PRICE_STEP, type OddsFormatter, type OrderType, PREDICT_REDEEM_MODAL_ID, PREDICT_SEARCH_MODAL_ID, PREDICT_SELL_MODAL_ID, PREDICT_TRADE_MODAL_ID, PRICE_HISTORY_SAMPLE_INTERVAL, PredictRedeemModal, type PredictRedeemModalParams, type PredictRedeemModalResult, PredictSearchModal, type PredictSearchModalParams, type PredictSearchModalResult, PredictSellModal, type PredictSellModalParams, type PredictSellModalResult, PredictTradeModal, type PredictTradeModalParams, type PredictTradeModalResult, type PredictWalletContextValue, PredictWalletProvider, type PredictWalletProviderProps, PriceHistoryInterval, type PriceHistoryIntervalType, ProfilePage, type ProfilePageProps, RedeemFormWidget, type RedeemFormWidgetProps, SORT_PRESETS, STATIC_CATEGORIES, SearchEventsButton, type SearchEventsButtonProps, SearchHistoryUI, type SearchHistoryUIProps, SearchHistoryWidget, type SearchHistoryWidgetProps, SearchInputUI, type SearchInputUIProps, SearchResultItemUI, type SearchResultItemUIProps, SearchResultListWidget, type SearchResultListWidgetProps, SearchWidget, type SearchWidgetProps, SellFormUI, type SellFormUIProps, SellFormWidget, type SellFormWidgetProps, SetupModal, type SetupModalProps, SimilarEventCard, type SimilarEventCardProps, SimilarEventsSection, type SimilarEventsSectionProps, type SortPreset, SourceBadge, type SourceBadgeProps, SpreadIndicator, type SpreadIndicatorProps, type TagItem, type TagSlugSelection, TradeFormSkeleton, TradeFormUI, type TradeFormUIProps, type TradeFormValidation, TradeFormWidget, type TradeFormWidgetProps, type TradeOutcome, type TradeSide, type UseEventDetailParams, type UseEventsInfiniteParams, type UseEventsInfiniteResult, type UseSearchResultListScriptParams, type UseSearchScriptParams, type UseSellFormParams, type UseSellFormResult, type UseTradeFormParams, type UseTradeFormResult, UserActivitySection, type UserActivitySectionProps, computeMaxBuyAmount, countActiveFilters, estimatePolymarketBuyFee, fireCelebration, floorToDecimals, formatKMB, formatShares, getSourceMeta, parsePolymarketError, polymarketFeeFactor, resolveExpiration, roundToTickSize, useEventDetail, useEventsInfinite, usePredictSearchHistory, usePredictWallet, useSearchResultListScript, useSearchScript, useSellForm, useTradeForm };
package/dist/index.d.ts CHANGED
@@ -298,6 +298,7 @@ type TradeSide = "buy" | "sell";
298
298
  type OrderType = "market" | "limit";
299
299
  type ExpirationPreset = "5m" | "1h" | "12h" | "24h" | "eod" | "custom";
300
300
  type DurationUnit = "minutes" | "hours" | "days";
301
+ type OddsFormatter = (price: number) => string;
301
302
  interface TradeFormValidation {
302
303
  isValid: boolean;
303
304
  errors: string[];
@@ -311,6 +312,49 @@ declare function roundToTickSize(price: number, tickSize: string): number;
311
312
  * Floor a number to the given number of decimal places (never rounds up).
312
313
  */
313
314
  declare function floorToDecimals(value: number, decimals: number): number;
315
+ /**
316
+ * Price-dependent factor in Polymarket's taker-fee formula:
317
+ * `min(1, (1 − price) / price)` (equivalently `min(price, 1−price) / price`).
318
+ * Capped at 1 (the worst case, reached when `price ≤ 0.5`). Falls back to the
319
+ * worst case (1) when the price is unknown/degenerate.
320
+ */
321
+ declare function polymarketFeeFactor(pricePerShare: number): number;
322
+ interface ComputeMaxBuyAmountParams {
323
+ source: string;
324
+ usdcBalance: number | null | undefined;
325
+ safetyBufferUsd?: number;
326
+ /**
327
+ * Polymarket base fee in basis points (from `GET /fee-rate/{token_id}`).
328
+ * Polymarket reserves a taker fee on top of the order amount, so the largest
329
+ * spendable amount must leave room for it. Defaults to 0 (fee-free markets).
330
+ */
331
+ feeRateBps?: number;
332
+ /**
333
+ * Per-share price (0–1) used to price the fee precisely. Omit to reserve the
334
+ * worst-case fee (factor = 1). Safe for buys: adverse fills push the price up,
335
+ * which only lowers the fee factor.
336
+ */
337
+ pricePerShare?: number;
338
+ }
339
+ declare function computeMaxBuyAmount({ source, usdcBalance, safetyBufferUsd, feeRateBps, pricePerShare, }: ComputeMaxBuyAmountParams): number;
340
+ interface EstimatePolymarketBuyFeeParams {
341
+ /** USDC amount the user intends to spend. */
342
+ usdcAmount: number;
343
+ /** Per-share execution price (0–1). */
344
+ pricePerShare: number;
345
+ /** Base fee in basis points (from `GET /fee-rate/{token_id}`). */
346
+ feeRateBps: number;
347
+ }
348
+ /**
349
+ * Estimate the Polymarket taker fee (USDC) for a buy, mirroring Polymarket's
350
+ * fee formula:
351
+ *
352
+ * fee = baseFeeRate × min(price, 1 − price) × shares, shares = amount / price
353
+ *
354
+ * which simplifies to `amount × r × min(1, (1 − price) / price)`. When the
355
+ * price is unknown/degenerate we fall back to the worst case (`amount × r`).
356
+ */
357
+ declare function estimatePolymarketBuyFee({ usdcAmount, pricePerShare, feeRateBps, }: EstimatePolymarketBuyFeeParams): number;
314
358
  /**
315
359
  * Parse a Polymarket CLOB API error message into a user-friendly string.
316
360
  * Falls back to the raw message (with order-hash stripped) if no pattern matches.
@@ -355,6 +399,11 @@ interface UseTradeFormResult {
355
399
  limitPrice: number;
356
400
  shares: number;
357
401
  estimatedCost: number;
402
+ /**
403
+ * Estimated Polymarket taker fee (USDC) reserved on top of the order amount.
404
+ * 0 for fee-free markets and for non-Polymarket sources.
405
+ */
406
+ estimatedFee: number;
358
407
  potentialPayout: number;
359
408
  potentialProfit: number;
360
409
  /**
@@ -363,6 +412,8 @@ interface UseTradeFormResult {
363
412
  */
364
413
  pricePerShare: number;
365
414
  usdcBalance: number | null;
415
+ maxBuyAmount: number;
416
+ spendableUsdcBalance: number | null;
366
417
  isBalanceLoading: boolean;
367
418
  isMarketDataLoading: boolean;
368
419
  isSubmitting: boolean;
@@ -529,8 +580,10 @@ interface EventMarketDetailWidgetProps {
529
580
  * `h-[262px]` so the widget can fill a flexible parent (e.g. `h-full`).
530
581
  */
531
582
  className?: string;
583
+ /** Optional formatter for display-only orderbook price labels. */
584
+ oddsFormatter?: OddsFormatter;
532
585
  }
533
- declare function EventMarketDetailWidget({ market, outcome, onTradeAction, initialViewMode, className, }: EventMarketDetailWidgetProps): react_jsx_runtime.JSX.Element;
586
+ declare function EventMarketDetailWidget({ market, outcome, onTradeAction, initialViewMode, className, oddsFormatter, }: EventMarketDetailWidgetProps): react_jsx_runtime.JSX.Element;
534
587
 
535
588
  interface EventPriceChartProps {
536
589
  event: PredictEvent;
@@ -688,6 +741,8 @@ interface TradeFormUIProps {
688
741
  limitPrice: number;
689
742
  shares: number;
690
743
  estimatedCost: number;
744
+ /** Estimated Polymarket taker fee (USDC). 0 hides the fee row. */
745
+ estimatedFee?: number;
691
746
  potentialPayout: number;
692
747
  potentialProfit: number;
693
748
  isMarketDataLoading: boolean;
@@ -703,6 +758,7 @@ interface TradeFormUIProps {
703
758
  /** Invoked when the user presses submit while balance is insufficient. */
704
759
  onInsufficientBalance?: () => void;
705
760
  supportsLimitOrder: boolean;
761
+ maxBuyAmount?: number;
706
762
  kycRequired: boolean;
707
763
  /** True when the user must complete KYC before the deposit flow is allowed. */
708
764
  needsKyc: boolean;
@@ -713,6 +769,8 @@ interface TradeFormUIProps {
713
769
  expirationPreset: ExpirationPreset;
714
770
  customDuration: number;
715
771
  customDurationUnit: DurationUnit;
772
+ /** Optional formatter for display-only odds/price labels. Defaults to cents/probability text. */
773
+ oddsFormatter?: OddsFormatter;
716
774
  onOutcomeChange: (outcome: TradeOutcome) => void;
717
775
  onOrderTypeChange: (type: OrderType) => void;
718
776
  onQuantityChange: (quantity: number) => void;
@@ -723,7 +781,7 @@ interface TradeFormUIProps {
723
781
  onCustomDurationUnitChange: (u: DurationUnit) => void;
724
782
  onSubmit: () => void;
725
783
  }
726
- declare function TradeFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, shares, potentialProfit, potentialPayout, estimatedCost, usdcBalance, isBalanceLoading, isMarketDataLoading, isSubmitting, authStatus, isValid, validationErrors, isInsufficientBalance, onInsufficientBalance, supportsLimitOrder, kycRequired, needsKyc, needsSetup, kycUrl, expirationEnabled, expirationPreset, customDuration, customDurationUnit, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: TradeFormUIProps): react_jsx_runtime.JSX.Element;
784
+ declare function TradeFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, shares, potentialProfit, potentialPayout, estimatedCost, estimatedFee, usdcBalance, isBalanceLoading, isMarketDataLoading, isSubmitting, authStatus, isValid, validationErrors, isInsufficientBalance, onInsufficientBalance, supportsLimitOrder, maxBuyAmount, kycRequired, needsKyc, needsSetup, kycUrl, expirationEnabled, expirationPreset, customDuration, customDurationUnit, oddsFormatter, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: TradeFormUIProps): react_jsx_runtime.JSX.Element;
727
785
 
728
786
  interface TradeFormWidgetProps {
729
787
  event?: PredictEvent;
@@ -744,8 +802,10 @@ interface TradeFormWidgetProps {
744
802
  onInsufficientBalance?: (source: ProviderSource) => void;
745
803
  /** Called whenever the user switches between YES and NO. */
746
804
  onOutcomeChange?: (outcome: TradeOutcome) => void;
805
+ /** Optional formatter for display-only odds/price labels. */
806
+ oddsFormatter?: OddsFormatter;
747
807
  }
748
- declare function TradeFormWidget({ event, market, variant, initialOutcome, chain, slippageBps, onInsufficientBalance, onOutcomeChange, }: TradeFormWidgetProps): react_jsx_runtime.JSX.Element;
808
+ declare function TradeFormWidget({ event, market, variant, initialOutcome, chain, slippageBps, onInsufficientBalance, onOutcomeChange, oddsFormatter, }: TradeFormWidgetProps): react_jsx_runtime.JSX.Element;
749
809
 
750
810
  type PredictSellModalParams = {
751
811
  event: PredictEvent;
@@ -862,6 +922,8 @@ interface SellFormUIProps {
862
922
  expirationPreset: ExpirationPreset;
863
923
  customDuration: number;
864
924
  customDurationUnit: DurationUnit;
925
+ /** Optional formatter for display-only odds/price labels. Defaults to cents/probability text. */
926
+ oddsFormatter?: OddsFormatter;
865
927
  onOutcomeChange: (outcome: TradeOutcome) => void;
866
928
  onOrderTypeChange: (type: OrderType) => void;
867
929
  onQuantityChange: (quantity: number) => void;
@@ -873,7 +935,7 @@ interface SellFormUIProps {
873
935
  onCustomDurationUnitChange: (u: DurationUnit) => void;
874
936
  onSubmit: () => void;
875
937
  }
876
- declare function SellFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, estimatedReturn, isMarketDataLoading, isSubmitting, authStatus, isValid, validationErrors, supportsLimitOrder, kycRequired, needsKyc, needsSetup, onSetupRequired, kycUrl, totalShares, activeOrderShares, availableShares, isAvailableLoading, precision, expirationEnabled, expirationPreset, customDuration, customDurationUnit, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onSellAll, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: SellFormUIProps): react_jsx_runtime.JSX.Element;
938
+ declare function SellFormUI({ event, market, variant, outcome, orderType, quantity, limitPrice, estimatedReturn, isMarketDataLoading, isSubmitting, authStatus, isValid, validationErrors, supportsLimitOrder, kycRequired, needsKyc, needsSetup, onSetupRequired, kycUrl, totalShares, activeOrderShares, availableShares, isAvailableLoading, precision, expirationEnabled, expirationPreset, customDuration, customDurationUnit, oddsFormatter, onOutcomeChange, onOrderTypeChange, onQuantityChange, onLimitPriceChange, onSellAll, onExpirationEnabledChange, onExpirationPresetChange, onCustomDurationChange, onCustomDurationUnitChange, onSubmit, }: SellFormUIProps): react_jsx_runtime.JSX.Element;
877
939
 
878
940
  interface SellFormWidgetProps {
879
941
  event?: PredictEvent;
@@ -896,8 +958,10 @@ interface SellFormWidgetProps {
896
958
  onSetupRequired?: () => void;
897
959
  /** Called after a sell order completes successfully (e.g. to close a modal). */
898
960
  onSuccess?: () => void;
961
+ /** Optional formatter for display-only odds/price labels. */
962
+ oddsFormatter?: OddsFormatter;
899
963
  }
900
- declare function SellFormWidget({ event, market, variant, initialOutcome, chain, slippageBps, onOutcomeChange, onSetupRequired, onSuccess, }: SellFormWidgetProps): react_jsx_runtime.JSX.Element;
964
+ declare function SellFormWidget({ event, market, variant, initialOutcome, chain, slippageBps, onOutcomeChange, onSetupRequired, onSuccess, oddsFormatter, }: SellFormWidgetProps): react_jsx_runtime.JSX.Element;
901
965
 
902
966
  type PredictRedeemModalParams = {
903
967
  event: PredictEvent;
@@ -1366,4 +1430,4 @@ type PredictWalletProviderProps = PropsWithChildren<{
1366
1430
  }>;
1367
1431
  declare function PredictWalletProvider({ pollingInterval, enabled, enableKalshi, children, }: PredictWalletProviderProps): react_jsx_runtime.JSX.Element;
1368
1432
 
1369
- export { CHART_RANGE_DURATION, CHART_RANGE_PERIOD, CHART_RANGE_SAMPLE_INTERVAL, CandlestickPeriod, type CandlestickPeriodType, CategoriesSkeleton, CategoriesUI, type CategoriesUIProps, CategoriesWidget, type CategoriesWidgetProps, type CategoryItem, type CategoryListItem, type CategoryTagItem, ChartRange, type ChartRangeType, CommentItemUI, type CommentItemUIProps, DEFAULT_CHART_RANGE, DEFAULT_FILTER_STATE, DEFAULT_PAGE_SIZE, DEFAULT_PRICE_HISTORY_INTERVAL, type DepthLevel, type DepthSlot, type DurationUnit, EventCommentsWidget, type EventCommentsWidgetProps, EventDetailPage, type EventDetailPageProps, EventDetailSkeleton, type EventDetailSkeletonProps, EventDetailUI, type EventDetailUIProps, EventDetailWidget, type EventDetailWidgetProps, EventItem, type EventItemProps, EventMarketDepthChartUI, type EventMarketDepthChartUIProps, EventMarketDetailWidget, type EventMarketDetailWidgetProps, EventPriceChart, type EventPriceChartProps, type EventsFilterState, EventsFilterUI, type EventsFilterUIProps, EventsHero, type EventsHeroProps, EventsPage, type EventsPageProps, EventsPageSkeleton, type EventsPageSkeletonProps, EventsSkeleton, type EventsSkeletonProps, EventsToolbarUI, type EventsToolbarUIProps, EventsUI, type EventsUIProps, EventsWidget, type EventsWidgetProps, type ExpirationPreset, KycModal, type KycModalProps, MAX_PRICE_HISTORY_MARKETS, MatchGroupCard, type MatchGroupCardProps, MatchMarketCard, type MatchMarketCardProps, MatchesFilterBar, type MatchesFilterBarProps, MatchesHero, type MatchesHeroProps, type MatchesHeroStats, MatchesPage, type MatchesPageProps, MatchesStatsBar, type MatchesStatsBarProps, MatchesWidget, type MatchesWidgetProps, type MatchesWidgetRef, ORDER_MAX_PRICE, ORDER_MIN_PRICE, ORDER_MIN_QUANTITY, ORDER_MIN_USDC, ORDER_PRICE_STEP, type OrderType, PREDICT_REDEEM_MODAL_ID, PREDICT_SEARCH_MODAL_ID, PREDICT_SELL_MODAL_ID, PREDICT_TRADE_MODAL_ID, PRICE_HISTORY_SAMPLE_INTERVAL, PredictRedeemModal, type PredictRedeemModalParams, type PredictRedeemModalResult, PredictSearchModal, type PredictSearchModalParams, type PredictSearchModalResult, PredictSellModal, type PredictSellModalParams, type PredictSellModalResult, PredictTradeModal, type PredictTradeModalParams, type PredictTradeModalResult, type PredictWalletContextValue, PredictWalletProvider, type PredictWalletProviderProps, PriceHistoryInterval, type PriceHistoryIntervalType, ProfilePage, type ProfilePageProps, RedeemFormWidget, type RedeemFormWidgetProps, SORT_PRESETS, STATIC_CATEGORIES, SearchEventsButton, type SearchEventsButtonProps, SearchHistoryUI, type SearchHistoryUIProps, SearchHistoryWidget, type SearchHistoryWidgetProps, SearchInputUI, type SearchInputUIProps, SearchResultItemUI, type SearchResultItemUIProps, SearchResultListWidget, type SearchResultListWidgetProps, SearchWidget, type SearchWidgetProps, SellFormUI, type SellFormUIProps, SellFormWidget, type SellFormWidgetProps, SetupModal, type SetupModalProps, SimilarEventCard, type SimilarEventCardProps, SimilarEventsSection, type SimilarEventsSectionProps, type SortPreset, SourceBadge, type SourceBadgeProps, SpreadIndicator, type SpreadIndicatorProps, type TagItem, type TagSlugSelection, TradeFormSkeleton, TradeFormUI, type TradeFormUIProps, type TradeFormValidation, TradeFormWidget, type TradeFormWidgetProps, type TradeOutcome, type TradeSide, type UseEventDetailParams, type UseEventsInfiniteParams, type UseEventsInfiniteResult, type UseSearchResultListScriptParams, type UseSearchScriptParams, type UseSellFormParams, type UseSellFormResult, type UseTradeFormParams, type UseTradeFormResult, UserActivitySection, type UserActivitySectionProps, countActiveFilters, fireCelebration, floorToDecimals, formatKMB, formatShares, getSourceMeta, parsePolymarketError, resolveExpiration, roundToTickSize, useEventDetail, useEventsInfinite, usePredictSearchHistory, usePredictWallet, useSearchResultListScript, useSearchScript, useSellForm, useTradeForm };
1433
+ export { CHART_RANGE_DURATION, CHART_RANGE_PERIOD, CHART_RANGE_SAMPLE_INTERVAL, CandlestickPeriod, type CandlestickPeriodType, CategoriesSkeleton, CategoriesUI, type CategoriesUIProps, CategoriesWidget, type CategoriesWidgetProps, type CategoryItem, type CategoryListItem, type CategoryTagItem, ChartRange, type ChartRangeType, CommentItemUI, type CommentItemUIProps, type ComputeMaxBuyAmountParams, DEFAULT_CHART_RANGE, DEFAULT_FILTER_STATE, DEFAULT_PAGE_SIZE, DEFAULT_PRICE_HISTORY_INTERVAL, type DepthLevel, type DepthSlot, type DurationUnit, type EstimatePolymarketBuyFeeParams, EventCommentsWidget, type EventCommentsWidgetProps, EventDetailPage, type EventDetailPageProps, EventDetailSkeleton, type EventDetailSkeletonProps, EventDetailUI, type EventDetailUIProps, EventDetailWidget, type EventDetailWidgetProps, EventItem, type EventItemProps, EventMarketDepthChartUI, type EventMarketDepthChartUIProps, EventMarketDetailWidget, type EventMarketDetailWidgetProps, EventPriceChart, type EventPriceChartProps, type EventsFilterState, EventsFilterUI, type EventsFilterUIProps, EventsHero, type EventsHeroProps, EventsPage, type EventsPageProps, EventsPageSkeleton, type EventsPageSkeletonProps, EventsSkeleton, type EventsSkeletonProps, EventsToolbarUI, type EventsToolbarUIProps, EventsUI, type EventsUIProps, EventsWidget, type EventsWidgetProps, type ExpirationPreset, KycModal, type KycModalProps, MAX_PRICE_HISTORY_MARKETS, MatchGroupCard, type MatchGroupCardProps, MatchMarketCard, type MatchMarketCardProps, MatchesFilterBar, type MatchesFilterBarProps, MatchesHero, type MatchesHeroProps, type MatchesHeroStats, MatchesPage, type MatchesPageProps, MatchesStatsBar, type MatchesStatsBarProps, MatchesWidget, type MatchesWidgetProps, type MatchesWidgetRef, ORDER_MAX_PRICE, ORDER_MIN_PRICE, ORDER_MIN_QUANTITY, ORDER_MIN_USDC, ORDER_PRICE_STEP, type OddsFormatter, type OrderType, PREDICT_REDEEM_MODAL_ID, PREDICT_SEARCH_MODAL_ID, PREDICT_SELL_MODAL_ID, PREDICT_TRADE_MODAL_ID, PRICE_HISTORY_SAMPLE_INTERVAL, PredictRedeemModal, type PredictRedeemModalParams, type PredictRedeemModalResult, PredictSearchModal, type PredictSearchModalParams, type PredictSearchModalResult, PredictSellModal, type PredictSellModalParams, type PredictSellModalResult, PredictTradeModal, type PredictTradeModalParams, type PredictTradeModalResult, type PredictWalletContextValue, PredictWalletProvider, type PredictWalletProviderProps, PriceHistoryInterval, type PriceHistoryIntervalType, ProfilePage, type ProfilePageProps, RedeemFormWidget, type RedeemFormWidgetProps, SORT_PRESETS, STATIC_CATEGORIES, SearchEventsButton, type SearchEventsButtonProps, SearchHistoryUI, type SearchHistoryUIProps, SearchHistoryWidget, type SearchHistoryWidgetProps, SearchInputUI, type SearchInputUIProps, SearchResultItemUI, type SearchResultItemUIProps, SearchResultListWidget, type SearchResultListWidgetProps, SearchWidget, type SearchWidgetProps, SellFormUI, type SellFormUIProps, SellFormWidget, type SellFormWidgetProps, SetupModal, type SetupModalProps, SimilarEventCard, type SimilarEventCardProps, SimilarEventsSection, type SimilarEventsSectionProps, type SortPreset, SourceBadge, type SourceBadgeProps, SpreadIndicator, type SpreadIndicatorProps, type TagItem, type TagSlugSelection, TradeFormSkeleton, TradeFormUI, type TradeFormUIProps, type TradeFormValidation, TradeFormWidget, type TradeFormWidgetProps, type TradeOutcome, type TradeSide, type UseEventDetailParams, type UseEventsInfiniteParams, type UseEventsInfiniteResult, type UseSearchResultListScriptParams, type UseSearchScriptParams, type UseSellFormParams, type UseSellFormResult, type UseTradeFormParams, type UseTradeFormResult, UserActivitySection, type UserActivitySectionProps, computeMaxBuyAmount, countActiveFilters, estimatePolymarketBuyFee, fireCelebration, floorToDecimals, formatKMB, formatShares, getSourceMeta, parsePolymarketError, polymarketFeeFactor, resolveExpiration, roundToTickSize, useEventDetail, useEventsInfinite, usePredictSearchHistory, usePredictWallet, useSearchResultListScript, useSearchScript, useSellForm, useTradeForm };