@latchprotocol/widgets 0.1.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 (132) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +649 -0
  3. package/dist/adapters/binDistribution.d.ts +19 -0
  4. package/dist/adapters/binDistribution.d.ts.map +1 -0
  5. package/dist/adapters/protocol.d.ts +409 -0
  6. package/dist/adapters/protocol.d.ts.map +1 -0
  7. package/dist/adapters/sale.d.ts +142 -0
  8. package/dist/adapters/sale.d.ts.map +1 -0
  9. package/dist/adapters/viem.d.ts +89 -0
  10. package/dist/adapters/viem.d.ts.map +1 -0
  11. package/dist/callpath/constants.d.ts +218 -0
  12. package/dist/callpath/constants.d.ts.map +1 -0
  13. package/dist/callpath/launch.d.ts +1979 -0
  14. package/dist/callpath/launch.d.ts.map +1 -0
  15. package/dist/callpath/liquidity.d.ts +103 -0
  16. package/dist/callpath/liquidity.d.ts.map +1 -0
  17. package/dist/callpath/plan.d.ts +34 -0
  18. package/dist/callpath/plan.d.ts.map +1 -0
  19. package/dist/callpath/swap.d.ts +129 -0
  20. package/dist/callpath/swap.d.ts.map +1 -0
  21. package/dist/chunks/SwapWidget-DgyHAVc8.js +2404 -0
  22. package/dist/chunks/SwapWidget-DgyHAVc8.js.map +1 -0
  23. package/dist/chunks/scan-Dhu7f4Nl.js +2497 -0
  24. package/dist/chunks/scan-Dhu7f4Nl.js.map +1 -0
  25. package/dist/chunks/useLocker-D1c_NTk-.js +1613 -0
  26. package/dist/chunks/useLocker-D1c_NTk-.js.map +1 -0
  27. package/dist/components/LaunchWidget.d.ts +117 -0
  28. package/dist/components/LaunchWidget.d.ts.map +1 -0
  29. package/dist/components/LiquidityWidget.d.ts +33 -0
  30. package/dist/components/LiquidityWidget.d.ts.map +1 -0
  31. package/dist/components/LockerWidget.d.ts +51 -0
  32. package/dist/components/LockerWidget.d.ts.map +1 -0
  33. package/dist/components/LocksWidgets.d.ts +61 -0
  34. package/dist/components/LocksWidgets.d.ts.map +1 -0
  35. package/dist/components/SwapWidget.d.ts +165 -0
  36. package/dist/components/SwapWidget.d.ts.map +1 -0
  37. package/dist/components/TokenTrustPanel.d.ts +32 -0
  38. package/dist/components/TokenTrustPanel.d.ts.map +1 -0
  39. package/dist/components/lockCharts.d.ts +29 -0
  40. package/dist/components/lockCharts.d.ts.map +1 -0
  41. package/dist/components/portal.d.ts +10 -0
  42. package/dist/components/portal.d.ts.map +1 -0
  43. package/dist/components/primitives.d.ts +139 -0
  44. package/dist/components/primitives.d.ts.map +1 -0
  45. package/dist/components/swap/SwapSettings.d.ts +12 -0
  46. package/dist/components/swap/SwapSettings.d.ts.map +1 -0
  47. package/dist/components/swap/TokenSelect.d.ts +61 -0
  48. package/dist/components/swap/TokenSelect.d.ts.map +1 -0
  49. package/dist/components/swap/state.d.ts +208 -0
  50. package/dist/components/swap/state.d.ts.map +1 -0
  51. package/dist/config/chain.d.ts +163 -0
  52. package/dist/config/chain.d.ts.map +1 -0
  53. package/dist/config/integrator.d.ts +121 -0
  54. package/dist/config/integrator.d.ts.map +1 -0
  55. package/dist/context/WidgetProvider.d.ts +78 -0
  56. package/dist/context/WidgetProvider.d.ts.map +1 -0
  57. package/dist/core/clMath.d.ts +98 -0
  58. package/dist/core/clMath.d.ts.map +1 -0
  59. package/dist/core/errors.d.ts +18 -0
  60. package/dist/core/errors.d.ts.map +1 -0
  61. package/dist/core/format.d.ts +47 -0
  62. package/dist/core/format.d.ts.map +1 -0
  63. package/dist/core/liquidityGuards.d.ts +53 -0
  64. package/dist/core/liquidityGuards.d.ts.map +1 -0
  65. package/dist/core/liquidityRefresh.d.ts +35 -0
  66. package/dist/core/liquidityRefresh.d.ts.map +1 -0
  67. package/dist/core/math.d.ts +129 -0
  68. package/dist/core/math.d.ts.map +1 -0
  69. package/dist/core/pool.d.ts +33 -0
  70. package/dist/core/pool.d.ts.map +1 -0
  71. package/dist/core/tokenLists.d.ts +46 -0
  72. package/dist/core/tokenLists.d.ts.map +1 -0
  73. package/dist/embed/iframe.d.ts +185 -0
  74. package/dist/embed/iframe.d.ts.map +1 -0
  75. package/dist/embed/lockBadge.d.ts +55 -0
  76. package/dist/embed/lockBadge.d.ts.map +1 -0
  77. package/dist/embed/webComponent.d.ts +83 -0
  78. package/dist/embed/webComponent.d.ts.map +1 -0
  79. package/dist/embed.d.ts +25 -0
  80. package/dist/embed.d.ts.map +1 -0
  81. package/dist/embed.js +543 -0
  82. package/dist/embed.js.map +1 -0
  83. package/dist/headless.d.ts +60 -0
  84. package/dist/headless.d.ts.map +1 -0
  85. package/dist/headless.js +223 -0
  86. package/dist/headless.js.map +1 -0
  87. package/dist/hooks/useAsyncResource.d.ts +38 -0
  88. package/dist/hooks/useAsyncResource.d.ts.map +1 -0
  89. package/dist/hooks/useLaunch.d.ts +140 -0
  90. package/dist/hooks/useLaunch.d.ts.map +1 -0
  91. package/dist/hooks/useLiquidity.d.ts +91 -0
  92. package/dist/hooks/useLiquidity.d.ts.map +1 -0
  93. package/dist/hooks/useLocker.d.ts +77 -0
  94. package/dist/hooks/useLocker.d.ts.map +1 -0
  95. package/dist/hooks/useLocks.d.ts +33 -0
  96. package/dist/hooks/useLocks.d.ts.map +1 -0
  97. package/dist/hooks/useSwapExecute.d.ts +46 -0
  98. package/dist/hooks/useSwapExecute.d.ts.map +1 -0
  99. package/dist/hooks/useSwapQuote.d.ts +51 -0
  100. package/dist/hooks/useSwapQuote.d.ts.map +1 -0
  101. package/dist/hooks/useTokenLists.d.ts +26 -0
  102. package/dist/hooks/useTokenLists.d.ts.map +1 -0
  103. package/dist/hooks/useTokenTrust.d.ts +40 -0
  104. package/dist/hooks/useTokenTrust.d.ts.map +1 -0
  105. package/dist/hooks/useTokens.d.ts +15 -0
  106. package/dist/hooks/useTokens.d.ts.map +1 -0
  107. package/dist/index.d.ts +59 -0
  108. package/dist/index.d.ts.map +1 -0
  109. package/dist/index.js +1052 -0
  110. package/dist/index.js.map +1 -0
  111. package/dist/latch-embed.d.ts +19 -0
  112. package/dist/latch-embed.d.ts.map +1 -0
  113. package/dist/latch-embed.js +950 -0
  114. package/dist/latch-embed.js.map +1 -0
  115. package/dist/latch-embed.mjs +13162 -0
  116. package/dist/latch-embed.mjs.map +1 -0
  117. package/dist/locker/model.d.ts +73 -0
  118. package/dist/locker/model.d.ts.map +1 -0
  119. package/dist/locks/embedModel.d.ts +22 -0
  120. package/dist/locks/embedModel.d.ts.map +1 -0
  121. package/dist/locks/fetch.d.ts +60 -0
  122. package/dist/locks/fetch.d.ts.map +1 -0
  123. package/dist/locks/model.d.ts +143 -0
  124. package/dist/locks/model.d.ts.map +1 -0
  125. package/dist/locks/scan.d.ts +25 -0
  126. package/dist/locks/scan.d.ts.map +1 -0
  127. package/dist/styles/css.d.ts +32 -0
  128. package/dist/styles/css.d.ts.map +1 -0
  129. package/dist/styles.css +895 -0
  130. package/dist/trust/model.d.ts +48 -0
  131. package/dist/trust/model.d.ts.map +1 -0
  132. package/package.json +102 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Headless liquidity provision, for both pool types.
3
+ *
4
+ * The pool-type difference lives entirely in the {@link LiquidityRange} union
5
+ * and in {@link ../callpath/liquidity.js}. Everything a UI touches here - the
6
+ * range editor state, the quote, the execution state machine - is identical for
7
+ * concentrated liquidity and for the liquidity book.
8
+ */
9
+ import type { Address, Hex } from "viem";
10
+ import type { AddLiquidityQuote, ApprovalRequirement, LiquidityRange, PoolInfo, PositionInfo, RemoveLiquidityQuote, TokenInfo } from "../adapters/protocol.js";
11
+ import { type AsyncResource, type AsyncStatus } from "./useAsyncResource.js";
12
+ /** Lifecycle of a liquidity transaction. */
13
+ export type LiquidityExecutionStep = "idle" | "needs-approval" | "approving" | "building" | "awaiting-signature" | "pending" | "success" | "error";
14
+ /** Builds a default range around the pool's current position. */
15
+ export declare function defaultRangeFor(pool: PoolInfo, currentTick: number | null, activeId: number | null, widthFactor?: number): LiquidityRange | null;
16
+ /** Widens or narrows a range symmetrically, respecting the pool's granularity. */
17
+ export declare function adjustRange(range: LiquidityRange, pool: PoolInfo, deltaSteps: number): LiquidityRange;
18
+ /** Human-readable description of a range, for labels and summaries. */
19
+ export declare function describeRange(range: LiquidityRange): string;
20
+ /** Parameters for {@link useAddLiquidityQuote}. */
21
+ export interface UseAddLiquidityQuoteParams {
22
+ readonly pool: PoolInfo | null;
23
+ readonly range: LiquidityRange | null;
24
+ readonly amount0Desired: bigint | null;
25
+ readonly amount1Desired: bigint | null;
26
+ readonly enabled?: boolean;
27
+ }
28
+ /** Quotes an add-liquidity operation. */
29
+ export declare function useAddLiquidityQuote(params: UseAddLiquidityQuoteParams): AsyncResource<AddLiquidityQuote | null> & {
30
+ readonly isMock: boolean;
31
+ };
32
+ /** Result of {@link useAddLiquidityExecute}. */
33
+ export interface UseLiquidityExecuteResult {
34
+ readonly step: LiquidityExecutionStep;
35
+ readonly error: Error | null;
36
+ readonly txHash: Hex | null;
37
+ readonly approvals: readonly ApprovalRequirement[];
38
+ readonly needsApproval: boolean;
39
+ /**
40
+ * The token the wallet holds too little of for this deposit, or `null` when
41
+ * every balance covers it (or has not been read yet). While set, neither an
42
+ * approval nor the deposit is offered: `approve` and `execute` re-read the
43
+ * balances and refuse with `InsufficientBalanceError` before anything is signed.
44
+ */
45
+ readonly insufficient: TokenInfo | null;
46
+ readonly statusMessage: string;
47
+ approve(): Promise<void>;
48
+ execute(): Promise<void>;
49
+ reset(): void;
50
+ }
51
+ /** Parameters for {@link useAddLiquidityExecute}. */
52
+ export interface UseAddLiquidityExecuteParams {
53
+ readonly quote: AddLiquidityQuote | null;
54
+ /** Slippage applied to the deposited amounts, in bps. */
55
+ readonly slippageBps?: number;
56
+ readonly recipient?: Address;
57
+ readonly hookData?: Hex;
58
+ readonly onSuccess?: (hash: Hex) => void;
59
+ }
60
+ /** Drives approve-then-add-liquidity for either pool type. */
61
+ export declare function useAddLiquidityExecute(params: UseAddLiquidityExecuteParams): UseLiquidityExecuteResult;
62
+ /**
63
+ * Positions held by `owner`, optionally filtered to one pool. `refreshKey`
64
+ * re-reads the list whenever it changes: pass a counter the host advances on
65
+ * every confirmed add or removal (the LiquidityWidget does), so an emptied
66
+ * position disappears and amounts update without a reload.
67
+ */
68
+ export declare function usePositions(owner: Address | null, pool?: PoolInfo | null, refreshKey?: unknown): AsyncResource<readonly PositionInfo[]>;
69
+ /** Parameters for {@link useRemoveLiquidity}. */
70
+ export interface UseRemoveLiquidityParams {
71
+ readonly position: PositionInfo | null;
72
+ /** Fraction to withdraw, in bps. */
73
+ readonly percentBps: number;
74
+ readonly slippageBps?: number;
75
+ readonly recipient?: Address;
76
+ readonly onSuccess?: (hash: Hex) => void;
77
+ }
78
+ /** Result of {@link useRemoveLiquidity}. */
79
+ export interface UseRemoveLiquidityResult {
80
+ readonly quote: RemoveLiquidityQuote | null;
81
+ readonly quoteStatus: AsyncStatus;
82
+ readonly step: LiquidityExecutionStep;
83
+ readonly error: Error | null;
84
+ readonly txHash: Hex | null;
85
+ readonly statusMessage: string;
86
+ execute(): Promise<void>;
87
+ reset(): void;
88
+ }
89
+ /** Quotes and executes a withdrawal from either pool type. */
90
+ export declare function useRemoveLiquidity(params: UseRemoveLiquidityParams): UseRemoveLiquidityResult;
91
+ //# sourceMappingURL=useLiquidity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLiquidity.d.ts","sourceRoot":"","sources":["../../src/hooks/useLiquidity.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACzC,OAAO,KAAK,EACV,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,SAAS,EACV,MAAM,yBAAyB,CAAC;AAQjC,OAAO,EAAoB,KAAK,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE/F,4CAA4C;AAC5C,MAAM,MAAM,sBAAsB,G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E,GAAG,KAAK,IAAI,CAAC;CAC1C;AAED,4CAA4C;AAC5C,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,KAAK,IAAI,IAAI,CAAC;CACf;AAED,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,wBAAwB,GAC/B,wBAAwB,CA0E1B"}
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Headless controllers for `LockerWidget`: the wallet, the live fees, the
3
+ * connected wallet's locks, and a step runner that simulates every call with
4
+ * its exact bytes before the wallet sees it and checks every receipt.
5
+ *
6
+ * The wallet is the same minimal surface `createViemAdapter` takes
7
+ * (`WidgetWallet`: `getAccount` + `sendTransaction`), or, when none is passed,
8
+ * the mounted `WidgetProvider`'s adapter. Reads, simulations and receipts go
9
+ * through the viem `PublicClient` the host passes, on the lock contracts'
10
+ * chain.
11
+ */
12
+ import type { Address, Hex, PublicClient } from "viem";
13
+ import { type FeeGateTerms, type PositionLockRecord, type TokenLockView, type UtilityCall } from "@latchprotocol/sdk/lock";
14
+ import type { WidgetWallet } from "../adapters/viem.js";
15
+ import { type AsyncResource } from "./useAsyncResource.js";
16
+ /** The two lock contracts, from the host's address book. `null` = the chain has no address for it; surfaces render "coming soon". */
17
+ export interface LockerContracts {
18
+ readonly positionLock: Address | null;
19
+ readonly tokenLock: Address | null;
20
+ }
21
+ /** The wallet a locker signs with: the prop, else the provider's adapter, else none. */
22
+ export declare function useLockerWallet(wallet: WidgetWallet | undefined): WidgetWallet | null;
23
+ /** The connected account, re-read every few seconds so a wallet switch shows. */
24
+ export declare function useLockerAccount(wallet: WidgetWallet | null): AsyncResource<Address | null>;
25
+ export interface LockerFees {
26
+ readonly position: FeeGateTerms | null;
27
+ readonly token: FeeGateTerms | null;
28
+ }
29
+ /** Each lock contract's fee terms, read live (`feeWei`, `pendingFee`, cap, recipient). */
30
+ export declare function useLockerFees(client: PublicClient, contracts: LockerContracts): AsyncResource<LockerFees>;
31
+ export interface MyLocks {
32
+ readonly positions: readonly PositionLockRecord[];
33
+ readonly tokens: readonly TokenLockView[];
34
+ /** The chain's `block.timestamp` when read. */
35
+ readonly now: bigint;
36
+ }
37
+ /** Locks `account` owns or has been offered, on both contracts. */
38
+ export declare function useMyLocks(client: PublicClient, contracts: LockerContracts, account: Address | null): AsyncResource<MyLocks>;
39
+ /** Thrown when a mined transaction reverted: the receipt, not the hash, is the proof. */
40
+ export declare class TransactionRevertedError extends Error {
41
+ readonly hash: Hex;
42
+ constructor(hash: Hex);
43
+ }
44
+ /**
45
+ * One call: simulate with the exact bytes and value from `account`, send
46
+ * through the wallet, wait for the receipt, and throw unless it succeeded.
47
+ */
48
+ export declare function simulateSendConfirm(client: PublicClient, wallet: WidgetWallet, account: Address, call: UtilityCall): Promise<Hex>;
49
+ export interface RunnerStep {
50
+ readonly label: string;
51
+ /** Built when the step starts, so it reads the chain as it is after the previous step. */
52
+ readonly build: () => Promise<UtilityCall>;
53
+ }
54
+ export type RunnerState = {
55
+ readonly k: "idle";
56
+ } | {
57
+ readonly k: "running";
58
+ readonly labels: readonly string[];
59
+ readonly active: number;
60
+ readonly phase: "simulating" | "signing" | "confirming";
61
+ } | {
62
+ readonly k: "done";
63
+ readonly labels: readonly string[];
64
+ readonly hashes: readonly Hex[];
65
+ } | {
66
+ readonly k: "failed";
67
+ readonly labels: readonly string[];
68
+ readonly active: number;
69
+ readonly message: string;
70
+ };
71
+ /** Runs steps in order; the first failure stops the run and is described in one sentence. */
72
+ export declare function useLockerRunner(client: PublicClient, wallet: WidgetWallet | null, account: Address | null, onDone?: () => void): {
73
+ state: RunnerState;
74
+ run(steps: readonly RunnerStep[]): Promise<void>;
75
+ reset(): void;
76
+ };
77
+ //# sourceMappingURL=useLocker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocker.d.ts","sourceRoot":"","sources":["../../src/hooks/useLocker.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE7E,qIAAqI;AACrI,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,YAAY,EAAE,OAAO,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;CACpC;AAED,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,CAWrF;AAED,iFAAiF;AACjF,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC,CAE3F;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;CACrC;AAED,0FAA0F;AAC1F,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,GAAG,aAAa,CAAC,UA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,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,EAAE,CAAA;CAAE,GAC3F;IAAE,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpH,6FAA6F;AAC7F,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,IAAI,GAAG;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,GAAG,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,KAAK,IAAI,IAAI,CAAA;CAAE,CAsCxN"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Headless readers for the lock widgets: one pool's position locks or one
3
+ * token's locks, read through the MIT SDK (`@latchprotocol/sdk/lock`), plus
4
+ * the chain clock their countdowns run on.
5
+ *
6
+ * No provider is required: a lock badge is read-only and takes a viem
7
+ * `PublicClient` directly, so a host can drop it beside any pool without the
8
+ * swap stack. A `null` lock address (the chain has no address for it) leaves the
9
+ * resource `idle`; the component says "coming soon" rather than reading.
10
+ * The loaders themselves live in `../locks/fetch.ts`, React-free.
11
+ */
12
+ import type { Address, Hex, PublicClient } from "viem";
13
+ import { type LpLockerSource } from "../locks/model.js";
14
+ import { type NativeCurrencyMeta, type PoolLocksData, type TokenLocksData } from "../locks/fetch.js";
15
+ import { type AsyncResource } from "./useAsyncResource.js";
16
+ export { fetchPoolLocks, fetchTokenLocks, poolLocksEnabled, type LocksReadOptions, type NativeCurrencyMeta, type PoolLocksData, type TokenLocksData } from "../locks/fetch.js";
17
+ export interface UseLocksOptions {
18
+ readonly native?: NativeCurrencyMeta;
19
+ /** Re-read interval; default 60 s. 0 disables polling. */
20
+ readonly refetchIntervalMs?: number;
21
+ /** The protocol's LP lockers: their permanent liquidity is read and counted. */
22
+ readonly lp?: LpLockerSource;
23
+ }
24
+ /** Every lock in one pool, as a React resource. See {@link fetchPoolLocks}. */
25
+ export declare function usePoolLocks(client: PublicClient, positionLock: Address | null, poolId: Hex, options?: UseLocksOptions): AsyncResource<PoolLocksData>;
26
+ /** Every lock of one token, as a React resource. See {@link fetchTokenLocks}. */
27
+ export declare function useTokenLocks(client: PublicClient, tokenLock: Address | null, token: Address, options?: UseLocksOptions): AsyncResource<TokenLocksData>;
28
+ /**
29
+ * The chain's `block.timestamp` now: `chainNow` as read, advanced by the
30
+ * local clock once a second. `null` until there is a read.
31
+ */
32
+ export declare function useChainClock(chainNow: bigint | null, readAtMs: number | null): bigint | null;
33
+ //# sourceMappingURL=useLocks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLocks.d.ts","sourceRoot":"","sources":["../../src/hooks/useLocks.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAKL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE7E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,gBAAgB,EAAE,KAAK,gBAAgB,EAAE,KAAK,kBAAkB,EAAE,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE/K,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IACrC,0DAA0D;IAC1D,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,gFAAgF;IAChF,QAAQ,CAAC,EAAE,CAAC,EAAE,cAAc,CAAC;CAC9B;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAC1B,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,OAAO,GAAG,IAAI,EAC5B,MAAM,EAAE,GAAG,EACX,OAAO,GAAE,eAAoB,GAC5B,aAAa,CAAC,aAAa,CAAC,CAQ9B;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAC3B,MAAM,EAAE,YAAY,EACpB,SAAS,EAAE,OAAO,GAAG,IAAI,EACzB,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,eAAoB,GAC5B,aAAa,CAAC,cAAc,CAAC,CAS/B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAS7F"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Headless swap execution: approvals, signature, confirmation.
3
+ *
4
+ * The integrator fee is threaded in here, not chosen here. The hook reads the
5
+ * validated config from context and passes it to `adapter.buildSwap`, which
6
+ * hands it to `buildSwapCall`, which encodes the `TAKE_PORTION` (or
7
+ * `PAY_PORTION`) step. There is no code path that executes a swap while
8
+ * dropping the fee, and none that executes one with an unvalidated fee.
9
+ */
10
+ import type { Hex } from "viem";
11
+ import type { ApprovalRequirement, SwapQuoteResult, TokenInfo, WidgetTransactionRequest } from "../adapters/protocol.js";
12
+ import type { QuoteBreakdown } from "../core/math.js";
13
+ /** Where a swap is in its lifecycle. */
14
+ export type SwapExecutionStep = "idle" | "needs-approval" | "approving" | "building" | "awaiting-signature" | "pending" | "success" | "error";
15
+ /** Parameters for {@link useSwapExecute}. */
16
+ export interface UseSwapExecuteParams {
17
+ readonly tokenIn: TokenInfo | null;
18
+ readonly tokenOut: TokenInfo | null;
19
+ readonly amountIn: bigint | null;
20
+ readonly quote: SwapQuoteResult | null;
21
+ readonly breakdown: QuoteBreakdown | null;
22
+ /** Defaults to the connected account. */
23
+ readonly recipient?: `0x${string}`;
24
+ /** Called once the swap transaction confirms. */
25
+ readonly onSuccess?: (hash: Hex) => void;
26
+ readonly onError?: (error: Error) => void;
27
+ }
28
+ /** Result of {@link useSwapExecute}. */
29
+ export interface UseSwapExecuteResult {
30
+ readonly step: SwapExecutionStep;
31
+ readonly error: Error | null;
32
+ readonly txHash: Hex | null;
33
+ readonly approvals: readonly ApprovalRequirement[];
34
+ readonly needsApproval: boolean;
35
+ readonly canExecute: boolean;
36
+ /** One-line description of the current state, suitable for `aria-live`. */
37
+ readonly statusMessage: string;
38
+ /** The built transaction, exposed so a host can inspect or simulate it. */
39
+ readonly preparedTransaction: WidgetTransactionRequest | null;
40
+ approve(): Promise<void>;
41
+ execute(): Promise<void>;
42
+ reset(): void;
43
+ }
44
+ /** Drives the approve-then-swap flow. */
45
+ export declare function useSwapExecute(params: UseSwapExecuteParams): UseSwapExecuteResult;
46
+ //# sourceMappingURL=useSwapExecute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSwapExecute.d.ts","sourceRoot":"","sources":["../../src/hooks/useSwapExecute.ts"],"names":[],"mappings":"AACA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,wBAAwB,EACzB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,wCAAwC;AACxC,MAAM,MAAM,iBAAiB,GACzB,MAAM,GACN,gBAAgB,GAChB,WAAW,GACX,UAAU,GACV,oBAAoB,GACpB,SAAS,GACT,SAAS,GACT,OAAO,CAAC;AAEZ,6CAA6C;AAC7C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,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2
+ * Headless swap quoting.
3
+ *
4
+ * Returns the adapter's raw quote *and* the derived
5
+ * {@link ../core/math.js | QuoteBreakdown}, which already has the integrator fee
6
+ * split out. A custom UI built on this hook shows the integrator's cut - and
7
+ * the user's true net - without having to know the fee mechanism exists.
8
+ */
9
+ import type { SwapQuoteResult, TokenInfo } from "../adapters/protocol.js";
10
+ import { type QuoteBreakdown } from "../core/math.js";
11
+ import type { PoolId } from "@latchprotocol/sdk";
12
+ import { type AsyncStatus } from "./useAsyncResource.js";
13
+ /** Parameters for {@link useSwapQuote}. */
14
+ export interface UseSwapQuoteParams {
15
+ readonly tokenIn: TokenInfo | null;
16
+ readonly tokenOut: TokenInfo | null;
17
+ /** Input amount in the smallest unit, or `null` while the field is empty. */
18
+ readonly amountIn: bigint | null;
19
+ /** Overrides the provider's default slippage. */
20
+ readonly slippageBps?: number;
21
+ /** Re-quote interval. Quotes go stale; 15s is a sane default for a UI. */
22
+ readonly refetchIntervalMs?: number;
23
+ readonly enabled?: boolean;
24
+ /** Quote through this pool only. See `SwapQuoteRequest.poolId`. */
25
+ readonly poolId?: PoolId;
26
+ }
27
+ /** Result of {@link useSwapQuote}. */
28
+ export interface UseSwapQuoteResult {
29
+ readonly status: AsyncStatus;
30
+ readonly quote: SwapQuoteResult | null;
31
+ /** Fee-aware derivation of the quote. `null` until a quote arrives. */
32
+ readonly breakdown: QuoteBreakdown | null;
33
+ readonly error: Error | null;
34
+ readonly isRefreshing: boolean;
35
+ readonly updatedAt: number | null;
36
+ /** True when the numbers came from the mock adapter and are not real. */
37
+ readonly isMock: boolean;
38
+ /** Output units per input unit, for display only. */
39
+ readonly rate: number | null;
40
+ readonly slippageBps: number;
41
+ refetch(): void;
42
+ }
43
+ /** Quotes a swap and derives the fee-inclusive breakdown. */
44
+ export declare function useSwapQuote(params: UseSwapQuoteParams): UseSwapQuoteResult;
45
+ /** Tracks a slippage setting with validation, for UIs that expose the control. */
46
+ export declare function useSlippageSetting(initialBps?: number): {
47
+ slippageBps: number;
48
+ setSlippageBps(next: number): void;
49
+ error: string | null;
50
+ };
51
+ //# sourceMappingURL=useSwapQuote.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSwapQuote.d.ts","sourceRoot":"","sources":["../../src/hooks/useSwapQuote.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAE1E,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAE3E,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IACpC,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,iDAAiD;IACjD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,mEAAmE;IACnE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,sCAAsC;AACtC,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC;IACvC,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,qDAAqD;IACrD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,6DAA6D;AAC7D,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAwG3E;AAED,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,CAmBA"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Fetches, validates and merges the token lists a widget was given, for the
3
+ * adapter's chain. Headless: returns entries and per-URL failures, renders
4
+ * nothing. A list that fails to load is reported by URL and reason and simply
5
+ * contributes no tokens — the picker still works on the adapter's tokens and
6
+ * the lists that did load. Nothing is cached across mounts; caching is the
7
+ * host app's job (the SDK is localStorage-free by design).
8
+ */
9
+ import type { TokenInfo } from "../adapters/protocol.js";
10
+ import { type TokenListInput } from "../core/tokenLists.js";
11
+ export interface TokenListFailure {
12
+ readonly url: string;
13
+ readonly message: string;
14
+ }
15
+ export interface TokenListsResource {
16
+ /** Entries from every list that loaded, merged (first list wins), for the adapter's chain. */
17
+ readonly tokens: readonly TokenInfo[];
18
+ /** `loading` while any URL is in flight; `ready` once every input settled (some may have failed). */
19
+ readonly status: "idle" | "loading" | "ready";
20
+ readonly failures: readonly TokenListFailure[];
21
+ /** The names of the lists that loaded, in input order. */
22
+ readonly sources: readonly string[];
23
+ }
24
+ /** Loads `inputs` (lists or URLs) and merges them for the adapter's chain. */
25
+ export declare function useTokenLists(inputs: readonly TokenListInput[] | undefined): TokenListsResource;
26
+ //# sourceMappingURL=useTokenLists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTokenLists.d.ts","sourceRoot":"","sources":["../../src/hooks/useTokenLists.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAwC,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAElG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,8FAA8F;IAC9F,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,qGAAqG;IACrG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IAC9C,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,0DAA0D;IAC1D,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CACrC;AAUD,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,GAAG,kBAAkB,CAoC/F"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Headless reader for `TokenTrustPanel`: the SDK's `readTokenTrust` for one
3
+ * token, plus the symbols of the currencies its pools pair it with, as a React
4
+ * resource. No provider and no wallet: a viem `PublicClient` is enough.
5
+ */
6
+ import { type Address, type Hex, type PublicClient } from "viem";
7
+ import { type PoolKind, type TokenTrust, type TrustContracts } from "@latchprotocol/sdk/trust";
8
+ import { type AsyncResource } from "./useAsyncResource.js";
9
+ import type { SymbolBook } from "../trust/model.js";
10
+ /** What to read. `contracts: null` means the host gave no addresses for this chain: nothing is read, and surfaces say "coming soon". */
11
+ export interface TokenTrustTarget {
12
+ readonly token: Address;
13
+ readonly contracts: TrustContracts | null;
14
+ /** Pools the host knows the token trades in, beyond the ones Latch's launches and locks reveal. */
15
+ readonly pools?: readonly {
16
+ readonly poolId: Hex;
17
+ readonly kind: PoolKind;
18
+ }[];
19
+ /** CL LP-locker position ids from a log scan the host already made. */
20
+ readonly lpLockerTokenIds?: readonly bigint[];
21
+ readonly native?: {
22
+ readonly symbol: string;
23
+ readonly decimals: number;
24
+ };
25
+ }
26
+ export interface TokenTrustData {
27
+ readonly trust: TokenTrust;
28
+ readonly symbols: SymbolBook;
29
+ }
30
+ /** One read of a token's trust facts, with the paired currencies' symbols. */
31
+ export declare function fetchTokenTrust(client: PublicClient, target: TokenTrustTarget & {
32
+ readonly contracts: TrustContracts;
33
+ }): Promise<TokenTrustData>;
34
+ export interface UseTokenTrustOptions {
35
+ /** Re-read interval in ms; default 60,000. 0 disables polling. */
36
+ readonly refetchIntervalMs?: number;
37
+ }
38
+ /** {@link fetchTokenTrust} as a resource: `idle` when `contracts` is `null`. */
39
+ export declare function useTokenTrust(client: PublicClient, target: TokenTrustTarget, options?: UseTokenTrustOptions): AsyncResource<TokenTrustData>;
40
+ //# sourceMappingURL=useTokenTrust.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTokenTrust.d.ts","sourceRoot":"","sources":["../../src/hooks/useTokenTrust.ts"],"names":[],"mappings":"AACA;;;;GAIG;AAEH,OAAO,EAAe,KAAK,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAE9E,OAAO,EAAkB,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/G,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,wIAAwI;AACxI,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1C,mGAAmG;IACnG,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS;QAAE,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;KAAE,EAAE,CAAC;IAC9E,uEAAuE;IACvE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1E;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;CAC9B;AAED,8EAA8E;AAC9E,wBAAsB,eAAe,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,GAAG;IAAE,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;CAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAiBtJ;AAED,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,gBAAgB,EAAE,OAAO,GAAE,oBAAyB,GAAG,aAAa,CAAC,cAAc,CAAC,CAgB/I"}
@@ -0,0 +1,15 @@
1
+ /** Token, balance, pool and account resources. All headless. */
2
+ import type { Address } from "viem";
3
+ import type { PoolInfo, PoolState, TokenInfo } from "../adapters/protocol.js";
4
+ import { type AsyncResource } from "./useAsyncResource.js";
5
+ /** The tokens this deployment offers. */
6
+ export declare function useTokenList(): AsyncResource<readonly TokenInfo[]>;
7
+ /** The connected account, or `null`. */
8
+ export declare function useAccount(): AsyncResource<Address | null>;
9
+ /** Balance of `token` for `owner`. Idle until both are known. */
10
+ export declare function useTokenBalance(token: TokenInfo | null, owner: Address | null): AsyncResource<bigint>;
11
+ /** Every pool the adapter knows about. */
12
+ export declare function usePools(): AsyncResource<readonly PoolInfo[]>;
13
+ /** Live state for one pool. */
14
+ export declare function usePoolState(pool: PoolInfo | null): AsyncResource<PoolState | null>;
15
+ //# sourceMappingURL=useTokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTokens.d.ts","sourceRoot":"","sources":["../../src/hooks/useTokens.ts"],"names":[],"mappings":"AACA,gEAAgE;AAGhE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE7E,yCAAyC;AACzC,wBAAgB,YAAY,IAAI,aAAa,CAAC,SAAS,SAAS,EAAE,CAAC,CAGlE;AAED,wCAAwC;AACxC,wBAAgB,UAAU,IAAI,aAAa,CAAC,OAAO,GAAG,IAAI,CAAC,CAG1D;AAED,iEAAiE;AACjE,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,GAAG,IAAI,EACvB,KAAK,EAAE,OAAO,GAAG,IAAI,GACpB,aAAa,CAAC,MAAM,CAAC,CAUvB;AAED,0CAA0C;AAC1C,wBAAgB,QAAQ,IAAI,aAAa,CAAC,SAAS,QAAQ,EAAE,CAAC,CAG7D;AAED,+BAA+B;AAC/B,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,GAAG,aAAa,CAAC,SAAS,GAAG,IAAI,CAAC,CAOnF"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Latch Protocol widgets.
3
+ *
4
+ * Embeddable swap, liquidity and launch UI for Latch Protocol, in two layers:
5
+ *
6
+ * - **Headless** (`@latchprotocol/widgets/headless`) - hooks and pure functions
7
+ * with no markup and no styles. Build your own UI on them.
8
+ * - **Styled** (this entry) - drop-in components on top of the headless layer,
9
+ * themed entirely through `--latch-*` CSS custom properties.
10
+ *
11
+ * Both share one thing that is not optional: `integrator: { referrer, feeBps }`
12
+ * is validated once at the provider and threaded into the swap call path, so the
13
+ * site embedding the widget earns from the flow it sends.
14
+ *
15
+ * @packageDocumentation
16
+ */
17
+ export * from "./config/integrator.js";
18
+ export * from "./config/chain.js";
19
+ export * from "./core/math.js";
20
+ export * from "./core/format.js";
21
+ export * from "./core/clMath.js";
22
+ export * from "./core/errors.js";
23
+ export * from "./core/pool.js";
24
+ export * from "./core/tokenLists.js";
25
+ export { buildUniformBinDistribution } from "./adapters/binDistribution.js";
26
+ export * from "./adapters/protocol.js";
27
+ export * from "./adapters/sale.js";
28
+ export { createViemAdapter, type ViemAdapterOptions, type ViemAdapterOverrides, type WidgetWallet, } from "./adapters/viem.js";
29
+ export * from "./callpath/constants.js";
30
+ export * from "./callpath/plan.js";
31
+ export * from "./callpath/swap.js";
32
+ export * from "./callpath/liquidity.js";
33
+ export * from "./callpath/launch.js";
34
+ export * from "./context/WidgetProvider.js";
35
+ export * from "./hooks/useAsyncResource.js";
36
+ export * from "./hooks/useSwapQuote.js";
37
+ export * from "./hooks/useSwapExecute.js";
38
+ export * from "./hooks/useLiquidity.js";
39
+ export * from "./hooks/useLaunch.js";
40
+ export * from "./hooks/useTokens.js";
41
+ export * from "./hooks/useTokenLists.js";
42
+ export * from "./hooks/useLocks.js";
43
+ export * from "./locks/model.js";
44
+ export * from "./locks/embedModel.js";
45
+ export * from "./locks/scan.js";
46
+ export * from "./trust/model.js";
47
+ export * from "./hooks/useTokenTrust.js";
48
+ export * from "./locker/model.js";
49
+ export * from "./hooks/useLocker.js";
50
+ export * from "./components/swap/state.js";
51
+ export * from "./components/primitives.js";
52
+ export * from "./components/SwapWidget.js";
53
+ export * from "./components/LiquidityWidget.js";
54
+ export * from "./components/LaunchWidget.js";
55
+ export * from "./components/LocksWidgets.js";
56
+ export * from "./components/TokenTrustPanel.js";
57
+ export * from "./components/LockerWidget.js";
58
+ export { WIDGET_CSS, injectWidgetStyles } from "./styles/css.js";
59
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;GAeG;AAGH,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAGlC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAG5E,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,OAAO,EACL,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EACzB,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAG5B,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC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