packages/frontend/src/lib/. The most useful hooks and helpers:
API
// lib/api.ts. typed REST client (one fetch + zod-validated responses per route)
export async function getOracles(): Promise<ApiOracle[]>;
export async function getOracleStrikes(oracleId: string): Promise<ApiStrike[]>;
export async function getBinaryMarkets(): Promise<ApiBinaryMarket[]>;
export async function getVaults(): Promise<ApiVault[]>;
// …
// lib/api-hooks.ts. TanStack Query wrappers
export function useOracles();
export function useOracle(id);
export function useStrikes(oracleId);
export function useFills(oracleId, limit);
export function useUserFills(address);
export function useUserRedemptions(address);
export function useAgents();
export function useVaults();
export function useBinaryMarkets();
Predict quotes
// lib/predict-quote.ts
/** Per-strike live ask via devInspect get_trade_amounts */
export function useStrikeQuote(oracleId, strike, isUp);
/** Per-range live ask via get_range_trade_amounts */
export function useRangeQuote(oracleId, lower, upper);
/** Per-oracle mint-window bounds (min/max strike + size) */
export function useMintBounds(oracleId);
/**
* Portfolio-level mark-to-market.
* Quotes ≤1 2 distinct open strikes, expired markets settle spot-vs-strike RPC-free,
* unquotable falls back to cost basis.
*/
export function usePositionsValue(address);
DeepBook V3 quotes
// lib/deepbook-quote.ts
/** Output qty from a market buy/sell via get_quantity_out_input_fee. Matches the zero-DEEP swap's fee math. */
export function useV3SwapQuote({ poolId, baseType, quoteType, side, qty });
/** pool::mid_price devInspect */
export function useV3MidPrice({ poolId });
Account discovery
// lib/account.ts
/**
* Unified hook for wallet + zkLogin signed-in address.
* dApp Kit's useCurrentAccount() returns null for zkLogin users;
* this hook merges both sources.
*/
export function useAppAccount(): { address: string } | null;
// lib/my-managers.ts
export function useMyManagers(address); // discovers PredictManagers owned by the address
// lib/predict-account.ts
export function usePredictAccount(managerId); // live DUSDC balance + position list
Realtime
// lib/realtime.ts
/** Singleton WS client. Per-channel subscribe / linear backoff / idle close */
export function useQuoteSubscription(channel, onUpdate);
Event-market holdings
// lib/binary-holdings.ts
/** Read wallet Coin<YES>/Coin<NO> per registry market via getBalance (15s refetch). */
export function useBinaryHoldings(address);
/** Mark holdings to pool mid; falls back to 50¢ neutral when unquotable. */
export function useBinaryHoldingsValue(address);
Tx signer (Sponsor cascade)
// lib/wallet.ts
/**
* Three-strategy signer:
* 0) self-sponsor via /v1/sponsor
* 1) Enoki sponsorAndExecuteTransaction (zk only, on SponsorUnavailableError)
* 2) direct execution (user pays gas)
*
* After execution, waitForTransaction({showEffects}) and throws a humanized
* error on MoveAbort.
*/
export function useTxSigner(): TxSigner;
Env helpers
// lib/env.ts
export const SERVER_HTTP_URL: string;
export const SERVER_WS_URL: string;
export const AGENT_STATUS_URLS: string[];
export const VAULT_ONCHAIN_LIVE: boolean; // true since 2026-06-10 republish
export const DEFAULT_SEAL_POLICY_ID: string;
Format helpers
// lib/format.ts
export function formatDusdc(micro: bigint | number): string; // "$1,086.70"
export function formatPct(value: number, digits = 2): string;
export function shortAddr(addr: string): string; // "0x0451…12e4"
export function formatDuration(ms: number): string;
export function humanizeAgentError(err: string): string;