@lifi/composer-sdk 0.0.1-alpha
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/LICENSE +201 -0
- package/README.md +220 -0
- package/dist/authoring/FlowBuilderCore.cjs +115 -0
- package/dist/authoring/FlowBuilderCore.cjs.map +1 -0
- package/dist/authoring/FlowBuilderCore.d.cts +114 -0
- package/dist/authoring/FlowBuilderCore.d.ts +114 -0
- package/dist/authoring/FlowBuilderCore.js +91 -0
- package/dist/authoring/FlowBuilderCore.js.map +1 -0
- package/dist/authoring/handles.cjs +43 -0
- package/dist/authoring/handles.cjs.map +1 -0
- package/dist/authoring/handles.d.cts +61 -0
- package/dist/authoring/handles.d.ts +61 -0
- package/dist/authoring/handles.js +17 -0
- package/dist/authoring/handles.js.map +1 -0
- package/dist/authoring/raw.cjs +41 -0
- package/dist/authoring/raw.cjs.map +1 -0
- package/dist/authoring/raw.d.cts +47 -0
- package/dist/authoring/raw.d.ts +47 -0
- package/dist/authoring/raw.js +16 -0
- package/dist/authoring/raw.js.map +1 -0
- package/dist/authoring/signatureArgs.cjs +114 -0
- package/dist/authoring/signatureArgs.cjs.map +1 -0
- package/dist/authoring/signatureArgs.d.cts +146 -0
- package/dist/authoring/signatureArgs.d.ts +146 -0
- package/dist/authoring/signatureArgs.js +87 -0
- package/dist/authoring/signatureArgs.js.map +1 -0
- package/dist/client.cjs +140 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +67 -0
- package/dist/client.d.ts +67 -0
- package/dist/client.js +116 -0
- package/dist/client.js.map +1 -0
- package/dist/discovery.cjs +17 -0
- package/dist/discovery.cjs.map +1 -0
- package/dist/discovery.d.cts +56 -0
- package/dist/discovery.d.ts +56 -0
- package/dist/discovery.js +1 -0
- package/dist/discovery.js.map +1 -0
- package/dist/errors.cjs +91 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.cts +77 -0
- package/dist/errors.d.ts +77 -0
- package/dist/errors.js +65 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/config.generated.cjs +17 -0
- package/dist/generated/config.generated.cjs.map +1 -0
- package/dist/generated/config.generated.d.cts +144 -0
- package/dist/generated/config.generated.d.ts +144 -0
- package/dist/generated/config.generated.js +1 -0
- package/dist/generated/config.generated.js.map +1 -0
- package/dist/generated/guards.generated.cjs +32 -0
- package/dist/generated/guards.generated.cjs.map +1 -0
- package/dist/generated/guards.generated.d.cts +4 -0
- package/dist/generated/guards.generated.d.ts +4 -0
- package/dist/generated/guards.generated.js +8 -0
- package/dist/generated/guards.generated.js.map +1 -0
- package/dist/generated/materialisers.generated.cjs +44 -0
- package/dist/generated/materialisers.generated.cjs.map +1 -0
- package/dist/generated/materialisers.generated.d.cts +4 -0
- package/dist/generated/materialisers.generated.d.ts +4 -0
- package/dist/generated/materialisers.generated.js +18 -0
- package/dist/generated/materialisers.generated.js.map +1 -0
- package/dist/generated/operations.generated.cjs +110 -0
- package/dist/generated/operations.generated.cjs.map +1 -0
- package/dist/generated/operations.generated.d.cts +337 -0
- package/dist/generated/operations.generated.d.ts +337 -0
- package/dist/generated/operations.generated.js +89 -0
- package/dist/generated/operations.generated.js.map +1 -0
- package/dist/generated/preconditions.generated.cjs +44 -0
- package/dist/generated/preconditions.generated.cjs.map +1 -0
- package/dist/generated/preconditions.generated.d.cts +4 -0
- package/dist/generated/preconditions.generated.d.ts +4 -0
- package/dist/generated/preconditions.generated.js +18 -0
- package/dist/generated/preconditions.generated.js.map +1 -0
- package/dist/guards.generated-DKKDKREA.d.ts +14 -0
- package/dist/guards.generated-hrQ1KPNv.d.cts +14 -0
- package/dist/index.cjs +76 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +99 -0
- package/dist/index.d.ts +99 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/materialisers.generated-BsA1uDW8.d.ts +24 -0
- package/dist/materialisers.generated-nMxTAaVi.d.cts +24 -0
- package/dist/preconditions.generated-DblS13Wq.d.cts +24 -0
- package/dist/preconditions.generated-U7YpVh30.d.ts +24 -0
- package/dist/raw-Dj_2rBSQ.d.cts +19 -0
- package/dist/raw-IxCF_bSS.d.ts +19 -0
- package/dist/raw.cjs +34 -0
- package/dist/raw.cjs.map +1 -0
- package/dist/raw.d.cts +4 -0
- package/dist/raw.d.ts +4 -0
- package/dist/raw.js +8 -0
- package/dist/raw.js.map +1 -0
- package/dist/resources-BKlFxjo8.d.cts +56 -0
- package/dist/resources-CYis1_DS.d.ts +56 -0
- package/dist/resources.cjs +39 -0
- package/dist/resources.cjs.map +1 -0
- package/dist/resources.d.cts +3 -0
- package/dist/resources.d.ts +3 -0
- package/dist/resources.js +14 -0
- package/dist/resources.js.map +1 -0
- package/dist/run/inputs.cjs +51 -0
- package/dist/run/inputs.cjs.map +1 -0
- package/dist/run/inputs.d.cts +91 -0
- package/dist/run/inputs.d.ts +91 -0
- package/dist/run/inputs.js +26 -0
- package/dist/run/inputs.js.map +1 -0
- package/dist/sdk.cjs +60 -0
- package/dist/sdk.cjs.map +1 -0
- package/dist/sdk.d.cts +112 -0
- package/dist/sdk.d.ts +112 -0
- package/dist/sdk.js +40 -0
- package/dist/sdk.js.map +1 -0
- package/dist/types.cjs +17 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +74 -0
- package/dist/types.d.ts +74 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/package.json +81 -0
- package/src/authoring/FlowBuilderCore.ts +270 -0
- package/src/authoring/handles.ts +81 -0
- package/src/authoring/raw.ts +60 -0
- package/src/authoring/signatureArgs.ts +249 -0
- package/src/client.ts +230 -0
- package/src/discovery.ts +51 -0
- package/src/errors.ts +150 -0
- package/src/examples/approveAndDeposit.ts +84 -0
- package/src/examples/callContract.ts +199 -0
- package/src/examples/config.ts +9 -0
- package/src/examples/consolidateToEth.ts +94 -0
- package/src/examples/consolidateToUsdc.ts +95 -0
- package/src/examples/depositFromProxy.ts +87 -0
- package/src/examples/dustSweep.ts +66 -0
- package/src/examples/lifiSwap.ts +56 -0
- package/src/examples/lifiZap.ts +60 -0
- package/src/examples/rawCallWithArithmetic.ts +78 -0
- package/src/examples/readContractState.ts +77 -0
- package/src/examples/run.ts +168 -0
- package/src/examples/splitAndZap.ts +73 -0
- package/src/examples/splitWithArithmetic.ts +93 -0
- package/src/examples/swapAndZap.ts +72 -0
- package/src/examples/swapToRecipient.ts +109 -0
- package/src/examples/swapWithAllowRevert.ts +119 -0
- package/src/examples/swapWithBalanceCheck.ts +73 -0
- package/src/examples/swapWithOutputValidation.ts +125 -0
- package/src/examples/transferTokens.ts +123 -0
- package/src/examples/untypedOpWithTypedRef.ts +77 -0
- package/src/generated/config.generated.ts +174 -0
- package/src/generated/guards.generated.ts +14 -0
- package/src/generated/materialisers.generated.ts +44 -0
- package/src/generated/operations.generated.ts +568 -0
- package/src/generated/preconditions.generated.ts +43 -0
- package/src/index.ts +149 -0
- package/src/raw.ts +10 -0
- package/src/resources.ts +61 -0
- package/src/run/inputs.ts +117 -0
- package/src/sdk.ts +173 -0
- package/src/types.ts +101 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildCallWireFormat,
|
|
3
|
+
buildStaticCallWireFormat
|
|
4
|
+
} from "../authoring/signatureArgs.js";
|
|
5
|
+
const bindGeneratedOps = (builder) => ({
|
|
6
|
+
core: {
|
|
7
|
+
split: (nodeId, args) => builder.call(nodeId, "core.split", args, {
|
|
8
|
+
a: "resource",
|
|
9
|
+
b: "resource"
|
|
10
|
+
}),
|
|
11
|
+
merge: (nodeId, args) => builder.call(nodeId, "core.merge", args, { merged: "resource" }),
|
|
12
|
+
add: (nodeId, args) => builder.call(nodeId, "core.add", args, { result: "uint256" }),
|
|
13
|
+
subtract: (nodeId, args) => builder.call(nodeId, "core.subtract", args, {
|
|
14
|
+
result: "uint256"
|
|
15
|
+
}),
|
|
16
|
+
multiply: (nodeId, args) => builder.call(nodeId, "core.multiply", args, {
|
|
17
|
+
result: "uint256"
|
|
18
|
+
}),
|
|
19
|
+
divideDown: (nodeId, args) => builder.call(nodeId, "core.divideDown", args, {
|
|
20
|
+
result: "uint256"
|
|
21
|
+
}),
|
|
22
|
+
divideUp: (nodeId, args) => builder.call(nodeId, "core.divideUp", args, {
|
|
23
|
+
result: "uint256"
|
|
24
|
+
}),
|
|
25
|
+
bpsDown: (nodeId, args) => builder.call(nodeId, "core.bpsDown", args, {
|
|
26
|
+
result: "uint256"
|
|
27
|
+
}),
|
|
28
|
+
bpsUp: (nodeId, args) => builder.call(nodeId, "core.bpsUp", args, { result: "uint256" }),
|
|
29
|
+
assertEqual: (nodeId, args) => builder.call(nodeId, "core.assertEqual", args, {}),
|
|
30
|
+
assertNotEqual: (nodeId, args) => builder.call(nodeId, "core.assertNotEqual", args, {}),
|
|
31
|
+
assertGt: (nodeId, args) => builder.call(nodeId, "core.assertGt", args, {}),
|
|
32
|
+
assertGte: (nodeId, args) => builder.call(nodeId, "core.assertGte", args, {}),
|
|
33
|
+
assertLt: (nodeId, args) => builder.call(nodeId, "core.assertLt", args, {}),
|
|
34
|
+
assertLte: (nodeId, args) => builder.call(nodeId, "core.assertLte", args, {}),
|
|
35
|
+
assertInRange: (nodeId, args) => builder.call(nodeId, "core.assertInRange", args, {}),
|
|
36
|
+
approve: (nodeId, args) => builder.call(nodeId, "core.approve", args, {}),
|
|
37
|
+
balanceOf: (nodeId, args) => builder.call(nodeId, "core.balanceOf", args, {
|
|
38
|
+
balance: "resource"
|
|
39
|
+
}),
|
|
40
|
+
transfer: (nodeId, args) => builder.call(nodeId, "core.transfer", args, {
|
|
41
|
+
transferred: "resource",
|
|
42
|
+
remainder: "resource"
|
|
43
|
+
}),
|
|
44
|
+
call: (nodeId, args) => {
|
|
45
|
+
const wire = buildCallWireFormat({
|
|
46
|
+
resource: args.resource,
|
|
47
|
+
bind: args.bind,
|
|
48
|
+
config: args.config,
|
|
49
|
+
guards: args.guards
|
|
50
|
+
});
|
|
51
|
+
return builder.call(nodeId, wire.op, wire, {
|
|
52
|
+
result: "uint256"
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
staticCall: (nodeId, args) => builder.call(
|
|
56
|
+
nodeId,
|
|
57
|
+
"core.staticCall",
|
|
58
|
+
buildStaticCallWireFormat({
|
|
59
|
+
bind: args.bind,
|
|
60
|
+
config: args.config,
|
|
61
|
+
guards: args.guards
|
|
62
|
+
}),
|
|
63
|
+
{ result: "uint256" }
|
|
64
|
+
),
|
|
65
|
+
rawCall: (nodeId, args) => builder.call(nodeId, "core.rawCall", args, {
|
|
66
|
+
result: "uint256"
|
|
67
|
+
}),
|
|
68
|
+
asResource: (nodeId, args) => builder.call(nodeId, "core.asResource", args, {
|
|
69
|
+
resource: "resource"
|
|
70
|
+
}),
|
|
71
|
+
peek: (nodeId, args) => builder.call(nodeId, "core.peek", args, { result: "uint256" })
|
|
72
|
+
},
|
|
73
|
+
lifi: {
|
|
74
|
+
swap: (nodeId, args) => builder.call(nodeId, "lifi.swap", args, {
|
|
75
|
+
amountOut: "resource",
|
|
76
|
+
unspentIn: "resource"
|
|
77
|
+
}),
|
|
78
|
+
zap: (nodeId, args) => builder.call(nodeId, "lifi.zap", args, {
|
|
79
|
+
amountOut: "resource"
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
invariant: {
|
|
83
|
+
balanceAtLeast: (nodeId, args) => builder.call(nodeId, "invariant.balanceAtLeast", args, {})
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
export {
|
|
87
|
+
bindGeneratedOps
|
|
88
|
+
};
|
|
89
|
+
//# sourceMappingURL=operations.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/generated/operations.generated.ts"],"sourcesContent":["// AUTO-GENERATED from manifest.json — do not edit by hand.\n// Regenerate with: yarn workspace @lifi/composer-sdk generate\n\nimport type {\n AnyBindable,\n FlowBuilderInternal,\n} from '../authoring/FlowBuilderCore.js';\nimport type { Bindable, OutputHandle } from '../authoring/handles.js';\nimport type {\n CoreCallResult,\n SignatureBind,\n StaticCallResult,\n} from '../authoring/signatureArgs.js';\nimport {\n buildCallWireFormat,\n buildStaticCallWireFormat,\n} from '../authoring/signatureArgs.js';\nimport type { TypedGuard } from '../types.js';\n\nimport type {\n CoreApproveConfig,\n CoreAsResourceConfig,\n CoreBalanceOfConfig,\n CoreBpsDownConfig,\n CoreBpsUpConfig,\n CoreCallConfig,\n CorePeekConfig,\n CoreRawCallConfig,\n CoreSplitConfig,\n CoreStaticCallConfig,\n CoreTransferConfig,\n LifiSwapConfig,\n LifiZapConfig,\n} from './config.generated.js';\n\n/** Split a resource into two outputs by basis-point ratio */\nexport interface CoreSplitArgs {\n readonly bind: {\n readonly source: Bindable<'resource'>;\n };\n readonly config: CoreSplitConfig;\n readonly guards?: readonly TypedGuard<'a' | 'b'>[];\n}\n\n/** Merge two same-token resources into one by addition */\nexport interface CoreMergeArgs {\n readonly bind: {\n readonly a: Bindable<'resource'>;\n readonly b: Bindable<'resource'>;\n };\n readonly guards?: readonly TypedGuard<'merged'>[];\n}\n\n/** Swap tokens via the LI.FI aggregator API */\nexport interface LifiSwapArgs {\n readonly bind: {\n readonly amountIn: Bindable<'resource'>;\n };\n readonly config: LifiSwapConfig;\n readonly guards?: readonly TypedGuard<'unspentIn'>[];\n}\n\n/** Assert that an account holds at least a minimum token balance */\nexport interface InvariantBalanceAtLeastArgs {\n readonly bind: {\n readonly minimumAmount: Bindable<'resource'>;\n readonly account: Bindable<'address'>;\n };\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Route tokens into a DeFi protocol position via the edge catalog */\nexport interface LifiZapArgs {\n readonly bind: {\n readonly amountIn: Bindable<'resource'>;\n };\n readonly config: LifiZapConfig;\n readonly guards?: readonly TypedGuard<'amountOut'>[];\n}\n\n/** Add two unsigned integers (a + b) */\nexport interface CoreAddArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Subtract b from a (a - b); reverts on underflow */\nexport interface CoreSubtractArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Multiply two unsigned integers (a * b) */\nexport interface CoreMultiplyArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Divide a by b, rounding toward zero */\nexport interface CoreDivideDownArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Divide a by b, rounding away from zero */\nexport interface CoreDivideUpArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Multiply value by basis points and divide by 10000, rounding down */\nexport interface CoreBpsDownArgs {\n readonly bind: {\n readonly value: Bindable<'uint256'>;\n };\n readonly config: CoreBpsDownConfig;\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Multiply value by basis points and divide by 10000, rounding up */\nexport interface CoreBpsUpArgs {\n readonly bind: {\n readonly value: Bindable<'uint256'>;\n };\n readonly config: CoreBpsUpConfig;\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Assert a == b; reverts if not equal */\nexport interface CoreAssertEqualArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Assert a != b; reverts if equal */\nexport interface CoreAssertNotEqualArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Assert a > b; reverts if a <= b */\nexport interface CoreAssertGtArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Assert a >= b; reverts if a < b */\nexport interface CoreAssertGteArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Assert a < b; reverts if a >= b */\nexport interface CoreAssertLtArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Assert a <= b; reverts if a > b */\nexport interface CoreAssertLteArgs {\n readonly bind: {\n readonly a: Bindable<'uint256'>;\n readonly b: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Assert min <= value <= max; reverts if value is outside the range */\nexport interface CoreAssertInRangeArgs {\n readonly bind: {\n readonly value: Bindable<'uint256'>;\n readonly min: Bindable<'uint256'>;\n readonly max: Bindable<'uint256'>;\n };\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Approve an ERC20 spender for the given token and amount */\nexport interface CoreApproveArgs {\n readonly bind: {\n readonly amount: Bindable<'resource'>;\n };\n readonly config: CoreApproveConfig;\n readonly guards?: readonly TypedGuard<never>[];\n}\n\n/** Read an ERC20 balance, producing a resource */\nexport interface CoreBalanceOfArgs {\n readonly bind: Record<string, never>;\n readonly config: CoreBalanceOfConfig;\n readonly guards?: readonly TypedGuard<'balance'>[];\n}\n\n/** Transfer tokens to a recipient address, optionally specifying a partial amount */\nexport interface CoreTransferArgs {\n readonly bind: {\n readonly amount: Bindable<'resource'>;\n readonly recipient: Bindable<'address'>;\n };\n readonly config: CoreTransferConfig;\n readonly guards?: readonly TypedGuard<'transferred' | 'remainder'>[];\n}\n\n/** Invoke a smart contract function, optionally spending a token resource */\nexport interface CoreCallArgs<TSig extends string = string> {\n readonly resource?: Bindable<'resource'>;\n readonly bind: SignatureBind<TSig>;\n readonly config: Omit<CoreCallConfig, 'args' | 'functionSignature'> & {\n readonly functionSignature: TSig;\n };\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Read from a smart contract at runtime (StaticCall); result is fresh at execution time */\nexport interface CoreStaticCallArgs<TSig extends string = string> {\n readonly bind: SignatureBind<TSig>;\n readonly config: Omit<CoreStaticCallConfig, 'args' | 'functionSignature'> & {\n readonly functionSignature: TSig;\n };\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Invoke a contract with pre-encoded calldata */\nexport interface CoreRawCallArgs {\n readonly bind: Record<string, never>;\n readonly config: CoreRawCallConfig;\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\n/** Graduate a raw handle to a resource, enabling slippage surfacing and linearity tracking */\nexport interface CoreAsResourceArgs {\n readonly bind: {\n readonly handle: Bindable<'uint256'>;\n };\n readonly config: CoreAsResourceConfig;\n readonly guards?: readonly TypedGuard<'resource'>[];\n}\n\n/** Read a smart contract value at compile time (off-chain eth_call); result is baked as a literal */\nexport interface CorePeekArgs {\n readonly bind: Record<string, never>;\n readonly config: CorePeekConfig;\n readonly guards?: readonly TypedGuard<'result'>[];\n}\n\nexport interface CoreSplitOutputs {\n readonly a: OutputHandle<'resource'>;\n readonly b: OutputHandle<'resource'>;\n}\n\nexport interface CoreMergeOutputs {\n readonly merged: OutputHandle<'resource'>;\n}\n\nexport interface LifiSwapOutputs {\n readonly amountOut: OutputHandle<'resource'>;\n readonly unspentIn: OutputHandle<'resource'>;\n}\n\nexport interface LifiZapOutputs {\n readonly amountOut: OutputHandle<'resource'>;\n}\n\nexport interface CoreAddOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport interface CoreSubtractOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport interface CoreMultiplyOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport interface CoreDivideDownOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport interface CoreDivideUpOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport interface CoreBpsDownOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport interface CoreBpsUpOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport interface CoreBalanceOfOutputs {\n readonly balance: OutputHandle<'resource'>;\n}\n\nexport interface CoreTransferOutputs {\n readonly transferred: OutputHandle<'resource'>;\n readonly remainder: OutputHandle<'resource'>;\n}\n\nexport interface CoreRawCallOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport interface CoreAsResourceOutputs {\n readonly resource: OutputHandle<'resource'>;\n}\n\nexport interface CorePeekOutputs {\n readonly result: OutputHandle<'uint256'>;\n}\n\nexport type GeneratedOps = {\n readonly core: {\n /** Split a resource into two outputs by basis-point ratio — original id: \"core.split\" */\n readonly split: (nodeId: string, args: CoreSplitArgs) => CoreSplitOutputs;\n /** Merge two same-token resources into one by addition — original id: \"core.merge\" */\n readonly merge: (nodeId: string, args: CoreMergeArgs) => CoreMergeOutputs;\n /** Add two unsigned integers (a + b) — original id: \"core.add\" */\n readonly add: (nodeId: string, args: CoreAddArgs) => CoreAddOutputs;\n /** Subtract b from a (a - b); reverts on underflow — original id: \"core.subtract\" */\n readonly subtract: (\n nodeId: string,\n args: CoreSubtractArgs,\n ) => CoreSubtractOutputs;\n /** Multiply two unsigned integers (a * b) — original id: \"core.multiply\" */\n readonly multiply: (\n nodeId: string,\n args: CoreMultiplyArgs,\n ) => CoreMultiplyOutputs;\n /** Divide a by b, rounding toward zero — original id: \"core.divideDown\" */\n readonly divideDown: (\n nodeId: string,\n args: CoreDivideDownArgs,\n ) => CoreDivideDownOutputs;\n /** Divide a by b, rounding away from zero — original id: \"core.divideUp\" */\n readonly divideUp: (\n nodeId: string,\n args: CoreDivideUpArgs,\n ) => CoreDivideUpOutputs;\n /** Multiply value by basis points and divide by 10000, rounding down — original id: \"core.bpsDown\" */\n readonly bpsDown: (\n nodeId: string,\n args: CoreBpsDownArgs,\n ) => CoreBpsDownOutputs;\n /** Multiply value by basis points and divide by 10000, rounding up — original id: \"core.bpsUp\" */\n readonly bpsUp: (nodeId: string, args: CoreBpsUpArgs) => CoreBpsUpOutputs;\n /** Assert a == b; reverts if not equal — original id: \"core.assertEqual\" */\n readonly assertEqual: (nodeId: string, args: CoreAssertEqualArgs) => void;\n /** Assert a != b; reverts if equal — original id: \"core.assertNotEqual\" */\n readonly assertNotEqual: (\n nodeId: string,\n args: CoreAssertNotEqualArgs,\n ) => void;\n /** Assert a > b; reverts if a <= b — original id: \"core.assertGt\" */\n readonly assertGt: (nodeId: string, args: CoreAssertGtArgs) => void;\n /** Assert a >= b; reverts if a < b — original id: \"core.assertGte\" */\n readonly assertGte: (nodeId: string, args: CoreAssertGteArgs) => void;\n /** Assert a < b; reverts if a >= b — original id: \"core.assertLt\" */\n readonly assertLt: (nodeId: string, args: CoreAssertLtArgs) => void;\n /** Assert a <= b; reverts if a > b — original id: \"core.assertLte\" */\n readonly assertLte: (nodeId: string, args: CoreAssertLteArgs) => void;\n /** Assert min <= value <= max; reverts if value is outside the range — original id: \"core.assertInRange\" */\n readonly assertInRange: (\n nodeId: string,\n args: CoreAssertInRangeArgs,\n ) => void;\n /** Approve an ERC20 spender for the given token and amount — original id: \"core.approve\" */\n readonly approve: (nodeId: string, args: CoreApproveArgs) => void;\n /** Read an ERC20 balance, producing a resource — original id: \"core.balanceOf\" */\n readonly balanceOf: (\n nodeId: string,\n args: CoreBalanceOfArgs,\n ) => CoreBalanceOfOutputs;\n /** Transfer tokens to a recipient address, optionally specifying a partial amount — original id: \"core.transfer\" */\n readonly transfer: (\n nodeId: string,\n args: CoreTransferArgs,\n ) => CoreTransferOutputs;\n /** Invoke a smart contract function, optionally spending a token resource — original id: \"core.call\" */\n readonly call: <TSig extends string>(\n nodeId: string,\n args: CoreCallArgs<TSig>,\n ) => CoreCallResult<TSig>;\n /** Read from a smart contract at runtime (StaticCall); result is fresh at execution time — original id: \"core.staticCall\" */\n readonly staticCall: <TSig extends string>(\n nodeId: string,\n args: CoreStaticCallArgs<TSig>,\n ) => StaticCallResult<TSig>;\n /** Invoke a contract with pre-encoded calldata — original id: \"core.rawCall\" */\n readonly rawCall: (\n nodeId: string,\n args: CoreRawCallArgs,\n ) => CoreRawCallOutputs;\n /** Graduate a raw handle to a resource, enabling slippage surfacing and linearity tracking — original id: \"core.asResource\" */\n readonly asResource: (\n nodeId: string,\n args: CoreAsResourceArgs,\n ) => CoreAsResourceOutputs;\n /** Read a smart contract value at compile time (off-chain eth_call); result is baked as a literal — original id: \"core.peek\" */\n readonly peek: (nodeId: string, args: CorePeekArgs) => CorePeekOutputs;\n };\n readonly lifi: {\n /** Swap tokens via the LI.FI aggregator API — original id: \"lifi.swap\" */\n readonly swap: (nodeId: string, args: LifiSwapArgs) => LifiSwapOutputs;\n /** Route tokens into a DeFi protocol position via the edge catalog — original id: \"lifi.zap\" */\n readonly zap: (nodeId: string, args: LifiZapArgs) => LifiZapOutputs;\n };\n readonly invariant: {\n /** Assert that an account holds at least a minimum token balance — original id: \"invariant.balanceAtLeast\" */\n readonly balanceAtLeast: (\n nodeId: string,\n args: InvariantBalanceAtLeastArgs,\n ) => void;\n };\n};\n\nexport const bindGeneratedOps = (\n builder: FlowBuilderInternal,\n): GeneratedOps => ({\n core: {\n split: (nodeId: string, args: CoreSplitArgs) =>\n builder.call(nodeId, 'core.split', args, {\n a: 'resource',\n b: 'resource',\n } as const),\n merge: (nodeId: string, args: CoreMergeArgs) =>\n builder.call(nodeId, 'core.merge', args, { merged: 'resource' } as const),\n add: (nodeId: string, args: CoreAddArgs) =>\n builder.call(nodeId, 'core.add', args, { result: 'uint256' } as const),\n subtract: (nodeId: string, args: CoreSubtractArgs) =>\n builder.call(nodeId, 'core.subtract', args, {\n result: 'uint256',\n } as const),\n multiply: (nodeId: string, args: CoreMultiplyArgs) =>\n builder.call(nodeId, 'core.multiply', args, {\n result: 'uint256',\n } as const),\n divideDown: (nodeId: string, args: CoreDivideDownArgs) =>\n builder.call(nodeId, 'core.divideDown', args, {\n result: 'uint256',\n } as const),\n divideUp: (nodeId: string, args: CoreDivideUpArgs) =>\n builder.call(nodeId, 'core.divideUp', args, {\n result: 'uint256',\n } as const),\n bpsDown: (nodeId: string, args: CoreBpsDownArgs) =>\n builder.call(nodeId, 'core.bpsDown', args, {\n result: 'uint256',\n } as const),\n bpsUp: (nodeId: string, args: CoreBpsUpArgs) =>\n builder.call(nodeId, 'core.bpsUp', args, { result: 'uint256' } as const),\n assertEqual: (nodeId: string, args: CoreAssertEqualArgs) =>\n builder.call(nodeId, 'core.assertEqual', args, {}),\n assertNotEqual: (nodeId: string, args: CoreAssertNotEqualArgs) =>\n builder.call(nodeId, 'core.assertNotEqual', args, {}),\n assertGt: (nodeId: string, args: CoreAssertGtArgs) =>\n builder.call(nodeId, 'core.assertGt', args, {}),\n assertGte: (nodeId: string, args: CoreAssertGteArgs) =>\n builder.call(nodeId, 'core.assertGte', args, {}),\n assertLt: (nodeId: string, args: CoreAssertLtArgs) =>\n builder.call(nodeId, 'core.assertLt', args, {}),\n assertLte: (nodeId: string, args: CoreAssertLteArgs) =>\n builder.call(nodeId, 'core.assertLte', args, {}),\n assertInRange: (nodeId: string, args: CoreAssertInRangeArgs) =>\n builder.call(nodeId, 'core.assertInRange', args, {}),\n approve: (nodeId: string, args: CoreApproveArgs) =>\n builder.call(nodeId, 'core.approve', args, {}),\n balanceOf: (nodeId: string, args: CoreBalanceOfArgs) =>\n builder.call(nodeId, 'core.balanceOf', args, {\n balance: 'resource',\n } as const),\n transfer: (nodeId: string, args: CoreTransferArgs) =>\n builder.call(nodeId, 'core.transfer', args, {\n transferred: 'resource',\n remainder: 'resource',\n } as const),\n call: <TSig extends string>(nodeId: string, args: CoreCallArgs<TSig>) => {\n const wire = buildCallWireFormat({\n resource: args.resource,\n bind: args.bind as Record<string, AnyBindable>,\n config: args.config as Record<string, unknown>,\n guards: args.guards,\n });\n return builder.call(nodeId, wire.op, wire, {\n result: 'uint256',\n } as const) as unknown as CoreCallResult<TSig>;\n },\n staticCall: <TSig extends string>(\n nodeId: string,\n args: CoreStaticCallArgs<TSig>,\n ) =>\n builder.call(\n nodeId,\n 'core.staticCall',\n buildStaticCallWireFormat({\n bind: args.bind as Record<string, AnyBindable>,\n config: args.config as Record<string, unknown>,\n guards: args.guards,\n }),\n { result: 'uint256' } as const,\n ) as unknown as StaticCallResult<TSig>,\n rawCall: (nodeId: string, args: CoreRawCallArgs) =>\n builder.call(nodeId, 'core.rawCall', args, {\n result: 'uint256',\n } as const),\n asResource: (nodeId: string, args: CoreAsResourceArgs) =>\n builder.call(nodeId, 'core.asResource', args, {\n resource: 'resource',\n } as const),\n peek: (nodeId: string, args: CorePeekArgs) =>\n builder.call(nodeId, 'core.peek', args, { result: 'uint256' } as const),\n },\n lifi: {\n swap: (nodeId: string, args: LifiSwapArgs) =>\n builder.call(nodeId, 'lifi.swap', args, {\n amountOut: 'resource',\n unspentIn: 'resource',\n } as const),\n zap: (nodeId: string, args: LifiZapArgs) =>\n builder.call(nodeId, 'lifi.zap', args, {\n amountOut: 'resource',\n } as const),\n },\n invariant: {\n balanceAtLeast: (nodeId: string, args: InvariantBalanceAtLeastArgs) =>\n builder.call(nodeId, 'invariant.balanceAtLeast', args, {}),\n },\n});\n"],"mappings":"AAaA;AAAA,EACE;AAAA,EACA;AAAA,OACK;AA+aA,MAAM,mBAAmB,CAC9B,aACkB;AAAA,EAClB,MAAM;AAAA,IACJ,OAAO,CAAC,QAAgB,SACtB,QAAQ,KAAK,QAAQ,cAAc,MAAM;AAAA,MACvC,GAAG;AAAA,MACH,GAAG;AAAA,IACL,CAAU;AAAA,IACZ,OAAO,CAAC,QAAgB,SACtB,QAAQ,KAAK,QAAQ,cAAc,MAAM,EAAE,QAAQ,WAAW,CAAU;AAAA,IAC1E,KAAK,CAAC,QAAgB,SACpB,QAAQ,KAAK,QAAQ,YAAY,MAAM,EAAE,QAAQ,UAAU,CAAU;AAAA,IACvE,UAAU,CAAC,QAAgB,SACzB,QAAQ,KAAK,QAAQ,iBAAiB,MAAM;AAAA,MAC1C,QAAQ;AAAA,IACV,CAAU;AAAA,IACZ,UAAU,CAAC,QAAgB,SACzB,QAAQ,KAAK,QAAQ,iBAAiB,MAAM;AAAA,MAC1C,QAAQ;AAAA,IACV,CAAU;AAAA,IACZ,YAAY,CAAC,QAAgB,SAC3B,QAAQ,KAAK,QAAQ,mBAAmB,MAAM;AAAA,MAC5C,QAAQ;AAAA,IACV,CAAU;AAAA,IACZ,UAAU,CAAC,QAAgB,SACzB,QAAQ,KAAK,QAAQ,iBAAiB,MAAM;AAAA,MAC1C,QAAQ;AAAA,IACV,CAAU;AAAA,IACZ,SAAS,CAAC,QAAgB,SACxB,QAAQ,KAAK,QAAQ,gBAAgB,MAAM;AAAA,MACzC,QAAQ;AAAA,IACV,CAAU;AAAA,IACZ,OAAO,CAAC,QAAgB,SACtB,QAAQ,KAAK,QAAQ,cAAc,MAAM,EAAE,QAAQ,UAAU,CAAU;AAAA,IACzE,aAAa,CAAC,QAAgB,SAC5B,QAAQ,KAAK,QAAQ,oBAAoB,MAAM,CAAC,CAAC;AAAA,IACnD,gBAAgB,CAAC,QAAgB,SAC/B,QAAQ,KAAK,QAAQ,uBAAuB,MAAM,CAAC,CAAC;AAAA,IACtD,UAAU,CAAC,QAAgB,SACzB,QAAQ,KAAK,QAAQ,iBAAiB,MAAM,CAAC,CAAC;AAAA,IAChD,WAAW,CAAC,QAAgB,SAC1B,QAAQ,KAAK,QAAQ,kBAAkB,MAAM,CAAC,CAAC;AAAA,IACjD,UAAU,CAAC,QAAgB,SACzB,QAAQ,KAAK,QAAQ,iBAAiB,MAAM,CAAC,CAAC;AAAA,IAChD,WAAW,CAAC,QAAgB,SAC1B,QAAQ,KAAK,QAAQ,kBAAkB,MAAM,CAAC,CAAC;AAAA,IACjD,eAAe,CAAC,QAAgB,SAC9B,QAAQ,KAAK,QAAQ,sBAAsB,MAAM,CAAC,CAAC;AAAA,IACrD,SAAS,CAAC,QAAgB,SACxB,QAAQ,KAAK,QAAQ,gBAAgB,MAAM,CAAC,CAAC;AAAA,IAC/C,WAAW,CAAC,QAAgB,SAC1B,QAAQ,KAAK,QAAQ,kBAAkB,MAAM;AAAA,MAC3C,SAAS;AAAA,IACX,CAAU;AAAA,IACZ,UAAU,CAAC,QAAgB,SACzB,QAAQ,KAAK,QAAQ,iBAAiB,MAAM;AAAA,MAC1C,aAAa;AAAA,MACb,WAAW;AAAA,IACb,CAAU;AAAA,IACZ,MAAM,CAAsB,QAAgB,SAA6B;AACvE,YAAM,OAAO,oBAAoB;AAAA,QAC/B,UAAU,KAAK;AAAA,QACf,MAAM,KAAK;AAAA,QACX,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK;AAAA,MACf,CAAC;AACD,aAAO,QAAQ,KAAK,QAAQ,KAAK,IAAI,MAAM;AAAA,QACzC,QAAQ;AAAA,MACV,CAAU;AAAA,IACZ;AAAA,IACA,YAAY,CACV,QACA,SAEA,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA,0BAA0B;AAAA,QACxB,MAAM,KAAK;AAAA,QACX,QAAQ,KAAK;AAAA,QACb,QAAQ,KAAK;AAAA,MACf,CAAC;AAAA,MACD,EAAE,QAAQ,UAAU;AAAA,IACtB;AAAA,IACF,SAAS,CAAC,QAAgB,SACxB,QAAQ,KAAK,QAAQ,gBAAgB,MAAM;AAAA,MACzC,QAAQ;AAAA,IACV,CAAU;AAAA,IACZ,YAAY,CAAC,QAAgB,SAC3B,QAAQ,KAAK,QAAQ,mBAAmB,MAAM;AAAA,MAC5C,UAAU;AAAA,IACZ,CAAU;AAAA,IACZ,MAAM,CAAC,QAAgB,SACrB,QAAQ,KAAK,QAAQ,aAAa,MAAM,EAAE,QAAQ,UAAU,CAAU;AAAA,EAC1E;AAAA,EACA,MAAM;AAAA,IACJ,MAAM,CAAC,QAAgB,SACrB,QAAQ,KAAK,QAAQ,aAAa,MAAM;AAAA,MACtC,WAAW;AAAA,MACX,WAAW;AAAA,IACb,CAAU;AAAA,IACZ,KAAK,CAAC,QAAgB,SACpB,QAAQ,KAAK,QAAQ,YAAY,MAAM;AAAA,MACrC,WAAW;AAAA,IACb,CAAU;AAAA,EACd;AAAA,EACA,WAAW;AAAA,IACT,gBAAgB,CAAC,QAAgB,SAC/B,QAAQ,KAAK,QAAQ,4BAA4B,MAAM,CAAC,CAAC;AAAA,EAC7D;AACF;","names":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var preconditions_generated_exports = {};
|
|
20
|
+
__export(preconditions_generated_exports, {
|
|
21
|
+
erc20Allowance: () => erc20Allowance,
|
|
22
|
+
erc20Balance: () => erc20Balance,
|
|
23
|
+
nativeBalance: () => nativeBalance
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(preconditions_generated_exports);
|
|
26
|
+
const erc20Balance = (config) => ({
|
|
27
|
+
type: "Erc20Balance",
|
|
28
|
+
...config
|
|
29
|
+
});
|
|
30
|
+
const nativeBalance = (config) => ({
|
|
31
|
+
type: "NativeBalance",
|
|
32
|
+
...config
|
|
33
|
+
});
|
|
34
|
+
const erc20Allowance = (config) => ({
|
|
35
|
+
type: "Erc20Allowance",
|
|
36
|
+
...config
|
|
37
|
+
});
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
erc20Allowance,
|
|
41
|
+
erc20Balance,
|
|
42
|
+
nativeBalance
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=preconditions.generated.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/generated/preconditions.generated.ts"],"sourcesContent":["// AUTO-GENERATED from manifest.json — do not edit by hand.\n// Regenerate with: yarn workspace @lifi/composer-sdk generate\n\nimport type { Precondition, PreconditionConfigOf } from '@lifi/compose-spec';\n\nimport type {\n Erc20AllowancePreconditionConfig,\n Erc20BalancePreconditionConfig,\n NativeBalancePreconditionConfig,\n} from './config.generated.js';\n\nexport type Erc20BalancePreconditionInput =\n PreconditionConfigOf<Erc20BalancePreconditionConfig>;\n\n/** Assert that a wallet holds at least a given ERC-20 token balance */\nexport const erc20Balance = (\n config: Erc20BalancePreconditionInput,\n): Precondition => ({\n type: 'Erc20Balance',\n ...config,\n});\n\nexport type NativeBalancePreconditionInput =\n PreconditionConfigOf<NativeBalancePreconditionConfig>;\n\n/** Assert that a wallet holds at least a given native coin balance */\nexport const nativeBalance = (\n config: NativeBalancePreconditionInput,\n): Precondition => ({\n type: 'NativeBalance',\n ...config,\n});\n\nexport type Erc20AllowancePreconditionInput =\n PreconditionConfigOf<Erc20AllowancePreconditionConfig>;\n\n/** Assert that an ERC-20 allowance is at least a given amount */\nexport const erc20Allowance = (\n config: Erc20AllowancePreconditionInput,\n): Precondition => ({\n type: 'Erc20Allowance',\n ...config,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,MAAM,eAAe,CAC1B,YACkB;AAAA,EAClB,MAAM;AAAA,EACN,GAAG;AACL;AAMO,MAAM,gBAAgB,CAC3B,YACkB;AAAA,EAClB,MAAM;AAAA,EACN,GAAG;AACL;AAMO,MAAM,iBAAiB,CAC5B,YACkB;AAAA,EAClB,MAAM;AAAA,EACN,GAAG;AACL;","names":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import '@lifi/compose-spec';
|
|
2
|
+
import './config.generated.cjs';
|
|
3
|
+
export { E as Erc20AllowancePreconditionInput, a as Erc20BalancePreconditionInput, N as NativeBalancePreconditionInput, e as erc20Allowance, b as erc20Balance, n as nativeBalance } from '../preconditions.generated-DblS13Wq.cjs';
|
|
4
|
+
import '../types.cjs';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import '@lifi/compose-spec';
|
|
2
|
+
import './config.generated.js';
|
|
3
|
+
export { E as Erc20AllowancePreconditionInput, a as Erc20BalancePreconditionInput, N as NativeBalancePreconditionInput, e as erc20Allowance, b as erc20Balance, n as nativeBalance } from '../preconditions.generated-U7YpVh30.js';
|
|
4
|
+
import '../types.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const erc20Balance = (config) => ({
|
|
2
|
+
type: "Erc20Balance",
|
|
3
|
+
...config
|
|
4
|
+
});
|
|
5
|
+
const nativeBalance = (config) => ({
|
|
6
|
+
type: "NativeBalance",
|
|
7
|
+
...config
|
|
8
|
+
});
|
|
9
|
+
const erc20Allowance = (config) => ({
|
|
10
|
+
type: "Erc20Allowance",
|
|
11
|
+
...config
|
|
12
|
+
});
|
|
13
|
+
export {
|
|
14
|
+
erc20Allowance,
|
|
15
|
+
erc20Balance,
|
|
16
|
+
nativeBalance
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=preconditions.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/generated/preconditions.generated.ts"],"sourcesContent":["// AUTO-GENERATED from manifest.json — do not edit by hand.\n// Regenerate with: yarn workspace @lifi/composer-sdk generate\n\nimport type { Precondition, PreconditionConfigOf } from '@lifi/compose-spec';\n\nimport type {\n Erc20AllowancePreconditionConfig,\n Erc20BalancePreconditionConfig,\n NativeBalancePreconditionConfig,\n} from './config.generated.js';\n\nexport type Erc20BalancePreconditionInput =\n PreconditionConfigOf<Erc20BalancePreconditionConfig>;\n\n/** Assert that a wallet holds at least a given ERC-20 token balance */\nexport const erc20Balance = (\n config: Erc20BalancePreconditionInput,\n): Precondition => ({\n type: 'Erc20Balance',\n ...config,\n});\n\nexport type NativeBalancePreconditionInput =\n PreconditionConfigOf<NativeBalancePreconditionConfig>;\n\n/** Assert that a wallet holds at least a given native coin balance */\nexport const nativeBalance = (\n config: NativeBalancePreconditionInput,\n): Precondition => ({\n type: 'NativeBalance',\n ...config,\n});\n\nexport type Erc20AllowancePreconditionInput =\n PreconditionConfigOf<Erc20AllowancePreconditionConfig>;\n\n/** Assert that an ERC-20 allowance is at least a given amount */\nexport const erc20Allowance = (\n config: Erc20AllowancePreconditionInput,\n): Precondition => ({\n type: 'Erc20Allowance',\n ...config,\n});\n"],"mappings":"AAeO,MAAM,eAAe,CAC1B,YACkB;AAAA,EAClB,MAAM;AAAA,EACN,GAAG;AACL;AAMO,MAAM,gBAAgB,CAC3B,YACkB;AAAA,EAClB,MAAM;AAAA,EACN,GAAG;AACL;AAMO,MAAM,iBAAiB,CAC5B,YACkB;AAAA,EAClB,MAAM;AAAA,EACN,GAAG;AACL;","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TypedGuard } from './types.js';
|
|
2
|
+
import { SlippageGuardConfig } from './generated/config.generated.js';
|
|
3
|
+
|
|
4
|
+
/** Assert that output amounts are within a slippage tolerance in basis points */
|
|
5
|
+
declare const slippage: <P extends string>(config: Omit<SlippageGuardConfig, "port"> & {
|
|
6
|
+
port: P;
|
|
7
|
+
}) => TypedGuard<P>;
|
|
8
|
+
|
|
9
|
+
declare const guardsMod_slippage: typeof slippage;
|
|
10
|
+
declare namespace guardsMod {
|
|
11
|
+
export { guardsMod_slippage as slippage };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { guardsMod as g, slippage as s };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TypedGuard } from './types.cjs';
|
|
2
|
+
import { SlippageGuardConfig } from './generated/config.generated.cjs';
|
|
3
|
+
|
|
4
|
+
/** Assert that output amounts are within a slippage tolerance in basis points */
|
|
5
|
+
declare const slippage: <P extends string>(config: Omit<SlippageGuardConfig, "port"> & {
|
|
6
|
+
port: P;
|
|
7
|
+
}) => TypedGuard<P>;
|
|
8
|
+
|
|
9
|
+
declare const guardsMod_slippage: typeof slippage;
|
|
10
|
+
declare namespace guardsMod {
|
|
11
|
+
export { guardsMod_slippage as slippage };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { guardsMod as g, slippage as s };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var index_exports = {};
|
|
31
|
+
__export(index_exports, {
|
|
32
|
+
createComposeSdk: () => import_sdk.createComposeSdk,
|
|
33
|
+
guards: () => guards,
|
|
34
|
+
isComposeError: () => import_errors.isComposeError,
|
|
35
|
+
isInputHandle: () => import_handles.isInputHandle,
|
|
36
|
+
isOutputHandle: () => import_handles.isOutputHandle,
|
|
37
|
+
materialiser: () => import_inputs.materialiser,
|
|
38
|
+
materialisers: () => materialisers,
|
|
39
|
+
preconditions: () => preconditions,
|
|
40
|
+
raw: () => raw,
|
|
41
|
+
ref: () => import_raw.ref,
|
|
42
|
+
resources: () => resources
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(index_exports);
|
|
45
|
+
var import_errors = require("./errors.js");
|
|
46
|
+
var import_handles = require("./authoring/handles.js");
|
|
47
|
+
var import_raw = require("./authoring/raw.js");
|
|
48
|
+
var import_inputs = require("./run/inputs.js");
|
|
49
|
+
var import_sdk = require("./sdk.js");
|
|
50
|
+
var guardsMod = __toESM(require("./generated/guards.generated.js"), 1);
|
|
51
|
+
var materialisersMod = __toESM(require("./generated/materialisers.generated.js"), 1);
|
|
52
|
+
var preconditionsMod = __toESM(require("./generated/preconditions.generated.js"), 1);
|
|
53
|
+
var rawMod = __toESM(require("./raw.js"), 1);
|
|
54
|
+
var resourcesMod = __toESM(require("./resources.js"), 1);
|
|
55
|
+
__reExport(index_exports, require("./generated/config.generated.js"), module.exports);
|
|
56
|
+
const guards = guardsMod;
|
|
57
|
+
const materialisers = materialisersMod;
|
|
58
|
+
const preconditions = preconditionsMod;
|
|
59
|
+
const resources = resourcesMod;
|
|
60
|
+
const raw = rawMod;
|
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
62
|
+
0 && (module.exports = {
|
|
63
|
+
createComposeSdk,
|
|
64
|
+
guards,
|
|
65
|
+
isComposeError,
|
|
66
|
+
isInputHandle,
|
|
67
|
+
isOutputHandle,
|
|
68
|
+
materialiser,
|
|
69
|
+
materialisers,
|
|
70
|
+
preconditions,
|
|
71
|
+
raw,
|
|
72
|
+
ref,
|
|
73
|
+
resources,
|
|
74
|
+
...require("./generated/config.generated.js")
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +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} 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 { 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsDA,oBAA+B;AAS/B,qBAA8C;AAC9C,iBAAoB;AAMpB,oBAA6B;AAE7B,iBAAiC;AAGjC,gBAA2B;AAC3B,uBAAkC;AAClC,uBAAkC;AAClC,aAAwB;AACxB,mBAA8B;AA6D9B,0BAAc,4CA5Id;AA8FO,MAAM,SAA2B;AAajC,MAAM,gBAAyC;AAgB/C,MAAM,gBAAyC;AAgB/C,MAAM,YAAiC;AASvC,MAAM,MAAqB;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export { AbiTypeToOutputKind, Address, InputDecl, InputSchema, InputSpecOf, IntegerString, IntegerStringInput, OutputKind, TypedGuard, TypedRef } from './types.cjs';
|
|
2
|
+
export { GetZapPacksOptions, ZapPackEdge, ZapPackOverview } from './discovery.cjs';
|
|
3
|
+
export { ComposeError, ComposeErrorCode, isComposeError } from './errors.cjs';
|
|
4
|
+
export { AppliedGuard, ApprovalEntry, Call, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeTransactionRequest, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, SimulationPolicy, SimulationRevert, SolType, SweepTo } from '@lifi/compose-spec';
|
|
5
|
+
export { AnyHandle, Bindable, InputHandle, OutputHandle, ResourceInputHandle, isInputHandle, isOutputHandle } from './authoring/handles.cjs';
|
|
6
|
+
export { ref } from './authoring/raw.cjs';
|
|
7
|
+
export { AnyBindable, FlowOptions, TypedFlow } from './authoring/FlowBuilderCore.cjs';
|
|
8
|
+
export { ComposeRunInput, materialiser } from './run/inputs.cjs';
|
|
9
|
+
export { ComposeSdk, ComposeSdkOptions, FlowBuilder, createComposeSdk } from './sdk.cjs';
|
|
10
|
+
import { g as guardsMod } from './guards.generated-hrQ1KPNv.cjs';
|
|
11
|
+
import { m as materialisersMod } from './materialisers.generated-nMxTAaVi.cjs';
|
|
12
|
+
import { p as preconditionsMod } from './preconditions.generated-DblS13Wq.cjs';
|
|
13
|
+
import { r as rawMod } from './raw-Dj_2rBSQ.cjs';
|
|
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';
|
|
16
|
+
import './client.cjs';
|
|
17
|
+
import './generated/operations.generated.cjs';
|
|
18
|
+
import './authoring/signatureArgs.cjs';
|
|
19
|
+
import 'abitype';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* `@lifi/composer-sdk` — TypeScript SDK for building and compiling
|
|
23
|
+
* Compose flows into executable EVM calldata.
|
|
24
|
+
*
|
|
25
|
+
* Start by creating an SDK instance with {@link createComposeSdk}, then use
|
|
26
|
+
* {@link ComposeSdk.flow} to build flows and compile them.
|
|
27
|
+
*
|
|
28
|
+
* @packageDocumentation
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Guard factories for protecting operation outputs (e.g. slippage tolerance).
|
|
33
|
+
* Pass guards to an operation's `guards` array.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* builder.lifi.swap('swap1', {
|
|
38
|
+
* bind: { amountIn: builder.inputs.token },
|
|
39
|
+
* config: { resourceOut: resources.native(1) },
|
|
40
|
+
* guards: [guards.slippage({ port: 'amountOut', bps: 300 })],
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const guards: typeof guardsMod;
|
|
45
|
+
/**
|
|
46
|
+
* Materialiser factories that tell the runtime how to resolve token input
|
|
47
|
+
* amounts on-chain (e.g. read a wallet balance, accept a direct deposit).
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* await builder.compile({
|
|
52
|
+
* inputs: { token: materialisers.balanceOf({}) },
|
|
53
|
+
* signer: '0x...',
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare const materialisers: typeof materialisersMod;
|
|
58
|
+
/**
|
|
59
|
+
* Precondition factories for asserting on-chain state before a flow executes
|
|
60
|
+
* (e.g. minimum token balances, ERC-20 allowances).
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* await builder.compile({
|
|
65
|
+
* inputs: { token: materialisers.balanceOf({}) },
|
|
66
|
+
* preconditions: [
|
|
67
|
+
* preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),
|
|
68
|
+
* ],
|
|
69
|
+
* signer: '0x...',
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare const preconditions: typeof preconditionsMod;
|
|
74
|
+
/**
|
|
75
|
+
* Resource declaration helpers for defining token inputs in a flow schema.
|
|
76
|
+
* Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}
|
|
77
|
+
* for the chain's native coin (ETH, MATIC, etc.).
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const builder = sdk.flow(1, {
|
|
82
|
+
* inputs: {
|
|
83
|
+
* usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),
|
|
84
|
+
* eth: resources.native(1),
|
|
85
|
+
* },
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare const resources: typeof resourcesMod;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Low-level escape hatch for constructing flow nodes, guards, and materialiser
|
|
93
|
+
* inputs without the typed builder API. Prefer the generated operation methods
|
|
94
|
+
* on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces
|
|
95
|
+
* for most use cases.
|
|
96
|
+
*/
|
|
97
|
+
declare const raw: typeof rawMod;
|
|
98
|
+
|
|
99
|
+
export { guards, materialisers, preconditions, raw, resources };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export { AbiTypeToOutputKind, Address, InputDecl, InputSchema, InputSpecOf, IntegerString, IntegerStringInput, OutputKind, TypedGuard, TypedRef } from './types.js';
|
|
2
|
+
export { GetZapPacksOptions, ZapPackEdge, ZapPackOverview } from './discovery.js';
|
|
3
|
+
export { ComposeError, ComposeErrorCode, isComposeError } from './errors.js';
|
|
4
|
+
export { AppliedGuard, ApprovalEntry, Call, ComposeCompilePartialData, ComposeCompileRequest, ComposeCompileResult, ComposeCompileSuccessData, ComposeContinuation, ComposeErrorKind, ComposeTransactionRequest, Flow, InputSpec, MaterialiserConfigOf, MaterialiserInput, Precondition, PreconditionConfigOf, PriceImpact, Ref, Resource, SimulationPolicy, SimulationRevert, SolType, SweepTo } from '@lifi/compose-spec';
|
|
5
|
+
export { AnyHandle, Bindable, InputHandle, OutputHandle, ResourceInputHandle, isInputHandle, isOutputHandle } from './authoring/handles.js';
|
|
6
|
+
export { ref } from './authoring/raw.js';
|
|
7
|
+
export { AnyBindable, FlowOptions, TypedFlow } from './authoring/FlowBuilderCore.js';
|
|
8
|
+
export { ComposeRunInput, materialiser } from './run/inputs.js';
|
|
9
|
+
export { ComposeSdk, ComposeSdkOptions, FlowBuilder, createComposeSdk } from './sdk.js';
|
|
10
|
+
import { g as guardsMod } from './guards.generated-DKKDKREA.js';
|
|
11
|
+
import { m as materialisersMod } from './materialisers.generated-BsA1uDW8.js';
|
|
12
|
+
import { p as preconditionsMod } from './preconditions.generated-U7YpVh30.js';
|
|
13
|
+
import { r as rawMod } from './raw-IxCF_bSS.js';
|
|
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';
|
|
16
|
+
import './client.js';
|
|
17
|
+
import './generated/operations.generated.js';
|
|
18
|
+
import './authoring/signatureArgs.js';
|
|
19
|
+
import 'abitype';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* `@lifi/composer-sdk` — TypeScript SDK for building and compiling
|
|
23
|
+
* Compose flows into executable EVM calldata.
|
|
24
|
+
*
|
|
25
|
+
* Start by creating an SDK instance with {@link createComposeSdk}, then use
|
|
26
|
+
* {@link ComposeSdk.flow} to build flows and compile them.
|
|
27
|
+
*
|
|
28
|
+
* @packageDocumentation
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Guard factories for protecting operation outputs (e.g. slippage tolerance).
|
|
33
|
+
* Pass guards to an operation's `guards` array.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* builder.lifi.swap('swap1', {
|
|
38
|
+
* bind: { amountIn: builder.inputs.token },
|
|
39
|
+
* config: { resourceOut: resources.native(1) },
|
|
40
|
+
* guards: [guards.slippage({ port: 'amountOut', bps: 300 })],
|
|
41
|
+
* });
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
declare const guards: typeof guardsMod;
|
|
45
|
+
/**
|
|
46
|
+
* Materialiser factories that tell the runtime how to resolve token input
|
|
47
|
+
* amounts on-chain (e.g. read a wallet balance, accept a direct deposit).
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* await builder.compile({
|
|
52
|
+
* inputs: { token: materialisers.balanceOf({}) },
|
|
53
|
+
* signer: '0x...',
|
|
54
|
+
* });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare const materialisers: typeof materialisersMod;
|
|
58
|
+
/**
|
|
59
|
+
* Precondition factories for asserting on-chain state before a flow executes
|
|
60
|
+
* (e.g. minimum token balances, ERC-20 allowances).
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* await builder.compile({
|
|
65
|
+
* inputs: { token: materialisers.balanceOf({}) },
|
|
66
|
+
* preconditions: [
|
|
67
|
+
* preconditions.erc20Balance({ wallet: '0x...', token: '0x...', balance: 1000n }),
|
|
68
|
+
* ],
|
|
69
|
+
* signer: '0x...',
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
declare const preconditions: typeof preconditionsMod;
|
|
74
|
+
/**
|
|
75
|
+
* Resource declaration helpers for defining token inputs in a flow schema.
|
|
76
|
+
* Use {@link resources.erc20} for ERC-20 tokens and {@link resources.native}
|
|
77
|
+
* for the chain's native coin (ETH, MATIC, etc.).
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const builder = sdk.flow(1, {
|
|
82
|
+
* inputs: {
|
|
83
|
+
* usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1),
|
|
84
|
+
* eth: resources.native(1),
|
|
85
|
+
* },
|
|
86
|
+
* });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
declare const resources: typeof resourcesMod;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Low-level escape hatch for constructing flow nodes, guards, and materialiser
|
|
93
|
+
* inputs without the typed builder API. Prefer the generated operation methods
|
|
94
|
+
* on {@link FlowBuilder} and the typed `guards`/`materialisers` namespaces
|
|
95
|
+
* for most use cases.
|
|
96
|
+
*/
|
|
97
|
+
declare const raw: typeof rawMod;
|
|
98
|
+
|
|
99
|
+
export { guards, materialisers, preconditions, raw, resources };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { isComposeError } from "./errors.js";
|
|
2
|
+
import { isInputHandle, isOutputHandle } from "./authoring/handles.js";
|
|
3
|
+
import { ref } from "./authoring/raw.js";
|
|
4
|
+
import { materialiser } from "./run/inputs.js";
|
|
5
|
+
import { createComposeSdk } from "./sdk.js";
|
|
6
|
+
import * as guardsMod from "./generated/guards.generated.js";
|
|
7
|
+
import * as materialisersMod from "./generated/materialisers.generated.js";
|
|
8
|
+
import * as preconditionsMod from "./generated/preconditions.generated.js";
|
|
9
|
+
import * as rawMod from "./raw.js";
|
|
10
|
+
import * as resourcesMod from "./resources.js";
|
|
11
|
+
const guards = guardsMod;
|
|
12
|
+
const materialisers = materialisersMod;
|
|
13
|
+
const preconditions = preconditionsMod;
|
|
14
|
+
const resources = resourcesMod;
|
|
15
|
+
export * from "./generated/config.generated.js";
|
|
16
|
+
const raw = rawMod;
|
|
17
|
+
export {
|
|
18
|
+
createComposeSdk,
|
|
19
|
+
guards,
|
|
20
|
+
isComposeError,
|
|
21
|
+
isInputHandle,
|
|
22
|
+
isOutputHandle,
|
|
23
|
+
materialiser,
|
|
24
|
+
materialisers,
|
|
25
|
+
preconditions,
|
|
26
|
+
raw,
|
|
27
|
+
ref,
|
|
28
|
+
resources
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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} 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 { 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":"AAsDA,SAAS,sBAAsB;AAS/B,SAAS,eAAe,sBAAsB;AAC9C,SAAS,WAAW;AAMpB,SAAS,oBAAoB;AAE7B,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":[]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { MaterialiserConfigOf, MaterialiserInput } from '@lifi/compose-spec';
|
|
2
|
+
import { BalanceOfMaterialiserConfig, CallMaterialiserConfig, DirectDepositMaterialiserConfig } from './generated/config.generated.js';
|
|
3
|
+
|
|
4
|
+
type BalanceOfMaterialiserInput = MaterialiserConfigOf<BalanceOfMaterialiserConfig>;
|
|
5
|
+
/** Read the on-chain token balance of an address as the input amount — accepts: resource */
|
|
6
|
+
declare const balanceOf: (config: BalanceOfMaterialiserInput) => MaterialiserInput;
|
|
7
|
+
type DirectDepositMaterialiserInput = MaterialiserConfigOf<DirectDepositMaterialiserConfig>;
|
|
8
|
+
/** Deposit tokens into the VM — native via msg.value, ERC-20 via transferFrom — accepts: resource */
|
|
9
|
+
declare const directDeposit: (config: DirectDepositMaterialiserInput) => MaterialiserInput;
|
|
10
|
+
type CallMaterialiserInput = MaterialiserConfigOf<CallMaterialiserConfig>;
|
|
11
|
+
/** Execute an arbitrary contract call and measure the resulting token balance diff — accepts: resource */
|
|
12
|
+
declare const call: (config: CallMaterialiserInput) => MaterialiserInput;
|
|
13
|
+
|
|
14
|
+
type materialisersMod_BalanceOfMaterialiserInput = BalanceOfMaterialiserInput;
|
|
15
|
+
type materialisersMod_CallMaterialiserInput = CallMaterialiserInput;
|
|
16
|
+
type materialisersMod_DirectDepositMaterialiserInput = DirectDepositMaterialiserInput;
|
|
17
|
+
declare const materialisersMod_balanceOf: typeof balanceOf;
|
|
18
|
+
declare const materialisersMod_call: typeof call;
|
|
19
|
+
declare const materialisersMod_directDeposit: typeof directDeposit;
|
|
20
|
+
declare namespace materialisersMod {
|
|
21
|
+
export { type materialisersMod_BalanceOfMaterialiserInput as BalanceOfMaterialiserInput, type materialisersMod_CallMaterialiserInput as CallMaterialiserInput, type materialisersMod_DirectDepositMaterialiserInput as DirectDepositMaterialiserInput, materialisersMod_balanceOf as balanceOf, materialisersMod_call as call, materialisersMod_directDeposit as directDeposit };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { type BalanceOfMaterialiserInput as B, type CallMaterialiserInput as C, type DirectDepositMaterialiserInput as D, balanceOf as b, call as c, directDeposit as d, materialisersMod as m };
|