@lifi/composer-sdk 0.7.1 → 0.9.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 (165) hide show
  1. package/README.md +5 -2
  2. package/dist/_virtual/_rolldown/runtime.cjs +33 -0
  3. package/dist/_virtual/_rolldown/runtime.js +13 -0
  4. package/dist/authoring/FlowBuilderCore.cjs +102 -120
  5. package/dist/authoring/FlowBuilderCore.cjs.map +1 -1
  6. package/dist/authoring/FlowBuilderCore.d.cts +58 -61
  7. package/dist/authoring/FlowBuilderCore.d.ts +58 -61
  8. package/dist/authoring/FlowBuilderCore.js +99 -97
  9. package/dist/authoring/FlowBuilderCore.js.map +1 -1
  10. package/dist/authoring/handles.cjs +25 -40
  11. package/dist/authoring/handles.cjs.map +1 -1
  12. package/dist/authoring/handles.d.cts +33 -34
  13. package/dist/authoring/handles.d.ts +33 -34
  14. package/dist/authoring/handles.js +21 -13
  15. package/dist/authoring/handles.js.map +1 -1
  16. package/dist/authoring/raw.cjs +85 -44
  17. package/dist/authoring/raw.cjs.map +1 -1
  18. package/dist/authoring/raw.d.cts +8 -8
  19. package/dist/authoring/raw.d.ts +8 -8
  20. package/dist/authoring/raw.js +83 -19
  21. package/dist/authoring/raw.js.map +1 -1
  22. package/dist/authoring/signatureArgs.cjs +81 -103
  23. package/dist/authoring/signatureArgs.cjs.map +1 -1
  24. package/dist/authoring/signatureArgs.d.cts +63 -64
  25. package/dist/authoring/signatureArgs.d.ts +63 -64
  26. package/dist/authoring/signatureArgs.js +76 -75
  27. package/dist/authoring/signatureArgs.js.map +1 -1
  28. package/dist/client.cjs +172 -220
  29. package/dist/client.cjs.map +1 -1
  30. package/dist/client.d.cts +131 -131
  31. package/dist/client.d.ts +131 -131
  32. package/dist/client.js +165 -198
  33. package/dist/client.js.map +1 -1
  34. package/dist/discovery.cjs +0 -17
  35. package/dist/discovery.d.cts +57 -56
  36. package/dist/discovery.d.ts +57 -56
  37. package/dist/discovery.js +1 -1
  38. package/dist/errors.cjs +211 -159
  39. package/dist/errors.cjs.map +1 -1
  40. package/dist/errors.d.cts +84 -84
  41. package/dist/errors.d.ts +84 -84
  42. package/dist/errors.js +201 -120
  43. package/dist/errors.js.map +1 -1
  44. package/dist/generated/config.generated.cjs +0 -17
  45. package/dist/generated/config.generated.d.cts +805 -895
  46. package/dist/generated/config.generated.d.ts +805 -895
  47. package/dist/generated/config.generated.js +1 -1
  48. package/dist/generated/guards.generated.cjs +27 -31
  49. package/dist/generated/guards.generated.cjs.map +1 -1
  50. package/dist/generated/guards.generated.d.cts +20 -4
  51. package/dist/generated/guards.generated.d.ts +20 -4
  52. package/dist/generated/guards.generated.js +21 -8
  53. package/dist/generated/guards.generated.js.map +1 -1
  54. package/dist/generated/materialisers.generated.cjs +25 -35
  55. package/dist/generated/materialisers.generated.cjs.map +1 -1
  56. package/dist/generated/materialisers.generated.d.cts +17 -4
  57. package/dist/generated/materialisers.generated.d.ts +17 -4
  58. package/dist/generated/materialisers.generated.js +19 -11
  59. package/dist/generated/materialisers.generated.js.map +1 -1
  60. package/dist/generated/operations.generated.cjs +236 -250
  61. package/dist/generated/operations.generated.cjs.map +1 -1
  62. package/dist/generated/operations.generated.d.cts +740 -657
  63. package/dist/generated/operations.generated.d.ts +740 -657
  64. package/dist/generated/operations.generated.js +235 -229
  65. package/dist/generated/operations.generated.js.map +1 -1
  66. package/dist/generated/preconditions.generated.cjs +25 -35
  67. package/dist/generated/preconditions.generated.cjs.map +1 -1
  68. package/dist/generated/preconditions.generated.d.cts +17 -4
  69. package/dist/generated/preconditions.generated.d.ts +17 -4
  70. package/dist/generated/preconditions.generated.js +19 -11
  71. package/dist/generated/preconditions.generated.js.map +1 -1
  72. package/dist/index.cjs +131 -97
  73. package/dist/index.cjs.map +1 -1
  74. package/dist/index.d.cts +29 -43
  75. package/dist/index.d.ts +29 -43
  76. package/dist/index.js +96 -45
  77. package/dist/index.js.map +1 -1
  78. package/dist/outputs.cjs +11 -32
  79. package/dist/outputs.cjs.map +1 -1
  80. package/dist/outputs.d.cts +5 -5
  81. package/dist/outputs.d.ts +5 -5
  82. package/dist/outputs.js +10 -8
  83. package/dist/outputs.js.map +1 -1
  84. package/dist/raw.cjs +21 -33
  85. package/dist/raw.cjs.map +1 -1
  86. package/dist/raw.d.cts +8 -4
  87. package/dist/raw.d.ts +8 -4
  88. package/dist/raw.js +12 -7
  89. package/dist/raw.js.map +1 -1
  90. package/dist/reachability.cjs +82 -112
  91. package/dist/reachability.cjs.map +1 -1
  92. package/dist/reachability.d.cts +33 -59
  93. package/dist/reachability.d.ts +33 -59
  94. package/dist/reachability.js +81 -88
  95. package/dist/reachability.js.map +1 -1
  96. package/dist/resources.cjs +47 -32
  97. package/dist/resources.cjs.map +1 -1
  98. package/dist/resources.d.cts +50 -3
  99. package/dist/resources.d.ts +50 -3
  100. package/dist/resources.js +42 -9
  101. package/dist/resources.js.map +1 -1
  102. package/dist/responseSchemas.cjs +99 -111
  103. package/dist/responseSchemas.cjs.map +1 -1
  104. package/dist/responseSchemas.d.cts +34 -34
  105. package/dist/responseSchemas.d.ts +34 -34
  106. package/dist/responseSchemas.js +85 -66
  107. package/dist/responseSchemas.js.map +1 -1
  108. package/dist/routeAmount.cjs +61 -31
  109. package/dist/routeAmount.cjs.map +1 -1
  110. package/dist/routeAmount.d.cts +52 -2
  111. package/dist/routeAmount.d.ts +52 -2
  112. package/dist/routeAmount.js +56 -8
  113. package/dist/routeAmount.js.map +1 -1
  114. package/dist/run/inputs.cjs +56 -48
  115. package/dist/run/inputs.cjs.map +1 -1
  116. package/dist/run/inputs.d.cts +70 -74
  117. package/dist/run/inputs.d.ts +70 -74
  118. package/dist/run/inputs.js +54 -23
  119. package/dist/run/inputs.js.map +1 -1
  120. package/dist/run/simulate.cjs +38 -43
  121. package/dist/run/simulate.cjs.map +1 -1
  122. package/dist/run/simulate.d.cts +36 -36
  123. package/dist/run/simulate.d.ts +36 -36
  124. package/dist/run/simulate.js +37 -19
  125. package/dist/run/simulate.js.map +1 -1
  126. package/dist/sdk.cjs +55 -66
  127. package/dist/sdk.cjs.map +1 -1
  128. package/dist/sdk.d.cts +108 -111
  129. package/dist/sdk.d.ts +108 -111
  130. package/dist/sdk.js +52 -44
  131. package/dist/sdk.js.map +1 -1
  132. package/dist/types.cjs +0 -17
  133. package/dist/types.d.cts +22 -22
  134. package/dist/types.d.ts +22 -22
  135. package/dist/types.js +1 -1
  136. package/package.json +4 -4
  137. package/src/client.ts +2 -2
  138. package/src/examples/aaveClaimRewards.ts +2 -1
  139. package/src/examples/emitCustomEvent.ts +1 -2
  140. package/src/examples/run.ts +14 -1
  141. package/src/examples/transferTokens.ts +21 -17
  142. package/src/examples/uniswapV2AddLiquidity.ts +106 -0
  143. package/src/examples/uniswapV3Mint.ts +95 -0
  144. package/src/generated/config.generated.ts +102 -47
  145. package/src/generated/guards.generated.ts +9 -0
  146. package/src/generated/operations.generated.ts +161 -5
  147. package/src/index.ts +0 -3
  148. package/dist/discovery.cjs.map +0 -1
  149. package/dist/discovery.js.map +0 -1
  150. package/dist/generated/config.generated.cjs.map +0 -1
  151. package/dist/generated/config.generated.js.map +0 -1
  152. package/dist/guards.generated-BPLFwe7y.d.ts +0 -19
  153. package/dist/guards.generated-M3VAIevI.d.cts +0 -19
  154. package/dist/materialisers.generated-BMkBQgWZ.d.ts +0 -24
  155. package/dist/materialisers.generated-BWq5oePO.d.cts +0 -24
  156. package/dist/preconditions.generated-DblS13Wq.d.cts +0 -24
  157. package/dist/preconditions.generated-U7YpVh30.d.ts +0 -24
  158. package/dist/raw-BvRghN3r.d.ts +0 -20
  159. package/dist/raw-s1rer8X3.d.cts +0 -20
  160. package/dist/resources-BKlFxjo8.d.cts +0 -56
  161. package/dist/resources-CYis1_DS.d.ts +0 -56
  162. package/dist/routeAmount-DdbJYJyM.d.cts +0 -55
  163. package/dist/routeAmount-DdbJYJyM.d.ts +0 -55
  164. package/dist/types.cjs.map +0 -1
  165. package/dist/types.js.map +0 -1
@@ -0,0 +1,95 @@
1
+ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
2
+
3
+ import {
4
+ createComposeSdk,
5
+ guards,
6
+ materialisers,
7
+ resources,
8
+ } from '../index.js';
9
+ import type { Address } from '../types.js';
10
+
11
+ import { API_KEY, BASE_URL } from './config.js';
12
+
13
+ // Uniswap V3 USDC/WETH 0.05% pool on Ethereum mainnet (chainId 1).
14
+ const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
15
+ const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
16
+ const POSITION_MANAGER = '0xC36442b4a4522E871399CD717aBDD847Ab11FE88';
17
+ const FACTORY = '0x1F98431c8aD98523631AE4a59f267346ea31F984';
18
+ const USDC_WETH_500_POOL = '0x88e6A0c2dDD26FEEb64F039a2c41296FcB3f5640';
19
+ // Full range: the widest ticks that are multiples of the pool's tick spacing (10).
20
+ const TICK_LOWER = -887270;
21
+ const TICK_UPPER = 887270;
22
+
23
+ export interface UniswapV3MintInput {
24
+ readonly owner: Address;
25
+ readonly usdcAmount: `${bigint}`;
26
+ readonly wethAmount: `${bigint}`;
27
+ }
28
+
29
+ /**
30
+ * Open a full-range Uniswap V3 USDC/WETH position on Ethereum mainnet.
31
+ *
32
+ * - `uniswapV3.mint` deposits the proxy's USDC and WETH and mints the
33
+ * position NFT straight to the signer.
34
+ * - Unused USDC or WETH comes back as residuals, swept to the signer.
35
+ */
36
+ export const buildUniswapV3Mint = ({
37
+ owner,
38
+ usdcAmount,
39
+ wethAmount,
40
+ }: UniswapV3MintInput): {
41
+ flow: Flow;
42
+ request: ComposeCompileRequest;
43
+ } => {
44
+ const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
45
+
46
+ const builder = sdk.flow(1, {
47
+ name: 'uniswap-v3-mint-usdc-weth',
48
+ inputs: {
49
+ usdc: resources.erc20(USDC, 1),
50
+ weth: resources.erc20(WETH, 1),
51
+ },
52
+ });
53
+
54
+ builder.uniswapV3.mint('mint', {
55
+ bind: {
56
+ tokenA: builder.inputs.usdc,
57
+ tokenB: builder.inputs.weth,
58
+ recipient: builder.context.sender,
59
+ },
60
+ config: {
61
+ positionManager: POSITION_MANAGER,
62
+ factory: FACTORY,
63
+ pool: USDC_WETH_500_POOL,
64
+ fee: 500,
65
+ tickLower: TICK_LOWER,
66
+ tickUpper: TICK_UPPER,
67
+ },
68
+ guards: [
69
+ // Bound the pool price before the deposit; N bps on the sqrt price
70
+ // allows about 2N bps of price movement, so this caps it near 50 bps.
71
+ guards.band({ port: 'sqrtPriceX96', bps: 25 }),
72
+ // Floor the minted liquidity. Liquidity is a handle, not a resource,
73
+ // so no minimum appears in the response.
74
+ guards.slippage({ port: 'liquidity', bps: 50 }),
75
+ ],
76
+ });
77
+
78
+ const flow = builder.build();
79
+
80
+ const request = sdk.request(flow, {
81
+ signer: owner,
82
+ inputs: {
83
+ usdc: materialisers.directDeposit({ amount: usdcAmount }),
84
+ weth: materialisers.directDeposit({ amount: wethAmount }),
85
+ },
86
+ // Return unused USDC or WETH to the signer.
87
+ sweepTo: builder.context.sender,
88
+ // The position NFT is not a resource, so only the residuals count as
89
+ // output and the default price-impact check would read a full loss.
90
+ // 0 skips the check; the band and slippage guards protect the deposit.
91
+ maxPriceImpactBps: 0,
92
+ });
93
+
94
+ return { flow, request };
95
+ };
@@ -12,6 +12,10 @@ export interface CoreSplitConfig {
12
12
  bps: Between010000;
13
13
  }
14
14
 
15
+ export interface CoreSplitAtConfig {
16
+ amount: IntegerStringInput;
17
+ }
18
+
15
19
  /**
16
20
  * an array of at most 16 item(s)
17
21
  *
@@ -179,6 +183,10 @@ export interface CorePartitionConfig {
179
183
  * a positive number
180
184
  */
181
185
  export type Positive = number;
186
+ /**
187
+ * a number between 0 and 1
188
+ */
189
+ export type Between01 = number;
182
190
  /**
183
191
  * a string at most 64 character(s) long
184
192
  */
@@ -204,7 +212,7 @@ export interface LifiSwapConfig {
204
212
  token: Address;
205
213
  chainId: Positive;
206
214
  };
207
- slippage?: number;
215
+ slippage?: Between01;
208
216
  timing?: {
209
217
  swapStepTimingStrategies?: {
210
218
  strategy: 'minWaitTime';
@@ -230,10 +238,6 @@ export interface LifiSwapConfig {
230
238
  * a string starting with "0x"
231
239
  */
232
240
  export type StartsWith0X = string;
233
- /**
234
- * a number between 0 and 1
235
- */
236
- export type Between01 = number;
237
241
 
238
242
  export interface LifiBridgeConfig {
239
243
  resourceOut:
@@ -343,9 +347,7 @@ export interface CoreBalanceOfConfig {
343
347
  owner?: Address;
344
348
  }
345
349
 
346
- export interface CoreTransferConfig {
347
- amount?: IntegerStringInput;
348
- }
350
+ export type CoreTransferConfig = Record<string, never>;
349
351
 
350
352
  export interface CoreEmitEvent1Config {
351
353
  signature: string;
@@ -1170,44 +1172,6 @@ export interface LifiFlashloanRepayConfig {
1170
1172
  fee?: string;
1171
1173
  }
1172
1174
 
1173
- export type ContinuationAssertReadyConfig =
1174
- | {
1175
- kind: 'erc20BalanceGte';
1176
- chainId: Positive;
1177
- /**
1178
- * EVM address: 0x followed by 40 hex characters
1179
- */
1180
- token: Address;
1181
- /**
1182
- * EVM address: 0x followed by 40 hex characters
1183
- */
1184
- owner: Address;
1185
- minAmount: string;
1186
- }
1187
- | {
1188
- kind: 'nativeBalanceGte';
1189
- chainId: Positive;
1190
- /**
1191
- * EVM address: 0x followed by 40 hex characters
1192
- */
1193
- owner: Address;
1194
- minAmount: string;
1195
- }
1196
- | {
1197
- kind: 'call';
1198
- chainId: Positive;
1199
- /**
1200
- * EVM address: 0x followed by 40 hex characters
1201
- */
1202
- to: string;
1203
- /**
1204
- * Hex bytes: 0x followed by an even number of hex characters
1205
- */
1206
- calldata: string;
1207
- comparator: 'gte' | 'eq' | 'lte';
1208
- value: string;
1209
- };
1210
-
1211
1175
  export interface LifiZapConfig {
1212
1176
  resourceOut:
1213
1177
  | {
@@ -1275,7 +1239,16 @@ export interface CorePeekConfig {
1275
1239
  */
1276
1240
  target: Address;
1277
1241
  functionSignature: string;
1278
- args?: string[];
1242
+ args?: (
1243
+ | MaxLength65536
1244
+ | (
1245
+ | MaxLength65536
1246
+ | (
1247
+ | MaxLength65536
1248
+ | (MaxLength65536 | (MaxLength65536 | MaxLength65536[])[])[]
1249
+ )[]
1250
+ )[]
1251
+ )[];
1279
1252
  }
1280
1253
 
1281
1254
  /**
@@ -1305,6 +1278,83 @@ export interface FlySwapConfig {
1305
1278
  maxSlippageBps?: Between05000;
1306
1279
  }
1307
1280
 
1281
+ export interface UniswapV2AddLiquidityConfig {
1282
+ /**
1283
+ * EVM address: 0x followed by 40 hex characters
1284
+ */
1285
+ router: string;
1286
+ /**
1287
+ * EVM address: 0x followed by 40 hex characters
1288
+ */
1289
+ factory: string;
1290
+ /**
1291
+ * EVM address: 0x followed by 40 hex characters
1292
+ */
1293
+ pair: string;
1294
+ }
1295
+
1296
+ export interface UniswapV2RemoveLiquidityConfig {
1297
+ /**
1298
+ * EVM address: 0x followed by 40 hex characters
1299
+ */
1300
+ router: string;
1301
+ /**
1302
+ * EVM address: 0x followed by 40 hex characters
1303
+ */
1304
+ factory: string;
1305
+ /**
1306
+ * EVM address: 0x followed by 40 hex characters
1307
+ */
1308
+ tokenA: string;
1309
+ /**
1310
+ * EVM address: 0x followed by 40 hex characters
1311
+ */
1312
+ tokenB: string;
1313
+ }
1314
+
1315
+ /**
1316
+ * a number between 0 and 999999
1317
+ */
1318
+ export type Between0999999 = number;
1319
+ /**
1320
+ * a number between -887272 and 887272
1321
+ */
1322
+ export type Between887272887272 = number;
1323
+
1324
+ export interface UniswapV3MintConfig {
1325
+ /**
1326
+ * EVM address: 0x followed by 40 hex characters
1327
+ */
1328
+ positionManager: string;
1329
+ /**
1330
+ * EVM address: 0x followed by 40 hex characters
1331
+ */
1332
+ factory: string;
1333
+ /**
1334
+ * EVM address: 0x followed by 40 hex characters
1335
+ */
1336
+ pool: string;
1337
+ fee: Between0999999;
1338
+ tickLower: Between887272887272;
1339
+ tickUpper: Between887272887272;
1340
+ }
1341
+
1342
+ export interface UniswapV3IncreaseLiquidityConfig {
1343
+ /**
1344
+ * EVM address: 0x followed by 40 hex characters
1345
+ */
1346
+ positionManager: string;
1347
+ /**
1348
+ * EVM address: 0x followed by 40 hex characters
1349
+ */
1350
+ factory: string;
1351
+ /**
1352
+ * EVM address: 0x followed by 40 hex characters
1353
+ */
1354
+ pool: string;
1355
+ tokenId: string;
1356
+ }
1357
+
1308
1358
  export interface SlippageGuardConfig {
1309
1359
  port: string;
1310
1360
  bps: Between010000;
@@ -1316,6 +1366,11 @@ export interface CoreNumericInvariantGuardConfig {
1316
1366
  threshold: IntegerStringInput;
1317
1367
  }
1318
1368
 
1369
+ export interface BandGuardConfig {
1370
+ port: string;
1371
+ bps: Between010000;
1372
+ }
1373
+
1319
1374
  export interface BalanceOfMaterialiserConfig {
1320
1375
  /**
1321
1376
  * EVM address: 0x followed by 40 hex characters
@@ -4,6 +4,7 @@
4
4
  import type { TypedGuard } from '../types.js';
5
5
 
6
6
  import type {
7
+ BandGuardConfig,
7
8
  CoreNumericInvariantGuardConfig,
8
9
  SlippageGuardConfig,
9
10
  } from './config.generated.js';
@@ -23,3 +24,11 @@ export const coreNumericInvariant = <P extends string>(
23
24
  kind: 'core.numericInvariant',
24
25
  ...config,
25
26
  });
27
+
28
+ /** Assert that an output stays within a tolerance in basis points of its simulated value, in both directions */
29
+ export const band = <P extends string>(
30
+ config: Omit<BandGuardConfig, 'port'> & { port: P },
31
+ ): TypedGuard<P> => ({
32
+ kind: 'band',
33
+ ...config,
34
+ });
@@ -40,6 +40,7 @@ import type {
40
40
  CorePartitionConfig,
41
41
  CorePeekConfig,
42
42
  CoreRawCallConfig,
43
+ CoreSplitAtConfig,
43
44
  CoreSplitConfig,
44
45
  CoreStaticCallConfig,
45
46
  CoreTransferConfig,
@@ -64,6 +65,10 @@ import type {
64
65
  MorphoBlueWithdrawCollateralConfig,
65
66
  MorphoBlueWithdrawConfig,
66
67
  ParaswapBuyConfig,
68
+ UniswapV2AddLiquidityConfig,
69
+ UniswapV2RemoveLiquidityConfig,
70
+ UniswapV3IncreaseLiquidityConfig,
71
+ UniswapV3MintConfig,
67
72
  } from './config.generated.js';
68
73
 
69
74
  /** Split a resource into two outputs by basis-point ratio. Output `a` receives `bps` of the source, rounded up, and `b` takes the remainder. */
@@ -75,6 +80,15 @@ export interface CoreSplitArgs {
75
80
  readonly guards?: readonly TypedGuard<'a' | 'b'>[];
76
81
  }
77
82
 
83
+ /** Split a resource at a fixed amount. Output `head` receives `min(source, amount)`; `tail` receives the rest, and is 0 (omitted when unspent) when the source is at or below `amount`. */
84
+ export interface CoreSplitAtArgs {
85
+ readonly bind: {
86
+ readonly source: Bindable<'resource'>;
87
+ };
88
+ readonly config: CoreSplitAtConfig;
89
+ readonly guards?: readonly TypedGuard<'head' | 'tail'>[];
90
+ }
91
+
78
92
  /** Partition a resource into one output per basis-point share. `bps` lists 2 to 16 shares summing to 10000; output `parts.i` receives share i, rounded down, and the last part takes the remainder. */
79
93
  export interface CorePartitionArgs<
80
94
  TBps extends FamilySource<CorePartitionConfig['bps']> = FamilySource<
@@ -411,14 +425,14 @@ export interface CoreBalanceOfArgs {
411
425
  readonly guards?: readonly TypedGuard<'balance'>[];
412
426
  }
413
427
 
414
- /** Transfer tokens to a recipient address, optionally specifying a partial amount */
428
+ /** Transfer the whole input resource to a recipient address. To send part of a resource, split it first with `core.split` or `core.splitAt`. */
415
429
  export interface CoreTransferArgs {
416
430
  readonly bind: {
417
431
  readonly amount: Bindable<'resource'>;
418
432
  readonly recipient: Bindable<'address'>;
419
433
  };
420
434
  readonly config: CoreTransferConfig;
421
- readonly guards?: readonly TypedGuard<'transferred' | 'remainder'>[];
435
+ readonly guards?: readonly TypedGuard<'transferred'>[];
422
436
  }
423
437
 
424
438
  /** Emit a custom on-chain event carrying 1 32-byte payload value. The value becomes a non-indexed data word in a fixed VM log event; the signature is hashed into a discriminator word (it is NOT an indexed EVM topic). */
@@ -654,11 +668,63 @@ export interface FlySwapArgs {
654
668
  readonly guards?: readonly TypedGuard<'unspentIn'>[];
655
669
  }
656
670
 
671
+ /** Deposit two ERC-20 tokens into an existing Uniswap V2 pair (or an ABI-identical fork such as SushiSwap V2) through its Router02 and receive the pair's LP token; unused input returns as residuals. Asserts on chain that the router's factory is `factory`, that the factory's pair for the two tokens is `pair`, and that the pair holds non-zero reserves. Exposes the pool price read before the deposit as `poolPrice`. The deposit is protected only with a `band` guard on `poolPrice` and a `slippage` guard on `liquidity`. Fee-on-transfer tokens are unsupported. */
672
+ export interface UniswapV2AddLiquidityArgs {
673
+ readonly bind: {
674
+ readonly tokenA: Bindable<'resource'>;
675
+ readonly tokenB: Bindable<'resource'>;
676
+ };
677
+ readonly config: UniswapV2AddLiquidityConfig;
678
+ readonly guards?: readonly TypedGuard<
679
+ 'liquidity' | 'residualA' | 'residualB' | 'poolPrice'
680
+ >[];
681
+ }
682
+
683
+ /** Burn a Uniswap V2 LP token (or one of an ABI-identical fork such as SushiSwap V2) through its Router02 and receive both underlying tokens. Asserts on chain that the router's factory is `factory` and that the factory's pair for `tokenA`/`tokenB` is the input LP token. The withdrawal is protected only with a `slippage` guard on each of `tokenA` and `tokenB`. Fee-on-transfer tokens are unsupported: the outputs are the amounts the router reports, which would overstate what such a token delivers. */
684
+ export interface UniswapV2RemoveLiquidityArgs {
685
+ readonly bind: {
686
+ readonly liquidity: Bindable<'resource'>;
687
+ };
688
+ readonly config: UniswapV2RemoveLiquidityConfig;
689
+ readonly guards?: readonly TypedGuard<'tokenA' | 'tokenB'>[];
690
+ }
691
+
692
+ /** Open a Uniswap V3 concentrated-liquidity position (or one on an ABI-identical fork) for a tick range, minting the position NFT straight to `recipient`, which must not be the execution address. Exposes the new `tokenId`; unused input comes back as residuals. The deposit is protected only with a `band` guard on `sqrtPriceX96` (read before the deposit) and a `slippage` guard on `liquidity`; a band of N bps on `sqrtPriceX96` allows about 2N bps of price movement. Fee-on-transfer tokens are unsupported. */
693
+ export interface UniswapV3MintArgs {
694
+ readonly bind: {
695
+ readonly tokenA: Bindable<'resource'>;
696
+ readonly tokenB: Bindable<'resource'>;
697
+ readonly recipient: Bindable<'address'>;
698
+ };
699
+ readonly config: UniswapV3MintConfig;
700
+ readonly guards?: readonly TypedGuard<
701
+ 'tokenId' | 'liquidity' | 'sqrtPriceX96' | 'residualA' | 'residualB'
702
+ >[];
703
+ }
704
+
705
+ /** Add two tokens to an existing Uniswap V3 position (or one on an ABI-identical fork). `owner` must own `tokenId`, and the position must hold the two input tokens; both are asserted on chain, since the position manager checks neither. Unused input comes back as residuals. The deposit is protected only with a `band` guard on `sqrtPriceX96` (read before the deposit) and a `slippage` guard on `liquidity`; a band of N bps on `sqrtPriceX96` allows about 2N bps of price movement. Fee-on-transfer tokens are unsupported. */
706
+ export interface UniswapV3IncreaseLiquidityArgs {
707
+ readonly bind: {
708
+ readonly tokenA: Bindable<'resource'>;
709
+ readonly tokenB: Bindable<'resource'>;
710
+ readonly owner: Bindable<'address'>;
711
+ };
712
+ readonly config: UniswapV3IncreaseLiquidityConfig;
713
+ readonly guards?: readonly TypedGuard<
714
+ 'liquidity' | 'sqrtPriceX96' | 'residualA' | 'residualB'
715
+ >[];
716
+ }
717
+
657
718
  export interface CoreSplitOutputs {
658
719
  readonly a: OutputHandle<'resource'>;
659
720
  readonly b: OutputHandle<'resource'>;
660
721
  }
661
722
 
723
+ export interface CoreSplitAtOutputs {
724
+ readonly head: OutputHandle<'resource'>;
725
+ readonly tail: OutputHandle<'resource'>;
726
+ }
727
+
662
728
  export interface CorePartitionOutputs<
663
729
  TBps extends FamilySource<CorePartitionConfig['bps']> = FamilySource<
664
730
  CorePartitionConfig['bps']
@@ -715,7 +781,6 @@ export interface CoreBalanceOfOutputs {
715
781
 
716
782
  export interface CoreTransferOutputs {
717
783
  readonly transferred: OutputHandle<'resource'>;
718
- readonly remainder: OutputHandle<'resource'>;
719
784
  }
720
785
 
721
786
  export interface CoreRawCallOutputs {
@@ -807,10 +872,42 @@ export interface FlySwapOutputs {
807
872
  readonly unspentIn: OutputHandle<'resource'>;
808
873
  }
809
874
 
875
+ export interface UniswapV2AddLiquidityOutputs {
876
+ readonly liquidity: OutputHandle<'resource'>;
877
+ readonly residualA: OutputHandle<'resource'>;
878
+ readonly residualB: OutputHandle<'resource'>;
879
+ readonly poolPrice: OutputHandle<'uint256'>;
880
+ }
881
+
882
+ export interface UniswapV2RemoveLiquidityOutputs {
883
+ readonly tokenA: OutputHandle<'resource'>;
884
+ readonly tokenB: OutputHandle<'resource'>;
885
+ }
886
+
887
+ export interface UniswapV3MintOutputs {
888
+ readonly tokenId: OutputHandle<'uint256'>;
889
+ readonly liquidity: OutputHandle<'uint256'>;
890
+ readonly sqrtPriceX96: OutputHandle<'uint256'>;
891
+ readonly residualA: OutputHandle<'resource'>;
892
+ readonly residualB: OutputHandle<'resource'>;
893
+ }
894
+
895
+ export interface UniswapV3IncreaseLiquidityOutputs {
896
+ readonly liquidity: OutputHandle<'uint256'>;
897
+ readonly sqrtPriceX96: OutputHandle<'uint256'>;
898
+ readonly residualA: OutputHandle<'resource'>;
899
+ readonly residualB: OutputHandle<'resource'>;
900
+ }
901
+
810
902
  export type GeneratedOps = {
811
903
  readonly core: {
812
904
  /** Split a resource into two outputs by basis-point ratio. Output `a` receives `bps` of the source, rounded up, and `b` takes the remainder. — original id: "core.split" */
813
905
  readonly split: (nodeId: string, args: CoreSplitArgs) => CoreSplitOutputs;
906
+ /** Split a resource at a fixed amount. Output `head` receives `min(source, amount)`; `tail` receives the rest, and is 0 (omitted when unspent) when the source is at or below `amount`. — original id: "core.splitAt" */
907
+ readonly splitAt: (
908
+ nodeId: string,
909
+ args: CoreSplitAtArgs,
910
+ ) => CoreSplitAtOutputs;
814
911
  /** Partition a resource into one output per basis-point share. `bps` lists 2 to 16 shares summing to 10000; output `parts.i` receives share i, rounded down, and the last part takes the remainder. — original id: "core.partition" */
815
912
  readonly partition: <
816
913
  const TBps extends FamilySource<CorePartitionConfig['bps']>,
@@ -876,7 +973,7 @@ export type GeneratedOps = {
876
973
  nodeId: string,
877
974
  args: CoreBalanceOfArgs,
878
975
  ) => CoreBalanceOfOutputs;
879
- /** Transfer tokens to a recipient address, optionally specifying a partial amount — original id: "core.transfer" */
976
+ /** Transfer the whole input resource to a recipient address. To send part of a resource, split it first with `core.split` or `core.splitAt`. — original id: "core.transfer" */
880
977
  readonly transfer: (
881
978
  nodeId: string,
882
979
  args: CoreTransferArgs,
@@ -1060,6 +1157,30 @@ export type GeneratedOps = {
1060
1157
  /** Swap via Fly's DexAggregator, sized at runtime: the router calldata leaves `amountIn` unset, so an upstream op's output can feed the swap without being known at plan time. Either leg may be the chain-native coin. — original id: "fly.swap" */
1061
1158
  readonly swap: (nodeId: string, args: FlySwapArgs) => FlySwapOutputs;
1062
1159
  };
1160
+ readonly uniswapV2: {
1161
+ /** Deposit two ERC-20 tokens into an existing Uniswap V2 pair (or an ABI-identical fork such as SushiSwap V2) through its Router02 and receive the pair's LP token; unused input returns as residuals. Asserts on chain that the router's factory is `factory`, that the factory's pair for the two tokens is `pair`, and that the pair holds non-zero reserves. Exposes the pool price read before the deposit as `poolPrice`. The deposit is protected only with a `band` guard on `poolPrice` and a `slippage` guard on `liquidity`. Fee-on-transfer tokens are unsupported. — original id: "uniswapV2.addLiquidity" */
1162
+ readonly addLiquidity: (
1163
+ nodeId: string,
1164
+ args: UniswapV2AddLiquidityArgs,
1165
+ ) => UniswapV2AddLiquidityOutputs;
1166
+ /** Burn a Uniswap V2 LP token (or one of an ABI-identical fork such as SushiSwap V2) through its Router02 and receive both underlying tokens. Asserts on chain that the router's factory is `factory` and that the factory's pair for `tokenA`/`tokenB` is the input LP token. The withdrawal is protected only with a `slippage` guard on each of `tokenA` and `tokenB`. Fee-on-transfer tokens are unsupported: the outputs are the amounts the router reports, which would overstate what such a token delivers. — original id: "uniswapV2.removeLiquidity" */
1167
+ readonly removeLiquidity: (
1168
+ nodeId: string,
1169
+ args: UniswapV2RemoveLiquidityArgs,
1170
+ ) => UniswapV2RemoveLiquidityOutputs;
1171
+ };
1172
+ readonly uniswapV3: {
1173
+ /** Open a Uniswap V3 concentrated-liquidity position (or one on an ABI-identical fork) for a tick range, minting the position NFT straight to `recipient`, which must not be the execution address. Exposes the new `tokenId`; unused input comes back as residuals. The deposit is protected only with a `band` guard on `sqrtPriceX96` (read before the deposit) and a `slippage` guard on `liquidity`; a band of N bps on `sqrtPriceX96` allows about 2N bps of price movement. Fee-on-transfer tokens are unsupported. — original id: "uniswapV3.mint" */
1174
+ readonly mint: (
1175
+ nodeId: string,
1176
+ args: UniswapV3MintArgs,
1177
+ ) => UniswapV3MintOutputs;
1178
+ /** Add two tokens to an existing Uniswap V3 position (or one on an ABI-identical fork). `owner` must own `tokenId`, and the position must hold the two input tokens; both are asserted on chain, since the position manager checks neither. Unused input comes back as residuals. The deposit is protected only with a `band` guard on `sqrtPriceX96` (read before the deposit) and a `slippage` guard on `liquidity`; a band of N bps on `sqrtPriceX96` allows about 2N bps of price movement. Fee-on-transfer tokens are unsupported. — original id: "uniswapV3.increaseLiquidity" */
1179
+ readonly increaseLiquidity: (
1180
+ nodeId: string,
1181
+ args: UniswapV3IncreaseLiquidityArgs,
1182
+ ) => UniswapV3IncreaseLiquidityOutputs;
1183
+ };
1063
1184
  };
1064
1185
 
1065
1186
  export const bindGeneratedOps = (
@@ -1071,6 +1192,11 @@ export const bindGeneratedOps = (
1071
1192
  a: 'resource',
1072
1193
  b: 'resource',
1073
1194
  } as const),
1195
+ splitAt: (nodeId: string, args: CoreSplitAtArgs) =>
1196
+ builder.call(nodeId, 'core.splitAt', args, {
1197
+ head: 'resource',
1198
+ tail: 'resource',
1199
+ } as const),
1074
1200
  partition: <const TBps extends FamilySource<CorePartitionConfig['bps']>>(
1075
1201
  nodeId: string,
1076
1202
  args: CorePartitionArgs<TBps>,
@@ -1135,7 +1261,6 @@ export const bindGeneratedOps = (
1135
1261
  transfer: (nodeId: string, args: CoreTransferArgs) =>
1136
1262
  builder.call(nodeId, 'core.transfer', args, {
1137
1263
  transferred: 'resource',
1138
- remainder: 'resource',
1139
1264
  } as const),
1140
1265
  emitEvent1: (nodeId: string, args: CoreEmitEvent1Args) =>
1141
1266
  builder.call(nodeId, 'core.emitEvent1', args, {}),
@@ -1359,4 +1484,35 @@ export const bindGeneratedOps = (
1359
1484
  unspentIn: 'resource',
1360
1485
  } as const),
1361
1486
  },
1487
+ uniswapV2: {
1488
+ addLiquidity: (nodeId: string, args: UniswapV2AddLiquidityArgs) =>
1489
+ builder.call(nodeId, 'uniswapV2.addLiquidity', args, {
1490
+ liquidity: 'resource',
1491
+ residualA: 'resource',
1492
+ residualB: 'resource',
1493
+ poolPrice: 'uint256',
1494
+ } as const),
1495
+ removeLiquidity: (nodeId: string, args: UniswapV2RemoveLiquidityArgs) =>
1496
+ builder.call(nodeId, 'uniswapV2.removeLiquidity', args, {
1497
+ tokenA: 'resource',
1498
+ tokenB: 'resource',
1499
+ } as const),
1500
+ },
1501
+ uniswapV3: {
1502
+ mint: (nodeId: string, args: UniswapV3MintArgs) =>
1503
+ builder.call(nodeId, 'uniswapV3.mint', args, {
1504
+ tokenId: 'uint256',
1505
+ liquidity: 'uint256',
1506
+ sqrtPriceX96: 'uint256',
1507
+ residualA: 'resource',
1508
+ residualB: 'resource',
1509
+ } as const),
1510
+ increaseLiquidity: (nodeId: string, args: UniswapV3IncreaseLiquidityArgs) =>
1511
+ builder.call(nodeId, 'uniswapV3.increaseLiquidity', args, {
1512
+ liquidity: 'uint256',
1513
+ sqrtPriceX96: 'uint256',
1514
+ residualA: 'resource',
1515
+ residualB: 'resource',
1516
+ } as const),
1517
+ },
1362
1518
  });
package/src/index.ts CHANGED
@@ -99,11 +99,8 @@ export type {
99
99
  Erc20AllowanceRequirement,
100
100
  ContinuationIntent,
101
101
  ContinuationOutcome,
102
- Check,
103
- CheckComparator,
104
102
  SettlementWire,
105
103
  SettlementEscrowWire,
106
- ContinuationPlanWire,
107
104
  } from '@lifi/compose-spec';
108
105
  export {
109
106
  SIMULATE_MAX_TRACKED_BALANCES,
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/discovery.ts"],"sourcesContent":["/**\n * Types for the Compose discovery API (`GET /compose/zap-packs`, `GET /chains`).\n *\n * These are SDK-facing presentation types — not part of the core compile\n * contract in compose-spec. The backend response is the source of truth;\n * the SDK provides typed access.\n *\n * The `type` field on edges is a plain `string` rather than a strict union\n * so the SDK remains forward-compatible when the backend introduces new\n * edge types. Known values at time of writing:\n * `\"enter-position\"`, `\"exit-position\"`, `\"wrap\"`, `\"unwrap\"`, `\"mint\"`, `\"burn\"`.\n */\n\n/**\n * A chain the Compose deployment supports.\n */\nexport interface ChainSummary {\n /** EVM chain ID. The stable identifier — key on this. */\n readonly chainId: number;\n /**\n * Human-readable label, suitable for display in a chain selector.\n *\n * Maintained by the deployment rather than derived from canonical chain\n * branding, so it can differ from a chain's marketed name and can change\n * without notice. Never treat it as an identifier, and never match on it.\n * A chain the deployment has no configured label for reports `Chain <id>`.\n */\n readonly name: string;\n}\n\n/**\n * A single routing edge representing a supported token-to-token path\n * through a DeFi protocol.\n */\nexport interface ZapPackEdge {\n /** Edge type (e.g. `\"enter-position\"`, `\"exit-position\"`, `\"wrap\"`). */\n readonly type: string;\n /** Input token. */\n readonly in: { readonly address: string; readonly chainId: number };\n /** Output token. */\n readonly out: { readonly address: string; readonly chainId: number };\n /** Minimum input amount accepted (stringified integer), if constrained. */\n readonly inAmountMin?: string;\n /** Maximum input amount accepted (stringified integer), if constrained. */\n readonly inAmountMax?: string;\n /**\n * Recipient binding obligation. `\"required\"` means the zap must bind its\n * `recipient` input. The output is externally owned, terminal, and unswept.\n * The loose string type preserves forward compatibility with new values.\n */\n readonly recipient?: string;\n /**\n * Output availability. `\"future\"` means the output becomes available only\n * after the initiating transaction settles; route via `lifi.zapAsync` with\n * a bound recipient. Absent means the output is available synchronously.\n * The loose string type preserves forward compatibility with new values.\n */\n readonly availability?: string;\n}\n\n/**\n * All routing edges for a single protocol.\n */\nexport interface ZapPackOverview {\n /** Protocol identifier (e.g. `\"aave\"`, `\"morpho\"`). */\n readonly protocol: string;\n /** Available routing edges for this protocol. */\n readonly edges: readonly ZapPackEdge[];\n}\n\n/**\n * Options for {@link ComposeClient.getZapPacks}.\n */\nexport interface GetZapPacksOptions {\n /**\n * Filter to specific protocols. Pass a single string or an array.\n * Only edges belonging to the listed protocols are returned.\n * Omit to fetch all available protocols.\n */\n readonly protocols?: string | readonly string[];\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}