@lifi/composer-sdk 0.0.1-alpha → 0.2.0-staging.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -1
- package/dist/authoring/signatureArgs.cjs +2 -2
- package/dist/authoring/signatureArgs.cjs.map +1 -1
- package/dist/authoring/signatureArgs.js +2 -2
- package/dist/authoring/signatureArgs.js.map +1 -1
- package/dist/client.cjs +2 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/dist/generated/config.generated.cjs.map +1 -1
- package/dist/generated/config.generated.d.cts +307 -16
- package/dist/generated/config.generated.d.ts +307 -16
- package/dist/generated/guards.generated.cjs +6 -0
- package/dist/generated/guards.generated.cjs.map +1 -1
- package/dist/generated/guards.generated.d.cts +1 -1
- package/dist/generated/guards.generated.d.ts +1 -1
- package/dist/generated/guards.generated.js +5 -0
- package/dist/generated/guards.generated.js.map +1 -1
- package/dist/generated/materialisers.generated.cjs +8 -2
- package/dist/generated/materialisers.generated.cjs.map +1 -1
- package/dist/generated/materialisers.generated.d.cts +1 -1
- package/dist/generated/materialisers.generated.d.ts +1 -1
- package/dist/generated/materialisers.generated.js +6 -1
- package/dist/generated/materialisers.generated.js.map +1 -1
- package/dist/generated/operations.generated.cjs +84 -14
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +208 -13
- package/dist/generated/operations.generated.d.ts +208 -13
- package/dist/generated/operations.generated.js +84 -14
- package/dist/generated/operations.generated.js.map +1 -1
- package/dist/guards.generated-BPLFwe7y.d.ts +19 -0
- package/dist/guards.generated-M3VAIevI.d.cts +19 -0
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/materialisers.generated-BfWJ-g7t.d.ts +29 -0
- package/dist/materialisers.generated-DaJRwiRe.d.cts +29 -0
- package/dist/run/inputs.cjs +8 -5
- package/dist/run/inputs.cjs.map +1 -1
- package/dist/run/inputs.d.cts +8 -0
- package/dist/run/inputs.d.ts +8 -0
- package/dist/run/inputs.js +8 -5
- package/dist/run/inputs.js.map +1 -1
- package/dist/sdk.cjs +1 -0
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.js +1 -0
- package/dist/sdk.js.map +1 -1
- package/package.json +14 -6
- package/src/authoring/signatureArgs.ts +2 -2
- package/src/client.ts +1 -1
- package/src/examples/aaveClaimRewards.ts +80 -0
- package/src/examples/aaveRepay.ts +69 -0
- package/src/examples/aaveRepayWithATokens.ts +81 -0
- package/src/examples/aaveSetEMode.ts +68 -0
- package/src/examples/run.ts +41 -4
- package/src/examples/staged/aaveBorrow.ts +104 -0
- package/src/examples/staged/aaveDebtRebalanceExactOut.ts +301 -0
- package/src/examples/staged/aaveHealthFactorExplode.ts +70 -0
- package/src/examples/staged/aaveToMorphoDebtMigration.ts +190 -0
- package/src/examples/staged/aaveToMorphoDebtMigrationWithSwap.ts +221 -0
- package/src/examples/staged/aaveToMorphoDebtMigrationWithSwapExactOut.ts +302 -0
- package/src/examples/staged/flashloanRepay.ts +138 -0
- package/src/examples/staged/morphoBlueBorrow.ts +89 -0
- package/src/examples/staged/morphoBlueRepay.ts +91 -0
- package/src/examples/staged/registry.ts +78 -0
- package/src/examples/swapToRecipient.ts +0 -19
- package/src/examples/swapWithFee.ts +59 -0
- package/src/generated/config.generated.ts +364 -18
- package/src/generated/guards.generated.ts +12 -1
- package/src/generated/materialisers.generated.ts +24 -12
- package/src/generated/operations.generated.ts +373 -13
- package/src/run/inputs.ts +16 -5
- package/src/sdk.ts +1 -0
- package/dist/guards.generated-DKKDKREA.d.ts +0 -14
- package/dist/guards.generated-hrQ1KPNv.d.cts +0 -14
- package/dist/materialisers.generated-BsA1uDW8.d.ts +0 -24
- package/dist/materialisers.generated-nMxTAaVi.d.cts +0 -24
package/dist/index.d.cts
CHANGED
|
@@ -7,12 +7,12 @@ export { ref } from './authoring/raw.cjs';
|
|
|
7
7
|
export { AnyBindable, FlowOptions, TypedFlow } from './authoring/FlowBuilderCore.cjs';
|
|
8
8
|
export { ComposeRunInput, materialiser } from './run/inputs.cjs';
|
|
9
9
|
export { ComposeSdk, ComposeSdkOptions, FlowBuilder, createComposeSdk } from './sdk.cjs';
|
|
10
|
-
import { g as guardsMod } from './guards.generated-
|
|
11
|
-
import { m as materialisersMod } from './materialisers.generated-
|
|
10
|
+
import { g as guardsMod } from './guards.generated-M3VAIevI.cjs';
|
|
11
|
+
import { m as materialisersMod } from './materialisers.generated-DaJRwiRe.cjs';
|
|
12
12
|
import { p as preconditionsMod } from './preconditions.generated-DblS13Wq.cjs';
|
|
13
13
|
import { r as rawMod } from './raw-Dj_2rBSQ.cjs';
|
|
14
14
|
import { r as resourcesMod } from './resources-BKlFxjo8.cjs';
|
|
15
|
-
export { BalanceOfMaterialiserConfig, Between010000, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreInvokeConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, LifiSwapConfig, LifiZapConfig, NativeBalancePreconditionConfig, Positive, SlippageGuardConfig, Unknown } from './generated/config.generated.cjs';
|
|
15
|
+
export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, GreaterThanOrEqualTo0, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapConfig, MaxItems50, MaxLength64, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, ParaswapBuyConfig, Positive, SlippageGuardConfig, Unknown } from './generated/config.generated.cjs';
|
|
16
16
|
import './client.cjs';
|
|
17
17
|
import './generated/operations.generated.cjs';
|
|
18
18
|
import './authoring/signatureArgs.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -7,12 +7,12 @@ export { ref } from './authoring/raw.js';
|
|
|
7
7
|
export { AnyBindable, FlowOptions, TypedFlow } from './authoring/FlowBuilderCore.js';
|
|
8
8
|
export { ComposeRunInput, materialiser } from './run/inputs.js';
|
|
9
9
|
export { ComposeSdk, ComposeSdkOptions, FlowBuilder, createComposeSdk } from './sdk.js';
|
|
10
|
-
import { g as guardsMod } from './guards.generated-
|
|
11
|
-
import { m as materialisersMod } from './materialisers.generated-
|
|
10
|
+
import { g as guardsMod } from './guards.generated-BPLFwe7y.js';
|
|
11
|
+
import { m as materialisersMod } from './materialisers.generated-BfWJ-g7t.js';
|
|
12
12
|
import { p as preconditionsMod } from './preconditions.generated-U7YpVh30.js';
|
|
13
13
|
import { r as rawMod } from './raw-IxCF_bSS.js';
|
|
14
14
|
import { r as resourcesMod } from './resources-CYis1_DS.js';
|
|
15
|
-
export { BalanceOfMaterialiserConfig, Between010000, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreInvokeConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, LifiSwapConfig, LifiZapConfig, NativeBalancePreconditionConfig, Positive, SlippageGuardConfig, Unknown } from './generated/config.generated.js';
|
|
15
|
+
export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, GreaterThanOrEqualTo0, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapConfig, MaxItems50, MaxLength64, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, ParaswapBuyConfig, Positive, SlippageGuardConfig, Unknown } from './generated/config.generated.js';
|
|
16
16
|
import './client.js';
|
|
17
17
|
import './generated/operations.generated.js';
|
|
18
18
|
import './authoring/signatureArgs.js';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MaterialiserConfigOf, MaterialiserInput } from '@lifi/compose-spec';
|
|
2
|
+
import { BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig$1, CallMaterialiserConfig as CallMaterialiserConfig$1, DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig$1, FlashloanMaterialiserConfig as FlashloanMaterialiserConfig$1 } from './generated/config.generated.js';
|
|
3
|
+
|
|
4
|
+
type BalanceOfMaterialiserConfig = MaterialiserConfigOf<BalanceOfMaterialiserConfig$1>;
|
|
5
|
+
/** Read the on-chain token balance of an address as the input amount — accepts: resource */
|
|
6
|
+
declare const balanceOf: (config: BalanceOfMaterialiserConfig) => MaterialiserInput;
|
|
7
|
+
type DirectDepositMaterialiserConfig = MaterialiserConfigOf<DirectDepositMaterialiserConfig$1>;
|
|
8
|
+
/** Deposit tokens into the VM — native via msg.value, ERC-20 via transferFrom — accepts: resource */
|
|
9
|
+
declare const directDeposit: (config: DirectDepositMaterialiserConfig) => MaterialiserInput;
|
|
10
|
+
type CallMaterialiserConfig = MaterialiserConfigOf<CallMaterialiserConfig$1>;
|
|
11
|
+
/** Execute an arbitrary contract call and measure the resulting token balance diff — accepts: resource */
|
|
12
|
+
declare const call: (config: CallMaterialiserConfig) => MaterialiserInput;
|
|
13
|
+
type FlashloanMaterialiserConfig = MaterialiserConfigOf<FlashloanMaterialiserConfig$1>;
|
|
14
|
+
/** Borrow tokens from a flashloan provider; amount becomes a register populated by the proxy at callback time — accepts: resource */
|
|
15
|
+
declare const flashloan: (config: FlashloanMaterialiserConfig) => MaterialiserInput;
|
|
16
|
+
|
|
17
|
+
type materialisersMod_BalanceOfMaterialiserConfig = BalanceOfMaterialiserConfig;
|
|
18
|
+
type materialisersMod_CallMaterialiserConfig = CallMaterialiserConfig;
|
|
19
|
+
type materialisersMod_DirectDepositMaterialiserConfig = DirectDepositMaterialiserConfig;
|
|
20
|
+
type materialisersMod_FlashloanMaterialiserConfig = FlashloanMaterialiserConfig;
|
|
21
|
+
declare const materialisersMod_balanceOf: typeof balanceOf;
|
|
22
|
+
declare const materialisersMod_call: typeof call;
|
|
23
|
+
declare const materialisersMod_directDeposit: typeof directDeposit;
|
|
24
|
+
declare const materialisersMod_flashloan: typeof flashloan;
|
|
25
|
+
declare namespace materialisersMod {
|
|
26
|
+
export { type materialisersMod_BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig, type materialisersMod_CallMaterialiserConfig as CallMaterialiserConfig, type materialisersMod_DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig, type materialisersMod_FlashloanMaterialiserConfig as FlashloanMaterialiserConfig, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit, materialisersMod_flashloan as flashloan };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { type BalanceOfMaterialiserConfig as B, type CallMaterialiserConfig as C, type DirectDepositMaterialiserConfig as D, type FlashloanMaterialiserConfig as F, balanceOf as b, call as c, directDeposit as d, flashloan as f, materialisersMod as m };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MaterialiserConfigOf, MaterialiserInput } from '@lifi/compose-spec';
|
|
2
|
+
import { BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig$1, CallMaterialiserConfig as CallMaterialiserConfig$1, DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig$1, FlashloanMaterialiserConfig as FlashloanMaterialiserConfig$1 } from './generated/config.generated.cjs';
|
|
3
|
+
|
|
4
|
+
type BalanceOfMaterialiserConfig = MaterialiserConfigOf<BalanceOfMaterialiserConfig$1>;
|
|
5
|
+
/** Read the on-chain token balance of an address as the input amount — accepts: resource */
|
|
6
|
+
declare const balanceOf: (config: BalanceOfMaterialiserConfig) => MaterialiserInput;
|
|
7
|
+
type DirectDepositMaterialiserConfig = MaterialiserConfigOf<DirectDepositMaterialiserConfig$1>;
|
|
8
|
+
/** Deposit tokens into the VM — native via msg.value, ERC-20 via transferFrom — accepts: resource */
|
|
9
|
+
declare const directDeposit: (config: DirectDepositMaterialiserConfig) => MaterialiserInput;
|
|
10
|
+
type CallMaterialiserConfig = MaterialiserConfigOf<CallMaterialiserConfig$1>;
|
|
11
|
+
/** Execute an arbitrary contract call and measure the resulting token balance diff — accepts: resource */
|
|
12
|
+
declare const call: (config: CallMaterialiserConfig) => MaterialiserInput;
|
|
13
|
+
type FlashloanMaterialiserConfig = MaterialiserConfigOf<FlashloanMaterialiserConfig$1>;
|
|
14
|
+
/** Borrow tokens from a flashloan provider; amount becomes a register populated by the proxy at callback time — accepts: resource */
|
|
15
|
+
declare const flashloan: (config: FlashloanMaterialiserConfig) => MaterialiserInput;
|
|
16
|
+
|
|
17
|
+
type materialisersMod_BalanceOfMaterialiserConfig = BalanceOfMaterialiserConfig;
|
|
18
|
+
type materialisersMod_CallMaterialiserConfig = CallMaterialiserConfig;
|
|
19
|
+
type materialisersMod_DirectDepositMaterialiserConfig = DirectDepositMaterialiserConfig;
|
|
20
|
+
type materialisersMod_FlashloanMaterialiserConfig = FlashloanMaterialiserConfig;
|
|
21
|
+
declare const materialisersMod_balanceOf: typeof balanceOf;
|
|
22
|
+
declare const materialisersMod_call: typeof call;
|
|
23
|
+
declare const materialisersMod_directDeposit: typeof directDeposit;
|
|
24
|
+
declare const materialisersMod_flashloan: typeof flashloan;
|
|
25
|
+
declare namespace materialisersMod {
|
|
26
|
+
export { type materialisersMod_BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfig, type materialisersMod_CallMaterialiserConfig as CallMaterialiserConfig, type materialisersMod_DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfig, type materialisersMod_FlashloanMaterialiserConfig as FlashloanMaterialiserConfig, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit, materialisersMod_flashloan as flashloan };
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { type BalanceOfMaterialiserConfig as B, type CallMaterialiserConfig as C, type DirectDepositMaterialiserConfig as D, type FlashloanMaterialiserConfig as F, balanceOf as b, call as c, directDeposit as d, flashloan as f, materialisersMod as m };
|
package/dist/run/inputs.cjs
CHANGED
|
@@ -31,15 +31,18 @@ const buildRun = (run) => ({
|
|
|
31
31
|
...run.preconditions?.length && { preconditions: run.preconditions },
|
|
32
32
|
signer: run.signer,
|
|
33
33
|
...run.assumptions && { assumptions: run.assumptions },
|
|
34
|
-
...run.referrer
|
|
35
|
-
...run.
|
|
34
|
+
...run.referrer !== void 0 && { referrer: run.referrer },
|
|
35
|
+
...run.integratorFeeBps !== void 0 && {
|
|
36
|
+
integratorFeeBps: run.integratorFeeBps
|
|
37
|
+
},
|
|
38
|
+
...run.maxPriceImpactBps !== void 0 && {
|
|
36
39
|
maxPriceImpactBps: run.maxPriceImpactBps
|
|
37
40
|
},
|
|
38
|
-
...run.sweepTo
|
|
39
|
-
...run.simulationPolicy
|
|
41
|
+
...run.sweepTo !== void 0 && { sweepTo: run.sweepTo },
|
|
42
|
+
...run.simulationPolicy !== void 0 && {
|
|
40
43
|
simulationPolicy: run.simulationPolicy
|
|
41
44
|
},
|
|
42
|
-
...run.checkOnChainAllowances
|
|
45
|
+
...run.checkOnChainAllowances !== void 0 && {
|
|
43
46
|
checkOnChainAllowances: run.checkOnChainAllowances
|
|
44
47
|
}
|
|
45
48
|
});
|
package/dist/run/inputs.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n SweepTo,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: SweepTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n maxPriceImpactBps?: number;\n sweepTo?: SweepTo;\n simulationPolicy?: SimulationPolicy;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n ...(run.preconditions?.length && { preconditions: run.preconditions }),\n signer: run.signer,\n ...(run.assumptions && { assumptions: run.assumptions }),\n ...(run.referrer
|
|
1
|
+
{"version":3,"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n SweepTo,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /**\n * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).\n * A non-zero value requires the request to be authenticated with an\n * integration-scoped API key — the integration is derived from the key, not\n * this field. Defaults to `0` (no fee) when omitted.\n */\n readonly integratorFeeBps?: number;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: SweepTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n integratorFeeBps?: number;\n maxPriceImpactBps?: number;\n sweepTo?: SweepTo;\n simulationPolicy?: SimulationPolicy;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n ...(run.preconditions?.length && { preconditions: run.preconditions }),\n signer: run.signer,\n ...(run.assumptions && { assumptions: run.assumptions }),\n ...(run.referrer !== undefined && { referrer: run.referrer }),\n ...(run.integratorFeeBps !== undefined && {\n integratorFeeBps: run.integratorFeeBps,\n }),\n ...(run.maxPriceImpactBps !== undefined && {\n maxPriceImpactBps: run.maxPriceImpactBps,\n }),\n ...(run.sweepTo !== undefined && { sweepTo: run.sweepTo }),\n ...(run.simulationPolicy !== undefined && {\n simulationPolicy: run.simulationPolicy,\n }),\n ...(run.checkOnChainAllowances !== undefined && {\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmFO,MAAM,eAAe,CAC1B,MACA,SAAkC,CAAC,OACZ;AAAA,EACvB;AAAA,EACA,GAAG;AACL;AAQO,MAAM,WAAW,CAAC,SAWN;AAAA,EACjB,QAAQ,IAAI;AAAA,EACZ,GAAI,IAAI,eAAe,UAAU,EAAE,eAAe,IAAI,cAAc;AAAA,EACpE,QAAQ,IAAI;AAAA,EACZ,GAAI,IAAI,eAAe,EAAE,aAAa,IAAI,YAAY;AAAA,EACtD,GAAI,IAAI,aAAa,UAAa,EAAE,UAAU,IAAI,SAAS;AAAA,EAC3D,GAAI,IAAI,qBAAqB,UAAa;AAAA,IACxC,kBAAkB,IAAI;AAAA,EACxB;AAAA,EACA,GAAI,IAAI,sBAAsB,UAAa;AAAA,IACzC,mBAAmB,IAAI;AAAA,EACzB;AAAA,EACA,GAAI,IAAI,YAAY,UAAa,EAAE,SAAS,IAAI,QAAQ;AAAA,EACxD,GAAI,IAAI,qBAAqB,UAAa;AAAA,IACxC,kBAAkB,IAAI;AAAA,EACxB;AAAA,EACA,GAAI,IAAI,2BAA2B,UAAa;AAAA,IAC9C,wBAAwB,IAAI;AAAA,EAC9B;AACF;","names":[]}
|
package/dist/run/inputs.d.cts
CHANGED
|
@@ -29,6 +29,13 @@ interface ComposeRunInput<T extends InputSchema = InputSchema> {
|
|
|
29
29
|
};
|
|
30
30
|
/** Optional integrator referrer identifier. */
|
|
31
31
|
readonly referrer?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
|
|
34
|
+
* A non-zero value requires the request to be authenticated with an
|
|
35
|
+
* integration-scoped API key — the integration is derived from the key, not
|
|
36
|
+
* this field. Defaults to `0` (no fee) when omitted.
|
|
37
|
+
*/
|
|
38
|
+
readonly integratorFeeBps?: number;
|
|
32
39
|
/** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
|
|
33
40
|
readonly maxPriceImpactBps?: number;
|
|
34
41
|
/**
|
|
@@ -82,6 +89,7 @@ declare const buildRun: (run: {
|
|
|
82
89
|
signer: string;
|
|
83
90
|
assumptions?: Record<string, bigint>;
|
|
84
91
|
referrer?: string;
|
|
92
|
+
integratorFeeBps?: number;
|
|
85
93
|
maxPriceImpactBps?: number;
|
|
86
94
|
sweepTo?: SweepTo;
|
|
87
95
|
simulationPolicy?: SimulationPolicy;
|
package/dist/run/inputs.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ interface ComposeRunInput<T extends InputSchema = InputSchema> {
|
|
|
29
29
|
};
|
|
30
30
|
/** Optional integrator referrer identifier. */
|
|
31
31
|
readonly referrer?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).
|
|
34
|
+
* A non-zero value requires the request to be authenticated with an
|
|
35
|
+
* integration-scoped API key — the integration is derived from the key, not
|
|
36
|
+
* this field. Defaults to `0` (no fee) when omitted.
|
|
37
|
+
*/
|
|
38
|
+
readonly integratorFeeBps?: number;
|
|
32
39
|
/** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */
|
|
33
40
|
readonly maxPriceImpactBps?: number;
|
|
34
41
|
/**
|
|
@@ -82,6 +89,7 @@ declare const buildRun: (run: {
|
|
|
82
89
|
signer: string;
|
|
83
90
|
assumptions?: Record<string, bigint>;
|
|
84
91
|
referrer?: string;
|
|
92
|
+
integratorFeeBps?: number;
|
|
85
93
|
maxPriceImpactBps?: number;
|
|
86
94
|
sweepTo?: SweepTo;
|
|
87
95
|
simulationPolicy?: SimulationPolicy;
|
package/dist/run/inputs.js
CHANGED
|
@@ -7,15 +7,18 @@ const buildRun = (run) => ({
|
|
|
7
7
|
...run.preconditions?.length && { preconditions: run.preconditions },
|
|
8
8
|
signer: run.signer,
|
|
9
9
|
...run.assumptions && { assumptions: run.assumptions },
|
|
10
|
-
...run.referrer
|
|
11
|
-
...run.
|
|
10
|
+
...run.referrer !== void 0 && { referrer: run.referrer },
|
|
11
|
+
...run.integratorFeeBps !== void 0 && {
|
|
12
|
+
integratorFeeBps: run.integratorFeeBps
|
|
13
|
+
},
|
|
14
|
+
...run.maxPriceImpactBps !== void 0 && {
|
|
12
15
|
maxPriceImpactBps: run.maxPriceImpactBps
|
|
13
16
|
},
|
|
14
|
-
...run.sweepTo
|
|
15
|
-
...run.simulationPolicy
|
|
17
|
+
...run.sweepTo !== void 0 && { sweepTo: run.sweepTo },
|
|
18
|
+
...run.simulationPolicy !== void 0 && {
|
|
16
19
|
simulationPolicy: run.simulationPolicy
|
|
17
20
|
},
|
|
18
|
-
...run.checkOnChainAllowances
|
|
21
|
+
...run.checkOnChainAllowances !== void 0 && {
|
|
19
22
|
checkOnChainAllowances: run.checkOnChainAllowances
|
|
20
23
|
}
|
|
21
24
|
});
|
package/dist/run/inputs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n SweepTo,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: SweepTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n maxPriceImpactBps?: number;\n sweepTo?: SweepTo;\n simulationPolicy?: SimulationPolicy;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n ...(run.preconditions?.length && { preconditions: run.preconditions }),\n signer: run.signer,\n ...(run.assumptions && { assumptions: run.assumptions }),\n ...(run.referrer
|
|
1
|
+
{"version":3,"sources":["../../src/run/inputs.ts"],"sourcesContent":["import type {\n ComposeRun,\n InputSpec,\n MaterialiserInput,\n Precondition,\n SimulationPolicy,\n SweepTo,\n} from '@lifi/compose-spec';\n\nimport type { Address, InputSchema, InputSpecOf } from '../types.js';\n\n/**\n * Runtime inputs for compiling a flow. Passed to `builder.compile()` or `sdk.request()`.\n *\n * @typeParam T - The flow's input schema, used to type-check `inputs` and `assumptions`.\n */\nexport interface ComposeRunInput<T extends InputSchema = InputSchema> {\n /**\n * Concrete values for each declared flow input. Resource inputs accept a\n * materialiser or a literal integer amount; scalar inputs accept the matching type.\n */\n readonly inputs: { readonly [K in keyof T]: InputSpecOf<T[K]> };\n /** Optional preconditions that must hold before the flow executes (e.g. minimum balances). */\n readonly preconditions?: readonly Precondition[];\n /** The `0x`-prefixed address of the transaction signer. */\n readonly signer: Address;\n /**\n * Optional assumed token amounts for resource inputs, keyed by input name.\n * When a materialiser resolves amounts at execution time rather than upfront,\n * assumptions let the compiler plan routes using estimated values. The keys\n * must match the input names declared in the flow schema.\n */\n readonly assumptions?: { readonly [K in keyof T]?: bigint };\n /** Optional integrator referrer identifier. */\n readonly referrer?: string;\n /**\n * Optional integrator fee in basis points (1bp = 0.01%, max `9000` = 90%).\n * A non-zero value requires the request to be authenticated with an\n * integration-scoped API key — the integration is derived from the key, not\n * this field. Defaults to `0` (no fee) when omitted.\n */\n readonly integratorFeeBps?: number;\n /** Maximum acceptable price impact in basis points (e.g. `300` = 3%). */\n readonly maxPriceImpactBps?: number;\n /**\n * Destination for sweeping all proxy-held terminal resources after execution.\n * Pass a literal `0x`-prefixed address or `{ $ref: \"context.sender\" }` to\n * send remaining tokens to the signer.\n */\n readonly sweepTo?: SweepTo;\n /**\n * Controls behavior when simulation detects a revert.\n * `'strict'` (default) returns an error; `'allow-revert'` returns a partial\n * result with the transaction and revert diagnostics.\n */\n readonly simulationPolicy?: SimulationPolicy;\n /**\n * When `true`, the server checks on-chain ERC-20 allowances and omits\n * approvals that are already sufficient. Defaults to `false`.\n */\n readonly checkOnChainAllowances?: boolean;\n}\n\n/**\n * Creates an untyped materialiser input spec. This is a low-level escape hatch\n * for materialiser kinds not yet covered by the generated helpers.\n *\n * Prefer the typed helpers in the `materialisers` namespace (e.g.\n * `materialisers.balanceOf()`, `materialisers.directDeposit()`) which provide\n * compile-time config validation.\n *\n * @param kind - The materialiser type (e.g. `\"balanceOf\"`, `\"directDeposit\"`).\n * @param config - Optional materialiser-specific configuration.\n * @returns A {@link MaterialiserInput} for use in {@link ComposeRunInput.inputs}.\n *\n * @example\n * ```ts\n * const run = {\n * inputs: { token: materialiser('customKind', { myParam: '0x...' }) },\n * signer: '0x...',\n * };\n * ```\n */\nexport const materialiser = (\n kind: string,\n config: Record<string, unknown> = {},\n): MaterialiserInput => ({\n kind,\n ...config,\n});\n\n/**\n * Assembles a {@link ComposeRun} object from individual parameters.\n * Used internally by the SDK; prefer {@link ComposeRunInput} for external use.\n *\n * @internal\n */\nexport const buildRun = (run: {\n inputs: Record<string, InputSpec>;\n preconditions?: readonly Precondition[];\n signer: string;\n assumptions?: Record<string, bigint>;\n referrer?: string;\n integratorFeeBps?: number;\n maxPriceImpactBps?: number;\n sweepTo?: SweepTo;\n simulationPolicy?: SimulationPolicy;\n checkOnChainAllowances?: boolean;\n}): ComposeRun => ({\n inputs: run.inputs,\n ...(run.preconditions?.length && { preconditions: run.preconditions }),\n signer: run.signer,\n ...(run.assumptions && { assumptions: run.assumptions }),\n ...(run.referrer !== undefined && { referrer: run.referrer }),\n ...(run.integratorFeeBps !== undefined && {\n integratorFeeBps: run.integratorFeeBps,\n }),\n ...(run.maxPriceImpactBps !== undefined && {\n maxPriceImpactBps: run.maxPriceImpactBps,\n }),\n ...(run.sweepTo !== undefined && { sweepTo: run.sweepTo }),\n ...(run.simulationPolicy !== undefined && {\n simulationPolicy: run.simulationPolicy,\n }),\n ...(run.checkOnChainAllowances !== undefined && {\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n});\n"],"mappings":"AAmFO,MAAM,eAAe,CAC1B,MACA,SAAkC,CAAC,OACZ;AAAA,EACvB;AAAA,EACA,GAAG;AACL;AAQO,MAAM,WAAW,CAAC,SAWN;AAAA,EACjB,QAAQ,IAAI;AAAA,EACZ,GAAI,IAAI,eAAe,UAAU,EAAE,eAAe,IAAI,cAAc;AAAA,EACpE,QAAQ,IAAI;AAAA,EACZ,GAAI,IAAI,eAAe,EAAE,aAAa,IAAI,YAAY;AAAA,EACtD,GAAI,IAAI,aAAa,UAAa,EAAE,UAAU,IAAI,SAAS;AAAA,EAC3D,GAAI,IAAI,qBAAqB,UAAa;AAAA,IACxC,kBAAkB,IAAI;AAAA,EACxB;AAAA,EACA,GAAI,IAAI,sBAAsB,UAAa;AAAA,IACzC,mBAAmB,IAAI;AAAA,EACzB;AAAA,EACA,GAAI,IAAI,YAAY,UAAa,EAAE,SAAS,IAAI,QAAQ;AAAA,EACxD,GAAI,IAAI,qBAAqB,UAAa;AAAA,IACxC,kBAAkB,IAAI;AAAA,EACxB;AAAA,EACA,GAAI,IAAI,2BAA2B,UAAa;AAAA,IAC9C,wBAAwB,IAAI;AAAA,EAC9B;AACF;","names":[]}
|
package/dist/sdk.cjs
CHANGED
|
@@ -35,6 +35,7 @@ const createComposeSdk = (options) => {
|
|
|
35
35
|
signer: run.signer,
|
|
36
36
|
assumptions: run.assumptions,
|
|
37
37
|
referrer: run.referrer,
|
|
38
|
+
integratorFeeBps: run.integratorFeeBps,
|
|
38
39
|
maxPriceImpactBps: run.maxPriceImpactBps,
|
|
39
40
|
sweepTo: run.sweepTo,
|
|
40
41
|
simulationPolicy: run.simulationPolicy,
|
package/dist/sdk.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["import type {\n ComposeCompileRequest,\n ComposeCompileResult,\n InputSpec,\n} from '@lifi/compose-spec';\n\nimport {\n createFlowBuilderCore,\n type FlowBuilderCore,\n type FlowOptions,\n type TypedFlow,\n} from './authoring/FlowBuilderCore.js';\nimport { type ComposeClient, createComposeClient } from './client.js';\nimport {\n bindGeneratedOps,\n type GeneratedOps,\n} from './generated/operations.generated.js';\nimport { buildRun, type ComposeRunInput } from './run/inputs.js';\nimport type { InputSchema } from './types.js';\n\nexport type { ComposeRunInput };\n\n/**\n * A flow builder augmented with generated operation methods and a `compile` method\n * that submits the flow to the Compose backend for compilation.\n *\n * Created via {@link ComposeSdk.flow}.\n *\n * @typeParam T - The input schema describing the flow's required inputs.\n */\nexport type FlowBuilder<T extends InputSchema = InputSchema> =\n FlowBuilderCore<T> &\n GeneratedOps & {\n /**\n * Builds the flow document from the current builder state and submits it\n * to the Compose API for compilation.\n *\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns The compiled transaction calldata and metadata.\n * @throws {@link ComposeError} on network, validation, or server errors.\n *\n * @example\n * ```ts\n * const result = await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * console.log(result.calldata);\n * ```\n */\n readonly compile: (\n run: ComposeRunInput<T>,\n ) => Promise<ComposeCompileResult>;\n };\n\n/**\n * Configuration for creating a Compose SDK instance.\n */\nexport interface ComposeSdkOptions {\n /** Base URL of the Compose API (e.g. `\"https://li.quest\"`). */\n readonly baseUrl: string;\n /** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */\n readonly fetch?: typeof globalThis.fetch;\n /** Optional LI.FI API key for authenticated access. Sent as the `x-lifi-api-key` header on every request. */\n readonly apiKey?: string;\n}\n\n/**\n * The top-level Compose SDK interface.\n *\n * Provides methods to build flows, compile them into executable calldata, and\n * interact with the Compose API directly.\n *\n * @example\n * ```ts\n * import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';\n *\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });\n *\n * const builder = sdk.flow(1, {\n * inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },\n * });\n *\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.usdc },\n * config: { resourceOut: resources.native(1) },\n * });\n *\n * const result = await builder.compile({\n * inputs: { usdc: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport interface ComposeSdk {\n /** Low-level HTTP client for the Compose API. */\n readonly client: ComposeClient;\n /**\n * Creates a new flow builder targeting the given chain.\n * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).\n * @param options - Flow configuration including input declarations.\n * @returns A {@link FlowBuilder} with generated operation methods and a `compile` method.\n * @throws Error if any resource input's `chainId` doesn't match the flow's `chainId`.\n */\n readonly flow: <T extends InputSchema>(\n chainId: number,\n options: FlowOptions<T>,\n ) => FlowBuilder<T>;\n /**\n * Builds a raw compile request without sending it. Useful for inspecting the\n * request payload or submitting it through a custom transport.\n * @param flow - A built flow document (from `builder.build()`).\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns A {@link ComposeCompileRequest} ready to send to the Compose API.\n */\n readonly request: <T extends InputSchema>(\n flow: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ) => ComposeCompileRequest;\n}\n\n/**\n * Creates a new Compose SDK instance.\n *\n * @param options - SDK configuration including the API base URL and optional fetch implementation.\n * @returns A {@link ComposeSdk} instance.\n *\n * @example\n * ```ts\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });\n * ```\n */\nexport const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {\n const composeClient = createComposeClient(options);\n\n const request = <T extends InputSchema>(\n flowDoc: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ): ComposeCompileRequest => ({\n flow: flowDoc,\n run: buildRun({\n inputs: run.inputs as Record<string, InputSpec>,\n preconditions: run.preconditions,\n signer: run.signer,\n assumptions: run.assumptions as Record<string, bigint> | undefined,\n referrer: run.referrer,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n });\n\n const flow = <T extends InputSchema>(\n chainId: number,\n opts: FlowOptions<T>,\n ): FlowBuilder<T> => {\n const core = createFlowBuilderCore(chainId, opts);\n const builder = Object.assign(core, bindGeneratedOps(core));\n\n const compile = async (\n run: ComposeRunInput<T>,\n ): Promise<ComposeCompileResult> => {\n const flowDoc = builder.build();\n const req = request(flowDoc, run);\n return composeClient.compile(req);\n };\n\n return Object.assign(builder, { compile });\n };\n\n return { client: composeClient, flow, request };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,6BAKO;AACP,oBAAwD;AACxD,kCAGO;AACP,oBAA+C;AAmHxC,MAAM,mBAAmB,CAAC,YAA2C;AAC1E,QAAM,oBAAgB,mCAAoB,OAAO;AAEjD,QAAM,UAAU,CACd,SACA,SAC2B;AAAA,IAC3B,MAAM;AAAA,IACN,SAAK,wBAAS;AAAA,MACZ,QAAQ,IAAI;AAAA,MACZ,eAAe,IAAI;AAAA,MACnB,QAAQ,IAAI;AAAA,MACZ,aAAa,IAAI;AAAA,MACjB,UAAU,IAAI;AAAA,MACd,mBAAmB,IAAI;AAAA,MACvB,SAAS,IAAI;AAAA,MACb,kBAAkB,IAAI;AAAA,MACtB,wBAAwB,IAAI;AAAA,IAC9B,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,CACX,SACA,SACmB;AACnB,UAAM,WAAO,8CAAsB,SAAS,IAAI;AAChD,UAAM,UAAU,OAAO,OAAO,UAAM,8CAAiB,IAAI,CAAC;AAE1D,UAAM,UAAU,OACd,QACkC;AAClC,YAAM,UAAU,QAAQ,MAAM;AAC9B,YAAM,MAAM,QAAQ,SAAS,GAAG;AAChC,aAAO,cAAc,QAAQ,GAAG;AAAA,IAClC;AAEA,WAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC3C;AAEA,SAAO,EAAE,QAAQ,eAAe,MAAM,QAAQ;AAChD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["import type {\n ComposeCompileRequest,\n ComposeCompileResult,\n InputSpec,\n} from '@lifi/compose-spec';\n\nimport {\n createFlowBuilderCore,\n type FlowBuilderCore,\n type FlowOptions,\n type TypedFlow,\n} from './authoring/FlowBuilderCore.js';\nimport { type ComposeClient, createComposeClient } from './client.js';\nimport {\n bindGeneratedOps,\n type GeneratedOps,\n} from './generated/operations.generated.js';\nimport { buildRun, type ComposeRunInput } from './run/inputs.js';\nimport type { InputSchema } from './types.js';\n\nexport type { ComposeRunInput };\n\n/**\n * A flow builder augmented with generated operation methods and a `compile` method\n * that submits the flow to the Compose backend for compilation.\n *\n * Created via {@link ComposeSdk.flow}.\n *\n * @typeParam T - The input schema describing the flow's required inputs.\n */\nexport type FlowBuilder<T extends InputSchema = InputSchema> =\n FlowBuilderCore<T> &\n GeneratedOps & {\n /**\n * Builds the flow document from the current builder state and submits it\n * to the Compose API for compilation.\n *\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns The compiled transaction calldata and metadata.\n * @throws {@link ComposeError} on network, validation, or server errors.\n *\n * @example\n * ```ts\n * const result = await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * console.log(result.calldata);\n * ```\n */\n readonly compile: (\n run: ComposeRunInput<T>,\n ) => Promise<ComposeCompileResult>;\n };\n\n/**\n * Configuration for creating a Compose SDK instance.\n */\nexport interface ComposeSdkOptions {\n /** Base URL of the Compose API (e.g. `\"https://li.quest\"`). */\n readonly baseUrl: string;\n /** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */\n readonly fetch?: typeof globalThis.fetch;\n /** Optional LI.FI API key for authenticated access. Sent as the `x-lifi-api-key` header on every request. */\n readonly apiKey?: string;\n}\n\n/**\n * The top-level Compose SDK interface.\n *\n * Provides methods to build flows, compile them into executable calldata, and\n * interact with the Compose API directly.\n *\n * @example\n * ```ts\n * import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';\n *\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });\n *\n * const builder = sdk.flow(1, {\n * inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },\n * });\n *\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.usdc },\n * config: { resourceOut: resources.native(1) },\n * });\n *\n * const result = await builder.compile({\n * inputs: { usdc: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport interface ComposeSdk {\n /** Low-level HTTP client for the Compose API. */\n readonly client: ComposeClient;\n /**\n * Creates a new flow builder targeting the given chain.\n * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).\n * @param options - Flow configuration including input declarations.\n * @returns A {@link FlowBuilder} with generated operation methods and a `compile` method.\n * @throws Error if any resource input's `chainId` doesn't match the flow's `chainId`.\n */\n readonly flow: <T extends InputSchema>(\n chainId: number,\n options: FlowOptions<T>,\n ) => FlowBuilder<T>;\n /**\n * Builds a raw compile request without sending it. Useful for inspecting the\n * request payload or submitting it through a custom transport.\n * @param flow - A built flow document (from `builder.build()`).\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns A {@link ComposeCompileRequest} ready to send to the Compose API.\n */\n readonly request: <T extends InputSchema>(\n flow: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ) => ComposeCompileRequest;\n}\n\n/**\n * Creates a new Compose SDK instance.\n *\n * @param options - SDK configuration including the API base URL and optional fetch implementation.\n * @returns A {@link ComposeSdk} instance.\n *\n * @example\n * ```ts\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });\n * ```\n */\nexport const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {\n const composeClient = createComposeClient(options);\n\n const request = <T extends InputSchema>(\n flowDoc: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ): ComposeCompileRequest => ({\n flow: flowDoc,\n run: buildRun({\n inputs: run.inputs as Record<string, InputSpec>,\n preconditions: run.preconditions,\n signer: run.signer,\n assumptions: run.assumptions as Record<string, bigint> | undefined,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n });\n\n const flow = <T extends InputSchema>(\n chainId: number,\n opts: FlowOptions<T>,\n ): FlowBuilder<T> => {\n const core = createFlowBuilderCore(chainId, opts);\n const builder = Object.assign(core, bindGeneratedOps(core));\n\n const compile = async (\n run: ComposeRunInput<T>,\n ): Promise<ComposeCompileResult> => {\n const flowDoc = builder.build();\n const req = request(flowDoc, run);\n return composeClient.compile(req);\n };\n\n return Object.assign(builder, { compile });\n };\n\n return { client: composeClient, flow, request };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,6BAKO;AACP,oBAAwD;AACxD,kCAGO;AACP,oBAA+C;AAmHxC,MAAM,mBAAmB,CAAC,YAA2C;AAC1E,QAAM,oBAAgB,mCAAoB,OAAO;AAEjD,QAAM,UAAU,CACd,SACA,SAC2B;AAAA,IAC3B,MAAM;AAAA,IACN,SAAK,wBAAS;AAAA,MACZ,QAAQ,IAAI;AAAA,MACZ,eAAe,IAAI;AAAA,MACnB,QAAQ,IAAI;AAAA,MACZ,aAAa,IAAI;AAAA,MACjB,UAAU,IAAI;AAAA,MACd,kBAAkB,IAAI;AAAA,MACtB,mBAAmB,IAAI;AAAA,MACvB,SAAS,IAAI;AAAA,MACb,kBAAkB,IAAI;AAAA,MACtB,wBAAwB,IAAI;AAAA,IAC9B,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,CACX,SACA,SACmB;AACnB,UAAM,WAAO,8CAAsB,SAAS,IAAI;AAChD,UAAM,UAAU,OAAO,OAAO,UAAM,8CAAiB,IAAI,CAAC;AAE1D,UAAM,UAAU,OACd,QACkC;AAClC,YAAM,UAAU,QAAQ,MAAM;AAC9B,YAAM,MAAM,QAAQ,SAAS,GAAG;AAChC,aAAO,cAAc,QAAQ,GAAG;AAAA,IAClC;AAEA,WAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC3C;AAEA,SAAO,EAAE,QAAQ,eAAe,MAAM,QAAQ;AAChD;","names":[]}
|
package/dist/sdk.js
CHANGED
|
@@ -16,6 +16,7 @@ const createComposeSdk = (options) => {
|
|
|
16
16
|
signer: run.signer,
|
|
17
17
|
assumptions: run.assumptions,
|
|
18
18
|
referrer: run.referrer,
|
|
19
|
+
integratorFeeBps: run.integratorFeeBps,
|
|
19
20
|
maxPriceImpactBps: run.maxPriceImpactBps,
|
|
20
21
|
sweepTo: run.sweepTo,
|
|
21
22
|
simulationPolicy: run.simulationPolicy,
|
package/dist/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["import type {\n ComposeCompileRequest,\n ComposeCompileResult,\n InputSpec,\n} from '@lifi/compose-spec';\n\nimport {\n createFlowBuilderCore,\n type FlowBuilderCore,\n type FlowOptions,\n type TypedFlow,\n} from './authoring/FlowBuilderCore.js';\nimport { type ComposeClient, createComposeClient } from './client.js';\nimport {\n bindGeneratedOps,\n type GeneratedOps,\n} from './generated/operations.generated.js';\nimport { buildRun, type ComposeRunInput } from './run/inputs.js';\nimport type { InputSchema } from './types.js';\n\nexport type { ComposeRunInput };\n\n/**\n * A flow builder augmented with generated operation methods and a `compile` method\n * that submits the flow to the Compose backend for compilation.\n *\n * Created via {@link ComposeSdk.flow}.\n *\n * @typeParam T - The input schema describing the flow's required inputs.\n */\nexport type FlowBuilder<T extends InputSchema = InputSchema> =\n FlowBuilderCore<T> &\n GeneratedOps & {\n /**\n * Builds the flow document from the current builder state and submits it\n * to the Compose API for compilation.\n *\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns The compiled transaction calldata and metadata.\n * @throws {@link ComposeError} on network, validation, or server errors.\n *\n * @example\n * ```ts\n * const result = await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * console.log(result.calldata);\n * ```\n */\n readonly compile: (\n run: ComposeRunInput<T>,\n ) => Promise<ComposeCompileResult>;\n };\n\n/**\n * Configuration for creating a Compose SDK instance.\n */\nexport interface ComposeSdkOptions {\n /** Base URL of the Compose API (e.g. `\"https://li.quest\"`). */\n readonly baseUrl: string;\n /** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */\n readonly fetch?: typeof globalThis.fetch;\n /** Optional LI.FI API key for authenticated access. Sent as the `x-lifi-api-key` header on every request. */\n readonly apiKey?: string;\n}\n\n/**\n * The top-level Compose SDK interface.\n *\n * Provides methods to build flows, compile them into executable calldata, and\n * interact with the Compose API directly.\n *\n * @example\n * ```ts\n * import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';\n *\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });\n *\n * const builder = sdk.flow(1, {\n * inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },\n * });\n *\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.usdc },\n * config: { resourceOut: resources.native(1) },\n * });\n *\n * const result = await builder.compile({\n * inputs: { usdc: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport interface ComposeSdk {\n /** Low-level HTTP client for the Compose API. */\n readonly client: ComposeClient;\n /**\n * Creates a new flow builder targeting the given chain.\n * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).\n * @param options - Flow configuration including input declarations.\n * @returns A {@link FlowBuilder} with generated operation methods and a `compile` method.\n * @throws Error if any resource input's `chainId` doesn't match the flow's `chainId`.\n */\n readonly flow: <T extends InputSchema>(\n chainId: number,\n options: FlowOptions<T>,\n ) => FlowBuilder<T>;\n /**\n * Builds a raw compile request without sending it. Useful for inspecting the\n * request payload or submitting it through a custom transport.\n * @param flow - A built flow document (from `builder.build()`).\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns A {@link ComposeCompileRequest} ready to send to the Compose API.\n */\n readonly request: <T extends InputSchema>(\n flow: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ) => ComposeCompileRequest;\n}\n\n/**\n * Creates a new Compose SDK instance.\n *\n * @param options - SDK configuration including the API base URL and optional fetch implementation.\n * @returns A {@link ComposeSdk} instance.\n *\n * @example\n * ```ts\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });\n * ```\n */\nexport const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {\n const composeClient = createComposeClient(options);\n\n const request = <T extends InputSchema>(\n flowDoc: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ): ComposeCompileRequest => ({\n flow: flowDoc,\n run: buildRun({\n inputs: run.inputs as Record<string, InputSpec>,\n preconditions: run.preconditions,\n signer: run.signer,\n assumptions: run.assumptions as Record<string, bigint> | undefined,\n referrer: run.referrer,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n });\n\n const flow = <T extends InputSchema>(\n chainId: number,\n opts: FlowOptions<T>,\n ): FlowBuilder<T> => {\n const core = createFlowBuilderCore(chainId, opts);\n const builder = Object.assign(core, bindGeneratedOps(core));\n\n const compile = async (\n run: ComposeRunInput<T>,\n ): Promise<ComposeCompileResult> => {\n const flowDoc = builder.build();\n const req = request(flowDoc, run);\n return composeClient.compile(req);\n };\n\n return Object.assign(builder, { compile });\n };\n\n return { client: composeClient, flow, request };\n};\n"],"mappings":"AAMA;AAAA,EACE;AAAA,OAIK;AACP,SAA6B,2BAA2B;AACxD;AAAA,EACE;AAAA,OAEK;AACP,SAAS,gBAAsC;AAmHxC,MAAM,mBAAmB,CAAC,YAA2C;AAC1E,QAAM,gBAAgB,oBAAoB,OAAO;AAEjD,QAAM,UAAU,CACd,SACA,SAC2B;AAAA,IAC3B,MAAM;AAAA,IACN,KAAK,SAAS;AAAA,MACZ,QAAQ,IAAI;AAAA,MACZ,eAAe,IAAI;AAAA,MACnB,QAAQ,IAAI;AAAA,MACZ,aAAa,IAAI;AAAA,MACjB,UAAU,IAAI;AAAA,MACd,mBAAmB,IAAI;AAAA,MACvB,SAAS,IAAI;AAAA,MACb,kBAAkB,IAAI;AAAA,MACtB,wBAAwB,IAAI;AAAA,IAC9B,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,CACX,SACA,SACmB;AACnB,UAAM,OAAO,sBAAsB,SAAS,IAAI;AAChD,UAAM,UAAU,OAAO,OAAO,MAAM,iBAAiB,IAAI,CAAC;AAE1D,UAAM,UAAU,OACd,QACkC;AAClC,YAAM,UAAU,QAAQ,MAAM;AAC9B,YAAM,MAAM,QAAQ,SAAS,GAAG;AAChC,aAAO,cAAc,QAAQ,GAAG;AAAA,IAClC;AAEA,WAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC3C;AAEA,SAAO,EAAE,QAAQ,eAAe,MAAM,QAAQ;AAChD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["import type {\n ComposeCompileRequest,\n ComposeCompileResult,\n InputSpec,\n} from '@lifi/compose-spec';\n\nimport {\n createFlowBuilderCore,\n type FlowBuilderCore,\n type FlowOptions,\n type TypedFlow,\n} from './authoring/FlowBuilderCore.js';\nimport { type ComposeClient, createComposeClient } from './client.js';\nimport {\n bindGeneratedOps,\n type GeneratedOps,\n} from './generated/operations.generated.js';\nimport { buildRun, type ComposeRunInput } from './run/inputs.js';\nimport type { InputSchema } from './types.js';\n\nexport type { ComposeRunInput };\n\n/**\n * A flow builder augmented with generated operation methods and a `compile` method\n * that submits the flow to the Compose backend for compilation.\n *\n * Created via {@link ComposeSdk.flow}.\n *\n * @typeParam T - The input schema describing the flow's required inputs.\n */\nexport type FlowBuilder<T extends InputSchema = InputSchema> =\n FlowBuilderCore<T> &\n GeneratedOps & {\n /**\n * Builds the flow document from the current builder state and submits it\n * to the Compose API for compilation.\n *\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns The compiled transaction calldata and metadata.\n * @throws {@link ComposeError} on network, validation, or server errors.\n *\n * @example\n * ```ts\n * const result = await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * console.log(result.calldata);\n * ```\n */\n readonly compile: (\n run: ComposeRunInput<T>,\n ) => Promise<ComposeCompileResult>;\n };\n\n/**\n * Configuration for creating a Compose SDK instance.\n */\nexport interface ComposeSdkOptions {\n /** Base URL of the Compose API (e.g. `\"https://li.quest\"`). */\n readonly baseUrl: string;\n /** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */\n readonly fetch?: typeof globalThis.fetch;\n /** Optional LI.FI API key for authenticated access. Sent as the `x-lifi-api-key` header on every request. */\n readonly apiKey?: string;\n}\n\n/**\n * The top-level Compose SDK interface.\n *\n * Provides methods to build flows, compile them into executable calldata, and\n * interact with the Compose API directly.\n *\n * @example\n * ```ts\n * import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';\n *\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });\n *\n * const builder = sdk.flow(1, {\n * inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },\n * });\n *\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.usdc },\n * config: { resourceOut: resources.native(1) },\n * });\n *\n * const result = await builder.compile({\n * inputs: { usdc: materialisers.balanceOf({}) },\n * signer: '0xYourAddress...',\n * });\n * ```\n */\nexport interface ComposeSdk {\n /** Low-level HTTP client for the Compose API. */\n readonly client: ComposeClient;\n /**\n * Creates a new flow builder targeting the given chain.\n * @param chainId - The EVM chain ID (e.g. `1` for Ethereum mainnet).\n * @param options - Flow configuration including input declarations.\n * @returns A {@link FlowBuilder} with generated operation methods and a `compile` method.\n * @throws Error if any resource input's `chainId` doesn't match the flow's `chainId`.\n */\n readonly flow: <T extends InputSchema>(\n chainId: number,\n options: FlowOptions<T>,\n ) => FlowBuilder<T>;\n /**\n * Builds a raw compile request without sending it. Useful for inspecting the\n * request payload or submitting it through a custom transport.\n * @param flow - A built flow document (from `builder.build()`).\n * @param run - Runtime inputs, preconditions, and signer address.\n * @returns A {@link ComposeCompileRequest} ready to send to the Compose API.\n */\n readonly request: <T extends InputSchema>(\n flow: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ) => ComposeCompileRequest;\n}\n\n/**\n * Creates a new Compose SDK instance.\n *\n * @param options - SDK configuration including the API base URL and optional fetch implementation.\n * @returns A {@link ComposeSdk} instance.\n *\n * @example\n * ```ts\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });\n * ```\n */\nexport const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {\n const composeClient = createComposeClient(options);\n\n const request = <T extends InputSchema>(\n flowDoc: TypedFlow<T>,\n run: ComposeRunInput<T>,\n ): ComposeCompileRequest => ({\n flow: flowDoc,\n run: buildRun({\n inputs: run.inputs as Record<string, InputSpec>,\n preconditions: run.preconditions,\n signer: run.signer,\n assumptions: run.assumptions as Record<string, bigint> | undefined,\n referrer: run.referrer,\n integratorFeeBps: run.integratorFeeBps,\n maxPriceImpactBps: run.maxPriceImpactBps,\n sweepTo: run.sweepTo,\n simulationPolicy: run.simulationPolicy,\n checkOnChainAllowances: run.checkOnChainAllowances,\n }),\n });\n\n const flow = <T extends InputSchema>(\n chainId: number,\n opts: FlowOptions<T>,\n ): FlowBuilder<T> => {\n const core = createFlowBuilderCore(chainId, opts);\n const builder = Object.assign(core, bindGeneratedOps(core));\n\n const compile = async (\n run: ComposeRunInput<T>,\n ): Promise<ComposeCompileResult> => {\n const flowDoc = builder.build();\n const req = request(flowDoc, run);\n return composeClient.compile(req);\n };\n\n return Object.assign(builder, { compile });\n };\n\n return { client: composeClient, flow, request };\n};\n"],"mappings":"AAMA;AAAA,EACE;AAAA,OAIK;AACP,SAA6B,2BAA2B;AACxD;AAAA,EACE;AAAA,OAEK;AACP,SAAS,gBAAsC;AAmHxC,MAAM,mBAAmB,CAAC,YAA2C;AAC1E,QAAM,gBAAgB,oBAAoB,OAAO;AAEjD,QAAM,UAAU,CACd,SACA,SAC2B;AAAA,IAC3B,MAAM;AAAA,IACN,KAAK,SAAS;AAAA,MACZ,QAAQ,IAAI;AAAA,MACZ,eAAe,IAAI;AAAA,MACnB,QAAQ,IAAI;AAAA,MACZ,aAAa,IAAI;AAAA,MACjB,UAAU,IAAI;AAAA,MACd,kBAAkB,IAAI;AAAA,MACtB,mBAAmB,IAAI;AAAA,MACvB,SAAS,IAAI;AAAA,MACb,kBAAkB,IAAI;AAAA,MACtB,wBAAwB,IAAI;AAAA,IAC9B,CAAC;AAAA,EACH;AAEA,QAAM,OAAO,CACX,SACA,SACmB;AACnB,UAAM,OAAO,sBAAsB,SAAS,IAAI;AAChD,UAAM,UAAU,OAAO,OAAO,MAAM,iBAAiB,IAAI,CAAC;AAE1D,UAAM,UAAU,OACd,QACkC;AAClC,YAAM,UAAU,QAAQ,MAAM;AAC9B,YAAM,MAAM,QAAQ,SAAS,GAAG;AAChC,aAAO,cAAc,QAAQ,GAAG;AAAA,IAClC;AAEA,WAAO,OAAO,OAAO,SAAS,EAAE,QAAQ,CAAC;AAAA,EAC3C;AAEA,SAAO,EAAE,QAAQ,eAAe,MAAM,QAAQ;AAChD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/composer-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.2.0-staging.4",
|
|
4
4
|
"description": "Public Composer SDK for building and submitting flows",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/lifinance/Yggdrasil.git",
|
|
9
|
+
"directory": "ts/packages/composer-sdk"
|
|
10
|
+
},
|
|
6
11
|
"type": "module",
|
|
7
12
|
"sideEffects": false,
|
|
8
13
|
"main": "./dist/index.cjs",
|
|
@@ -30,20 +35,23 @@
|
|
|
30
35
|
"build": "tsc --noEmit && tsup",
|
|
31
36
|
"clean": "rm -rf dist out",
|
|
32
37
|
"pack:local": "yarn build && mkdir -p out && yarn pack --out 'out/%s-%v.tgz'",
|
|
33
|
-
"generate": "tsx scripts/generate-sdk.ts",
|
|
38
|
+
"generate": "tsx scripts/generate-sdk/index.ts",
|
|
39
|
+
"generate:staged": "tsx scripts/generate-sdk/index.ts --staged",
|
|
34
40
|
"test": "vitest run --config vitest.config.ts",
|
|
35
41
|
"check:types": "tsc --noEmit",
|
|
36
42
|
"check:sdk-drift": "vitest run --config vitest.drift.config.ts",
|
|
37
43
|
"fix": "run-s fix:lint fix:prettier",
|
|
38
44
|
"fix:lint": "eslint src --fix",
|
|
39
|
-
"fix:prettier": "prettier \"src/**/*.ts\" --write",
|
|
45
|
+
"fix:prettier": "prettier \"src/**/*.ts\" \"scripts/**/*.ts\" --write",
|
|
40
46
|
"lint": "eslint src",
|
|
41
47
|
"test:lint": "eslint src",
|
|
42
|
-
"test:prettier": "prettier \"src/**/*.ts\" --list-different",
|
|
43
|
-
"
|
|
48
|
+
"test:prettier": "prettier \"src/**/*.ts\" \"scripts/**/*.ts\" --list-different",
|
|
49
|
+
"verify:staged": "bash scripts/verify-staged.sh",
|
|
50
|
+
"example": "tsx src/examples/run.ts",
|
|
51
|
+
"example:staged": "tsx src/examples/run.ts --staged"
|
|
44
52
|
},
|
|
45
53
|
"peerDependencies": {
|
|
46
|
-
"@lifi/compose-spec": "0.0.
|
|
54
|
+
"@lifi/compose-spec": "0.2.0-staging.4"
|
|
47
55
|
},
|
|
48
56
|
"dependencies": {
|
|
49
57
|
"abitype": "^1.2.3",
|
|
@@ -187,7 +187,7 @@ const resolvePositionalArgs = (
|
|
|
187
187
|
|
|
188
188
|
return paramNames.map((name) => {
|
|
189
189
|
const bindable = bind[name];
|
|
190
|
-
if (bindable
|
|
190
|
+
if (bindable === undefined) {
|
|
191
191
|
throw new Error(
|
|
192
192
|
`${label}: bind value for parameter "${name}" is undefined`,
|
|
193
193
|
);
|
|
@@ -211,7 +211,7 @@ export const buildCallWireFormat = (
|
|
|
211
211
|
args.bind,
|
|
212
212
|
args.config,
|
|
213
213
|
);
|
|
214
|
-
const hasResource = args.resource
|
|
214
|
+
const hasResource = args.resource !== undefined;
|
|
215
215
|
|
|
216
216
|
return {
|
|
217
217
|
op: hasResource ? 'core.call' : 'core.invoke',
|
package/src/client.ts
CHANGED
|
@@ -201,7 +201,7 @@ export const createComposeClient = (
|
|
|
201
201
|
options?: GetZapPacksOptions,
|
|
202
202
|
): Promise<readonly ZapPackOverview[]> => {
|
|
203
203
|
const params = new URLSearchParams();
|
|
204
|
-
if (options?.protocols
|
|
204
|
+
if (options?.protocols !== undefined) {
|
|
205
205
|
// Backend expects a single comma-separated value, not repeated keys.
|
|
206
206
|
const raw = options.protocols;
|
|
207
207
|
const list = typeof raw === 'string' ? raw : raw.join(',');
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
2
|
+
|
|
3
|
+
import { createComposeSdk } from '../index.js';
|
|
4
|
+
import type { Address } from '../types.js';
|
|
5
|
+
|
|
6
|
+
import { BASE_URL } from './config.js';
|
|
7
|
+
|
|
8
|
+
// Aave v3 incentives contracts on Ethereum mainnet.
|
|
9
|
+
const REWARDS_CONTROLLER = '0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb';
|
|
10
|
+
const AAVE = '0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9';
|
|
11
|
+
// Receipt-token positions the proxy holds and that accrue AAVE rewards.
|
|
12
|
+
const A_ETH_USDC = '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c';
|
|
13
|
+
const VDEBT_USDC = '0x72E95b8931767C79bA4EeE721354d6E99a61D004';
|
|
14
|
+
|
|
15
|
+
export interface AaveClaimRewardsInput {
|
|
16
|
+
readonly owner: Address;
|
|
17
|
+
readonly recipient: Address;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Claim accrued AAVE rewards from a set of Aave v3 receipt-token positions,
|
|
22
|
+
* then forward the claimed amount to a recipient.
|
|
23
|
+
*
|
|
24
|
+
* The op surfaces the claimed AAVE as a tracked resource (`claimed`) so
|
|
25
|
+
* downstream nodes can spend or forward it. With no `amount` configured,
|
|
26
|
+
* Aave claims the full accrued balance (MaxUint256 sentinel).
|
|
27
|
+
*
|
|
28
|
+
* Demonstrates:
|
|
29
|
+
* - `aave.claimRewards` against multiple aToken/vDebt positions.
|
|
30
|
+
* - Routing the `claimed` resource output into `core.transfer`.
|
|
31
|
+
* - The `claimedAmount` handle for assertions or downstream arithmetic.
|
|
32
|
+
*/
|
|
33
|
+
export const buildAaveClaimRewards = ({
|
|
34
|
+
owner,
|
|
35
|
+
recipient,
|
|
36
|
+
}: AaveClaimRewardsInput): {
|
|
37
|
+
flow: Flow;
|
|
38
|
+
request: ComposeCompileRequest;
|
|
39
|
+
} => {
|
|
40
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
41
|
+
|
|
42
|
+
const builder = sdk.flow(1, {
|
|
43
|
+
name: 'aave-claim-rewards',
|
|
44
|
+
inputs: {
|
|
45
|
+
recipient: 'address',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const claimOut = builder.aave.claimRewards('claim', {
|
|
50
|
+
bind: {},
|
|
51
|
+
config: {
|
|
52
|
+
rewardsController: REWARDS_CONTROLLER,
|
|
53
|
+
assets: [A_ETH_USDC, VDEBT_USDC],
|
|
54
|
+
reward: AAVE,
|
|
55
|
+
// amount omitted → claim full accrued balance.
|
|
56
|
+
// to omitted → rewards land on the proxy (executionAddress).
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// Forward the claimed AAVE to the requested recipient.
|
|
61
|
+
builder.core.transfer('forward-rewards', {
|
|
62
|
+
bind: {
|
|
63
|
+
amount: claimOut.claimed,
|
|
64
|
+
recipient: builder.inputs.recipient,
|
|
65
|
+
},
|
|
66
|
+
config: {},
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const flow = builder.build();
|
|
70
|
+
|
|
71
|
+
const request = sdk.request(flow, {
|
|
72
|
+
signer: owner,
|
|
73
|
+
inputs: {
|
|
74
|
+
recipient,
|
|
75
|
+
},
|
|
76
|
+
sweepTo: builder.context.sender,
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return { flow, request };
|
|
80
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
2
|
+
|
|
3
|
+
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
|
+
import type { Address } from '../types.js';
|
|
5
|
+
|
|
6
|
+
import { BASE_URL } from './config.js';
|
|
7
|
+
|
|
8
|
+
// Aave v3 contracts on Ethereum mainnet.
|
|
9
|
+
const AAVE_V3_POOL = '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2';
|
|
10
|
+
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
11
|
+
|
|
12
|
+
export interface AaveRepayInput {
|
|
13
|
+
readonly owner: Address;
|
|
14
|
+
readonly amount: `${bigint}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Repay an Aave v3 variable-rate WETH debt by supplying WETH to the proxy.
|
|
19
|
+
*
|
|
20
|
+
* Aave internally caps the repay at `min(amount, outstandingDebt)`, so the
|
|
21
|
+
* op returns any unspent WETH on the `residual` resource port. The
|
|
22
|
+
* residual is swept back to the sender on completion.
|
|
23
|
+
*
|
|
24
|
+
* Demonstrates:
|
|
25
|
+
* - `aave.repay` with a resource input (the WETH used to repay).
|
|
26
|
+
* - Binding `onBehalfOf` from the runtime context — the proxy repays its
|
|
27
|
+
* own debt position.
|
|
28
|
+
* - The `residual` port for surfacing any unused input back to the caller.
|
|
29
|
+
*/
|
|
30
|
+
export const buildAaveRepay = ({
|
|
31
|
+
owner,
|
|
32
|
+
amount,
|
|
33
|
+
}: AaveRepayInput): {
|
|
34
|
+
flow: Flow;
|
|
35
|
+
request: ComposeCompileRequest;
|
|
36
|
+
} => {
|
|
37
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
38
|
+
|
|
39
|
+
const builder = sdk.flow(1, {
|
|
40
|
+
name: 'aave-repay-weth',
|
|
41
|
+
inputs: {
|
|
42
|
+
assetIn: resources.erc20(WETH, 1),
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
builder.aave.repay('repay', {
|
|
47
|
+
bind: {
|
|
48
|
+
assetIn: builder.inputs.assetIn,
|
|
49
|
+
onBehalfOf: builder.context.executionAddress,
|
|
50
|
+
},
|
|
51
|
+
config: {
|
|
52
|
+
pool: AAVE_V3_POOL,
|
|
53
|
+
mode: 'exact',
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const flow = builder.build();
|
|
58
|
+
|
|
59
|
+
const request = sdk.request(flow, {
|
|
60
|
+
signer: owner,
|
|
61
|
+
inputs: {
|
|
62
|
+
assetIn: materialisers.directDeposit({ amount }),
|
|
63
|
+
},
|
|
64
|
+
// Any unspent WETH (residual) is swept back to the signer.
|
|
65
|
+
sweepTo: builder.context.sender,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return { flow, request };
|
|
69
|
+
};
|