@chainflip/sdk 1.4.4 → 1.5.0-alpha.1
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/dist/{broker-PBJJVRH4.mjs → broker-4AIV4KDP.mjs} +12 -6
- package/dist/{chunk-JHVSTX24.mjs → chunk-HWJAHLL7.mjs} +11 -4
- package/dist/funding.d.mts +1 -1
- package/dist/funding.d.ts +1 -1
- package/dist/swap.d.mts +34 -13
- package/dist/swap.d.ts +34 -13
- package/dist/swap.js +1417 -20
- package/dist/swap.mjs +1392 -13
- package/package.json +2 -2
- /package/dist/{contracts-Maix4eRX.d.mts → contracts-Cb-5VdIi.d.mts} +0 -0
- /package/dist/{contracts-Maix4eRX.d.ts → contracts-Cb-5VdIi.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z, assetAndChain, numericString, hexString, btcAddress,
|
|
1
|
+
import { z, assetAndChain, numericString, hexString, btcAddress, ccmParamsSchema, affiliateBroker, fillOrKillParams, dotAddress, ethereumAddress } from './chunk-HWJAHLL7.mjs';
|
|
2
2
|
import { __name, Chains } from './chunk-3V7QJANN.mjs';
|
|
3
3
|
import { HttpClient } from '@chainflip/rpc';
|
|
4
4
|
import { bytesToHex } from '@chainflip/utils/bytes';
|
|
@@ -19,7 +19,7 @@ var validateRequest = /* @__PURE__ */ __name((network, params) => z.tuple([
|
|
|
19
19
|
btcAddress(network)
|
|
20
20
|
]),
|
|
21
21
|
z.number(),
|
|
22
|
-
|
|
22
|
+
ccmParamsSchema.merge(z.object({
|
|
23
23
|
cfParameters: z.union([
|
|
24
24
|
hexString,
|
|
25
25
|
z.string()
|
|
@@ -30,7 +30,12 @@ var validateRequest = /* @__PURE__ */ __name((network, params) => z.tuple([
|
|
|
30
30
|
gas_budget: `0x${BigInt(rest.gasBudget).toString(16)}`
|
|
31
31
|
})).optional(),
|
|
32
32
|
z.number().optional(),
|
|
33
|
-
z.array(affiliateBroker).optional()
|
|
33
|
+
z.array(affiliateBroker).optional(),
|
|
34
|
+
fillOrKillParams.transform(({ retryDurationBlocks, refundAddress, minPriceX128 }) => ({
|
|
35
|
+
retry_duration: retryDurationBlocks,
|
|
36
|
+
refund_address: refundAddress,
|
|
37
|
+
min_price: `0x${BigInt(minPriceX128).toString(16)}`
|
|
38
|
+
})).optional()
|
|
34
39
|
]).parse(params), "validateRequest");
|
|
35
40
|
var validateResponse = /* @__PURE__ */ __name((network, response) => z.object({
|
|
36
41
|
address: z.union([
|
|
@@ -63,12 +68,13 @@ async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork) {
|
|
|
63
68
|
},
|
|
64
69
|
submitAddress(destChain, destAddress),
|
|
65
70
|
swapRequest.commissionBps ?? 0,
|
|
66
|
-
swapRequest.
|
|
67
|
-
...swapRequest.
|
|
71
|
+
swapRequest.ccmParams && {
|
|
72
|
+
...swapRequest.ccmParams,
|
|
68
73
|
cfParameters: void 0
|
|
69
74
|
},
|
|
70
75
|
maxBoostFeeBps,
|
|
71
|
-
swapRequest.affiliates
|
|
76
|
+
swapRequest.affiliates,
|
|
77
|
+
swapRequest.fillOrKillParams
|
|
72
78
|
]);
|
|
73
79
|
const response = await client.sendRequest("broker_requestSwapDepositAddress", ...params);
|
|
74
80
|
return validateResponse(chainflipNetwork, response);
|
|
@@ -4442,7 +4442,7 @@ z.object({
|
|
|
4442
4442
|
brokerCommissionBps: args.brokerCommissionBps
|
|
4443
4443
|
};
|
|
4444
4444
|
});
|
|
4445
|
-
var
|
|
4445
|
+
var ccmParamsSchema = z.object({
|
|
4446
4446
|
gasBudget: numericString,
|
|
4447
4447
|
message: hexStringWithMaxByteSize(1024 * 10)
|
|
4448
4448
|
});
|
|
@@ -4453,6 +4453,11 @@ var affiliateBroker = z.object({
|
|
|
4453
4453
|
account,
|
|
4454
4454
|
bps
|
|
4455
4455
|
}));
|
|
4456
|
+
var fillOrKillParams = z.object({
|
|
4457
|
+
retryDurationBlocks: number,
|
|
4458
|
+
refundAddress: z.string(),
|
|
4459
|
+
minPriceX128: numericString
|
|
4460
|
+
});
|
|
4456
4461
|
z.object({
|
|
4457
4462
|
srcAsset: asset,
|
|
4458
4463
|
destAsset: asset,
|
|
@@ -4460,12 +4465,14 @@ z.object({
|
|
|
4460
4465
|
destChain: chain,
|
|
4461
4466
|
destAddress: z.string(),
|
|
4462
4467
|
amount: numericString,
|
|
4463
|
-
ccmMetadata:
|
|
4468
|
+
ccmMetadata: ccmParamsSchema.optional(),
|
|
4469
|
+
ccmParams: ccmParamsSchema.optional(),
|
|
4464
4470
|
maxBoostFeeBps: z.number().optional(),
|
|
4465
|
-
srcAddress: z.string().optional()
|
|
4471
|
+
srcAddress: z.string().optional(),
|
|
4472
|
+
fillOrKillParams: fillOrKillParams.optional()
|
|
4466
4473
|
}).transform(({ amount, ...rest }) => ({
|
|
4467
4474
|
...rest,
|
|
4468
4475
|
expectedDepositAmount: amount
|
|
4469
4476
|
}));
|
|
4470
4477
|
|
|
4471
|
-
export { affiliateBroker, assertValidAddress, assetAndChain, btcAddress,
|
|
4478
|
+
export { affiliateBroker, assertValidAddress, assetAndChain, btcAddress, ccmParamsSchema, dotAddress, ethereumAddress, fillOrKillParams, hexString, numericString, z };
|
package/dist/funding.d.mts
CHANGED
package/dist/funding.d.ts
CHANGED
package/dist/swap.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-
|
|
3
|
-
export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-
|
|
2
|
+
import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-Cb-5VdIi.mjs';
|
|
3
|
+
export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-Cb-5VdIi.mjs';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
-
declare const
|
|
6
|
+
declare const ccmParamsSchema: z.ZodObject<{
|
|
7
7
|
gasBudget: z.ZodString;
|
|
8
8
|
message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -13,7 +13,7 @@ declare const ccmMetadataSchema: z.ZodObject<{
|
|
|
13
13
|
message: string;
|
|
14
14
|
gasBudget: string;
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
16
|
+
type CcmParams = z.infer<typeof ccmParamsSchema>;
|
|
17
17
|
declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
|
|
18
18
|
account: z.ZodEffects<z.ZodString, string, string>;
|
|
19
19
|
commissionBps: z.ZodNumber;
|
|
@@ -31,6 +31,23 @@ declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
|
|
|
31
31
|
commissionBps: number;
|
|
32
32
|
}>;
|
|
33
33
|
type AffiliateBroker = z.input<typeof affiliateBroker>;
|
|
34
|
+
declare const fillOrKillParams: z.ZodObject<{
|
|
35
|
+
retryDurationBlocks: z.ZodNumber;
|
|
36
|
+
refundAddress: z.ZodString;
|
|
37
|
+
minPriceX128: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
retryDurationBlocks: number;
|
|
40
|
+
refundAddress: string;
|
|
41
|
+
minPriceX128: string;
|
|
42
|
+
}, {
|
|
43
|
+
retryDurationBlocks: number;
|
|
44
|
+
refundAddress: string;
|
|
45
|
+
minPriceX128: string;
|
|
46
|
+
}>;
|
|
47
|
+
type FillOrKillParamsX128 = z.input<typeof fillOrKillParams>;
|
|
48
|
+
type FillOrKillParams = Omit<FillOrKillParamsX128, 'minPriceX128'> & {
|
|
49
|
+
minPrice: string;
|
|
50
|
+
};
|
|
34
51
|
type Fee<T> = {
|
|
35
52
|
type: T;
|
|
36
53
|
chain: Chain;
|
|
@@ -51,6 +68,7 @@ type QuoteDetails = {
|
|
|
51
68
|
poolInfo: PoolInfo[];
|
|
52
69
|
lowLiquidityWarning: boolean | undefined;
|
|
53
70
|
estimatedDurationSeconds: number;
|
|
71
|
+
estimatedPrice: string;
|
|
54
72
|
};
|
|
55
73
|
type BoostedQuoteDetails = QuoteDetails & {
|
|
56
74
|
estimatedBoostFeeBps: number;
|
|
@@ -66,7 +84,8 @@ interface ExecuteSwapParams {
|
|
|
66
84
|
destAsset: Asset;
|
|
67
85
|
amount: string;
|
|
68
86
|
destAddress: string;
|
|
69
|
-
|
|
87
|
+
ccmParams?: CcmParams;
|
|
88
|
+
ccmMetadata?: CcmParams;
|
|
70
89
|
}
|
|
71
90
|
|
|
72
91
|
interface ChainData {
|
|
@@ -107,9 +126,11 @@ interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affi
|
|
|
107
126
|
}
|
|
108
127
|
interface DepositAddressRequest extends QuoteRequest {
|
|
109
128
|
destAddress: string;
|
|
110
|
-
|
|
129
|
+
ccmParams?: CcmParams;
|
|
111
130
|
maxBoostFeeBps?: number;
|
|
112
131
|
srcAddress?: string;
|
|
132
|
+
fillOrKillParams?: FillOrKillParams;
|
|
133
|
+
ccmMetadata?: CcmParams;
|
|
113
134
|
}
|
|
114
135
|
interface DepositAddressResponse extends DepositAddressRequest {
|
|
115
136
|
depositChannelId: string;
|
|
@@ -126,10 +147,15 @@ interface SwapStatusRequest {
|
|
|
126
147
|
interface SwapStatusResponseCommonFields extends ChainsAndAssets {
|
|
127
148
|
destAddress: string;
|
|
128
149
|
ccmDepositReceivedBlockIndex: string | undefined;
|
|
129
|
-
|
|
150
|
+
ccmParams: CcmParams | undefined;
|
|
130
151
|
feesPaid: SwapFee[];
|
|
131
152
|
estimatedDefaultDurationSeconds: number | undefined;
|
|
132
153
|
srcChainRequiredBlockConfirmations: number | undefined;
|
|
154
|
+
depositTransactionRef: string | undefined;
|
|
155
|
+
latestSwapScheduledAt: number | undefined;
|
|
156
|
+
latestSwapScheduledBlockIndex: string | undefined;
|
|
157
|
+
depositTransactionHash: string | undefined;
|
|
158
|
+
ccmMetadata?: CcmParams;
|
|
133
159
|
}
|
|
134
160
|
interface DepositAddressFields extends SwapStatusResponseCommonFields {
|
|
135
161
|
depositAddress: string;
|
|
@@ -148,6 +174,7 @@ interface DepositAddressFields extends SwapStatusResponseCommonFields {
|
|
|
148
174
|
effectiveBoostFeeBps?: number;
|
|
149
175
|
boostSkippedAt?: number;
|
|
150
176
|
boostSkippedBlockIndex?: string;
|
|
177
|
+
fillOrKillParams: FillOrKillParams;
|
|
151
178
|
}
|
|
152
179
|
type BroadcastRequested = {
|
|
153
180
|
swapId: string;
|
|
@@ -169,8 +196,6 @@ type CopyFields<T, U> = {
|
|
|
169
196
|
type VaultSwapFields = CopyFields<DepositAddressFields, SwapStatusResponseCommonFields>;
|
|
170
197
|
type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
|
|
171
198
|
depositAmount: string;
|
|
172
|
-
depositTransactionHash: string | undefined;
|
|
173
|
-
depositTransactionRef: string | undefined;
|
|
174
199
|
destAddress: string;
|
|
175
200
|
error: {
|
|
176
201
|
message: string;
|
|
@@ -188,8 +213,6 @@ type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
|
|
|
188
213
|
type SwapState = {
|
|
189
214
|
state: 'AWAITING_DEPOSIT';
|
|
190
215
|
depositAmount: string | undefined;
|
|
191
|
-
depositTransactionHash: string | undefined;
|
|
192
|
-
depositTransactionRef: string | undefined;
|
|
193
216
|
depositTransactionConfirmations: number | undefined;
|
|
194
217
|
} | {
|
|
195
218
|
state: 'DEPOSIT_RECEIVED';
|
|
@@ -242,8 +265,6 @@ type SwapState = {
|
|
|
242
265
|
message: string;
|
|
243
266
|
};
|
|
244
267
|
depositAmount: string;
|
|
245
|
-
depositTransactionHash: string | undefined;
|
|
246
|
-
depositTransactionRef: string | undefined;
|
|
247
268
|
failedAt: number;
|
|
248
269
|
failedBlockIndex: string;
|
|
249
270
|
} | {
|
package/dist/swap.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-
|
|
3
|
-
export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-
|
|
2
|
+
import { A as AssetAndChain, C as Chain, a as Asset, I as InternalAsset, b as AssetOfChain, c as ChainflipNetwork, T as TransactionOptions, d as ChainAssetMap, e as ChainMap } from './contracts-Cb-5VdIi.js';
|
|
3
|
+
export { g as Assets, h as ChainflipIds, i as ChainflipNetworks, f as Chains, U as UncheckedAssetAndChain, j as getChainflipId } from './contracts-Cb-5VdIi.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
-
declare const
|
|
6
|
+
declare const ccmParamsSchema: z.ZodObject<{
|
|
7
7
|
gasBudget: z.ZodString;
|
|
8
8
|
message: z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>;
|
|
9
9
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -13,7 +13,7 @@ declare const ccmMetadataSchema: z.ZodObject<{
|
|
|
13
13
|
message: string;
|
|
14
14
|
gasBudget: string;
|
|
15
15
|
}>;
|
|
16
|
-
type
|
|
16
|
+
type CcmParams = z.infer<typeof ccmParamsSchema>;
|
|
17
17
|
declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
|
|
18
18
|
account: z.ZodEffects<z.ZodString, string, string>;
|
|
19
19
|
commissionBps: z.ZodNumber;
|
|
@@ -31,6 +31,23 @@ declare const affiliateBroker: z.ZodEffects<z.ZodObject<{
|
|
|
31
31
|
commissionBps: number;
|
|
32
32
|
}>;
|
|
33
33
|
type AffiliateBroker = z.input<typeof affiliateBroker>;
|
|
34
|
+
declare const fillOrKillParams: z.ZodObject<{
|
|
35
|
+
retryDurationBlocks: z.ZodNumber;
|
|
36
|
+
refundAddress: z.ZodString;
|
|
37
|
+
minPriceX128: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
retryDurationBlocks: number;
|
|
40
|
+
refundAddress: string;
|
|
41
|
+
minPriceX128: string;
|
|
42
|
+
}, {
|
|
43
|
+
retryDurationBlocks: number;
|
|
44
|
+
refundAddress: string;
|
|
45
|
+
minPriceX128: string;
|
|
46
|
+
}>;
|
|
47
|
+
type FillOrKillParamsX128 = z.input<typeof fillOrKillParams>;
|
|
48
|
+
type FillOrKillParams = Omit<FillOrKillParamsX128, 'minPriceX128'> & {
|
|
49
|
+
minPrice: string;
|
|
50
|
+
};
|
|
34
51
|
type Fee<T> = {
|
|
35
52
|
type: T;
|
|
36
53
|
chain: Chain;
|
|
@@ -51,6 +68,7 @@ type QuoteDetails = {
|
|
|
51
68
|
poolInfo: PoolInfo[];
|
|
52
69
|
lowLiquidityWarning: boolean | undefined;
|
|
53
70
|
estimatedDurationSeconds: number;
|
|
71
|
+
estimatedPrice: string;
|
|
54
72
|
};
|
|
55
73
|
type BoostedQuoteDetails = QuoteDetails & {
|
|
56
74
|
estimatedBoostFeeBps: number;
|
|
@@ -66,7 +84,8 @@ interface ExecuteSwapParams {
|
|
|
66
84
|
destAsset: Asset;
|
|
67
85
|
amount: string;
|
|
68
86
|
destAddress: string;
|
|
69
|
-
|
|
87
|
+
ccmParams?: CcmParams;
|
|
88
|
+
ccmMetadata?: CcmParams;
|
|
70
89
|
}
|
|
71
90
|
|
|
72
91
|
interface ChainData {
|
|
@@ -107,9 +126,11 @@ interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affi
|
|
|
107
126
|
}
|
|
108
127
|
interface DepositAddressRequest extends QuoteRequest {
|
|
109
128
|
destAddress: string;
|
|
110
|
-
|
|
129
|
+
ccmParams?: CcmParams;
|
|
111
130
|
maxBoostFeeBps?: number;
|
|
112
131
|
srcAddress?: string;
|
|
132
|
+
fillOrKillParams?: FillOrKillParams;
|
|
133
|
+
ccmMetadata?: CcmParams;
|
|
113
134
|
}
|
|
114
135
|
interface DepositAddressResponse extends DepositAddressRequest {
|
|
115
136
|
depositChannelId: string;
|
|
@@ -126,10 +147,15 @@ interface SwapStatusRequest {
|
|
|
126
147
|
interface SwapStatusResponseCommonFields extends ChainsAndAssets {
|
|
127
148
|
destAddress: string;
|
|
128
149
|
ccmDepositReceivedBlockIndex: string | undefined;
|
|
129
|
-
|
|
150
|
+
ccmParams: CcmParams | undefined;
|
|
130
151
|
feesPaid: SwapFee[];
|
|
131
152
|
estimatedDefaultDurationSeconds: number | undefined;
|
|
132
153
|
srcChainRequiredBlockConfirmations: number | undefined;
|
|
154
|
+
depositTransactionRef: string | undefined;
|
|
155
|
+
latestSwapScheduledAt: number | undefined;
|
|
156
|
+
latestSwapScheduledBlockIndex: string | undefined;
|
|
157
|
+
depositTransactionHash: string | undefined;
|
|
158
|
+
ccmMetadata?: CcmParams;
|
|
133
159
|
}
|
|
134
160
|
interface DepositAddressFields extends SwapStatusResponseCommonFields {
|
|
135
161
|
depositAddress: string;
|
|
@@ -148,6 +174,7 @@ interface DepositAddressFields extends SwapStatusResponseCommonFields {
|
|
|
148
174
|
effectiveBoostFeeBps?: number;
|
|
149
175
|
boostSkippedAt?: number;
|
|
150
176
|
boostSkippedBlockIndex?: string;
|
|
177
|
+
fillOrKillParams: FillOrKillParams;
|
|
151
178
|
}
|
|
152
179
|
type BroadcastRequested = {
|
|
153
180
|
swapId: string;
|
|
@@ -169,8 +196,6 @@ type CopyFields<T, U> = {
|
|
|
169
196
|
type VaultSwapFields = CopyFields<DepositAddressFields, SwapStatusResponseCommonFields>;
|
|
170
197
|
type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
|
|
171
198
|
depositAmount: string;
|
|
172
|
-
depositTransactionHash: string | undefined;
|
|
173
|
-
depositTransactionRef: string | undefined;
|
|
174
199
|
destAddress: string;
|
|
175
200
|
error: {
|
|
176
201
|
message: string;
|
|
@@ -188,8 +213,6 @@ type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
|
|
|
188
213
|
type SwapState = {
|
|
189
214
|
state: 'AWAITING_DEPOSIT';
|
|
190
215
|
depositAmount: string | undefined;
|
|
191
|
-
depositTransactionHash: string | undefined;
|
|
192
|
-
depositTransactionRef: string | undefined;
|
|
193
216
|
depositTransactionConfirmations: number | undefined;
|
|
194
217
|
} | {
|
|
195
218
|
state: 'DEPOSIT_RECEIVED';
|
|
@@ -242,8 +265,6 @@ type SwapState = {
|
|
|
242
265
|
message: string;
|
|
243
266
|
};
|
|
244
267
|
depositAmount: string;
|
|
245
|
-
depositTransactionHash: string | undefined;
|
|
246
|
-
depositTransactionRef: string | undefined;
|
|
247
268
|
failedAt: number;
|
|
248
269
|
failedBlockIndex: string;
|
|
249
270
|
} | {
|