@chainflip/sdk 0.2.1 → 0.2.3
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/funding.d.mts +12 -4
- package/dist/funding.d.ts +12 -4
- package/dist/funding.js +10 -2
- package/dist/funding.mjs +11 -3
- package/dist/swap.d.mts +59 -59
- package/dist/swap.d.ts +59 -59
- package/dist/swap.js +45 -10
- package/dist/swap.mjs +47 -12
- package/package.json +3 -3
- package/dist/{chunk-UBMU3BTF.mjs → chunk-FTLY2OML.mjs} +15 -15
package/dist/funding.d.mts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import { a as ChainflipNetwork, T as TransactionOptions } from './contracts-646d1727.js';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type PendingRedemption = {
|
|
5
|
+
amount: bigint;
|
|
6
|
+
redeemAddress: string;
|
|
7
|
+
startTime: bigint;
|
|
8
|
+
expiryTime: bigint;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type FundingSDKOption = {
|
|
5
12
|
network?: Exclude<ChainflipNetwork, 'mainnet'>;
|
|
6
13
|
signer: Signer;
|
|
7
14
|
};
|
|
8
15
|
type TransactionHash = `0x${string}`;
|
|
9
16
|
declare class FundingSDK {
|
|
10
17
|
private readonly options;
|
|
11
|
-
constructor(options:
|
|
18
|
+
constructor(options: FundingSDKOption);
|
|
12
19
|
fundStateChainAccount(accountId: `0x${string}`, amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash>;
|
|
13
20
|
executeRedemption(accountId: `0x${string}`, txOpts?: TransactionOptions): Promise<TransactionHash>;
|
|
14
21
|
getMinimumFunding(): Promise<bigint>;
|
|
15
22
|
getRedemptionDelay(): Promise<bigint>;
|
|
16
23
|
getFlipBalance(): Promise<bigint>;
|
|
24
|
+
getPendingRedemption(accountId: `0x${string}`): Promise<PendingRedemption | undefined>;
|
|
17
25
|
approveStateChainGateway(amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
export { FundingSDK };
|
|
28
|
+
export { FundingSDK, FundingSDKOption, PendingRedemption };
|
package/dist/funding.d.ts
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import { a as ChainflipNetwork, T as TransactionOptions } from './contracts-646d1727.js';
|
|
3
3
|
|
|
4
|
-
type
|
|
4
|
+
type PendingRedemption = {
|
|
5
|
+
amount: bigint;
|
|
6
|
+
redeemAddress: string;
|
|
7
|
+
startTime: bigint;
|
|
8
|
+
expiryTime: bigint;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
type FundingSDKOption = {
|
|
5
12
|
network?: Exclude<ChainflipNetwork, 'mainnet'>;
|
|
6
13
|
signer: Signer;
|
|
7
14
|
};
|
|
8
15
|
type TransactionHash = `0x${string}`;
|
|
9
16
|
declare class FundingSDK {
|
|
10
17
|
private readonly options;
|
|
11
|
-
constructor(options:
|
|
18
|
+
constructor(options: FundingSDKOption);
|
|
12
19
|
fundStateChainAccount(accountId: `0x${string}`, amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash>;
|
|
13
20
|
executeRedemption(accountId: `0x${string}`, txOpts?: TransactionOptions): Promise<TransactionHash>;
|
|
14
21
|
getMinimumFunding(): Promise<bigint>;
|
|
15
22
|
getRedemptionDelay(): Promise<bigint>;
|
|
16
23
|
getFlipBalance(): Promise<bigint>;
|
|
24
|
+
getPendingRedemption(accountId: `0x${string}`): Promise<PendingRedemption | undefined>;
|
|
17
25
|
approveStateChainGateway(amount: bigint, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
|
|
18
26
|
}
|
|
19
27
|
|
|
20
|
-
export { FundingSDK };
|
|
28
|
+
export { FundingSDK, FundingSDKOption, PendingRedemption };
|
package/dist/funding.js
CHANGED
|
@@ -956,8 +956,13 @@ var getRedemptionDelay = /* @__PURE__ */ __name((networkOpts) => {
|
|
|
956
956
|
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
957
957
|
return stateChainGateway.REDEMPTION_DELAY();
|
|
958
958
|
}, "getRedemptionDelay");
|
|
959
|
+
var getPendingRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts) => {
|
|
960
|
+
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
961
|
+
const pendingRedemption = await stateChainGateway.getPendingRedemption(accountId);
|
|
962
|
+
return pendingRedemption.amount !== 0n ? stateChainGateway.getPendingRedemption(accountId) : void 0;
|
|
963
|
+
}, "getPendingRedemption");
|
|
959
964
|
|
|
960
|
-
// src/funding/
|
|
965
|
+
// src/funding/sdk.ts
|
|
961
966
|
var _FundingSDK = class _FundingSDK {
|
|
962
967
|
constructor(options) {
|
|
963
968
|
__publicField(this, "options");
|
|
@@ -990,8 +995,11 @@ var _FundingSDK = class _FundingSDK {
|
|
|
990
995
|
async getFlipBalance() {
|
|
991
996
|
return getFlipBalance(this.options.network, this.options.signer);
|
|
992
997
|
}
|
|
998
|
+
async getPendingRedemption(accountId) {
|
|
999
|
+
return getPendingRedemption(accountId, this.options);
|
|
1000
|
+
}
|
|
993
1001
|
/**
|
|
994
|
-
* @param
|
|
1002
|
+
* @param the amount of FLIP to request approval for
|
|
995
1003
|
* @returns the transaction hash or null if no approval was required
|
|
996
1004
|
*/
|
|
997
1005
|
async approveStateChainGateway(amount, txOpts = {}) {
|
package/dist/funding.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __name, __publicField, ChainflipNetworks, getFlipBalance, getStateChainGatewayContractAddress, approve, getTokenContractAddress, Assets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-
|
|
1
|
+
import { __name, __publicField, ChainflipNetworks, getFlipBalance, getStateChainGatewayContractAddress, approve, getTokenContractAddress, Assets, checkAllowance, assert, extractOverrides, StateChainGateway__factory } from './chunk-FTLY2OML.mjs';
|
|
2
2
|
|
|
3
3
|
// ../shared/src/stateChainGateway/utils.ts
|
|
4
4
|
var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
|
|
@@ -42,8 +42,13 @@ var getRedemptionDelay = /* @__PURE__ */ __name((networkOpts) => {
|
|
|
42
42
|
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
43
43
|
return stateChainGateway.REDEMPTION_DELAY();
|
|
44
44
|
}, "getRedemptionDelay");
|
|
45
|
+
var getPendingRedemption = /* @__PURE__ */ __name(async (accountId, networkOpts) => {
|
|
46
|
+
const stateChainGateway = getStateChainGateway(networkOpts);
|
|
47
|
+
const pendingRedemption = await stateChainGateway.getPendingRedemption(accountId);
|
|
48
|
+
return pendingRedemption.amount !== 0n ? stateChainGateway.getPendingRedemption(accountId) : void 0;
|
|
49
|
+
}, "getPendingRedemption");
|
|
45
50
|
|
|
46
|
-
// src/funding/
|
|
51
|
+
// src/funding/sdk.ts
|
|
47
52
|
var _FundingSDK = class _FundingSDK {
|
|
48
53
|
constructor(options) {
|
|
49
54
|
__publicField(this, "options");
|
|
@@ -76,8 +81,11 @@ var _FundingSDK = class _FundingSDK {
|
|
|
76
81
|
async getFlipBalance() {
|
|
77
82
|
return getFlipBalance(this.options.network, this.options.signer);
|
|
78
83
|
}
|
|
84
|
+
async getPendingRedemption(accountId) {
|
|
85
|
+
return getPendingRedemption(accountId, this.options);
|
|
86
|
+
}
|
|
79
87
|
/**
|
|
80
|
-
* @param
|
|
88
|
+
* @param the amount of FLIP to request approval for
|
|
81
89
|
* @returns the transaction hash or null if no approval was required
|
|
82
90
|
*/
|
|
83
91
|
async approveStateChainGateway(amount, txOpts = {}) {
|
package/dist/swap.d.mts
CHANGED
|
@@ -14,16 +14,16 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
14
14
|
amount: bigint;
|
|
15
15
|
srcChain: "Ethereum";
|
|
16
16
|
srcAsset: "FLIP";
|
|
17
|
+
destAsset: "USDC" | "ETH";
|
|
17
18
|
destChain: "Ethereum";
|
|
18
19
|
destAddress: `0x${string}`;
|
|
19
|
-
destAsset: "USDC" | "ETH";
|
|
20
20
|
}, {
|
|
21
21
|
amount: bigint;
|
|
22
22
|
srcChain: "Ethereum";
|
|
23
23
|
srcAsset: "FLIP";
|
|
24
|
+
destAsset: "USDC" | "ETH";
|
|
24
25
|
destChain: "Ethereum";
|
|
25
26
|
destAddress: `0x${string}`;
|
|
26
|
-
destAsset: "USDC" | "ETH";
|
|
27
27
|
}>, z.ZodObject<{
|
|
28
28
|
amount: z.ZodBigInt;
|
|
29
29
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -35,174 +35,174 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
35
35
|
amount: bigint;
|
|
36
36
|
srcChain: "Ethereum";
|
|
37
37
|
srcAsset: "USDC";
|
|
38
|
+
destAsset: "FLIP" | "ETH";
|
|
38
39
|
destChain: "Ethereum";
|
|
39
40
|
destAddress: `0x${string}`;
|
|
40
|
-
destAsset: "FLIP" | "ETH";
|
|
41
41
|
}, {
|
|
42
42
|
amount: bigint;
|
|
43
43
|
srcChain: "Ethereum";
|
|
44
44
|
srcAsset: "USDC";
|
|
45
|
+
destAsset: "FLIP" | "ETH";
|
|
45
46
|
destChain: "Ethereum";
|
|
46
47
|
destAddress: `0x${string}`;
|
|
47
|
-
destAsset: "FLIP" | "ETH";
|
|
48
48
|
}>, z.ZodObject<{
|
|
49
49
|
amount: z.ZodBigInt;
|
|
50
50
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
51
|
+
destAsset: z.ZodLiteral<"DOT">;
|
|
51
52
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
52
53
|
destAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>]>, string | null, string>, string, string>, string, string>;
|
|
53
|
-
destAsset: z.ZodLiteral<"DOT">;
|
|
54
54
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
56
|
amount: bigint;
|
|
57
57
|
srcChain: "Ethereum";
|
|
58
58
|
srcAsset: "FLIP" | "USDC";
|
|
59
|
+
destAsset: "DOT";
|
|
59
60
|
destChain: "Polkadot";
|
|
60
61
|
destAddress: string;
|
|
61
|
-
destAsset: "DOT";
|
|
62
62
|
}, {
|
|
63
63
|
amount: bigint;
|
|
64
64
|
srcChain: "Ethereum";
|
|
65
65
|
srcAsset: "FLIP" | "USDC";
|
|
66
|
+
destAsset: "DOT";
|
|
66
67
|
destChain: "Polkadot";
|
|
67
68
|
destAddress: string;
|
|
68
|
-
destAsset: "DOT";
|
|
69
69
|
}>, z.ZodObject<{
|
|
70
70
|
amount: z.ZodBigInt;
|
|
71
71
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
72
|
+
destAsset: z.ZodLiteral<"BTC">;
|
|
72
73
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
73
74
|
destAddress: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string> | z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
|
|
74
|
-
destAsset: z.ZodLiteral<"BTC">;
|
|
75
75
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
76
76
|
}, "strip", z.ZodTypeAny, {
|
|
77
77
|
amount: bigint;
|
|
78
78
|
srcChain: "Ethereum";
|
|
79
79
|
srcAsset: "FLIP" | "USDC";
|
|
80
|
+
destAsset: "BTC";
|
|
80
81
|
destChain: "Bitcoin";
|
|
81
82
|
destAddress: string;
|
|
82
|
-
destAsset: "BTC";
|
|
83
83
|
}, {
|
|
84
84
|
amount: bigint;
|
|
85
85
|
srcChain: "Ethereum";
|
|
86
86
|
srcAsset: "FLIP" | "USDC";
|
|
87
|
+
destAsset: "BTC";
|
|
87
88
|
destChain: "Bitcoin";
|
|
88
89
|
destAddress: string;
|
|
89
|
-
destAsset: "BTC";
|
|
90
90
|
}>]>;
|
|
91
91
|
declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
92
92
|
amount: z.ZodBigInt;
|
|
93
93
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
94
94
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
95
|
+
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
95
96
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
96
97
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
97
|
-
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
98
98
|
ccmMetadata: z.ZodObject<{
|
|
99
|
-
message: z.ZodString;
|
|
100
99
|
gasBudget: z.ZodString;
|
|
100
|
+
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
101
101
|
}, "strip", z.ZodTypeAny, {
|
|
102
|
-
message: string
|
|
102
|
+
message: `0x${string}`;
|
|
103
103
|
gasBudget: string;
|
|
104
104
|
}, {
|
|
105
|
-
message: string
|
|
105
|
+
message: `0x${string}`;
|
|
106
106
|
gasBudget: string;
|
|
107
107
|
}>;
|
|
108
108
|
}, "strip", z.ZodTypeAny, {
|
|
109
109
|
amount: bigint;
|
|
110
110
|
srcChain: "Ethereum";
|
|
111
111
|
srcAsset: "ETH";
|
|
112
|
+
destAsset: "FLIP" | "USDC";
|
|
112
113
|
destChain: "Ethereum";
|
|
113
114
|
destAddress: `0x${string}`;
|
|
114
|
-
destAsset: "FLIP" | "USDC";
|
|
115
115
|
ccmMetadata: {
|
|
116
|
-
message: string
|
|
116
|
+
message: `0x${string}`;
|
|
117
117
|
gasBudget: string;
|
|
118
118
|
};
|
|
119
119
|
}, {
|
|
120
120
|
amount: bigint;
|
|
121
121
|
srcChain: "Ethereum";
|
|
122
122
|
srcAsset: "ETH";
|
|
123
|
+
destAsset: "FLIP" | "USDC";
|
|
123
124
|
destChain: "Ethereum";
|
|
124
125
|
destAddress: `0x${string}`;
|
|
125
|
-
destAsset: "FLIP" | "USDC";
|
|
126
126
|
ccmMetadata: {
|
|
127
|
-
message: string
|
|
127
|
+
message: `0x${string}`;
|
|
128
128
|
gasBudget: string;
|
|
129
129
|
};
|
|
130
130
|
}>, z.ZodUnion<[z.ZodObject<{
|
|
131
131
|
amount: z.ZodBigInt;
|
|
132
132
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
133
133
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
134
|
+
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
134
135
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
135
136
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
136
|
-
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
137
137
|
ccmMetadata: z.ZodObject<{
|
|
138
|
-
message: z.ZodString;
|
|
139
138
|
gasBudget: z.ZodString;
|
|
139
|
+
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
140
140
|
}, "strip", z.ZodTypeAny, {
|
|
141
|
-
message: string
|
|
141
|
+
message: `0x${string}`;
|
|
142
142
|
gasBudget: string;
|
|
143
143
|
}, {
|
|
144
|
-
message: string
|
|
144
|
+
message: `0x${string}`;
|
|
145
145
|
gasBudget: string;
|
|
146
146
|
}>;
|
|
147
147
|
}, "strip", z.ZodTypeAny, {
|
|
148
148
|
amount: bigint;
|
|
149
149
|
srcChain: "Ethereum";
|
|
150
150
|
srcAsset: "FLIP";
|
|
151
|
+
destAsset: "USDC" | "ETH";
|
|
151
152
|
destChain: "Ethereum";
|
|
152
153
|
destAddress: `0x${string}`;
|
|
153
|
-
destAsset: "USDC" | "ETH";
|
|
154
154
|
ccmMetadata: {
|
|
155
|
-
message: string
|
|
155
|
+
message: `0x${string}`;
|
|
156
156
|
gasBudget: string;
|
|
157
157
|
};
|
|
158
158
|
}, {
|
|
159
159
|
amount: bigint;
|
|
160
160
|
srcChain: "Ethereum";
|
|
161
161
|
srcAsset: "FLIP";
|
|
162
|
+
destAsset: "USDC" | "ETH";
|
|
162
163
|
destChain: "Ethereum";
|
|
163
164
|
destAddress: `0x${string}`;
|
|
164
|
-
destAsset: "USDC" | "ETH";
|
|
165
165
|
ccmMetadata: {
|
|
166
|
-
message: string
|
|
166
|
+
message: `0x${string}`;
|
|
167
167
|
gasBudget: string;
|
|
168
168
|
};
|
|
169
169
|
}>, z.ZodObject<{
|
|
170
170
|
amount: z.ZodBigInt;
|
|
171
171
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
172
172
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
173
|
+
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
173
174
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
174
175
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
175
|
-
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
176
176
|
ccmMetadata: z.ZodObject<{
|
|
177
|
-
message: z.ZodString;
|
|
178
177
|
gasBudget: z.ZodString;
|
|
178
|
+
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
179
179
|
}, "strip", z.ZodTypeAny, {
|
|
180
|
-
message: string
|
|
180
|
+
message: `0x${string}`;
|
|
181
181
|
gasBudget: string;
|
|
182
182
|
}, {
|
|
183
|
-
message: string
|
|
183
|
+
message: `0x${string}`;
|
|
184
184
|
gasBudget: string;
|
|
185
185
|
}>;
|
|
186
186
|
}, "strip", z.ZodTypeAny, {
|
|
187
187
|
amount: bigint;
|
|
188
188
|
srcChain: "Ethereum";
|
|
189
189
|
srcAsset: "USDC";
|
|
190
|
+
destAsset: "FLIP" | "ETH";
|
|
190
191
|
destChain: "Ethereum";
|
|
191
192
|
destAddress: `0x${string}`;
|
|
192
|
-
destAsset: "FLIP" | "ETH";
|
|
193
193
|
ccmMetadata: {
|
|
194
|
-
message: string
|
|
194
|
+
message: `0x${string}`;
|
|
195
195
|
gasBudget: string;
|
|
196
196
|
};
|
|
197
197
|
}, {
|
|
198
198
|
amount: bigint;
|
|
199
199
|
srcChain: "Ethereum";
|
|
200
200
|
srcAsset: "USDC";
|
|
201
|
+
destAsset: "FLIP" | "ETH";
|
|
201
202
|
destChain: "Ethereum";
|
|
202
203
|
destAddress: `0x${string}`;
|
|
203
|
-
destAsset: "FLIP" | "ETH";
|
|
204
204
|
ccmMetadata: {
|
|
205
|
-
message: string
|
|
205
|
+
message: `0x${string}`;
|
|
206
206
|
gasBudget: string;
|
|
207
207
|
};
|
|
208
208
|
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
@@ -216,16 +216,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
216
216
|
amount: bigint;
|
|
217
217
|
srcChain: "Ethereum";
|
|
218
218
|
srcAsset: "ETH";
|
|
219
|
+
destAsset: "FLIP" | "USDC";
|
|
219
220
|
destChain: "Ethereum";
|
|
220
221
|
destAddress: `0x${string}`;
|
|
221
|
-
destAsset: "FLIP" | "USDC";
|
|
222
222
|
}, {
|
|
223
223
|
amount: bigint;
|
|
224
224
|
srcChain: "Ethereum";
|
|
225
225
|
srcAsset: "ETH";
|
|
226
|
+
destAsset: "FLIP" | "USDC";
|
|
226
227
|
destChain: "Ethereum";
|
|
227
228
|
destAddress: `0x${string}`;
|
|
228
|
-
destAsset: "FLIP" | "USDC";
|
|
229
229
|
}>, z.ZodObject<{
|
|
230
230
|
amount: z.ZodBigInt;
|
|
231
231
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -237,16 +237,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
237
237
|
amount: bigint;
|
|
238
238
|
srcChain: "Ethereum";
|
|
239
239
|
srcAsset: "ETH";
|
|
240
|
+
destAsset: "DOT";
|
|
240
241
|
destChain: "Polkadot";
|
|
241
242
|
destAddress: string;
|
|
242
|
-
destAsset: "DOT";
|
|
243
243
|
}, {
|
|
244
244
|
amount: bigint;
|
|
245
245
|
srcChain: "Ethereum";
|
|
246
246
|
srcAsset: "ETH";
|
|
247
|
+
destAsset: "DOT";
|
|
247
248
|
destChain: "Polkadot";
|
|
248
249
|
destAddress: string;
|
|
249
|
-
destAsset: "DOT";
|
|
250
250
|
}>, z.ZodObject<{
|
|
251
251
|
amount: z.ZodBigInt;
|
|
252
252
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -258,16 +258,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
258
258
|
amount: bigint;
|
|
259
259
|
srcChain: "Ethereum";
|
|
260
260
|
srcAsset: "ETH";
|
|
261
|
+
destAsset: "BTC";
|
|
261
262
|
destChain: "Bitcoin";
|
|
262
263
|
destAddress: string;
|
|
263
|
-
destAsset: "BTC";
|
|
264
264
|
}, {
|
|
265
265
|
amount: bigint;
|
|
266
266
|
srcChain: "Ethereum";
|
|
267
267
|
srcAsset: "ETH";
|
|
268
|
+
destAsset: "BTC";
|
|
268
269
|
destChain: "Bitcoin";
|
|
269
270
|
destAddress: string;
|
|
270
|
-
destAsset: "BTC";
|
|
271
271
|
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
272
272
|
amount: z.ZodBigInt;
|
|
273
273
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -279,16 +279,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
279
279
|
amount: bigint;
|
|
280
280
|
srcChain: "Ethereum";
|
|
281
281
|
srcAsset: "FLIP";
|
|
282
|
+
destAsset: "USDC" | "ETH";
|
|
282
283
|
destChain: "Ethereum";
|
|
283
284
|
destAddress: `0x${string}`;
|
|
284
|
-
destAsset: "USDC" | "ETH";
|
|
285
285
|
}, {
|
|
286
286
|
amount: bigint;
|
|
287
287
|
srcChain: "Ethereum";
|
|
288
288
|
srcAsset: "FLIP";
|
|
289
|
+
destAsset: "USDC" | "ETH";
|
|
289
290
|
destChain: "Ethereum";
|
|
290
291
|
destAddress: `0x${string}`;
|
|
291
|
-
destAsset: "USDC" | "ETH";
|
|
292
292
|
}>, z.ZodObject<{
|
|
293
293
|
amount: z.ZodBigInt;
|
|
294
294
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -300,71 +300,71 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
300
300
|
amount: bigint;
|
|
301
301
|
srcChain: "Ethereum";
|
|
302
302
|
srcAsset: "USDC";
|
|
303
|
+
destAsset: "FLIP" | "ETH";
|
|
303
304
|
destChain: "Ethereum";
|
|
304
305
|
destAddress: `0x${string}`;
|
|
305
|
-
destAsset: "FLIP" | "ETH";
|
|
306
306
|
}, {
|
|
307
307
|
amount: bigint;
|
|
308
308
|
srcChain: "Ethereum";
|
|
309
309
|
srcAsset: "USDC";
|
|
310
|
+
destAsset: "FLIP" | "ETH";
|
|
310
311
|
destChain: "Ethereum";
|
|
311
312
|
destAddress: `0x${string}`;
|
|
312
|
-
destAsset: "FLIP" | "ETH";
|
|
313
313
|
}>, z.ZodObject<{
|
|
314
314
|
amount: z.ZodBigInt;
|
|
315
315
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
316
|
+
destAsset: z.ZodLiteral<"DOT">;
|
|
316
317
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
317
318
|
destAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>]>, string | null, string>, string, string>, string, string>;
|
|
318
|
-
destAsset: z.ZodLiteral<"DOT">;
|
|
319
319
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
320
320
|
}, "strip", z.ZodTypeAny, {
|
|
321
321
|
amount: bigint;
|
|
322
322
|
srcChain: "Ethereum";
|
|
323
323
|
srcAsset: "FLIP" | "USDC";
|
|
324
|
+
destAsset: "DOT";
|
|
324
325
|
destChain: "Polkadot";
|
|
325
326
|
destAddress: string;
|
|
326
|
-
destAsset: "DOT";
|
|
327
327
|
}, {
|
|
328
328
|
amount: bigint;
|
|
329
329
|
srcChain: "Ethereum";
|
|
330
330
|
srcAsset: "FLIP" | "USDC";
|
|
331
|
+
destAsset: "DOT";
|
|
331
332
|
destChain: "Polkadot";
|
|
332
333
|
destAddress: string;
|
|
333
|
-
destAsset: "DOT";
|
|
334
334
|
}>, z.ZodObject<{
|
|
335
335
|
amount: z.ZodBigInt;
|
|
336
336
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
337
|
+
destAsset: z.ZodLiteral<"BTC">;
|
|
337
338
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
338
339
|
destAddress: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string> | z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
|
|
339
|
-
destAsset: z.ZodLiteral<"BTC">;
|
|
340
340
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
341
341
|
}, "strip", z.ZodTypeAny, {
|
|
342
342
|
amount: bigint;
|
|
343
343
|
srcChain: "Ethereum";
|
|
344
344
|
srcAsset: "FLIP" | "USDC";
|
|
345
|
+
destAsset: "BTC";
|
|
345
346
|
destChain: "Bitcoin";
|
|
346
347
|
destAddress: string;
|
|
347
|
-
destAsset: "BTC";
|
|
348
348
|
}, {
|
|
349
349
|
amount: bigint;
|
|
350
350
|
srcChain: "Ethereum";
|
|
351
351
|
srcAsset: "FLIP" | "USDC";
|
|
352
|
+
destAsset: "BTC";
|
|
352
353
|
destChain: "Bitcoin";
|
|
353
354
|
destAddress: string;
|
|
354
|
-
destAsset: "BTC";
|
|
355
355
|
}>]>]>;
|
|
356
356
|
type ExecuteSwapParams = z.infer<typeof executeSwapParamsSchema>;
|
|
357
357
|
type TokenSwapParams = z.infer<typeof tokenSwapParamsSchema>;
|
|
358
358
|
|
|
359
359
|
declare const ccmMetadataSchema: z.ZodObject<{
|
|
360
|
-
gasBudget: z.
|
|
361
|
-
message: z.
|
|
360
|
+
gasBudget: z.ZodString;
|
|
361
|
+
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
362
362
|
}, "strip", z.ZodTypeAny, {
|
|
363
|
-
message: string
|
|
364
|
-
gasBudget:
|
|
363
|
+
message: `0x${string}`;
|
|
364
|
+
gasBudget: string;
|
|
365
365
|
}, {
|
|
366
|
-
message: string
|
|
367
|
-
gasBudget:
|
|
366
|
+
message: `0x${string}`;
|
|
367
|
+
gasBudget: string;
|
|
368
368
|
}>;
|
|
369
369
|
type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
|
|
370
370
|
declare const quoteResponseSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
@@ -537,7 +537,7 @@ type RequestOptions = {
|
|
|
537
537
|
};
|
|
538
538
|
|
|
539
539
|
type TransactionHash = `0x${string}`;
|
|
540
|
-
type
|
|
540
|
+
type SwapSDKOptions = {
|
|
541
541
|
network?: Exclude<ChainflipNetwork, 'mainnet'>;
|
|
542
542
|
signer?: Signer;
|
|
543
543
|
backendUrl?: string;
|
|
@@ -546,7 +546,7 @@ declare class SwapSDK {
|
|
|
546
546
|
private readonly baseUrl;
|
|
547
547
|
private readonly network;
|
|
548
548
|
private readonly signer?;
|
|
549
|
-
constructor(options?:
|
|
549
|
+
constructor(options?: SwapSDKOptions);
|
|
550
550
|
getChains(sourceChain?: Chain): Promise<ChainData[]>;
|
|
551
551
|
getAssets(chain: Chain): Promise<AssetData[]>;
|
|
552
552
|
getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
|
|
@@ -556,4 +556,4 @@ declare class SwapSDK {
|
|
|
556
556
|
approveVault(params: Pick<TokenSwapParams, 'srcAsset' | 'amount'>, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
export { Asset, AssetData, Chain, ChainData, ChainflipNetwork, DepositAddressRequest, DepositAddressResponse, QuoteRequest, QuoteResponse,
|
|
559
|
+
export { Asset, AssetData, Chain, ChainData, ChainflipNetwork, DepositAddressRequest, DepositAddressResponse, QuoteRequest, QuoteResponse, SwapSDK, SwapSDKOptions, SwapStatusRequest, SwapStatusResponse, chainAssets };
|
package/dist/swap.d.ts
CHANGED
|
@@ -14,16 +14,16 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
14
14
|
amount: bigint;
|
|
15
15
|
srcChain: "Ethereum";
|
|
16
16
|
srcAsset: "FLIP";
|
|
17
|
+
destAsset: "USDC" | "ETH";
|
|
17
18
|
destChain: "Ethereum";
|
|
18
19
|
destAddress: `0x${string}`;
|
|
19
|
-
destAsset: "USDC" | "ETH";
|
|
20
20
|
}, {
|
|
21
21
|
amount: bigint;
|
|
22
22
|
srcChain: "Ethereum";
|
|
23
23
|
srcAsset: "FLIP";
|
|
24
|
+
destAsset: "USDC" | "ETH";
|
|
24
25
|
destChain: "Ethereum";
|
|
25
26
|
destAddress: `0x${string}`;
|
|
26
|
-
destAsset: "USDC" | "ETH";
|
|
27
27
|
}>, z.ZodObject<{
|
|
28
28
|
amount: z.ZodBigInt;
|
|
29
29
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -35,174 +35,174 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
35
35
|
amount: bigint;
|
|
36
36
|
srcChain: "Ethereum";
|
|
37
37
|
srcAsset: "USDC";
|
|
38
|
+
destAsset: "FLIP" | "ETH";
|
|
38
39
|
destChain: "Ethereum";
|
|
39
40
|
destAddress: `0x${string}`;
|
|
40
|
-
destAsset: "FLIP" | "ETH";
|
|
41
41
|
}, {
|
|
42
42
|
amount: bigint;
|
|
43
43
|
srcChain: "Ethereum";
|
|
44
44
|
srcAsset: "USDC";
|
|
45
|
+
destAsset: "FLIP" | "ETH";
|
|
45
46
|
destChain: "Ethereum";
|
|
46
47
|
destAddress: `0x${string}`;
|
|
47
|
-
destAsset: "FLIP" | "ETH";
|
|
48
48
|
}>, z.ZodObject<{
|
|
49
49
|
amount: z.ZodBigInt;
|
|
50
50
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
51
|
+
destAsset: z.ZodLiteral<"DOT">;
|
|
51
52
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
52
53
|
destAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>]>, string | null, string>, string, string>, string, string>;
|
|
53
|
-
destAsset: z.ZodLiteral<"DOT">;
|
|
54
54
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
56
|
amount: bigint;
|
|
57
57
|
srcChain: "Ethereum";
|
|
58
58
|
srcAsset: "FLIP" | "USDC";
|
|
59
|
+
destAsset: "DOT";
|
|
59
60
|
destChain: "Polkadot";
|
|
60
61
|
destAddress: string;
|
|
61
|
-
destAsset: "DOT";
|
|
62
62
|
}, {
|
|
63
63
|
amount: bigint;
|
|
64
64
|
srcChain: "Ethereum";
|
|
65
65
|
srcAsset: "FLIP" | "USDC";
|
|
66
|
+
destAsset: "DOT";
|
|
66
67
|
destChain: "Polkadot";
|
|
67
68
|
destAddress: string;
|
|
68
|
-
destAsset: "DOT";
|
|
69
69
|
}>, z.ZodObject<{
|
|
70
70
|
amount: z.ZodBigInt;
|
|
71
71
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
72
|
+
destAsset: z.ZodLiteral<"BTC">;
|
|
72
73
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
73
74
|
destAddress: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string> | z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
|
|
74
|
-
destAsset: z.ZodLiteral<"BTC">;
|
|
75
75
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
76
76
|
}, "strip", z.ZodTypeAny, {
|
|
77
77
|
amount: bigint;
|
|
78
78
|
srcChain: "Ethereum";
|
|
79
79
|
srcAsset: "FLIP" | "USDC";
|
|
80
|
+
destAsset: "BTC";
|
|
80
81
|
destChain: "Bitcoin";
|
|
81
82
|
destAddress: string;
|
|
82
|
-
destAsset: "BTC";
|
|
83
83
|
}, {
|
|
84
84
|
amount: bigint;
|
|
85
85
|
srcChain: "Ethereum";
|
|
86
86
|
srcAsset: "FLIP" | "USDC";
|
|
87
|
+
destAsset: "BTC";
|
|
87
88
|
destChain: "Bitcoin";
|
|
88
89
|
destAddress: string;
|
|
89
|
-
destAsset: "BTC";
|
|
90
90
|
}>]>;
|
|
91
91
|
declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
92
92
|
amount: z.ZodBigInt;
|
|
93
93
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
94
94
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
95
|
+
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
95
96
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
96
97
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
97
|
-
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
98
98
|
ccmMetadata: z.ZodObject<{
|
|
99
|
-
message: z.ZodString;
|
|
100
99
|
gasBudget: z.ZodString;
|
|
100
|
+
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
101
101
|
}, "strip", z.ZodTypeAny, {
|
|
102
|
-
message: string
|
|
102
|
+
message: `0x${string}`;
|
|
103
103
|
gasBudget: string;
|
|
104
104
|
}, {
|
|
105
|
-
message: string
|
|
105
|
+
message: `0x${string}`;
|
|
106
106
|
gasBudget: string;
|
|
107
107
|
}>;
|
|
108
108
|
}, "strip", z.ZodTypeAny, {
|
|
109
109
|
amount: bigint;
|
|
110
110
|
srcChain: "Ethereum";
|
|
111
111
|
srcAsset: "ETH";
|
|
112
|
+
destAsset: "FLIP" | "USDC";
|
|
112
113
|
destChain: "Ethereum";
|
|
113
114
|
destAddress: `0x${string}`;
|
|
114
|
-
destAsset: "FLIP" | "USDC";
|
|
115
115
|
ccmMetadata: {
|
|
116
|
-
message: string
|
|
116
|
+
message: `0x${string}`;
|
|
117
117
|
gasBudget: string;
|
|
118
118
|
};
|
|
119
119
|
}, {
|
|
120
120
|
amount: bigint;
|
|
121
121
|
srcChain: "Ethereum";
|
|
122
122
|
srcAsset: "ETH";
|
|
123
|
+
destAsset: "FLIP" | "USDC";
|
|
123
124
|
destChain: "Ethereum";
|
|
124
125
|
destAddress: `0x${string}`;
|
|
125
|
-
destAsset: "FLIP" | "USDC";
|
|
126
126
|
ccmMetadata: {
|
|
127
|
-
message: string
|
|
127
|
+
message: `0x${string}`;
|
|
128
128
|
gasBudget: string;
|
|
129
129
|
};
|
|
130
130
|
}>, z.ZodUnion<[z.ZodObject<{
|
|
131
131
|
amount: z.ZodBigInt;
|
|
132
132
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
133
133
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
134
|
+
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
134
135
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
135
136
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
136
|
-
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
137
137
|
ccmMetadata: z.ZodObject<{
|
|
138
|
-
message: z.ZodString;
|
|
139
138
|
gasBudget: z.ZodString;
|
|
139
|
+
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
140
140
|
}, "strip", z.ZodTypeAny, {
|
|
141
|
-
message: string
|
|
141
|
+
message: `0x${string}`;
|
|
142
142
|
gasBudget: string;
|
|
143
143
|
}, {
|
|
144
|
-
message: string
|
|
144
|
+
message: `0x${string}`;
|
|
145
145
|
gasBudget: string;
|
|
146
146
|
}>;
|
|
147
147
|
}, "strip", z.ZodTypeAny, {
|
|
148
148
|
amount: bigint;
|
|
149
149
|
srcChain: "Ethereum";
|
|
150
150
|
srcAsset: "FLIP";
|
|
151
|
+
destAsset: "USDC" | "ETH";
|
|
151
152
|
destChain: "Ethereum";
|
|
152
153
|
destAddress: `0x${string}`;
|
|
153
|
-
destAsset: "USDC" | "ETH";
|
|
154
154
|
ccmMetadata: {
|
|
155
|
-
message: string
|
|
155
|
+
message: `0x${string}`;
|
|
156
156
|
gasBudget: string;
|
|
157
157
|
};
|
|
158
158
|
}, {
|
|
159
159
|
amount: bigint;
|
|
160
160
|
srcChain: "Ethereum";
|
|
161
161
|
srcAsset: "FLIP";
|
|
162
|
+
destAsset: "USDC" | "ETH";
|
|
162
163
|
destChain: "Ethereum";
|
|
163
164
|
destAddress: `0x${string}`;
|
|
164
|
-
destAsset: "USDC" | "ETH";
|
|
165
165
|
ccmMetadata: {
|
|
166
|
-
message: string
|
|
166
|
+
message: `0x${string}`;
|
|
167
167
|
gasBudget: string;
|
|
168
168
|
};
|
|
169
169
|
}>, z.ZodObject<{
|
|
170
170
|
amount: z.ZodBigInt;
|
|
171
171
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
172
172
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
173
|
+
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
173
174
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
174
175
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
175
|
-
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
176
176
|
ccmMetadata: z.ZodObject<{
|
|
177
|
-
message: z.ZodString;
|
|
178
177
|
gasBudget: z.ZodString;
|
|
178
|
+
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
179
179
|
}, "strip", z.ZodTypeAny, {
|
|
180
|
-
message: string
|
|
180
|
+
message: `0x${string}`;
|
|
181
181
|
gasBudget: string;
|
|
182
182
|
}, {
|
|
183
|
-
message: string
|
|
183
|
+
message: `0x${string}`;
|
|
184
184
|
gasBudget: string;
|
|
185
185
|
}>;
|
|
186
186
|
}, "strip", z.ZodTypeAny, {
|
|
187
187
|
amount: bigint;
|
|
188
188
|
srcChain: "Ethereum";
|
|
189
189
|
srcAsset: "USDC";
|
|
190
|
+
destAsset: "FLIP" | "ETH";
|
|
190
191
|
destChain: "Ethereum";
|
|
191
192
|
destAddress: `0x${string}`;
|
|
192
|
-
destAsset: "FLIP" | "ETH";
|
|
193
193
|
ccmMetadata: {
|
|
194
|
-
message: string
|
|
194
|
+
message: `0x${string}`;
|
|
195
195
|
gasBudget: string;
|
|
196
196
|
};
|
|
197
197
|
}, {
|
|
198
198
|
amount: bigint;
|
|
199
199
|
srcChain: "Ethereum";
|
|
200
200
|
srcAsset: "USDC";
|
|
201
|
+
destAsset: "FLIP" | "ETH";
|
|
201
202
|
destChain: "Ethereum";
|
|
202
203
|
destAddress: `0x${string}`;
|
|
203
|
-
destAsset: "FLIP" | "ETH";
|
|
204
204
|
ccmMetadata: {
|
|
205
|
-
message: string
|
|
205
|
+
message: `0x${string}`;
|
|
206
206
|
gasBudget: string;
|
|
207
207
|
};
|
|
208
208
|
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
@@ -216,16 +216,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
216
216
|
amount: bigint;
|
|
217
217
|
srcChain: "Ethereum";
|
|
218
218
|
srcAsset: "ETH";
|
|
219
|
+
destAsset: "FLIP" | "USDC";
|
|
219
220
|
destChain: "Ethereum";
|
|
220
221
|
destAddress: `0x${string}`;
|
|
221
|
-
destAsset: "FLIP" | "USDC";
|
|
222
222
|
}, {
|
|
223
223
|
amount: bigint;
|
|
224
224
|
srcChain: "Ethereum";
|
|
225
225
|
srcAsset: "ETH";
|
|
226
|
+
destAsset: "FLIP" | "USDC";
|
|
226
227
|
destChain: "Ethereum";
|
|
227
228
|
destAddress: `0x${string}`;
|
|
228
|
-
destAsset: "FLIP" | "USDC";
|
|
229
229
|
}>, z.ZodObject<{
|
|
230
230
|
amount: z.ZodBigInt;
|
|
231
231
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -237,16 +237,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
237
237
|
amount: bigint;
|
|
238
238
|
srcChain: "Ethereum";
|
|
239
239
|
srcAsset: "ETH";
|
|
240
|
+
destAsset: "DOT";
|
|
240
241
|
destChain: "Polkadot";
|
|
241
242
|
destAddress: string;
|
|
242
|
-
destAsset: "DOT";
|
|
243
243
|
}, {
|
|
244
244
|
amount: bigint;
|
|
245
245
|
srcChain: "Ethereum";
|
|
246
246
|
srcAsset: "ETH";
|
|
247
|
+
destAsset: "DOT";
|
|
247
248
|
destChain: "Polkadot";
|
|
248
249
|
destAddress: string;
|
|
249
|
-
destAsset: "DOT";
|
|
250
250
|
}>, z.ZodObject<{
|
|
251
251
|
amount: z.ZodBigInt;
|
|
252
252
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -258,16 +258,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
258
258
|
amount: bigint;
|
|
259
259
|
srcChain: "Ethereum";
|
|
260
260
|
srcAsset: "ETH";
|
|
261
|
+
destAsset: "BTC";
|
|
261
262
|
destChain: "Bitcoin";
|
|
262
263
|
destAddress: string;
|
|
263
|
-
destAsset: "BTC";
|
|
264
264
|
}, {
|
|
265
265
|
amount: bigint;
|
|
266
266
|
srcChain: "Ethereum";
|
|
267
267
|
srcAsset: "ETH";
|
|
268
|
+
destAsset: "BTC";
|
|
268
269
|
destChain: "Bitcoin";
|
|
269
270
|
destAddress: string;
|
|
270
|
-
destAsset: "BTC";
|
|
271
271
|
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
272
272
|
amount: z.ZodBigInt;
|
|
273
273
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -279,16 +279,16 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
279
279
|
amount: bigint;
|
|
280
280
|
srcChain: "Ethereum";
|
|
281
281
|
srcAsset: "FLIP";
|
|
282
|
+
destAsset: "USDC" | "ETH";
|
|
282
283
|
destChain: "Ethereum";
|
|
283
284
|
destAddress: `0x${string}`;
|
|
284
|
-
destAsset: "USDC" | "ETH";
|
|
285
285
|
}, {
|
|
286
286
|
amount: bigint;
|
|
287
287
|
srcChain: "Ethereum";
|
|
288
288
|
srcAsset: "FLIP";
|
|
289
|
+
destAsset: "USDC" | "ETH";
|
|
289
290
|
destChain: "Ethereum";
|
|
290
291
|
destAddress: `0x${string}`;
|
|
291
|
-
destAsset: "USDC" | "ETH";
|
|
292
292
|
}>, z.ZodObject<{
|
|
293
293
|
amount: z.ZodBigInt;
|
|
294
294
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
@@ -300,71 +300,71 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
300
300
|
amount: bigint;
|
|
301
301
|
srcChain: "Ethereum";
|
|
302
302
|
srcAsset: "USDC";
|
|
303
|
+
destAsset: "FLIP" | "ETH";
|
|
303
304
|
destChain: "Ethereum";
|
|
304
305
|
destAddress: `0x${string}`;
|
|
305
|
-
destAsset: "FLIP" | "ETH";
|
|
306
306
|
}, {
|
|
307
307
|
amount: bigint;
|
|
308
308
|
srcChain: "Ethereum";
|
|
309
309
|
srcAsset: "USDC";
|
|
310
|
+
destAsset: "FLIP" | "ETH";
|
|
310
311
|
destChain: "Ethereum";
|
|
311
312
|
destAddress: `0x${string}`;
|
|
312
|
-
destAsset: "FLIP" | "ETH";
|
|
313
313
|
}>, z.ZodObject<{
|
|
314
314
|
amount: z.ZodBigInt;
|
|
315
315
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
316
|
+
destAsset: z.ZodLiteral<"DOT">;
|
|
316
317
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
317
318
|
destAddress: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodUnion<[z.ZodString, z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>]>, string | null, string>, string, string>, string, string>;
|
|
318
|
-
destAsset: z.ZodLiteral<"DOT">;
|
|
319
319
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
320
320
|
}, "strip", z.ZodTypeAny, {
|
|
321
321
|
amount: bigint;
|
|
322
322
|
srcChain: "Ethereum";
|
|
323
323
|
srcAsset: "FLIP" | "USDC";
|
|
324
|
+
destAsset: "DOT";
|
|
324
325
|
destChain: "Polkadot";
|
|
325
326
|
destAddress: string;
|
|
326
|
-
destAsset: "DOT";
|
|
327
327
|
}, {
|
|
328
328
|
amount: bigint;
|
|
329
329
|
srcChain: "Ethereum";
|
|
330
330
|
srcAsset: "FLIP" | "USDC";
|
|
331
|
+
destAsset: "DOT";
|
|
331
332
|
destChain: "Polkadot";
|
|
332
333
|
destAddress: string;
|
|
333
|
-
destAsset: "DOT";
|
|
334
334
|
}>, z.ZodObject<{
|
|
335
335
|
amount: z.ZodBigInt;
|
|
336
336
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
337
|
+
destAsset: z.ZodLiteral<"BTC">;
|
|
337
338
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
338
339
|
destAddress: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string> | z.ZodEffects<z.ZodUnion<[z.ZodEffects<z.ZodString, string, string>, z.ZodEffects<z.ZodString, string, string>]>, string, string>;
|
|
339
|
-
destAsset: z.ZodLiteral<"BTC">;
|
|
340
340
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
341
341
|
}, "strip", z.ZodTypeAny, {
|
|
342
342
|
amount: bigint;
|
|
343
343
|
srcChain: "Ethereum";
|
|
344
344
|
srcAsset: "FLIP" | "USDC";
|
|
345
|
+
destAsset: "BTC";
|
|
345
346
|
destChain: "Bitcoin";
|
|
346
347
|
destAddress: string;
|
|
347
|
-
destAsset: "BTC";
|
|
348
348
|
}, {
|
|
349
349
|
amount: bigint;
|
|
350
350
|
srcChain: "Ethereum";
|
|
351
351
|
srcAsset: "FLIP" | "USDC";
|
|
352
|
+
destAsset: "BTC";
|
|
352
353
|
destChain: "Bitcoin";
|
|
353
354
|
destAddress: string;
|
|
354
|
-
destAsset: "BTC";
|
|
355
355
|
}>]>]>;
|
|
356
356
|
type ExecuteSwapParams = z.infer<typeof executeSwapParamsSchema>;
|
|
357
357
|
type TokenSwapParams = z.infer<typeof tokenSwapParamsSchema>;
|
|
358
358
|
|
|
359
359
|
declare const ccmMetadataSchema: z.ZodObject<{
|
|
360
|
-
gasBudget: z.
|
|
361
|
-
message: z.
|
|
360
|
+
gasBudget: z.ZodString;
|
|
361
|
+
message: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
|
|
362
362
|
}, "strip", z.ZodTypeAny, {
|
|
363
|
-
message: string
|
|
364
|
-
gasBudget:
|
|
363
|
+
message: `0x${string}`;
|
|
364
|
+
gasBudget: string;
|
|
365
365
|
}, {
|
|
366
|
-
message: string
|
|
367
|
-
gasBudget:
|
|
366
|
+
message: `0x${string}`;
|
|
367
|
+
gasBudget: string;
|
|
368
368
|
}>;
|
|
369
369
|
type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
|
|
370
370
|
declare const quoteResponseSchema: z.ZodUnion<[z.ZodEffects<z.ZodObject<{
|
|
@@ -537,7 +537,7 @@ type RequestOptions = {
|
|
|
537
537
|
};
|
|
538
538
|
|
|
539
539
|
type TransactionHash = `0x${string}`;
|
|
540
|
-
type
|
|
540
|
+
type SwapSDKOptions = {
|
|
541
541
|
network?: Exclude<ChainflipNetwork, 'mainnet'>;
|
|
542
542
|
signer?: Signer;
|
|
543
543
|
backendUrl?: string;
|
|
@@ -546,7 +546,7 @@ declare class SwapSDK {
|
|
|
546
546
|
private readonly baseUrl;
|
|
547
547
|
private readonly network;
|
|
548
548
|
private readonly signer?;
|
|
549
|
-
constructor(options?:
|
|
549
|
+
constructor(options?: SwapSDKOptions);
|
|
550
550
|
getChains(sourceChain?: Chain): Promise<ChainData[]>;
|
|
551
551
|
getAssets(chain: Chain): Promise<AssetData[]>;
|
|
552
552
|
getQuote(quoteRequest: QuoteRequest, options?: RequestOptions): Promise<QuoteResponse>;
|
|
@@ -556,4 +556,4 @@ declare class SwapSDK {
|
|
|
556
556
|
approveVault(params: Pick<TokenSwapParams, 'srcAsset' | 'amount'>, txOpts?: TransactionOptions): Promise<TransactionHash | null>;
|
|
557
557
|
}
|
|
558
558
|
|
|
559
|
-
export { Asset, AssetData, Chain, ChainData, ChainflipNetwork, DepositAddressRequest, DepositAddressResponse, QuoteRequest, QuoteResponse,
|
|
559
|
+
export { Asset, AssetData, Chain, ChainData, ChainflipNetwork, DepositAddressRequest, DepositAddressResponse, QuoteRequest, QuoteResponse, SwapSDK, SwapSDKOptions, SwapStatusRequest, SwapStatusResponse, chainAssets };
|
package/dist/swap.js
CHANGED
|
@@ -411,8 +411,8 @@ zod.z.object({
|
|
|
411
411
|
"Btc"
|
|
412
412
|
])
|
|
413
413
|
}).transform(({ __kind }) => __kind.toUpperCase());
|
|
414
|
-
zod.z.nativeEnum(Chains);
|
|
415
|
-
zod.z.nativeEnum(Assets);
|
|
414
|
+
var chainflipChain = zod.z.nativeEnum(Chains);
|
|
415
|
+
var chainflipAsset = zod.z.nativeEnum(Assets);
|
|
416
416
|
zod.z.nativeEnum(ChainflipNetworks);
|
|
417
417
|
zod.z.union([
|
|
418
418
|
zod.z.object({
|
|
@@ -435,6 +435,45 @@ zod.z.union([
|
|
|
435
435
|
type: "SWAP"
|
|
436
436
|
}))
|
|
437
437
|
]);
|
|
438
|
+
zod.z.object({
|
|
439
|
+
srcAsset: chainflipAsset,
|
|
440
|
+
destAsset: chainflipAsset,
|
|
441
|
+
amount: numericString
|
|
442
|
+
});
|
|
443
|
+
var ccmMetadataSchema = zod.z.object({
|
|
444
|
+
gasBudget: numericString,
|
|
445
|
+
message: hexString
|
|
446
|
+
});
|
|
447
|
+
zod.z.object({
|
|
448
|
+
srcAsset: chainflipAsset,
|
|
449
|
+
destAsset: chainflipAsset,
|
|
450
|
+
srcChain: chainflipChain,
|
|
451
|
+
destChain: chainflipChain,
|
|
452
|
+
destAddress: zod.z.string(),
|
|
453
|
+
amount: numericString,
|
|
454
|
+
ccmMetadata: ccmMetadataSchema.optional()
|
|
455
|
+
}).transform(({ amount, ...rest }) => ({
|
|
456
|
+
...rest,
|
|
457
|
+
expectedDepositAmount: amount
|
|
458
|
+
}));
|
|
459
|
+
zod.z.union([
|
|
460
|
+
zod.z.object({
|
|
461
|
+
id: zod.z.string(),
|
|
462
|
+
intermediate_amount: numericString,
|
|
463
|
+
egress_amount: numericString
|
|
464
|
+
}).transform(({ id, ...rest }) => ({
|
|
465
|
+
id,
|
|
466
|
+
intermediateAmount: rest.intermediate_amount,
|
|
467
|
+
egressAmount: rest.egress_amount
|
|
468
|
+
})),
|
|
469
|
+
zod.z.object({
|
|
470
|
+
id: zod.z.string(),
|
|
471
|
+
egress_amount: numericString
|
|
472
|
+
}).transform(({ id, ...rest }) => ({
|
|
473
|
+
id,
|
|
474
|
+
egressAmount: rest.egress_amount
|
|
475
|
+
}))
|
|
476
|
+
]);
|
|
438
477
|
|
|
439
478
|
// ../shared/src/vault/schemas.ts
|
|
440
479
|
var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
@@ -498,10 +537,6 @@ var tokenSwapParamsSchema = zod.z.union([
|
|
|
498
537
|
erc20ToDot,
|
|
499
538
|
erc20ToBtc
|
|
500
539
|
]);
|
|
501
|
-
var ccmMetadataSchema = zod.z.object({
|
|
502
|
-
message: zod.z.string(),
|
|
503
|
-
gasBudget: numericString
|
|
504
|
-
});
|
|
505
540
|
var ccmFlipToEthereumAssset = flipToEthereumAsset.extend({
|
|
506
541
|
ccmMetadata: ccmMetadataSchema
|
|
507
542
|
});
|
|
@@ -1904,7 +1939,7 @@ var getVaultManagerContractAddress = /* @__PURE__ */ __name((network) => {
|
|
|
1904
1939
|
var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, networkOpts, txOpts) => {
|
|
1905
1940
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1906
1941
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
1907
|
-
const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], "", {
|
|
1942
|
+
const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], "0x", {
|
|
1908
1943
|
value: amount,
|
|
1909
1944
|
...extractOverrides(txOpts)
|
|
1910
1945
|
});
|
|
@@ -1917,13 +1952,13 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
1917
1952
|
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1918
1953
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
1919
1954
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
1920
|
-
const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "", extractOverrides(txOpts));
|
|
1955
|
+
const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
1921
1956
|
return transaction.wait(txOpts.wait);
|
|
1922
1957
|
}, "swapToken");
|
|
1923
1958
|
var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
1924
1959
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1925
1960
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
1926
|
-
const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, "", {
|
|
1961
|
+
const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, "0x", {
|
|
1927
1962
|
value: params.amount,
|
|
1928
1963
|
...extractOverrides(txOpts)
|
|
1929
1964
|
});
|
|
@@ -1936,7 +1971,7 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
1936
1971
|
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1937
1972
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
1938
1973
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
1939
|
-
const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "", extractOverrides(txOpts));
|
|
1974
|
+
const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
1940
1975
|
return transaction.wait(txOpts.wait);
|
|
1941
1976
|
}, "callToken");
|
|
1942
1977
|
var executeSwap = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
package/dist/swap.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isString, Chains, Assets, ChainflipNetworks, __name, __publicField, assert, getVaultManagerContractAddress, approve, isTokenCall, isTokenSwap, getTokenContractAddress, checkAllowance, Vault__factory, chainContractIds, assetContractIds, extractOverrides, assetDecimals, isTestnet, getMinimumDepositAmount, getMinimumSwapAmount } from './chunk-
|
|
2
|
-
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-
|
|
1
|
+
import { isString, Chains, Assets, ChainflipNetworks, __name, __publicField, assert, getVaultManagerContractAddress, approve, isTokenCall, isTokenSwap, getTokenContractAddress, checkAllowance, Vault__factory, chainContractIds, assetContractIds, extractOverrides, assetDecimals, isTestnet, getMinimumDepositAmount, getMinimumSwapAmount } from './chunk-FTLY2OML.mjs';
|
|
2
|
+
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-FTLY2OML.mjs';
|
|
3
3
|
import { encodeAddress, decodeAddress, base58Decode } from '@polkadot/util-crypto';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { hexToU8a } from '@polkadot/util';
|
|
@@ -299,8 +299,8 @@ z.object({
|
|
|
299
299
|
"Btc"
|
|
300
300
|
])
|
|
301
301
|
}).transform(({ __kind }) => __kind.toUpperCase());
|
|
302
|
-
z.nativeEnum(Chains);
|
|
303
|
-
z.nativeEnum(Assets);
|
|
302
|
+
var chainflipChain = z.nativeEnum(Chains);
|
|
303
|
+
var chainflipAsset = z.nativeEnum(Assets);
|
|
304
304
|
z.nativeEnum(ChainflipNetworks);
|
|
305
305
|
z.union([
|
|
306
306
|
z.object({
|
|
@@ -323,6 +323,45 @@ z.union([
|
|
|
323
323
|
type: "SWAP"
|
|
324
324
|
}))
|
|
325
325
|
]);
|
|
326
|
+
z.object({
|
|
327
|
+
srcAsset: chainflipAsset,
|
|
328
|
+
destAsset: chainflipAsset,
|
|
329
|
+
amount: numericString
|
|
330
|
+
});
|
|
331
|
+
var ccmMetadataSchema = z.object({
|
|
332
|
+
gasBudget: numericString,
|
|
333
|
+
message: hexString
|
|
334
|
+
});
|
|
335
|
+
z.object({
|
|
336
|
+
srcAsset: chainflipAsset,
|
|
337
|
+
destAsset: chainflipAsset,
|
|
338
|
+
srcChain: chainflipChain,
|
|
339
|
+
destChain: chainflipChain,
|
|
340
|
+
destAddress: z.string(),
|
|
341
|
+
amount: numericString,
|
|
342
|
+
ccmMetadata: ccmMetadataSchema.optional()
|
|
343
|
+
}).transform(({ amount, ...rest }) => ({
|
|
344
|
+
...rest,
|
|
345
|
+
expectedDepositAmount: amount
|
|
346
|
+
}));
|
|
347
|
+
z.union([
|
|
348
|
+
z.object({
|
|
349
|
+
id: z.string(),
|
|
350
|
+
intermediate_amount: numericString,
|
|
351
|
+
egress_amount: numericString
|
|
352
|
+
}).transform(({ id, ...rest }) => ({
|
|
353
|
+
id,
|
|
354
|
+
intermediateAmount: rest.intermediate_amount,
|
|
355
|
+
egressAmount: rest.egress_amount
|
|
356
|
+
})),
|
|
357
|
+
z.object({
|
|
358
|
+
id: z.string(),
|
|
359
|
+
egress_amount: numericString
|
|
360
|
+
}).transform(({ id, ...rest }) => ({
|
|
361
|
+
id,
|
|
362
|
+
egressAmount: rest.egress_amount
|
|
363
|
+
}))
|
|
364
|
+
]);
|
|
326
365
|
|
|
327
366
|
// ../shared/src/vault/schemas.ts
|
|
328
367
|
var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
@@ -386,10 +425,6 @@ var tokenSwapParamsSchema = z.union([
|
|
|
386
425
|
erc20ToDot,
|
|
387
426
|
erc20ToBtc
|
|
388
427
|
]);
|
|
389
|
-
var ccmMetadataSchema = z.object({
|
|
390
|
-
message: z.string(),
|
|
391
|
-
gasBudget: numericString
|
|
392
|
-
});
|
|
393
428
|
var ccmFlipToEthereumAssset = flipToEthereumAsset.extend({
|
|
394
429
|
ccmMetadata: ccmMetadataSchema
|
|
395
430
|
});
|
|
@@ -415,7 +450,7 @@ var executeSwapParamsSchema = z.union([
|
|
|
415
450
|
var swapNative = /* @__PURE__ */ __name(async ({ destChain, destAsset, destAddress, amount }, networkOpts, txOpts) => {
|
|
416
451
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
417
452
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
418
|
-
const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], "", {
|
|
453
|
+
const transaction = await vault.xSwapNative(chainContractIds[destChain], destAddress, assetContractIds[destAsset], "0x", {
|
|
419
454
|
value: amount,
|
|
420
455
|
...extractOverrides(txOpts)
|
|
421
456
|
});
|
|
@@ -428,13 +463,13 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
428
463
|
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
429
464
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
430
465
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
431
|
-
const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "", extractOverrides(txOpts));
|
|
466
|
+
const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
432
467
|
return transaction.wait(txOpts.wait);
|
|
433
468
|
}, "swapToken");
|
|
434
469
|
var callNative = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
435
470
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
436
471
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
437
|
-
const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, "", {
|
|
472
|
+
const transaction = await vault.xCallNative(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, "0x", {
|
|
438
473
|
value: params.amount,
|
|
439
474
|
...extractOverrides(txOpts)
|
|
440
475
|
});
|
|
@@ -447,7 +482,7 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
447
482
|
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
448
483
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
449
484
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
450
|
-
const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "", extractOverrides(txOpts));
|
|
485
|
+
const transaction = await vault.xCallToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], params.ccmMetadata.message, params.ccmMetadata.gasBudget, erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
451
486
|
return transaction.wait(txOpts.wait);
|
|
452
487
|
}, "callToken");
|
|
453
488
|
var executeSwap = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@polkadot/util": "^12.
|
|
45
|
-
"@polkadot/util-crypto": "^12.
|
|
44
|
+
"@polkadot/util": "^12.5.1",
|
|
45
|
+
"@polkadot/util-crypto": "^12.5.1",
|
|
46
46
|
"axios": "^1.5.0",
|
|
47
47
|
"ethers": "6.7.1",
|
|
48
48
|
"zod": "^3.22.2"
|
|
@@ -73,6 +73,21 @@ var chainContractIds = {
|
|
|
73
73
|
[Chains.Polkadot]: 2,
|
|
74
74
|
[Chains.Bitcoin]: 3
|
|
75
75
|
};
|
|
76
|
+
|
|
77
|
+
// ../shared/src/guards.ts
|
|
78
|
+
var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
79
|
+
function assert(condition, message) {
|
|
80
|
+
if (condition)
|
|
81
|
+
return;
|
|
82
|
+
const error = new Error(message);
|
|
83
|
+
if (error.stack) {
|
|
84
|
+
error.stack = error.stack.replace(/\n.+/, "\n");
|
|
85
|
+
}
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
__name(assert, "assert");
|
|
89
|
+
var isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenSwap");
|
|
90
|
+
var isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenCall");
|
|
76
91
|
var _abi = [
|
|
77
92
|
{
|
|
78
93
|
inputs: [
|
|
@@ -2089,21 +2104,6 @@ var ADDRESSES = {
|
|
|
2089
2104
|
};
|
|
2090
2105
|
var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
|
|
2091
2106
|
|
|
2092
|
-
// ../shared/src/guards.ts
|
|
2093
|
-
var isString = /* @__PURE__ */ __name((value) => typeof value === "string", "isString");
|
|
2094
|
-
function assert(condition, message) {
|
|
2095
|
-
if (condition)
|
|
2096
|
-
return;
|
|
2097
|
-
const error = new Error(message);
|
|
2098
|
-
if (error.stack) {
|
|
2099
|
-
error.stack = error.stack.replace(/\n.+/, "\n");
|
|
2100
|
-
}
|
|
2101
|
-
throw error;
|
|
2102
|
-
}
|
|
2103
|
-
__name(assert, "assert");
|
|
2104
|
-
var isTokenSwap = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenSwap");
|
|
2105
|
-
var isTokenCall = /* @__PURE__ */ __name((params) => params.srcAsset !== Assets.ETH, "isTokenCall");
|
|
2106
|
-
|
|
2107
2107
|
// ../shared/src/contracts.ts
|
|
2108
2108
|
var extractOverrides = /* @__PURE__ */ __name((transactionOverrides) => {
|
|
2109
2109
|
const { wait, ...ethersOverrides } = transactionOverrides;
|