@lifi/composer-sdk 0.2.0-staging.4 → 0.2.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 +81 -0
- package/dist/authoring/handles.cjs.map +1 -1
- package/dist/authoring/handles.d.cts +13 -6
- package/dist/authoring/handles.d.ts +13 -6
- package/dist/authoring/handles.js.map +1 -1
- package/dist/client.cjs +38 -6
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +25 -1
- package/dist/client.d.ts +25 -1
- package/dist/client.js +41 -6
- package/dist/client.js.map +1 -1
- package/dist/errors.cjs +4 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +6 -1
- package/dist/errors.js.map +1 -1
- package/dist/generated/config.generated.cjs.map +1 -1
- package/dist/generated/config.generated.d.cts +82 -7
- package/dist/generated/config.generated.d.ts +82 -7
- package/dist/generated/materialisers.generated.cjs +2 -8
- package/dist/generated/materialisers.generated.cjs.map +1 -1
- package/dist/generated/materialisers.generated.d.cts +1 -1
- package/dist/generated/materialisers.generated.d.ts +1 -1
- package/dist/generated/materialisers.generated.js +1 -6
- package/dist/generated/materialisers.generated.js.map +1 -1
- package/dist/generated/operations.generated.cjs +56 -31
- package/dist/generated/operations.generated.cjs.map +1 -1
- package/dist/generated/operations.generated.d.cts +204 -94
- package/dist/generated/operations.generated.d.ts +204 -94
- package/dist/generated/operations.generated.js +56 -31
- package/dist/generated/operations.generated.js.map +1 -1
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/{materialisers.generated-BfWJ-g7t.d.ts → materialisers.generated-BMkBQgWZ.d.ts} +3 -8
- package/dist/{materialisers.generated-DaJRwiRe.d.cts → materialisers.generated-BWq5oePO.d.cts} +3 -8
- package/dist/responseSchemas.cjs +110 -0
- package/dist/responseSchemas.cjs.map +1 -0
- package/dist/responseSchemas.d.cts +36 -0
- package/dist/responseSchemas.d.ts +36 -0
- package/dist/responseSchemas.js +74 -0
- package/dist/responseSchemas.js.map +1 -0
- package/dist/run/simulate.cjs +41 -0
- package/dist/run/simulate.cjs.map +1 -0
- package/dist/run/simulate.d.cts +59 -0
- package/dist/run/simulate.d.ts +59 -0
- package/dist/run/simulate.js +17 -0
- package/dist/run/simulate.js.map +1 -0
- package/dist/sdk.cjs +6 -1
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.d.cts +13 -1
- package/dist/sdk.d.ts +13 -1
- package/dist/sdk.js +6 -1
- package/dist/sdk.js.map +1 -1
- package/package.json +7 -5
- package/src/authoring/handles.ts +19 -10
- package/src/client.ts +86 -11
- package/src/errors.ts +8 -10
- package/src/examples/aaveRepay.ts +55 -16
- package/src/examples/aaveRepayWithATokens.ts +41 -30
- package/src/examples/aaveRounding.ts +42 -0
- package/src/examples/aaveSetEMode.ts +0 -1
- package/src/examples/config.ts +1 -1
- package/src/examples/emitCustomEvent.ts +75 -0
- package/src/examples/invariantChecks.ts +96 -0
- package/src/examples/run.ts +20 -18
- package/src/examples/simulateCompiledSwap.ts +76 -0
- package/src/examples/simulateRawTransaction.ts +39 -0
- package/src/examples/untypedOpWithTypedRef.ts +26 -20
- package/src/generated/config.generated.ts +229 -6
- package/src/generated/materialisers.generated.ts +0 -12
- package/src/generated/operations.generated.ts +330 -177
- package/src/index.ts +19 -0
- package/src/responseSchemas.ts +143 -0
- package/src/run/simulate.ts +78 -0
- package/src/sdk.ts +20 -1
- package/src/examples/staged/aaveBorrow.ts +0 -104
- package/src/examples/staged/aaveDebtRebalanceExactOut.ts +0 -301
- package/src/examples/staged/aaveHealthFactorExplode.ts +0 -70
- package/src/examples/staged/aaveToMorphoDebtMigration.ts +0 -190
- package/src/examples/staged/aaveToMorphoDebtMigrationWithSwap.ts +0 -221
- package/src/examples/staged/aaveToMorphoDebtMigrationWithSwapExactOut.ts +0 -302
- package/src/examples/staged/flashloanRepay.ts +0 -138
- package/src/examples/staged/morphoBlueBorrow.ts +0 -89
- package/src/examples/staged/morphoBlueRepay.ts +0 -91
- package/src/examples/staged/registry.ts +0 -78
package/src/examples/run.ts
CHANGED
|
@@ -10,14 +10,13 @@
|
|
|
10
10
|
* Available examples:
|
|
11
11
|
* aave-repay — repay an Aave v3 WETH debt by supplying WETH
|
|
12
12
|
* aave-repay-atoken — repay an Aave v3 USDC debt by burning proxy aTokens
|
|
13
|
-
* aave-
|
|
13
|
+
* aave-emode — switch the proxy's Aave v3 eMode category
|
|
14
14
|
* approve-deposit — approve vault allowance then deposit USDC
|
|
15
15
|
* consolidate — consolidate ERC-20 balances to USDC
|
|
16
16
|
* consolidate-eth — consolidate ERC-20 balances to native ETH
|
|
17
17
|
* deposit-proxy — deposit tokens already on the proxy into Aave
|
|
18
18
|
* dust-sweep — split USDC 80/20 and sweep leftover dust
|
|
19
19
|
* swap — swap WETH to USDC via LI.FI
|
|
20
|
-
* swap-fee — swap WETH to USDC with a 50 bps integrator fee
|
|
21
20
|
* split-zap — split USDC 60/40 and zap into Aave + Morpho vaults
|
|
22
21
|
* split-arithmetic — split USDC 70/30 with arithmetic assertions
|
|
23
22
|
* zap — zap USDC into Aave lending position
|
|
@@ -29,7 +28,6 @@
|
|
|
29
28
|
* raw-call — query a contract with raw calldata + arithmetic
|
|
30
29
|
* read-state — read on-chain state via peek, staticCall, balanceOf
|
|
31
30
|
* redeem — redeem ERC-4626 vault shares via core.call
|
|
32
|
-
* claim — claim rewards from a contract (resource-free call)
|
|
33
31
|
* wrap-eth — wrap native ETH into WETH via ValueCall
|
|
34
32
|
* transfer — transfer full token balance to a recipient
|
|
35
33
|
* partial-transfer — transfer a specific amount, keeping the remainder
|
|
@@ -39,15 +37,11 @@ import type { ComposeCompileRequest } from '@lifi/compose-spec';
|
|
|
39
37
|
|
|
40
38
|
import { createComposeSdk } from '../sdk.js';
|
|
41
39
|
|
|
42
|
-
import { buildAaveClaimRewards } from './aaveClaimRewards.js';
|
|
43
40
|
import { buildAaveRepay } from './aaveRepay.js';
|
|
44
41
|
import { buildAaveRepayWithATokens } from './aaveRepayWithATokens.js';
|
|
42
|
+
import { buildAaveSetEMode } from './aaveSetEMode.js';
|
|
45
43
|
import { buildApproveAndDeposit } from './approveAndDeposit.js';
|
|
46
|
-
import {
|
|
47
|
-
buildClaimRewards,
|
|
48
|
-
buildRedeemFromVault,
|
|
49
|
-
buildWrapEth,
|
|
50
|
-
} from './callContract.js';
|
|
44
|
+
import { buildRedeemFromVault, buildWrapEth } from './callContract.js';
|
|
51
45
|
import { API_KEY, BASE_URL, OWNER, PROXY, RECIPIENT } from './config.js';
|
|
52
46
|
import { buildConsolidateToEth } from './consolidateToEth.js';
|
|
53
47
|
import { buildConsolidateStablesToUsdc } from './consolidateToUsdc.js';
|
|
@@ -63,22 +57,25 @@ import { buildSwapAndZapExample } from './swapAndZap.js';
|
|
|
63
57
|
import { buildSwapToRecipient } from './swapToRecipient.js';
|
|
64
58
|
import { buildSwapWithAllowRevertExample } from './swapWithAllowRevert.js';
|
|
65
59
|
import { buildSwapWithBalanceCheck } from './swapWithBalanceCheck.js';
|
|
66
|
-
import { buildSwapWithFeeExample } from './swapWithFee.js';
|
|
67
60
|
import { buildSwapWithOutputValidation } from './swapWithOutputValidation.js';
|
|
68
61
|
import { buildPartialTransfer, buildTransferTokens } from './transferTokens.js';
|
|
69
62
|
import { buildUntypedOpWithTypedRef } from './untypedOpWithTypedRef.js';
|
|
70
63
|
|
|
71
64
|
const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
|
|
72
65
|
'aave-repay': () =>
|
|
73
|
-
buildAaveRepay({
|
|
66
|
+
buildAaveRepay({
|
|
67
|
+
owner: OWNER,
|
|
68
|
+
collateralAmount: '1000000000',
|
|
69
|
+
borrowAmount: '100000000000000000',
|
|
70
|
+
repayAmount: '101000000000000000',
|
|
71
|
+
}).request,
|
|
74
72
|
'aave-repay-atoken': () =>
|
|
75
73
|
buildAaveRepayWithATokens({
|
|
76
74
|
owner: OWNER,
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
collateralAmount: '1000000000',
|
|
76
|
+
borrowAmount: '500000000',
|
|
79
77
|
}).request,
|
|
80
|
-
'aave-
|
|
81
|
-
buildAaveClaimRewards({ owner: OWNER, recipient: RECIPIENT }).request,
|
|
78
|
+
'aave-emode': () => buildAaveSetEMode({ owner: OWNER }).request,
|
|
82
79
|
'approve-deposit': () =>
|
|
83
80
|
buildApproveAndDeposit({ owner: OWNER, amount: '1000000000' }).request,
|
|
84
81
|
consolidate: () =>
|
|
@@ -105,7 +102,6 @@ const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
|
|
|
105
102
|
}).request,
|
|
106
103
|
'dust-sweep': () => buildDustSweepExample().request,
|
|
107
104
|
swap: () => buildLifiSwapExample().request,
|
|
108
|
-
'swap-fee': () => buildSwapWithFeeExample().request,
|
|
109
105
|
'split-zap': () => buildSplitAndZapExample().request,
|
|
110
106
|
'split-arithmetic': () =>
|
|
111
107
|
buildSplitWithArithmetic({ owner: OWNER, amount: '1000000000' }).request,
|
|
@@ -133,7 +129,6 @@ const EXAMPLES: Record<string, () => ComposeCompileRequest> = {
|
|
|
133
129
|
redeem: () =>
|
|
134
130
|
buildRedeemFromVault({ owner: OWNER, amount: '1000000000000000000' })
|
|
135
131
|
.request,
|
|
136
|
-
claim: () => buildClaimRewards({ owner: OWNER }).request,
|
|
137
132
|
'wrap-eth': () =>
|
|
138
133
|
buildWrapEth({ owner: OWNER, amount: '1000000000000000000' }).request,
|
|
139
134
|
transfer: () =>
|
|
@@ -190,7 +185,14 @@ const run = async () => {
|
|
|
190
185
|
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
191
186
|
|
|
192
187
|
console.log('--- Request ---');
|
|
193
|
-
console.log(
|
|
188
|
+
console.log(
|
|
189
|
+
JSON.stringify(
|
|
190
|
+
request,
|
|
191
|
+
(_key, value: unknown) =>
|
|
192
|
+
typeof value === 'bigint' ? value.toString() : value,
|
|
193
|
+
2,
|
|
194
|
+
),
|
|
195
|
+
);
|
|
194
196
|
|
|
195
197
|
console.log(`\n--- Compiling against ${BASE_URL} ---`);
|
|
196
198
|
const result = await sdk.client.compile(request);
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { SimulateResult } from '@lifi/compose-spec';
|
|
2
|
+
|
|
3
|
+
import { buildSimulateRequest, materialisers, resources } from '../index.js';
|
|
4
|
+
import type { ComposeSdk } from '../index.js';
|
|
5
|
+
|
|
6
|
+
import { OWNER } from './config.js';
|
|
7
|
+
|
|
8
|
+
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
9
|
+
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
10
|
+
|
|
11
|
+
// 1 WETH (18 decimals).
|
|
12
|
+
const ONE_WETH = 1_000_000_000_000_000_000n;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* End-to-end `/simulate` usage: compile a WETH→USDC swap, then simulate the
|
|
16
|
+
* compiled transaction to see how the signer's balances move and how much
|
|
17
|
+
* inner-call gas it burns — without broadcasting anything on-chain.
|
|
18
|
+
*
|
|
19
|
+
* Demonstrates the compile → simulate arc:
|
|
20
|
+
* - `buildSimulateRequest` lifts a `ComposeCompileResult` into a
|
|
21
|
+
* `SimulateRequest`, supplying the fields a compiled flow cannot carry: the
|
|
22
|
+
* target `chainId`, the `signer` (`from`), the funding `requirements`, and the
|
|
23
|
+
* `trackedBalances` to watch.
|
|
24
|
+
* - `sdk.simulate` runs it and returns a discriminated `ok | revert | error`
|
|
25
|
+
* result. A `revert` is a *successful simulation* whose execution reverted, so
|
|
26
|
+
* it is returned (not thrown); only transport/auth/5xx failures throw.
|
|
27
|
+
*
|
|
28
|
+
* Unlike the pure-builder examples, this performs network I/O through the
|
|
29
|
+
* injected `sdk` (one `/compose` call, one `/simulate` call). Pass a live
|
|
30
|
+
* `createComposeSdk({ baseUrl })` to run it for real, or a mock-backed SDK in
|
|
31
|
+
* tests.
|
|
32
|
+
*/
|
|
33
|
+
export const simulateCompiledSwap = async (
|
|
34
|
+
sdk: ComposeSdk,
|
|
35
|
+
): Promise<SimulateResult> => {
|
|
36
|
+
// Author and compile a single WETH → USDC swap on Ethereum mainnet.
|
|
37
|
+
const builder = sdk.flow(1, {
|
|
38
|
+
name: 'swap-weth-to-usdc',
|
|
39
|
+
inputs: { amountIn: resources.erc20(WETH, 1) },
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
builder.lifi.swap('swap', {
|
|
43
|
+
bind: { amountIn: builder.inputs.amountIn },
|
|
44
|
+
config: { resourceOut: resources.erc20(USDC, 1), slippage: 0.03 },
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const compiled = await builder.compile({
|
|
48
|
+
signer: OWNER,
|
|
49
|
+
inputs: {
|
|
50
|
+
amountIn: materialisers.directDeposit({ amount: ONE_WETH }),
|
|
51
|
+
},
|
|
52
|
+
sweepTo: builder.context.sender,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Lift the compiled transaction into a simulation request. The chain, signer,
|
|
56
|
+
// funding, and watched balances are NOT inferable from a compiled flow, so
|
|
57
|
+
// they are supplied here. `to`/`data`/`value` come from the compile result.
|
|
58
|
+
const request = buildSimulateRequest({
|
|
59
|
+
result: compiled,
|
|
60
|
+
chainId: 1,
|
|
61
|
+
signer: OWNER,
|
|
62
|
+
// Seed the signer with the 1 WETH the swap deposits, so the inner call has
|
|
63
|
+
// funds to pull. `bigint` amounts are serialised to decimal strings.
|
|
64
|
+
requirements: [
|
|
65
|
+
{ type: 'Erc20Balance', wallet: OWNER, token: WETH, balance: ONE_WETH },
|
|
66
|
+
],
|
|
67
|
+
// Watch the signer's WETH (spent) and USDC (received) balances; the response
|
|
68
|
+
// `deltas` come back ordered to match.
|
|
69
|
+
trackedBalances: [
|
|
70
|
+
{ token: WETH, owner: OWNER },
|
|
71
|
+
{ token: USDC, owner: OWNER },
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return sdk.simulate(request);
|
|
76
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { SimulateRequest } from '@lifi/compose-spec';
|
|
2
|
+
|
|
3
|
+
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
4
|
+
const SENDER = '0x1111111111111111111111111111111111111111';
|
|
5
|
+
const RECIPIENT = '0x2222222222222222222222222222222222222222';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Build a representative `POST /simulate` request: a USDC transfer of 1 USDC
|
|
9
|
+
* (1_000_000 base units at 6 decimals) from `SENDER` to `RECIPIENT` on chain 1.
|
|
10
|
+
*
|
|
11
|
+
* Demonstrates:
|
|
12
|
+
* - A pre-encoded `transfer(address,uint256)` calldata literal (`data`)
|
|
13
|
+
* - Funding the sender with an `Erc20Balance` requirement so the transfer can
|
|
14
|
+
* succeed in simulation (`bigint` amounts are accepted and serialised)
|
|
15
|
+
* - Watching both the sender's and recipient's USDC balance via `trackedBalances`
|
|
16
|
+
*
|
|
17
|
+
* Pure: returns a plain {@link SimulateRequest}, performs no network I/O. Pass
|
|
18
|
+
* it to `sdk.client.simulate(...)` / `sdk.simulate(...)` to run it.
|
|
19
|
+
*/
|
|
20
|
+
export const buildSimulateRawTransactionExample = (): SimulateRequest => ({
|
|
21
|
+
chainId: 1,
|
|
22
|
+
from: SENDER,
|
|
23
|
+
to: USDC,
|
|
24
|
+
// transfer(RECIPIENT, 1_000_000)
|
|
25
|
+
data: '0xa9059cbb0000000000000000000000002222222222222222222222222222222222222222000000000000000000000000000000000000000000000000000000000f4240',
|
|
26
|
+
value: 0n,
|
|
27
|
+
requirements: [
|
|
28
|
+
{
|
|
29
|
+
type: 'Erc20Balance',
|
|
30
|
+
wallet: SENDER,
|
|
31
|
+
token: USDC,
|
|
32
|
+
balance: 1_000_000n,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
trackedBalances: [
|
|
36
|
+
{ token: USDC, owner: SENDER },
|
|
37
|
+
{ token: USDC, owner: RECIPIENT },
|
|
38
|
+
],
|
|
39
|
+
});
|
|
@@ -1,25 +1,32 @@
|
|
|
1
1
|
import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
2
2
|
|
|
3
|
-
import { createComposeSdk,
|
|
3
|
+
import { createComposeSdk, raw } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
6
|
import { BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
//
|
|
10
|
-
const
|
|
8
|
+
// Real ERC-4626 vault (Steakhouse USDC on Ethereum mainnet) queried through
|
|
9
|
+
// the untyped escape hatch.
|
|
10
|
+
const VAULT = '0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB';
|
|
11
11
|
|
|
12
12
|
export interface UntypedOpWithTypedRefInput {
|
|
13
13
|
readonly owner: Address;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Insert an untyped operation node
|
|
18
|
-
*
|
|
17
|
+
* Insert an untyped operation node, then feed its output into typed builder
|
|
18
|
+
* methods using `raw.ref<T>()`.
|
|
19
|
+
*
|
|
20
|
+
* `untypedOp` is the escape hatch for ops the installed SDK's typed surface
|
|
21
|
+
* doesn't cover — typically backend ops newer than your SDK version. The op
|
|
22
|
+
* id is passed as a plain string and its bind/config shapes are not
|
|
23
|
+
* type-checked, so the backend validates them at compile time instead.
|
|
24
|
+
*
|
|
25
|
+
* This example routes a real op (`core.staticCall`) through the untyped path
|
|
26
|
+
* so the flow compiles end-to-end; the mechanism is identical for any op id.
|
|
19
27
|
*
|
|
20
28
|
* Demonstrates:
|
|
21
|
-
* - `builder.untypedOp()` to add a node the typed API doesn't cover
|
|
22
|
-
* (e.g. a custom vault query).
|
|
29
|
+
* - `builder.untypedOp()` to add a node the typed API doesn't cover.
|
|
23
30
|
* - `raw.ref<'uint256'>()` to reference the untyped node's output in a typed
|
|
24
31
|
* `Bindable<'uint256'>` slot — the explicit type parameter is required
|
|
25
32
|
* so the compiler verifies the ref is used in a compatible slot.
|
|
@@ -35,16 +42,17 @@ export const buildUntypedOpWithTypedRef = ({
|
|
|
35
42
|
|
|
36
43
|
const builder = sdk.flow(1, {
|
|
37
44
|
name: 'untyped-op-with-typed-ref',
|
|
38
|
-
inputs: {
|
|
39
|
-
amountIn: resources.erc20(USDC, 1),
|
|
40
|
-
},
|
|
45
|
+
inputs: {},
|
|
41
46
|
});
|
|
42
47
|
|
|
43
|
-
// Insert an untyped node
|
|
48
|
+
// Insert an untyped node querying the vault. untypedOp returns void —
|
|
44
49
|
// the typed builder has no knowledge of this node's outputs.
|
|
45
|
-
builder.untypedOp('vault-query', '
|
|
46
|
-
bind: {
|
|
47
|
-
config: {
|
|
50
|
+
builder.untypedOp('vault-query', 'core.staticCall', {
|
|
51
|
+
bind: {},
|
|
52
|
+
config: {
|
|
53
|
+
target: VAULT,
|
|
54
|
+
functionSignature: 'function totalAssets() view returns (uint256)',
|
|
55
|
+
},
|
|
48
56
|
});
|
|
49
57
|
|
|
50
58
|
// Use raw.ref to bridge the untyped node's output into a typed operation.
|
|
@@ -60,17 +68,15 @@ export const buildUntypedOpWithTypedRef = ({
|
|
|
60
68
|
|
|
61
69
|
// Continue with fully typed operations downstream.
|
|
62
70
|
builder.core.assertGte('check-min', {
|
|
63
|
-
bind: { a: scaled.result, b:
|
|
71
|
+
bind: { a: scaled.result, b: vaultResult },
|
|
64
72
|
});
|
|
65
73
|
|
|
66
74
|
const flow = builder.build();
|
|
67
75
|
|
|
76
|
+
// No sweepTo: the flow reads state and asserts — it produces no resources.
|
|
68
77
|
const request = sdk.request(flow, {
|
|
69
78
|
signer: owner,
|
|
70
|
-
inputs: {
|
|
71
|
-
amountIn: materialisers.directDeposit({ amount: '1000000' }),
|
|
72
|
-
},
|
|
73
|
-
sweepTo: builder.context.sender,
|
|
79
|
+
inputs: {},
|
|
74
80
|
});
|
|
75
81
|
|
|
76
82
|
return { flow, request };
|
|
@@ -55,6 +55,40 @@ export interface LifiSwapConfig {
|
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
export interface InvariantNumericConfig {
|
|
59
|
+
op: 'gte' | 'gt' | 'lte' | 'lt' | 'eq' | 'neq';
|
|
60
|
+
threshold: IntegerStringInput;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface InvariantNumericInRangeConfig {
|
|
64
|
+
min: IntegerStringInput;
|
|
65
|
+
max: IntegerStringInput;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface InvariantGteConfig {
|
|
69
|
+
threshold: IntegerStringInput;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface InvariantGtConfig {
|
|
73
|
+
threshold: IntegerStringInput;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface InvariantLteConfig {
|
|
77
|
+
threshold: IntegerStringInput;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface InvariantLtConfig {
|
|
81
|
+
threshold: IntegerStringInput;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface InvariantEqConfig {
|
|
85
|
+
threshold: IntegerStringInput;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface InvariantNeqConfig {
|
|
89
|
+
threshold: IntegerStringInput;
|
|
90
|
+
}
|
|
91
|
+
|
|
58
92
|
export interface CoreBpsDownConfig {
|
|
59
93
|
bps: number;
|
|
60
94
|
}
|
|
@@ -76,23 +110,155 @@ export interface CoreTransferConfig {
|
|
|
76
110
|
amount?: IntegerStringInput;
|
|
77
111
|
}
|
|
78
112
|
|
|
113
|
+
export interface CoreEmitEvent1Config {
|
|
114
|
+
signature: string;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface CoreEmitEvent2Config {
|
|
118
|
+
signature: string;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface CoreEmitEvent3Config {
|
|
122
|
+
signature: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface CoreEmitEvent4Config {
|
|
126
|
+
signature: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* a string at most 65536 character(s) long
|
|
131
|
+
*/
|
|
132
|
+
export type MaxLength65536 = string;
|
|
133
|
+
|
|
79
134
|
export interface CoreCallConfig {
|
|
80
135
|
target: Address;
|
|
81
136
|
functionSignature: string;
|
|
82
137
|
callType?: 'Call' | 'ValueCall';
|
|
83
|
-
args?:
|
|
138
|
+
args?: (
|
|
139
|
+
| (
|
|
140
|
+
| MaxLength65536
|
|
141
|
+
| number
|
|
142
|
+
| boolean
|
|
143
|
+
| {
|
|
144
|
+
$ref: string;
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
| (
|
|
148
|
+
| (
|
|
149
|
+
| MaxLength65536
|
|
150
|
+
| number
|
|
151
|
+
| boolean
|
|
152
|
+
| {
|
|
153
|
+
$ref: string;
|
|
154
|
+
}
|
|
155
|
+
)
|
|
156
|
+
| (
|
|
157
|
+
| (
|
|
158
|
+
| MaxLength65536
|
|
159
|
+
| number
|
|
160
|
+
| boolean
|
|
161
|
+
| {
|
|
162
|
+
$ref: string;
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
| (
|
|
166
|
+
| (
|
|
167
|
+
| MaxLength65536
|
|
168
|
+
| number
|
|
169
|
+
| boolean
|
|
170
|
+
| {
|
|
171
|
+
$ref: string;
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
| (
|
|
175
|
+
| (
|
|
176
|
+
| MaxLength65536
|
|
177
|
+
| number
|
|
178
|
+
| boolean
|
|
179
|
+
| {
|
|
180
|
+
$ref: string;
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
| (
|
|
184
|
+
| MaxLength65536
|
|
185
|
+
| number
|
|
186
|
+
| boolean
|
|
187
|
+
| {
|
|
188
|
+
$ref: string;
|
|
189
|
+
}
|
|
190
|
+
)[]
|
|
191
|
+
)[]
|
|
192
|
+
)[]
|
|
193
|
+
)[]
|
|
194
|
+
)[]
|
|
195
|
+
)[];
|
|
84
196
|
approvals?: {
|
|
85
197
|
spender: Address;
|
|
86
198
|
}[];
|
|
87
199
|
}
|
|
88
|
-
export interface Unknown {
|
|
89
|
-
[k: string]: unknown;
|
|
90
|
-
}
|
|
91
200
|
|
|
92
201
|
export interface CoreStaticCallConfig {
|
|
93
202
|
target: Address;
|
|
94
203
|
functionSignature: string;
|
|
95
|
-
args?:
|
|
204
|
+
args?: (
|
|
205
|
+
| (
|
|
206
|
+
| MaxLength65536
|
|
207
|
+
| number
|
|
208
|
+
| boolean
|
|
209
|
+
| {
|
|
210
|
+
$ref: string;
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
| (
|
|
214
|
+
| (
|
|
215
|
+
| MaxLength65536
|
|
216
|
+
| number
|
|
217
|
+
| boolean
|
|
218
|
+
| {
|
|
219
|
+
$ref: string;
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
| (
|
|
223
|
+
| (
|
|
224
|
+
| MaxLength65536
|
|
225
|
+
| number
|
|
226
|
+
| boolean
|
|
227
|
+
| {
|
|
228
|
+
$ref: string;
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
| (
|
|
232
|
+
| (
|
|
233
|
+
| MaxLength65536
|
|
234
|
+
| number
|
|
235
|
+
| boolean
|
|
236
|
+
| {
|
|
237
|
+
$ref: string;
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
| (
|
|
241
|
+
| (
|
|
242
|
+
| MaxLength65536
|
|
243
|
+
| number
|
|
244
|
+
| boolean
|
|
245
|
+
| {
|
|
246
|
+
$ref: string;
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
| (
|
|
250
|
+
| MaxLength65536
|
|
251
|
+
| number
|
|
252
|
+
| boolean
|
|
253
|
+
| {
|
|
254
|
+
$ref: string;
|
|
255
|
+
}
|
|
256
|
+
)[]
|
|
257
|
+
)[]
|
|
258
|
+
)[]
|
|
259
|
+
)[]
|
|
260
|
+
)[]
|
|
261
|
+
)[];
|
|
96
262
|
}
|
|
97
263
|
|
|
98
264
|
export interface CoreRawCallConfig {
|
|
@@ -106,7 +272,64 @@ export interface CoreInvokeConfig {
|
|
|
106
272
|
target: Address;
|
|
107
273
|
functionSignature: string;
|
|
108
274
|
callType?: 'Call' | 'ValueCall';
|
|
109
|
-
args?:
|
|
275
|
+
args?: (
|
|
276
|
+
| (
|
|
277
|
+
| MaxLength65536
|
|
278
|
+
| number
|
|
279
|
+
| boolean
|
|
280
|
+
| {
|
|
281
|
+
$ref: string;
|
|
282
|
+
}
|
|
283
|
+
)
|
|
284
|
+
| (
|
|
285
|
+
| (
|
|
286
|
+
| MaxLength65536
|
|
287
|
+
| number
|
|
288
|
+
| boolean
|
|
289
|
+
| {
|
|
290
|
+
$ref: string;
|
|
291
|
+
}
|
|
292
|
+
)
|
|
293
|
+
| (
|
|
294
|
+
| (
|
|
295
|
+
| MaxLength65536
|
|
296
|
+
| number
|
|
297
|
+
| boolean
|
|
298
|
+
| {
|
|
299
|
+
$ref: string;
|
|
300
|
+
}
|
|
301
|
+
)
|
|
302
|
+
| (
|
|
303
|
+
| (
|
|
304
|
+
| MaxLength65536
|
|
305
|
+
| number
|
|
306
|
+
| boolean
|
|
307
|
+
| {
|
|
308
|
+
$ref: string;
|
|
309
|
+
}
|
|
310
|
+
)
|
|
311
|
+
| (
|
|
312
|
+
| (
|
|
313
|
+
| MaxLength65536
|
|
314
|
+
| number
|
|
315
|
+
| boolean
|
|
316
|
+
| {
|
|
317
|
+
$ref: string;
|
|
318
|
+
}
|
|
319
|
+
)
|
|
320
|
+
| (
|
|
321
|
+
| MaxLength65536
|
|
322
|
+
| number
|
|
323
|
+
| boolean
|
|
324
|
+
| {
|
|
325
|
+
$ref: string;
|
|
326
|
+
}
|
|
327
|
+
)[]
|
|
328
|
+
)[]
|
|
329
|
+
)[]
|
|
330
|
+
)[]
|
|
331
|
+
)[]
|
|
332
|
+
)[];
|
|
110
333
|
}
|
|
111
334
|
|
|
112
335
|
export interface CoreAsResourceConfig {
|
|
@@ -10,7 +10,6 @@ import type {
|
|
|
10
10
|
BalanceOfMaterialiserConfig as BalanceOfMaterialiserConfigSchema,
|
|
11
11
|
CallMaterialiserConfig as CallMaterialiserConfigSchema,
|
|
12
12
|
DirectDepositMaterialiserConfig as DirectDepositMaterialiserConfigSchema,
|
|
13
|
-
FlashloanMaterialiserConfig as FlashloanMaterialiserConfigSchema,
|
|
14
13
|
} from './config.generated.js';
|
|
15
14
|
|
|
16
15
|
export type BalanceOfMaterialiserConfig =
|
|
@@ -43,14 +42,3 @@ export const call = (config: CallMaterialiserConfig): MaterialiserInput => ({
|
|
|
43
42
|
kind: 'call',
|
|
44
43
|
...config,
|
|
45
44
|
});
|
|
46
|
-
|
|
47
|
-
export type FlashloanMaterialiserConfig =
|
|
48
|
-
MaterialiserConfigOf<FlashloanMaterialiserConfigSchema>;
|
|
49
|
-
|
|
50
|
-
/** Borrow tokens from a flashloan provider; amount becomes a register populated by the proxy at callback time — accepts: resource */
|
|
51
|
-
export const flashloan = (
|
|
52
|
-
config: FlashloanMaterialiserConfig,
|
|
53
|
-
): MaterialiserInput => ({
|
|
54
|
-
kind: 'flashloan',
|
|
55
|
-
...config,
|
|
56
|
-
});
|