@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 @@
1
+ {"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/callpath/launch.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAEH,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC5G,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,OAAO,EACb,MAAM,WAAW,CAAC;AAEnB;;;;GAIG;AACH,OAAO,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,CAAC;AAC9D,YAAY,EAAE,aAAa,EAAE,CAAC;AAE9B,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAAC,MAAM,EAAE,oBAAoB,CAAC;IACtC,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE;IACtC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,qCAAqC;IACrC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC,GAAG,aAAa,CA8BhB;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,GAAG,OAAO,CAGxE;AAED,gDAAgD;AAChD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACzE;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAC5B,oGAAoG;IACpG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,GAAG,eAAe,CAmC5E"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Liquidity call-path construction for both pool types.
3
+ *
4
+ * Concentrated liquidity and the liquidity book differ in what a "range" is -
5
+ * a tick pair versus a span of bins - and in the shape of their position
6
+ * manager params. Everything above this file works with the single
7
+ * {@link ../adapters/protocol.js | LiquidityRange} union; the divergence is
8
+ * confined to the two encoders here.
9
+ *
10
+ * Both paths go through `PositionManager.modifyLiquidities(unlockData, deadline)`
11
+ * with the same `abi.encode(actions, params)` transport the swap path uses.
12
+ *
13
+ * ## Why there is no integrator fee on this path
14
+ *
15
+ * `PAY_PORTION` and `TAKE_PORTION` split an output currency. Adding liquidity
16
+ * has no output to split, and removing it returns the user's own principal -
17
+ * skimming that is not a referral fee, it is a withdrawal charge. Integrator
18
+ * revenue on liquidity, if it is ever added, belongs in a hook that earns from
19
+ * the position, not in a router step that taxes the deposit. The `integrator`
20
+ * config is still carried here so it can be recorded in analytics events.
21
+ */
22
+ import { type Address, type Hex } from "viem";
23
+ import { type PoolKey } from "@latchprotocol/sdk";
24
+ /** An encoded position-manager call. */
25
+ export interface EncodedLiquidityCall {
26
+ readonly to: Address;
27
+ readonly data: Hex;
28
+ readonly value: bigint;
29
+ readonly planTrace: string;
30
+ }
31
+ /** Arguments for minting a new concentrated-liquidity position. */
32
+ export interface BuildCLMintArgs {
33
+ readonly positionManager: Address;
34
+ readonly poolKey: PoolKey;
35
+ readonly tickLower: number;
36
+ readonly tickUpper: number;
37
+ readonly liquidity: bigint;
38
+ readonly amount0Max: bigint;
39
+ readonly amount1Max: bigint;
40
+ readonly owner: Address;
41
+ readonly deadline: bigint;
42
+ readonly hookData?: Hex;
43
+ /** Native value to attach, when one side of the pair is the native asset. */
44
+ readonly value?: bigint;
45
+ }
46
+ /** Encodes `CL_MINT_POSITION` followed by `SETTLE_PAIR` (and `SWEEP` of the native side when value is attached). */
47
+ export declare function buildCLMintCall(args: BuildCLMintArgs): EncodedLiquidityCall;
48
+ /** Arguments for decreasing or closing a concentrated-liquidity position. */
49
+ export interface BuildCLDecreaseArgs {
50
+ readonly positionManager: Address;
51
+ readonly poolKey: PoolKey;
52
+ readonly tokenId: bigint;
53
+ readonly liquidity: bigint;
54
+ readonly amount0Min: bigint;
55
+ readonly amount1Min: bigint;
56
+ readonly recipient: Address;
57
+ readonly owner: Address;
58
+ readonly deadline: bigint;
59
+ readonly hookData?: Hex;
60
+ }
61
+ /** Encodes `CL_DECREASE_LIQUIDITY` followed by `TAKE_PAIR`. */
62
+ export declare function buildCLDecreaseCall(args: BuildCLDecreaseArgs): EncodedLiquidityCall;
63
+ /** Arguments for adding liquidity to a bin pool. */
64
+ export interface BuildBinAddArgs {
65
+ readonly positionManager: Address;
66
+ readonly poolKey: PoolKey;
67
+ readonly amount0: bigint;
68
+ readonly amount1: bigint;
69
+ readonly amount0Max: bigint;
70
+ readonly amount1Max: bigint;
71
+ readonly activeIdDesired: number;
72
+ readonly idSlippage: number;
73
+ /** Bin offsets relative to the active id, one entry per bin. */
74
+ readonly deltaIds: readonly number[];
75
+ /** Share of `amount0` per bin, scaled to 1e18. Must sum to <= 1e18. */
76
+ readonly distributionX: readonly bigint[];
77
+ /** Share of `amount1` per bin, scaled to 1e18. Must sum to <= 1e18. */
78
+ readonly distributionY: readonly bigint[];
79
+ readonly to: Address;
80
+ readonly deadline: bigint;
81
+ readonly hookData?: Hex;
82
+ readonly value?: bigint;
83
+ }
84
+ /** Encodes `BIN_ADD_LIQUIDITY` followed by `SETTLE_PAIR` (and `SWEEP` of the native side when value is attached). */
85
+ export declare function buildBinAddCall(args: BuildBinAddArgs): EncodedLiquidityCall;
86
+ /** Arguments for removing liquidity from a bin pool. */
87
+ export interface BuildBinRemoveArgs {
88
+ readonly positionManager: Address;
89
+ readonly poolKey: PoolKey;
90
+ readonly amount0Min: bigint;
91
+ readonly amount1Min: bigint;
92
+ /** Bin ids being burned. */
93
+ readonly ids: readonly number[];
94
+ /** Share amount burned per bin, aligned with `ids`. */
95
+ readonly amounts: readonly bigint[];
96
+ readonly from: Address;
97
+ readonly recipient: Address;
98
+ readonly deadline: bigint;
99
+ readonly hookData?: Hex;
100
+ }
101
+ /** Encodes `BIN_REMOVE_LIQUIDITY` followed by `TAKE_PAIR`. */
102
+ export declare function buildBinRemoveCall(args: BuildBinRemoveArgs): EncodedLiquidityCall;
103
+ //# sourceMappingURL=liquidity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liquidity.d.ts","sourceRoot":"","sources":["../../src/callpath/liquidity.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;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CAyD3E;AAED,wDAAwD;AACxD,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IAChC,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;CACzB;AAED,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,GAAG,oBAAoB,CA4CjF"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Action-plan encoding.
3
+ *
4
+ * A periphery call is a list of `(actionId, abi-encoded params)` pairs executed
5
+ * inside one vault lock. The pairs are transported as `abi.encode(bytes actions,
6
+ * bytes[] params)`, where `actions` is the raw concatenation of one-byte ids.
7
+ *
8
+ * `CalldataDecoder.decodeActionsRouterParams` requires *strict* encoding - the
9
+ * first word must be exactly `0x40` - which is what a standard two-parameter ABI
10
+ * encoding produces. Do not hand-roll this.
11
+ */
12
+ import { type Hex } from "viem";
13
+ /** One step of a plan. */
14
+ export interface PlannedAction {
15
+ readonly action: number;
16
+ readonly params: Hex;
17
+ /** Debug label, never encoded. */
18
+ readonly label: string;
19
+ }
20
+ /** An ordered list of actions destined for one vault lock. */
21
+ export declare class ActionPlan {
22
+ #private;
23
+ /** Appends an action. Order is the execution order. */
24
+ add(action: number, params: Hex, label: string): this;
25
+ /** The planned steps, in order. */
26
+ get steps(): readonly PlannedAction[];
27
+ /** Human-readable trace of the plan, used in dev tooling and error messages. */
28
+ describe(): string;
29
+ /** `abi.encode(bytes actions, bytes[] params)`. */
30
+ encode(): Hex;
31
+ }
32
+ /** Convenience constructor. */
33
+ export declare function plan(): ActionPlan;
34
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/callpath/plan.ts"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AAEH,OAAO,EAAkC,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAEhE,0BAA0B;AAC1B,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC;IACrB,kCAAkC;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,8DAA8D;AAC9D,qBAAa,UAAU;;IAGrB,uDAAuD;IACvD,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAQrD,mCAAmC;IACnC,IAAI,KAAK,IAAI,SAAS,aAAa,EAAE,CAEpC;IAED,gFAAgF;IAChF,QAAQ,IAAI,MAAM;IAMlB,mDAAmD;IACnD,MAAM,IAAI,GAAG;CAgBd;AAED,+BAA+B;AAC/B,wBAAgB,IAAI,IAAI,UAAU,CAEjC"}
@@ -0,0 +1,129 @@
1
+ /**
2
+ * Swap call-path construction - **including integrator fee attribution**.
3
+ *
4
+ * This is the file that turns `integrator: { referrer, feeBps }` into money.
5
+ * The fee is not a post-hoc transfer and not an off-chain promise: it is a step
6
+ * in the same plan as the swap, so it settles atomically with it.
7
+ *
8
+ * ## The two fee modes
9
+ *
10
+ * ### `take-portion` (default)
11
+ *
12
+ * ```text
13
+ * UniversalRouter.execute([INFI_SWAP], [plan], deadline)
14
+ * plan:
15
+ * 0. CL_SWAP_EXACT_IN_SINGLE amountOutMinimum = minAmountOutGross
16
+ * 1. SETTLE_ALL pay currencyIn from the caller (via Permit2)
17
+ * 2. TAKE_PORTION feeBps of the output credit -> referrer
18
+ * 3. TAKE_ALL the rest -> caller, floored at minAmountOutNet
19
+ * ```
20
+ *
21
+ * The vault credit is split before anything leaves the singleton, so the router
22
+ * never custodies the fee and there is no window in which it can be swept.
23
+ *
24
+ * ### `pay-portion`
25
+ *
26
+ * ```text
27
+ * UniversalRouter.execute([INFI_SWAP, PAY_PORTION, SWEEP], [...], deadline)
28
+ * ```
29
+ *
30
+ * The swap takes its whole output to the router, `PAY_PORTION` forwards the
31
+ * fee, and `SWEEP` returns the remainder to the recipient. Use this when the
32
+ * fee has to be taken across a plan the periphery cannot express alone.
33
+ *
34
+ * ## Two minimums, deliberately
35
+ *
36
+ * The swap action enforces `minAmountOutGross`; the final take/sweep enforces
37
+ * `minAmountOutNet`. Because `x - floor(x * bps / 10_000)` is monotonically
38
+ * non-decreasing in `x`, clearing the gross floor guarantees clearing the net
39
+ * floor. Both are encoded so that neither the pool nor the fee step can quietly
40
+ * erode the user's guarantee.
41
+ */
42
+ import { type Address, type Hex } from "viem";
43
+ import { poolKeyToTuple, type PoolKey } from "@latchprotocol/sdk";
44
+ import { ActionPlan } from "./plan.js";
45
+ import type { ResolvedIntegratorConfig } from "../config/integrator.js";
46
+ /** ABI shape of a `PoolKey` struct. */
47
+ export declare const POOL_KEY_COMPONENTS: readonly [{
48
+ readonly name: "currency0";
49
+ readonly type: "address";
50
+ }, {
51
+ readonly name: "currency1";
52
+ readonly type: "address";
53
+ }, {
54
+ readonly name: "hooks";
55
+ readonly type: "address";
56
+ }, {
57
+ readonly name: "poolManager";
58
+ readonly type: "address";
59
+ }, {
60
+ readonly name: "fee";
61
+ readonly type: "uint24";
62
+ }, {
63
+ readonly name: "parameters";
64
+ readonly type: "bytes32";
65
+ }];
66
+ /** One hop of a swap, resolved to the exact pool it will execute against. */
67
+ export interface SwapHop {
68
+ readonly poolKey: PoolKey;
69
+ readonly poolType: "CL" | "BIN";
70
+ /** Input currency of this hop. */
71
+ readonly currencyIn: Address;
72
+ /** Output currency of this hop. */
73
+ readonly currencyOut: Address;
74
+ readonly hookData?: Hex;
75
+ }
76
+ /** Everything needed to encode a swap transaction. */
77
+ export interface BuildSwapCallArgs {
78
+ readonly router: Address;
79
+ readonly hops: readonly SwapHop[];
80
+ readonly amountIn: bigint;
81
+ readonly minAmountOutGross: bigint;
82
+ readonly minAmountOutNet: bigint;
83
+ /**
84
+ * Quoted gross output, used only to report the expected fee back to the UI.
85
+ * The chain always recomputes the fee from the realised output.
86
+ */
87
+ readonly expectedAmountOutGross?: bigint;
88
+ readonly integrator: ResolvedIntegratorConfig;
89
+ /** Who receives the output. Use the caller's own address for the normal case. */
90
+ readonly recipient: Address;
91
+ /** The account submitting the transaction, used to detect the sentinel case. */
92
+ readonly sender: Address;
93
+ readonly deadline: bigint;
94
+ }
95
+ /** A fully encoded swap transaction plus the trace used to explain it. */
96
+ export interface EncodedSwapCall {
97
+ readonly to: Address;
98
+ readonly data: Hex;
99
+ readonly value: bigint;
100
+ readonly commands: Hex;
101
+ readonly inputs: readonly Hex[];
102
+ /** Human-readable dump of the periphery plan. */
103
+ readonly planTrace: string;
104
+ /** Populated whenever a fee step was encoded. */
105
+ readonly integratorFee: {
106
+ readonly referrer: Address;
107
+ readonly feeBps: number;
108
+ readonly currency: Address;
109
+ readonly mode: "take-portion" | "pay-portion";
110
+ /** Fee implied by the quoted output. The chain recomputes it on the real one. */
111
+ readonly expectedAmount: bigint;
112
+ } | null;
113
+ }
114
+ /**
115
+ * Builds the periphery action plan for a swap.
116
+ *
117
+ * Exported so integrators building their own router flows can reuse exactly the
118
+ * plan the widgets use, fee step included.
119
+ */
120
+ export declare function buildSwapPlan(args: BuildSwapCallArgs): {
121
+ readonly plan: ActionPlan;
122
+ readonly currencyIn: Address;
123
+ readonly currencyOut: Address;
124
+ };
125
+ /** Encodes the full `UniversalRouter.execute` call for a swap. */
126
+ export declare function buildSwapCall(args: BuildSwapCallArgs): EncodedSwapCall;
127
+ /** Positional pool-key tuple, re-exported so callers do not reach into the SDK. */
128
+ export { poolKeyToTuple };
129
+ //# sourceMappingURL=swap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"swap.d.ts","sourceRoot":"","sources":["../../src/callpath/swap.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAEH,OAAO,EAIL,KAAK,OAAO,EACZ,KAAK,GAAG,EACT,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AASlE,OAAO,EAAE,UAAU,EAAQ,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAGxE,uCAAuC;AACvC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;EAOtB,CAAC;AAiDX,6EAA6E;AAC7E,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC;IAChC,kCAAkC;IAClC,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,mCAAmC;IACnC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC;CACzB;AAED,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC;;;OAGG;IACH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