@lifi/composer-sdk 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/dist/client.cjs +9 -3
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +9 -3
- package/dist/client.js.map +1 -1
- package/dist/generated/config.generated.cjs.map +1 -1
- package/dist/generated/config.generated.d.cts +37 -14
- package/dist/generated/config.generated.d.ts +37 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/sdk.cjs.map +1 -1
- package/dist/sdk.d.cts +5 -5
- package/dist/sdk.d.ts +5 -5
- package/dist/sdk.js.map +1 -1
- package/package.json +3 -3
- package/src/client.ts +10 -5
- package/src/examples/aaveClaimRewards.ts +2 -2
- package/src/examples/aaveRepay.ts +2 -2
- package/src/examples/aaveRepayWithATokens.ts +2 -2
- package/src/examples/aaveSetEMode.ts +2 -2
- package/src/examples/approveAndDeposit.ts +2 -2
- package/src/examples/callContract.ts +4 -4
- package/src/examples/config.ts +4 -1
- package/src/examples/consolidateToEth.ts +2 -2
- package/src/examples/consolidateToUsdc.ts +2 -2
- package/src/examples/depositFromProxy.ts +2 -2
- package/src/examples/dustSweep.ts +2 -2
- package/src/examples/emitCustomEvent.ts +2 -2
- package/src/examples/invariantChecks.ts +2 -2
- package/src/examples/lifiSwap.ts +2 -2
- package/src/examples/lifiZap.ts +2 -2
- package/src/examples/rawCallWithArithmetic.ts +2 -2
- package/src/examples/readContractState.ts +2 -2
- package/src/examples/splitAndZap.ts +2 -2
- package/src/examples/splitWithArithmetic.ts +2 -2
- package/src/examples/swapAndZap.ts +2 -2
- package/src/examples/swapToRecipient.ts +2 -2
- package/src/examples/swapWithAllowRevert.ts +3 -3
- package/src/examples/swapWithBalanceCheck.ts +2 -2
- package/src/examples/swapWithFee.ts +2 -2
- package/src/examples/swapWithOutputValidation.ts +2 -2
- package/src/examples/transferTokens.ts +3 -3
- package/src/examples/untypedOpWithTypedRef.ts +2 -2
- package/src/generated/config.generated.ts +42 -14
- package/src/index.ts +6 -0
- package/src/sdk.ts +5 -5
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
resources,
|
|
8
8
|
} from '../index.js';
|
|
9
9
|
|
|
10
|
-
import { BASE_URL, OWNER } from './config.js';
|
|
10
|
+
import { API_KEY, BASE_URL, OWNER } from './config.js';
|
|
11
11
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
12
12
|
// Aave v3 aEthUSDC receipt token on Ethereum mainnet
|
|
13
13
|
const A_ETH_USDC = '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c';
|
|
@@ -26,7 +26,7 @@ export const buildSplitAndZapExample = (): {
|
|
|
26
26
|
flow: Flow;
|
|
27
27
|
request: ComposeCompileRequest;
|
|
28
28
|
} => {
|
|
29
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
29
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
30
30
|
|
|
31
31
|
const builder = sdk.flow(1, {
|
|
32
32
|
name: 'split-usdc-to-two-vaults',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ export const buildSplitWithArithmetic = ({
|
|
|
29
29
|
flow: Flow;
|
|
30
30
|
request: ComposeCompileRequest;
|
|
31
31
|
} => {
|
|
32
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
32
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
33
33
|
|
|
34
34
|
const builder = sdk.flow(1, {
|
|
35
35
|
name: 'split-with-arithmetic',
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
resources,
|
|
8
8
|
} from '../index.js';
|
|
9
9
|
|
|
10
|
-
import { BASE_URL, OWNER } from './config.js';
|
|
10
|
+
import { API_KEY, BASE_URL, OWNER } from './config.js';
|
|
11
11
|
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
12
12
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
13
13
|
// Aave aEthUSDC receipt token on Ethereum mainnet
|
|
@@ -25,7 +25,7 @@ export const buildSwapAndZapExample = (): {
|
|
|
25
25
|
flow: Flow;
|
|
26
26
|
request: ComposeCompileRequest;
|
|
27
27
|
} => {
|
|
28
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
28
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
29
29
|
|
|
30
30
|
// Declare the flow with a single WETH input on Ethereum mainnet.
|
|
31
31
|
const builder = sdk.flow(1, {
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
9
9
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
@@ -35,7 +35,7 @@ export const buildSwapToRecipient = ({
|
|
|
35
35
|
flow: Flow;
|
|
36
36
|
request: ComposeCompileRequest;
|
|
37
37
|
} => {
|
|
38
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
38
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
39
39
|
|
|
40
40
|
// Declare the flow on Ethereum mainnet with two token inputs and one address input.
|
|
41
41
|
const builder = sdk.flow(1, {
|
|
@@ -2,7 +2,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
2
2
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
|
|
5
|
-
import { BASE_URL, OWNER } from './config.js';
|
|
5
|
+
import { API_KEY, BASE_URL, OWNER } from './config.js';
|
|
6
6
|
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
7
7
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@ export const buildSwapWithAllowRevertExample = (): {
|
|
|
25
25
|
flow: Flow;
|
|
26
26
|
request: ComposeCompileRequest;
|
|
27
27
|
} => {
|
|
28
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
28
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
29
29
|
|
|
30
30
|
const builder = sdk.flow(1, {
|
|
31
31
|
name: 'swap-weth-to-usdc-allow-revert',
|
|
@@ -70,7 +70,7 @@ export const buildSwapWithAllowRevertExample = (): {
|
|
|
70
70
|
* but demonstrates the branching pattern callers should use.
|
|
71
71
|
*/
|
|
72
72
|
export const handleCompileResult = async (): Promise<void> => {
|
|
73
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
73
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
74
74
|
|
|
75
75
|
const builder = sdk.flow(1, {
|
|
76
76
|
inputs: { amountIn: resources.erc20(WETH, 1) },
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
9
9
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
@@ -29,7 +29,7 @@ export const buildSwapWithBalanceCheck = ({
|
|
|
29
29
|
flow: Flow;
|
|
30
30
|
request: ComposeCompileRequest;
|
|
31
31
|
} => {
|
|
32
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
32
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
33
33
|
|
|
34
34
|
// Declare the flow with a single WETH input on Ethereum mainnet.
|
|
35
35
|
const builder = sdk.flow(1, {
|
|
@@ -2,7 +2,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
2
2
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
|
|
5
|
-
import { BASE_URL, OWNER } from './config.js';
|
|
5
|
+
import { API_KEY, BASE_URL, OWNER } from './config.js';
|
|
6
6
|
|
|
7
7
|
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
8
8
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
@@ -22,7 +22,7 @@ export const buildSwapWithFeeExample = (): {
|
|
|
22
22
|
flow: Flow;
|
|
23
23
|
request: ComposeCompileRequest;
|
|
24
24
|
} => {
|
|
25
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
25
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
26
26
|
|
|
27
27
|
// Declare the flow with a single WETH input on Ethereum mainnet.
|
|
28
28
|
const builder = sdk.flow(1, {
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2';
|
|
9
9
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
@@ -31,7 +31,7 @@ export const buildSwapWithOutputValidation = ({
|
|
|
31
31
|
flow: Flow;
|
|
32
32
|
request: ComposeCompileRequest;
|
|
33
33
|
} => {
|
|
34
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
34
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
35
35
|
|
|
36
36
|
const builder = sdk.flow(1, {
|
|
37
37
|
name: 'swap-with-output-validation',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, materialisers, resources } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48';
|
|
9
9
|
|
|
@@ -31,7 +31,7 @@ export const buildTransferTokens = ({
|
|
|
31
31
|
flow: Flow;
|
|
32
32
|
request: ComposeCompileRequest;
|
|
33
33
|
} => {
|
|
34
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
34
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
35
35
|
|
|
36
36
|
const builder = sdk.flow(1, {
|
|
37
37
|
name: 'transfer-usdc',
|
|
@@ -79,7 +79,7 @@ export const buildPartialTransfer = ({
|
|
|
79
79
|
flow: Flow;
|
|
80
80
|
request: ComposeCompileRequest;
|
|
81
81
|
} => {
|
|
82
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
82
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
83
83
|
|
|
84
84
|
const builder = sdk.flow(1, {
|
|
85
85
|
name: 'partial-transfer-usdc',
|
|
@@ -3,7 +3,7 @@ import type { ComposeCompileRequest, Flow } from '@lifi/compose-spec';
|
|
|
3
3
|
import { createComposeSdk, raw } from '../index.js';
|
|
4
4
|
import type { Address } from '../types.js';
|
|
5
5
|
|
|
6
|
-
import { BASE_URL } from './config.js';
|
|
6
|
+
import { API_KEY, BASE_URL } from './config.js';
|
|
7
7
|
|
|
8
8
|
// Real ERC-4626 vault (Steakhouse USDC on Ethereum mainnet) queried through
|
|
9
9
|
// the untyped escape hatch.
|
|
@@ -38,7 +38,7 @@ export const buildUntypedOpWithTypedRef = ({
|
|
|
38
38
|
flow: Flow;
|
|
39
39
|
request: ComposeCompileRequest;
|
|
40
40
|
} => {
|
|
41
|
-
const sdk = createComposeSdk({ baseUrl: BASE_URL });
|
|
41
|
+
const sdk = createComposeSdk({ baseUrl: BASE_URL, apiKey: API_KEY });
|
|
42
42
|
|
|
43
43
|
const builder = sdk.flow(1, {
|
|
44
44
|
name: 'untyped-op-with-typed-ref',
|
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
import type { Address, IntegerStringInput } from '../types.js';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* a number between 0 and 10000
|
|
8
|
+
*/
|
|
9
|
+
export type Between010000 = number;
|
|
10
|
+
|
|
6
11
|
export interface CoreSplitConfig {
|
|
7
|
-
bps:
|
|
12
|
+
bps: Between010000;
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
/**
|
|
@@ -89,12 +94,17 @@ export interface InvariantNeqConfig {
|
|
|
89
94
|
threshold: IntegerStringInput;
|
|
90
95
|
}
|
|
91
96
|
|
|
97
|
+
/**
|
|
98
|
+
* a non-negative number
|
|
99
|
+
*/
|
|
100
|
+
export type NonNegative = number;
|
|
101
|
+
|
|
92
102
|
export interface CoreBpsDownConfig {
|
|
93
|
-
bps:
|
|
103
|
+
bps: NonNegative;
|
|
94
104
|
}
|
|
95
105
|
|
|
96
106
|
export interface CoreBpsUpConfig {
|
|
97
|
-
bps:
|
|
107
|
+
bps: NonNegative;
|
|
98
108
|
}
|
|
99
109
|
|
|
100
110
|
export interface CoreApproveConfig {
|
|
@@ -634,6 +644,33 @@ export interface LifiFlashloanRepayConfig {
|
|
|
634
644
|
fee?: string;
|
|
635
645
|
}
|
|
636
646
|
|
|
647
|
+
export type ContinuationAssertReadyConfig =
|
|
648
|
+
| {
|
|
649
|
+
kind: 'erc20BalanceGte';
|
|
650
|
+
chainId: Positive;
|
|
651
|
+
token: StartsWith0X;
|
|
652
|
+
owner: StartsWith0X;
|
|
653
|
+
minAmount: string;
|
|
654
|
+
}
|
|
655
|
+
| {
|
|
656
|
+
kind: 'nativeBalanceGte';
|
|
657
|
+
chainId: Positive;
|
|
658
|
+
owner: StartsWith0X;
|
|
659
|
+
minAmount: string;
|
|
660
|
+
}
|
|
661
|
+
| {
|
|
662
|
+
kind: 'call';
|
|
663
|
+
chainId: Positive;
|
|
664
|
+
to: StartsWith0X;
|
|
665
|
+
calldata: StartsWith0X;
|
|
666
|
+
comparator: 'gte' | 'eq' | 'lte';
|
|
667
|
+
value: string;
|
|
668
|
+
};
|
|
669
|
+
/**
|
|
670
|
+
* a string starting with "0x"
|
|
671
|
+
*/
|
|
672
|
+
export type StartsWith0X = string;
|
|
673
|
+
|
|
637
674
|
export interface LifiZapConfig {
|
|
638
675
|
resourceOut:
|
|
639
676
|
| {
|
|
@@ -647,15 +684,6 @@ export interface LifiZapConfig {
|
|
|
647
684
|
};
|
|
648
685
|
}
|
|
649
686
|
|
|
650
|
-
/**
|
|
651
|
-
* a non-negative number
|
|
652
|
-
*/
|
|
653
|
-
export type GreaterThanOrEqualTo0 = number;
|
|
654
|
-
/**
|
|
655
|
-
* a number between 0 and 10000
|
|
656
|
-
*/
|
|
657
|
-
export type Between010000 = number;
|
|
658
|
-
|
|
659
687
|
export interface ParaswapBuyConfig {
|
|
660
688
|
resourceOut:
|
|
661
689
|
| {
|
|
@@ -668,8 +696,8 @@ export interface ParaswapBuyConfig {
|
|
|
668
696
|
chainId: Positive;
|
|
669
697
|
};
|
|
670
698
|
exactAmountOut: string;
|
|
671
|
-
srcDecimals:
|
|
672
|
-
destDecimals:
|
|
699
|
+
srcDecimals: NonNegative;
|
|
700
|
+
destDecimals: NonNegative;
|
|
673
701
|
maxSlippageBps?: Between010000;
|
|
674
702
|
partner?: string;
|
|
675
703
|
partnerAddress?: string;
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,12 @@ export type {
|
|
|
63
63
|
Erc20BalanceRequirement,
|
|
64
64
|
NativeBalanceRequirement,
|
|
65
65
|
Erc20AllowanceRequirement,
|
|
66
|
+
ContinuationIntent,
|
|
67
|
+
ContinuationOutcome,
|
|
68
|
+
Check,
|
|
69
|
+
CheckComparator,
|
|
70
|
+
Phase1ArtifactWire,
|
|
71
|
+
ContinuationPlanWire,
|
|
66
72
|
} from '@lifi/compose-spec';
|
|
67
73
|
export {
|
|
68
74
|
SIMULATE_MAX_TRACKED_BALANCES,
|
package/src/sdk.ts
CHANGED
|
@@ -63,8 +63,8 @@ export interface ComposeSdkOptions {
|
|
|
63
63
|
readonly baseUrl: string;
|
|
64
64
|
/** Optional custom `fetch` implementation. Defaults to `globalThis.fetch`. */
|
|
65
65
|
readonly fetch?: typeof globalThis.fetch;
|
|
66
|
-
/**
|
|
67
|
-
readonly apiKey
|
|
66
|
+
/** LI.FI API key, sent as the `x-lifi-api-key` header on every request. Required — the Compose API rejects unauthenticated requests. */
|
|
67
|
+
readonly apiKey: string;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
/**
|
|
@@ -77,7 +77,7 @@ export interface ComposeSdkOptions {
|
|
|
77
77
|
* ```ts
|
|
78
78
|
* import { createComposeSdk, resources, materialisers } from '@lifi/composer-sdk';
|
|
79
79
|
*
|
|
80
|
-
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });
|
|
80
|
+
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });
|
|
81
81
|
*
|
|
82
82
|
* const builder = sdk.flow(1, {
|
|
83
83
|
* inputs: { usdc: resources.erc20('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 1) },
|
|
@@ -136,12 +136,12 @@ export interface ComposeSdk {
|
|
|
136
136
|
/**
|
|
137
137
|
* Creates a new Compose SDK instance.
|
|
138
138
|
*
|
|
139
|
-
* @param options - SDK configuration including the API base URL and optional fetch implementation.
|
|
139
|
+
* @param options - SDK configuration including the API base URL, required API key, and optional fetch implementation.
|
|
140
140
|
* @returns A {@link ComposeSdk} instance.
|
|
141
141
|
*
|
|
142
142
|
* @example
|
|
143
143
|
* ```ts
|
|
144
|
-
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest' });
|
|
144
|
+
* const sdk = createComposeSdk({ baseUrl: 'https://li.quest', apiKey: 'YOUR_API_KEY' });
|
|
145
145
|
* ```
|
|
146
146
|
*/
|
|
147
147
|
export const createComposeSdk = (options: ComposeSdkOptions): ComposeSdk => {
|