@chainflip/sdk 0.2.4 → 0.2.6
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-HVSV6XD5.mjs → chunk-MGNNXMB7.mjs} +17 -4
- package/dist/{contracts-920ad844.d.ts → contracts-fee99026.d.ts} +1 -1
- package/dist/funding.d.mts +1 -1
- package/dist/funding.d.ts +1 -1
- package/dist/funding.js +17 -4
- package/dist/funding.mjs +1 -1
- package/dist/swap.d.mts +53 -80
- package/dist/swap.d.ts +53 -80
- package/dist/swap.js +29 -33
- package/dist/swap.mjs +14 -31
- package/package.json +2 -2
|
@@ -26,6 +26,7 @@ var Assets = arrayToMap([
|
|
|
26
26
|
"BTC"
|
|
27
27
|
]);
|
|
28
28
|
var ChainflipNetworks = arrayToMap([
|
|
29
|
+
"backspin",
|
|
29
30
|
"sisyphos",
|
|
30
31
|
"perseverance",
|
|
31
32
|
"mainnet"
|
|
@@ -2064,6 +2065,9 @@ __publicField(_Vault__factory, "abi", _abi3);
|
|
|
2064
2065
|
var Vault__factory = _Vault__factory;
|
|
2065
2066
|
|
|
2066
2067
|
// ../shared/src/consts.ts
|
|
2068
|
+
({
|
|
2069
|
+
[ChainflipNetworks.perseverance]: 100
|
|
2070
|
+
});
|
|
2067
2071
|
var MINIMUM_DEPOSIT_AMOUNTS = {
|
|
2068
2072
|
[ChainflipNetworks.perseverance]: {
|
|
2069
2073
|
[Assets.ETH]: "0",
|
|
@@ -2079,24 +2083,32 @@ var MINIMUM_SWAP_AMOUNTS = {
|
|
|
2079
2083
|
[Assets.ETH]: "580000000000000",
|
|
2080
2084
|
[Assets.FLIP]: "1000000000000000000",
|
|
2081
2085
|
[Assets.USDC]: "1000000",
|
|
2082
|
-
[Assets.BTC]: "
|
|
2086
|
+
[Assets.BTC]: "1000",
|
|
2083
2087
|
[Assets.DOT]: "2000000000"
|
|
2084
2088
|
}
|
|
2085
2089
|
};
|
|
2086
2090
|
var getMinimumSwapAmount = /* @__PURE__ */ __name((network, asset) => MINIMUM_SWAP_AMOUNTS[network]?.[asset] ?? "0", "getMinimumSwapAmount");
|
|
2091
|
+
var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
|
|
2087
2092
|
var ADDRESSES = {
|
|
2093
|
+
[ChainflipNetworks.backspin]: {
|
|
2094
|
+
FLIP_CONTRACT_ADDRESS: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
|
|
2095
|
+
USDC_CONTRACT_ADDRESS: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
|
2096
|
+
VAULT_CONTRACT_ADDRESS: "0xB7A5bd0345EF1Cc5E66bf61BdeC17D2461fBd968",
|
|
2097
|
+
STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883"
|
|
2098
|
+
},
|
|
2088
2099
|
[ChainflipNetworks.sisyphos]: {
|
|
2089
2100
|
FLIP_CONTRACT_ADDRESS: "0x2BbB561C6eaB74f358cA9e8a961E3A20CAE3D100",
|
|
2101
|
+
USDC_CONTRACT_ADDRESS: GOERLI_USDC_CONTRACT_ADDRESS,
|
|
2090
2102
|
VAULT_CONTRACT_ADDRESS: "0xC17CCec5015081EB2DF26d20A9e02c5484C1d641",
|
|
2091
2103
|
STATE_CHAIN_GATEWAY_ADDRESS: "0xE8bE4B7F8a38C1913387c9C20B94402bc3Db9F70"
|
|
2092
2104
|
},
|
|
2093
2105
|
[ChainflipNetworks.perseverance]: {
|
|
2094
2106
|
FLIP_CONTRACT_ADDRESS: "0x0485D65da68b2A6b48C3fA28D7CCAce196798B94",
|
|
2107
|
+
USDC_CONTRACT_ADDRESS: GOERLI_USDC_CONTRACT_ADDRESS,
|
|
2095
2108
|
VAULT_CONTRACT_ADDRESS: "0x40caFF3f3B6706Da904a7895e0fC7F7922437e9B",
|
|
2096
2109
|
STATE_CHAIN_GATEWAY_ADDRESS: "0x38AA40B7b5a70d738baBf6699a45DacdDBBEB3fc"
|
|
2097
2110
|
}
|
|
2098
2111
|
};
|
|
2099
|
-
var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
|
|
2100
2112
|
|
|
2101
2113
|
// ../shared/src/contracts.ts
|
|
2102
2114
|
var extractOverrides = /* @__PURE__ */ __name((transactionOverrides) => {
|
|
@@ -2107,8 +2119,9 @@ var getTokenContractAddress = /* @__PURE__ */ __name((asset, network) => {
|
|
|
2107
2119
|
assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
|
|
2108
2120
|
if (asset === Assets.FLIP)
|
|
2109
2121
|
return ADDRESSES[network].FLIP_CONTRACT_ADDRESS;
|
|
2110
|
-
|
|
2111
|
-
|
|
2122
|
+
if (asset === Assets.USDC)
|
|
2123
|
+
return ADDRESSES[network].USDC_CONTRACT_ADDRESS;
|
|
2124
|
+
throw new Error("Only FLIP and USDC are supported for now");
|
|
2112
2125
|
}, "getTokenContractAddress");
|
|
2113
2126
|
var getStateChainGatewayContractAddress = /* @__PURE__ */ __name((network) => {
|
|
2114
2127
|
assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
|
|
@@ -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 ["sisyphos", "perseverance", "mainnet"]>;
|
|
8
|
+
declare const ChainflipNetworks: ArrayToMap<readonly ["backspin", "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,6 +779,7 @@ var Assets = arrayToMap([
|
|
|
779
779
|
"BTC"
|
|
780
780
|
]);
|
|
781
781
|
var ChainflipNetworks = arrayToMap([
|
|
782
|
+
"backspin",
|
|
782
783
|
"sisyphos",
|
|
783
784
|
"perseverance",
|
|
784
785
|
"mainnet"
|
|
@@ -826,6 +827,9 @@ var ChainflipNetworks = arrayToMap([
|
|
|
826
827
|
});
|
|
827
828
|
|
|
828
829
|
// ../shared/src/consts.ts
|
|
830
|
+
({
|
|
831
|
+
[ChainflipNetworks.perseverance]: 100
|
|
832
|
+
});
|
|
829
833
|
({
|
|
830
834
|
[ChainflipNetworks.perseverance]: {
|
|
831
835
|
[Assets.ETH]: "0",
|
|
@@ -840,23 +844,31 @@ var ChainflipNetworks = arrayToMap([
|
|
|
840
844
|
[Assets.ETH]: "580000000000000",
|
|
841
845
|
[Assets.FLIP]: "1000000000000000000",
|
|
842
846
|
[Assets.USDC]: "1000000",
|
|
843
|
-
[Assets.BTC]: "
|
|
847
|
+
[Assets.BTC]: "1000",
|
|
844
848
|
[Assets.DOT]: "2000000000"
|
|
845
849
|
}
|
|
846
850
|
});
|
|
851
|
+
var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
|
|
847
852
|
var ADDRESSES = {
|
|
853
|
+
[ChainflipNetworks.backspin]: {
|
|
854
|
+
FLIP_CONTRACT_ADDRESS: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
|
|
855
|
+
USDC_CONTRACT_ADDRESS: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
|
856
|
+
VAULT_CONTRACT_ADDRESS: "0xB7A5bd0345EF1Cc5E66bf61BdeC17D2461fBd968",
|
|
857
|
+
STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883"
|
|
858
|
+
},
|
|
848
859
|
[ChainflipNetworks.sisyphos]: {
|
|
849
860
|
FLIP_CONTRACT_ADDRESS: "0x2BbB561C6eaB74f358cA9e8a961E3A20CAE3D100",
|
|
861
|
+
USDC_CONTRACT_ADDRESS: GOERLI_USDC_CONTRACT_ADDRESS,
|
|
850
862
|
VAULT_CONTRACT_ADDRESS: "0xC17CCec5015081EB2DF26d20A9e02c5484C1d641",
|
|
851
863
|
STATE_CHAIN_GATEWAY_ADDRESS: "0xE8bE4B7F8a38C1913387c9C20B94402bc3Db9F70"
|
|
852
864
|
},
|
|
853
865
|
[ChainflipNetworks.perseverance]: {
|
|
854
866
|
FLIP_CONTRACT_ADDRESS: "0x0485D65da68b2A6b48C3fA28D7CCAce196798B94",
|
|
867
|
+
USDC_CONTRACT_ADDRESS: GOERLI_USDC_CONTRACT_ADDRESS,
|
|
855
868
|
VAULT_CONTRACT_ADDRESS: "0x40caFF3f3B6706Da904a7895e0fC7F7922437e9B",
|
|
856
869
|
STATE_CHAIN_GATEWAY_ADDRESS: "0x38AA40B7b5a70d738baBf6699a45DacdDBBEB3fc"
|
|
857
870
|
}
|
|
858
871
|
};
|
|
859
|
-
var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
|
|
860
872
|
|
|
861
873
|
// ../shared/src/guards.ts
|
|
862
874
|
function assert(condition, message) {
|
|
@@ -879,8 +891,9 @@ var getTokenContractAddress = /* @__PURE__ */ __name((asset, network) => {
|
|
|
879
891
|
assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
|
|
880
892
|
if (asset === Assets.FLIP)
|
|
881
893
|
return ADDRESSES[network].FLIP_CONTRACT_ADDRESS;
|
|
882
|
-
|
|
883
|
-
|
|
894
|
+
if (asset === Assets.USDC)
|
|
895
|
+
return ADDRESSES[network].USDC_CONTRACT_ADDRESS;
|
|
896
|
+
throw new Error("Only FLIP and USDC are supported for now");
|
|
884
897
|
}, "getTokenContractAddress");
|
|
885
898
|
var getStateChainGatewayContractAddress = /* @__PURE__ */ __name((network) => {
|
|
886
899
|
assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
|
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-MGNNXMB7.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-fee99026.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-fee99026.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-fee99026.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-fee99026.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,6 +55,7 @@ var Assets = arrayToMap([
|
|
|
55
55
|
"BTC"
|
|
56
56
|
]);
|
|
57
57
|
var ChainflipNetworks = arrayToMap([
|
|
58
|
+
"backspin",
|
|
58
59
|
"sisyphos",
|
|
59
60
|
"perseverance",
|
|
60
61
|
"mainnet"
|
|
@@ -133,9 +134,9 @@ var Encoding;
|
|
|
133
134
|
})(Encoding || (Encoding = {}));
|
|
134
135
|
var bech32 = {
|
|
135
136
|
getEncodingConst(enc) {
|
|
136
|
-
if (enc ===
|
|
137
|
+
if (enc === "bech32")
|
|
137
138
|
return 1;
|
|
138
|
-
if (enc ===
|
|
139
|
+
if (enc === "bech32m")
|
|
139
140
|
return 734539939;
|
|
140
141
|
return null;
|
|
141
142
|
},
|
|
@@ -259,9 +260,9 @@ var segwitAddress = {
|
|
|
259
260
|
},
|
|
260
261
|
decode(hrp, addr) {
|
|
261
262
|
let bech32m = false;
|
|
262
|
-
let dec = bech32.decode(addr,
|
|
263
|
+
let dec = bech32.decode(addr, "bech32");
|
|
263
264
|
if (dec === null) {
|
|
264
|
-
dec = bech32.decode(addr,
|
|
265
|
+
dec = bech32.decode(addr, "bech32m");
|
|
265
266
|
bech32m = true;
|
|
266
267
|
}
|
|
267
268
|
if (dec === null || dec.hrp !== hrp || dec.data.length < 1 || dec.data[0] > 16) {
|
|
@@ -286,9 +287,9 @@ var segwitAddress = {
|
|
|
286
287
|
};
|
|
287
288
|
},
|
|
288
289
|
encode(hrp, version, program) {
|
|
289
|
-
let enc =
|
|
290
|
+
let enc = "bech32";
|
|
290
291
|
if (version > 0) {
|
|
291
|
-
enc =
|
|
292
|
+
enc = "bech32m";
|
|
292
293
|
}
|
|
293
294
|
const ret = bech32.encode(
|
|
294
295
|
hrp,
|
|
@@ -455,24 +456,6 @@ zod.z.object({
|
|
|
455
456
|
...rest,
|
|
456
457
|
expectedDepositAmount: amount
|
|
457
458
|
}));
|
|
458
|
-
zod.z.union([
|
|
459
|
-
zod.z.object({
|
|
460
|
-
id: zod.z.string(),
|
|
461
|
-
intermediate_amount: numericString,
|
|
462
|
-
egress_amount: numericString
|
|
463
|
-
}).transform(({ id, ...rest }) => ({
|
|
464
|
-
id,
|
|
465
|
-
intermediateAmount: rest.intermediate_amount,
|
|
466
|
-
egressAmount: rest.egress_amount
|
|
467
|
-
})),
|
|
468
|
-
zod.z.object({
|
|
469
|
-
id: zod.z.string(),
|
|
470
|
-
egress_amount: numericString
|
|
471
|
-
}).transform(({ id, ...rest }) => ({
|
|
472
|
-
id,
|
|
473
|
-
egressAmount: rest.egress_amount
|
|
474
|
-
}))
|
|
475
|
-
]);
|
|
476
459
|
|
|
477
460
|
// ../shared/src/vault/schemas.ts
|
|
478
461
|
var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
@@ -480,7 +463,7 @@ var bytesToHex = /* @__PURE__ */ __name((arr) => `0x${[
|
|
|
480
463
|
].map((v) => v.toString(16).padStart(2, "0")).join("")}`, "bytesToHex");
|
|
481
464
|
var utf8ToHex = /* @__PURE__ */ __name((str) => `0x${Buffer.from(str).toString("hex")}`, "utf8ToHex");
|
|
482
465
|
var eth = zod.z.object({
|
|
483
|
-
amount:
|
|
466
|
+
amount: numericString,
|
|
484
467
|
srcChain: zod.z.literal(Chains.Ethereum),
|
|
485
468
|
srcAsset: zod.z.literal(Assets.ETH)
|
|
486
469
|
});
|
|
@@ -1862,6 +1845,9 @@ __publicField(_Vault__factory, "abi", _abi2);
|
|
|
1862
1845
|
var Vault__factory = _Vault__factory;
|
|
1863
1846
|
|
|
1864
1847
|
// ../shared/src/consts.ts
|
|
1848
|
+
({
|
|
1849
|
+
[ChainflipNetworks.perseverance]: 100
|
|
1850
|
+
});
|
|
1865
1851
|
var MINIMUM_DEPOSIT_AMOUNTS = {
|
|
1866
1852
|
[ChainflipNetworks.perseverance]: {
|
|
1867
1853
|
[Assets.ETH]: "0",
|
|
@@ -1877,24 +1863,32 @@ var MINIMUM_SWAP_AMOUNTS = {
|
|
|
1877
1863
|
[Assets.ETH]: "580000000000000",
|
|
1878
1864
|
[Assets.FLIP]: "1000000000000000000",
|
|
1879
1865
|
[Assets.USDC]: "1000000",
|
|
1880
|
-
[Assets.BTC]: "
|
|
1866
|
+
[Assets.BTC]: "1000",
|
|
1881
1867
|
[Assets.DOT]: "2000000000"
|
|
1882
1868
|
}
|
|
1883
1869
|
};
|
|
1884
1870
|
var getMinimumSwapAmount = /* @__PURE__ */ __name((network, asset) => MINIMUM_SWAP_AMOUNTS[network]?.[asset] ?? "0", "getMinimumSwapAmount");
|
|
1871
|
+
var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
|
|
1885
1872
|
var ADDRESSES = {
|
|
1873
|
+
[ChainflipNetworks.backspin]: {
|
|
1874
|
+
FLIP_CONTRACT_ADDRESS: "0x10C6E9530F1C1AF873a391030a1D9E8ed0630D26",
|
|
1875
|
+
USDC_CONTRACT_ADDRESS: "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0",
|
|
1876
|
+
VAULT_CONTRACT_ADDRESS: "0xB7A5bd0345EF1Cc5E66bf61BdeC17D2461fBd968",
|
|
1877
|
+
STATE_CHAIN_GATEWAY_ADDRESS: "0xeEBe00Ac0756308ac4AaBfD76c05c4F3088B8883"
|
|
1878
|
+
},
|
|
1886
1879
|
[ChainflipNetworks.sisyphos]: {
|
|
1887
1880
|
FLIP_CONTRACT_ADDRESS: "0x2BbB561C6eaB74f358cA9e8a961E3A20CAE3D100",
|
|
1881
|
+
USDC_CONTRACT_ADDRESS: GOERLI_USDC_CONTRACT_ADDRESS,
|
|
1888
1882
|
VAULT_CONTRACT_ADDRESS: "0xC17CCec5015081EB2DF26d20A9e02c5484C1d641",
|
|
1889
1883
|
STATE_CHAIN_GATEWAY_ADDRESS: "0xE8bE4B7F8a38C1913387c9C20B94402bc3Db9F70"
|
|
1890
1884
|
},
|
|
1891
1885
|
[ChainflipNetworks.perseverance]: {
|
|
1892
1886
|
FLIP_CONTRACT_ADDRESS: "0x0485D65da68b2A6b48C3fA28D7CCAce196798B94",
|
|
1887
|
+
USDC_CONTRACT_ADDRESS: GOERLI_USDC_CONTRACT_ADDRESS,
|
|
1893
1888
|
VAULT_CONTRACT_ADDRESS: "0x40caFF3f3B6706Da904a7895e0fC7F7922437e9B",
|
|
1894
1889
|
STATE_CHAIN_GATEWAY_ADDRESS: "0x38AA40B7b5a70d738baBf6699a45DacdDBBEB3fc"
|
|
1895
1890
|
}
|
|
1896
1891
|
};
|
|
1897
|
-
var GOERLI_USDC_CONTRACT_ADDRESS = "0x07865c6E87B9F70255377e024ace6630C1Eaa37F";
|
|
1898
1892
|
|
|
1899
1893
|
// ../shared/src/contracts.ts
|
|
1900
1894
|
var extractOverrides = /* @__PURE__ */ __name((transactionOverrides) => {
|
|
@@ -1905,8 +1899,9 @@ var getTokenContractAddress = /* @__PURE__ */ __name((asset, network) => {
|
|
|
1905
1899
|
assert(network !== ChainflipNetworks.mainnet, "Mainnet is not yet supported");
|
|
1906
1900
|
if (asset === Assets.FLIP)
|
|
1907
1901
|
return ADDRESSES[network].FLIP_CONTRACT_ADDRESS;
|
|
1908
|
-
|
|
1909
|
-
|
|
1902
|
+
if (asset === Assets.USDC)
|
|
1903
|
+
return ADDRESSES[network].USDC_CONTRACT_ADDRESS;
|
|
1904
|
+
throw new Error("Only FLIP and USDC are supported for now");
|
|
1910
1905
|
}, "getTokenContractAddress");
|
|
1911
1906
|
var checkAllowance = /* @__PURE__ */ __name(async (amount, spenderAddress, erc20Address, signer) => {
|
|
1912
1907
|
const erc20 = ERC20__factory.connect(erc20Address, signer);
|
|
@@ -1943,7 +1938,7 @@ var swapToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
1943
1938
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1944
1939
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
1945
1940
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
1946
|
-
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1941
|
+
const { isAllowable } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1947
1942
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
1948
1943
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
1949
1944
|
const transaction = await vault.xSwapToken(chainContractIds[params.destChain], params.destAddress, assetContractIds[params.destAsset], erc20Address, params.amount, "0x", extractOverrides(txOpts));
|
|
@@ -1962,7 +1957,7 @@ var callToken = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
|
1962
1957
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1963
1958
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
1964
1959
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
1965
|
-
const { isAllowable } = await checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1960
|
+
const { isAllowable } = await checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1966
1961
|
assert(isAllowable, "Swap amount exceeds allowance");
|
|
1967
1962
|
const vault = Vault__factory.connect(vaultContractAddress, networkOpts.signer);
|
|
1968
1963
|
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));
|
|
@@ -1982,18 +1977,19 @@ var checkVaultAllowance = /* @__PURE__ */ __name((params, networkOpts) => {
|
|
|
1982
1977
|
const erc20Address = networkOpts.network === "localnet" ? networkOpts.srcTokenContractAddress : getTokenContractAddress(params.srcAsset, networkOpts.network);
|
|
1983
1978
|
assert(erc20Address !== void 0, "Missing ERC20 contract address");
|
|
1984
1979
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1985
|
-
return checkAllowance(params.amount, vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1980
|
+
return checkAllowance(BigInt(params.amount), vaultContractAddress, erc20Address, networkOpts.signer);
|
|
1986
1981
|
}, "checkVaultAllowance");
|
|
1987
1982
|
var approveVault = /* @__PURE__ */ __name(async (params, networkOpts, txOpts) => {
|
|
1988
1983
|
const { isAllowable, erc20, allowance } = await checkVaultAllowance(params, networkOpts);
|
|
1989
1984
|
if (isAllowable)
|
|
1990
1985
|
return null;
|
|
1991
1986
|
const vaultContractAddress = networkOpts.network === "localnet" ? networkOpts.vaultContractAddress : getVaultManagerContractAddress(networkOpts.network);
|
|
1992
|
-
return approve(params.amount, vaultContractAddress, erc20, allowance, txOpts);
|
|
1987
|
+
return approve(BigInt(params.amount), vaultContractAddress, erc20, allowance, txOpts);
|
|
1993
1988
|
}, "approveVault");
|
|
1994
1989
|
|
|
1995
1990
|
// src/swap/consts.ts
|
|
1996
1991
|
var BACKEND_SERVICE_URLS = {
|
|
1992
|
+
[ChainflipNetworks.backspin]: "https://chainflip-swap-backspin.staging/",
|
|
1997
1993
|
[ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
|
|
1998
1994
|
[ChainflipNetworks.perseverance]: "https://chainflip-swap-perseverance.chainflip.io/"
|
|
1999
1995
|
};
|
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-MGNNXMB7.mjs';
|
|
2
|
+
export { Assets, ChainflipNetworks, Chains, assetChains, assetContractIds, assetDecimals, chainAssets, chainContractIds } from './chunk-MGNNXMB7.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,18 +481,19 @@ 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 = {
|
|
496
|
+
[ChainflipNetworks.backspin]: "https://chainflip-swap-backspin.staging/",
|
|
514
497
|
[ChainflipNetworks.sisyphos]: "https://chainflip-swap.staging/",
|
|
515
498
|
[ChainflipNetworks.perseverance]: "https://chainflip-swap-perseverance.chainflip.io/"
|
|
516
499
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainflip/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
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
|
},
|