@chainflip/sdk 0.2.3 → 0.2.5
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/{chunk-FTLY2OML.mjs → chunk-HR2UQBMZ.mjs} +6 -9
- package/dist/{contracts-646d1727.d.ts → contracts-920ad844.d.ts} +1 -1
- package/dist/funding.d.mts +1 -1
- package/dist/funding.d.ts +1 -1
- package/dist/funding.js +6 -9
- package/dist/funding.mjs +1 -1
- package/dist/swap.d.mts +53 -80
- package/dist/swap.d.ts +53 -80
- package/dist/swap.js +19 -41
- package/dist/swap.mjs +15 -34
- package/package.json +2 -2
|
@@ -26,7 +26,6 @@ var Assets = arrayToMap([
|
|
|
26
26
|
"BTC"
|
|
27
27
|
]);
|
|
28
28
|
var ChainflipNetworks = arrayToMap([
|
|
29
|
-
"partnernet",
|
|
30
29
|
"sisyphos",
|
|
31
30
|
"perseverance",
|
|
32
31
|
"mainnet"
|
|
@@ -2065,8 +2064,11 @@ __publicField(_Vault__factory, "abi", _abi3);
|
|
|
2065
2064
|
var Vault__factory = _Vault__factory;
|
|
2066
2065
|
|
|
2067
2066
|
// ../shared/src/consts.ts
|
|
2067
|
+
({
|
|
2068
|
+
[ChainflipNetworks.perseverance]: 100
|
|
2069
|
+
});
|
|
2068
2070
|
var MINIMUM_DEPOSIT_AMOUNTS = {
|
|
2069
|
-
[ChainflipNetworks.
|
|
2071
|
+
[ChainflipNetworks.perseverance]: {
|
|
2070
2072
|
[Assets.ETH]: "0",
|
|
2071
2073
|
[Assets.FLIP]: "0",
|
|
2072
2074
|
[Assets.USDC]: "0",
|
|
@@ -2076,11 +2078,11 @@ var MINIMUM_DEPOSIT_AMOUNTS = {
|
|
|
2076
2078
|
};
|
|
2077
2079
|
var getMinimumDepositAmount = /* @__PURE__ */ __name((network, asset) => MINIMUM_DEPOSIT_AMOUNTS[network]?.[asset] ?? "0", "getMinimumDepositAmount");
|
|
2078
2080
|
var MINIMUM_SWAP_AMOUNTS = {
|
|
2079
|
-
[ChainflipNetworks.
|
|
2081
|
+
[ChainflipNetworks.perseverance]: {
|
|
2080
2082
|
[Assets.ETH]: "580000000000000",
|
|
2081
2083
|
[Assets.FLIP]: "1000000000000000000",
|
|
2082
2084
|
[Assets.USDC]: "1000000",
|
|
2083
|
-
[Assets.BTC]: "
|
|
2085
|
+
[Assets.BTC]: "1000",
|
|
2084
2086
|
[Assets.DOT]: "2000000000"
|
|
2085
2087
|
}
|
|
2086
2088
|
};
|
|
@@ -2091,11 +2093,6 @@ var ADDRESSES = {
|
|
|
2091
2093
|
VAULT_CONTRACT_ADDRESS: "0xC17CCec5015081EB2DF26d20A9e02c5484C1d641",
|
|
2092
2094
|
STATE_CHAIN_GATEWAY_ADDRESS: "0xE8bE4B7F8a38C1913387c9C20B94402bc3Db9F70"
|
|
2093
2095
|
},
|
|
2094
|
-
[ChainflipNetworks.partnernet]: {
|
|
2095
|
-
FLIP_CONTRACT_ADDRESS: "0x1Ea4F05a319A8f779F05E153974605756bB13D4F",
|
|
2096
|
-
VAULT_CONTRACT_ADDRESS: "0xAfD0C34E6d25F707d931F8b7EE9cf0Ff52160A46",
|
|
2097
|
-
STATE_CHAIN_GATEWAY_ADDRESS: "0x07B3Bef16c640B072085BF83C24b6C43000aE056"
|
|
2098
|
-
},
|
|
2099
2096
|
[ChainflipNetworks.perseverance]: {
|
|
2100
2097
|
FLIP_CONTRACT_ADDRESS: "0x0485D65da68b2A6b48C3fA28D7CCAce196798B94",
|
|
2101
2098
|
VAULT_CONTRACT_ADDRESS: "0x40caFF3f3B6706Da904a7895e0fC7F7922437e9B",
|
|
@@ -5,7 +5,7 @@ declare const Chains: ArrayToMap<readonly ["Bitcoin", "Ethereum", "Polkadot"]>;
|
|
|
5
5
|
type Chain = (typeof Chains)[keyof typeof Chains];
|
|
6
6
|
declare const Assets: ArrayToMap<readonly ["FLIP", "USDC", "DOT", "ETH", "BTC"]>;
|
|
7
7
|
type Asset = (typeof Assets)[keyof typeof Assets];
|
|
8
|
-
declare const ChainflipNetworks: ArrayToMap<readonly ["
|
|
8
|
+
declare const ChainflipNetworks: ArrayToMap<readonly ["sisyphos", "perseverance", "mainnet"]>;
|
|
9
9
|
type ChainflipNetwork = (typeof ChainflipNetworks)[keyof typeof ChainflipNetworks];
|
|
10
10
|
declare const assetChains: {
|
|
11
11
|
ETH: "Ethereum";
|
package/dist/funding.d.mts
CHANGED
package/dist/funding.d.ts
CHANGED
package/dist/funding.js
CHANGED
|
@@ -779,7 +779,6 @@ var Assets = arrayToMap([
|
|
|
779
779
|
"BTC"
|
|
780
780
|
]);
|
|
781
781
|
var ChainflipNetworks = arrayToMap([
|
|
782
|
-
"partnernet",
|
|
783
782
|
"sisyphos",
|
|
784
783
|
"perseverance",
|
|
785
784
|
"mainnet"
|
|
@@ -828,7 +827,10 @@ var ChainflipNetworks = arrayToMap([
|
|
|
828
827
|
|
|
829
828
|
// ../shared/src/consts.ts
|
|
830
829
|
({
|
|
831
|
-
[ChainflipNetworks.
|
|
830
|
+
[ChainflipNetworks.perseverance]: 100
|
|
831
|
+
});
|
|
832
|
+
({
|
|
833
|
+
[ChainflipNetworks.perseverance]: {
|
|
832
834
|
[Assets.ETH]: "0",
|
|
833
835
|
[Assets.FLIP]: "0",
|
|
834
836
|
[Assets.USDC]: "0",
|
|
@@ -837,11 +839,11 @@ var ChainflipNetworks = arrayToMap([
|
|
|
837
839
|
}
|
|
838
840
|
});
|
|
839
841
|
({
|
|
840
|
-
[ChainflipNetworks.
|
|
842
|
+
[ChainflipNetworks.perseverance]: {
|
|
841
843
|
[Assets.ETH]: "580000000000000",
|
|
842
844
|
[Assets.FLIP]: "1000000000000000000",
|
|
843
845
|
[Assets.USDC]: "1000000",
|
|
844
|
-
[Assets.BTC]: "
|
|
846
|
+
[Assets.BTC]: "1000",
|
|
845
847
|
[Assets.DOT]: "2000000000"
|
|
846
848
|
}
|
|
847
849
|
});
|
|
@@ -851,11 +853,6 @@ var ADDRESSES = {
|
|
|
851
853
|
VAULT_CONTRACT_ADDRESS: "0xC17CCec5015081EB2DF26d20A9e02c5484C1d641",
|
|
852
854
|
STATE_CHAIN_GATEWAY_ADDRESS: "0xE8bE4B7F8a38C1913387c9C20B94402bc3Db9F70"
|
|
853
855
|
},
|
|
854
|
-
[ChainflipNetworks.partnernet]: {
|
|
855
|
-
FLIP_CONTRACT_ADDRESS: "0x1Ea4F05a319A8f779F05E153974605756bB13D4F",
|
|
856
|
-
VAULT_CONTRACT_ADDRESS: "0xAfD0C34E6d25F707d931F8b7EE9cf0Ff52160A46",
|
|
857
|
-
STATE_CHAIN_GATEWAY_ADDRESS: "0x07B3Bef16c640B072085BF83C24b6C43000aE056"
|
|
858
|
-
},
|
|
859
856
|
[ChainflipNetworks.perseverance]: {
|
|
860
857
|
FLIP_CONTRACT_ADDRESS: "0x0485D65da68b2A6b48C3fA28D7CCAce196798B94",
|
|
861
858
|
VAULT_CONTRACT_ADDRESS: "0x40caFF3f3B6706Da904a7895e0fC7F7922437e9B",
|
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-HR2UQBMZ.mjs';
|
|
2
2
|
|
|
3
3
|
// ../shared/src/stateChainGateway/utils.ts
|
|
4
4
|
var getStateChainGateway = /* @__PURE__ */ __name((networkOpts) => {
|
package/dist/swap.d.mts
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import {
|
|
3
|
-
export { d as Assets, e as ChainflipNetworks, b as Chains, f as assetChains, h as assetContractIds, g as assetDecimals, i as chainContractIds } from './contracts-
|
|
2
|
+
import { A as Asset, C as Chain, c as chainAssets, a as ChainflipNetwork, T as TransactionOptions } from './contracts-920ad844.js';
|
|
3
|
+
export { d as Assets, e as ChainflipNetworks, b as Chains, f as assetChains, h as assetContractIds, g as assetDecimals, i as chainContractIds } from './contracts-920ad844.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
7
|
-
amount: z.
|
|
7
|
+
amount: z.ZodString;
|
|
8
8
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
9
9
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
10
10
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
11
11
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
12
12
|
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
amount:
|
|
14
|
+
amount: string;
|
|
15
15
|
srcChain: "Ethereum";
|
|
16
16
|
srcAsset: "FLIP";
|
|
17
17
|
destAsset: "USDC" | "ETH";
|
|
18
18
|
destChain: "Ethereum";
|
|
19
19
|
destAddress: `0x${string}`;
|
|
20
20
|
}, {
|
|
21
|
-
amount:
|
|
21
|
+
amount: string;
|
|
22
22
|
srcChain: "Ethereum";
|
|
23
23
|
srcAsset: "FLIP";
|
|
24
24
|
destAsset: "USDC" | "ETH";
|
|
25
25
|
destChain: "Ethereum";
|
|
26
26
|
destAddress: `0x${string}`;
|
|
27
27
|
}>, z.ZodObject<{
|
|
28
|
-
amount: z.
|
|
28
|
+
amount: z.ZodString;
|
|
29
29
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
30
30
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
31
31
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
32
32
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
33
33
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
34
34
|
}, "strip", z.ZodTypeAny, {
|
|
35
|
-
amount:
|
|
35
|
+
amount: string;
|
|
36
36
|
srcChain: "Ethereum";
|
|
37
37
|
srcAsset: "USDC";
|
|
38
38
|
destAsset: "FLIP" | "ETH";
|
|
39
39
|
destChain: "Ethereum";
|
|
40
40
|
destAddress: `0x${string}`;
|
|
41
41
|
}, {
|
|
42
|
-
amount:
|
|
42
|
+
amount: string;
|
|
43
43
|
srcChain: "Ethereum";
|
|
44
44
|
srcAsset: "USDC";
|
|
45
45
|
destAsset: "FLIP" | "ETH";
|
|
46
46
|
destChain: "Ethereum";
|
|
47
47
|
destAddress: `0x${string}`;
|
|
48
48
|
}>, z.ZodObject<{
|
|
49
|
-
amount: z.
|
|
49
|
+
amount: z.ZodString;
|
|
50
50
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
51
51
|
destAsset: z.ZodLiteral<"DOT">;
|
|
52
52
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
53
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>;
|
|
54
54
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
amount:
|
|
56
|
+
amount: string;
|
|
57
57
|
srcChain: "Ethereum";
|
|
58
58
|
srcAsset: "FLIP" | "USDC";
|
|
59
59
|
destAsset: "DOT";
|
|
60
60
|
destChain: "Polkadot";
|
|
61
61
|
destAddress: string;
|
|
62
62
|
}, {
|
|
63
|
-
amount:
|
|
63
|
+
amount: string;
|
|
64
64
|
srcChain: "Ethereum";
|
|
65
65
|
srcAsset: "FLIP" | "USDC";
|
|
66
66
|
destAsset: "DOT";
|
|
67
67
|
destChain: "Polkadot";
|
|
68
68
|
destAddress: string;
|
|
69
69
|
}>, z.ZodObject<{
|
|
70
|
-
amount: z.
|
|
70
|
+
amount: z.ZodString;
|
|
71
71
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
72
72
|
destAsset: z.ZodLiteral<"BTC">;
|
|
73
73
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
74
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>;
|
|
75
75
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
76
76
|
}, "strip", z.ZodTypeAny, {
|
|
77
|
-
amount:
|
|
77
|
+
amount: string;
|
|
78
78
|
srcChain: "Ethereum";
|
|
79
79
|
srcAsset: "FLIP" | "USDC";
|
|
80
80
|
destAsset: "BTC";
|
|
81
81
|
destChain: "Bitcoin";
|
|
82
82
|
destAddress: string;
|
|
83
83
|
}, {
|
|
84
|
-
amount:
|
|
84
|
+
amount: string;
|
|
85
85
|
srcChain: "Ethereum";
|
|
86
86
|
srcAsset: "FLIP" | "USDC";
|
|
87
87
|
destAsset: "BTC";
|
|
@@ -89,7 +89,7 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
89
89
|
destAddress: string;
|
|
90
90
|
}>]>;
|
|
91
91
|
declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
92
|
-
amount: z.
|
|
92
|
+
amount: z.ZodString;
|
|
93
93
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
94
94
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
95
95
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
@@ -106,7 +106,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
106
106
|
gasBudget: string;
|
|
107
107
|
}>;
|
|
108
108
|
}, "strip", z.ZodTypeAny, {
|
|
109
|
-
amount:
|
|
109
|
+
amount: string;
|
|
110
110
|
srcChain: "Ethereum";
|
|
111
111
|
srcAsset: "ETH";
|
|
112
112
|
destAsset: "FLIP" | "USDC";
|
|
@@ -117,7 +117,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
117
117
|
gasBudget: string;
|
|
118
118
|
};
|
|
119
119
|
}, {
|
|
120
|
-
amount:
|
|
120
|
+
amount: string;
|
|
121
121
|
srcChain: "Ethereum";
|
|
122
122
|
srcAsset: "ETH";
|
|
123
123
|
destAsset: "FLIP" | "USDC";
|
|
@@ -128,7 +128,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
128
128
|
gasBudget: string;
|
|
129
129
|
};
|
|
130
130
|
}>, z.ZodUnion<[z.ZodObject<{
|
|
131
|
-
amount: z.
|
|
131
|
+
amount: z.ZodString;
|
|
132
132
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
133
133
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
134
134
|
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
@@ -145,7 +145,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
145
145
|
gasBudget: string;
|
|
146
146
|
}>;
|
|
147
147
|
}, "strip", z.ZodTypeAny, {
|
|
148
|
-
amount:
|
|
148
|
+
amount: string;
|
|
149
149
|
srcChain: "Ethereum";
|
|
150
150
|
srcAsset: "FLIP";
|
|
151
151
|
destAsset: "USDC" | "ETH";
|
|
@@ -156,7 +156,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
156
156
|
gasBudget: string;
|
|
157
157
|
};
|
|
158
158
|
}, {
|
|
159
|
-
amount:
|
|
159
|
+
amount: string;
|
|
160
160
|
srcChain: "Ethereum";
|
|
161
161
|
srcAsset: "FLIP";
|
|
162
162
|
destAsset: "USDC" | "ETH";
|
|
@@ -167,7 +167,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
167
167
|
gasBudget: string;
|
|
168
168
|
};
|
|
169
169
|
}>, z.ZodObject<{
|
|
170
|
-
amount: z.
|
|
170
|
+
amount: z.ZodString;
|
|
171
171
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
172
172
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
173
173
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
@@ -184,7 +184,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
184
184
|
gasBudget: string;
|
|
185
185
|
}>;
|
|
186
186
|
}, "strip", z.ZodTypeAny, {
|
|
187
|
-
amount:
|
|
187
|
+
amount: string;
|
|
188
188
|
srcChain: "Ethereum";
|
|
189
189
|
srcAsset: "USDC";
|
|
190
190
|
destAsset: "FLIP" | "ETH";
|
|
@@ -195,7 +195,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
195
195
|
gasBudget: string;
|
|
196
196
|
};
|
|
197
197
|
}, {
|
|
198
|
-
amount:
|
|
198
|
+
amount: string;
|
|
199
199
|
srcChain: "Ethereum";
|
|
200
200
|
srcAsset: "USDC";
|
|
201
201
|
destAsset: "FLIP" | "ETH";
|
|
@@ -206,147 +206,147 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
206
206
|
gasBudget: string;
|
|
207
207
|
};
|
|
208
208
|
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
209
|
-
amount: z.
|
|
209
|
+
amount: z.ZodString;
|
|
210
210
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
211
211
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
212
212
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
213
213
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
214
214
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
215
215
|
}, "strip", z.ZodTypeAny, {
|
|
216
|
-
amount:
|
|
216
|
+
amount: string;
|
|
217
217
|
srcChain: "Ethereum";
|
|
218
218
|
srcAsset: "ETH";
|
|
219
219
|
destAsset: "FLIP" | "USDC";
|
|
220
220
|
destChain: "Ethereum";
|
|
221
221
|
destAddress: `0x${string}`;
|
|
222
222
|
}, {
|
|
223
|
-
amount:
|
|
223
|
+
amount: string;
|
|
224
224
|
srcChain: "Ethereum";
|
|
225
225
|
srcAsset: "ETH";
|
|
226
226
|
destAsset: "FLIP" | "USDC";
|
|
227
227
|
destChain: "Ethereum";
|
|
228
228
|
destAddress: `0x${string}`;
|
|
229
229
|
}>, z.ZodObject<{
|
|
230
|
-
amount: z.
|
|
230
|
+
amount: z.ZodString;
|
|
231
231
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
232
232
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
233
233
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
234
234
|
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>;
|
|
235
235
|
destAsset: z.ZodLiteral<"DOT">;
|
|
236
236
|
}, "strip", z.ZodTypeAny, {
|
|
237
|
-
amount:
|
|
237
|
+
amount: string;
|
|
238
238
|
srcChain: "Ethereum";
|
|
239
239
|
srcAsset: "ETH";
|
|
240
240
|
destAsset: "DOT";
|
|
241
241
|
destChain: "Polkadot";
|
|
242
242
|
destAddress: string;
|
|
243
243
|
}, {
|
|
244
|
-
amount:
|
|
244
|
+
amount: string;
|
|
245
245
|
srcChain: "Ethereum";
|
|
246
246
|
srcAsset: "ETH";
|
|
247
247
|
destAsset: "DOT";
|
|
248
248
|
destChain: "Polkadot";
|
|
249
249
|
destAddress: string;
|
|
250
250
|
}>, z.ZodObject<{
|
|
251
|
-
amount: z.
|
|
251
|
+
amount: z.ZodString;
|
|
252
252
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
253
253
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
254
254
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
255
255
|
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>;
|
|
256
256
|
destAsset: z.ZodLiteral<"BTC">;
|
|
257
257
|
}, "strip", z.ZodTypeAny, {
|
|
258
|
-
amount:
|
|
258
|
+
amount: string;
|
|
259
259
|
srcChain: "Ethereum";
|
|
260
260
|
srcAsset: "ETH";
|
|
261
261
|
destAsset: "BTC";
|
|
262
262
|
destChain: "Bitcoin";
|
|
263
263
|
destAddress: string;
|
|
264
264
|
}, {
|
|
265
|
-
amount:
|
|
265
|
+
amount: string;
|
|
266
266
|
srcChain: "Ethereum";
|
|
267
267
|
srcAsset: "ETH";
|
|
268
268
|
destAsset: "BTC";
|
|
269
269
|
destChain: "Bitcoin";
|
|
270
270
|
destAddress: string;
|
|
271
271
|
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
272
|
-
amount: z.
|
|
272
|
+
amount: z.ZodString;
|
|
273
273
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
274
274
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
275
275
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
276
276
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
277
277
|
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
278
278
|
}, "strip", z.ZodTypeAny, {
|
|
279
|
-
amount:
|
|
279
|
+
amount: string;
|
|
280
280
|
srcChain: "Ethereum";
|
|
281
281
|
srcAsset: "FLIP";
|
|
282
282
|
destAsset: "USDC" | "ETH";
|
|
283
283
|
destChain: "Ethereum";
|
|
284
284
|
destAddress: `0x${string}`;
|
|
285
285
|
}, {
|
|
286
|
-
amount:
|
|
286
|
+
amount: string;
|
|
287
287
|
srcChain: "Ethereum";
|
|
288
288
|
srcAsset: "FLIP";
|
|
289
289
|
destAsset: "USDC" | "ETH";
|
|
290
290
|
destChain: "Ethereum";
|
|
291
291
|
destAddress: `0x${string}`;
|
|
292
292
|
}>, z.ZodObject<{
|
|
293
|
-
amount: z.
|
|
293
|
+
amount: z.ZodString;
|
|
294
294
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
295
295
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
296
296
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
297
297
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
298
298
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
299
299
|
}, "strip", z.ZodTypeAny, {
|
|
300
|
-
amount:
|
|
300
|
+
amount: string;
|
|
301
301
|
srcChain: "Ethereum";
|
|
302
302
|
srcAsset: "USDC";
|
|
303
303
|
destAsset: "FLIP" | "ETH";
|
|
304
304
|
destChain: "Ethereum";
|
|
305
305
|
destAddress: `0x${string}`;
|
|
306
306
|
}, {
|
|
307
|
-
amount:
|
|
307
|
+
amount: string;
|
|
308
308
|
srcChain: "Ethereum";
|
|
309
309
|
srcAsset: "USDC";
|
|
310
310
|
destAsset: "FLIP" | "ETH";
|
|
311
311
|
destChain: "Ethereum";
|
|
312
312
|
destAddress: `0x${string}`;
|
|
313
313
|
}>, z.ZodObject<{
|
|
314
|
-
amount: z.
|
|
314
|
+
amount: z.ZodString;
|
|
315
315
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
316
316
|
destAsset: z.ZodLiteral<"DOT">;
|
|
317
317
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
318
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>;
|
|
319
319
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
320
320
|
}, "strip", z.ZodTypeAny, {
|
|
321
|
-
amount:
|
|
321
|
+
amount: string;
|
|
322
322
|
srcChain: "Ethereum";
|
|
323
323
|
srcAsset: "FLIP" | "USDC";
|
|
324
324
|
destAsset: "DOT";
|
|
325
325
|
destChain: "Polkadot";
|
|
326
326
|
destAddress: string;
|
|
327
327
|
}, {
|
|
328
|
-
amount:
|
|
328
|
+
amount: string;
|
|
329
329
|
srcChain: "Ethereum";
|
|
330
330
|
srcAsset: "FLIP" | "USDC";
|
|
331
331
|
destAsset: "DOT";
|
|
332
332
|
destChain: "Polkadot";
|
|
333
333
|
destAddress: string;
|
|
334
334
|
}>, z.ZodObject<{
|
|
335
|
-
amount: z.
|
|
335
|
+
amount: z.ZodString;
|
|
336
336
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
337
337
|
destAsset: z.ZodLiteral<"BTC">;
|
|
338
338
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
339
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>;
|
|
340
340
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
341
341
|
}, "strip", z.ZodTypeAny, {
|
|
342
|
-
amount:
|
|
342
|
+
amount: string;
|
|
343
343
|
srcChain: "Ethereum";
|
|
344
344
|
srcAsset: "FLIP" | "USDC";
|
|
345
345
|
destAsset: "BTC";
|
|
346
346
|
destChain: "Bitcoin";
|
|
347
347
|
destAddress: string;
|
|
348
348
|
}, {
|
|
349
|
-
amount:
|
|
349
|
+
amount: string;
|
|
350
350
|
srcChain: "Ethereum";
|
|
351
351
|
srcAsset: "FLIP" | "USDC";
|
|
352
352
|
destAsset: "BTC";
|
|
@@ -367,43 +367,16 @@ declare const ccmMetadataSchema: z.ZodObject<{
|
|
|
367
367
|
gasBudget: string;
|
|
368
368
|
}>;
|
|
369
369
|
type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
egress_amount: string;
|
|
378
|
-
}, {
|
|
379
|
-
id: string;
|
|
380
|
-
intermediate_amount: string;
|
|
381
|
-
egress_amount: string;
|
|
382
|
-
}>, {
|
|
383
|
-
id: string;
|
|
384
|
-
intermediateAmount: string;
|
|
385
|
-
egressAmount: string;
|
|
386
|
-
}, {
|
|
387
|
-
id: string;
|
|
388
|
-
intermediate_amount: string;
|
|
389
|
-
egress_amount: string;
|
|
390
|
-
}>, z.ZodEffects<z.ZodObject<{
|
|
391
|
-
id: z.ZodString;
|
|
392
|
-
egress_amount: z.ZodString;
|
|
393
|
-
}, "strip", z.ZodTypeAny, {
|
|
394
|
-
id: string;
|
|
395
|
-
egress_amount: string;
|
|
396
|
-
}, {
|
|
397
|
-
id: string;
|
|
398
|
-
egress_amount: string;
|
|
399
|
-
}>, {
|
|
400
|
-
id: string;
|
|
370
|
+
type QuoteFee = {
|
|
371
|
+
type: 'liquidity' | 'network';
|
|
372
|
+
asset: Asset;
|
|
373
|
+
amount: string;
|
|
374
|
+
};
|
|
375
|
+
type QuoteQueryResponse = {
|
|
376
|
+
intermediateAmount?: string;
|
|
401
377
|
egressAmount: string;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
egress_amount: string;
|
|
405
|
-
}>]>;
|
|
406
|
-
type QuoteQueryResponse = z.infer<typeof quoteResponseSchema>;
|
|
378
|
+
includedFees: QuoteFee[];
|
|
379
|
+
};
|
|
407
380
|
|
|
408
381
|
interface ChainData {
|
|
409
382
|
id: Chain;
|
package/dist/swap.d.ts
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import {
|
|
3
|
-
export { d as Assets, e as ChainflipNetworks, b as Chains, f as assetChains, h as assetContractIds, g as assetDecimals, i as chainContractIds } from './contracts-
|
|
2
|
+
import { A as Asset, C as Chain, c as chainAssets, a as ChainflipNetwork, T as TransactionOptions } from './contracts-920ad844.js';
|
|
3
|
+
export { d as Assets, e as ChainflipNetworks, b as Chains, f as assetChains, h as assetContractIds, g as assetDecimals, i as chainContractIds } from './contracts-920ad844.js';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
6
|
declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
7
|
-
amount: z.
|
|
7
|
+
amount: z.ZodString;
|
|
8
8
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
9
9
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
10
10
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
11
11
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
12
12
|
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
13
13
|
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
amount:
|
|
14
|
+
amount: string;
|
|
15
15
|
srcChain: "Ethereum";
|
|
16
16
|
srcAsset: "FLIP";
|
|
17
17
|
destAsset: "USDC" | "ETH";
|
|
18
18
|
destChain: "Ethereum";
|
|
19
19
|
destAddress: `0x${string}`;
|
|
20
20
|
}, {
|
|
21
|
-
amount:
|
|
21
|
+
amount: string;
|
|
22
22
|
srcChain: "Ethereum";
|
|
23
23
|
srcAsset: "FLIP";
|
|
24
24
|
destAsset: "USDC" | "ETH";
|
|
25
25
|
destChain: "Ethereum";
|
|
26
26
|
destAddress: `0x${string}`;
|
|
27
27
|
}>, z.ZodObject<{
|
|
28
|
-
amount: z.
|
|
28
|
+
amount: z.ZodString;
|
|
29
29
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
30
30
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
31
31
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
32
32
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
33
33
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
34
34
|
}, "strip", z.ZodTypeAny, {
|
|
35
|
-
amount:
|
|
35
|
+
amount: string;
|
|
36
36
|
srcChain: "Ethereum";
|
|
37
37
|
srcAsset: "USDC";
|
|
38
38
|
destAsset: "FLIP" | "ETH";
|
|
39
39
|
destChain: "Ethereum";
|
|
40
40
|
destAddress: `0x${string}`;
|
|
41
41
|
}, {
|
|
42
|
-
amount:
|
|
42
|
+
amount: string;
|
|
43
43
|
srcChain: "Ethereum";
|
|
44
44
|
srcAsset: "USDC";
|
|
45
45
|
destAsset: "FLIP" | "ETH";
|
|
46
46
|
destChain: "Ethereum";
|
|
47
47
|
destAddress: `0x${string}`;
|
|
48
48
|
}>, z.ZodObject<{
|
|
49
|
-
amount: z.
|
|
49
|
+
amount: z.ZodString;
|
|
50
50
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
51
51
|
destAsset: z.ZodLiteral<"DOT">;
|
|
52
52
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
53
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>;
|
|
54
54
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
55
55
|
}, "strip", z.ZodTypeAny, {
|
|
56
|
-
amount:
|
|
56
|
+
amount: string;
|
|
57
57
|
srcChain: "Ethereum";
|
|
58
58
|
srcAsset: "FLIP" | "USDC";
|
|
59
59
|
destAsset: "DOT";
|
|
60
60
|
destChain: "Polkadot";
|
|
61
61
|
destAddress: string;
|
|
62
62
|
}, {
|
|
63
|
-
amount:
|
|
63
|
+
amount: string;
|
|
64
64
|
srcChain: "Ethereum";
|
|
65
65
|
srcAsset: "FLIP" | "USDC";
|
|
66
66
|
destAsset: "DOT";
|
|
67
67
|
destChain: "Polkadot";
|
|
68
68
|
destAddress: string;
|
|
69
69
|
}>, z.ZodObject<{
|
|
70
|
-
amount: z.
|
|
70
|
+
amount: z.ZodString;
|
|
71
71
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
72
72
|
destAsset: z.ZodLiteral<"BTC">;
|
|
73
73
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
74
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>;
|
|
75
75
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
76
76
|
}, "strip", z.ZodTypeAny, {
|
|
77
|
-
amount:
|
|
77
|
+
amount: string;
|
|
78
78
|
srcChain: "Ethereum";
|
|
79
79
|
srcAsset: "FLIP" | "USDC";
|
|
80
80
|
destAsset: "BTC";
|
|
81
81
|
destChain: "Bitcoin";
|
|
82
82
|
destAddress: string;
|
|
83
83
|
}, {
|
|
84
|
-
amount:
|
|
84
|
+
amount: string;
|
|
85
85
|
srcChain: "Ethereum";
|
|
86
86
|
srcAsset: "FLIP" | "USDC";
|
|
87
87
|
destAsset: "BTC";
|
|
@@ -89,7 +89,7 @@ declare const tokenSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
89
89
|
destAddress: string;
|
|
90
90
|
}>]>;
|
|
91
91
|
declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
92
|
-
amount: z.
|
|
92
|
+
amount: z.ZodString;
|
|
93
93
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
94
94
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
95
95
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
@@ -106,7 +106,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
106
106
|
gasBudget: string;
|
|
107
107
|
}>;
|
|
108
108
|
}, "strip", z.ZodTypeAny, {
|
|
109
|
-
amount:
|
|
109
|
+
amount: string;
|
|
110
110
|
srcChain: "Ethereum";
|
|
111
111
|
srcAsset: "ETH";
|
|
112
112
|
destAsset: "FLIP" | "USDC";
|
|
@@ -117,7 +117,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
117
117
|
gasBudget: string;
|
|
118
118
|
};
|
|
119
119
|
}, {
|
|
120
|
-
amount:
|
|
120
|
+
amount: string;
|
|
121
121
|
srcChain: "Ethereum";
|
|
122
122
|
srcAsset: "ETH";
|
|
123
123
|
destAsset: "FLIP" | "USDC";
|
|
@@ -128,7 +128,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
128
128
|
gasBudget: string;
|
|
129
129
|
};
|
|
130
130
|
}>, z.ZodUnion<[z.ZodObject<{
|
|
131
|
-
amount: z.
|
|
131
|
+
amount: z.ZodString;
|
|
132
132
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
133
133
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
134
134
|
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
@@ -145,7 +145,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
145
145
|
gasBudget: string;
|
|
146
146
|
}>;
|
|
147
147
|
}, "strip", z.ZodTypeAny, {
|
|
148
|
-
amount:
|
|
148
|
+
amount: string;
|
|
149
149
|
srcChain: "Ethereum";
|
|
150
150
|
srcAsset: "FLIP";
|
|
151
151
|
destAsset: "USDC" | "ETH";
|
|
@@ -156,7 +156,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
156
156
|
gasBudget: string;
|
|
157
157
|
};
|
|
158
158
|
}, {
|
|
159
|
-
amount:
|
|
159
|
+
amount: string;
|
|
160
160
|
srcChain: "Ethereum";
|
|
161
161
|
srcAsset: "FLIP";
|
|
162
162
|
destAsset: "USDC" | "ETH";
|
|
@@ -167,7 +167,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
167
167
|
gasBudget: string;
|
|
168
168
|
};
|
|
169
169
|
}>, z.ZodObject<{
|
|
170
|
-
amount: z.
|
|
170
|
+
amount: z.ZodString;
|
|
171
171
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
172
172
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
173
173
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
@@ -184,7 +184,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
184
184
|
gasBudget: string;
|
|
185
185
|
}>;
|
|
186
186
|
}, "strip", z.ZodTypeAny, {
|
|
187
|
-
amount:
|
|
187
|
+
amount: string;
|
|
188
188
|
srcChain: "Ethereum";
|
|
189
189
|
srcAsset: "USDC";
|
|
190
190
|
destAsset: "FLIP" | "ETH";
|
|
@@ -195,7 +195,7 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
195
195
|
gasBudget: string;
|
|
196
196
|
};
|
|
197
197
|
}, {
|
|
198
|
-
amount:
|
|
198
|
+
amount: string;
|
|
199
199
|
srcChain: "Ethereum";
|
|
200
200
|
srcAsset: "USDC";
|
|
201
201
|
destAsset: "FLIP" | "ETH";
|
|
@@ -206,147 +206,147 @@ declare const executeSwapParamsSchema: z.ZodUnion<[z.ZodObject<{
|
|
|
206
206
|
gasBudget: string;
|
|
207
207
|
};
|
|
208
208
|
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
209
|
-
amount: z.
|
|
209
|
+
amount: z.ZodString;
|
|
210
210
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
211
211
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
212
212
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
213
213
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
214
214
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
215
215
|
}, "strip", z.ZodTypeAny, {
|
|
216
|
-
amount:
|
|
216
|
+
amount: string;
|
|
217
217
|
srcChain: "Ethereum";
|
|
218
218
|
srcAsset: "ETH";
|
|
219
219
|
destAsset: "FLIP" | "USDC";
|
|
220
220
|
destChain: "Ethereum";
|
|
221
221
|
destAddress: `0x${string}`;
|
|
222
222
|
}, {
|
|
223
|
-
amount:
|
|
223
|
+
amount: string;
|
|
224
224
|
srcChain: "Ethereum";
|
|
225
225
|
srcAsset: "ETH";
|
|
226
226
|
destAsset: "FLIP" | "USDC";
|
|
227
227
|
destChain: "Ethereum";
|
|
228
228
|
destAddress: `0x${string}`;
|
|
229
229
|
}>, z.ZodObject<{
|
|
230
|
-
amount: z.
|
|
230
|
+
amount: z.ZodString;
|
|
231
231
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
232
232
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
233
233
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
234
234
|
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>;
|
|
235
235
|
destAsset: z.ZodLiteral<"DOT">;
|
|
236
236
|
}, "strip", z.ZodTypeAny, {
|
|
237
|
-
amount:
|
|
237
|
+
amount: string;
|
|
238
238
|
srcChain: "Ethereum";
|
|
239
239
|
srcAsset: "ETH";
|
|
240
240
|
destAsset: "DOT";
|
|
241
241
|
destChain: "Polkadot";
|
|
242
242
|
destAddress: string;
|
|
243
243
|
}, {
|
|
244
|
-
amount:
|
|
244
|
+
amount: string;
|
|
245
245
|
srcChain: "Ethereum";
|
|
246
246
|
srcAsset: "ETH";
|
|
247
247
|
destAsset: "DOT";
|
|
248
248
|
destChain: "Polkadot";
|
|
249
249
|
destAddress: string;
|
|
250
250
|
}>, z.ZodObject<{
|
|
251
|
-
amount: z.
|
|
251
|
+
amount: z.ZodString;
|
|
252
252
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
253
253
|
srcAsset: z.ZodLiteral<"ETH">;
|
|
254
254
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
255
255
|
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>;
|
|
256
256
|
destAsset: z.ZodLiteral<"BTC">;
|
|
257
257
|
}, "strip", z.ZodTypeAny, {
|
|
258
|
-
amount:
|
|
258
|
+
amount: string;
|
|
259
259
|
srcChain: "Ethereum";
|
|
260
260
|
srcAsset: "ETH";
|
|
261
261
|
destAsset: "BTC";
|
|
262
262
|
destChain: "Bitcoin";
|
|
263
263
|
destAddress: string;
|
|
264
264
|
}, {
|
|
265
|
-
amount:
|
|
265
|
+
amount: string;
|
|
266
266
|
srcChain: "Ethereum";
|
|
267
267
|
srcAsset: "ETH";
|
|
268
268
|
destAsset: "BTC";
|
|
269
269
|
destChain: "Bitcoin";
|
|
270
270
|
destAddress: string;
|
|
271
271
|
}>]>, z.ZodUnion<[z.ZodObject<{
|
|
272
|
-
amount: z.
|
|
272
|
+
amount: z.ZodString;
|
|
273
273
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
274
274
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
275
275
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
276
276
|
srcAsset: z.ZodLiteral<"FLIP">;
|
|
277
277
|
destAsset: z.ZodUnion<[z.ZodLiteral<"USDC">, z.ZodLiteral<"ETH">]>;
|
|
278
278
|
}, "strip", z.ZodTypeAny, {
|
|
279
|
-
amount:
|
|
279
|
+
amount: string;
|
|
280
280
|
srcChain: "Ethereum";
|
|
281
281
|
srcAsset: "FLIP";
|
|
282
282
|
destAsset: "USDC" | "ETH";
|
|
283
283
|
destChain: "Ethereum";
|
|
284
284
|
destAddress: `0x${string}`;
|
|
285
285
|
}, {
|
|
286
|
-
amount:
|
|
286
|
+
amount: string;
|
|
287
287
|
srcChain: "Ethereum";
|
|
288
288
|
srcAsset: "FLIP";
|
|
289
289
|
destAsset: "USDC" | "ETH";
|
|
290
290
|
destChain: "Ethereum";
|
|
291
291
|
destAddress: `0x${string}`;
|
|
292
292
|
}>, z.ZodObject<{
|
|
293
|
-
amount: z.
|
|
293
|
+
amount: z.ZodString;
|
|
294
294
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
295
295
|
destChain: z.ZodLiteral<"Ethereum">;
|
|
296
296
|
destAddress: z.ZodEffects<z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>, `0x${string}`, `0x${string}`>;
|
|
297
297
|
srcAsset: z.ZodLiteral<"USDC">;
|
|
298
298
|
destAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"ETH">]>;
|
|
299
299
|
}, "strip", z.ZodTypeAny, {
|
|
300
|
-
amount:
|
|
300
|
+
amount: string;
|
|
301
301
|
srcChain: "Ethereum";
|
|
302
302
|
srcAsset: "USDC";
|
|
303
303
|
destAsset: "FLIP" | "ETH";
|
|
304
304
|
destChain: "Ethereum";
|
|
305
305
|
destAddress: `0x${string}`;
|
|
306
306
|
}, {
|
|
307
|
-
amount:
|
|
307
|
+
amount: string;
|
|
308
308
|
srcChain: "Ethereum";
|
|
309
309
|
srcAsset: "USDC";
|
|
310
310
|
destAsset: "FLIP" | "ETH";
|
|
311
311
|
destChain: "Ethereum";
|
|
312
312
|
destAddress: `0x${string}`;
|
|
313
313
|
}>, z.ZodObject<{
|
|
314
|
-
amount: z.
|
|
314
|
+
amount: z.ZodString;
|
|
315
315
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
316
316
|
destAsset: z.ZodLiteral<"DOT">;
|
|
317
317
|
destChain: z.ZodLiteral<"Polkadot">;
|
|
318
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>;
|
|
319
319
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
320
320
|
}, "strip", z.ZodTypeAny, {
|
|
321
|
-
amount:
|
|
321
|
+
amount: string;
|
|
322
322
|
srcChain: "Ethereum";
|
|
323
323
|
srcAsset: "FLIP" | "USDC";
|
|
324
324
|
destAsset: "DOT";
|
|
325
325
|
destChain: "Polkadot";
|
|
326
326
|
destAddress: string;
|
|
327
327
|
}, {
|
|
328
|
-
amount:
|
|
328
|
+
amount: string;
|
|
329
329
|
srcChain: "Ethereum";
|
|
330
330
|
srcAsset: "FLIP" | "USDC";
|
|
331
331
|
destAsset: "DOT";
|
|
332
332
|
destChain: "Polkadot";
|
|
333
333
|
destAddress: string;
|
|
334
334
|
}>, z.ZodObject<{
|
|
335
|
-
amount: z.
|
|
335
|
+
amount: z.ZodString;
|
|
336
336
|
srcChain: z.ZodLiteral<"Ethereum">;
|
|
337
337
|
destAsset: z.ZodLiteral<"BTC">;
|
|
338
338
|
destChain: z.ZodLiteral<"Bitcoin">;
|
|
339
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>;
|
|
340
340
|
srcAsset: z.ZodUnion<[z.ZodLiteral<"FLIP">, z.ZodLiteral<"USDC">]>;
|
|
341
341
|
}, "strip", z.ZodTypeAny, {
|
|
342
|
-
amount:
|
|
342
|
+
amount: string;
|
|
343
343
|
srcChain: "Ethereum";
|
|
344
344
|
srcAsset: "FLIP" | "USDC";
|
|
345
345
|
destAsset: "BTC";
|
|
346
346
|
destChain: "Bitcoin";
|
|
347
347
|
destAddress: string;
|
|
348
348
|
}, {
|
|
349
|
-
amount:
|
|
349
|
+
amount: string;
|
|
350
350
|
srcChain: "Ethereum";
|
|
351
351
|
srcAsset: "FLIP" | "USDC";
|
|
352
352
|
destAsset: "BTC";
|
|
@@ -367,43 +367,16 @@ declare const ccmMetadataSchema: z.ZodObject<{
|
|
|
367
367
|
gasBudget: string;
|
|
368
368
|
}>;
|
|
369
369
|
type CcmMetadata = z.infer<typeof ccmMetadataSchema>;
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
egress_amount: string;
|
|
378
|
-
}, {
|
|
379
|
-
id: string;
|
|
380
|
-
intermediate_amount: string;
|
|
381
|
-
egress_amount: string;
|
|
382
|
-
}>, {
|
|
383
|
-
id: string;
|
|
384
|
-
intermediateAmount: string;
|
|
385
|
-
egressAmount: string;
|
|
386
|
-
}, {
|
|
387
|
-
id: string;
|
|
388
|
-
intermediate_amount: string;
|
|
389
|
-
egress_amount: string;
|
|
390
|
-
}>, z.ZodEffects<z.ZodObject<{
|
|
391
|
-
id: z.ZodString;
|
|
392
|
-
egress_amount: z.ZodString;
|
|
393
|
-
}, "strip", z.ZodTypeAny, {
|
|
394
|
-
id: string;
|
|
395
|
-
egress_amount: string;
|
|
396
|
-
}, {
|
|
397
|
-
id: string;
|
|
398
|
-
egress_amount: string;
|
|
399
|
-
}>, {
|
|
400
|
-
id: string;
|
|
370
|
+
type QuoteFee = {
|
|
371
|
+
type: 'liquidity' | 'network';
|
|
372
|
+
asset: Asset;
|
|
373
|
+
amount: string;
|
|
374
|
+
};
|
|
375
|
+
type QuoteQueryResponse = {
|
|
376
|
+
intermediateAmount?: string;
|
|
401
377
|
egressAmount: string;
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
egress_amount: string;
|
|
405
|
-
}>]>;
|
|
406
|
-
type QuoteQueryResponse = z.infer<typeof quoteResponseSchema>;
|
|
378
|
+
includedFees: QuoteFee[];
|
|
379
|
+
};
|
|
407
380
|
|
|
408
381
|
interface ChainData {
|
|
409
382
|
id: Chain;
|
package/dist/swap.js
CHANGED
|
@@ -55,7 +55,6 @@ var Assets = arrayToMap([
|
|
|
55
55
|
"BTC"
|
|
56
56
|
]);
|
|
57
57
|
var ChainflipNetworks = arrayToMap([
|
|
58
|
-
"partnernet",
|
|
59
58
|
"sisyphos",
|
|
60
59
|
"perseverance",
|
|
61
60
|
"mainnet"
|
|
@@ -134,9 +133,9 @@ var Encoding;
|
|
|
134
133
|
})(Encoding || (Encoding = {}));
|
|
135
134
|
var bech32 = {
|
|
136
135
|
getEncodingConst(enc) {
|
|
137
|
-
if (enc ===
|
|
136
|
+
if (enc === "bech32")
|
|
138
137
|
return 1;
|
|
139
|
-
if (enc ===
|
|
138
|
+
if (enc === "bech32m")
|
|
140
139
|
return 734539939;
|
|
141
140
|
return null;
|
|
142
141
|
},
|
|
@@ -260,9 +259,9 @@ var segwitAddress = {
|
|
|
260
259
|
},
|
|
261
260
|
decode(hrp, addr) {
|
|
262
261
|
let bech32m = false;
|
|
263
|
-
let dec = bech32.decode(addr,
|
|
262
|
+
let dec = bech32.decode(addr, "bech32");
|
|
264
263
|
if (dec === null) {
|
|
265
|
-
dec = bech32.decode(addr,
|
|
264
|
+
dec = bech32.decode(addr, "bech32m");
|
|
266
265
|
bech32m = true;
|
|
267
266
|
}
|
|
268
267
|
if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) {
|
|
@@ -287,9 +286,9 @@ var segwitAddress = {
|
|
|
287
286
|
};
|
|
288
287
|
},
|
|
289
288
|
encode(hrp, version, program) {
|
|
290
|
-
let enc =
|
|
289
|
+
let enc = "bech32";
|
|
291
290
|
if (version > 0) {
|
|
292
|
-
enc =
|
|
291
|
+
enc = "bech32m";
|
|
293
292
|
}
|
|
294
293
|
const ret = bech32.encode(
|
|
295
294
|
hrp,
|
|
@@ -456,24 +455,6 @@ zod.z.object({
|
|
|
456
455
|
...rest,
|
|
457
456
|
expectedDepositAmount: amount
|
|
458
457
|
}));
|
|
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
|
-
]);
|
|
477
458
|
|
|
478
459
|
// ../shared/src/vault/schemas.ts
|
|
479
460
|
var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
@@ -481,7 +462,7 @@ var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
|
481
462
|
].map((v) => v.toString(16).padStart(2, "0")).join("")}`, "bytesToHex");
|
|
482
463
|
var utf8ToHex = /* @__PURE__ */ __name((str) => `0x${Buffer.from(str).toString("hex")}`, "utf8ToHex");
|
|
483
464
|
var eth = zod.z.object({
|
|
484
|
-
amount:
|
|
465
|
+
amount: numericString,
|
|
485
466
|
srcChain: zod.z.literal(Chains.Ethereum),
|
|
486
467
|
srcAsset: zod.z.literal(Assets.ETH)
|
|
487
468
|
});
|
|
@@ -1863,8 +1844,11 @@ __publicField(_Vault__factory, "abi", _abi2);
|
|
|
1863
1844
|
var Vault__factory = _Vault__factory;
|
|
1864
1845
|
|
|
1865
1846
|
// ../shared/src/consts.ts
|
|
1847
|
+
({
|
|
1848
|
+
[ChainflipNetworks.perseverance]: 100
|
|
1849
|
+
});
|
|
1866
1850
|
var MINIMUM_DEPOSIT_AMOUNTS = {
|
|
1867
|
-
[ChainflipNetworks.
|
|
1851
|
+
[ChainflipNetworks.perseverance]: {
|
|
1868
1852
|
[Assets.ETH]: "0",
|
|
1869
1853
|
[Assets.FLIP]: "0",
|
|
1870
1854
|
[Assets.USDC]: "0",
|
|
@@ -1874,11 +1858,11 @@ var MINIMUM_DEPOSIT_AMOUNTS = {
|
|
|
1874
1858
|
};
|
|
1875
1859
|
var getMinimumDepositAmount = /* @__PURE__ */ __name((network, asset) => MINIMUM_DEPOSIT_AMOUNTS[network]?.[asset] ?? "0", "getMinimumDepositAmount");
|
|
1876
1860
|
var MINIMUM_SWAP_AMOUNTS = {
|
|
1877
|
-
[ChainflipNetworks.
|
|
1861
|
+
[ChainflipNetworks.perseverance]: {
|
|
1878
1862
|
[Assets.ETH]: "580000000000000",
|
|
1879
1863
|
[Assets.FLIP]: "1000000000000000000",
|
|
1880
1864
|
[Assets.USDC]: "1000000",
|
|
1881
|
-
[Assets.BTC]: "
|
|
1865
|
+
[Assets.BTC]: "1000",
|
|
1882
1866
|
[Assets.DOT]: "2000000000"
|
|
1883
1867
|
}
|
|
1884
1868
|
};
|
|
@@ -1889,11 +1873,6 @@ var ADDRESSES = {
|
|
|
1889
1873
|
VAULT_CONTRACT_ADDRESS: "0xC17CCec5015081EB2DF26d20A9e02c5484C1d641",
|
|
1890
1874
|
STATE_CHAIN_GATEWAY_ADDRESS: "0xE8bE4B7F8a38C1913387c9C20B94402bc3Db9F70"
|
|
1891
1875
|
},
|
|
1892
|
-
[ChainflipNetworks.partnernet]: {
|
|
1893
|
-
FLIP_CONTRACT_ADDRESS: "0x1Ea4F05a319A8f779F05E153974605756bB13D4F",
|
|
1894
|
-
VAULT_CONTRACT_ADDRESS: "0xAfD0C34E6d25F707d931F8b7EE9cf0Ff52160A46",
|
|
1895
|
-
STATE_CHAIN_GATEWAY_ADDRESS: "0x07B3Bef16c640B072085BF83C24b6C43000aE056"
|
|
1896
|
-
},
|
|
1897
1876
|
[ChainflipNetworks.perseverance]: {
|
|
1898
1877
|
FLIP_CONTRACT_ADDRESS: "0x0485D65da68b2A6b48C3fA28D7CCAce196798B94",
|
|
1899
1878
|
VAULT_CONTRACT_ADDRESS: "0x40caFF3f3B6706Da904a7895e0fC7F7922437e9B",
|
|
@@ -1949,7 +1928,7 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
1949
1928
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1950
1929
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
1951
1930
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
1952
|
-
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1931
|
+
const { isAllowable } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1953
1932
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
1954
1933
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
1955
1934
|
const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
@@ -1968,7 +1947,7 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
1968
1947
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1969
1948
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
1970
1949
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
1971
|
-
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1950
|
+
const { isAllowable } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1972
1951
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
1973
1952
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
1974
1953
|
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));
|
|
@@ -1988,21 +1967,20 @@ var checkVaultAllowance = /* @__PURE__ */ __name((params, networkOpts) => {
|
|
|
1988
1967
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
1989
1968
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
1990
1969
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1991
|
-
return checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1970
|
+
return checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1992
1971
|
}, "checkVaultAllowance");
|
|
1993
1972
|
var approveVault = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
1994
1973
|
const { isAllowable, erc20, allowance } = await checkVaultAllowance(params, networkOpts);
|
|
1995
1974
|
if (isAllowable)
|
|
1996
1975
|
return null;
|
|
1997
1976
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1998
|
-
return approve(params.amount, vaultContractAddress, erc20, allowance, txOpts);
|
|
1977
|
+
return approve(BigInt(params.amount), vaultContractAddress, erc20, allowance, txOpts);
|
|
1999
1978
|
}, "approveVault");
|
|
2000
1979
|
|
|
2001
1980
|
// src/swap/consts.ts
|
|
2002
1981
|
var BACKEND_SERVICE_URLS = {
|
|
2003
1982
|
[ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
|
|
2004
|
-
[ChainflipNetworks.perseverance]: "https://chainflip-swap-perseverance.chainflip.io/"
|
|
2005
|
-
[ChainflipNetworks.partnernet]: "https://chainflip-swap-partnernet.chainflip.io/"
|
|
1983
|
+
[ChainflipNetworks.perseverance]: "https://chainflip-swap-perseverance.chainflip.io/"
|
|
2006
1984
|
};
|
|
2007
1985
|
|
|
2008
1986
|
// src/swap/assets.ts
|
|
@@ -2179,7 +2157,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
2179
2157
|
__publicField(this, "baseUrl");
|
|
2180
2158
|
__publicField(this, "network");
|
|
2181
2159
|
__publicField(this, "signer");
|
|
2182
|
-
this.network = options.network ?? ChainflipNetworks.
|
|
2160
|
+
this.network = options.network ?? ChainflipNetworks.perseverance;
|
|
2183
2161
|
this.baseUrl = options.backendUrl ?? BACKEND_SERVICE_URLS[this.network];
|
|
2184
2162
|
this.signer = options.signer;
|
|
2185
2163
|
}
|
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-HR2UQBMZ.mjs';
|
|
2
|
+
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-HR2UQBMZ.mjs';
|
|
3
3
|
import { encodeAddress, decodeAddress, base58Decode } from '@polkadot/util-crypto';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { hexToU8a } from '@polkadot/util';
|
|
@@ -22,9 +22,9 @@ var Encoding;
|
|
|
22
22
|
})(Encoding || (Encoding = {}));
|
|
23
23
|
var bech32 = {
|
|
24
24
|
getEncodingConst(enc) {
|
|
25
|
-
if (enc ===
|
|
25
|
+
if (enc === "bech32")
|
|
26
26
|
return 1;
|
|
27
|
-
if (enc ===
|
|
27
|
+
if (enc === "bech32m")
|
|
28
28
|
return 734539939;
|
|
29
29
|
return null;
|
|
30
30
|
},
|
|
@@ -148,9 +148,9 @@ var segwitAddress = {
|
|
|
148
148
|
},
|
|
149
149
|
decode(hrp, addr) {
|
|
150
150
|
let bech32m = false;
|
|
151
|
-
let dec = bech32.decode(addr,
|
|
151
|
+
let dec = bech32.decode(addr, "bech32");
|
|
152
152
|
if (dec === null) {
|
|
153
|
-
dec = bech32.decode(addr,
|
|
153
|
+
dec = bech32.decode(addr, "bech32m");
|
|
154
154
|
bech32m = true;
|
|
155
155
|
}
|
|
156
156
|
if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) {
|
|
@@ -175,9 +175,9 @@ var segwitAddress = {
|
|
|
175
175
|
};
|
|
176
176
|
},
|
|
177
177
|
encode(hrp, version, program) {
|
|
178
|
-
let enc =
|
|
178
|
+
let enc = "bech32";
|
|
179
179
|
if (version > 0) {
|
|
180
|
-
enc =
|
|
180
|
+
enc = "bech32m";
|
|
181
181
|
}
|
|
182
182
|
const ret = bech32.encode(
|
|
183
183
|
hrp,
|
|
@@ -344,24 +344,6 @@ z.object({
|
|
|
344
344
|
...rest,
|
|
345
345
|
expectedDepositAmount: amount
|
|
346
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
|
-
]);
|
|
365
347
|
|
|
366
348
|
// ../shared/src/vault/schemas.ts
|
|
367
349
|
var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
@@ -369,7 +351,7 @@ var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
|
369
351
|
].map((v) => v.toString(16).padStart(2, "0")).join("")}`, "bytesToHex");
|
|
370
352
|
var utf8ToHex = /* @__PURE__ */ __name((str) => `0x${Buffer.from(str).toString("hex")}`, "utf8ToHex");
|
|
371
353
|
var eth = z.object({
|
|
372
|
-
amount:
|
|
354
|
+
amount: numericString,
|
|
373
355
|
srcChain: z.literal(Chains.Ethereum),
|
|
374
356
|
srcAsset: z.literal(Assets.ETH)
|
|
375
357
|
});
|
|
@@ -460,7 +442,7 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
460
442
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
461
443
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
462
444
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
463
|
-
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
445
|
+
const { isAllowable } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
464
446
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
465
447
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
466
448
|
const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
@@ -479,7 +461,7 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
479
461
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
480
462
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
481
463
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
482
|
-
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
464
|
+
const { isAllowable } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
483
465
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
484
466
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
485
467
|
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));
|
|
@@ -499,21 +481,20 @@ var checkVaultAllowance = /* @__PURE__ */ __name((params, networkOpts) => {
|
|
|
499
481
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
500
482
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
501
483
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
502
|
-
return checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
484
|
+
return checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
503
485
|
}, "checkVaultAllowance");
|
|
504
486
|
var approveVault = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
505
487
|
const { isAllowable, erc20, allowance } = await checkVaultAllowance(params, networkOpts);
|
|
506
488
|
if (isAllowable)
|
|
507
489
|
return null;
|
|
508
490
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
509
|
-
return approve(params.amount, vaultContractAddress, erc20, allowance, txOpts);
|
|
491
|
+
return approve(BigInt(params.amount), vaultContractAddress, erc20, allowance, txOpts);
|
|
510
492
|
}, "approveVault");
|
|
511
493
|
|
|
512
494
|
// src/swap/consts.ts
|
|
513
495
|
var BACKEND_SERVICE_URLS = {
|
|
514
496
|
[ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
|
|
515
|
-
[ChainflipNetworks.perseverance]: "https://chainflip-swap-perseverance.chainflip.io/"
|
|
516
|
-
[ChainflipNetworks.partnernet]: "https://chainflip-swap-partnernet.chainflip.io/"
|
|
497
|
+
[ChainflipNetworks.perseverance]: "https://chainflip-swap-perseverance.chainflip.io/"
|
|
517
498
|
};
|
|
518
499
|
|
|
519
500
|
// src/swap/assets.ts
|
|
@@ -690,7 +671,7 @@ var _SwapSDK = class _SwapSDK {
|
|
|
690
671
|
__publicField(this, "baseUrl");
|
|
691
672
|
__publicField(this, "network");
|
|
692
673
|
__publicField(this, "signer");
|
|
693
|
-
this.network = options.network ?? ChainflipNetworks.
|
|
674
|
+
this.network = options.network ?? ChainflipNetworks.perseverance;
|
|
694
675
|
this.baseUrl = options.backendUrl ?? BACKEND_SERVICE_URLS[this.network];
|
|
695
676
|
this.signer = options.signer;
|
|
696
677
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./swap": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@polkadot/util": "^12.5.1",
|
|
45
45
|
"@polkadot/util-crypto": "^12.5.1",
|
|
46
|
-
"axios": "^1.5.
|
|
46
|
+
"axios": "^1.5.1",
|
|
47
47
|
"ethers": "6.7.1",
|
|
48
48
|
"zod": "^3.22.2"
|
|
49
49
|
},
|