@chainflip/sdk 1.4.4 → 1.5.0-alpha.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/dist/{broker-PBJJVRH4.mjs → broker-QFRN2UBT.mjs} +12 -6
- package/dist/{chunk-JHVSTX24.mjs → chunk-7ENWS5RM.mjs} +11 -4
- package/dist/funding.d.mts +1 -1
- package/dist/funding.d.ts +1 -1
- package/dist/swap.d.mts +29 -13
- package/dist/swap.d.ts +29 -13
- package/dist/swap.js +32 -17
- package/dist/swap.mjs +12 -10
- 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-7ENWS5RM.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, minPrice }) => ({
|
|
35
|
+
retry_duration: retryDurationBlocks,
|
|
36
|
+
refund_address: refundAddress,
|
|
37
|
+
min_price: `0x${BigInt(minPrice).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
|
+
minPrice: 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,20 @@ 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
|
+
minPrice: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
retryDurationBlocks: number;
|
|
40
|
+
refundAddress: string;
|
|
41
|
+
minPrice: string;
|
|
42
|
+
}, {
|
|
43
|
+
retryDurationBlocks: number;
|
|
44
|
+
refundAddress: string;
|
|
45
|
+
minPrice: string;
|
|
46
|
+
}>;
|
|
47
|
+
type FillOrKillParams = z.input<typeof fillOrKillParams>;
|
|
34
48
|
type Fee<T> = {
|
|
35
49
|
type: T;
|
|
36
50
|
chain: Chain;
|
|
@@ -51,6 +65,7 @@ type QuoteDetails = {
|
|
|
51
65
|
poolInfo: PoolInfo[];
|
|
52
66
|
lowLiquidityWarning: boolean | undefined;
|
|
53
67
|
estimatedDurationSeconds: number;
|
|
68
|
+
estimatedPrice: string;
|
|
54
69
|
};
|
|
55
70
|
type BoostedQuoteDetails = QuoteDetails & {
|
|
56
71
|
estimatedBoostFeeBps: number;
|
|
@@ -66,7 +81,8 @@ interface ExecuteSwapParams {
|
|
|
66
81
|
destAsset: Asset;
|
|
67
82
|
amount: string;
|
|
68
83
|
destAddress: string;
|
|
69
|
-
|
|
84
|
+
ccmParams?: CcmParams;
|
|
85
|
+
ccmMetadata?: CcmParams;
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
interface ChainData {
|
|
@@ -107,9 +123,11 @@ interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affi
|
|
|
107
123
|
}
|
|
108
124
|
interface DepositAddressRequest extends QuoteRequest {
|
|
109
125
|
destAddress: string;
|
|
110
|
-
|
|
126
|
+
ccmParams?: CcmParams;
|
|
111
127
|
maxBoostFeeBps?: number;
|
|
112
128
|
srcAddress?: string;
|
|
129
|
+
fillOrKillParams?: FillOrKillParams;
|
|
130
|
+
ccmMetadata?: CcmParams;
|
|
113
131
|
}
|
|
114
132
|
interface DepositAddressResponse extends DepositAddressRequest {
|
|
115
133
|
depositChannelId: string;
|
|
@@ -126,10 +144,13 @@ interface SwapStatusRequest {
|
|
|
126
144
|
interface SwapStatusResponseCommonFields extends ChainsAndAssets {
|
|
127
145
|
destAddress: string;
|
|
128
146
|
ccmDepositReceivedBlockIndex: string | undefined;
|
|
129
|
-
|
|
147
|
+
ccmParams: CcmParams | undefined;
|
|
130
148
|
feesPaid: SwapFee[];
|
|
131
149
|
estimatedDefaultDurationSeconds: number | undefined;
|
|
132
150
|
srcChainRequiredBlockConfirmations: number | undefined;
|
|
151
|
+
depositTransactionRef: string | undefined;
|
|
152
|
+
depositTransactionHash: string | undefined;
|
|
153
|
+
ccmMetadata?: CcmParams;
|
|
133
154
|
}
|
|
134
155
|
interface DepositAddressFields extends SwapStatusResponseCommonFields {
|
|
135
156
|
depositAddress: string;
|
|
@@ -148,6 +169,7 @@ interface DepositAddressFields extends SwapStatusResponseCommonFields {
|
|
|
148
169
|
effectiveBoostFeeBps?: number;
|
|
149
170
|
boostSkippedAt?: number;
|
|
150
171
|
boostSkippedBlockIndex?: string;
|
|
172
|
+
fillOrKillParams: FillOrKillParams;
|
|
151
173
|
}
|
|
152
174
|
type BroadcastRequested = {
|
|
153
175
|
swapId: string;
|
|
@@ -169,8 +191,6 @@ type CopyFields<T, U> = {
|
|
|
169
191
|
type VaultSwapFields = CopyFields<DepositAddressFields, SwapStatusResponseCommonFields>;
|
|
170
192
|
type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
|
|
171
193
|
depositAmount: string;
|
|
172
|
-
depositTransactionHash: string | undefined;
|
|
173
|
-
depositTransactionRef: string | undefined;
|
|
174
194
|
destAddress: string;
|
|
175
195
|
error: {
|
|
176
196
|
message: string;
|
|
@@ -188,8 +208,6 @@ type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
|
|
|
188
208
|
type SwapState = {
|
|
189
209
|
state: 'AWAITING_DEPOSIT';
|
|
190
210
|
depositAmount: string | undefined;
|
|
191
|
-
depositTransactionHash: string | undefined;
|
|
192
|
-
depositTransactionRef: string | undefined;
|
|
193
211
|
depositTransactionConfirmations: number | undefined;
|
|
194
212
|
} | {
|
|
195
213
|
state: 'DEPOSIT_RECEIVED';
|
|
@@ -242,8 +260,6 @@ type SwapState = {
|
|
|
242
260
|
message: string;
|
|
243
261
|
};
|
|
244
262
|
depositAmount: string;
|
|
245
|
-
depositTransactionHash: string | undefined;
|
|
246
|
-
depositTransactionRef: string | undefined;
|
|
247
263
|
failedAt: number;
|
|
248
264
|
failedBlockIndex: string;
|
|
249
265
|
} | {
|
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,20 @@ 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
|
+
minPrice: z.ZodString;
|
|
38
|
+
}, "strip", z.ZodTypeAny, {
|
|
39
|
+
retryDurationBlocks: number;
|
|
40
|
+
refundAddress: string;
|
|
41
|
+
minPrice: string;
|
|
42
|
+
}, {
|
|
43
|
+
retryDurationBlocks: number;
|
|
44
|
+
refundAddress: string;
|
|
45
|
+
minPrice: string;
|
|
46
|
+
}>;
|
|
47
|
+
type FillOrKillParams = z.input<typeof fillOrKillParams>;
|
|
34
48
|
type Fee<T> = {
|
|
35
49
|
type: T;
|
|
36
50
|
chain: Chain;
|
|
@@ -51,6 +65,7 @@ type QuoteDetails = {
|
|
|
51
65
|
poolInfo: PoolInfo[];
|
|
52
66
|
lowLiquidityWarning: boolean | undefined;
|
|
53
67
|
estimatedDurationSeconds: number;
|
|
68
|
+
estimatedPrice: string;
|
|
54
69
|
};
|
|
55
70
|
type BoostedQuoteDetails = QuoteDetails & {
|
|
56
71
|
estimatedBoostFeeBps: number;
|
|
@@ -66,7 +81,8 @@ interface ExecuteSwapParams {
|
|
|
66
81
|
destAsset: Asset;
|
|
67
82
|
amount: string;
|
|
68
83
|
destAddress: string;
|
|
69
|
-
|
|
84
|
+
ccmParams?: CcmParams;
|
|
85
|
+
ccmMetadata?: CcmParams;
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
interface ChainData {
|
|
@@ -107,9 +123,11 @@ interface QuoteResponse extends Omit<QuoteRequest, 'brokerCommissionBps' | 'affi
|
|
|
107
123
|
}
|
|
108
124
|
interface DepositAddressRequest extends QuoteRequest {
|
|
109
125
|
destAddress: string;
|
|
110
|
-
|
|
126
|
+
ccmParams?: CcmParams;
|
|
111
127
|
maxBoostFeeBps?: number;
|
|
112
128
|
srcAddress?: string;
|
|
129
|
+
fillOrKillParams?: FillOrKillParams;
|
|
130
|
+
ccmMetadata?: CcmParams;
|
|
113
131
|
}
|
|
114
132
|
interface DepositAddressResponse extends DepositAddressRequest {
|
|
115
133
|
depositChannelId: string;
|
|
@@ -126,10 +144,13 @@ interface SwapStatusRequest {
|
|
|
126
144
|
interface SwapStatusResponseCommonFields extends ChainsAndAssets {
|
|
127
145
|
destAddress: string;
|
|
128
146
|
ccmDepositReceivedBlockIndex: string | undefined;
|
|
129
|
-
|
|
147
|
+
ccmParams: CcmParams | undefined;
|
|
130
148
|
feesPaid: SwapFee[];
|
|
131
149
|
estimatedDefaultDurationSeconds: number | undefined;
|
|
132
150
|
srcChainRequiredBlockConfirmations: number | undefined;
|
|
151
|
+
depositTransactionRef: string | undefined;
|
|
152
|
+
depositTransactionHash: string | undefined;
|
|
153
|
+
ccmMetadata?: CcmParams;
|
|
133
154
|
}
|
|
134
155
|
interface DepositAddressFields extends SwapStatusResponseCommonFields {
|
|
135
156
|
depositAddress: string;
|
|
@@ -148,6 +169,7 @@ interface DepositAddressFields extends SwapStatusResponseCommonFields {
|
|
|
148
169
|
effectiveBoostFeeBps?: number;
|
|
149
170
|
boostSkippedAt?: number;
|
|
150
171
|
boostSkippedBlockIndex?: string;
|
|
172
|
+
fillOrKillParams: FillOrKillParams;
|
|
151
173
|
}
|
|
152
174
|
type BroadcastRequested = {
|
|
153
175
|
swapId: string;
|
|
@@ -169,8 +191,6 @@ type CopyFields<T, U> = {
|
|
|
169
191
|
type VaultSwapFields = CopyFields<DepositAddressFields, SwapStatusResponseCommonFields>;
|
|
170
192
|
type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
|
|
171
193
|
depositAmount: string;
|
|
172
|
-
depositTransactionHash: string | undefined;
|
|
173
|
-
depositTransactionRef: string | undefined;
|
|
174
194
|
destAddress: string;
|
|
175
195
|
error: {
|
|
176
196
|
message: string;
|
|
@@ -188,8 +208,6 @@ type FailedVaultSwapStatusResponse = CopyFields<DepositAddressFields, {
|
|
|
188
208
|
type SwapState = {
|
|
189
209
|
state: 'AWAITING_DEPOSIT';
|
|
190
210
|
depositAmount: string | undefined;
|
|
191
|
-
depositTransactionHash: string | undefined;
|
|
192
|
-
depositTransactionRef: string | undefined;
|
|
193
211
|
depositTransactionConfirmations: number | undefined;
|
|
194
212
|
} | {
|
|
195
213
|
state: 'DEPOSIT_RECEIVED';
|
|
@@ -242,8 +260,6 @@ type SwapState = {
|
|
|
242
260
|
message: string;
|
|
243
261
|
};
|
|
244
262
|
depositAmount: string;
|
|
245
|
-
depositTransactionHash: string | undefined;
|
|
246
|
-
depositTransactionRef: string | undefined;
|
|
247
263
|
failedAt: number;
|
|
248
264
|
failedBlockIndex: string;
|
|
249
265
|
} | {
|
package/dist/swap.js
CHANGED
|
@@ -4689,7 +4689,7 @@ var init_parsers = __esm({
|
|
|
4689
4689
|
});
|
|
4690
4690
|
|
|
4691
4691
|
// ../shared/src/schemas.ts
|
|
4692
|
-
var
|
|
4692
|
+
var ccmParamsSchema, affiliateBroker, fillOrKillParams;
|
|
4693
4693
|
var init_schemas = __esm({
|
|
4694
4694
|
"../shared/src/schemas.ts"() {
|
|
4695
4695
|
init_lib();
|
|
@@ -4731,7 +4731,7 @@ var init_schemas = __esm({
|
|
|
4731
4731
|
brokerCommissionBps: args.brokerCommissionBps
|
|
4732
4732
|
};
|
|
4733
4733
|
});
|
|
4734
|
-
|
|
4734
|
+
ccmParamsSchema = z.object({
|
|
4735
4735
|
gasBudget: numericString,
|
|
4736
4736
|
message: hexStringWithMaxByteSize(1024 * 10)
|
|
4737
4737
|
});
|
|
@@ -4742,6 +4742,11 @@ var init_schemas = __esm({
|
|
|
4742
4742
|
account,
|
|
4743
4743
|
bps
|
|
4744
4744
|
}));
|
|
4745
|
+
fillOrKillParams = z.object({
|
|
4746
|
+
retryDurationBlocks: number,
|
|
4747
|
+
refundAddress: z.string(),
|
|
4748
|
+
minPrice: numericString
|
|
4749
|
+
});
|
|
4745
4750
|
z.object({
|
|
4746
4751
|
srcAsset: asset,
|
|
4747
4752
|
destAsset: asset,
|
|
@@ -4749,9 +4754,11 @@ var init_schemas = __esm({
|
|
|
4749
4754
|
destChain: chain,
|
|
4750
4755
|
destAddress: z.string(),
|
|
4751
4756
|
amount: numericString,
|
|
4752
|
-
ccmMetadata:
|
|
4757
|
+
ccmMetadata: ccmParamsSchema.optional(),
|
|
4758
|
+
ccmParams: ccmParamsSchema.optional(),
|
|
4753
4759
|
maxBoostFeeBps: z.number().optional(),
|
|
4754
|
-
srcAddress: z.string().optional()
|
|
4760
|
+
srcAddress: z.string().optional(),
|
|
4761
|
+
fillOrKillParams: fillOrKillParams.optional()
|
|
4755
4762
|
}).transform(({ amount, ...rest }) => ({
|
|
4756
4763
|
...rest,
|
|
4757
4764
|
expectedDepositAmount: amount
|
|
@@ -4778,12 +4785,13 @@ async function requestSwapDepositAddress(swapRequest, opts, chainflipNetwork2) {
|
|
|
4778
4785
|
},
|
|
4779
4786
|
submitAddress(destChain, destAddress),
|
|
4780
4787
|
swapRequest.commissionBps ?? 0,
|
|
4781
|
-
swapRequest.
|
|
4782
|
-
...swapRequest.
|
|
4788
|
+
swapRequest.ccmParams && {
|
|
4789
|
+
...swapRequest.ccmParams,
|
|
4783
4790
|
cfParameters: void 0
|
|
4784
4791
|
},
|
|
4785
4792
|
maxBoostFeeBps,
|
|
4786
|
-
swapRequest.affiliates
|
|
4793
|
+
swapRequest.affiliates,
|
|
4794
|
+
swapRequest.fillOrKillParams
|
|
4787
4795
|
]);
|
|
4788
4796
|
const response = await client.sendRequest("broker_requestSwapDepositAddress", ...params);
|
|
4789
4797
|
return validateResponse(chainflipNetwork2, response);
|
|
@@ -4810,7 +4818,7 @@ var init_broker = __esm({
|
|
|
4810
4818
|
btcAddress(network)
|
|
4811
4819
|
]),
|
|
4812
4820
|
z.number(),
|
|
4813
|
-
|
|
4821
|
+
ccmParamsSchema.merge(z.object({
|
|
4814
4822
|
cfParameters: z.union([
|
|
4815
4823
|
hexString,
|
|
4816
4824
|
z.string()
|
|
@@ -4821,7 +4829,12 @@ var init_broker = __esm({
|
|
|
4821
4829
|
gas_budget: `0x${BigInt(rest.gasBudget).toString(16)}`
|
|
4822
4830
|
})).optional(),
|
|
4823
4831
|
z.number().optional(),
|
|
4824
|
-
z.array(affiliateBroker).optional()
|
|
4832
|
+
z.array(affiliateBroker).optional(),
|
|
4833
|
+
fillOrKillParams.transform(({ retryDurationBlocks, refundAddress, minPrice }) => ({
|
|
4834
|
+
retry_duration: retryDurationBlocks,
|
|
4835
|
+
refund_address: refundAddress,
|
|
4836
|
+
min_price: `0x${BigInt(minPrice).toString(16)}`
|
|
4837
|
+
})).optional()
|
|
4825
4838
|
]).parse(params), "validateRequest");
|
|
4826
4839
|
validateResponse = /* @__PURE__ */ __name((network, response) => z.object({
|
|
4827
4840
|
address: z.union([
|
|
@@ -8560,7 +8573,7 @@ var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
8560
8573
|
asset: params.destAsset
|
|
8561
8574
|
});
|
|
8562
8575
|
const { vaultContract: vault } = getVaultContract(params.srcChain, networkOpts);
|
|
8563
|
-
const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.
|
|
8576
|
+
const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, "0x", {
|
|
8564
8577
|
value: params.amount,
|
|
8565
8578
|
...extractOverrides(txOpts)
|
|
8566
8579
|
});
|
|
@@ -8573,24 +8586,24 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
8573
8586
|
const erc20Address = getErc20Address(srcAsset, networkOpts);
|
|
8574
8587
|
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultAddress, erc20Address, networkOpts.signer);
|
|
8575
8588
|
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
8576
|
-
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.
|
|
8589
|
+
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
8577
8590
|
await transaction.wait(txOpts.wait);
|
|
8578
8591
|
return transaction;
|
|
8579
8592
|
}, "callToken");
|
|
8580
|
-
var executeSwap = /* @__PURE__ */ __name(async ({
|
|
8593
|
+
var executeSwap = /* @__PURE__ */ __name(async ({ ccmParams: unvalidatedCcmParams, ...params }, networkOpts, txOpts) => {
|
|
8581
8594
|
assertIsValidSwap(params);
|
|
8582
8595
|
assertIsEvmChain(params.srcChain);
|
|
8583
8596
|
assertValidAddress(params.destChain, params.destAddress, networkOpts.network);
|
|
8584
8597
|
await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
|
|
8585
|
-
if (
|
|
8598
|
+
if (unvalidatedCcmParams) {
|
|
8586
8599
|
assertIsEvmChain(params.destChain);
|
|
8587
|
-
const
|
|
8600
|
+
const ccmParams = ccmParamsSchema.parse(unvalidatedCcmParams);
|
|
8588
8601
|
return params.srcAsset === chainConstants[params.srcChain].gasAsset ? callNative({
|
|
8589
8602
|
...params,
|
|
8590
|
-
|
|
8603
|
+
ccmParams
|
|
8591
8604
|
}, networkOpts, txOpts) : callToken({
|
|
8592
8605
|
...params,
|
|
8593
|
-
|
|
8606
|
+
ccmParams
|
|
8594
8607
|
}, networkOpts, txOpts);
|
|
8595
8608
|
}
|
|
8596
8609
|
return params.srcAsset === chainConstants[params.srcChain].gasAsset ? swapNative(params, networkOpts, txOpts) : swapToken(params, networkOpts, txOpts);
|
|
@@ -8655,7 +8668,7 @@ var getChainData = /* @__PURE__ */ __name((chain2, network, env) => ({
|
|
|
8655
8668
|
init_enums();
|
|
8656
8669
|
|
|
8657
8670
|
// package.json
|
|
8658
|
-
var version = "1.
|
|
8671
|
+
var version = "1.5.0-alpha.0";
|
|
8659
8672
|
|
|
8660
8673
|
// src/swap/consts.ts
|
|
8661
8674
|
var CF_SDK_VERSION_HEADERS = {
|
|
@@ -8773,6 +8786,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8773
8786
|
chain: srcChain,
|
|
8774
8787
|
asset: srcAsset
|
|
8775
8788
|
}, BigInt(amount));
|
|
8789
|
+
depositAddressRequest.ccmParams ?? (depositAddressRequest.ccmParams = depositAddressRequest.ccmMetadata);
|
|
8776
8790
|
let response;
|
|
8777
8791
|
if (this.options.broker !== void 0) {
|
|
8778
8792
|
const { requestSwapDepositAddress: requestSwapDepositAddress2 } = await Promise.resolve().then(() => (init_broker(), broker_exports));
|
|
@@ -8820,6 +8834,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
8820
8834
|
chain: srcChain,
|
|
8821
8835
|
asset: srcAsset
|
|
8822
8836
|
}, BigInt(amount));
|
|
8837
|
+
params.ccmParams ?? (params.ccmParams = params.ccmMetadata);
|
|
8823
8838
|
const tx = await executeSwap_default(params, {
|
|
8824
8839
|
network: this.options.network,
|
|
8825
8840
|
signer
|
package/dist/swap.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getEnvironment, getSupportedAssets, getAllBoostPoolsDepth, getVaultContractAddress, approve, getTokenContractAddress, getEvmChainId, checkAllowance, extractOverrides, Vault__factory } from './chunk-M32JHS3U.mjs';
|
|
2
|
-
import { assertValidAddress,
|
|
2
|
+
import { assertValidAddress, ccmParamsSchema, dotAddress } from './chunk-7ENWS5RM.mjs';
|
|
3
3
|
import { __name, ChainflipNetworks, __publicField, Chains, assetConstants, getInternalAsset, isNotNullish, assert, getAssetAndChain, readChainAssetValue, isTestnet, chainConstants, getInternalAssets } from './chunk-3V7QJANN.mjs';
|
|
4
4
|
export { Assets, InternalAssets as ChainflipIds, ChainflipNetworks, Chains, getInternalAsset as getChainflipId } from './chunk-3V7QJANN.mjs';
|
|
5
5
|
import { bytesToHex } from '@chainflip/utils/bytes';
|
|
@@ -2262,7 +2262,7 @@ var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
2262
2262
|
asset: params.destAsset
|
|
2263
2263
|
});
|
|
2264
2264
|
const { vaultContract: vault } = getVaultContract(params.srcChain, networkOpts);
|
|
2265
|
-
const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.
|
|
2265
|
+
const transaction = await vault.xCallNative(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, "0x", {
|
|
2266
2266
|
value: params.amount,
|
|
2267
2267
|
...extractOverrides(txOpts)
|
|
2268
2268
|
});
|
|
@@ -2275,24 +2275,24 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
2275
2275
|
const erc20Address = getErc20Address(srcAsset, networkOpts);
|
|
2276
2276
|
const { hasSufficientAllowance } = await checkAllowance(BigInt(params.amount), vaultAddress, erc20Address, networkOpts.signer);
|
|
2277
2277
|
assert(hasSufficientAllowance, "Swap amount exceeds allowance");
|
|
2278
|
-
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.
|
|
2278
|
+
const transaction = await vault.xCallToken(chainConstants[params.destChain].contractId, encodeAddress(params.destChain, params.destAddress), assetConstants[destAsset].contractId, params.ccmParams.message, params.ccmParams.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
2279
2279
|
await transaction.wait(txOpts.wait);
|
|
2280
2280
|
return transaction;
|
|
2281
2281
|
}, "callToken");
|
|
2282
|
-
var executeSwap = /* @__PURE__ */ __name(async ({
|
|
2282
|
+
var executeSwap = /* @__PURE__ */ __name(async ({ ccmParams: unvalidatedCcmParams, ...params }, networkOpts, txOpts) => {
|
|
2283
2283
|
assertIsValidSwap(params);
|
|
2284
2284
|
assertIsEvmChain(params.srcChain);
|
|
2285
2285
|
assertValidAddress(params.destChain, params.destAddress, networkOpts.network);
|
|
2286
2286
|
await assertSignerIsConnectedToChain(networkOpts, params.srcChain);
|
|
2287
|
-
if (
|
|
2287
|
+
if (unvalidatedCcmParams) {
|
|
2288
2288
|
assertIsEvmChain(params.destChain);
|
|
2289
|
-
const
|
|
2289
|
+
const ccmParams = ccmParamsSchema.parse(unvalidatedCcmParams);
|
|
2290
2290
|
return params.srcAsset === chainConstants[params.srcChain].gasAsset ? callNative({
|
|
2291
2291
|
...params,
|
|
2292
|
-
|
|
2292
|
+
ccmParams
|
|
2293
2293
|
}, networkOpts, txOpts) : callToken({
|
|
2294
2294
|
...params,
|
|
2295
|
-
|
|
2295
|
+
ccmParams
|
|
2296
2296
|
}, networkOpts, txOpts);
|
|
2297
2297
|
}
|
|
2298
2298
|
return params.srcAsset === chainConstants[params.srcChain].gasAsset ? swapNative(params, networkOpts, txOpts) : swapToken(params, networkOpts, txOpts);
|
|
@@ -2349,7 +2349,7 @@ var getChainData = /* @__PURE__ */ __name((chain, network, env) => ({
|
|
|
2349
2349
|
}), "getChainData");
|
|
2350
2350
|
|
|
2351
2351
|
// package.json
|
|
2352
|
-
var version = "1.
|
|
2352
|
+
var version = "1.5.0-alpha.0";
|
|
2353
2353
|
|
|
2354
2354
|
// src/swap/consts.ts
|
|
2355
2355
|
var CF_SDK_VERSION_HEADERS = {
|
|
@@ -2467,9 +2467,10 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2467
2467
|
chain: srcChain,
|
|
2468
2468
|
asset: srcAsset
|
|
2469
2469
|
}, BigInt(amount));
|
|
2470
|
+
depositAddressRequest.ccmParams ?? (depositAddressRequest.ccmParams = depositAddressRequest.ccmMetadata);
|
|
2470
2471
|
let response;
|
|
2471
2472
|
if (this.options.broker !== void 0) {
|
|
2472
|
-
const { requestSwapDepositAddress } = await import('./broker-
|
|
2473
|
+
const { requestSwapDepositAddress } = await import('./broker-QFRN2UBT.mjs');
|
|
2473
2474
|
const result = await requestSwapDepositAddress({
|
|
2474
2475
|
...depositAddressRequest,
|
|
2475
2476
|
commissionBps: brokerCommissionBps ?? this.options.broker.commissionBps,
|
|
@@ -2514,6 +2515,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2514
2515
|
chain: srcChain,
|
|
2515
2516
|
asset: srcAsset
|
|
2516
2517
|
}, BigInt(amount));
|
|
2518
|
+
params.ccmParams ?? (params.ccmParams = params.ccmMetadata);
|
|
2517
2519
|
const tx = await executeSwap_default(params, {
|
|
2518
2520
|
network: this.options.network,
|
|
2519
2521
|
signer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"ethers": "^6.13.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"tsup": "^8.
|
|
50
|
+
"tsup": "^8.2.4"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"test": "jest --forceExit",
|
|
File without changes
|
|
File without changes
|