@liberfi.io/ui-portfolio 0.1.161 → 2.0.0

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/README.md CHANGED
@@ -94,6 +94,17 @@ function useAccountInfo(): UseAccountInfoResult;
94
94
  | `holdings` | `SpotHolding[]` | User's spot holdings (sorted by value desc) |
95
95
  | `isHoldingsLoading` | `boolean` | Whether holdings query is loading |
96
96
 
97
+ ### Components — Portfolio (Phase 3)
98
+
99
+ Portfolio widgets introduced alongside the Phase 3 server migration. Every script calls `@liberfi.io/react` hooks directly and never touches `@chainstream-io/sdk`; the UI layers are pure presentational tables driven by props. All three widgets accept a `chain` + `address` (wallet address) pair and manage their own cursor-pagination state.
100
+
101
+ | Export | Kind | Description |
102
+ | ------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
103
+ | `PortfolioActivitiesWidget` | Widget | Wallet activities table (Phase 3 `/v2/trade/{chain}/activities`) with `sortBy` (`timestamp` / `totalUsd`), type filter, trader tags, and gas fee. |
104
+ | `PortfolioNetWorthTokensWidget` | Widget | Net-worth-by-token holdings table (Phase 3 `/v2/wallet/{chain}/{wallet}/net-worth/tokens`) with `avgCostUsd`, wallet tags, and last-active-at. |
105
+ | `PortfolioPnlDetailsWidget` | Widget | Per-token PnL details (Phase 3 `/v2/wallet/{chain}/{wallet}/pnl-details`) with `resolution` / `positionState` / `sortBy` selectors and new fields (`isClosed`, `firstBuyAt`, `lastSellAt`). |
106
+ | `TagBadge` / `TagBadgeList` | UI | Shared classification chip primitive used across the Phase 3 widgets. |
107
+
97
108
  ### Other exports
98
109
 
99
110
  The package also exports portfolio page components (`PortfolioPageWidget`, `usePortfolioPage`, etc.), holdings, hooks (`useWalletSummary`, `useOverviewQuery`, etc.), providers, contexts, and types. See `src/index.ts` and `src/components/index.tsx` for the full list.
@@ -137,8 +148,29 @@ Omit callbacks to hide the corresponding UI elements:
137
148
  <AccountInfoWidget />
138
149
  ```
139
150
 
151
+ ### Composing the portfolio page
152
+
153
+ ```tsx
154
+ import {
155
+ PortfolioActivitiesWidget,
156
+ PortfolioNetWorthTokensWidget,
157
+ PortfolioPnlDetailsWidget,
158
+ } from "@liberfi.io/ui-portfolio";
159
+
160
+ function PortfolioPage({ chain, address }: { chain: Chain; address: string }) {
161
+ return (
162
+ <div className="flex flex-col gap-6">
163
+ <PortfolioNetWorthTokensWidget chain={chain} address={address} />
164
+ <PortfolioPnlDetailsWidget chain={chain} address={address} />
165
+ <PortfolioActivitiesWidget chain={chain} address={address} />
166
+ </div>
167
+ );
168
+ }
169
+ ```
170
+
140
171
  ## Future Improvements
141
172
 
142
173
  - Optional portfolio context so the account widget can render outside `PortfolioProvider` with placeholder balances.
143
174
  - ARIA and keyboard improvements for the popover trigger.
144
175
  - Perps tab integration when perps positions data is available.
176
+ - Portfolio Phase 3 widgets: add CSV / image export, and support grouped tokens (by chain) for multi-chain wallets.
package/dist/index.d.mts CHANGED
@@ -7,7 +7,7 @@ import { A as AssetTab, C as CurveType, a as CurvePeriod, P as PortfolioQuery, b
7
7
  export { q as CURVE_PERIOD_VALUE, x as ChartDataPointDTO, F as CurvePoint, H as DistributionItem, G as GetPortfolioChartReply, y as GetSpotHoldingsReply, B as GetTradeHistoryReply, r as PerpsPositionSide, J as PerpsTradeRecord, w as PortfolioOverviewDTO, t as PredictionBetStatus, u as PredictionResult, K as PredictionSettledRecord, v as PredictionSource, E as SpotHistoryRecord, s as SpotHistoryType, T as TokenHoldingDTO, z as TradeRecordDTO } from './index-Bq_qim6b.mjs';
8
8
  import * as _tanstack_react_query from '@tanstack/react-query';
9
9
  import { UseQueryOptions } from '@tanstack/react-query';
10
- import { Chain, Portfolio, PortfolioPnl } from '@liberfi.io/types';
10
+ import { API, Activity, Chain, WalletPortfolios, Portfolio, WalletPortfolioPnls, PortfolioPnl } from '@liberfi.io/types';
11
11
 
12
12
  declare global {
13
13
  interface Window {
@@ -16,7 +16,7 @@ declare global {
16
16
  };
17
17
  }
18
18
  }
19
- declare const _default: "0.1.161";
19
+ declare const _default: "2.0.0";
20
20
 
21
21
  /** Action button rendered in the popover action bar. */
22
22
  interface AccountAction {
@@ -296,6 +296,230 @@ interface BatchActionButtonProps {
296
296
  }
297
297
  declare function BatchActionButton({ label, disabled, onClick, }: BatchActionButtonProps): react_jsx_runtime.JSX.Element;
298
298
 
299
+ /**
300
+ * Format the elapsed time between `from` and `now` as a short age string
301
+ * (e.g. "5m", "2h", "3d"). Returns "--" if `from` is unavailable.
302
+ */
303
+ declare function formatAgeShort(from: Date | string | number | undefined, now?: Date | number): string;
304
+ declare function truncateMiddle(input: string | undefined, head?: number, tail?: number): string;
305
+
306
+ interface TagBadgeProps {
307
+ tag: string;
308
+ className?: string;
309
+ }
310
+ /**
311
+ * Classification tag chip used across portfolio widgets (mirrors the
312
+ * `HolderTagBadge` / `TraderTagBadge` palette from `@liberfi.io/ui-tokens`).
313
+ */
314
+ declare function TagBadge({ tag, className }: TagBadgeProps): react_jsx_runtime.JSX.Element;
315
+ interface TagBadgeListProps {
316
+ tags?: Array<string>;
317
+ className?: string;
318
+ max?: number;
319
+ }
320
+ declare function TagBadgeList({ tags, className, max }: TagBadgeListProps): react_jsx_runtime.JSX.Element | null;
321
+
322
+ type PortfolioActivitiesSortBy = API.ActivitiesSortBy;
323
+ type PortfolioActivitiesTypeFilter = "all" | "buy" | "sell";
324
+ interface PortfolioActivitiesProps {
325
+ activities: Array<Activity>;
326
+ isLoading?: boolean;
327
+ sortBy: PortfolioActivitiesSortBy;
328
+ onSortByChange: (sortBy: PortfolioActivitiesSortBy) => void;
329
+ typeFilter?: PortfolioActivitiesTypeFilter;
330
+ onTypeFilterChange?: (t: PortfolioActivitiesTypeFilter) => void;
331
+ onLoadMore?: () => void;
332
+ hasMore?: boolean;
333
+ now?: number;
334
+ /** native token decimals for gas-fee formatting */
335
+ nativeDecimals?: number;
336
+ /** native token symbol (e.g. "SOL") */
337
+ nativeSymbol?: string;
338
+ className?: string;
339
+ onRowClick?: (activity: Activity) => void;
340
+ }
341
+ /**
342
+ * Presentational wallet activities table (Phase 3). Shows per-activity token,
343
+ * side, trader-tags, token-amount, usd-amount, gas-fee and age.
344
+ */
345
+ declare function PortfolioActivities({ activities, isLoading, sortBy, onSortByChange, typeFilter, onTypeFilterChange, onLoadMore, hasMore, now, nativeDecimals, nativeSymbol, className, onRowClick, }: PortfolioActivitiesProps): react_jsx_runtime.JSX.Element;
346
+
347
+ interface UsePortfolioActivitiesScriptParams {
348
+ chain: Chain;
349
+ address: string;
350
+ limit?: number;
351
+ initialSortBy?: PortfolioActivitiesSortBy;
352
+ initialTypeFilter?: PortfolioActivitiesTypeFilter;
353
+ }
354
+ interface UsePortfolioActivitiesScriptResult {
355
+ activities: Array<Activity>;
356
+ isLoading: boolean;
357
+ sortBy: PortfolioActivitiesSortBy;
358
+ setSortBy: (s: PortfolioActivitiesSortBy) => void;
359
+ typeFilter: PortfolioActivitiesTypeFilter;
360
+ setTypeFilter: (t: PortfolioActivitiesTypeFilter) => void;
361
+ hasMore: boolean;
362
+ loadMore: () => void;
363
+ }
364
+ /**
365
+ * Script for the Phase 3 wallet-activities list. Mirrors the semantics of the
366
+ * token-activities list script: cursor pagination with reset on
367
+ * (sortBy / typeFilter / chain / address), plus live prepend when on the
368
+ * default view.
369
+ */
370
+ declare function usePortfolioActivitiesScript({ chain, address, limit, initialSortBy, initialTypeFilter, }: UsePortfolioActivitiesScriptParams): UsePortfolioActivitiesScriptResult;
371
+
372
+ interface PortfolioActivitiesWidgetProps {
373
+ chain: Chain;
374
+ address: string;
375
+ limit?: number;
376
+ initialSortBy?: PortfolioActivitiesSortBy;
377
+ initialTypeFilter?: PortfolioActivitiesTypeFilter;
378
+ nativeDecimals?: number;
379
+ nativeSymbol?: string;
380
+ className?: string;
381
+ onRowClick?: (activity: Activity) => void;
382
+ }
383
+ /**
384
+ * Phase 3 wallet activities widget. Consumes
385
+ * `GET /v2/trade/{chain}/activities?walletAddress=…` via `useWalletActivitiesQuery`.
386
+ */
387
+ declare function PortfolioActivitiesWidget({ chain, address, limit, initialSortBy, initialTypeFilter, nativeDecimals, nativeSymbol, className, onRowClick, }: PortfolioActivitiesWidgetProps): react_jsx_runtime.JSX.Element;
388
+
389
+ interface PortfolioNetWorthTokensProps {
390
+ data?: WalletPortfolios;
391
+ isLoading?: boolean;
392
+ className?: string;
393
+ now?: number;
394
+ onRowClick?: (portfolio: Portfolio) => void;
395
+ onLoadMore?: () => void;
396
+ hasMore?: boolean;
397
+ }
398
+ /**
399
+ * Presentational net-worth-by-token table (Phase 3).
400
+ *
401
+ * Columns:
402
+ * - Token (symbol + truncated address)
403
+ * - Amount (native token)
404
+ * - Value (USD)
405
+ * - Avg cost (USD) — sparse (~0.2% fill)
406
+ * - Tags (wallet-for-token classifications)
407
+ * - Last active
408
+ */
409
+ declare function PortfolioNetWorthTokens({ data, isLoading, className, now, onRowClick, onLoadMore, hasMore, }: PortfolioNetWorthTokensProps): react_jsx_runtime.JSX.Element;
410
+
411
+ interface UsePortfolioNetWorthTokensScriptParams {
412
+ chain: Chain;
413
+ address: string;
414
+ /** page size */
415
+ limit?: number;
416
+ }
417
+ interface UsePortfolioNetWorthTokensScriptResult {
418
+ data?: WalletPortfolios;
419
+ isLoading: boolean;
420
+ hasMore: boolean;
421
+ loadMore: () => void;
422
+ }
423
+ /**
424
+ * Script for the Phase 3 portfolio net-worth-tokens list.
425
+ *
426
+ * Pagination: we accumulate pages into a single `WalletPortfolios` object so
427
+ * the UI can show the full list with infinite-scroll semantics while still
428
+ * carrying the summary fields (`balanceInUsd`, `balanceInNative`) from the
429
+ * first page.
430
+ */
431
+ declare function usePortfolioNetWorthTokensScript({ chain, address, limit, }: UsePortfolioNetWorthTokensScriptParams): UsePortfolioNetWorthTokensScriptResult;
432
+
433
+ interface PortfolioNetWorthTokensWidgetProps {
434
+ chain: Chain;
435
+ address: string;
436
+ limit?: number;
437
+ className?: string;
438
+ onRowClick?: (portfolio: Portfolio) => void;
439
+ }
440
+ /**
441
+ * Phase 3 net-worth-by-token widget. Consumes
442
+ * `GET /v2/wallet/{chain}/{wallet}/net-worth/tokens` via
443
+ * `useWalletPortfoliosQuery` and surfaces the new fields
444
+ * (`isActive`, `avgCostUsd`, `lastActiveAt`, `walletTokenTags`).
445
+ */
446
+ declare function PortfolioNetWorthTokensWidget({ chain, address, limit, className, onRowClick, }: PortfolioNetWorthTokensWidgetProps): react_jsx_runtime.JSX.Element;
447
+
448
+ type PnlResolution = API.WalletPnlResolution;
449
+ type PositionState = API.PositionState;
450
+ type PnlSortBy = API.WalletPnlSortBy;
451
+ interface PortfolioPnlDetailsProps {
452
+ data?: WalletPortfolioPnls;
453
+ isLoading?: boolean;
454
+ resolution: PnlResolution;
455
+ onResolutionChange: (r: PnlResolution) => void;
456
+ positionState: PositionState;
457
+ onPositionStateChange: (p: PositionState) => void;
458
+ sortBy: PnlSortBy;
459
+ onSortByChange: (s: PnlSortBy) => void;
460
+ hasMore?: boolean;
461
+ onLoadMore?: () => void;
462
+ now?: number;
463
+ className?: string;
464
+ onRowClick?: (pnl: PortfolioPnl) => void;
465
+ }
466
+ /**
467
+ * Presentational PnL details table (Phase 3). Shows per-position realized /
468
+ * unrealized / total PnL and the new Phase 3 fields (`isClosed`, `firstBuyAt`,
469
+ * `lastSellAt`). The summary row at the top shows aggregate PnL and win rate.
470
+ */
471
+ declare function PortfolioPnlDetails({ data, isLoading, resolution, onResolutionChange, positionState, onPositionStateChange, sortBy, onSortByChange, hasMore, onLoadMore, now, className, onRowClick, }: PortfolioPnlDetailsProps): react_jsx_runtime.JSX.Element;
472
+
473
+ interface UsePortfolioPnlDetailsScriptParams {
474
+ chain: Chain;
475
+ address: string;
476
+ limit?: number;
477
+ initialResolution?: PnlResolution;
478
+ initialPositionState?: PositionState;
479
+ initialSortBy?: PnlSortBy;
480
+ }
481
+ interface UsePortfolioPnlDetailsScriptResult {
482
+ data?: WalletPortfolioPnls;
483
+ isLoading: boolean;
484
+ resolution: PnlResolution;
485
+ setResolution: (r: PnlResolution) => void;
486
+ positionState: PositionState;
487
+ setPositionState: (p: PositionState) => void;
488
+ sortBy: PnlSortBy;
489
+ setSortBy: (s: PnlSortBy) => void;
490
+ hasMore: boolean;
491
+ loadMore: () => void;
492
+ }
493
+ /**
494
+ * Script for the Phase 3 PnL-details widget.
495
+ *
496
+ * Pagination: accumulates cursor pages into a single `WalletPortfolioPnls`
497
+ * while keeping the header summary from the first page. Any of
498
+ * `resolution` / `positionState` / `sortBy` / `chain` / `address` changing
499
+ * triggers a full reset — the server invalidates cursors on any of these
500
+ * changes.
501
+ */
502
+ declare function usePortfolioPnlDetailsScript({ chain, address, limit, initialResolution, initialPositionState, initialSortBy, }: UsePortfolioPnlDetailsScriptParams): UsePortfolioPnlDetailsScriptResult;
503
+
504
+ interface PortfolioPnlDetailsWidgetProps {
505
+ chain: Chain;
506
+ address: string;
507
+ limit?: number;
508
+ initialResolution?: PnlResolution;
509
+ initialPositionState?: PositionState;
510
+ initialSortBy?: PnlSortBy;
511
+ className?: string;
512
+ onRowClick?: (pnl: PortfolioPnl) => void;
513
+ }
514
+ /**
515
+ * Phase 3 PnL-details widget. Consumes
516
+ * `GET /v2/wallet/{chain}/{wallet}/pnl-details` via
517
+ * `useWalletPortfolioPnlsQuery` and renders the new fields (`isClosed`,
518
+ * `firstBuyAt`, `lastSellAt`) alongside resolution / positionState / sortBy
519
+ * selectors.
520
+ */
521
+ declare function PortfolioPnlDetailsWidget({ chain, address, limit, initialResolution, initialPositionState, initialSortBy, className, onRowClick, }: PortfolioPnlDetailsWidgetProps): react_jsx_runtime.JSX.Element;
522
+
299
523
  declare const PortfolioClientContext: react.Context<IPortfolioClient | null>;
300
524
 
301
525
  /** Refetch function for wallet summary. */
@@ -453,4 +677,4 @@ declare function computeDistribution(holdings: SpotHolding[]): DistributionData;
453
677
  */
454
678
  declare function formatTime(epochMs: number): string;
455
679
 
456
- export { type AccountAction, AccountInfoUI, type AccountInfoUIProps, AccountInfoWidget, type AccountInfoWidgetProps, AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, AsyncStatus, BalanceRowUI, type BalanceRowUIProps, BatchActionButton, type BatchActionButtonProps, ConfirmDialog, type ConfirmDialogProps, CurveCardUI, type CurveCardUIProps, CurveData, CurvePeriod, CurveQuery, CurveType, DistributionCardUI, type DistributionCardUIProps, DistributionData, HoldingsEmpty, type HoldingsEmptyProps, type HoldingsRenderProps, HoldingsSearch, type HoldingsSearchProps, HoldingsSectionWidget, type HoldingsSectionWidgetProps, HoldingsSubTabs, type HoldingsSubTabsProps, IPortfolioClient, PerpsHistoryData, PerpsHistoryQuery, PerpsPanelUI, type PerpsPanelUIProps, PerpsPosition, PerpsPositionsData, type PerpsSubTab, PortfolioClientContext, PortfolioClientProvider, type PortfolioClientProviderProps, PortfolioContext, type PortfolioContextValue, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, type RefetchWalletSummaryFn, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, type TokenPortfolio, type UseAccountInfoResult, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, type UseWalletPortfoliosParams, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, WalletSummary, computeDistribution, curveDataQueryKey, distributionQueryKey, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, useAccountInfo, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioClient, usePortfolioContext, usePortfolioPage, usePredictionBetsQuery, usePredictionSettledQuery, useRefetchWalletSummary, useSpotHistoryQuery, useSpotHoldingsQuery, useWalletPortfolios, useWalletSummary, _default as version };
680
+ export { type AccountAction, AccountInfoUI, type AccountInfoUIProps, AccountInfoWidget, type AccountInfoWidgetProps, AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, AsyncStatus, BalanceRowUI, type BalanceRowUIProps, BatchActionButton, type BatchActionButtonProps, ConfirmDialog, type ConfirmDialogProps, CurveCardUI, type CurveCardUIProps, CurveData, CurvePeriod, CurveQuery, CurveType, DistributionCardUI, type DistributionCardUIProps, DistributionData, HoldingsEmpty, type HoldingsEmptyProps, type HoldingsRenderProps, HoldingsSearch, type HoldingsSearchProps, HoldingsSectionWidget, type HoldingsSectionWidgetProps, HoldingsSubTabs, type HoldingsSubTabsProps, IPortfolioClient, PerpsHistoryData, PerpsHistoryQuery, PerpsPanelUI, type PerpsPanelUIProps, PerpsPosition, PerpsPositionsData, type PerpsSubTab, type PnlResolution, type PnlSortBy, PortfolioActivities, type PortfolioActivitiesProps, type PortfolioActivitiesSortBy, type PortfolioActivitiesTypeFilter, PortfolioActivitiesWidget, type PortfolioActivitiesWidgetProps, PortfolioClientContext, PortfolioClientProvider, type PortfolioClientProviderProps, PortfolioContext, type PortfolioContextValue, PortfolioNetWorthTokens, type PortfolioNetWorthTokensProps, PortfolioNetWorthTokensWidget, type PortfolioNetWorthTokensWidgetProps, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioPnlDetails, type PortfolioPnlDetailsProps, PortfolioPnlDetailsWidget, type PortfolioPnlDetailsWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, type PositionState, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, type RefetchWalletSummaryFn, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, TagBadge, TagBadgeList, type TagBadgeListProps, type TagBadgeProps, type TokenPortfolio, type UseAccountInfoResult, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioActivitiesScriptParams, type UsePortfolioActivitiesScriptResult, type UsePortfolioNetWorthTokensScriptParams, type UsePortfolioNetWorthTokensScriptResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, type UsePortfolioPnlDetailsScriptParams, type UsePortfolioPnlDetailsScriptResult, type UseWalletPortfoliosParams, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, WalletSummary, computeDistribution, curveDataQueryKey, distributionQueryKey, formatAgeShort, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, truncateMiddle, useAccountInfo, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioActivitiesScript, usePortfolioClient, usePortfolioContext, usePortfolioNetWorthTokensScript, usePortfolioPage, usePortfolioPnlDetailsScript, usePredictionBetsQuery, usePredictionSettledQuery, useRefetchWalletSummary, useSpotHistoryQuery, useSpotHoldingsQuery, useWalletPortfolios, useWalletSummary, _default as version };
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { A as AssetTab, C as CurveType, a as CurvePeriod, P as PortfolioQuery, b
7
7
  export { q as CURVE_PERIOD_VALUE, x as ChartDataPointDTO, F as CurvePoint, H as DistributionItem, G as GetPortfolioChartReply, y as GetSpotHoldingsReply, B as GetTradeHistoryReply, r as PerpsPositionSide, J as PerpsTradeRecord, w as PortfolioOverviewDTO, t as PredictionBetStatus, u as PredictionResult, K as PredictionSettledRecord, v as PredictionSource, E as SpotHistoryRecord, s as SpotHistoryType, T as TokenHoldingDTO, z as TradeRecordDTO } from './index-Bq_qim6b.js';
8
8
  import * as _tanstack_react_query from '@tanstack/react-query';
9
9
  import { UseQueryOptions } from '@tanstack/react-query';
10
- import { Chain, Portfolio, PortfolioPnl } from '@liberfi.io/types';
10
+ import { API, Activity, Chain, WalletPortfolios, Portfolio, WalletPortfolioPnls, PortfolioPnl } from '@liberfi.io/types';
11
11
 
12
12
  declare global {
13
13
  interface Window {
@@ -16,7 +16,7 @@ declare global {
16
16
  };
17
17
  }
18
18
  }
19
- declare const _default: "0.1.161";
19
+ declare const _default: "2.0.0";
20
20
 
21
21
  /** Action button rendered in the popover action bar. */
22
22
  interface AccountAction {
@@ -296,6 +296,230 @@ interface BatchActionButtonProps {
296
296
  }
297
297
  declare function BatchActionButton({ label, disabled, onClick, }: BatchActionButtonProps): react_jsx_runtime.JSX.Element;
298
298
 
299
+ /**
300
+ * Format the elapsed time between `from` and `now` as a short age string
301
+ * (e.g. "5m", "2h", "3d"). Returns "--" if `from` is unavailable.
302
+ */
303
+ declare function formatAgeShort(from: Date | string | number | undefined, now?: Date | number): string;
304
+ declare function truncateMiddle(input: string | undefined, head?: number, tail?: number): string;
305
+
306
+ interface TagBadgeProps {
307
+ tag: string;
308
+ className?: string;
309
+ }
310
+ /**
311
+ * Classification tag chip used across portfolio widgets (mirrors the
312
+ * `HolderTagBadge` / `TraderTagBadge` palette from `@liberfi.io/ui-tokens`).
313
+ */
314
+ declare function TagBadge({ tag, className }: TagBadgeProps): react_jsx_runtime.JSX.Element;
315
+ interface TagBadgeListProps {
316
+ tags?: Array<string>;
317
+ className?: string;
318
+ max?: number;
319
+ }
320
+ declare function TagBadgeList({ tags, className, max }: TagBadgeListProps): react_jsx_runtime.JSX.Element | null;
321
+
322
+ type PortfolioActivitiesSortBy = API.ActivitiesSortBy;
323
+ type PortfolioActivitiesTypeFilter = "all" | "buy" | "sell";
324
+ interface PortfolioActivitiesProps {
325
+ activities: Array<Activity>;
326
+ isLoading?: boolean;
327
+ sortBy: PortfolioActivitiesSortBy;
328
+ onSortByChange: (sortBy: PortfolioActivitiesSortBy) => void;
329
+ typeFilter?: PortfolioActivitiesTypeFilter;
330
+ onTypeFilterChange?: (t: PortfolioActivitiesTypeFilter) => void;
331
+ onLoadMore?: () => void;
332
+ hasMore?: boolean;
333
+ now?: number;
334
+ /** native token decimals for gas-fee formatting */
335
+ nativeDecimals?: number;
336
+ /** native token symbol (e.g. "SOL") */
337
+ nativeSymbol?: string;
338
+ className?: string;
339
+ onRowClick?: (activity: Activity) => void;
340
+ }
341
+ /**
342
+ * Presentational wallet activities table (Phase 3). Shows per-activity token,
343
+ * side, trader-tags, token-amount, usd-amount, gas-fee and age.
344
+ */
345
+ declare function PortfolioActivities({ activities, isLoading, sortBy, onSortByChange, typeFilter, onTypeFilterChange, onLoadMore, hasMore, now, nativeDecimals, nativeSymbol, className, onRowClick, }: PortfolioActivitiesProps): react_jsx_runtime.JSX.Element;
346
+
347
+ interface UsePortfolioActivitiesScriptParams {
348
+ chain: Chain;
349
+ address: string;
350
+ limit?: number;
351
+ initialSortBy?: PortfolioActivitiesSortBy;
352
+ initialTypeFilter?: PortfolioActivitiesTypeFilter;
353
+ }
354
+ interface UsePortfolioActivitiesScriptResult {
355
+ activities: Array<Activity>;
356
+ isLoading: boolean;
357
+ sortBy: PortfolioActivitiesSortBy;
358
+ setSortBy: (s: PortfolioActivitiesSortBy) => void;
359
+ typeFilter: PortfolioActivitiesTypeFilter;
360
+ setTypeFilter: (t: PortfolioActivitiesTypeFilter) => void;
361
+ hasMore: boolean;
362
+ loadMore: () => void;
363
+ }
364
+ /**
365
+ * Script for the Phase 3 wallet-activities list. Mirrors the semantics of the
366
+ * token-activities list script: cursor pagination with reset on
367
+ * (sortBy / typeFilter / chain / address), plus live prepend when on the
368
+ * default view.
369
+ */
370
+ declare function usePortfolioActivitiesScript({ chain, address, limit, initialSortBy, initialTypeFilter, }: UsePortfolioActivitiesScriptParams): UsePortfolioActivitiesScriptResult;
371
+
372
+ interface PortfolioActivitiesWidgetProps {
373
+ chain: Chain;
374
+ address: string;
375
+ limit?: number;
376
+ initialSortBy?: PortfolioActivitiesSortBy;
377
+ initialTypeFilter?: PortfolioActivitiesTypeFilter;
378
+ nativeDecimals?: number;
379
+ nativeSymbol?: string;
380
+ className?: string;
381
+ onRowClick?: (activity: Activity) => void;
382
+ }
383
+ /**
384
+ * Phase 3 wallet activities widget. Consumes
385
+ * `GET /v2/trade/{chain}/activities?walletAddress=…` via `useWalletActivitiesQuery`.
386
+ */
387
+ declare function PortfolioActivitiesWidget({ chain, address, limit, initialSortBy, initialTypeFilter, nativeDecimals, nativeSymbol, className, onRowClick, }: PortfolioActivitiesWidgetProps): react_jsx_runtime.JSX.Element;
388
+
389
+ interface PortfolioNetWorthTokensProps {
390
+ data?: WalletPortfolios;
391
+ isLoading?: boolean;
392
+ className?: string;
393
+ now?: number;
394
+ onRowClick?: (portfolio: Portfolio) => void;
395
+ onLoadMore?: () => void;
396
+ hasMore?: boolean;
397
+ }
398
+ /**
399
+ * Presentational net-worth-by-token table (Phase 3).
400
+ *
401
+ * Columns:
402
+ * - Token (symbol + truncated address)
403
+ * - Amount (native token)
404
+ * - Value (USD)
405
+ * - Avg cost (USD) — sparse (~0.2% fill)
406
+ * - Tags (wallet-for-token classifications)
407
+ * - Last active
408
+ */
409
+ declare function PortfolioNetWorthTokens({ data, isLoading, className, now, onRowClick, onLoadMore, hasMore, }: PortfolioNetWorthTokensProps): react_jsx_runtime.JSX.Element;
410
+
411
+ interface UsePortfolioNetWorthTokensScriptParams {
412
+ chain: Chain;
413
+ address: string;
414
+ /** page size */
415
+ limit?: number;
416
+ }
417
+ interface UsePortfolioNetWorthTokensScriptResult {
418
+ data?: WalletPortfolios;
419
+ isLoading: boolean;
420
+ hasMore: boolean;
421
+ loadMore: () => void;
422
+ }
423
+ /**
424
+ * Script for the Phase 3 portfolio net-worth-tokens list.
425
+ *
426
+ * Pagination: we accumulate pages into a single `WalletPortfolios` object so
427
+ * the UI can show the full list with infinite-scroll semantics while still
428
+ * carrying the summary fields (`balanceInUsd`, `balanceInNative`) from the
429
+ * first page.
430
+ */
431
+ declare function usePortfolioNetWorthTokensScript({ chain, address, limit, }: UsePortfolioNetWorthTokensScriptParams): UsePortfolioNetWorthTokensScriptResult;
432
+
433
+ interface PortfolioNetWorthTokensWidgetProps {
434
+ chain: Chain;
435
+ address: string;
436
+ limit?: number;
437
+ className?: string;
438
+ onRowClick?: (portfolio: Portfolio) => void;
439
+ }
440
+ /**
441
+ * Phase 3 net-worth-by-token widget. Consumes
442
+ * `GET /v2/wallet/{chain}/{wallet}/net-worth/tokens` via
443
+ * `useWalletPortfoliosQuery` and surfaces the new fields
444
+ * (`isActive`, `avgCostUsd`, `lastActiveAt`, `walletTokenTags`).
445
+ */
446
+ declare function PortfolioNetWorthTokensWidget({ chain, address, limit, className, onRowClick, }: PortfolioNetWorthTokensWidgetProps): react_jsx_runtime.JSX.Element;
447
+
448
+ type PnlResolution = API.WalletPnlResolution;
449
+ type PositionState = API.PositionState;
450
+ type PnlSortBy = API.WalletPnlSortBy;
451
+ interface PortfolioPnlDetailsProps {
452
+ data?: WalletPortfolioPnls;
453
+ isLoading?: boolean;
454
+ resolution: PnlResolution;
455
+ onResolutionChange: (r: PnlResolution) => void;
456
+ positionState: PositionState;
457
+ onPositionStateChange: (p: PositionState) => void;
458
+ sortBy: PnlSortBy;
459
+ onSortByChange: (s: PnlSortBy) => void;
460
+ hasMore?: boolean;
461
+ onLoadMore?: () => void;
462
+ now?: number;
463
+ className?: string;
464
+ onRowClick?: (pnl: PortfolioPnl) => void;
465
+ }
466
+ /**
467
+ * Presentational PnL details table (Phase 3). Shows per-position realized /
468
+ * unrealized / total PnL and the new Phase 3 fields (`isClosed`, `firstBuyAt`,
469
+ * `lastSellAt`). The summary row at the top shows aggregate PnL and win rate.
470
+ */
471
+ declare function PortfolioPnlDetails({ data, isLoading, resolution, onResolutionChange, positionState, onPositionStateChange, sortBy, onSortByChange, hasMore, onLoadMore, now, className, onRowClick, }: PortfolioPnlDetailsProps): react_jsx_runtime.JSX.Element;
472
+
473
+ interface UsePortfolioPnlDetailsScriptParams {
474
+ chain: Chain;
475
+ address: string;
476
+ limit?: number;
477
+ initialResolution?: PnlResolution;
478
+ initialPositionState?: PositionState;
479
+ initialSortBy?: PnlSortBy;
480
+ }
481
+ interface UsePortfolioPnlDetailsScriptResult {
482
+ data?: WalletPortfolioPnls;
483
+ isLoading: boolean;
484
+ resolution: PnlResolution;
485
+ setResolution: (r: PnlResolution) => void;
486
+ positionState: PositionState;
487
+ setPositionState: (p: PositionState) => void;
488
+ sortBy: PnlSortBy;
489
+ setSortBy: (s: PnlSortBy) => void;
490
+ hasMore: boolean;
491
+ loadMore: () => void;
492
+ }
493
+ /**
494
+ * Script for the Phase 3 PnL-details widget.
495
+ *
496
+ * Pagination: accumulates cursor pages into a single `WalletPortfolioPnls`
497
+ * while keeping the header summary from the first page. Any of
498
+ * `resolution` / `positionState` / `sortBy` / `chain` / `address` changing
499
+ * triggers a full reset — the server invalidates cursors on any of these
500
+ * changes.
501
+ */
502
+ declare function usePortfolioPnlDetailsScript({ chain, address, limit, initialResolution, initialPositionState, initialSortBy, }: UsePortfolioPnlDetailsScriptParams): UsePortfolioPnlDetailsScriptResult;
503
+
504
+ interface PortfolioPnlDetailsWidgetProps {
505
+ chain: Chain;
506
+ address: string;
507
+ limit?: number;
508
+ initialResolution?: PnlResolution;
509
+ initialPositionState?: PositionState;
510
+ initialSortBy?: PnlSortBy;
511
+ className?: string;
512
+ onRowClick?: (pnl: PortfolioPnl) => void;
513
+ }
514
+ /**
515
+ * Phase 3 PnL-details widget. Consumes
516
+ * `GET /v2/wallet/{chain}/{wallet}/pnl-details` via
517
+ * `useWalletPortfolioPnlsQuery` and renders the new fields (`isClosed`,
518
+ * `firstBuyAt`, `lastSellAt`) alongside resolution / positionState / sortBy
519
+ * selectors.
520
+ */
521
+ declare function PortfolioPnlDetailsWidget({ chain, address, limit, initialResolution, initialPositionState, initialSortBy, className, onRowClick, }: PortfolioPnlDetailsWidgetProps): react_jsx_runtime.JSX.Element;
522
+
299
523
  declare const PortfolioClientContext: react.Context<IPortfolioClient | null>;
300
524
 
301
525
  /** Refetch function for wallet summary. */
@@ -453,4 +677,4 @@ declare function computeDistribution(holdings: SpotHolding[]): DistributionData;
453
677
  */
454
678
  declare function formatTime(epochMs: number): string;
455
679
 
456
- export { type AccountAction, AccountInfoUI, type AccountInfoUIProps, AccountInfoWidget, type AccountInfoWidgetProps, AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, AsyncStatus, BalanceRowUI, type BalanceRowUIProps, BatchActionButton, type BatchActionButtonProps, ConfirmDialog, type ConfirmDialogProps, CurveCardUI, type CurveCardUIProps, CurveData, CurvePeriod, CurveQuery, CurveType, DistributionCardUI, type DistributionCardUIProps, DistributionData, HoldingsEmpty, type HoldingsEmptyProps, type HoldingsRenderProps, HoldingsSearch, type HoldingsSearchProps, HoldingsSectionWidget, type HoldingsSectionWidgetProps, HoldingsSubTabs, type HoldingsSubTabsProps, IPortfolioClient, PerpsHistoryData, PerpsHistoryQuery, PerpsPanelUI, type PerpsPanelUIProps, PerpsPosition, PerpsPositionsData, type PerpsSubTab, PortfolioClientContext, PortfolioClientProvider, type PortfolioClientProviderProps, PortfolioContext, type PortfolioContextValue, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, type RefetchWalletSummaryFn, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, type TokenPortfolio, type UseAccountInfoResult, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, type UseWalletPortfoliosParams, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, WalletSummary, computeDistribution, curveDataQueryKey, distributionQueryKey, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, useAccountInfo, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioClient, usePortfolioContext, usePortfolioPage, usePredictionBetsQuery, usePredictionSettledQuery, useRefetchWalletSummary, useSpotHistoryQuery, useSpotHoldingsQuery, useWalletPortfolios, useWalletSummary, _default as version };
680
+ export { type AccountAction, AccountInfoUI, type AccountInfoUIProps, AccountInfoWidget, type AccountInfoWidgetProps, AddressRowUI, type AddressRowUIProps, AssetTab, AssetTabsUI, type AssetTabsUIProps, AsyncStatus, BalanceRowUI, type BalanceRowUIProps, BatchActionButton, type BatchActionButtonProps, ConfirmDialog, type ConfirmDialogProps, CurveCardUI, type CurveCardUIProps, CurveData, CurvePeriod, CurveQuery, CurveType, DistributionCardUI, type DistributionCardUIProps, DistributionData, HoldingsEmpty, type HoldingsEmptyProps, type HoldingsRenderProps, HoldingsSearch, type HoldingsSearchProps, HoldingsSectionWidget, type HoldingsSectionWidgetProps, HoldingsSubTabs, type HoldingsSubTabsProps, IPortfolioClient, PerpsHistoryData, PerpsHistoryQuery, PerpsPanelUI, type PerpsPanelUIProps, PerpsPosition, PerpsPositionsData, type PerpsSubTab, type PnlResolution, type PnlSortBy, PortfolioActivities, type PortfolioActivitiesProps, type PortfolioActivitiesSortBy, type PortfolioActivitiesTypeFilter, PortfolioActivitiesWidget, type PortfolioActivitiesWidgetProps, PortfolioClientContext, PortfolioClientProvider, type PortfolioClientProviderProps, PortfolioContext, type PortfolioContextValue, PortfolioNetWorthTokens, type PortfolioNetWorthTokensProps, PortfolioNetWorthTokensWidget, type PortfolioNetWorthTokensWidgetProps, PortfolioOverview, PortfolioPageSkeleton, PortfolioPageWidget, type PortfolioPageWidgetProps, PortfolioPnlDetails, type PortfolioPnlDetailsProps, PortfolioPnlDetailsWidget, type PortfolioPnlDetailsWidgetProps, PortfolioProvider, type PortfolioProviderProps, PortfolioQuery, type PositionState, PredictionBet, PredictionBetsData, PredictionPanelUI, type PredictionPanelUIProps, PredictionSettledData, PredictionSettledQuery, type PredictionSubTab, type RefetchWalletSummaryFn, SpotHistoryData, SpotHistoryQuery, SpotHolding, SpotHoldingsData, SpotPanelUI, type SpotPanelUIProps, type SpotSubTab, TagBadge, TagBadgeList, type TagBadgeListProps, type TagBadgeProps, type TokenPortfolio, type UseAccountInfoResult, type UseHoldingsSectionOptions, type UseHoldingsSectionResult, type UsePortfolioActivitiesScriptParams, type UsePortfolioActivitiesScriptResult, type UsePortfolioNetWorthTokensScriptParams, type UsePortfolioNetWorthTokensScriptResult, type UsePortfolioPageOptions, type UsePortfolioPageResult, type UsePortfolioPnlDetailsScriptParams, type UsePortfolioPnlDetailsScriptResult, type UseWalletPortfoliosParams, ViewingBannerUI, type ViewingBannerUIProps, type WalletOption, WalletSummary, computeDistribution, curveDataQueryKey, distributionQueryKey, formatAgeShort, formatPercent, formatSignedUsd, formatTime, formatTokenBalance, formatUsd, getExplorerUrl, overviewQueryKey, parseDecimal, perpsHistoryQueryKey, perpsPositionsQueryKey, predictionBetsQueryKey, predictionSettledQueryKey, splitUsd, spotHistoryQueryKey, spotHoldingsQueryKey, truncateAddress, truncateMiddle, useAccountInfo, useCurveDataQuery, useDistributionQuery, useHoldingsSection, useOverviewQuery, usePerpsHistoryQuery, usePerpsPositionsQuery, usePortfolioActivitiesScript, usePortfolioClient, usePortfolioContext, usePortfolioNetWorthTokensScript, usePortfolioPage, usePortfolioPnlDetailsScript, usePredictionBetsQuery, usePredictionSettledQuery, useRefetchWalletSummary, useSpotHistoryQuery, useSpotHoldingsQuery, useWalletPortfolios, useWalletSummary, _default as version };