@liberfi.io/ui-trade 0.1.2 → 0.1.4

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
@@ -1,11 +1,12 @@
1
1
  # @liberfi.io/ui-trade
2
2
 
3
- Trade hooks and swap widget for the Liberfi React SDK. This package provides chain-agnostic swap logic and a ready-to-use swap form component that works across Solana, Ethereum, and BSC.
3
+ Trade hooks and widgets for the Liberfi React SDK. This package provides chain-agnostic swap logic and ready-to-use trade form components that work across Solana, Ethereum, and BSC.
4
4
 
5
- The package is organized in two layers:
5
+ The package is organized in three layers:
6
6
 
7
7
  - **Hooks** (`useSwap`, `useSwapRoutePolling`, `useTxConfirmation`) — pure-logic building blocks with no UI side-effects, designed for IoC.
8
8
  - **Swap Widget** (`SwapWidget` / `useSwapScript` / `SwapUI` / `SwapPreviewModal`) — a full swap form with preview-before-confirm flow, following the Script/Widget/UI three-layer architecture, composable at any level.
9
+ - **Instant Trade** (`InstantTradeWidget` / `InstantTradeProvider` / `PresetFormWidget`) — a configurable quick-trade form with buy/sell tabs, preset management, customizable quick-amount buttons, and trade settings (slippage, priority fee, tip fee, anti-MEV).
9
10
 
10
11
  ## Design Philosophy
11
12
 
@@ -478,11 +479,201 @@ function EvmSwapButton() {
478
479
  }
479
480
  ```
480
481
 
482
+ ### Components (Instant Trade)
483
+
484
+ The instant trade module provides a configurable quick-trade form with preset management and customizable quick-amount buttons.
485
+
486
+ #### `InstantTradeWidget`
487
+
488
+ Full instant-trade form with buy/sell tabs, amount input, quick buttons, preset management, and trade execution.
489
+
490
+ ```tsx
491
+ <InstantTradeWidget
492
+ chain={Chain.SOLANA}
493
+ tokenAddress="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
494
+ onSwapSubmitted={(result) => console.log(result)}
495
+ onSwapError={(error, phase) => console.error(error)}
496
+ />
497
+ ```
498
+
499
+ **Props (`InstantTradeWidgetProps`):**
500
+
501
+ | Name | Type | Description |
502
+ | ------------------- | ------------------------------------------ | ----------------------------------------------------- |
503
+ | `chain` | `Chain` | Target chain. |
504
+ | `tokenAddress` | `string` | Address of the token being traded. |
505
+ | `onSwapSubmitted?` | `(result: SwapResult) => void` | Called when a swap is submitted. |
506
+ | `onSwapError?` | `(error: Error, phase: SwapPhase) => void` | Called on swap error. |
507
+ | `settings?` | `InstantTradeSettings` | Controlled settings (omit for localStorage). |
508
+ | `onSettingsChange?` | `(settings: InstantTradeSettings) => void` | Called when settings change. |
509
+ | `headerExtra?` | `ReactNode` | Slot for extra header content (e.g. wallet switcher). |
510
+ | `className?` | `string` | External style customization. |
511
+
512
+ #### `InstantTradeProvider`
513
+
514
+ Context provider for instant trade state. Use with `InstantTradeAmountInput` and `InstantTradeButton` for compact inline trading.
515
+
516
+ ```tsx
517
+ <InstantTradeProvider chain={Chain.SOLANA} tokenAddress="...">
518
+ <InstantTradeAmountInput
519
+ amount={amount}
520
+ onAmountChange={setAmount}
521
+ preset={preset}
522
+ onPresetChange={setPreset}
523
+ />
524
+ <InstantTradeButton />
525
+ </InstantTradeProvider>
526
+ ```
527
+
528
+ #### `useInstantTradeScript(params)`
529
+
530
+ Script-layer hook for the instant trade form. Must be used inside an `InstantTradeProvider`. Encapsulates token queries, balance queries, form state, and swap execution.
531
+
532
+ #### `InstantTradeAmountInput`
533
+
534
+ Compact amount input with lightning icon, native token avatar, and 3 preset buttons (P1/P2/P3) with tooltips. Must be inside an `InstantTradeProvider`.
535
+
536
+ #### `InstantTradeButton`
537
+
538
+ Trade execution button that reads state from `InstantTradeProvider`. Handles wallet resolution, amount conversion, and swap execution.
539
+
540
+ #### `PresetFormWidget`
541
+
542
+ Standalone widget for editing trade preset values (slippage, priority fee, tip fee, auto fee, anti-MEV, custom RPC).
543
+
544
+ ```tsx
545
+ <PresetFormWidget
546
+ chain={Chain.SOLANA}
547
+ value={presetValues}
548
+ onChange={setPresetValues}
549
+ />
550
+ ```
551
+
552
+ #### `PresetFormUI`
553
+
554
+ Pure presentational preset form. Accepts value/onChange props directly, with optional `nativeSymbol` and `nativeDecimals`.
555
+
556
+ ### Instant Trade Types
557
+
558
+ #### `TradePresetValues`
559
+
560
+ ```typescript
561
+ interface TradePresetValues {
562
+ slippage: number | null;
563
+ priorityFee: number | null;
564
+ tipFee: number | null;
565
+ autoFee: boolean;
566
+ maxAutoFee: number | null;
567
+ antiMev: "off" | "reduced" | "secure";
568
+ customRPC: string | null;
569
+ }
570
+ ```
571
+
572
+ #### `InstantTradeSettings`
573
+
574
+ ```typescript
575
+ interface InstantTradeSettings {
576
+ buy: BuySettings;
577
+ sell: SellSettings;
578
+ }
579
+
580
+ interface BuySettings {
581
+ customAmounts: (number | null)[];
582
+ presets: TradePresetValues[];
583
+ }
584
+
585
+ interface SellSettings {
586
+ customPercentages: (number | null)[];
587
+ presets: TradePresetValues[];
588
+ }
589
+ ```
590
+
591
+ #### `DEFAULT_TRADE_PRESET`
592
+
593
+ Default preset values: slippage=20, priorityFee=0.001, tipFee=0.001, autoFee=false, maxAutoFee=0.1, antiMev="off".
594
+
595
+ #### `DEFAULT_INSTANT_TRADE_SETTINGS`
596
+
597
+ Default settings with 4 buy amounts (0.01, 0.1, 1, 10), 4 sell percentages (10, 25, 50, 100), and 3 default presets each.
598
+
599
+ ## Usage Examples
600
+
601
+ ### InstantTradeWidget (Full Trade Form)
602
+
603
+ ```tsx
604
+ import { Chain } from "@liberfi.io/types";
605
+ import { InstantTradeWidget } from "@liberfi.io/ui-trade";
606
+
607
+ function TokenTradePage({ tokenAddress }: { tokenAddress: string }) {
608
+ return (
609
+ <InstantTradeWidget
610
+ chain={Chain.SOLANA}
611
+ tokenAddress={tokenAddress}
612
+ onSwapSubmitted={(result) => {
613
+ toast.success(`Transaction submitted: ${result.txHash}`);
614
+ }}
615
+ onSwapError={(error, phase) => {
616
+ toast.error(`Swap failed at ${phase}: ${error.message}`);
617
+ }}
618
+ />
619
+ );
620
+ }
621
+ ```
622
+
623
+ ### Compact Inline Trading
624
+
625
+ ```tsx
626
+ import { Chain } from "@liberfi.io/types";
627
+ import {
628
+ InstantTradeProvider,
629
+ InstantTradeAmountInput,
630
+ InstantTradeButton,
631
+ } from "@liberfi.io/ui-trade";
632
+
633
+ function TokenHeader({ tokenAddress }: { tokenAddress: string }) {
634
+ return (
635
+ <InstantTradeProvider chain={Chain.SOLANA} tokenAddress={tokenAddress}>
636
+ <div className="flex items-center gap-2">
637
+ <InstantTradeAmountInput
638
+ amount={undefined}
639
+ onAmountChange={() => {}}
640
+ variant="bordered"
641
+ size="sm"
642
+ />
643
+ <InstantTradeButton />
644
+ </div>
645
+ </InstantTradeProvider>
646
+ );
647
+ }
648
+ ```
649
+
650
+ ### Preset Settings Editor
651
+
652
+ ```tsx
653
+ import { useState } from "react";
654
+ import { Chain } from "@liberfi.io/types";
655
+ import { PresetFormWidget, DEFAULT_TRADE_PRESET } from "@liberfi.io/ui-trade";
656
+
657
+ function TradeSettings() {
658
+ const [preset, setPreset] = useState(DEFAULT_TRADE_PRESET);
659
+
660
+ return (
661
+ <PresetFormWidget
662
+ chain={Chain.SOLANA}
663
+ value={preset}
664
+ onChange={setPreset}
665
+ />
666
+ );
667
+ }
668
+ ```
669
+
481
670
  ## Future Improvements
482
671
 
483
672
  - Add `useSwapQuote` hook for fetching quotes without executing (read-only route info).
484
673
  - Add ERC20 approval detection and `useTokenApproval` hook for EVM chains that don't support permit.
485
674
  - Support `ExactOut` swap mode with output amount estimation.
486
675
  - Add a skeleton loading component (`swap-skeleton.ui.tsx`) for the swap form.
487
- - Add slippage / priority fee / anti-MEV configuration to `SwapWidget` props.
488
676
  - Support token-select callback props on `SwapWidget` for integrating with external token picker UI.
677
+ - Add limit order and advanced trade modes to `InstantTradeWidget`.
678
+ - Add token price conversion display in the instant trade form.
679
+ - Support custom RPC endpoint validation in `PresetFormWidget`.
package/dist/index.d.mts CHANGED
@@ -2,6 +2,8 @@ import * as _liberfi_io_types from '@liberfi.io/types';
2
2
  import { Chain, API, Token, Portfolio } from '@liberfi.io/types';
3
3
  import { WalletAdapter } from '@liberfi.io/wallet-connector';
4
4
  import * as react_jsx_runtime from 'react/jsx-runtime';
5
+ import { ReactNode } from 'react';
6
+ import { PredefinedToken } from '@liberfi.io/utils';
5
7
 
6
8
  /**
7
9
  * Input parameters for the `swap()` function returned by {@link useSwap}.
@@ -61,6 +63,33 @@ interface UseSwapRoutePollingOptions {
61
63
  /** Called when a route fetch fails. */
62
64
  onError?: (error: Error) => void;
63
65
  }
66
+ /** Configuration values for a single trade preset (slippage, fees, MEV). */
67
+ interface TradePresetValues {
68
+ /** Slippage tolerance, 0-100 (percent). `null` = use default. */
69
+ slippage: number | null;
70
+ /** Priority fee in native token units. `null` = use default. */
71
+ priorityFee: number | null;
72
+ /** Tip fee in native token units. `null` = use default. */
73
+ tipFee: number | null;
74
+ /** Whether automatic fee estimation is enabled. */
75
+ autoFee: boolean;
76
+ /** Maximum fee cap when auto-fee is on (native token units). */
77
+ maxAutoFee: number | null;
78
+ /** Anti-MEV protection level. */
79
+ antiMev: "off" | "reduced" | "secure";
80
+ /** Custom RPC endpoint URL. `null` = use default. */
81
+ customRPC: string | null;
82
+ }
83
+ /** Default preset values matching Solana-typical settings. */
84
+ declare const DEFAULT_TRADE_PRESET: TradePresetValues;
85
+ /** Default preset values for EVM chains (gas fee in Gwei). */
86
+ declare const DEFAULT_EVM_TRADE_PRESET: TradePresetValues;
87
+ /** Default preset values for BSC (gas in Gwei + tip in BNB). */
88
+ declare const DEFAULT_BSC_TRADE_PRESET: TradePresetValues;
89
+ /** Default quick-buy amounts (native token units). */
90
+ declare const DEFAULT_BUY_AMOUNTS: number[];
91
+ /** Default quick-sell percentages. */
92
+ declare const DEFAULT_SELL_PERCENTAGES: number[];
64
93
  /** Confirmation status of a tracked transaction. */
65
94
  type TxConfirmationStatus = "idle" | "pending" | "confirmed" | "failed";
66
95
  /** Options for the {@link useTxConfirmation} hook. */
@@ -317,6 +346,294 @@ declare function SwapUI({ fromToken, toToken, fromBalance, toBalance, amount, am
317
346
  */
318
347
  declare function SwapPreviewModal({ isOpen, onOpenChange, fromToken, toToken, fromBalance, inputAmount, inputAmountInUsd, outputAmount, outputAmountInUsd, route, isRouting, routeError, onConfirm, isSwapping, }: SwapPreviewModalProps): react_jsx_runtime.JSX.Element;
319
348
 
349
+ /** Parameters for {@link useInstantTradeScript}. */
350
+ interface UseInstantTradeScriptParams {
351
+ /** Target chain */
352
+ chain: Chain;
353
+ /** Address of the token being traded (the non-native side) */
354
+ tokenAddress: string;
355
+ /** Called when a swap transaction is successfully submitted */
356
+ onSwapSubmitted?: (result: SwapResult) => void;
357
+ /** Called when a swap error occurs at any phase */
358
+ onSwapError?: (error: Error, phase: SwapPhase) => void;
359
+ }
360
+ /** Return value of {@link useInstantTradeScript}. */
361
+ interface UseInstantTradeScriptResult {
362
+ chain: Chain;
363
+ tokenAddress: string;
364
+ nativeToken: PredefinedToken | undefined;
365
+ tokenInfo: Token | null;
366
+ nativeBalance: Portfolio | null;
367
+ tokenBalance: Portfolio | null;
368
+ direction: "buy" | "sell";
369
+ setDirection: (d: "buy" | "sell") => void;
370
+ amount: number | undefined;
371
+ setAmount: (v: number | undefined) => void;
372
+ buyPreset: number;
373
+ setBuyPreset: (p: number) => void;
374
+ sellPreset: number;
375
+ setSellPreset: (p: number) => void;
376
+ currentPresetValues: TradePresetValues;
377
+ settings: InstantTradeSettings;
378
+ updateBuySettings: (s: BuySettings) => void;
379
+ updateSellSettings: (s: SellSettings) => void;
380
+ showSettings: boolean;
381
+ handlePresetClick: (preset: number) => void;
382
+ swap: () => Promise<void>;
383
+ isSwapping: boolean;
384
+ submitText: string;
385
+ isDisabled: boolean;
386
+ isLoading: boolean;
387
+ }
388
+ /** Props for {@link InstantTradeWidget}. */
389
+ interface InstantTradeWidgetProps {
390
+ /** Target chain */
391
+ chain: Chain;
392
+ /** Address of the token being traded */
393
+ tokenAddress: string;
394
+ /** Called when a swap transaction is submitted */
395
+ onSwapSubmitted?: (result: SwapResult) => void;
396
+ /** Called on swap error */
397
+ onSwapError?: (error: Error, phase: SwapPhase) => void;
398
+ /** Controlled settings (omit for localStorage fallback) */
399
+ settings?: InstantTradeSettings;
400
+ /** Called when settings change */
401
+ onSettingsChange?: (settings: InstantTradeSettings) => void;
402
+ /** Slot rendered next to trade-type tabs (e.g. wallet switcher) */
403
+ headerExtra?: ReactNode;
404
+ /** External style customization */
405
+ className?: string;
406
+ }
407
+ /** Props for {@link InstantTradeUI}. */
408
+ interface InstantTradeUIProps {
409
+ chain: Chain;
410
+ direction: "buy" | "sell";
411
+ onDirectionChange: (d: "buy" | "sell") => void;
412
+ amount: number | undefined;
413
+ onAmountChange: (v: number | undefined) => void;
414
+ customAmounts: (number | null)[];
415
+ customPercentages: (number | null)[];
416
+ onQuickAmountClick: (v: number) => void;
417
+ onQuickPercentageClick: (percent: number) => void;
418
+ onCustomAmountsEdit: (amounts: (number | null)[]) => void;
419
+ onCustomPercentagesEdit: (pcts: (number | null)[]) => void;
420
+ tokenSymbol?: string;
421
+ nativeSymbol?: string;
422
+ nativeDecimals?: number;
423
+ nativeBalance?: string;
424
+ tokenBalance?: string;
425
+ amountConversion?: string;
426
+ preset: number;
427
+ onPresetChange: (p: number) => void;
428
+ presetValues: TradePresetValues;
429
+ onPresetSettingsChange: (v: TradePresetValues) => void;
430
+ showSettings: boolean;
431
+ onPresetClick: (preset: number) => void;
432
+ submitText: string;
433
+ isDisabled: boolean;
434
+ isLoading: boolean;
435
+ onSubmit: () => void;
436
+ className?: string;
437
+ headerExtra?: ReactNode;
438
+ }
439
+ /** Value exposed by {@link InstantTradeContext}. */
440
+ interface InstantTradeContextValue {
441
+ chain: Chain;
442
+ tokenAddress: string;
443
+ nativeToken: PredefinedToken | undefined;
444
+ direction: "buy" | "sell";
445
+ setDirection: (d: "buy" | "sell") => void;
446
+ /** Quick-trade amount (native token units for buy, token units for sell). */
447
+ amount: number | undefined;
448
+ setAmount: (v: number | undefined) => void;
449
+ buyPreset: number;
450
+ setBuyPreset: (p: number) => void;
451
+ sellPreset: number;
452
+ setSellPreset: (p: number) => void;
453
+ settings: InstantTradeSettings;
454
+ updateBuySettings: (s: BuySettings) => void;
455
+ updateSellSettings: (s: SellSettings) => void;
456
+ currentPresetValues: TradePresetValues;
457
+ }
458
+ /** Props for {@link InstantTradeProvider}. */
459
+ interface InstantTradeProviderProps {
460
+ /** Target chain */
461
+ chain: Chain;
462
+ /** Address of the token being traded */
463
+ tokenAddress: string;
464
+ /** Controlled settings (omit for built-in localStorage persistence) */
465
+ settings?: InstantTradeSettings;
466
+ /** Called when settings change */
467
+ onSettingsChange?: (settings: InstantTradeSettings) => void;
468
+ children: ReactNode;
469
+ }
470
+ /** Props for {@link InstantTradeAmountInput}. */
471
+ interface InstantTradeAmountInputProps {
472
+ amount?: number;
473
+ onAmountChange: (amount?: number) => void;
474
+ preset?: number;
475
+ onPresetChange?: (preset: number) => void;
476
+ /** Called when an already-selected preset is clicked (e.g. open settings) */
477
+ onPresetClick?: (preset: number) => void;
478
+ variant?: "default" | "bordered";
479
+ radius?: "full" | "lg" | "md" | "sm";
480
+ size?: "sm" | "lg";
481
+ fullWidth?: boolean;
482
+ className?: string;
483
+ }
484
+ /** Props for {@link InstantTradeButton}. */
485
+ interface InstantTradeButtonProps {
486
+ className?: string;
487
+ children?: ReactNode;
488
+ }
489
+ /** Props for {@link PresetFormUI}. */
490
+ interface PresetFormUIProps {
491
+ value: TradePresetValues;
492
+ onChange: (value: TradePresetValues) => void;
493
+ /** Target chain — determines which fields are shown (e.g. anti-MEV for Solana only). */
494
+ chain: Chain;
495
+ nativeSymbol?: string;
496
+ nativeDecimals?: number;
497
+ className?: string;
498
+ }
499
+ /** Props for {@link PresetFormWidget}. */
500
+ interface PresetFormWidgetProps {
501
+ value: TradePresetValues;
502
+ onChange: (value: TradePresetValues) => void;
503
+ chain: Chain;
504
+ className?: string;
505
+ }
506
+
507
+ /** Buy-side trade settings. */
508
+ interface BuySettings {
509
+ /** Four customizable quick-amount buttons (native token units) */
510
+ customAmounts: (number | null)[];
511
+ /** Three preset configurations */
512
+ presets: TradePresetValues[];
513
+ }
514
+ /** Sell-side trade settings. */
515
+ interface SellSettings {
516
+ /** Four customizable quick-percentage buttons (0-100) */
517
+ customPercentages: (number | null)[];
518
+ /** Three preset configurations */
519
+ presets: TradePresetValues[];
520
+ }
521
+ /** Combined buy + sell settings for instant trade. */
522
+ interface InstantTradeSettings {
523
+ buy: BuySettings;
524
+ sell: SellSettings;
525
+ }
526
+
527
+ declare const DEFAULT_INSTANT_TRADE_SETTINGS: InstantTradeSettings;
528
+ /** Access the nearest {@link InstantTradeProvider}. Throws if none found. */
529
+ declare function useInstantTrade(): InstantTradeContextValue;
530
+ /**
531
+ * Provides instant-trade state to descendant components.
532
+ *
533
+ * Settings follow a controlled / uncontrolled pattern:
534
+ * - **Controlled**: pass `settings` + `onSettingsChange` props.
535
+ * - **Uncontrolled** (default): settings auto-persist to localStorage keyed by chain.
536
+ */
537
+ declare function InstantTradeProvider({ chain, tokenAddress, settings: controlledSettings, onSettingsChange, children, }: InstantTradeProviderProps): react_jsx_runtime.JSX.Element;
538
+
539
+ /**
540
+ * Script hook that encapsulates all data and state for the instant trade form.
541
+ *
542
+ * Must be used inside an {@link InstantTradeProvider}.
543
+ * Pure TypeScript — no JSX, no UI imports.
544
+ */
545
+ declare function useInstantTradeScript(params: UseInstantTradeScriptParams): UseInstantTradeScriptResult;
546
+
547
+ /**
548
+ * Full instant-trade widget — thin orchestration layer.
549
+ *
550
+ * Wraps `InstantTradeProvider`, calls `useInstantTradeScript` to get all data,
551
+ * and renders `InstantTradeUI` as the presentational layer.
552
+ *
553
+ * For custom UIs, use `useInstantTradeScript` directly inside an
554
+ * `InstantTradeProvider` with your own presentation.
555
+ */
556
+ declare function InstantTradeWidget({ chain, tokenAddress, onSwapSubmitted, onSwapError, settings, onSettingsChange, headerExtra, className, }: InstantTradeWidgetProps): react_jsx_runtime.JSX.Element;
557
+
558
+ /**
559
+ * Preset form widget — thin orchestration layer.
560
+ *
561
+ * Manages local state initialized from `value`, resolves chain-specific
562
+ * native token info, and syncs changes upward via `onChange`.
563
+ */
564
+ declare function PresetFormWidget({ value, onChange, chain, className, }: PresetFormWidgetProps): react_jsx_runtime.JSX.Element;
565
+
566
+ /**
567
+ * Pure presentational component for the instant trade form.
568
+ *
569
+ * Receives all data and callbacks via props — no API calls, no context access.
570
+ * Consumers can replace this component while reusing `useInstantTradeScript`.
571
+ */
572
+ declare function InstantTradeUI({ chain, direction, onDirectionChange, amount, onAmountChange, customAmounts, customPercentages, onQuickAmountClick, onQuickPercentageClick, onCustomAmountsEdit, onCustomPercentagesEdit, tokenSymbol, nativeSymbol, nativeDecimals, nativeBalance, tokenBalance, amountConversion, preset, onPresetChange, presetValues, onPresetSettingsChange, showSettings, onPresetClick, submitText, isDisabled, isLoading, onSubmit, className, headerExtra, }: InstantTradeUIProps): react_jsx_runtime.JSX.Element;
573
+
574
+ /**
575
+ * Pure presentational preset-settings form.
576
+ *
577
+ * Renders inputs for slippage, priority fee, tip fee, auto fee,
578
+ * max auto fee, anti-MEV and custom RPC.
579
+ *
580
+ * The `chain` prop controls which fields are visible:
581
+ * - Solana: priority fee (SOL), tip fee (SOL), anti-MEV
582
+ * - Ethereum: gas fee (Gwei) only
583
+ * - BSC: gas fee (Gwei) + tip fee (BNB)
584
+ */
585
+ declare function PresetFormUI({ value, onChange, chain, nativeSymbol, nativeDecimals, className, }: PresetFormUIProps): react_jsx_runtime.JSX.Element;
586
+
587
+ /**
588
+ * Compact amount input with preset selector buttons.
589
+ *
590
+ * Designed for inline/header usage (e.g. token detail page).
591
+ * Must be rendered inside an {@link InstantTradeProvider}.
592
+ */
593
+ declare function InstantTradeAmountInput({ amount, onAmountChange, preset, onPresetChange, onPresetClick, variant, radius, size, fullWidth, className, }: InstantTradeAmountInputProps): react_jsx_runtime.JSX.Element;
594
+
595
+ /**
596
+ * Trade execution button that reads state from {@link InstantTradeProvider}.
597
+ *
598
+ * Resolves wallet, token addresses, converts amounts, applies preset
599
+ * settings, and calls `useSwap` from the SDK.
600
+ */
601
+ declare function InstantTradeButton({ className, children, }: InstantTradeButtonProps): react_jsx_runtime.JSX.Element;
602
+
603
+ type AntiMevOption = "off" | "reduced" | "secure";
604
+ interface ChainPresetFeatures {
605
+ /** Label for the priority/gas fee field */
606
+ feeLabel: string;
607
+ /** Unit displayed for the fee input (e.g. "SOL", "Gwei") */
608
+ feeUnit: string;
609
+ /** Decimal places for the fee input */
610
+ feeDecimals: number;
611
+ /** Whether this chain supports a separate tip/bribe fee */
612
+ showTipFee: boolean;
613
+ /** Unit for tip fee (e.g. "SOL", "BNB"). Empty when hidden. */
614
+ tipFeeUnit: string;
615
+ /** Decimal places for the tip fee input */
616
+ tipFeeDecimals: number;
617
+ /**
618
+ * Available anti-MEV protection levels for this chain.
619
+ * - Solana: ["off", "reduced", "secure"]
620
+ * - ETH / BSC: ["off", "secure"]
621
+ */
622
+ antiMevOptions: AntiMevOption[];
623
+ }
624
+ /**
625
+ * Returns the set of preset form features applicable to a given chain.
626
+ *
627
+ * - Solana: priority fee (SOL), tip fee (SOL/Jito), anti-MEV
628
+ * - Ethereum: gas fee (Gwei) only
629
+ * - BSC: gas fee (Gwei) + tip fee (BNB)
630
+ * - Other EVM: gas fee (Gwei), same as Ethereum by default
631
+ */
632
+ declare function getChainPresetFeatures(chain: Chain, nativeSymbol?: string): ChainPresetFeatures;
633
+ declare function isSolanaChain(chain: Chain): boolean;
634
+ /** Returns chain-appropriate default preset values. */
635
+ declare function getDefaultPresetForChain(chain: Chain): TradePresetValues;
636
+
320
637
  declare global {
321
638
  interface Window {
322
639
  __LIBERFI_VERSION__?: {
@@ -324,6 +641,6 @@ declare global {
324
641
  };
325
642
  }
326
643
  }
327
- declare const _default: "0.1.2";
644
+ declare const _default: "0.1.4";
328
645
 
329
- export { type SwapInput, type SwapPhase, SwapPreviewModal, type SwapPreviewModalProps, type SwapResult, SwapUI, type SwapUIProps, SwapWidget, type SwapWidgetProps, type TxConfirmationStatus, type UseSwapOptions, type UseSwapRoutePollingOptions, type UseSwapScriptParams, type UseSwapScriptResult, type UseTxConfirmationOptions, useSwap, useSwapRoutePolling, useSwapScript, useTxConfirmation, _default as version };
646
+ export { type AntiMevOption, type BuySettings, type ChainPresetFeatures, DEFAULT_BSC_TRADE_PRESET, DEFAULT_BUY_AMOUNTS, DEFAULT_EVM_TRADE_PRESET, DEFAULT_INSTANT_TRADE_SETTINGS, DEFAULT_SELL_PERCENTAGES, DEFAULT_TRADE_PRESET, InstantTradeAmountInput, type InstantTradeAmountInputProps, InstantTradeButton, type InstantTradeButtonProps, type InstantTradeContextValue, InstantTradeProvider, type InstantTradeProviderProps, type InstantTradeSettings, InstantTradeUI, type InstantTradeUIProps, InstantTradeWidget, type InstantTradeWidgetProps, PresetFormUI, type PresetFormUIProps, PresetFormWidget, type PresetFormWidgetProps, type SellSettings, type SwapInput, type SwapPhase, SwapPreviewModal, type SwapPreviewModalProps, type SwapResult, SwapUI, type SwapUIProps, SwapWidget, type SwapWidgetProps, type TradePresetValues, type TxConfirmationStatus, type UseInstantTradeScriptParams, type UseInstantTradeScriptResult, type UseSwapOptions, type UseSwapRoutePollingOptions, type UseSwapScriptParams, type UseSwapScriptResult, type UseTxConfirmationOptions, getChainPresetFeatures, getDefaultPresetForChain, isSolanaChain, useInstantTrade, useInstantTradeScript, useSwap, useSwapRoutePolling, useSwapScript, useTxConfirmation, _default as version };