@swapkit/core 1.0.0-rc.119 → 1.0.0-rc.120
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/{index.es.js → index.js} +1072 -963
- package/dist/index.js.map +41 -0
- package/package.json +27 -36
- package/src/__tests__/helpers.test.ts +2 -26
- package/src/client/index.ts +21 -26
- package/src/client/old.ts +64 -76
- package/src/helpers/explorerUrls.ts +6 -31
- package/src/types.ts +2 -2
- package/LICENSE +0 -201
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -353
- package/dist/index.es.js.map +0 -1
- package/src/helpers/mayanode.ts +0 -31
- package/src/helpers/thornode.ts +0 -31
|
@@ -1,206 +1,205 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
case
|
|
20
|
-
case
|
|
21
|
-
case
|
|
22
|
-
case
|
|
23
|
-
return `${
|
|
24
|
-
case
|
|
25
|
-
case
|
|
26
|
-
case
|
|
27
|
-
case
|
|
28
|
-
case
|
|
29
|
-
case
|
|
30
|
-
case
|
|
31
|
-
return `${
|
|
32
|
-
case
|
|
33
|
-
|
|
34
|
-
case
|
|
35
|
-
case
|
|
36
|
-
|
|
37
|
-
case a.Dogecoin:
|
|
38
|
-
return `${t}/transaction/${e.toLowerCase()}`;
|
|
1
|
+
var __require = ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined")
|
|
5
|
+
return require.apply(this, arguments);
|
|
6
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
// src/client/index.ts
|
|
10
|
+
import {AssetValue, SwapKitError} from "@swapkit/helpers";
|
|
11
|
+
import {Chain as Chain2} from "@swapkit/types";
|
|
12
|
+
|
|
13
|
+
// src/helpers/explorerUrls.ts
|
|
14
|
+
import {Chain, ChainToExplorerUrl} from "@swapkit/types";
|
|
15
|
+
function getExplorerTxUrl({ chain, txHash }) {
|
|
16
|
+
const baseUrl = ChainToExplorerUrl[chain];
|
|
17
|
+
switch (chain) {
|
|
18
|
+
case Chain.Binance:
|
|
19
|
+
case Chain.Maya:
|
|
20
|
+
case Chain.Kujira:
|
|
21
|
+
case Chain.Cosmos:
|
|
22
|
+
case Chain.THORChain:
|
|
23
|
+
return `${baseUrl}/tx/${txHash.startsWith("0x") ? txHash.slice(2) : txHash}`;
|
|
24
|
+
case Chain.Arbitrum:
|
|
25
|
+
case Chain.Avalanche:
|
|
26
|
+
case Chain.BinanceSmartChain:
|
|
27
|
+
case Chain.Ethereum:
|
|
28
|
+
case Chain.Optimism:
|
|
29
|
+
case Chain.Polkadot:
|
|
30
|
+
case Chain.Polygon:
|
|
31
|
+
return `${baseUrl}/tx/${txHash.startsWith("0x") ? txHash : `0x${txHash}`}`;
|
|
32
|
+
case Chain.Litecoin:
|
|
33
|
+
case Chain.Bitcoin:
|
|
34
|
+
case Chain.BitcoinCash:
|
|
35
|
+
case Chain.Dogecoin:
|
|
36
|
+
return `${baseUrl}/transaction/${txHash.toLowerCase()}`;
|
|
39
37
|
default:
|
|
40
|
-
throw new Error(`Unsupported chain: ${
|
|
38
|
+
throw new Error(`Unsupported chain: ${chain}`);
|
|
41
39
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
case a.Optimism:
|
|
57
|
-
case a.Polkadot:
|
|
58
|
-
case a.Polygon:
|
|
59
|
-
case a.THORChain:
|
|
60
|
-
return `${t}/address/${e}`;
|
|
61
|
-
case a.Cosmos:
|
|
62
|
-
return `${t}/account/${e}`;
|
|
63
|
-
default:
|
|
64
|
-
throw new Error(`Unsupported chain: ${r}`);
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
var Me = /* @__PURE__ */ ((r) => (r.Approve = "approve", r.CheckOnly = "checkOnly", r))(Me || {});
|
|
68
|
-
function ze({
|
|
69
|
-
stagenet: r,
|
|
70
|
-
wallets: e,
|
|
71
|
-
plugins: t,
|
|
72
|
-
config: n = {},
|
|
73
|
-
apis: p,
|
|
74
|
-
rpcUrls: i
|
|
40
|
+
}
|
|
41
|
+
function getExplorerAddressUrl({ chain, address }) {
|
|
42
|
+
const baseUrl = ChainToExplorerUrl[chain];
|
|
43
|
+
return `${baseUrl}/address/${address}`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// src/client/index.ts
|
|
47
|
+
function SwapKit({
|
|
48
|
+
stagenet,
|
|
49
|
+
wallets,
|
|
50
|
+
plugins,
|
|
51
|
+
config = {},
|
|
52
|
+
apis,
|
|
53
|
+
rpcUrls
|
|
75
54
|
}) {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
55
|
+
const connectedWallets = {};
|
|
56
|
+
const availablePlugins = {};
|
|
57
|
+
for (const plugin of plugins) {
|
|
58
|
+
const { name, methods } = plugin({ wallets: connectedWallets, stagenet });
|
|
59
|
+
availablePlugins[name] = methods;
|
|
80
60
|
}
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
61
|
+
const connectWalletMethods = wallets.reduce((acc, wallet) => {
|
|
62
|
+
acc[wallet.connectMethodName] = wallet.connect({
|
|
63
|
+
addChain,
|
|
64
|
+
config,
|
|
65
|
+
apis,
|
|
66
|
+
rpcUrls
|
|
67
|
+
});
|
|
68
|
+
return acc;
|
|
69
|
+
}, {});
|
|
70
|
+
function getSwapKitPlugin(pluginName) {
|
|
71
|
+
const plugin = availablePlugins[pluginName] || Object.values(availablePlugins)[0];
|
|
72
|
+
if (!plugin) {
|
|
73
|
+
throw new SwapKitError("core_plugin_not_found", "Could not find the requested plugin");
|
|
74
|
+
}
|
|
75
|
+
return plugin;
|
|
92
76
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
77
|
+
function addChain(connectWallet) {
|
|
78
|
+
connectedWallets[connectWallet.chain] = connectWallet;
|
|
95
79
|
}
|
|
96
|
-
function
|
|
97
|
-
assetValue
|
|
98
|
-
type
|
|
99
|
-
contractAddress
|
|
80
|
+
function approve({
|
|
81
|
+
assetValue,
|
|
82
|
+
type = "checkOnly",
|
|
83
|
+
contractAddress
|
|
100
84
|
}) {
|
|
101
|
-
const { address
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
85
|
+
const { address, chain, isGasAsset, isSynthetic } = assetValue;
|
|
86
|
+
const isEVMChain = [Chain2.Ethereum, Chain2.Avalanche, Chain2.BinanceSmartChain].includes(chain);
|
|
87
|
+
const isNativeEVM = isEVMChain && isGasAsset;
|
|
88
|
+
if (isNativeEVM || !isEVMChain || isSynthetic) {
|
|
89
|
+
return Promise.resolve(type === "checkOnly" ? true : "approved");
|
|
90
|
+
}
|
|
91
|
+
const walletMethods = connectedWallets[chain];
|
|
92
|
+
const walletAction = type === "checkOnly" ? walletMethods?.isApproved : walletMethods?.approve;
|
|
93
|
+
if (!walletAction)
|
|
94
|
+
throw new SwapKitError("core_wallet_connection_not_found");
|
|
95
|
+
const from = getAddress(chain);
|
|
96
|
+
if (!(address && from))
|
|
97
|
+
throw new SwapKitError("core_approve_asset_address_or_from_not_found");
|
|
98
|
+
const spenderAddress = contractAddress;
|
|
99
|
+
return walletAction({
|
|
100
|
+
amount: assetValue.getBaseValue("bigint"),
|
|
101
|
+
assetAddress: address,
|
|
102
|
+
from,
|
|
103
|
+
spenderAddress
|
|
116
104
|
});
|
|
117
105
|
}
|
|
118
|
-
function
|
|
119
|
-
return
|
|
120
|
-
}
|
|
121
|
-
function l(u) {
|
|
122
|
-
var m;
|
|
123
|
-
return ((m = d(u)) == null ? void 0 : m.address) || "";
|
|
124
|
-
}
|
|
125
|
-
function A(u) {
|
|
126
|
-
var m;
|
|
127
|
-
return ((m = d(u)) == null ? void 0 : m.balance) || [];
|
|
106
|
+
function getWallet(chain) {
|
|
107
|
+
return connectedWallets[chain];
|
|
128
108
|
}
|
|
129
|
-
function
|
|
130
|
-
return
|
|
109
|
+
function getAddress(chain) {
|
|
110
|
+
return getWallet(chain)?.address || "";
|
|
131
111
|
}
|
|
132
|
-
function
|
|
133
|
-
return
|
|
112
|
+
function getBalance(chain) {
|
|
113
|
+
return getWallet(chain)?.balance || [];
|
|
134
114
|
}
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
return (x = (_ = d(m)) == null ? void 0 : _.validateAddress) == null ? void 0 : x.call(_, u);
|
|
115
|
+
function validateAddress({ address, chain }) {
|
|
116
|
+
return getWallet(chain)?.validateAddress?.(address);
|
|
138
117
|
}
|
|
139
|
-
async function
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const R = await (x == null ? void 0 : x.getBalance(x.address, m));
|
|
145
|
-
return x.balance = R != null && R.length ? R : _, x;
|
|
146
|
-
} catch (R) {
|
|
147
|
-
throw new s("core_wallet_connection_not_found", R);
|
|
118
|
+
async function getWalletWithBalance(chain, potentialScamFilter) {
|
|
119
|
+
const defaultBalance = [AssetValue.fromChainOrSignature(chain)];
|
|
120
|
+
const wallet = getWallet(chain);
|
|
121
|
+
if (!wallet) {
|
|
122
|
+
throw new SwapKitError("core_wallet_connection_not_found");
|
|
148
123
|
}
|
|
124
|
+
const balance = await wallet?.getBalance(wallet.address, potentialScamFilter);
|
|
125
|
+
wallet.balance = balance?.length ? balance : defaultBalance;
|
|
126
|
+
return wallet;
|
|
149
127
|
}
|
|
150
|
-
function
|
|
151
|
-
return
|
|
152
|
-
assetValue: u,
|
|
153
|
-
contractAddress: m,
|
|
154
|
-
type: "approve"
|
|
155
|
-
/* Approve */
|
|
156
|
-
});
|
|
128
|
+
function approveAssetValue(assetValue, contractAddress) {
|
|
129
|
+
return approve({ assetValue, contractAddress, type: ApproveMode.Approve });
|
|
157
130
|
}
|
|
158
|
-
function
|
|
159
|
-
return
|
|
160
|
-
assetValue: u,
|
|
161
|
-
contractAddress: m,
|
|
162
|
-
type: "checkOnly"
|
|
163
|
-
/* CheckOnly */
|
|
164
|
-
});
|
|
131
|
+
function isAssetValueApproved(assetValue, contractAddress) {
|
|
132
|
+
return approve({ assetValue, contractAddress, type: ApproveMode.CheckOnly });
|
|
165
133
|
}
|
|
166
|
-
function
|
|
167
|
-
|
|
134
|
+
function swap({ provider, ...rest }) {
|
|
135
|
+
const plugin = getSwapKitPlugin(provider?.name);
|
|
136
|
+
return plugin.swap({ provider, ...rest });
|
|
168
137
|
}
|
|
169
138
|
return {
|
|
170
|
-
...
|
|
171
|
-
...
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
getWallet
|
|
178
|
-
getWalletWithBalance
|
|
179
|
-
isAssetValueApproved
|
|
180
|
-
swap
|
|
181
|
-
validateAddress
|
|
139
|
+
...availablePlugins,
|
|
140
|
+
...connectWalletMethods,
|
|
141
|
+
getExplorerAddressUrl,
|
|
142
|
+
getExplorerTxUrl,
|
|
143
|
+
approveAssetValue,
|
|
144
|
+
getAddress,
|
|
145
|
+
getBalance,
|
|
146
|
+
getWallet,
|
|
147
|
+
getWalletWithBalance,
|
|
148
|
+
isAssetValueApproved,
|
|
149
|
+
swap,
|
|
150
|
+
validateAddress
|
|
182
151
|
};
|
|
183
152
|
}
|
|
184
|
-
|
|
153
|
+
var ApproveMode;
|
|
154
|
+
(function(ApproveMode2) {
|
|
155
|
+
ApproveMode2["Approve"] = "approve";
|
|
156
|
+
ApproveMode2["CheckOnly"] = "checkOnly";
|
|
157
|
+
})(ApproveMode || (ApproveMode = {}));
|
|
158
|
+
// src/client/old.ts
|
|
159
|
+
import {
|
|
160
|
+
AssetValue as AssetValue2,
|
|
161
|
+
SwapKitApi,
|
|
162
|
+
SwapKitError as SwapKitError2,
|
|
163
|
+
SwapKitNumber,
|
|
164
|
+
gasFeeMultiplier,
|
|
165
|
+
getMemoFor,
|
|
166
|
+
getMinAmountByChain,
|
|
167
|
+
wrapWithThrow
|
|
168
|
+
} from "@swapkit/helpers";
|
|
169
|
+
import {
|
|
170
|
+
AGG_SWAP,
|
|
171
|
+
Chain as Chain3,
|
|
172
|
+
ChainToChainId,
|
|
173
|
+
FeeOption,
|
|
174
|
+
MemoType,
|
|
175
|
+
SWAP_IN,
|
|
176
|
+
SWAP_OUT,
|
|
177
|
+
TCAvalancheDepositABI,
|
|
178
|
+
TCBscDepositABI,
|
|
179
|
+
TCEthereumVaultAbi
|
|
180
|
+
} from "@swapkit/types";
|
|
181
|
+
|
|
182
|
+
// src/aggregator/contracts/avaxGeneric.ts
|
|
183
|
+
var avaxGeneric = [
|
|
185
184
|
{
|
|
186
185
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
187
186
|
stateMutability: "nonpayable",
|
|
188
187
|
type: "constructor"
|
|
189
188
|
},
|
|
190
189
|
{
|
|
191
|
-
anonymous:
|
|
190
|
+
anonymous: false,
|
|
192
191
|
inputs: [
|
|
193
|
-
{ indexed:
|
|
194
|
-
{ indexed:
|
|
192
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
193
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
195
194
|
],
|
|
196
195
|
name: "FeeSet",
|
|
197
196
|
type: "event"
|
|
198
197
|
},
|
|
199
198
|
{
|
|
200
|
-
anonymous:
|
|
199
|
+
anonymous: false,
|
|
201
200
|
inputs: [
|
|
202
|
-
{ indexed:
|
|
203
|
-
{ indexed:
|
|
201
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
202
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
204
203
|
],
|
|
205
204
|
name: "OwnerSet",
|
|
206
205
|
type: "event"
|
|
@@ -272,7 +271,10 @@ const Ae = [
|
|
|
272
271
|
type: "function"
|
|
273
272
|
},
|
|
274
273
|
{ stateMutability: "payable", type: "receive" }
|
|
275
|
-
]
|
|
274
|
+
];
|
|
275
|
+
|
|
276
|
+
// src/aggregator/contracts/avaxWoofi.ts
|
|
277
|
+
var avaxWoofi = [
|
|
276
278
|
{
|
|
277
279
|
inputs: [
|
|
278
280
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -283,44 +285,44 @@ const Ae = [
|
|
|
283
285
|
type: "constructor"
|
|
284
286
|
},
|
|
285
287
|
{
|
|
286
|
-
anonymous:
|
|
288
|
+
anonymous: false,
|
|
287
289
|
inputs: [
|
|
288
|
-
{ indexed:
|
|
289
|
-
{ indexed:
|
|
290
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
291
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
290
292
|
],
|
|
291
293
|
name: "FeeSet",
|
|
292
294
|
type: "event"
|
|
293
295
|
},
|
|
294
296
|
{
|
|
295
|
-
anonymous:
|
|
297
|
+
anonymous: false,
|
|
296
298
|
inputs: [
|
|
297
|
-
{ indexed:
|
|
298
|
-
{ indexed:
|
|
299
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
300
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
299
301
|
],
|
|
300
302
|
name: "OwnerSet",
|
|
301
303
|
type: "event"
|
|
302
304
|
},
|
|
303
305
|
{
|
|
304
|
-
anonymous:
|
|
306
|
+
anonymous: false,
|
|
305
307
|
inputs: [
|
|
306
|
-
{ indexed:
|
|
307
|
-
{ indexed:
|
|
308
|
-
{ indexed:
|
|
309
|
-
{ indexed:
|
|
310
|
-
{ indexed:
|
|
311
|
-
{ indexed:
|
|
312
|
-
{ indexed:
|
|
308
|
+
{ indexed: false, internalType: "address", name: "from", type: "address" },
|
|
309
|
+
{ indexed: false, internalType: "address", name: "token", type: "address" },
|
|
310
|
+
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
|
|
311
|
+
{ indexed: false, internalType: "uint256", name: "out", type: "uint256" },
|
|
312
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
313
|
+
{ indexed: false, internalType: "address", name: "vault", type: "address" },
|
|
314
|
+
{ indexed: false, internalType: "string", name: "memo", type: "string" }
|
|
313
315
|
],
|
|
314
316
|
name: "SwapIn",
|
|
315
317
|
type: "event"
|
|
316
318
|
},
|
|
317
319
|
{
|
|
318
|
-
anonymous:
|
|
320
|
+
anonymous: false,
|
|
319
321
|
inputs: [
|
|
320
|
-
{ indexed:
|
|
321
|
-
{ indexed:
|
|
322
|
-
{ indexed:
|
|
323
|
-
{ indexed:
|
|
322
|
+
{ indexed: false, internalType: "address", name: "to", type: "address" },
|
|
323
|
+
{ indexed: false, internalType: "address", name: "token", type: "address" },
|
|
324
|
+
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
|
|
325
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" }
|
|
324
326
|
],
|
|
325
327
|
name: "SwapOut",
|
|
326
328
|
type: "event"
|
|
@@ -416,40 +418,43 @@ const Ae = [
|
|
|
416
418
|
type: "function"
|
|
417
419
|
},
|
|
418
420
|
{ stateMutability: "payable", type: "receive" }
|
|
419
|
-
]
|
|
421
|
+
];
|
|
422
|
+
|
|
423
|
+
// src/aggregator/contracts/bscGeneric.ts
|
|
424
|
+
var bscGeneric = [
|
|
420
425
|
{
|
|
421
426
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
422
427
|
stateMutability: "nonpayable",
|
|
423
428
|
type: "constructor"
|
|
424
429
|
},
|
|
425
430
|
{
|
|
426
|
-
anonymous:
|
|
431
|
+
anonymous: false,
|
|
427
432
|
inputs: [
|
|
428
|
-
{ indexed:
|
|
429
|
-
{ indexed:
|
|
433
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
434
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
430
435
|
],
|
|
431
436
|
name: "FeeSet",
|
|
432
437
|
type: "event"
|
|
433
438
|
},
|
|
434
439
|
{
|
|
435
|
-
anonymous:
|
|
440
|
+
anonymous: false,
|
|
436
441
|
inputs: [
|
|
437
|
-
{ indexed:
|
|
438
|
-
{ indexed:
|
|
442
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
443
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
439
444
|
],
|
|
440
445
|
name: "OwnerSet",
|
|
441
446
|
type: "event"
|
|
442
447
|
},
|
|
443
448
|
{
|
|
444
|
-
anonymous:
|
|
449
|
+
anonymous: false,
|
|
445
450
|
inputs: [
|
|
446
|
-
{ indexed:
|
|
447
|
-
{ indexed:
|
|
448
|
-
{ indexed:
|
|
449
|
-
{ indexed:
|
|
450
|
-
{ indexed:
|
|
451
|
-
{ indexed:
|
|
452
|
-
{ indexed:
|
|
451
|
+
{ indexed: false, internalType: "address", name: "from", type: "address" },
|
|
452
|
+
{ indexed: false, internalType: "address", name: "token", type: "address" },
|
|
453
|
+
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
|
|
454
|
+
{ indexed: false, internalType: "uint256", name: "out", type: "uint256" },
|
|
455
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
456
|
+
{ indexed: false, internalType: "address", name: "vault", type: "address" },
|
|
457
|
+
{ indexed: false, internalType: "string", name: "memo", type: "string" }
|
|
453
458
|
],
|
|
454
459
|
name: "SwapIn",
|
|
455
460
|
type: "event"
|
|
@@ -521,26 +526,29 @@ const Ae = [
|
|
|
521
526
|
type: "function"
|
|
522
527
|
},
|
|
523
528
|
{ stateMutability: "payable", type: "receive" }
|
|
524
|
-
]
|
|
529
|
+
];
|
|
530
|
+
|
|
531
|
+
// src/aggregator/contracts/ethGeneric.ts
|
|
532
|
+
var ethGeneric = [
|
|
525
533
|
{
|
|
526
534
|
inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
|
|
527
535
|
stateMutability: "nonpayable",
|
|
528
536
|
type: "constructor"
|
|
529
537
|
},
|
|
530
538
|
{
|
|
531
|
-
anonymous:
|
|
539
|
+
anonymous: false,
|
|
532
540
|
inputs: [
|
|
533
|
-
{ indexed:
|
|
534
|
-
{ indexed:
|
|
541
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
542
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
535
543
|
],
|
|
536
544
|
name: "FeeSet",
|
|
537
545
|
type: "event"
|
|
538
546
|
},
|
|
539
547
|
{
|
|
540
|
-
anonymous:
|
|
548
|
+
anonymous: false,
|
|
541
549
|
inputs: [
|
|
542
|
-
{ indexed:
|
|
543
|
-
{ indexed:
|
|
550
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
551
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
544
552
|
],
|
|
545
553
|
name: "OwnerSet",
|
|
546
554
|
type: "event"
|
|
@@ -612,7 +620,10 @@ const Ae = [
|
|
|
612
620
|
type: "function"
|
|
613
621
|
},
|
|
614
622
|
{ stateMutability: "payable", type: "receive" }
|
|
615
|
-
]
|
|
623
|
+
];
|
|
624
|
+
|
|
625
|
+
// src/aggregator/contracts/pancakeV2.ts
|
|
626
|
+
var pancakeV2 = [
|
|
616
627
|
{
|
|
617
628
|
inputs: [
|
|
618
629
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -623,44 +634,44 @@ const Ae = [
|
|
|
623
634
|
type: "constructor"
|
|
624
635
|
},
|
|
625
636
|
{
|
|
626
|
-
anonymous:
|
|
637
|
+
anonymous: false,
|
|
627
638
|
inputs: [
|
|
628
|
-
{ indexed:
|
|
629
|
-
{ indexed:
|
|
639
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
640
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
630
641
|
],
|
|
631
642
|
name: "FeeSet",
|
|
632
643
|
type: "event"
|
|
633
644
|
},
|
|
634
645
|
{
|
|
635
|
-
anonymous:
|
|
646
|
+
anonymous: false,
|
|
636
647
|
inputs: [
|
|
637
|
-
{ indexed:
|
|
638
|
-
{ indexed:
|
|
648
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
649
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
639
650
|
],
|
|
640
651
|
name: "OwnerSet",
|
|
641
652
|
type: "event"
|
|
642
653
|
},
|
|
643
654
|
{
|
|
644
|
-
anonymous:
|
|
655
|
+
anonymous: false,
|
|
645
656
|
inputs: [
|
|
646
|
-
{ indexed:
|
|
647
|
-
{ indexed:
|
|
648
|
-
{ indexed:
|
|
649
|
-
{ indexed:
|
|
650
|
-
{ indexed:
|
|
651
|
-
{ indexed:
|
|
652
|
-
{ indexed:
|
|
657
|
+
{ indexed: false, internalType: "address", name: "from", type: "address" },
|
|
658
|
+
{ indexed: false, internalType: "address", name: "token", type: "address" },
|
|
659
|
+
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
|
|
660
|
+
{ indexed: false, internalType: "uint256", name: "out", type: "uint256" },
|
|
661
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
662
|
+
{ indexed: false, internalType: "address", name: "vault", type: "address" },
|
|
663
|
+
{ indexed: false, internalType: "string", name: "memo", type: "string" }
|
|
653
664
|
],
|
|
654
665
|
name: "SwapIn",
|
|
655
666
|
type: "event"
|
|
656
667
|
},
|
|
657
668
|
{
|
|
658
|
-
anonymous:
|
|
669
|
+
anonymous: false,
|
|
659
670
|
inputs: [
|
|
660
|
-
{ indexed:
|
|
661
|
-
{ indexed:
|
|
662
|
-
{ indexed:
|
|
663
|
-
{ indexed:
|
|
671
|
+
{ indexed: false, internalType: "address", name: "to", type: "address" },
|
|
672
|
+
{ indexed: false, internalType: "address", name: "token", type: "address" },
|
|
673
|
+
{ indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
|
|
674
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" }
|
|
664
675
|
],
|
|
665
676
|
name: "SwapOut",
|
|
666
677
|
type: "event"
|
|
@@ -756,7 +767,10 @@ const Ae = [
|
|
|
756
767
|
type: "function"
|
|
757
768
|
},
|
|
758
769
|
{ stateMutability: "payable", type: "receive" }
|
|
759
|
-
]
|
|
770
|
+
];
|
|
771
|
+
|
|
772
|
+
// src/aggregator/contracts/pangolin.ts
|
|
773
|
+
var pangolin = [
|
|
760
774
|
{
|
|
761
775
|
inputs: [
|
|
762
776
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -767,19 +781,19 @@ const Ae = [
|
|
|
767
781
|
type: "constructor"
|
|
768
782
|
},
|
|
769
783
|
{
|
|
770
|
-
anonymous:
|
|
784
|
+
anonymous: false,
|
|
771
785
|
inputs: [
|
|
772
|
-
{ indexed:
|
|
773
|
-
{ indexed:
|
|
786
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
787
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
774
788
|
],
|
|
775
789
|
name: "FeeSet",
|
|
776
790
|
type: "event"
|
|
777
791
|
},
|
|
778
792
|
{
|
|
779
|
-
anonymous:
|
|
793
|
+
anonymous: false,
|
|
780
794
|
inputs: [
|
|
781
|
-
{ indexed:
|
|
782
|
-
{ indexed:
|
|
795
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
796
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
783
797
|
],
|
|
784
798
|
name: "OwnerSet",
|
|
785
799
|
type: "event"
|
|
@@ -875,17 +889,20 @@ const Ae = [
|
|
|
875
889
|
type: "function"
|
|
876
890
|
},
|
|
877
891
|
{ stateMutability: "payable", type: "receive" }
|
|
878
|
-
]
|
|
892
|
+
];
|
|
893
|
+
|
|
894
|
+
// src/aggregator/contracts/routers/kyber.ts
|
|
895
|
+
var kyberRouter = [
|
|
879
896
|
{
|
|
880
897
|
inputs: [{ internalType: "address", name: "_WETH", type: "address" }],
|
|
881
898
|
stateMutability: "nonpayable",
|
|
882
899
|
type: "constructor"
|
|
883
900
|
},
|
|
884
901
|
{
|
|
885
|
-
anonymous:
|
|
902
|
+
anonymous: false,
|
|
886
903
|
inputs: [
|
|
887
904
|
{
|
|
888
|
-
indexed:
|
|
905
|
+
indexed: false,
|
|
889
906
|
internalType: "bytes",
|
|
890
907
|
name: "clientData",
|
|
891
908
|
type: "bytes"
|
|
@@ -895,10 +912,10 @@ const Ae = [
|
|
|
895
912
|
type: "event"
|
|
896
913
|
},
|
|
897
914
|
{
|
|
898
|
-
anonymous:
|
|
915
|
+
anonymous: false,
|
|
899
916
|
inputs: [
|
|
900
917
|
{
|
|
901
|
-
indexed:
|
|
918
|
+
indexed: false,
|
|
902
919
|
internalType: "string",
|
|
903
920
|
name: "reason",
|
|
904
921
|
type: "string"
|
|
@@ -908,22 +925,22 @@ const Ae = [
|
|
|
908
925
|
type: "event"
|
|
909
926
|
},
|
|
910
927
|
{
|
|
911
|
-
anonymous:
|
|
928
|
+
anonymous: false,
|
|
912
929
|
inputs: [
|
|
913
930
|
{
|
|
914
|
-
indexed:
|
|
931
|
+
indexed: false,
|
|
915
932
|
internalType: "address",
|
|
916
933
|
name: "pair",
|
|
917
934
|
type: "address"
|
|
918
935
|
},
|
|
919
936
|
{
|
|
920
|
-
indexed:
|
|
937
|
+
indexed: false,
|
|
921
938
|
internalType: "uint256",
|
|
922
939
|
name: "amountOut",
|
|
923
940
|
type: "uint256"
|
|
924
941
|
},
|
|
925
942
|
{
|
|
926
|
-
indexed:
|
|
943
|
+
indexed: false,
|
|
927
944
|
internalType: "address",
|
|
928
945
|
name: "output",
|
|
929
946
|
type: "address"
|
|
@@ -933,54 +950,54 @@ const Ae = [
|
|
|
933
950
|
type: "event"
|
|
934
951
|
},
|
|
935
952
|
{
|
|
936
|
-
anonymous:
|
|
953
|
+
anonymous: false,
|
|
937
954
|
inputs: [
|
|
938
955
|
{
|
|
939
|
-
indexed:
|
|
956
|
+
indexed: false,
|
|
940
957
|
internalType: "address",
|
|
941
958
|
name: "token",
|
|
942
959
|
type: "address"
|
|
943
960
|
},
|
|
944
961
|
{
|
|
945
|
-
indexed:
|
|
962
|
+
indexed: false,
|
|
946
963
|
internalType: "uint256",
|
|
947
964
|
name: "totalAmount",
|
|
948
965
|
type: "uint256"
|
|
949
966
|
},
|
|
950
967
|
{
|
|
951
|
-
indexed:
|
|
968
|
+
indexed: false,
|
|
952
969
|
internalType: "uint256",
|
|
953
970
|
name: "totalFee",
|
|
954
971
|
type: "uint256"
|
|
955
972
|
},
|
|
956
973
|
{
|
|
957
|
-
indexed:
|
|
974
|
+
indexed: false,
|
|
958
975
|
internalType: "address[]",
|
|
959
976
|
name: "recipients",
|
|
960
977
|
type: "address[]"
|
|
961
978
|
},
|
|
962
979
|
{
|
|
963
|
-
indexed:
|
|
980
|
+
indexed: false,
|
|
964
981
|
internalType: "uint256[]",
|
|
965
982
|
name: "amounts",
|
|
966
983
|
type: "uint256[]"
|
|
967
984
|
},
|
|
968
|
-
{ indexed:
|
|
985
|
+
{ indexed: false, internalType: "bool", name: "isBps", type: "bool" }
|
|
969
986
|
],
|
|
970
987
|
name: "Fee",
|
|
971
988
|
type: "event"
|
|
972
989
|
},
|
|
973
990
|
{
|
|
974
|
-
anonymous:
|
|
991
|
+
anonymous: false,
|
|
975
992
|
inputs: [
|
|
976
993
|
{
|
|
977
|
-
indexed:
|
|
994
|
+
indexed: true,
|
|
978
995
|
internalType: "address",
|
|
979
996
|
name: "previousOwner",
|
|
980
997
|
type: "address"
|
|
981
998
|
},
|
|
982
999
|
{
|
|
983
|
-
indexed:
|
|
1000
|
+
indexed: true,
|
|
984
1001
|
internalType: "address",
|
|
985
1002
|
name: "newOwner",
|
|
986
1003
|
type: "address"
|
|
@@ -990,40 +1007,40 @@ const Ae = [
|
|
|
990
1007
|
type: "event"
|
|
991
1008
|
},
|
|
992
1009
|
{
|
|
993
|
-
anonymous:
|
|
1010
|
+
anonymous: false,
|
|
994
1011
|
inputs: [
|
|
995
1012
|
{
|
|
996
|
-
indexed:
|
|
1013
|
+
indexed: false,
|
|
997
1014
|
internalType: "address",
|
|
998
1015
|
name: "sender",
|
|
999
1016
|
type: "address"
|
|
1000
1017
|
},
|
|
1001
1018
|
{
|
|
1002
|
-
indexed:
|
|
1019
|
+
indexed: false,
|
|
1003
1020
|
internalType: "contract IERC20",
|
|
1004
1021
|
name: "srcToken",
|
|
1005
1022
|
type: "address"
|
|
1006
1023
|
},
|
|
1007
1024
|
{
|
|
1008
|
-
indexed:
|
|
1025
|
+
indexed: false,
|
|
1009
1026
|
internalType: "contract IERC20",
|
|
1010
1027
|
name: "dstToken",
|
|
1011
1028
|
type: "address"
|
|
1012
1029
|
},
|
|
1013
1030
|
{
|
|
1014
|
-
indexed:
|
|
1031
|
+
indexed: false,
|
|
1015
1032
|
internalType: "address",
|
|
1016
1033
|
name: "dstReceiver",
|
|
1017
1034
|
type: "address"
|
|
1018
1035
|
},
|
|
1019
1036
|
{
|
|
1020
|
-
indexed:
|
|
1037
|
+
indexed: false,
|
|
1021
1038
|
internalType: "uint256",
|
|
1022
1039
|
name: "spentAmount",
|
|
1023
1040
|
type: "uint256"
|
|
1024
1041
|
},
|
|
1025
1042
|
{
|
|
1026
|
-
indexed:
|
|
1043
|
+
indexed: false,
|
|
1027
1044
|
internalType: "uint256",
|
|
1028
1045
|
name: "returnAmount",
|
|
1029
1046
|
type: "uint256"
|
|
@@ -1276,7 +1293,10 @@ const Ae = [
|
|
|
1276
1293
|
type: "function"
|
|
1277
1294
|
},
|
|
1278
1295
|
{ stateMutability: "payable", type: "receive" }
|
|
1279
|
-
]
|
|
1296
|
+
];
|
|
1297
|
+
|
|
1298
|
+
// src/aggregator/contracts/routers/oneinch.ts
|
|
1299
|
+
var oneInchRouter = [
|
|
1280
1300
|
{
|
|
1281
1301
|
inputs: [
|
|
1282
1302
|
{
|
|
@@ -1545,16 +1565,16 @@ const Ae = [
|
|
|
1545
1565
|
type: "error"
|
|
1546
1566
|
},
|
|
1547
1567
|
{
|
|
1548
|
-
anonymous:
|
|
1568
|
+
anonymous: false,
|
|
1549
1569
|
inputs: [
|
|
1550
1570
|
{
|
|
1551
|
-
indexed:
|
|
1571
|
+
indexed: true,
|
|
1552
1572
|
internalType: "address",
|
|
1553
1573
|
name: "maker",
|
|
1554
1574
|
type: "address"
|
|
1555
1575
|
},
|
|
1556
1576
|
{
|
|
1557
|
-
indexed:
|
|
1577
|
+
indexed: false,
|
|
1558
1578
|
internalType: "uint256",
|
|
1559
1579
|
name: "newNonce",
|
|
1560
1580
|
type: "uint256"
|
|
@@ -1564,22 +1584,22 @@ const Ae = [
|
|
|
1564
1584
|
type: "event"
|
|
1565
1585
|
},
|
|
1566
1586
|
{
|
|
1567
|
-
anonymous:
|
|
1587
|
+
anonymous: false,
|
|
1568
1588
|
inputs: [
|
|
1569
1589
|
{
|
|
1570
|
-
indexed:
|
|
1590
|
+
indexed: true,
|
|
1571
1591
|
internalType: "address",
|
|
1572
1592
|
name: "maker",
|
|
1573
1593
|
type: "address"
|
|
1574
1594
|
},
|
|
1575
1595
|
{
|
|
1576
|
-
indexed:
|
|
1596
|
+
indexed: false,
|
|
1577
1597
|
internalType: "bytes32",
|
|
1578
1598
|
name: "orderHash",
|
|
1579
1599
|
type: "bytes32"
|
|
1580
1600
|
},
|
|
1581
1601
|
{
|
|
1582
|
-
indexed:
|
|
1602
|
+
indexed: false,
|
|
1583
1603
|
internalType: "uint256",
|
|
1584
1604
|
name: "remainingRaw",
|
|
1585
1605
|
type: "uint256"
|
|
@@ -1589,22 +1609,22 @@ const Ae = [
|
|
|
1589
1609
|
type: "event"
|
|
1590
1610
|
},
|
|
1591
1611
|
{
|
|
1592
|
-
anonymous:
|
|
1612
|
+
anonymous: false,
|
|
1593
1613
|
inputs: [
|
|
1594
1614
|
{
|
|
1595
|
-
indexed:
|
|
1615
|
+
indexed: true,
|
|
1596
1616
|
internalType: "address",
|
|
1597
1617
|
name: "maker",
|
|
1598
1618
|
type: "address"
|
|
1599
1619
|
},
|
|
1600
1620
|
{
|
|
1601
|
-
indexed:
|
|
1621
|
+
indexed: false,
|
|
1602
1622
|
internalType: "bytes32",
|
|
1603
1623
|
name: "orderHash",
|
|
1604
1624
|
type: "bytes32"
|
|
1605
1625
|
},
|
|
1606
1626
|
{
|
|
1607
|
-
indexed:
|
|
1627
|
+
indexed: false,
|
|
1608
1628
|
internalType: "uint256",
|
|
1609
1629
|
name: "remaining",
|
|
1610
1630
|
type: "uint256"
|
|
@@ -1614,16 +1634,16 @@ const Ae = [
|
|
|
1614
1634
|
type: "event"
|
|
1615
1635
|
},
|
|
1616
1636
|
{
|
|
1617
|
-
anonymous:
|
|
1637
|
+
anonymous: false,
|
|
1618
1638
|
inputs: [
|
|
1619
1639
|
{
|
|
1620
|
-
indexed:
|
|
1640
|
+
indexed: false,
|
|
1621
1641
|
internalType: "bytes32",
|
|
1622
1642
|
name: "orderHash",
|
|
1623
1643
|
type: "bytes32"
|
|
1624
1644
|
},
|
|
1625
1645
|
{
|
|
1626
|
-
indexed:
|
|
1646
|
+
indexed: false,
|
|
1627
1647
|
internalType: "uint256",
|
|
1628
1648
|
name: "makingAmount",
|
|
1629
1649
|
type: "uint256"
|
|
@@ -1633,16 +1653,16 @@ const Ae = [
|
|
|
1633
1653
|
type: "event"
|
|
1634
1654
|
},
|
|
1635
1655
|
{
|
|
1636
|
-
anonymous:
|
|
1656
|
+
anonymous: false,
|
|
1637
1657
|
inputs: [
|
|
1638
1658
|
{
|
|
1639
|
-
indexed:
|
|
1659
|
+
indexed: true,
|
|
1640
1660
|
internalType: "address",
|
|
1641
1661
|
name: "previousOwner",
|
|
1642
1662
|
type: "address"
|
|
1643
1663
|
},
|
|
1644
1664
|
{
|
|
1645
|
-
indexed:
|
|
1665
|
+
indexed: true,
|
|
1646
1666
|
internalType: "address",
|
|
1647
1667
|
name: "newOwner",
|
|
1648
1668
|
type: "address"
|
|
@@ -3463,7 +3483,10 @@ const Ae = [
|
|
|
3463
3483
|
stateMutability: "payable",
|
|
3464
3484
|
type: "receive"
|
|
3465
3485
|
}
|
|
3466
|
-
]
|
|
3486
|
+
];
|
|
3487
|
+
|
|
3488
|
+
// src/aggregator/contracts/routers/pancakeswap.ts
|
|
3489
|
+
var pancakeSwapRouter = [
|
|
3467
3490
|
{
|
|
3468
3491
|
inputs: [
|
|
3469
3492
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -3802,7 +3825,10 @@ const Ae = [
|
|
|
3802
3825
|
type: "function"
|
|
3803
3826
|
},
|
|
3804
3827
|
{ stateMutability: "payable", type: "receive" }
|
|
3805
|
-
]
|
|
3828
|
+
];
|
|
3829
|
+
|
|
3830
|
+
// src/aggregator/contracts/routers/pangolin.ts
|
|
3831
|
+
var pangolinRouter = [
|
|
3806
3832
|
{
|
|
3807
3833
|
inputs: [
|
|
3808
3834
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -4141,7 +4167,10 @@ const Ae = [
|
|
|
4141
4167
|
type: "function"
|
|
4142
4168
|
},
|
|
4143
4169
|
{ stateMutability: "payable", type: "receive" }
|
|
4144
|
-
]
|
|
4170
|
+
];
|
|
4171
|
+
|
|
4172
|
+
// src/aggregator/contracts/routers/sushiswap.ts
|
|
4173
|
+
var sushiswapRouter = [
|
|
4145
4174
|
{
|
|
4146
4175
|
inputs: [
|
|
4147
4176
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -4480,7 +4509,10 @@ const Ae = [
|
|
|
4480
4509
|
type: "function"
|
|
4481
4510
|
},
|
|
4482
4511
|
{ stateMutability: "payable", type: "receive" }
|
|
4483
|
-
]
|
|
4512
|
+
];
|
|
4513
|
+
|
|
4514
|
+
// src/aggregator/contracts/routers/traderJoe.ts
|
|
4515
|
+
var traderJoeRouter = [
|
|
4484
4516
|
{
|
|
4485
4517
|
inputs: [
|
|
4486
4518
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -4819,7 +4851,10 @@ const Ae = [
|
|
|
4819
4851
|
type: "function"
|
|
4820
4852
|
},
|
|
4821
4853
|
{ stateMutability: "payable", type: "receive" }
|
|
4822
|
-
]
|
|
4854
|
+
];
|
|
4855
|
+
|
|
4856
|
+
// src/aggregator/contracts/routers/uniswapv2.ts
|
|
4857
|
+
var uniswapv2Router = [
|
|
4823
4858
|
{
|
|
4824
4859
|
inputs: [
|
|
4825
4860
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -5158,7 +5193,10 @@ const Ae = [
|
|
|
5158
5193
|
type: "function"
|
|
5159
5194
|
},
|
|
5160
5195
|
{ stateMutability: "payable", type: "receive" }
|
|
5161
|
-
]
|
|
5196
|
+
];
|
|
5197
|
+
|
|
5198
|
+
// src/aggregator/contracts/routers/uniswapv3.ts
|
|
5199
|
+
var uniswapv3Router = [
|
|
5162
5200
|
{
|
|
5163
5201
|
inputs: [
|
|
5164
5202
|
{ internalType: "address", name: "_factory", type: "address" },
|
|
@@ -5411,7 +5449,10 @@ const Ae = [
|
|
|
5411
5449
|
type: "function"
|
|
5412
5450
|
},
|
|
5413
5451
|
{ stateMutability: "payable", type: "receive" }
|
|
5414
|
-
]
|
|
5452
|
+
];
|
|
5453
|
+
|
|
5454
|
+
// src/aggregator/contracts/routers/woofi.ts
|
|
5455
|
+
var woofiRouter = [
|
|
5415
5456
|
{
|
|
5416
5457
|
inputs: [
|
|
5417
5458
|
{ internalType: "address", name: "_weth", type: "address" },
|
|
@@ -5421,36 +5462,36 @@ const Ae = [
|
|
|
5421
5462
|
type: "constructor"
|
|
5422
5463
|
},
|
|
5423
5464
|
{
|
|
5424
|
-
anonymous:
|
|
5465
|
+
anonymous: false,
|
|
5425
5466
|
inputs: [
|
|
5426
|
-
{ indexed:
|
|
5427
|
-
{ indexed:
|
|
5467
|
+
{ indexed: true, internalType: "address", name: "previousOwner", type: "address" },
|
|
5468
|
+
{ indexed: true, internalType: "address", name: "newOwner", type: "address" }
|
|
5428
5469
|
],
|
|
5429
5470
|
name: "OwnershipTransferred",
|
|
5430
5471
|
type: "event"
|
|
5431
5472
|
},
|
|
5432
5473
|
{
|
|
5433
|
-
anonymous:
|
|
5434
|
-
inputs: [{ indexed:
|
|
5474
|
+
anonymous: false,
|
|
5475
|
+
inputs: [{ indexed: false, internalType: "address", name: "newPool", type: "address" }],
|
|
5435
5476
|
name: "WooPoolChanged",
|
|
5436
5477
|
type: "event"
|
|
5437
5478
|
},
|
|
5438
5479
|
{
|
|
5439
|
-
anonymous:
|
|
5480
|
+
anonymous: false,
|
|
5440
5481
|
inputs: [
|
|
5441
5482
|
{
|
|
5442
|
-
indexed:
|
|
5483
|
+
indexed: false,
|
|
5443
5484
|
internalType: "enum IWooRouterV2.SwapType",
|
|
5444
5485
|
name: "swapType",
|
|
5445
5486
|
type: "uint8"
|
|
5446
5487
|
},
|
|
5447
|
-
{ indexed:
|
|
5448
|
-
{ indexed:
|
|
5449
|
-
{ indexed:
|
|
5450
|
-
{ indexed:
|
|
5451
|
-
{ indexed:
|
|
5452
|
-
{ indexed:
|
|
5453
|
-
{ indexed:
|
|
5488
|
+
{ indexed: true, internalType: "address", name: "fromToken", type: "address" },
|
|
5489
|
+
{ indexed: true, internalType: "address", name: "toToken", type: "address" },
|
|
5490
|
+
{ indexed: false, internalType: "uint256", name: "fromAmount", type: "uint256" },
|
|
5491
|
+
{ indexed: false, internalType: "uint256", name: "toAmount", type: "uint256" },
|
|
5492
|
+
{ indexed: false, internalType: "address", name: "from", type: "address" },
|
|
5493
|
+
{ indexed: true, internalType: "address", name: "to", type: "address" },
|
|
5494
|
+
{ indexed: false, internalType: "address", name: "rebateTo", type: "address" }
|
|
5454
5495
|
],
|
|
5455
5496
|
name: "WooRouterSwap",
|
|
5456
5497
|
type: "event"
|
|
@@ -5581,23 +5622,41 @@ const Ae = [
|
|
|
5581
5622
|
type: "function"
|
|
5582
5623
|
},
|
|
5583
5624
|
{ stateMutability: "payable", type: "receive" }
|
|
5584
|
-
]
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
["
|
|
5590
|
-
["
|
|
5591
|
-
|
|
5592
|
-
["
|
|
5593
|
-
|
|
5594
|
-
["
|
|
5595
|
-
["
|
|
5596
|
-
["
|
|
5597
|
-
["
|
|
5598
|
-
["
|
|
5599
|
-
["
|
|
5600
|
-
|
|
5625
|
+
];
|
|
5626
|
+
|
|
5627
|
+
// src/aggregator/contracts/routers/index.ts
|
|
5628
|
+
var DEX_CONTRACT_ADDRESS;
|
|
5629
|
+
(function(DEX_CONTRACT_ADDRESS2) {
|
|
5630
|
+
DEX_CONTRACT_ADDRESS2["TRADERJOE"] = "0x60aE616a2155Ee3d9A68541Ba4544862310933d4";
|
|
5631
|
+
DEX_CONTRACT_ADDRESS2["PANGOLIN"] = "0xE54Ca86531e17Ef3616d22Ca28b0D458b6C89106";
|
|
5632
|
+
DEX_CONTRACT_ADDRESS2["WOOFI"] = "0xC22FBb3133dF781E6C25ea6acebe2D2Bb8CeA2f9";
|
|
5633
|
+
DEX_CONTRACT_ADDRESS2["ONEINCH_AVAX"] = "0x1111111254fb6c44bAC0beD2854e76F90643097d";
|
|
5634
|
+
DEX_CONTRACT_ADDRESS2["KYBER_AVAX"] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5";
|
|
5635
|
+
DEX_CONTRACT_ADDRESS2["PANCAKESWAP_BSC"] = "0x10ED43C718714eb63d5aA57B78B54704E256024E";
|
|
5636
|
+
DEX_CONTRACT_ADDRESS2["ONEINCH_ETH"] = "0x1111111254fb6c44bac0bed2854e76f90643097d";
|
|
5637
|
+
DEX_CONTRACT_ADDRESS2["PANCAKESWAP_ETH"] = "0xEfF92A263d31888d860bD50809A8D171709b7b1c";
|
|
5638
|
+
DEX_CONTRACT_ADDRESS2["KYBER_ETH"] = "0x6131B5fae19EA4f9D964eAc0408E4408b66337b5";
|
|
5639
|
+
DEX_CONTRACT_ADDRESS2["SUSHISWAP"] = "0xd9e1ce17f2641f24ae83637ab66a2cca9c378b9f";
|
|
5640
|
+
DEX_CONTRACT_ADDRESS2["UNISWAP_V2"] = "0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D";
|
|
5641
|
+
DEX_CONTRACT_ADDRESS2["UNISWAP_V3"] = "0xE592427A0AEce92De3Edee1F18E0157C05861564";
|
|
5642
|
+
})(DEX_CONTRACT_ADDRESS || (DEX_CONTRACT_ADDRESS = {}));
|
|
5643
|
+
var lowercasedRouterAbiMapping = {
|
|
5644
|
+
[DEX_CONTRACT_ADDRESS.PANGOLIN.toLowerCase()]: pangolinRouter,
|
|
5645
|
+
[DEX_CONTRACT_ADDRESS.WOOFI.toLowerCase()]: woofiRouter,
|
|
5646
|
+
[DEX_CONTRACT_ADDRESS.TRADERJOE.toLowerCase()]: traderJoeRouter,
|
|
5647
|
+
[DEX_CONTRACT_ADDRESS.ONEINCH_AVAX.toLowerCase()]: oneInchRouter,
|
|
5648
|
+
[DEX_CONTRACT_ADDRESS.KYBER_AVAX.toLowerCase()]: kyberRouter,
|
|
5649
|
+
[DEX_CONTRACT_ADDRESS.PANCAKESWAP_BSC.toLowerCase()]: pancakeSwapRouter,
|
|
5650
|
+
[DEX_CONTRACT_ADDRESS.KYBER_ETH.toLowerCase()]: kyberRouter,
|
|
5651
|
+
[DEX_CONTRACT_ADDRESS.SUSHISWAP.toLowerCase()]: sushiswapRouter,
|
|
5652
|
+
[DEX_CONTRACT_ADDRESS.PANCAKESWAP_ETH.toLowerCase()]: pancakeSwapRouter,
|
|
5653
|
+
[DEX_CONTRACT_ADDRESS.UNISWAP_V2.toLowerCase()]: uniswapv2Router,
|
|
5654
|
+
[DEX_CONTRACT_ADDRESS.UNISWAP_V3.toLowerCase()]: uniswapv3Router,
|
|
5655
|
+
[DEX_CONTRACT_ADDRESS.ONEINCH_ETH.toLowerCase()]: oneInchRouter
|
|
5656
|
+
};
|
|
5657
|
+
|
|
5658
|
+
// src/aggregator/contracts/sushiswap.ts
|
|
5659
|
+
var sushiswap2 = [
|
|
5601
5660
|
{
|
|
5602
5661
|
inputs: [
|
|
5603
5662
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -5608,19 +5667,19 @@ const Ae = [
|
|
|
5608
5667
|
type: "constructor"
|
|
5609
5668
|
},
|
|
5610
5669
|
{
|
|
5611
|
-
anonymous:
|
|
5670
|
+
anonymous: false,
|
|
5612
5671
|
inputs: [
|
|
5613
|
-
{ indexed:
|
|
5614
|
-
{ indexed:
|
|
5672
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
5673
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
5615
5674
|
],
|
|
5616
5675
|
name: "FeeSet",
|
|
5617
5676
|
type: "event"
|
|
5618
5677
|
},
|
|
5619
5678
|
{
|
|
5620
|
-
anonymous:
|
|
5679
|
+
anonymous: false,
|
|
5621
5680
|
inputs: [
|
|
5622
|
-
{ indexed:
|
|
5623
|
-
{ indexed:
|
|
5681
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
5682
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
5624
5683
|
],
|
|
5625
5684
|
name: "OwnerSet",
|
|
5626
5685
|
type: "event"
|
|
@@ -5716,7 +5775,10 @@ const Ae = [
|
|
|
5716
5775
|
type: "function"
|
|
5717
5776
|
},
|
|
5718
5777
|
{ stateMutability: "payable", type: "receive" }
|
|
5719
|
-
]
|
|
5778
|
+
];
|
|
5779
|
+
|
|
5780
|
+
// src/aggregator/contracts/traderJoe.ts
|
|
5781
|
+
var traderJoe2 = [
|
|
5720
5782
|
{
|
|
5721
5783
|
inputs: [
|
|
5722
5784
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -5727,19 +5789,19 @@ const Ae = [
|
|
|
5727
5789
|
type: "constructor"
|
|
5728
5790
|
},
|
|
5729
5791
|
{
|
|
5730
|
-
anonymous:
|
|
5792
|
+
anonymous: false,
|
|
5731
5793
|
inputs: [
|
|
5732
|
-
{ indexed:
|
|
5733
|
-
{ indexed:
|
|
5794
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
5795
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
5734
5796
|
],
|
|
5735
5797
|
name: "FeeSet",
|
|
5736
5798
|
type: "event"
|
|
5737
5799
|
},
|
|
5738
5800
|
{
|
|
5739
|
-
anonymous:
|
|
5801
|
+
anonymous: false,
|
|
5740
5802
|
inputs: [
|
|
5741
|
-
{ indexed:
|
|
5742
|
-
{ indexed:
|
|
5803
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
5804
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
5743
5805
|
],
|
|
5744
5806
|
name: "OwnerSet",
|
|
5745
5807
|
type: "event"
|
|
@@ -5835,7 +5897,10 @@ const Ae = [
|
|
|
5835
5897
|
type: "function"
|
|
5836
5898
|
},
|
|
5837
5899
|
{ stateMutability: "payable", type: "receive" }
|
|
5838
|
-
]
|
|
5900
|
+
];
|
|
5901
|
+
|
|
5902
|
+
// src/aggregator/contracts/uniswapV2.ts
|
|
5903
|
+
var uniswapV2 = [
|
|
5839
5904
|
{
|
|
5840
5905
|
inputs: [
|
|
5841
5906
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -5846,19 +5911,19 @@ const Ae = [
|
|
|
5846
5911
|
type: "constructor"
|
|
5847
5912
|
},
|
|
5848
5913
|
{
|
|
5849
|
-
anonymous:
|
|
5914
|
+
anonymous: false,
|
|
5850
5915
|
inputs: [
|
|
5851
|
-
{ indexed:
|
|
5852
|
-
{ indexed:
|
|
5916
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
5917
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
5853
5918
|
],
|
|
5854
5919
|
name: "FeeSet",
|
|
5855
5920
|
type: "event"
|
|
5856
5921
|
},
|
|
5857
5922
|
{
|
|
5858
|
-
anonymous:
|
|
5923
|
+
anonymous: false,
|
|
5859
5924
|
inputs: [
|
|
5860
|
-
{ indexed:
|
|
5861
|
-
{ indexed:
|
|
5925
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
5926
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
5862
5927
|
],
|
|
5863
5928
|
name: "OwnerSet",
|
|
5864
5929
|
type: "event"
|
|
@@ -5954,7 +6019,10 @@ const Ae = [
|
|
|
5954
6019
|
type: "function"
|
|
5955
6020
|
},
|
|
5956
6021
|
{ stateMutability: "payable", type: "receive" }
|
|
5957
|
-
]
|
|
6022
|
+
];
|
|
6023
|
+
|
|
6024
|
+
// src/aggregator/contracts/uniswapV2Leg.ts
|
|
6025
|
+
var uniswapV2Leg = [
|
|
5958
6026
|
{
|
|
5959
6027
|
inputs: [
|
|
5960
6028
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -5966,19 +6034,19 @@ const Ae = [
|
|
|
5966
6034
|
type: "constructor"
|
|
5967
6035
|
},
|
|
5968
6036
|
{
|
|
5969
|
-
anonymous:
|
|
6037
|
+
anonymous: false,
|
|
5970
6038
|
inputs: [
|
|
5971
|
-
{ indexed:
|
|
5972
|
-
{ indexed:
|
|
6039
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
6040
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
5973
6041
|
],
|
|
5974
6042
|
name: "FeeSet",
|
|
5975
6043
|
type: "event"
|
|
5976
6044
|
},
|
|
5977
6045
|
{
|
|
5978
|
-
anonymous:
|
|
6046
|
+
anonymous: false,
|
|
5979
6047
|
inputs: [
|
|
5980
|
-
{ indexed:
|
|
5981
|
-
{ indexed:
|
|
6048
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
6049
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
5982
6050
|
],
|
|
5983
6051
|
name: "OwnerSet",
|
|
5984
6052
|
type: "event"
|
|
@@ -6081,7 +6149,10 @@ const Ae = [
|
|
|
6081
6149
|
type: "function"
|
|
6082
6150
|
},
|
|
6083
6151
|
{ stateMutability: "payable", type: "receive" }
|
|
6084
|
-
]
|
|
6152
|
+
];
|
|
6153
|
+
|
|
6154
|
+
// src/aggregator/contracts/uniswapV3_100.ts
|
|
6155
|
+
var uniswapV3_100 = [
|
|
6085
6156
|
{
|
|
6086
6157
|
inputs: [
|
|
6087
6158
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -6093,19 +6164,19 @@ const Ae = [
|
|
|
6093
6164
|
type: "constructor"
|
|
6094
6165
|
},
|
|
6095
6166
|
{
|
|
6096
|
-
anonymous:
|
|
6167
|
+
anonymous: false,
|
|
6097
6168
|
inputs: [
|
|
6098
|
-
{ indexed:
|
|
6099
|
-
{ indexed:
|
|
6169
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
6170
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
6100
6171
|
],
|
|
6101
6172
|
name: "FeeSet",
|
|
6102
6173
|
type: "event"
|
|
6103
6174
|
},
|
|
6104
6175
|
{
|
|
6105
|
-
anonymous:
|
|
6176
|
+
anonymous: false,
|
|
6106
6177
|
inputs: [
|
|
6107
|
-
{ indexed:
|
|
6108
|
-
{ indexed:
|
|
6178
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
6179
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
6109
6180
|
],
|
|
6110
6181
|
name: "OwnerSet",
|
|
6111
6182
|
type: "event"
|
|
@@ -6208,7 +6279,10 @@ const Ae = [
|
|
|
6208
6279
|
type: "function"
|
|
6209
6280
|
},
|
|
6210
6281
|
{ stateMutability: "payable", type: "receive" }
|
|
6211
|
-
]
|
|
6282
|
+
];
|
|
6283
|
+
|
|
6284
|
+
// src/aggregator/contracts/uniswapV3_500.ts
|
|
6285
|
+
var uniswapV3_500 = [
|
|
6212
6286
|
{
|
|
6213
6287
|
inputs: [
|
|
6214
6288
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -6220,19 +6294,19 @@ const Ae = [
|
|
|
6220
6294
|
type: "constructor"
|
|
6221
6295
|
},
|
|
6222
6296
|
{
|
|
6223
|
-
anonymous:
|
|
6297
|
+
anonymous: false,
|
|
6224
6298
|
inputs: [
|
|
6225
|
-
{ indexed:
|
|
6226
|
-
{ indexed:
|
|
6299
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
6300
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
6227
6301
|
],
|
|
6228
6302
|
name: "FeeSet",
|
|
6229
6303
|
type: "event"
|
|
6230
6304
|
},
|
|
6231
6305
|
{
|
|
6232
|
-
anonymous:
|
|
6306
|
+
anonymous: false,
|
|
6233
6307
|
inputs: [
|
|
6234
|
-
{ indexed:
|
|
6235
|
-
{ indexed:
|
|
6308
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
6309
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
6236
6310
|
],
|
|
6237
6311
|
name: "OwnerSet",
|
|
6238
6312
|
type: "event"
|
|
@@ -6335,7 +6409,10 @@ const Ae = [
|
|
|
6335
6409
|
type: "function"
|
|
6336
6410
|
},
|
|
6337
6411
|
{ stateMutability: "payable", type: "receive" }
|
|
6338
|
-
]
|
|
6412
|
+
];
|
|
6413
|
+
|
|
6414
|
+
// src/aggregator/contracts/uniswapV3_3000.ts
|
|
6415
|
+
var uniswapV3_3000 = [
|
|
6339
6416
|
{
|
|
6340
6417
|
inputs: [
|
|
6341
6418
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -6347,19 +6424,19 @@ const Ae = [
|
|
|
6347
6424
|
type: "constructor"
|
|
6348
6425
|
},
|
|
6349
6426
|
{
|
|
6350
|
-
anonymous:
|
|
6427
|
+
anonymous: false,
|
|
6351
6428
|
inputs: [
|
|
6352
|
-
{ indexed:
|
|
6353
|
-
{ indexed:
|
|
6429
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
6430
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
6354
6431
|
],
|
|
6355
6432
|
name: "FeeSet",
|
|
6356
6433
|
type: "event"
|
|
6357
6434
|
},
|
|
6358
6435
|
{
|
|
6359
|
-
anonymous:
|
|
6436
|
+
anonymous: false,
|
|
6360
6437
|
inputs: [
|
|
6361
|
-
{ indexed:
|
|
6362
|
-
{ indexed:
|
|
6438
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
6439
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
6363
6440
|
],
|
|
6364
6441
|
name: "OwnerSet",
|
|
6365
6442
|
type: "event"
|
|
@@ -6462,7 +6539,10 @@ const Ae = [
|
|
|
6462
6539
|
type: "function"
|
|
6463
6540
|
},
|
|
6464
6541
|
{ stateMutability: "payable", type: "receive" }
|
|
6465
|
-
]
|
|
6542
|
+
];
|
|
6543
|
+
|
|
6544
|
+
// src/aggregator/contracts/uniswapV3_10000.ts
|
|
6545
|
+
var uniswapV3_10000 = [
|
|
6466
6546
|
{
|
|
6467
6547
|
inputs: [
|
|
6468
6548
|
{ internalType: "address", name: "_ttp", type: "address" },
|
|
@@ -6474,19 +6554,19 @@ const Ae = [
|
|
|
6474
6554
|
type: "constructor"
|
|
6475
6555
|
},
|
|
6476
6556
|
{
|
|
6477
|
-
anonymous:
|
|
6557
|
+
anonymous: false,
|
|
6478
6558
|
inputs: [
|
|
6479
|
-
{ indexed:
|
|
6480
|
-
{ indexed:
|
|
6559
|
+
{ indexed: false, internalType: "uint256", name: "fee", type: "uint256" },
|
|
6560
|
+
{ indexed: false, internalType: "address", name: "feeRecipient", type: "address" }
|
|
6481
6561
|
],
|
|
6482
6562
|
name: "FeeSet",
|
|
6483
6563
|
type: "event"
|
|
6484
6564
|
},
|
|
6485
6565
|
{
|
|
6486
|
-
anonymous:
|
|
6566
|
+
anonymous: false,
|
|
6487
6567
|
inputs: [
|
|
6488
|
-
{ indexed:
|
|
6489
|
-
{ indexed:
|
|
6568
|
+
{ indexed: true, internalType: "address", name: "owner", type: "address" },
|
|
6569
|
+
{ indexed: false, internalType: "bool", name: "active", type: "bool" }
|
|
6490
6570
|
],
|
|
6491
6571
|
name: "OwnerSet",
|
|
6492
6572
|
type: "event"
|
|
@@ -6589,627 +6669,656 @@ const Ae = [
|
|
|
6589
6669
|
type: "function"
|
|
6590
6670
|
},
|
|
6591
6671
|
{ stateMutability: "payable", type: "receive" }
|
|
6592
|
-
]
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
["
|
|
6601
|
-
["
|
|
6602
|
-
["
|
|
6603
|
-
|
|
6604
|
-
["
|
|
6605
|
-
|
|
6606
|
-
["
|
|
6607
|
-
["
|
|
6608
|
-
["
|
|
6609
|
-
["
|
|
6610
|
-
["
|
|
6611
|
-
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
|
|
6617
|
-
|
|
6672
|
+
];
|
|
6673
|
+
|
|
6674
|
+
// src/aggregator/contracts/index.ts
|
|
6675
|
+
var AGG_CONTRACT_ADDRESS;
|
|
6676
|
+
(function(AGG_CONTRACT_ADDRESS2) {
|
|
6677
|
+
AGG_CONTRACT_ADDRESS2["PANGOLIN"] = "0x942c6dA485FD6cEf255853ef83a149d43A73F18a";
|
|
6678
|
+
AGG_CONTRACT_ADDRESS2["AVAX_GENERIC"] = "0x7C38b8B2efF28511ECc14a621e263857Fb5771d3";
|
|
6679
|
+
AGG_CONTRACT_ADDRESS2["AVAX_WOOFI"] = "0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a";
|
|
6680
|
+
AGG_CONTRACT_ADDRESS2["AVAX_TRADER_JOE"] = "0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212";
|
|
6681
|
+
AGG_CONTRACT_ADDRESS2["BSC_GENERIC"] = "0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c";
|
|
6682
|
+
AGG_CONTRACT_ADDRESS2["BSC_PANCAKE_V2"] = "0x30912B38618D3D37De3191A4FFE982C65a9aEC2E";
|
|
6683
|
+
AGG_CONTRACT_ADDRESS2["ETH_GENERIC"] = "0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2";
|
|
6684
|
+
AGG_CONTRACT_ADDRESS2["UNISWAP_V2"] = "0x86904Eb2b3c743400D03f929F2246EfA80B91215";
|
|
6685
|
+
AGG_CONTRACT_ADDRESS2["SUSHISWAP"] = "0xbf365e79aA44A2164DA135100C57FDB6635ae870";
|
|
6686
|
+
AGG_CONTRACT_ADDRESS2["UNISWAP_V3_100"] = "0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8";
|
|
6687
|
+
AGG_CONTRACT_ADDRESS2["UNISWAP_V3_500"] = "0xe4ddca21881bac219af7f217703db0475d2a9f02";
|
|
6688
|
+
AGG_CONTRACT_ADDRESS2["UNISWAP_V3_3000"] = "0x11733abf0cdb43298f7e949c930188451a9a9ef2";
|
|
6689
|
+
AGG_CONTRACT_ADDRESS2["UNISWAP_V3_10000"] = "0xb33874810e5395eb49d8bd7e912631db115d5a03";
|
|
6690
|
+
AGG_CONTRACT_ADDRESS2["UNISWAP_V2_LEG"] = "0x3660dE6C56cFD31998397652941ECe42118375DA";
|
|
6691
|
+
})(AGG_CONTRACT_ADDRESS || (AGG_CONTRACT_ADDRESS = {}));
|
|
6692
|
+
var lowercasedGenericAbiMappings = {
|
|
6693
|
+
[AGG_CONTRACT_ADDRESS.AVAX_GENERIC.toLowerCase()]: avaxGeneric,
|
|
6694
|
+
[AGG_CONTRACT_ADDRESS.BSC_GENERIC.toLowerCase()]: bscGeneric,
|
|
6695
|
+
[AGG_CONTRACT_ADDRESS.ETH_GENERIC.toLowerCase()]: ethGeneric
|
|
6696
|
+
};
|
|
6697
|
+
var lowercasedContractAbiMapping = {
|
|
6698
|
+
...lowercasedRouterAbiMapping,
|
|
6699
|
+
...lowercasedGenericAbiMappings,
|
|
6700
|
+
[AGG_CONTRACT_ADDRESS.PANGOLIN.toLowerCase()]: pangolin,
|
|
6701
|
+
[AGG_CONTRACT_ADDRESS.AVAX_WOOFI.toLowerCase()]: avaxWoofi,
|
|
6702
|
+
[AGG_CONTRACT_ADDRESS.AVAX_TRADER_JOE.toLowerCase()]: traderJoe2,
|
|
6703
|
+
[AGG_CONTRACT_ADDRESS.BSC_PANCAKE_V2.toLowerCase()]: pancakeV2,
|
|
6704
|
+
[AGG_CONTRACT_ADDRESS.SUSHISWAP.toLowerCase()]: sushiswap2,
|
|
6705
|
+
[AGG_CONTRACT_ADDRESS.UNISWAP_V2.toLowerCase()]: uniswapV2,
|
|
6706
|
+
[AGG_CONTRACT_ADDRESS.UNISWAP_V2_LEG.toLowerCase()]: uniswapV2Leg,
|
|
6707
|
+
[AGG_CONTRACT_ADDRESS.UNISWAP_V3_100.toLowerCase()]: uniswapV3_100,
|
|
6708
|
+
[AGG_CONTRACT_ADDRESS.UNISWAP_V3_500.toLowerCase()]: uniswapV3_500,
|
|
6709
|
+
[AGG_CONTRACT_ADDRESS.UNISWAP_V3_3000.toLowerCase()]: uniswapV3_3000,
|
|
6710
|
+
[AGG_CONTRACT_ADDRESS.UNISWAP_V3_10000.toLowerCase()]: uniswapV3_10000
|
|
6711
|
+
};
|
|
6712
|
+
|
|
6713
|
+
// src/aggregator/getSwapParams.ts
|
|
6714
|
+
var getSwapInParams = ({
|
|
6715
|
+
streamSwap,
|
|
6716
|
+
contractAddress,
|
|
6717
|
+
recipient,
|
|
6718
|
+
toChecksumAddress,
|
|
6618
6719
|
calldata: {
|
|
6619
|
-
amount
|
|
6620
|
-
amountOutMin
|
|
6621
|
-
data
|
|
6622
|
-
deadline
|
|
6623
|
-
memo
|
|
6624
|
-
router
|
|
6625
|
-
memoStreamingSwap
|
|
6626
|
-
tcMemo
|
|
6627
|
-
tcRouter
|
|
6628
|
-
tcVault
|
|
6629
|
-
vault
|
|
6630
|
-
token
|
|
6720
|
+
amount,
|
|
6721
|
+
amountOutMin = "",
|
|
6722
|
+
data = "",
|
|
6723
|
+
deadline,
|
|
6724
|
+
memo,
|
|
6725
|
+
router,
|
|
6726
|
+
memoStreamingSwap,
|
|
6727
|
+
tcMemo,
|
|
6728
|
+
tcRouter,
|
|
6729
|
+
tcVault,
|
|
6730
|
+
vault,
|
|
6731
|
+
token
|
|
6631
6732
|
}
|
|
6632
6733
|
}) => {
|
|
6633
|
-
const
|
|
6634
|
-
if (
|
|
6734
|
+
const isGeneric = !!lowercasedGenericAbiMappings[contractAddress.toLowerCase()];
|
|
6735
|
+
if (isGeneric && !router) {
|
|
6635
6736
|
throw new Error("Router is required on calldata for swapIn with GenericContract");
|
|
6636
|
-
|
|
6637
|
-
|
|
6737
|
+
}
|
|
6738
|
+
const baseMemo = tcMemo || memo;
|
|
6739
|
+
const transactionMemo = streamSwap ? memoStreamingSwap || baseMemo : baseMemo;
|
|
6740
|
+
if (!(tcVault || vault))
|
|
6638
6741
|
throw new Error("TC Vault is required on calldata");
|
|
6639
|
-
if (!(
|
|
6742
|
+
if (!(tcRouter || router))
|
|
6640
6743
|
throw new Error("TC Router is required on calldata");
|
|
6641
|
-
if (!
|
|
6744
|
+
if (!transactionMemo)
|
|
6642
6745
|
throw new Error("TC Memo is required on calldata");
|
|
6643
|
-
if (!
|
|
6746
|
+
if (!token)
|
|
6644
6747
|
throw new Error("Token is required on calldata");
|
|
6645
|
-
const
|
|
6646
|
-
|
|
6647
|
-
|
|
6648
|
-
|
|
6649
|
-
|
|
6650
|
-
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
return [...
|
|
6654
|
-
}
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
return
|
|
6660
|
-
},
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
(r, e) => (r[e] = null, r),
|
|
6665
|
-
{}
|
|
6666
|
-
), Qe = ({
|
|
6667
|
-
chain: r,
|
|
6668
|
-
address: e
|
|
6748
|
+
const baseParams = [
|
|
6749
|
+
toChecksumAddress(tcRouter || router),
|
|
6750
|
+
toChecksumAddress(tcVault || vault),
|
|
6751
|
+
transactionMemo.replace("{recipientAddress}", recipient),
|
|
6752
|
+
toChecksumAddress(token),
|
|
6753
|
+
amount
|
|
6754
|
+
];
|
|
6755
|
+
const contractParams = isGeneric ? [toChecksumAddress(router), data, deadline] : [amountOutMin, deadline];
|
|
6756
|
+
return [...baseParams, ...contractParams];
|
|
6757
|
+
};
|
|
6758
|
+
|
|
6759
|
+
// src/client/old.ts
|
|
6760
|
+
var getEmptyWalletStructure = () => Object.values(Chain3).reduce((acc, chain) => {
|
|
6761
|
+
acc[chain] = null;
|
|
6762
|
+
return acc;
|
|
6763
|
+
}, {});
|
|
6764
|
+
var validateAddressType = ({
|
|
6765
|
+
chain,
|
|
6766
|
+
address
|
|
6669
6767
|
}) => {
|
|
6670
|
-
if (!
|
|
6671
|
-
return
|
|
6672
|
-
switch (
|
|
6673
|
-
case
|
|
6674
|
-
return !
|
|
6768
|
+
if (!address)
|
|
6769
|
+
return false;
|
|
6770
|
+
switch (chain) {
|
|
6771
|
+
case Chain3.Bitcoin:
|
|
6772
|
+
return !address.startsWith("bc1p");
|
|
6675
6773
|
default:
|
|
6676
|
-
return
|
|
6774
|
+
return true;
|
|
6677
6775
|
}
|
|
6678
6776
|
};
|
|
6679
|
-
|
|
6680
|
-
class
|
|
6681
|
-
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6777
|
+
|
|
6778
|
+
class SwapKitCore {
|
|
6779
|
+
connectedChains = getEmptyWalletStructure();
|
|
6780
|
+
connectedWallets = getEmptyWalletStructure();
|
|
6781
|
+
stagenet = false;
|
|
6782
|
+
constructor({ stagenet } = {}) {
|
|
6783
|
+
this.stagenet = !!stagenet;
|
|
6784
|
+
}
|
|
6785
|
+
getAddress = (chain) => this.connectedChains[chain]?.address || "";
|
|
6786
|
+
getExplorerTxUrl = (chain, txHash) => getExplorerTxUrl({ chain, txHash });
|
|
6787
|
+
getWallet = (chain) => this.connectedWallets[chain];
|
|
6788
|
+
getExplorerAddressUrl = (chain, address) => getExplorerAddressUrl({ chain, address });
|
|
6789
|
+
getBalance = async (chain, potentialScamFilter) => {
|
|
6790
|
+
const wallet = await this.getWalletByChain(chain, potentialScamFilter);
|
|
6791
|
+
return wallet?.balance || [];
|
|
6792
|
+
};
|
|
6793
|
+
swap = async ({
|
|
6794
|
+
streamSwap,
|
|
6795
|
+
recipient,
|
|
6796
|
+
route,
|
|
6797
|
+
feeOptionKey = FeeOption.Average
|
|
6798
|
+
}) => {
|
|
6799
|
+
const {
|
|
6800
|
+
meta: { quoteMode }
|
|
6801
|
+
} = route;
|
|
6802
|
+
const evmChain = quoteMode.startsWith("ERC20-") ? Chain3.Ethereum : quoteMode.startsWith("ARC20-") ? Chain3.Avalanche : quoteMode.startsWith("BEP20-") ? Chain3.BinanceSmartChain : undefined;
|
|
6803
|
+
if (!route.complete)
|
|
6804
|
+
throw new SwapKitError2("core_swap_route_not_complete");
|
|
6805
|
+
if (AGG_SWAP.includes(quoteMode) && evmChain) {
|
|
6806
|
+
const walletMethods = this.connectedWallets[evmChain];
|
|
6807
|
+
if (!walletMethods?.sendTransaction) {
|
|
6808
|
+
throw new SwapKitError2("core_wallet_connection_not_found");
|
|
6809
|
+
}
|
|
6810
|
+
const transaction = streamSwap ? route?.streamingSwap?.transaction : route?.transaction;
|
|
6811
|
+
if (!transaction)
|
|
6812
|
+
throw new SwapKitError2("core_swap_route_transaction_not_found");
|
|
6813
|
+
const { data, from, to, value } = route.transaction;
|
|
6814
|
+
const params = {
|
|
6815
|
+
data,
|
|
6816
|
+
from,
|
|
6817
|
+
to: to.toLowerCase(),
|
|
6818
|
+
chainId: BigInt(ChainToChainId[evmChain]),
|
|
6819
|
+
value: value ? BigInt(value) : 0n
|
|
6820
|
+
};
|
|
6821
|
+
return walletMethods.sendTransaction(params, feeOptionKey);
|
|
6822
|
+
}
|
|
6823
|
+
if (SWAP_OUT.includes(quoteMode)) {
|
|
6824
|
+
if (!route.calldata.fromAsset)
|
|
6825
|
+
throw new SwapKitError2("core_swap_asset_not_recognized");
|
|
6826
|
+
const asset = await AssetValue2.fromString(route.calldata.fromAsset);
|
|
6827
|
+
if (!asset)
|
|
6828
|
+
throw new SwapKitError2("core_swap_asset_not_recognized");
|
|
6829
|
+
const { address: recipient2 } = await this.#getInboundDataByChain(asset.chain);
|
|
6704
6830
|
const {
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
} =
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6831
|
+
contract: router,
|
|
6832
|
+
calldata: { expiration, amountIn, memo, memoStreamingSwap }
|
|
6833
|
+
} = route;
|
|
6834
|
+
const assetValue = asset.add(SwapKitNumber.fromBigInt(BigInt(amountIn), asset.decimal));
|
|
6835
|
+
const swapMemo = streamSwap ? memoStreamingSwap || memo : memo;
|
|
6836
|
+
return this.deposit({
|
|
6837
|
+
expiration,
|
|
6838
|
+
assetValue,
|
|
6839
|
+
memo: swapMemo,
|
|
6840
|
+
feeOptionKey,
|
|
6841
|
+
router,
|
|
6842
|
+
recipient: recipient2
|
|
6843
|
+
});
|
|
6844
|
+
}
|
|
6845
|
+
if (SWAP_IN.includes(quoteMode) && evmChain) {
|
|
6846
|
+
const { calldata, contract: contractAddress } = route;
|
|
6847
|
+
if (!contractAddress)
|
|
6848
|
+
throw new SwapKitError2("core_swap_contract_not_found");
|
|
6849
|
+
const walletMethods = this.connectedWallets[evmChain];
|
|
6850
|
+
const from = this.getAddress(evmChain);
|
|
6851
|
+
if (!(walletMethods?.sendTransaction && from)) {
|
|
6852
|
+
throw new SwapKitError2("core_wallet_connection_not_found");
|
|
6724
6853
|
}
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6731
|
-
const { address: w } = await M(this, S).call(this, b.chain), {
|
|
6732
|
-
contract: T,
|
|
6733
|
-
calldata: { expiration: d, amountIn: l, memo: A, memoStreamingSwap: k }
|
|
6734
|
-
} = n, h = b.add(oe.fromBigInt(BigInt(l), b.decimal)), g = e && k || A;
|
|
6735
|
-
return this.deposit({
|
|
6736
|
-
expiration: d,
|
|
6737
|
-
assetValue: h,
|
|
6738
|
-
memo: g,
|
|
6739
|
-
feeOptionKey: p,
|
|
6740
|
-
router: T,
|
|
6741
|
-
recipient: w
|
|
6854
|
+
const { getProvider, toChecksumAddress } = await import("@swapkit/toolbox-evm");
|
|
6855
|
+
const provider = getProvider(evmChain);
|
|
6856
|
+
const abi = lowercasedContractAbiMapping[contractAddress.toLowerCase()];
|
|
6857
|
+
if (!abi)
|
|
6858
|
+
throw new SwapKitError2("core_swap_contract_not_supported", {
|
|
6859
|
+
contractAddress
|
|
6742
6860
|
});
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6752
|
-
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
}
|
|
6768
|
-
|
|
6769
|
-
})
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
|
|
6781
|
-
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
}
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6861
|
+
const contract = await walletMethods.createContract?.(contractAddress, abi, provider);
|
|
6862
|
+
const tx = await contract.getFunction("swapIn").populateTransaction(...getSwapInParams({
|
|
6863
|
+
streamSwap,
|
|
6864
|
+
toChecksumAddress,
|
|
6865
|
+
contractAddress,
|
|
6866
|
+
recipient,
|
|
6867
|
+
calldata
|
|
6868
|
+
}), { from });
|
|
6869
|
+
return walletMethods.sendTransaction(tx, feeOptionKey);
|
|
6870
|
+
}
|
|
6871
|
+
throw new SwapKitError2("core_swap_quote_mode_not_supported", { quoteMode });
|
|
6872
|
+
};
|
|
6873
|
+
getWalletByChain = async (chain, potentialScamFilter) => {
|
|
6874
|
+
const address = this.getAddress(chain);
|
|
6875
|
+
if (!address)
|
|
6876
|
+
return null;
|
|
6877
|
+
const defaultBalance = [AssetValue2.fromChainOrSignature(chain)];
|
|
6878
|
+
const walletType = this.connectedChains[chain]?.walletType;
|
|
6879
|
+
try {
|
|
6880
|
+
const balance = await this.getWallet(chain)?.getBalance(address, potentialScamFilter);
|
|
6881
|
+
this.connectedChains[chain] = {
|
|
6882
|
+
address,
|
|
6883
|
+
balance: balance?.length ? balance : defaultBalance,
|
|
6884
|
+
walletType
|
|
6885
|
+
};
|
|
6886
|
+
return { ...this.connectedChains[chain] };
|
|
6887
|
+
} catch (error) {
|
|
6888
|
+
console.error(error);
|
|
6889
|
+
return { address, balance: defaultBalance, walletType };
|
|
6890
|
+
}
|
|
6891
|
+
};
|
|
6892
|
+
approveAssetValue = (assetValue, contractAddress) => this.#approve({ assetValue, type: "approve", contractAddress });
|
|
6893
|
+
isAssetValueApproved = (assetValue, contractAddress) => this.#approve({ assetValue, contractAddress, type: "checkOnly" });
|
|
6894
|
+
validateAddress = ({ address, chain }) => this.getWallet(chain)?.validateAddress?.(address);
|
|
6895
|
+
transfer = async (params) => {
|
|
6896
|
+
const walletInstance = this.connectedWallets[params.assetValue.chain];
|
|
6897
|
+
if (!walletInstance)
|
|
6898
|
+
throw new SwapKitError2("core_wallet_connection_not_found");
|
|
6899
|
+
try {
|
|
6900
|
+
const tx = await walletInstance.transfer(this.#prepareTxParams(params));
|
|
6901
|
+
return tx;
|
|
6902
|
+
} catch (error) {
|
|
6903
|
+
throw new SwapKitError2("core_swap_transaction_error", error);
|
|
6904
|
+
}
|
|
6905
|
+
};
|
|
6906
|
+
deposit = async ({
|
|
6907
|
+
assetValue,
|
|
6908
|
+
recipient,
|
|
6909
|
+
router,
|
|
6910
|
+
...rest
|
|
6911
|
+
}) => {
|
|
6912
|
+
const { chain, symbol, ticker } = assetValue;
|
|
6913
|
+
const walletInstance = this.connectedWallets[chain];
|
|
6914
|
+
const connectedWallet = this.connectedChains[chain];
|
|
6915
|
+
const isAddressValidated = await validateAddressType({
|
|
6916
|
+
address: connectedWallet?.address,
|
|
6917
|
+
chain
|
|
6792
6918
|
});
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6919
|
+
if (!isAddressValidated) {
|
|
6920
|
+
throw new SwapKitError2("core_transaction_invalid_sender_address");
|
|
6921
|
+
}
|
|
6922
|
+
if (!walletInstance) {
|
|
6923
|
+
throw new SwapKitError2("core_wallet_connection_not_found");
|
|
6924
|
+
}
|
|
6925
|
+
const params = this.#prepareTxParams({
|
|
6926
|
+
assetValue,
|
|
6927
|
+
recipient,
|
|
6928
|
+
router,
|
|
6929
|
+
...rest
|
|
6802
6930
|
});
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
if (!await Qe({
|
|
6811
|
-
address: b == null ? void 0 : b.address,
|
|
6812
|
-
chain: i
|
|
6813
|
-
}))
|
|
6814
|
-
throw new s("core_transaction_invalid_sender_address");
|
|
6815
|
-
if (!f)
|
|
6816
|
-
throw new s("core_wallet_connection_not_found");
|
|
6817
|
-
const T = M(this, P).call(this, {
|
|
6818
|
-
assetValue: e,
|
|
6819
|
-
recipient: t,
|
|
6820
|
-
router: n,
|
|
6821
|
-
...p
|
|
6822
|
-
});
|
|
6823
|
-
try {
|
|
6824
|
-
switch (i) {
|
|
6825
|
-
case a.THORChain:
|
|
6826
|
-
case a.Maya: {
|
|
6827
|
-
const d = f;
|
|
6828
|
-
return await (t === "" ? d.deposit(T) : d.transfer(T));
|
|
6829
|
-
}
|
|
6830
|
-
case a.Ethereum:
|
|
6831
|
-
case a.BinanceSmartChain:
|
|
6832
|
-
case a.Avalanche: {
|
|
6833
|
-
const { getChecksumAddressFromAsset: d } = await import("@swapkit/toolbox-evm"), l = i === a.Avalanche ? be : i === a.BinanceSmartChain ? fe : we;
|
|
6834
|
-
return await f.call({
|
|
6835
|
-
abi: l,
|
|
6836
|
-
contractAddress: n || (await M(this, S).call(this, i)).router,
|
|
6837
|
-
funcName: "depositWithExpiry",
|
|
6838
|
-
funcParams: [
|
|
6839
|
-
t,
|
|
6840
|
-
d({ chain: i, symbol: o, ticker: c }, i),
|
|
6841
|
-
e.getBaseValue("string"),
|
|
6842
|
-
T.memo,
|
|
6843
|
-
p.expiration || Number.parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
|
|
6844
|
-
],
|
|
6845
|
-
txOverrides: {
|
|
6846
|
-
from: T.from,
|
|
6847
|
-
value: e.isGasAsset ? e.getBaseValue("bigint") : void 0
|
|
6848
|
-
}
|
|
6849
|
-
});
|
|
6850
|
-
}
|
|
6851
|
-
default:
|
|
6852
|
-
return await f.transfer(T);
|
|
6931
|
+
try {
|
|
6932
|
+
switch (chain) {
|
|
6933
|
+
case Chain3.THORChain:
|
|
6934
|
+
case Chain3.Maya: {
|
|
6935
|
+
const wallet = walletInstance;
|
|
6936
|
+
const tx = await (recipient === "" ? wallet.deposit(params) : wallet.transfer(params));
|
|
6937
|
+
return tx;
|
|
6853
6938
|
}
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6863
|
-
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
})
|
|
6876
|
-
});
|
|
6877
|
-
} catch (i) {
|
|
6878
|
-
throw new s("core_transaction_create_liquidity_rune_error", i);
|
|
6879
|
-
}
|
|
6880
|
-
try {
|
|
6881
|
-
p = await M(this, E).call(this, {
|
|
6882
|
-
assetValue: t,
|
|
6883
|
-
memo: O(v.DEPOSIT, {
|
|
6884
|
-
...t,
|
|
6885
|
-
address: this.getAddress(a.THORChain)
|
|
6886
|
-
})
|
|
6887
|
-
});
|
|
6888
|
-
} catch (i) {
|
|
6889
|
-
throw new s("core_transaction_create_liquidity_asset_error", i);
|
|
6890
|
-
}
|
|
6891
|
-
return { runeTx: n, assetTx: p };
|
|
6892
|
-
});
|
|
6893
|
-
y(this, "addLiquidity", async ({
|
|
6894
|
-
runeAssetValue: e,
|
|
6895
|
-
assetValue: t,
|
|
6896
|
-
runeAddr: n,
|
|
6897
|
-
assetAddr: p,
|
|
6898
|
-
isPendingSymmAsset: i,
|
|
6899
|
-
mode: o = "sym"
|
|
6900
|
-
}) => {
|
|
6901
|
-
const { chain: c, symbol: f } = t, b = o === "sym", w = (e == null ? void 0 : e.gt(0)) && (b || o === "rune"), T = (t == null ? void 0 : t.gt(0)) && (b || o === "asset"), d = i || w, l = d ? n || this.getAddress(a.THORChain) : "", A = b || o === "asset" ? p || this.getAddress(c) : "";
|
|
6902
|
-
if (!(w || T))
|
|
6903
|
-
throw new s("core_transaction_add_liquidity_invalid_params");
|
|
6904
|
-
if (d && !l)
|
|
6905
|
-
throw new s("core_transaction_add_liquidity_no_rune_address");
|
|
6906
|
-
let k, h;
|
|
6907
|
-
if (w && e)
|
|
6908
|
-
try {
|
|
6909
|
-
k = await M(this, E).call(this, {
|
|
6910
|
-
assetValue: e,
|
|
6911
|
-
memo: O(v.DEPOSIT, {
|
|
6912
|
-
chain: c,
|
|
6913
|
-
symbol: f,
|
|
6914
|
-
address: A
|
|
6915
|
-
})
|
|
6939
|
+
case Chain3.Ethereum:
|
|
6940
|
+
case Chain3.BinanceSmartChain:
|
|
6941
|
+
case Chain3.Avalanche: {
|
|
6942
|
+
const { getChecksumAddressFromAsset } = await import("@swapkit/toolbox-evm");
|
|
6943
|
+
const abi = chain === Chain3.Avalanche ? TCAvalancheDepositABI : chain === Chain3.BinanceSmartChain ? TCBscDepositABI : TCEthereumVaultAbi;
|
|
6944
|
+
const wallet = walletInstance;
|
|
6945
|
+
const response = await wallet.call({
|
|
6946
|
+
abi,
|
|
6947
|
+
contractAddress: router || (await this.#getInboundDataByChain(chain)).router,
|
|
6948
|
+
funcName: "depositWithExpiry",
|
|
6949
|
+
funcParams: [
|
|
6950
|
+
recipient,
|
|
6951
|
+
getChecksumAddressFromAsset({ chain, symbol, ticker }, chain),
|
|
6952
|
+
assetValue.getBaseValue("string"),
|
|
6953
|
+
params.memo,
|
|
6954
|
+
rest.expiration || Number.parseInt(`${(new Date().getTime() + 900000) / 1000}`)
|
|
6955
|
+
],
|
|
6956
|
+
txOverrides: {
|
|
6957
|
+
from: params.from,
|
|
6958
|
+
value: assetValue.isGasAsset ? assetValue.getBaseValue("bigint") : undefined
|
|
6959
|
+
}
|
|
6916
6960
|
});
|
|
6917
|
-
|
|
6918
|
-
throw new s("core_transaction_add_liquidity_rune_error", g);
|
|
6961
|
+
return response;
|
|
6919
6962
|
}
|
|
6920
|
-
|
|
6921
|
-
|
|
6922
|
-
|
|
6923
|
-
assetValue: t,
|
|
6924
|
-
memo: O(v.DEPOSIT, {
|
|
6925
|
-
chain: c,
|
|
6926
|
-
symbol: f,
|
|
6927
|
-
address: l
|
|
6928
|
-
})
|
|
6929
|
-
});
|
|
6930
|
-
} catch (g) {
|
|
6931
|
-
throw new s("core_transaction_add_liquidity_asset_error", g);
|
|
6963
|
+
default: {
|
|
6964
|
+
const tx = await walletInstance.transfer(params);
|
|
6965
|
+
return tx;
|
|
6932
6966
|
}
|
|
6933
|
-
|
|
6934
|
-
})
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
6940
|
-
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
|
|
6944
|
-
|
|
6945
|
-
|
|
6946
|
-
|
|
6967
|
+
}
|
|
6968
|
+
} catch (error) {
|
|
6969
|
+
const errorMessage = typeof error === "string" ? error.toLowerCase() : error?.message?.toLowerCase();
|
|
6970
|
+
const isInsufficientFunds = errorMessage?.includes("insufficient funds");
|
|
6971
|
+
const isGas = errorMessage?.includes("gas");
|
|
6972
|
+
const isServer = errorMessage?.includes("server");
|
|
6973
|
+
const isUserRejected = errorMessage?.includes("user rejected");
|
|
6974
|
+
const errorKey = isInsufficientFunds ? "core_transaction_deposit_insufficient_funds_error" : isGas ? "core_transaction_deposit_gas_error" : isServer ? "core_transaction_deposit_server_error" : isUserRejected ? "core_transaction_user_rejected" : "core_transaction_deposit_error";
|
|
6975
|
+
throw new SwapKitError2(errorKey, error);
|
|
6976
|
+
}
|
|
6977
|
+
};
|
|
6978
|
+
createLiquidity = async ({
|
|
6979
|
+
runeAssetValue,
|
|
6980
|
+
assetValue
|
|
6981
|
+
}) => {
|
|
6982
|
+
if (runeAssetValue.lte(0) || assetValue.lte(0)) {
|
|
6983
|
+
throw new SwapKitError2("core_transaction_create_liquidity_invalid_params");
|
|
6984
|
+
}
|
|
6985
|
+
const assetAddress = this.getAddress(assetValue.chain);
|
|
6986
|
+
const runeAddress = this.getAddress(Chain3.THORChain);
|
|
6987
|
+
const runeTx = await wrapWithThrow(() => {
|
|
6988
|
+
return this.#depositToPool({
|
|
6989
|
+
assetValue: runeAssetValue,
|
|
6990
|
+
memo: getMemoFor(MemoType.DEPOSIT, { ...assetValue, address: assetAddress })
|
|
6947
6991
|
});
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
percent: n,
|
|
6954
|
-
from: p,
|
|
6955
|
-
to: i
|
|
6956
|
-
}) => {
|
|
6957
|
-
const o = i === "rune" && p !== "rune" ? L.fromChainOrSignature(a.THORChain) : p === "sym" && i === "sym" || p === "rune" || p === "asset" ? void 0 : t, c = U(p === "asset" ? t.chain : a.THORChain), f = e || O(v.WITHDRAW, {
|
|
6958
|
-
symbol: t.symbol,
|
|
6959
|
-
chain: t.chain,
|
|
6960
|
-
ticker: t.ticker,
|
|
6961
|
-
basisPoints: Math.min(1e4, Math.round(n * 100)),
|
|
6962
|
-
targetAssetString: o == null ? void 0 : o.toString(),
|
|
6963
|
-
singleSide: !1
|
|
6992
|
+
}, "core_transaction_create_liquidity_rune_error");
|
|
6993
|
+
const assetTx = await wrapWithThrow(() => {
|
|
6994
|
+
return this.#depositToPool({
|
|
6995
|
+
assetValue,
|
|
6996
|
+
memo: getMemoFor(MemoType.DEPOSIT, { ...assetValue, address: runeAddress })
|
|
6964
6997
|
});
|
|
6965
|
-
|
|
6966
|
-
}
|
|
6967
|
-
|
|
6968
|
-
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
|
|
6972
|
-
|
|
6973
|
-
|
|
6974
|
-
|
|
6975
|
-
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
})
|
|
6994
|
-
}));
|
|
6995
|
-
y(this, "nodeAction", ({
|
|
6996
|
-
type: e,
|
|
6997
|
-
assetValue: t,
|
|
6998
|
-
address: n
|
|
6999
|
-
}) => {
|
|
7000
|
-
const p = e === "bond" ? v.BOND : e === "unbond" ? v.UNBOND : v.LEAVE, i = O(p, {
|
|
7001
|
-
address: n,
|
|
7002
|
-
unbondAmount: e === "unbond" ? t.getBaseValue("number") : void 0
|
|
6998
|
+
}, "core_transaction_create_liquidity_asset_error");
|
|
6999
|
+
return { runeTx, assetTx };
|
|
7000
|
+
};
|
|
7001
|
+
addLiquidity = async ({
|
|
7002
|
+
runeAssetValue,
|
|
7003
|
+
assetValue,
|
|
7004
|
+
runeAddr,
|
|
7005
|
+
assetAddr,
|
|
7006
|
+
isPendingSymmAsset,
|
|
7007
|
+
mode = "sym"
|
|
7008
|
+
}) => {
|
|
7009
|
+
const { chain, symbol } = assetValue;
|
|
7010
|
+
const isSym = mode === "sym";
|
|
7011
|
+
const runeTransfer = runeAssetValue?.gt(0) && (isSym || mode === "rune");
|
|
7012
|
+
const assetTransfer = assetValue?.gt(0) && (isSym || mode === "asset");
|
|
7013
|
+
const includeRuneAddress = isPendingSymmAsset || runeTransfer;
|
|
7014
|
+
const runeAddress = includeRuneAddress ? runeAddr || this.getAddress(Chain3.THORChain) : "";
|
|
7015
|
+
const assetAddress = isSym || mode === "asset" ? assetAddr || this.getAddress(chain) : "";
|
|
7016
|
+
if (!(runeTransfer || assetTransfer)) {
|
|
7017
|
+
throw new SwapKitError2("core_transaction_add_liquidity_invalid_params");
|
|
7018
|
+
}
|
|
7019
|
+
if (includeRuneAddress && !runeAddress) {
|
|
7020
|
+
throw new SwapKitError2("core_transaction_add_liquidity_no_rune_address");
|
|
7021
|
+
}
|
|
7022
|
+
const runeTx = await wrapWithThrow(() => {
|
|
7023
|
+
return this.#depositToPool({
|
|
7024
|
+
assetValue: runeAssetValue,
|
|
7025
|
+
memo: getMemoFor(MemoType.DEPOSIT, { chain, symbol, address: assetAddress })
|
|
7003
7026
|
});
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7027
|
+
}, "core_transaction_add_liquidity_rune_error");
|
|
7028
|
+
const assetTx = assetTransfer && assetValue ? wrapWithThrow(() => {
|
|
7029
|
+
return this.#depositToPool({
|
|
7030
|
+
assetValue,
|
|
7031
|
+
memo: getMemoFor(MemoType.DEPOSIT, { chain, symbol, address: runeAddress })
|
|
7007
7032
|
});
|
|
7033
|
+
}, "core_transaction_add_liquidity_asset_error") : null;
|
|
7034
|
+
return { runeTx, assetTx };
|
|
7035
|
+
};
|
|
7036
|
+
addLiquidityPart = ({
|
|
7037
|
+
assetValue,
|
|
7038
|
+
poolAddress,
|
|
7039
|
+
address,
|
|
7040
|
+
symmetric
|
|
7041
|
+
}) => {
|
|
7042
|
+
if (symmetric && !address) {
|
|
7043
|
+
throw new SwapKitError2("core_transaction_add_liquidity_invalid_params");
|
|
7044
|
+
}
|
|
7045
|
+
const memo = getMemoFor(MemoType.DEPOSIT, {
|
|
7046
|
+
chain: poolAddress.split(".")[0],
|
|
7047
|
+
symbol: poolAddress.split(".")[1],
|
|
7048
|
+
address: symmetric ? address : ""
|
|
7008
7049
|
});
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
addChain: M(this, W),
|
|
7028
|
-
config: t || {},
|
|
7029
|
-
apis: n,
|
|
7030
|
-
rpcUrls: p
|
|
7031
|
-
});
|
|
7032
|
-
} catch (i) {
|
|
7033
|
-
throw new s("core_extend_error", i);
|
|
7034
|
-
}
|
|
7035
|
-
});
|
|
7036
|
-
y(this, "estimateMaxSendableAmount", async ({
|
|
7037
|
-
chain: e,
|
|
7038
|
-
params: t
|
|
7039
|
-
}) => {
|
|
7040
|
-
const n = this.getWallet(e);
|
|
7041
|
-
switch (e) {
|
|
7042
|
-
case a.Arbitrum:
|
|
7043
|
-
case a.Avalanche:
|
|
7044
|
-
case a.BinanceSmartChain:
|
|
7045
|
-
case a.Ethereum:
|
|
7046
|
-
case a.Optimism:
|
|
7047
|
-
case a.Polygon: {
|
|
7048
|
-
const { estimateMaxSendableAmount: p } = await import("@swapkit/toolbox-evm");
|
|
7049
|
-
return p({
|
|
7050
|
-
...t,
|
|
7051
|
-
toolbox: n
|
|
7052
|
-
});
|
|
7053
|
-
}
|
|
7054
|
-
case a.Bitcoin:
|
|
7055
|
-
case a.BitcoinCash:
|
|
7056
|
-
case a.Dogecoin:
|
|
7057
|
-
case a.Litecoin:
|
|
7058
|
-
return n.estimateMaxSendableAmount(t);
|
|
7059
|
-
case a.Binance:
|
|
7060
|
-
case a.THORChain:
|
|
7061
|
-
case a.Cosmos: {
|
|
7062
|
-
const { estimateMaxSendableAmount: p } = await import("@swapkit/toolbox-cosmos");
|
|
7063
|
-
return p({
|
|
7064
|
-
...t,
|
|
7065
|
-
toolbox: n
|
|
7066
|
-
});
|
|
7067
|
-
}
|
|
7068
|
-
default:
|
|
7069
|
-
throw new s("core_estimated_max_spendable_chain_not_supported");
|
|
7070
|
-
}
|
|
7071
|
-
});
|
|
7072
|
-
/**
|
|
7073
|
-
* Wallet connection methods
|
|
7074
|
-
*/
|
|
7075
|
-
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
7076
|
-
y(this, "connectXDEFI", async (e) => {
|
|
7077
|
-
throw new s("core_wallet_xdefi_not_installed");
|
|
7078
|
-
});
|
|
7079
|
-
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
7080
|
-
y(this, "connectEVMWallet", async (e, t) => {
|
|
7081
|
-
throw new s("core_wallet_evmwallet_not_installed");
|
|
7082
|
-
});
|
|
7083
|
-
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
7084
|
-
y(this, "connectWalletconnect", async (e, t) => {
|
|
7085
|
-
throw new s("core_wallet_walletconnect_not_installed");
|
|
7086
|
-
});
|
|
7087
|
-
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
7088
|
-
y(this, "connectKeepkey", async (e, t) => {
|
|
7089
|
-
throw new s("core_wallet_keepkey_not_installed");
|
|
7090
|
-
});
|
|
7091
|
-
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
7092
|
-
y(this, "connectKeystore", async (e, t) => {
|
|
7093
|
-
throw new s("core_wallet_keystore_not_installed");
|
|
7094
|
-
});
|
|
7095
|
-
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
7096
|
-
y(this, "connectLedger", async (e, t) => {
|
|
7097
|
-
throw new s("core_wallet_ledger_not_installed");
|
|
7098
|
-
});
|
|
7099
|
-
// biome-ignore lint/suspicious/useAwait: Extended methods
|
|
7100
|
-
y(this, "connectTrezor", async (e, t) => {
|
|
7101
|
-
throw new s("core_wallet_trezor_not_installed");
|
|
7050
|
+
return this.#depositToPool({ assetValue, memo });
|
|
7051
|
+
};
|
|
7052
|
+
withdraw = ({
|
|
7053
|
+
memo,
|
|
7054
|
+
assetValue,
|
|
7055
|
+
percent,
|
|
7056
|
+
from,
|
|
7057
|
+
to
|
|
7058
|
+
}) => {
|
|
7059
|
+
const targetAsset = to === "rune" && from !== "rune" ? AssetValue2.fromChainOrSignature(Chain3.THORChain) : from === "sym" && to === "sym" || from === "rune" || from === "asset" ? undefined : assetValue;
|
|
7060
|
+
const value = getMinAmountByChain(from === "asset" ? assetValue.chain : Chain3.THORChain);
|
|
7061
|
+
const memoString = memo || getMemoFor(MemoType.WITHDRAW, {
|
|
7062
|
+
symbol: assetValue.symbol,
|
|
7063
|
+
chain: assetValue.chain,
|
|
7064
|
+
ticker: assetValue.ticker,
|
|
7065
|
+
basisPoints: Math.min(1e4, Math.round(percent * 100)),
|
|
7066
|
+
targetAssetString: targetAsset?.toString(),
|
|
7067
|
+
singleSide: false
|
|
7102
7068
|
});
|
|
7103
|
-
|
|
7104
|
-
|
|
7105
|
-
|
|
7069
|
+
return this.#depositToPool({ assetValue: value, memo: memoString });
|
|
7070
|
+
};
|
|
7071
|
+
savings = ({
|
|
7072
|
+
assetValue,
|
|
7073
|
+
memo,
|
|
7074
|
+
percent,
|
|
7075
|
+
type
|
|
7076
|
+
}) => {
|
|
7077
|
+
const memoType = type === "add" ? MemoType.DEPOSIT : MemoType.WITHDRAW;
|
|
7078
|
+
const memoString = memo || getMemoFor(memoType, {
|
|
7079
|
+
ticker: assetValue.ticker,
|
|
7080
|
+
symbol: assetValue.symbol,
|
|
7081
|
+
chain: assetValue.chain,
|
|
7082
|
+
singleSide: true,
|
|
7083
|
+
basisPoints: percent ? Math.min(1e4, Math.round(percent * 100)) : undefined
|
|
7106
7084
|
});
|
|
7107
|
-
|
|
7108
|
-
|
|
7109
|
-
|
|
7085
|
+
const value = memoType === MemoType.DEPOSIT ? assetValue : getMinAmountByChain(assetValue.chain);
|
|
7086
|
+
return this.#depositToPool({ memo: memoString, assetValue: value });
|
|
7087
|
+
};
|
|
7088
|
+
loan = ({
|
|
7089
|
+
assetValue,
|
|
7090
|
+
memo,
|
|
7091
|
+
minAmount,
|
|
7092
|
+
type
|
|
7093
|
+
}) => this.#depositToPool({
|
|
7094
|
+
assetValue,
|
|
7095
|
+
memo: memo || getMemoFor(type === "open" ? MemoType.OPEN_LOAN : MemoType.CLOSE_LOAN, {
|
|
7096
|
+
asset: assetValue.toString(),
|
|
7097
|
+
minAmount: minAmount.toString(),
|
|
7098
|
+
address: this.getAddress(assetValue.chain)
|
|
7099
|
+
})
|
|
7100
|
+
});
|
|
7101
|
+
nodeAction = ({
|
|
7102
|
+
type,
|
|
7103
|
+
assetValue,
|
|
7104
|
+
address
|
|
7105
|
+
}) => {
|
|
7106
|
+
const memoType = type === "bond" ? MemoType.BOND : type === "unbond" ? MemoType.UNBOND : MemoType.LEAVE;
|
|
7107
|
+
const memo = getMemoFor(memoType, {
|
|
7108
|
+
address,
|
|
7109
|
+
unbondAmount: type === "unbond" ? assetValue.getBaseValue("number") : undefined
|
|
7110
7110
|
});
|
|
7111
|
-
|
|
7112
|
-
|
|
7111
|
+
return this.#thorchainTransfer({
|
|
7112
|
+
memo,
|
|
7113
|
+
assetValue: type === "bond" ? assetValue : getMinAmountByChain(Chain3.THORChain)
|
|
7113
7114
|
});
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
|
|
7120
|
-
|
|
7121
|
-
|
|
7122
|
-
|
|
7123
|
-
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7115
|
+
};
|
|
7116
|
+
registerThorname = ({
|
|
7117
|
+
assetValue,
|
|
7118
|
+
...param
|
|
7119
|
+
}) => this.#thorchainTransfer({
|
|
7120
|
+
assetValue,
|
|
7121
|
+
memo: getMemoFor(MemoType.THORNAME_REGISTER, param)
|
|
7122
|
+
});
|
|
7123
|
+
registerMayaname = ({
|
|
7124
|
+
assetValue,
|
|
7125
|
+
...param
|
|
7126
|
+
}) => this.#mayachainTransfer({
|
|
7127
|
+
assetValue,
|
|
7128
|
+
memo: getMemoFor(MemoType.THORNAME_REGISTER, param)
|
|
7129
|
+
});
|
|
7130
|
+
extend = ({ wallets, config, apis = {}, rpcUrls = {} }) => {
|
|
7131
|
+
try {
|
|
7132
|
+
for (const wallet of wallets) {
|
|
7133
|
+
this[wallet.connectMethodName] = wallet.connect({
|
|
7134
|
+
addChain: this.#addConnectedChain,
|
|
7135
|
+
config: config || {},
|
|
7136
|
+
apis,
|
|
7137
|
+
rpcUrls
|
|
7138
|
+
});
|
|
7127
7139
|
}
|
|
7140
|
+
} catch (error) {
|
|
7141
|
+
throw new SwapKitError2("core_extend_error", error);
|
|
7142
|
+
}
|
|
7143
|
+
};
|
|
7144
|
+
estimateMaxSendableAmount = async ({
|
|
7145
|
+
chain,
|
|
7146
|
+
params
|
|
7147
|
+
}) => {
|
|
7148
|
+
const walletMethods = this.getWallet(chain);
|
|
7149
|
+
switch (chain) {
|
|
7150
|
+
case Chain3.Arbitrum:
|
|
7151
|
+
case Chain3.Avalanche:
|
|
7152
|
+
case Chain3.BinanceSmartChain:
|
|
7153
|
+
case Chain3.Ethereum:
|
|
7154
|
+
case Chain3.Optimism:
|
|
7155
|
+
case Chain3.Polygon: {
|
|
7156
|
+
const { estimateMaxSendableAmount } = await import("@swapkit/toolbox-evm");
|
|
7157
|
+
return estimateMaxSendableAmount({
|
|
7158
|
+
...params,
|
|
7159
|
+
toolbox: walletMethods
|
|
7160
|
+
});
|
|
7161
|
+
}
|
|
7162
|
+
case Chain3.Bitcoin:
|
|
7163
|
+
case Chain3.BitcoinCash:
|
|
7164
|
+
case Chain3.Dogecoin:
|
|
7165
|
+
case Chain3.Litecoin:
|
|
7166
|
+
return walletMethods.estimateMaxSendableAmount(params);
|
|
7167
|
+
case Chain3.Binance:
|
|
7168
|
+
case Chain3.THORChain:
|
|
7169
|
+
case Chain3.Cosmos: {
|
|
7170
|
+
const { estimateMaxSendableAmount } = await import("@swapkit/toolbox-cosmos");
|
|
7171
|
+
return estimateMaxSendableAmount({
|
|
7172
|
+
...params,
|
|
7173
|
+
toolbox: walletMethods
|
|
7174
|
+
});
|
|
7175
|
+
}
|
|
7176
|
+
default:
|
|
7177
|
+
throw new SwapKitError2("core_estimated_max_spendable_chain_not_supported");
|
|
7178
|
+
}
|
|
7179
|
+
};
|
|
7180
|
+
connectXDEFI = async (_chains) => {
|
|
7181
|
+
throw new SwapKitError2("core_wallet_xdefi_not_installed");
|
|
7182
|
+
};
|
|
7183
|
+
connectEVMWallet = async (_chains, _wallet) => {
|
|
7184
|
+
throw new SwapKitError2("core_wallet_evmwallet_not_installed");
|
|
7185
|
+
};
|
|
7186
|
+
connectWalletconnect = async (_chains, _options) => {
|
|
7187
|
+
throw new SwapKitError2("core_wallet_walletconnect_not_installed");
|
|
7188
|
+
};
|
|
7189
|
+
connectKeepkey = async (_chains, _derivationPath) => {
|
|
7190
|
+
throw new SwapKitError2("core_wallet_keepkey_not_installed");
|
|
7191
|
+
};
|
|
7192
|
+
connectKeystore = async (_chains, _phrase) => {
|
|
7193
|
+
throw new SwapKitError2("core_wallet_keystore_not_installed");
|
|
7194
|
+
};
|
|
7195
|
+
connectLedger = async (_chains, _derivationPath) => {
|
|
7196
|
+
throw new SwapKitError2("core_wallet_ledger_not_installed");
|
|
7197
|
+
};
|
|
7198
|
+
connectTrezor = async (_chains, _derivationPath) => {
|
|
7199
|
+
throw new SwapKitError2("core_wallet_trezor_not_installed");
|
|
7200
|
+
};
|
|
7201
|
+
connectKeplr = async (_chain) => {
|
|
7202
|
+
throw new SwapKitError2("core_wallet_keplr_not_installed");
|
|
7203
|
+
};
|
|
7204
|
+
connectOkx = async (_chains) => {
|
|
7205
|
+
throw new SwapKitError2("core_wallet_okx_not_installed");
|
|
7206
|
+
};
|
|
7207
|
+
disconnectChain = (chain) => {
|
|
7208
|
+
this.connectedChains[chain] = null;
|
|
7209
|
+
this.connectedWallets[chain] = null;
|
|
7210
|
+
};
|
|
7211
|
+
#getInboundDataByChain = async (chain) => {
|
|
7212
|
+
switch (chain) {
|
|
7213
|
+
case Chain3.Maya:
|
|
7214
|
+
case Chain3.THORChain:
|
|
7215
|
+
return { gas_rate: "0", router: "", address: "", halted: false, chain };
|
|
7216
|
+
default: {
|
|
7217
|
+
const inboundData = await SwapKitApi.getInboundAddresses({ stagenet: this.stagenet });
|
|
7218
|
+
const chainAddressData = inboundData.find((item) => item.chain === chain);
|
|
7219
|
+
if (!chainAddressData)
|
|
7220
|
+
throw new SwapKitError2("core_inbound_data_not_found");
|
|
7221
|
+
if (chainAddressData?.halted)
|
|
7222
|
+
throw new SwapKitError2("core_chain_halted");
|
|
7223
|
+
return chainAddressData;
|
|
7224
|
+
}
|
|
7225
|
+
}
|
|
7226
|
+
};
|
|
7227
|
+
#addConnectedChain = ({
|
|
7228
|
+
chain,
|
|
7229
|
+
address,
|
|
7230
|
+
balance,
|
|
7231
|
+
walletType,
|
|
7232
|
+
...rest
|
|
7233
|
+
}) => {
|
|
7234
|
+
this.connectedChains[chain] = {
|
|
7235
|
+
address: address || "",
|
|
7236
|
+
balance: balance || [],
|
|
7237
|
+
walletType: walletType || "unknown"
|
|
7238
|
+
};
|
|
7239
|
+
this.connectedWallets[chain] = { ...rest };
|
|
7240
|
+
};
|
|
7241
|
+
#approve = async ({
|
|
7242
|
+
assetValue,
|
|
7243
|
+
type = "checkOnly",
|
|
7244
|
+
contractAddress
|
|
7245
|
+
}) => {
|
|
7246
|
+
const { address, chain, isGasAsset, isSynthetic } = assetValue;
|
|
7247
|
+
const isEVMChain = [Chain3.Ethereum, Chain3.Avalanche, Chain3.BinanceSmartChain].includes(chain);
|
|
7248
|
+
const isNativeEVM = isEVMChain && isGasAsset;
|
|
7249
|
+
if (isNativeEVM || !isEVMChain || isSynthetic)
|
|
7250
|
+
return true;
|
|
7251
|
+
const walletMethods = this.connectedWallets[chain];
|
|
7252
|
+
const walletAction = type === "checkOnly" ? walletMethods?.isApproved : walletMethods?.approve;
|
|
7253
|
+
if (!walletAction) {
|
|
7254
|
+
throw new SwapKitError2("core_wallet_connection_not_found");
|
|
7255
|
+
}
|
|
7256
|
+
const from = this.getAddress(chain);
|
|
7257
|
+
if (!(address && from)) {
|
|
7258
|
+
throw new SwapKitError2("core_approve_asset_address_or_from_not_found");
|
|
7259
|
+
}
|
|
7260
|
+
const spenderAddress = contractAddress || (await this.#getInboundDataByChain(chain)).router;
|
|
7261
|
+
return walletAction({
|
|
7262
|
+
amount: assetValue.getBaseValue("bigint"),
|
|
7263
|
+
assetAddress: address,
|
|
7264
|
+
from,
|
|
7265
|
+
spenderAddress
|
|
7128
7266
|
});
|
|
7129
|
-
|
|
7130
|
-
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
const { address: p, chain: i, isGasAsset: o, isSynthetic: c } = e, f = [a.Ethereum, a.Avalanche, a.BinanceSmartChain].includes(i);
|
|
7148
|
-
if (f && o || !f || c)
|
|
7149
|
-
return !0;
|
|
7150
|
-
const w = this.connectedWallets[i], T = t === "checkOnly" ? w == null ? void 0 : w.isApproved : w == null ? void 0 : w.approve;
|
|
7151
|
-
if (!T)
|
|
7152
|
-
throw new s("core_wallet_connection_not_found");
|
|
7153
|
-
const d = this.getAddress(i);
|
|
7154
|
-
if (!(p && d))
|
|
7155
|
-
throw new s("core_approve_asset_address_or_from_not_found");
|
|
7156
|
-
const l = n || (await M(this, S).call(this, i)).router;
|
|
7157
|
-
return T({
|
|
7158
|
-
amount: e.getBaseValue("bigint"),
|
|
7159
|
-
assetAddress: p,
|
|
7160
|
-
from: d,
|
|
7161
|
-
spenderAddress: l
|
|
7162
|
-
});
|
|
7163
|
-
});
|
|
7164
|
-
F(this, E, async ({
|
|
7165
|
-
assetValue: e,
|
|
7166
|
-
memo: t,
|
|
7167
|
-
feeOptionKey: n = K.Fast
|
|
7168
|
-
}) => {
|
|
7169
|
-
const {
|
|
7170
|
-
gas_rate: p,
|
|
7171
|
-
router: i,
|
|
7172
|
-
address: o
|
|
7173
|
-
} = await M(this, S).call(this, e.chain), c = (Number.parseInt(p) || 0) * de[n];
|
|
7174
|
-
return this.deposit({
|
|
7175
|
-
assetValue: e,
|
|
7176
|
-
recipient: o,
|
|
7177
|
-
memo: t,
|
|
7178
|
-
router: i,
|
|
7179
|
-
feeRate: c
|
|
7180
|
-
});
|
|
7181
|
-
});
|
|
7182
|
-
F(this, H, async ({
|
|
7183
|
-
memo: e,
|
|
7184
|
-
assetValue: t
|
|
7185
|
-
}) => {
|
|
7186
|
-
const n = await Ge(this.stagenet);
|
|
7187
|
-
if (n.HALTCHAINGLOBAL >= 1 || n.HALTTHORCHAIN >= 1)
|
|
7188
|
-
throw new s("core_chain_halted");
|
|
7189
|
-
return this.deposit({ assetValue: t, recipient: "", memo: e });
|
|
7190
|
-
});
|
|
7191
|
-
F(this, V, async ({
|
|
7192
|
-
memo: e,
|
|
7193
|
-
assetValue: t
|
|
7194
|
-
}) => {
|
|
7195
|
-
const n = await Ue(this.stagenet);
|
|
7196
|
-
if (n.HALTCHAINGLOBAL >= 1 || n.HALTTHORCHAIN >= 1)
|
|
7197
|
-
throw new s("core_chain_halted");
|
|
7198
|
-
return this.deposit({ assetValue: t, recipient: "", memo: e });
|
|
7267
|
+
};
|
|
7268
|
+
#depositToPool = async ({
|
|
7269
|
+
assetValue,
|
|
7270
|
+
memo,
|
|
7271
|
+
feeOptionKey = FeeOption.Fast
|
|
7272
|
+
}) => {
|
|
7273
|
+
const {
|
|
7274
|
+
gas_rate = "0",
|
|
7275
|
+
router,
|
|
7276
|
+
address: poolAddress
|
|
7277
|
+
} = await this.#getInboundDataByChain(assetValue.chain);
|
|
7278
|
+
const feeRate = Number.parseInt(gas_rate) * gasFeeMultiplier[feeOptionKey];
|
|
7279
|
+
return this.deposit({
|
|
7280
|
+
assetValue,
|
|
7281
|
+
recipient: poolAddress,
|
|
7282
|
+
memo,
|
|
7283
|
+
router,
|
|
7284
|
+
feeRate
|
|
7199
7285
|
});
|
|
7200
|
-
|
|
7201
|
-
|
|
7202
|
-
|
|
7203
|
-
|
|
7204
|
-
|
|
7205
|
-
})
|
|
7206
|
-
|
|
7207
|
-
|
|
7286
|
+
};
|
|
7287
|
+
#thorchainTransfer = async ({
|
|
7288
|
+
memo,
|
|
7289
|
+
assetValue
|
|
7290
|
+
}) => {
|
|
7291
|
+
const mimir = await SwapKitApi.getMimirInfo({ stagenet: this.stagenet });
|
|
7292
|
+
if (mimir.HALTCHAINGLOBAL >= 1 || mimir.HALTTHORCHAIN >= 1) {
|
|
7293
|
+
throw new SwapKitError2("core_chain_halted");
|
|
7294
|
+
}
|
|
7295
|
+
return this.deposit({ assetValue, recipient: "", memo });
|
|
7296
|
+
};
|
|
7297
|
+
#mayachainTransfer = async ({
|
|
7298
|
+
memo,
|
|
7299
|
+
assetValue
|
|
7300
|
+
}) => {
|
|
7301
|
+
const mimir = await SwapKitApi.getMimirInfo({ type: "mayachain", stagenet: this.stagenet });
|
|
7302
|
+
if (mimir.HALTCHAINGLOBAL >= 1 || mimir.HALTTHORCHAIN >= 1) {
|
|
7303
|
+
throw new SwapKitError2("core_chain_halted");
|
|
7304
|
+
}
|
|
7305
|
+
return this.deposit({ assetValue, recipient: "", memo });
|
|
7306
|
+
};
|
|
7307
|
+
#prepareTxParams = ({ assetValue, ...restTxParams }) => ({
|
|
7308
|
+
...restTxParams,
|
|
7309
|
+
memo: restTxParams.memo || "",
|
|
7310
|
+
from: this.getAddress(assetValue.chain),
|
|
7311
|
+
assetValue
|
|
7312
|
+
});
|
|
7208
7313
|
}
|
|
7209
|
-
|
|
7314
|
+
|
|
7315
|
+
// src/index.ts
|
|
7316
|
+
export * from "@swapkit/helpers";
|
|
7317
|
+
export * from "@swapkit/types";
|
|
7210
7318
|
export {
|
|
7211
|
-
|
|
7212
|
-
|
|
7213
|
-
|
|
7319
|
+
SwapKitCore,
|
|
7320
|
+
SwapKit,
|
|
7321
|
+
ApproveMode
|
|
7214
7322
|
};
|
|
7215
|
-
|
|
7323
|
+
|
|
7324
|
+
//# debugId=7476CD7A24100A4B64756e2164756e21
|