@spicenet-io/spiceflow-ui 4.8.0-rc.0 → 4.8.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.
Files changed (39) hide show
  1. package/README.md +68 -3
  2. package/dist/auth-privy.cjs.js +1 -1
  3. package/dist/auth-privy.js +1 -1
  4. package/dist/components/AccountDisplay/parts/AccountActions.d.ts +0 -1
  5. package/dist/components/AccountDisplay/parts/AccountPanel.d.ts +0 -1
  6. package/dist/components/SpiceDeposit/lib/swapper.d.ts +35 -0
  7. package/dist/components/SpiceDeposit/steps/SelectSourceModal.d.ts +3 -0
  8. package/dist/components/SpiceDeposit/steps/SwapperDepositModal.d.ts +3 -0
  9. package/dist/components/SpiceSupply/lib/buildBatches.d.ts +0 -1
  10. package/dist/components/SpiceSupply/lib/executors.d.ts +0 -2
  11. package/dist/components/SpiceSupply/lib/feePreview.d.ts +0 -2
  12. package/dist/execution/fundEmbeddedWallet.d.ts +0 -7
  13. package/dist/hooks/index.d.ts +0 -2
  14. package/dist/hooks/useSupplyAssets.d.ts +1 -3
  15. package/dist/hooks/useSupplyQuote.d.ts +3 -4
  16. package/dist/hooks/useSwapperEmbed.d.ts +23 -0
  17. package/dist/index.cjs.js +11 -11
  18. package/dist/index.d.ts +16 -12
  19. package/dist/index.js +13 -13
  20. package/dist/privy-CKRpUHB_.js +2 -0
  21. package/dist/privy-ROtJpoJf.js +2 -0
  22. package/dist/providers/SpiceFlowProvider.d.ts +6 -0
  23. package/dist/types/assets.d.ts +0 -2
  24. package/dist/types/deposit.d.ts +51 -1
  25. package/dist/types/supply.d.ts +1 -2
  26. package/dist/utils/crossChainRouter/liquidityVenues.d.ts +24 -12
  27. package/dist/utils/crossChainRouter/nativeWrap.d.ts +6 -0
  28. package/dist/utils/crossChainRouter/uniV3.d.ts +30 -7
  29. package/dist/utils/crossChainRouter/uniV4.d.ts +37 -2
  30. package/dist/utils/crossChainRouter/venueConfig.d.ts +23 -0
  31. package/dist/utils/fees.d.ts +0 -7
  32. package/dist/utils/spiceConstants.d.ts +0 -2
  33. package/dist/utils/swapQuotes.d.ts +3 -2
  34. package/package.json +4 -2
  35. package/dist/hooks/useSpiceSupply.d.ts +0 -59
  36. package/dist/privy-CRGZIHW9.js +0 -2
  37. package/dist/privy-DB3mdjuj.js +0 -2
  38. package/dist/utils/crossChainRouter/algebra.d.ts +0 -83
  39. package/dist/utils/spicenetBatch.d.ts +0 -18
package/README.md CHANGED
@@ -35,6 +35,67 @@ function App() {
35
35
  }
36
36
  ```
37
37
 
38
+ ## Liquidity venues
39
+
40
+ When a flow has to swap on the destination chain, the SDK quotes every liquidity
41
+ venue that covers that chain and takes the best fill: the most output on a
42
+ supply, the least input on a pay. Routing is decided here, on your RPC. The
43
+ solver only executes the calls the winning quote produced.
44
+
45
+ Leave `liquidityVenues` off and you get the built-in venues. Declare it once on
46
+ the provider to add your own, and every component picks them up.
47
+
48
+ ```tsx
49
+ <SpiceFlowProvider
50
+ network="mainnet"
51
+ nativeChainId={4663}
52
+ rpcOverrides={{ 4663: ROBINHOOD_RPC }}
53
+ liquidityVenues={{
54
+ venues: [
55
+ {
56
+ protocol: "uniswap-v3",
57
+ chainId: 4663,
58
+ swapRouter: "0x1e406484F1F204b23cE84B9901C0171a738fd406",
59
+ quoterV2: "0x3E290e5E01818002A0b672148BdC7514D861C7B3",
60
+ hubCurrencies: ["0x0bd7d308f8e1639fab988df18a8011f41eacad73"],
61
+ },
62
+ ],
63
+ }}
64
+ >
65
+ ```
66
+
67
+ Your venues race the built-ins on price; they do not override them. Set
68
+ `includeDefaults: false` to drop the built-ins and route only through what you
69
+ declared. On a chain with no venue at all, quoting fails with that chain named
70
+ rather than falling back to something you did not configure.
71
+
72
+ Every entry names one chain and one protocol family, and serves both swap
73
+ directions. Supply the **deployment's** addresses, not a pool address: a
74
+ v3-style pool calls back into `msg.sender`, so swaps go through the router and
75
+ quotes through the quoter. The SDK finds the pools from the fee tiers (or tick
76
+ spacings) and hub currencies.
77
+
78
+ | `protocol` | Required | Optional |
79
+ | ---------------------- | ------------------------------------------------- | -------------------------------------------------------- |
80
+ | `uniswap-v3` | `chainId`, `swapRouter`, `quoterV2` | `name`, `feeTiers`, `hubCurrencies`, `routerHasDeadline` |
81
+ | `uniswap-v4` | `chainId`, `quoter`, `universalRouter`, `permit2` | `name`, `hubCurrencies` |
82
+ | `aerodrome-slipstream` | `chainId`, `swapRouter`, `quoterV2` | `name`, `tickSpacings`, `hubCurrencies` |
83
+
84
+ `name` is the label shown to the user as "via <name>" once a swap is quoted, so
85
+ give it the name people know the venue by. It defaults to the protocol, which
86
+ means a swap always names something real rather than a family it does not belong
87
+ to.
88
+
89
+ `hubCurrencies` are the intermediate tokens tried for two-hop routes, usually
90
+ wrapped native and the chain's main stablecoin. Set `routerHasDeadline` when the
91
+ deployment forked the original Uniswap `SwapRouter`, whose exact-output structs
92
+ carry a deadline; SwapRouter02 forks do not.
93
+
94
+ Most DEXs are forks of one of these families, so adding one is addresses only.
95
+ A venue from a different family (a Uniswap v2 pair, Curve, Balancer) needs an
96
+ adapter in the SDK — send us the chain, router, quoter and one funded pool and
97
+ it becomes a `protocol` everyone can name.
98
+
38
99
  ## Components
39
100
 
40
101
  - **SwapWidget** - Main swap interface component
@@ -66,13 +127,17 @@ bun run build
66
127
  bun run typecheck
67
128
  ```
68
129
 
69
- ### Linting
130
+ CI runs this on every pull request, so a type error fails the build.
131
+
132
+ ### Formatting
70
133
 
71
134
  ```bash
72
- bun run lint
73
- bun run lint:fix
135
+ bun run format
74
136
  ```
75
137
 
138
+ Prettier runs over staged files on commit via lint-staged. There is no ESLint
139
+ setup in this repository.
140
+
76
141
  ## Component Playground
77
142
 
78
143
  This repository includes a lightweight React playground app for viewing and testing all components without the complexity of Storybook.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const r=require("./privy-DB3mdjuj.js");require("react/jsx-runtime"),require("react"),require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@privy-io/react-auth"),require("wagmi"),require("@tanstack/react-query"),exports.PrivyLogin=r.PrivyLogin;
2
+ "use strict";const r=require("./privy-ROtJpoJf.js");require("react/jsx-runtime"),require("react"),require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@privy-io/react-auth"),require("wagmi"),require("@tanstack/react-query"),exports.PrivyLogin=r.PrivyLogin;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{P as g}from"./privy-CRGZIHW9.js";import"react/jsx-runtime";import"react";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@privy-io/react-auth";import"wagmi";import"@tanstack/react-query";export{g as PrivyLogin};
2
+ import{P as g}from"./privy-CKRpUHB_.js";import"react/jsx-runtime";import"react";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@privy-io/react-auth";import"wagmi";import"@tanstack/react-query";export{g as PrivyLogin};
@@ -2,7 +2,6 @@ import React from "react";
2
2
  interface AccountActionsProps {
3
3
  onDepositClick?: () => void;
4
4
  onWithdrawClick?: () => void;
5
- onDisconnectClick: () => void;
6
5
  depositDisabled?: boolean;
7
6
  withdrawDisabled?: boolean;
8
7
  primaryColor?: string;
@@ -18,7 +18,6 @@ interface AccountPanelProps {
18
18
  notice?: AccountNotice | null;
19
19
  onDepositClick?: () => void;
20
20
  onWithdrawClick?: () => void;
21
- onDisconnectClick: () => void;
22
21
  depositDisabled?: boolean;
23
22
  onCompleteDeposit?: (deposit: VerifiedPendingDeposit) => void;
24
23
  primaryColor?: string;
@@ -0,0 +1,35 @@
1
+ import { type Address } from "viem";
2
+ import type { SupportedDepositOption, SwapperEmbedOptions, SwapperStyles } from "@swapper-finance/deposit-sdk";
3
+ import { type Token } from "@spicenet-io/spiceflow-core";
4
+ import type { DepositSource, SpiceSwapperConfig, SwapperEmbedFactory } from "../../../types/deposit";
5
+ import type { ResolvedDarkPalette } from "../../../utils/theme";
6
+ export declare const DEFAULT_SWAPPER_INTEGRATOR_ID = "692fb8af264069ca12a9";
7
+ export declare const SWAPPER_FALLBACK_DESTINATION_CHAIN_ID = 42161;
8
+ export declare const SWAPPER_SUPPORTED_DESTINATION_CHAIN_IDS: readonly number[];
9
+ export declare function resolveSwapperDestinationChainId(params: {
10
+ targetKind: "external" | "embedded";
11
+ appChainId?: number;
12
+ }): number;
13
+ export declare function getSwapperDestinationToken(chainId?: number): Token | undefined;
14
+ export declare function resolveSwapperConfig(config?: SpiceSwapperConfig): {
15
+ integratorId: string;
16
+ enabled: boolean;
17
+ embedFactory?: SwapperEmbedFactory;
18
+ };
19
+ export declare const defaultSwapperEmbedFactory: SwapperEmbedFactory;
20
+ export declare function buildSwapperStyles(dk: ResolvedDarkPalette, dark: boolean, primaryColor: string): SwapperStyles;
21
+ export declare function getSupportedDepositOptions(source: Exclude<DepositSource, "wallet"> | null): SupportedDepositOption[];
22
+ export declare function buildSwapperOptions(params: {
23
+ integratorId: string;
24
+ depositWalletAddress: Address;
25
+ source: Exclude<DepositSource, "wallet"> | null;
26
+ styles: SwapperStyles;
27
+ destinationChainId?: number;
28
+ }): SwapperEmbedOptions;
29
+ export declare function readSwapperUsdcBalance(targetAddress: Address, chainId?: number): Promise<bigint>;
30
+ export declare function waitForUsdcArrival(targetAddress: Address, baseline: bigint, options?: {
31
+ timeoutMs?: number;
32
+ intervalMs?: number;
33
+ signal?: AbortSignal;
34
+ chainId?: number;
35
+ }): Promise<bigint | null>;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import type { SelectSourceModalProps } from "../../../types/deposit";
3
+ export declare const SelectSourceModal: React.FC<SelectSourceModalProps>;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import type { SwapperDepositModalProps } from "../../../types/deposit";
3
+ export declare const SwapperDepositModal: React.FC<SwapperDepositModalProps>;
@@ -7,7 +7,6 @@ import type { ResolvedExactOutputSwap } from "../../../utils/swapQuotes";
7
7
  import type { ExecutionOptions } from "../../../hooks/useSpiceExecution";
8
8
  import type { FeeEstimateSummary } from "@spicenet-io/spiceflow-core";
9
9
  type EstimateFn = (chainBatches: ChainBatch[], tokenAddress: string, tokenTransferAmount: bigint, options?: ExecutionOptions) => Promise<FeeEstimateSummary>;
10
- export declare function buildEmbeddedEscrowDepositBatch(token: Address, amount: bigint, chainId: number): ChainBatch;
11
10
  export declare function stripSpicenetFundingBatches(batches: ChainBatch[]): ChainBatch[];
12
11
  export declare function scaleTokenAmount(amount: bigint, fromDecimals: number, toDecimals: number): bigint;
13
12
  export interface BatchBuilderContext {
@@ -12,14 +12,12 @@ export type PaymentResult = {
12
12
  txHash?: string;
13
13
  error?: string;
14
14
  };
15
- export declare function isExternalSource(asset: SelectedAsset["asset"] | null | undefined, isNon7702: boolean): boolean;
16
15
  export type ExecutorContext = {
17
16
  selectedAsset: SelectedAsset | null;
18
17
  parsedAmount: number;
19
18
  currentPaymentAmount: string;
20
19
  isInsufficientBalance: boolean;
21
20
  isPayMode: boolean;
22
- isFeeInclusiveInput: boolean;
23
21
  isNon7702: boolean;
24
22
  isSourceDestToken: boolean;
25
23
  needsSwap: boolean;
@@ -36,7 +36,6 @@ export declare function estimatePayFunding(args: {
36
36
  export declare function estimateSupplyMaxAmount(ctx: {
37
37
  asset: Asset;
38
38
  isPayMode: boolean;
39
- isFeeInclusiveInput?: boolean;
40
39
  isNon7702: boolean;
41
40
  needsSwap: boolean;
42
41
  isQuoting: boolean;
@@ -50,7 +49,6 @@ export interface FeePreviewContext {
50
49
  signal?: AbortSignal;
51
50
  selectedAsset: SelectedAsset | null;
52
51
  isPayMode: boolean;
53
- isFeeInclusiveInput?: boolean;
54
52
  parsedAmount: number;
55
53
  needsSwap: boolean;
56
54
  exactOutputSwap: ResolvedExactOutputSwap | null;
@@ -6,13 +6,6 @@ export declare function sendTokenTransferTx(extWc: any, params: {
6
6
  amount: bigint;
7
7
  viemChain?: unknown;
8
8
  }): Promise<`0x${string}`>;
9
- export declare function readEmbeddedShortfall(params: {
10
- sourceClient: any;
11
- holder: Address;
12
- tokenAddr: Address;
13
- isNative: boolean;
14
- amount: bigint;
15
- }): Promise<bigint>;
16
9
  export declare function fundEmbeddedWallet(params: {
17
10
  extWc: any;
18
11
  sourceClient: any;
@@ -19,5 +19,3 @@ export type { PartnerWhitelistCheckResponse, UseIsUserWhitelistedOptions, } from
19
19
  export { useSupplyAssets, isSupportedSupplyAsset } from "./useSupplyAssets";
20
20
  export { useSupplyQuote, resolveInputSupplySwapQuote } from "./useSupplyQuote";
21
21
  export type { UseSupplyQuoteOpts, SupplyQuoteResult } from "./useSupplyQuote";
22
- export { useSpiceSupply } from "./useSpiceSupply";
23
- export type { UseSpiceSupplyParams, UseSpiceSupplyResult, } from "./useSpiceSupply";
@@ -1,6 +1,6 @@
1
1
  import { type Address } from "viem";
2
2
  import type { Asset } from "../types/assets";
3
- export declare function isSupportedSupplyAsset(asset: Pick<Asset, "address" | "chainTokens" | "isNative">, supportedSourceAssets?: string[]): boolean;
3
+ export declare function isSupportedSupplyAsset(asset: Pick<Asset, "address" | "chainTokens">, supportedSourceAssets?: string[]): boolean;
4
4
  type DestinationToken = {
5
5
  address: Address;
6
6
  decimals: number;
@@ -14,11 +14,9 @@ export declare function useSupplyAssets(opts: {
14
14
  supportedSourceAssets?: string[];
15
15
  sourceChains?: number[];
16
16
  enabled: boolean;
17
- includeExternalWalletAssets?: boolean;
18
17
  }): {
19
18
  displayAssets: (Asset & {
20
19
  _source: "wallet" | "spice";
21
- _fundingWallet?: "embedded" | "external";
22
20
  })[];
23
21
  filteredSpiceAssets: Asset[];
24
22
  walletAssets: Asset[];
@@ -1,5 +1,6 @@
1
1
  import { type Address } from "viem";
2
- import type { LiquidityVenue, ResolvedSwap } from "../utils/crossChainRouter/liquidityVenues";
2
+ import { type LiquidityVenuesConfig } from "../utils/crossChainRouter/venueConfig";
3
+ import type { ResolvedSwap } from "../utils/crossChainRouter/liquidityVenues";
3
4
  import { type ExactOutputSwapIntent, type ResolvedExactOutputSwap } from "../utils/swapQuotes";
4
5
  import type { SelectedAsset } from "../types/assets";
5
6
  export interface UseSupplyQuoteOpts {
@@ -14,8 +15,6 @@ export interface UseSupplyQuoteOpts {
14
15
  chainId: number;
15
16
  recipient: Address | undefined;
16
17
  paymentAmount?: string;
17
- maxSlippage?: number;
18
- resolveInputSwap?: LiquidityVenue["resolve"];
19
18
  resolveExactOutputSwap?: (intent: ExactOutputSwapIntent, chainId: number, recipient: Address) => Promise<ResolvedExactOutputSwap | null>;
20
19
  }
21
20
  export interface SupplyQuoteResult {
@@ -37,6 +36,6 @@ export declare function resolveInputSupplySwapQuote(params: {
37
36
  tokenIn: Address;
38
37
  tokenOut: Address;
39
38
  amountIn: bigint;
40
- maxSlippage?: number;
39
+ liquidityVenues?: LiquidityVenuesConfig;
41
40
  }): Promise<ResolvedSwap>;
42
41
  export declare function useSupplyQuote(opts: UseSupplyQuoteOpts): SupplyQuoteResult;
@@ -0,0 +1,23 @@
1
+ import type { Address } from "viem";
2
+ import type { DepositSource, SwapperEmbedFactory, SwapperTransactionSuccessEvent } from "../types/deposit";
3
+ import type { ResolvedDarkPalette } from "../utils/theme";
4
+ type WidgetSource = Exclude<DepositSource, "wallet">;
5
+ interface UseSwapperEmbedParams {
6
+ enabled: boolean;
7
+ integratorId: string;
8
+ depositWalletAddress?: Address;
9
+ destinationChainId?: number;
10
+ brand: {
11
+ dk: ResolvedDarkPalette;
12
+ dark: boolean;
13
+ primaryColor: string;
14
+ };
15
+ embedFactory?: SwapperEmbedFactory;
16
+ onTransactionSuccess: (event?: SwapperTransactionSuccessEvent) => void;
17
+ onCloseRequest: () => void;
18
+ }
19
+ export declare function useSwapperEmbed({ enabled, integratorId, depositWalletAddress, destinationChainId, brand, embedFactory, onTransactionSuccess, onCloseRequest, }: UseSwapperEmbedParams): {
20
+ showWidget: (placeholder: HTMLElement, source: WidgetSource) => void;
21
+ hideWidget: () => void;
22
+ };
23
+ export {};