@lifi/composer-sdk 0.2.0 → 0.3.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.
- package/README.md +23 -3
- package/dist/client.cjs +9 -3
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +9 -3
- package/dist/client.js.map +1 -1
- package/dist/generated/config.generated.cjs.map +1 -1
- package/dist/generated/config.generated.d.cts +37 -14
- package/dist/generated/config.generated.d.ts +37 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.d.cts +5 -5
- package/dist/sdk.d.ts +5 -5
- package/dist/sdk.js.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +10 -5
- package/src/examples/aaveClaimRewards.ts +2 -2
- package/src/examples/aaveRepay.ts +2 -2
- package/src/examples/aaveRepayWithATokens.ts +2 -2
- package/src/examples/aaveSetEMode.ts +2 -2
- package/src/examples/approveAndDeposit.ts +2 -2
- package/src/examples/callContract.ts +4 -4
- package/src/examples/config.ts +4 -1
- package/src/examples/consolidateToEth.ts +2 -2
- package/src/examples/consolidateToUsdc.ts +2 -2
- package/src/examples/depositFromProxy.ts +2 -2
- package/src/examples/dustSweep.ts +2 -2
- package/src/examples/emitCustomEvent.ts +2 -2
- package/src/examples/invariantChecks.ts +2 -2
- package/src/examples/lifiSwap.ts +2 -2
- package/src/examples/lifiZap.ts +2 -2
- package/src/examples/rawCallWithArithmetic.ts +2 -2
- package/src/examples/readContractState.ts +2 -2
- package/src/examples/splitAndZap.ts +2 -2
- package/src/examples/splitWithArithmetic.ts +2 -2
- package/src/examples/swapAndZap.ts +2 -2
- package/src/examples/swapToRecipient.ts +2 -2
- package/src/examples/swapWithAllowRevert.ts +3 -3
- package/src/examples/swapWithBalanceCheck.ts +2 -2
- package/src/examples/swapWithFee.ts +2 -2
- package/src/examples/swapWithOutputValidation.ts +2 -2
- package/src/examples/transferTokens.ts +3 -3
- package/src/examples/untypedOpWithTypedRef.ts +2 -2
- package/src/generated/config.generated.ts +42 -14
- package/src/index.ts +6 -0
- package/src/sdk.ts +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AbiTypeToOutputKind, Address, InputDecl, InputSchema, InputSpecOf, IntegerString, IntegerStringInput, OutputKind, TypedGuard, TypedRef } from './types.cjs';
|
|
2
2
|
export { GetZapPacksOptions, ZapPackEdge, ZapPackOverview } from './discovery.cjs';
|
|
3
3
|
export { ComposeError, ComposeErrorCode, isComposeError } from './errors.cjs';
|
|
4
|
-
export { AppliedGuard, ApprovalEntry, Call, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeTransactionRequest, Erc20AllowanceRequirement, Erc20BalanceRequirement, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, NativeBalanceRequirement, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SlotFinderRequirement, SolType, SweepTo, TrackedBalance } from '@lifi/compose-spec';
|
|
4
|
+
export { AppliedGuard, ApprovalEntry, Call, Check, CheckComparator, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeTransactionRequest, ContinuationIntent, ContinuationOutcome, ContinuationPlanWire, Erc20AllowanceRequirement, Erc20BalanceRequirement, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, NativeBalanceRequirement, Phase1ArtifactWire, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SlotFinderRequirement, SolType, SweepTo, TrackedBalance } from '@lifi/compose-spec';
|
|
5
5
|
export { AnyHandle, Bindable, InputHandle, OutputHandle, ResourceInputHandle, isInputHandle, isOutputHandle } from './authoring/handles.cjs';
|
|
6
6
|
export { ref } from './authoring/raw.cjs';
|
|
7
7
|
export { AnyBindable, FlowOptions, TypedFlow } from './authoring/FlowBuilderCore.cjs';
|
|
@@ -13,7 +13,7 @@ import { m as materialisersMod } from './materialisers.generated-BWq5oePO.cjs';
|
|
|
13
13
|
import { p as preconditionsMod } from './preconditions.generated-DblS13Wq.cjs';
|
|
14
14
|
import { r as rawMod } from './raw-Dj_2rBSQ.cjs';
|
|
15
15
|
import { r as resourcesMod } from './resources-BKlFxjo8.cjs';
|
|
16
|
-
export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig,
|
|
16
|
+
export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, ContinuationAssertReadyConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, InvariantEqConfig, InvariantGtConfig, InvariantGteConfig, InvariantLtConfig, InvariantLteConfig, InvariantNeqConfig, InvariantNumericConfig, InvariantNumericInRangeConfig, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapConfig, MaxItems50, MaxLength64, MaxLength65536, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, NonNegative, ParaswapBuyConfig, Positive, SlippageGuardConfig, StartsWith0X } from './generated/config.generated.cjs';
|
|
17
17
|
import './client.cjs';
|
|
18
18
|
import './generated/operations.generated.cjs';
|
|
19
19
|
import './authoring/signatureArgs.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AbiTypeToOutputKind, Address, InputDecl, InputSchema, InputSpecOf, IntegerString, IntegerStringInput, OutputKind, TypedGuard, TypedRef } from './types.js';
|
|
2
2
|
export { GetZapPacksOptions, ZapPackEdge, ZapPackOverview } from './discovery.js';
|
|
3
3
|
export { ComposeError, ComposeErrorCode, isComposeError } from './errors.js';
|
|
4
|
-
export { AppliedGuard, ApprovalEntry, Call, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeTransactionRequest, Erc20AllowanceRequirement, Erc20BalanceRequirement, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, NativeBalanceRequirement, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SlotFinderRequirement, SolType, SweepTo, TrackedBalance } from '@lifi/compose-spec';
|
|
4
|
+
export { AppliedGuard, ApprovalEntry, Call, Check, CheckComparator, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeTransactionRequest, ContinuationIntent, ContinuationOutcome, ContinuationPlanWire, Erc20AllowanceRequirement, Erc20BalanceRequirement, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, NativeBalanceRequirement, Phase1ArtifactWire, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, SIMULATE_MAX_REQUIREMENTS, SIMULATE_MAX_TRACKED_BALANCES, SimulateBalanceEntry, SimulateOkResult, SimulateRequest, SimulateResult, SimulateRevertDecodeResult, SimulateRevertResult, SimulateSetupErrorResult, SimulationPolicy, SimulationRevert, SlotFinderRequirement, SolType, SweepTo, TrackedBalance } from '@lifi/compose-spec';
|
|
5
5
|
export { AnyHandle, Bindable, InputHandle, OutputHandle, ResourceInputHandle, isInputHandle, isOutputHandle } from './authoring/handles.js';
|
|
6
6
|
export { ref } from './authoring/raw.js';
|
|
7
7
|
export { AnyBindable, FlowOptions, TypedFlow } from './authoring/FlowBuilderCore.js';
|
|
@@ -13,7 +13,7 @@ import { m as materialisersMod } from './materialisers.generated-BMkBQgWZ.js';
|
|
|
13
13
|
import { p as preconditionsMod } from './preconditions.generated-U7YpVh30.js';
|
|
14
14
|
import { r as rawMod } from './raw-IxCF_bSS.js';
|
|
15
15
|
import { r as resourcesMod } from './resources-CYis1_DS.js';
|
|
16
|
-
export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig,
|
|
16
|
+
export { AaveBorrowConfig, AaveClaimRewardsConfig, AaveGetHealthFactorConfig, AaveRepayConfig, AaveRepayWithATokensConfig, AaveSetEModeConfig, BalanceOfMaterialiserConfig, Between010000, Between0255, CallMaterialiserConfig, ContinuationAssertReadyConfig, CoreApproveConfig, CoreAsResourceConfig, CoreBalanceOfConfig, CoreBpsDownConfig, CoreBpsUpConfig, CoreCallConfig, CoreEmitEvent1Config, CoreEmitEvent2Config, CoreEmitEvent3Config, CoreEmitEvent4Config, CoreInvokeConfig, CoreNumericInvariantGuardConfig, CorePeekConfig, CoreRawCallConfig, CoreSplitConfig, CoreStaticCallConfig, CoreTransferConfig, DirectDepositMaterialiserConfig, Erc20AllowancePreconditionConfig, Erc20BalancePreconditionConfig, FlashloanMaterialiserConfig, InvariantEqConfig, InvariantGtConfig, InvariantGteConfig, InvariantLtConfig, InvariantLteConfig, InvariantNeqConfig, InvariantNumericConfig, InvariantNumericInRangeConfig, LifiFlashloanRepayConfig, LifiSwapConfig, LifiZapConfig, MaxItems50, MaxLength64, MaxLength65536, MorphoBlueBorrowConfig, MorphoBlueGetPositionConfig, MorphoBlueRepayConfig, MorphoBlueSupplyCollateralConfig, MorphoBlueSupplyConfig, MorphoBlueWithdrawCollateralConfig, MorphoBlueWithdrawConfig, NativeBalancePreconditionConfig, NonNegative, ParaswapBuyConfig, Positive, SlippageGuardConfig, StartsWith0X } from './generated/config.generated.js';
|
|
17
17
|
import './client.js';
|
|
18
18
|
import './generated/operations.generated.js';
|
|
19
19
|
import './authoring/signatureArgs.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@lifi/composer-sdk` — TypeScript SDK for building and compiling\n * Compose flows into executable EVM calldata.\n *\n * Start by creating an SDK instance with {@link createComposeSdk}, then use\n * {@link ComposeSdk.flow} to build flows and compile them.\n *\n * @packageDocumentation\n */\n\nexport type {\n AbiTypeToOutputKind,\n Address,\n InputDecl,\n InputSchema,\n InputSpecOf,\n IntegerString,\n IntegerStringInput,\n OutputKind,\n TypedGuard,\n TypedRef,\n} from './types.js';\n\nexport type {\n GetZapPacksOptions,\n ZapPackEdge,\n ZapPackOverview,\n} from './discovery.js';\nexport type { ComposeError, ComposeErrorCode } from './errors.js';\nexport type {\n AppliedGuard,\n ApprovalEntry,\n Call,\n ComposeCompilePartialData,\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeCompileSuccessData,\n ComposeContinuation,\n ComposeErrorKind,\n ComposeTransactionRequest,\n Flow,\n InputSpec,\n MaterialiserConfigOf,\n MaterialiserInput,\n Precondition,\n PreconditionConfigOf,\n PriceImpact,\n Ref,\n Resource,\n SimulationPolicy,\n SimulationRevert,\n SolType,\n SweepTo,\n SimulateRequest,\n SimulateResult,\n SimulateOkResult,\n SimulateRevertResult,\n SimulateRevertDecodeResult,\n SimulateSetupErrorResult,\n SimulateBalanceEntry,\n TrackedBalance,\n SlotFinderRequirement,\n Erc20BalanceRequirement,\n NativeBalanceRequirement,\n Erc20AllowanceRequirement,\n} from '@lifi/compose-spec';\nexport {\n SIMULATE_MAX_TRACKED_BALANCES,\n SIMULATE_MAX_REQUIREMENTS,\n} from '@lifi/compose-spec';\nexport { isComposeError } from './errors.js';\n\nexport type {\n Bindable,\n InputHandle,\n ResourceInputHandle,\n OutputHandle,\n AnyHandle,\n} from './authoring/handles.js';\nexport { isInputHandle, isOutputHandle } from './authoring/handles.js';\nexport { ref } from './authoring/raw.js';\n\nexport type { AnyBindable } from './authoring/FlowBuilderCore.js';\nexport type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';\n\nexport type { ComposeRunInput } from './run/inputs.js';\nexport { materialiser } from './run/inputs.js';\n\nexport { buildSimulateRequest } from './run/simulate.js';\nexport type { BuildSimulateRequestInput } from './run/simulate.js';\n\nexport { createComposeSdk } from './sdk.js';\nexport type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';\n\nimport * as guardsMod from './generated/guards.generated.js';\nimport * as materialisersMod from './generated/materialisers.generated.js';\nimport * as preconditionsMod from './generated/preconditions.generated.js';\nimport * as rawMod from './raw.js';\nimport * as resourcesMod from './resources.js';\n\n/**\n * Guard factories for protecting operation outputs (e.g. slippage tolerance).\n * Pass guards to an operation's `guards` array.\n *\n * @example\n * ```ts\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.token },\n * config: { resourceOut: resources.native(1) },\n * guards: [guards.slippage({ port: 'amountOut', bps: 300 })],\n * });\n * ```\n */\nexport const guards: typeof guardsMod = guardsMod;\n/**\n * Materialiser factories that tell the runtime how to resolve token input\n * amounts on-chain (e.g. read a wallet balance, accept a direct deposit).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0x...',\n * });\n * ```\n */\nexport const materialisers: typeof materialisersMod = materialisersMod;\n/**\n * Precondition factories for asserting on-chain state before a flow executes\n * (e.g. minimum token balances, ERC-20 allowances).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * preconditions: [\n * preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),\n * ],\n * signer: '0x...',\n * });\n * ```\n */\nexport const preconditions: typeof preconditionsMod = preconditionsMod;\n/**\n * Resource declaration helpers for defining token inputs in a flow schema.\n * Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}\n * for the chain's native coin (ETH, MATIC, etc.).\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: {\n * usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),\n * eth: resources.native(1),\n * },\n * });\n * ```\n */\nexport const resources: typeof resourcesMod = resourcesMod;\nexport * from './generated/config.generated.js';\n\n/**\n * Low-level escape hatch for constructing flow nodes, guards, and materialiser\n * inputs without the typed builder API. Prefer the generated operation methods\n * on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces\n * for most use cases.\n */\nexport const raw: typeof rawMod = rawMod;\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * `@lifi/composer-sdk` — TypeScript SDK for building and compiling\n * Compose flows into executable EVM calldata.\n *\n * Start by creating an SDK instance with {@link createComposeSdk}, then use\n * {@link ComposeSdk.flow} to build flows and compile them.\n *\n * @packageDocumentation\n */\n\nexport type {\n AbiTypeToOutputKind,\n Address,\n InputDecl,\n InputSchema,\n InputSpecOf,\n IntegerString,\n IntegerStringInput,\n OutputKind,\n TypedGuard,\n TypedRef,\n} from './types.js';\n\nexport type {\n GetZapPacksOptions,\n ZapPackEdge,\n ZapPackOverview,\n} from './discovery.js';\nexport type { ComposeError, ComposeErrorCode } from './errors.js';\nexport type {\n AppliedGuard,\n ApprovalEntry,\n Call,\n ComposeCompilePartialData,\n ComposeCompileRequest,\n ComposeCompileResult,\n ComposeCompileSuccessData,\n ComposeContinuation,\n ComposeErrorKind,\n ComposeTransactionRequest,\n Flow,\n InputSpec,\n MaterialiserConfigOf,\n MaterialiserInput,\n Precondition,\n PreconditionConfigOf,\n PriceImpact,\n Ref,\n Resource,\n SimulationPolicy,\n SimulationRevert,\n SolType,\n SweepTo,\n SimulateRequest,\n SimulateResult,\n SimulateOkResult,\n SimulateRevertResult,\n SimulateRevertDecodeResult,\n SimulateSetupErrorResult,\n SimulateBalanceEntry,\n TrackedBalance,\n SlotFinderRequirement,\n Erc20BalanceRequirement,\n NativeBalanceRequirement,\n Erc20AllowanceRequirement,\n ContinuationIntent,\n ContinuationOutcome,\n Check,\n CheckComparator,\n Phase1ArtifactWire,\n ContinuationPlanWire,\n} from '@lifi/compose-spec';\nexport {\n SIMULATE_MAX_TRACKED_BALANCES,\n SIMULATE_MAX_REQUIREMENTS,\n} from '@lifi/compose-spec';\nexport { isComposeError } from './errors.js';\n\nexport type {\n Bindable,\n InputHandle,\n ResourceInputHandle,\n OutputHandle,\n AnyHandle,\n} from './authoring/handles.js';\nexport { isInputHandle, isOutputHandle } from './authoring/handles.js';\nexport { ref } from './authoring/raw.js';\n\nexport type { AnyBindable } from './authoring/FlowBuilderCore.js';\nexport type { TypedFlow, FlowOptions } from './authoring/FlowBuilderCore.js';\n\nexport type { ComposeRunInput } from './run/inputs.js';\nexport { materialiser } from './run/inputs.js';\n\nexport { buildSimulateRequest } from './run/simulate.js';\nexport type { BuildSimulateRequestInput } from './run/simulate.js';\n\nexport { createComposeSdk } from './sdk.js';\nexport type { ComposeSdk, ComposeSdkOptions, FlowBuilder } from './sdk.js';\n\nimport * as guardsMod from './generated/guards.generated.js';\nimport * as materialisersMod from './generated/materialisers.generated.js';\nimport * as preconditionsMod from './generated/preconditions.generated.js';\nimport * as rawMod from './raw.js';\nimport * as resourcesMod from './resources.js';\n\n/**\n * Guard factories for protecting operation outputs (e.g. slippage tolerance).\n * Pass guards to an operation's `guards` array.\n *\n * @example\n * ```ts\n * builder.lifi.swap('swap1', {\n * bind: { amountIn: builder.inputs.token },\n * config: { resourceOut: resources.native(1) },\n * guards: [guards.slippage({ port: 'amountOut', bps: 300 })],\n * });\n * ```\n */\nexport const guards: typeof guardsMod = guardsMod;\n/**\n * Materialiser factories that tell the runtime how to resolve token input\n * amounts on-chain (e.g. read a wallet balance, accept a direct deposit).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * signer: '0x...',\n * });\n * ```\n */\nexport const materialisers: typeof materialisersMod = materialisersMod;\n/**\n * Precondition factories for asserting on-chain state before a flow executes\n * (e.g. minimum token balances, ERC-20 allowances).\n *\n * @example\n * ```ts\n * await builder.compile({\n * inputs: { token: materialisers.balanceOf({}) },\n * preconditions: [\n * preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),\n * ],\n * signer: '0x...',\n * });\n * ```\n */\nexport const preconditions: typeof preconditionsMod = preconditionsMod;\n/**\n * Resource declaration helpers for defining token inputs in a flow schema.\n * Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}\n * for the chain's native coin (ETH, MATIC, etc.).\n *\n * @example\n * ```ts\n * const builder = sdk.flow(1, {\n * inputs: {\n * usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),\n * eth: resources.native(1),\n * },\n * });\n * ```\n */\nexport const resources: typeof resourcesMod = resourcesMod;\nexport * from './generated/config.generated.js';\n\n/**\n * Low-level escape hatch for constructing flow nodes, guards, and materialiser\n * inputs without the typed builder API. Prefer the generated operation methods\n * on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces\n * for most use cases.\n */\nexport const raw: typeof rawMod = rawMod;\n"],"mappings":"AAwEA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAS/B,SAAS,eAAe,sBAAsB;AAC9C,SAAS,WAAW;AAMpB,SAAS,oBAAoB;AAE7B,SAAS,4BAA4B;AAGrC,SAAS,wBAAwB;AAGjC,YAAY,eAAe;AAC3B,YAAY,sBAAsB;AAClC,YAAY,sBAAsB;AAClC,YAAY,YAAY;AACxB,YAAY,kBAAkB;AAevB,MAAM,SAA2B;AAajC,MAAM,gBAAyC;AAgB/C,MAAM,gBAAyC;AAgB/C,MAAM,YAAiC;AAC9C,cAAc;AAQP,MAAM,MAAqB;","names":[]}
|
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 SimulateRequest,\n SimulateResult,\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 /**
|
|
1
|
+
{"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["import type {\n ComposeCompileRequest,\n ComposeCompileResult,\n InputSpec,\n SimulateRequest,\n SimulateResult,\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 /** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */\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', apiKey: 'YOUR_API_KEY' });\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 * Simulates a raw, pre-encoded transaction. Thin pass-through to\n * {@link ComposeClient.simulate}; see it for the `ok` / `revert` / `error`\n * result discrimination and error behaviour. Pair with `buildSimulateRequest`\n * to assemble the request from a compile result.\n *\n * @param request - The raw transaction plus funding `requirements` and\n * `trackedBalances`.\n * @returns A {@link SimulateResult} (`ok` / `revert` / `error`).\n * @throws {@link ComposeError} on network, validation, or server errors.\n */\n readonly simulate: (request: SimulateRequest) => Promise<SimulateResult>;\n}\n\n/**\n * Creates a new Compose SDK instance.\n *\n * @param options - SDK configuration including the API base URL, required API key, and optional fetch implementation.\n * @returns A {@link ComposeSdk} instance.\n *\n * @example\n * ```ts\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });\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 {\n client: composeClient,\n flow,\n request,\n simulate: composeClient.simulate,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,6BAKO;AACP,oBAAwD;AACxD,kCAGO;AACP,oBAA+C;AA+HxC,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;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,UAAU,cAAc;AAAA,EAC1B;AACF;","names":[]}
|
package/dist/sdk.d.cts
CHANGED
|
@@ -46,8 +46,8 @@ interface ComposeSdkOptions {
|
|
|
46
46
|
readonly baseUrl: string;
|
|
47
47
|
/** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */
|
|
48
48
|
readonly fetch?: typeof globalThis.fetch;
|
|
49
|
-
/**
|
|
50
|
-
readonly apiKey
|
|
49
|
+
/** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */
|
|
50
|
+
readonly apiKey: string;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* The top-level Compose SDK interface.
|
|
@@ -59,7 +59,7 @@ interface ComposeSdkOptions {
|
|
|
59
59
|
* ```ts
|
|
60
60
|
* import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';
|
|
61
61
|
*
|
|
62
|
-
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });
|
|
62
|
+
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });
|
|
63
63
|
*
|
|
64
64
|
* const builder = sdk.flow(1, {
|
|
65
65
|
* inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },
|
|
@@ -111,12 +111,12 @@ interface ComposeSdk {
|
|
|
111
111
|
/**
|
|
112
112
|
* Creates a new Compose SDK instance.
|
|
113
113
|
*
|
|
114
|
-
* @param options - SDK configuration including the API base URL and optional fetch implementation.
|
|
114
|
+
* @param options - SDK configuration including the API base URL, required API key, and optional fetch implementation.
|
|
115
115
|
* @returns A {@link ComposeSdk} instance.
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
118
118
|
* ```ts
|
|
119
|
-
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });
|
|
119
|
+
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });
|
|
120
120
|
* ```
|
|
121
121
|
*/
|
|
122
122
|
declare const createComposeSdk: (options: ComposeSdkOptions) => ComposeSdk;
|
package/dist/sdk.d.ts
CHANGED
|
@@ -46,8 +46,8 @@ interface ComposeSdkOptions {
|
|
|
46
46
|
readonly baseUrl: string;
|
|
47
47
|
/** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */
|
|
48
48
|
readonly fetch?: typeof globalThis.fetch;
|
|
49
|
-
/**
|
|
50
|
-
readonly apiKey
|
|
49
|
+
/** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */
|
|
50
|
+
readonly apiKey: string;
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
53
|
* The top-level Compose SDK interface.
|
|
@@ -59,7 +59,7 @@ interface ComposeSdkOptions {
|
|
|
59
59
|
* ```ts
|
|
60
60
|
* import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';
|
|
61
61
|
*
|
|
62
|
-
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });
|
|
62
|
+
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });
|
|
63
63
|
*
|
|
64
64
|
* const builder = sdk.flow(1, {
|
|
65
65
|
* inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },
|
|
@@ -111,12 +111,12 @@ interface ComposeSdk {
|
|
|
111
111
|
/**
|
|
112
112
|
* Creates a new Compose SDK instance.
|
|
113
113
|
*
|
|
114
|
-
* @param options - SDK configuration including the API base URL and optional fetch implementation.
|
|
114
|
+
* @param options - SDK configuration including the API base URL, required API key, and optional fetch implementation.
|
|
115
115
|
* @returns A {@link ComposeSdk} instance.
|
|
116
116
|
*
|
|
117
117
|
* @example
|
|
118
118
|
* ```ts
|
|
119
|
-
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });
|
|
119
|
+
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });
|
|
120
120
|
* ```
|
|
121
121
|
*/
|
|
122
122
|
declare const createComposeSdk: (options: ComposeSdkOptions) => ComposeSdk;
|
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 SimulateRequest,\n SimulateResult,\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 /**
|
|
1
|
+
{"version":3,"sources":["../src/sdk.ts"],"sourcesContent":["import type {\n ComposeCompileRequest,\n ComposeCompileResult,\n InputSpec,\n SimulateRequest,\n SimulateResult,\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 /** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */\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', apiKey: 'YOUR_API_KEY' });\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 * Simulates a raw, pre-encoded transaction. Thin pass-through to\n * {@link ComposeClient.simulate}; see it for the `ok` / `revert` / `error`\n * result discrimination and error behaviour. Pair with `buildSimulateRequest`\n * to assemble the request from a compile result.\n *\n * @param request - The raw transaction plus funding `requirements` and\n * `trackedBalances`.\n * @returns A {@link SimulateResult} (`ok` / `revert` / `error`).\n * @throws {@link ComposeError} on network, validation, or server errors.\n */\n readonly simulate: (request: SimulateRequest) => Promise<SimulateResult>;\n}\n\n/**\n * Creates a new Compose SDK instance.\n *\n * @param options - SDK configuration including the API base URL, required API key, and optional fetch implementation.\n * @returns A {@link ComposeSdk} instance.\n *\n * @example\n * ```ts\n * const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });\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 {\n client: composeClient,\n flow,\n request,\n simulate: composeClient.simulate,\n };\n};\n"],"mappings":"AAQA;AAAA,EACE;AAAA,OAIK;AACP,SAA6B,2BAA2B;AACxD;AAAA,EACE;AAAA,OAEK;AACP,SAAS,gBAAsC;AA+HxC,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;AAAA,IACL,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA,UAAU,cAAc;AAAA,EAC1B;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/composer-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Public Composer SDK for building and submitting flows",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"example:staged": "tsx src/examples/run.ts --staged"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@lifi/compose-spec": "0.
|
|
54
|
+
"@lifi/compose-spec": "0.3.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"abitype": "^1.2.3",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"eslint-plugin-require-extensions": "^0.1.3",
|
|
72
72
|
"json-schema-to-typescript": "^15.0.4",
|
|
73
73
|
"npm-run-all": "^4.1.5",
|
|
74
|
-
"prettier": "^3.
|
|
74
|
+
"prettier": "^3.9.4",
|
|
75
75
|
"tsup": "^8.5.1",
|
|
76
76
|
"tsx": "^4.20.4",
|
|
77
77
|
"typescript": "^5.9.2",
|
package/src/client.ts
CHANGED
|
@@ -33,8 +33,8 @@ export interface ComposeClientOptions {
|
|
|
33
33
|
readonly baseUrl: string;
|
|
34
34
|
/** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */
|
|
35
35
|
readonly fetch?: typeof globalThis.fetch;
|
|
36
|
-
/**
|
|
37
|
-
readonly apiKey
|
|
36
|
+
/** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */
|
|
37
|
+
readonly apiKey: string;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
@@ -189,15 +189,20 @@ export const createComposeClient = (
|
|
|
189
189
|
`Invalid baseUrl: expected an HTTP(S) URL, got "${options.baseUrl}"`,
|
|
190
190
|
);
|
|
191
191
|
}
|
|
192
|
+
const trimmedApiKey = options.apiKey?.trim() || undefined;
|
|
193
|
+
if (!trimmedApiKey) {
|
|
194
|
+
throw new ComposeError(
|
|
195
|
+
'VALIDATION_ERROR',
|
|
196
|
+
'apiKey is required: pass a LI.FI API key to createComposeSdk().',
|
|
197
|
+
);
|
|
198
|
+
}
|
|
192
199
|
const fetchFn = options.fetch ?? globalThis.fetch;
|
|
193
200
|
const base = options.baseUrl.replace(/\/$/, '');
|
|
194
201
|
|
|
195
|
-
const trimmedApiKey = options.apiKey?.trim() || undefined;
|
|
196
|
-
|
|
197
202
|
const baseHeaders: Record<string, string> = {
|
|
198
203
|
Accept: 'application/json',
|
|
199
204
|
'x-lifi-composer-sdk': SDK_VERSION,
|
|
200
|
-
|
|
205
|
+
'x-lifi-api-key': trimmedApiKey,
|
|
201
206
|
};
|
|
202
207
|
|
|
203
208
|
const getManifest = async (): Promise<ComposeManifest> => {
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Aave v3 incentives contracts on Ethereum mainnet.
|
|
9
9
|
const REWARDS_CONTROLLER = '0x8164Cc65827dcFe994AB23944CBC90e0aa80bFcb';
|
|
@@ -37,7 +37,7 @@ export const buildAaveClaimRewards = ({
|
|
|
37
37
|
flow: Flow;
|
|
38
38
|
request: ComposeCompileRequest;
|
|
39
39
|
} => {
|
|
40
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
40
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
41
41
|
|
|
42
42
|
const builder = sdk.flow(1, {
|
|
43
43
|
name: 'aave-claim-rewards',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Aave v3 contracts on Ethereum mainnet.
|
|
9
9
|
const AAVE_V3_POOL = '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2';
|
|
@@ -49,7 +49,7 @@ export const buildAaveRepay = ({
|
|
|
49
49
|
flow: Flow;
|
|
50
50
|
request: ComposeCompileRequest;
|
|
51
51
|
} => {
|
|
52
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
52
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
53
53
|
|
|
54
54
|
const builder = sdk.flow(1, {
|
|
55
55
|
name: 'aave-repay-weth',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Aave v3 contracts on Ethereum mainnet.
|
|
9
9
|
const AAVE_V3_POOL = '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2';
|
|
@@ -39,7 +39,7 @@ export const buildAaveRepayWithATokens = ({
|
|
|
39
39
|
flow: Flow;
|
|
40
40
|
request: ComposeCompileRequest;
|
|
41
41
|
} => {
|
|
42
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
42
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
43
43
|
|
|
44
44
|
const builder = sdk.flow(1, {
|
|
45
45
|
name: 'aave-repay-with-atokens',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Aave v3 contracts on Ethereum mainnet.
|
|
9
9
|
const AAVE_V3_POOL = '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2';
|
|
@@ -41,7 +41,7 @@ export const buildAaveSetEMode = ({
|
|
|
41
41
|
flow: Flow;
|
|
42
42
|
request: ComposeCompileRequest;
|
|
43
43
|
} => {
|
|
44
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
44
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
45
45
|
|
|
46
46
|
const builder = sdk.flow(1, {
|
|
47
47
|
name: 'aave-set-emode',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
9
9
|
// Example ERC-4626 vault address (Steakhouse USDC on Ethereum mainnet)
|
|
@@ -30,7 +30,7 @@ export const buildApproveAndDeposit = ({
|
|
|
30
30
|
flow: Flow;
|
|
31
31
|
request: ComposeCompileRequest;
|
|
32
32
|
} => {
|
|
33
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
33
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
34
34
|
|
|
35
35
|
const builder = sdk.flow(1, {
|
|
36
36
|
name: 'approve-and-deposit',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Example ERC-4626 vault address (Steakhouse USDC on Ethereum mainnet)
|
|
9
9
|
const VAULT = '0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB';
|
|
@@ -31,7 +31,7 @@ export const buildRedeemFromVault = ({
|
|
|
31
31
|
flow: Flow;
|
|
32
32
|
request: ComposeCompileRequest;
|
|
33
33
|
} => {
|
|
34
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
34
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
35
35
|
|
|
36
36
|
const builder = sdk.flow(1, {
|
|
37
37
|
name: 'redeem-from-vault',
|
|
@@ -103,7 +103,7 @@ export const buildClaimRewards = ({
|
|
|
103
103
|
const REWARDS_CONTRACT = '0x1111111111111111111111111111111111111111';
|
|
104
104
|
const REWARD_TOKEN = '0x2222222222222222222222222222222222222222';
|
|
105
105
|
|
|
106
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
106
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
107
107
|
|
|
108
108
|
const builder = sdk.flow(1, {
|
|
109
109
|
name: 'claim-rewards',
|
|
@@ -154,7 +154,7 @@ export const buildWrapEth = ({
|
|
|
154
154
|
flow: Flow;
|
|
155
155
|
request: ComposeCompileRequest;
|
|
156
156
|
} => {
|
|
157
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
157
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
158
158
|
|
|
159
159
|
const builder = sdk.flow(1, {
|
|
160
160
|
name: 'wrap-eth',
|
package/src/examples/config.ts
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
// built-in process.env.BASE_URL (set to "/" from the `base` config option).
|
|
3
3
|
export const BASE_URL: string =
|
|
4
4
|
process.env['COMPOSER_BASE_URL'] ?? 'https://composer.li.quest';
|
|
5
|
-
|
|
5
|
+
// `apiKey` is required by `createComposeSdk`/`createComposeClient`; fall back to a
|
|
6
|
+
// placeholder so the examples remain runnable (against a backend that accepts it)
|
|
7
|
+
// without every contributor needing a real LI.FI API key set locally.
|
|
8
|
+
export const API_KEY: string = process.env['LIFI_API_KEY'] ?? 'YOUR_API_KEY';
|
|
6
9
|
|
|
7
10
|
export const OWNER = '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045';
|
|
8
11
|
export const RECIPIENT = '0x1234567890abcdef1234567890abcdef12345678';
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
export interface ConsolidateToEthInput {
|
|
9
9
|
readonly owner: Address;
|
|
@@ -38,7 +38,7 @@ export const buildConsolidateToEth = ({
|
|
|
38
38
|
flow: Flow;
|
|
39
39
|
request: ComposeCompileRequest;
|
|
40
40
|
} => {
|
|
41
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
41
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
42
42
|
const erc20 = (token: Address) => resources.erc20(token, CHAIN_ID);
|
|
43
43
|
|
|
44
44
|
// Declare the flow with one input per ERC-20 token on Ethereum mainnet.
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
export interface ConsolidateStablesToUsdcInput {
|
|
9
9
|
readonly owner: Address;
|
|
@@ -39,7 +39,7 @@ export const buildConsolidateStablesToUsdc = ({
|
|
|
39
39
|
flow: Flow;
|
|
40
40
|
request: ComposeCompileRequest;
|
|
41
41
|
} => {
|
|
42
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
42
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
43
43
|
const erc20 = (token: Address) => resources.erc20(token, CHAIN_ID);
|
|
44
44
|
|
|
45
45
|
// Declare the flow with one input per stablecoin on Ethereum mainnet.
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
} from '../index.js';
|
|
10
10
|
import type { Address } from '../types.js';
|
|
11
11
|
|
|
12
|
-
import { BASE_URL } from './config.js';
|
|
12
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
13
13
|
|
|
14
14
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
15
15
|
// Aave v3 aEthUSDC receipt token on Ethereum mainnet
|
|
@@ -45,7 +45,7 @@ export const buildDepositFromProxy = ({
|
|
|
45
45
|
flow: Flow;
|
|
46
46
|
request: ComposeCompileRequest;
|
|
47
47
|
} => {
|
|
48
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
48
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
49
49
|
|
|
50
50
|
const builder = sdk.flow(1, {
|
|
51
51
|
name: 'deposit-from-proxy',
|
|
@@ -2,7 +2,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
2
2
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
|
|
5
|
-
import { BASE_URL, OWNER } from './config.js';
|
|
5
|
+
import { API_KEY, BASE_URL, OWNER } from './config.js';
|
|
6
6
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
7
7
|
const USDT = '0xdAC17F958D2ee523a2206206994597C13D831ec7';
|
|
8
8
|
|
|
@@ -23,7 +23,7 @@ export const buildDustSweepExample = (): {
|
|
|
23
23
|
flow: Flow;
|
|
24
24
|
request: ComposeCompileRequest;
|
|
25
25
|
} => {
|
|
26
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
26
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
27
27
|
|
|
28
28
|
const builder = sdk.flow(1, {
|
|
29
29
|
name: 'dust-sweep',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Example ERC-4626 vault address (Steakhouse USDC on Ethereum mainnet)
|
|
9
9
|
const VAULT = '0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB';
|
|
@@ -33,7 +33,7 @@ export const buildEmitCustomEvent = ({
|
|
|
33
33
|
flow: Flow;
|
|
34
34
|
request: ComposeCompileRequest;
|
|
35
35
|
} => {
|
|
36
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
36
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
37
37
|
|
|
38
38
|
const builder = sdk.flow(1, {
|
|
39
39
|
name: 'emit-custom-event',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
9
9
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
@@ -41,7 +41,7 @@ export const buildInvariantChecks = ({
|
|
|
41
41
|
flow: Flow;
|
|
42
42
|
request: ComposeCompileRequest;
|
|
43
43
|
} => {
|
|
44
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
44
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
45
45
|
|
|
46
46
|
// One WETH resource input plus a scalar spender address.
|
|
47
47
|
const builder = sdk.flow(1, {
|
package/src/examples/lifiSwap.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
2
2
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
|
|
5
|
-
import { BASE_URL, OWNER } from './config.js';
|
|
5
|
+
import { API_KEY, BASE_URL, OWNER } from './config.js';
|
|
6
6
|
|
|
7
7
|
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
8
8
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
@@ -19,7 +19,7 @@ export const buildLifiSwapExample = (): {
|
|
|
19
19
|
flow: Flow;
|
|
20
20
|
request: ComposeCompileRequest;
|
|
21
21
|
} => {
|
|
22
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
22
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
23
23
|
|
|
24
24
|
// Declare the flow with a single WETH input on Ethereum mainnet.
|
|
25
25
|
const builder = sdk.flow(1, {
|
package/src/examples/lifiZap.ts
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
resources,
|
|
8
8
|
} from '../index.js';
|
|
9
9
|
|
|
10
|
-
import { BASE_URL, OWNER } from './config.js';
|
|
10
|
+
import { API_KEY, BASE_URL, OWNER } from './config.js';
|
|
11
11
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
12
12
|
// Aave aEthUSDC receipt token on Ethereum mainnet
|
|
13
13
|
const A_ETH_USDC = '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c';
|
|
@@ -24,7 +24,7 @@ export const buildLifiZapExample = (): {
|
|
|
24
24
|
flow: Flow;
|
|
25
25
|
request: ComposeCompileRequest;
|
|
26
26
|
} => {
|
|
27
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
27
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
28
28
|
|
|
29
29
|
// Declare the flow with a single USDC input on Ethereum mainnet.
|
|
30
30
|
const builder = sdk.flow(1, {
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Example contract address for a non-standard oracle
|
|
9
9
|
const ORACLE = '0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419';
|
|
@@ -27,7 +27,7 @@ export const buildRawCallWithArithmetic = ({
|
|
|
27
27
|
flow: Flow;
|
|
28
28
|
request: ComposeCompileRequest;
|
|
29
29
|
} => {
|
|
30
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
30
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
31
31
|
|
|
32
32
|
const builder = sdk.flow(1, {
|
|
33
33
|
name: 'raw-call-with-arithmetic',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
9
9
|
// Example ERC-4626 vault address (Steakhouse USDC on Ethereum mainnet)
|
|
@@ -28,7 +28,7 @@ export const buildReadContractState = ({
|
|
|
28
28
|
flow: Flow;
|
|
29
29
|
request: ComposeCompileRequest;
|
|
30
30
|
} => {
|
|
31
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
31
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
32
32
|
|
|
33
33
|
const builder = sdk.flow(1, {
|
|
34
34
|
name: 'read-contract-state',
|