@pancakeswap/sdk 5.8.1 → 5.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,34 +1,16 @@
1
1
  'use strict';
2
2
 
3
- var chains = require('@pancakeswap/chains');
4
3
  var swapSdkCore = require('@pancakeswap/swap-sdk-core');
5
- var invariant5 = require('tiny-invariant');
6
- var viem = require('viem');
7
- var warning = require('tiny-warning');
8
- var chains$1 = require('viem/chains');
4
+ var v2Sdk = require('@pancakeswap/v2-sdk');
5
+ var swapSdkEvm = require('@pancakeswap/swap-sdk-evm');
6
+ var chains = require('@pancakeswap/chains');
7
+ var invariant = require('tiny-invariant');
9
8
 
10
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
10
 
12
- var invariant5__default = /*#__PURE__*/_interopDefault(invariant5);
13
- var warning__default = /*#__PURE__*/_interopDefault(warning);
11
+ var invariant__default = /*#__PURE__*/_interopDefault(invariant);
14
12
 
15
- // src/constants.ts
16
- function validateAndParseAddress(address) {
17
- try {
18
- const checksummedAddress = viem.getAddress(address);
19
- warning__default.default(address === checksummedAddress, `${address} is not checksummed.`);
20
- return checksummedAddress;
21
- } catch (error) {
22
- invariant5__default.default(false, `${address} is not a valid address.`);
23
- }
24
- }
25
-
26
- // src/entities/token.ts
27
- var ERC20Token = class extends swapSdkCore.Token {
28
- constructor(chainId, address, decimals, symbol, name, projectLink) {
29
- super(chainId, validateAndParseAddress(address), decimals, symbol, name, projectLink);
30
- }
31
- };
13
+ // src/index.ts
32
14
  var OnRampCurrency = class extends swapSdkCore.BaseCurrency {
33
15
  constructor(chainId, address, decimals, symbol, name, projectLink) {
34
16
  super(chainId, decimals, symbol, name);
@@ -53,8 +35,8 @@ var OnRampCurrency = class extends swapSdkCore.BaseCurrency {
53
35
  sortsBefore(other) {
54
36
  if (!other.isToken)
55
37
  return false;
56
- invariant5__default.default(this.chainId === other.chainId, "CHAIN_IDS");
57
- invariant5__default.default(this.address !== other.address, "ADDRESSES");
38
+ invariant__default.default(this.chainId === other.chainId, "CHAIN_IDS");
39
+ invariant__default.default(this.address !== other.address, "ADDRESSES");
58
40
  return this.address.toLowerCase() < other.address.toLowerCase();
59
41
  }
60
42
  /**
@@ -75,1793 +57,26 @@ var OnRampCurrency = class extends swapSdkCore.BaseCurrency {
75
57
  }
76
58
  };
77
59
 
78
- // src/constants.ts
79
- var ZERO_PERCENT = new swapSdkCore.Percent("0");
80
- var ONE_HUNDRED_PERCENT = new swapSdkCore.Percent("1");
81
- var FACTORY_ADDRESS = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73";
82
- var FACTORY_ADDRESS_ETH = "0x1097053Fd2ea711dad45caCcc45EfF7548fCB362";
83
- var FACTORY_ADDRESS_MAP = {
84
- [chains.ChainId.ETHEREUM]: FACTORY_ADDRESS_ETH,
85
- [chains.ChainId.GOERLI]: FACTORY_ADDRESS_ETH,
86
- [chains.ChainId.BSC]: FACTORY_ADDRESS,
87
- [chains.ChainId.BSC_TESTNET]: "0x6725F303b657a9451d8BA641348b6761A6CC7a17",
88
- [chains.ChainId.ARBITRUM_ONE]: "0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E",
89
- [chains.ChainId.ARBITRUM_GOERLI]: "0x333EAE459075b1d7dE8eb57997b5d4eee5F1070a",
90
- [chains.ChainId.POLYGON_ZKEVM]: "0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E",
91
- [chains.ChainId.POLYGON_ZKEVM_TESTNET]: "0xBA40c83026213F9cbc79998752721a0312bdB74a",
92
- [chains.ChainId.ZKSYNC]: "0xd03D8D566183F0086d8D09A84E1e30b58Dd5619d",
93
- [chains.ChainId.ZKSYNC_TESTNET]: "0x48a33610Cd0E130af2024D55F67aE72a8C51aC27",
94
- [chains.ChainId.LINEA]: "0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E",
95
- [chains.ChainId.LINEA_TESTNET]: "0xB6FAfd4ADbCd21cF665909767e0eD0D05709abfB",
96
- [chains.ChainId.OPBNB]: "0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E",
97
- [chains.ChainId.OPBNB_TESTNET]: "0x776e4bD2f72de2176A59465e316335aaf8ed4E8F",
98
- [chains.ChainId.BASE]: "0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E",
99
- [chains.ChainId.BASE_TESTNET]: "0x715303D2eF7dA7FFAbF637651D71FD11d41fAf7F",
100
- [chains.ChainId.SCROLL_SEPOLIA]: "0x2B3C5df29F73dbF028BA82C33e0A5A6e5800F75e",
101
- [chains.ChainId.SEPOLIA]: "0x1bdc540dEB9Ed1fA29964DeEcCc524A8f5e2198e",
102
- [chains.ChainId.ARBITRUM_SEPOLIA]: "0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E",
103
- [chains.ChainId.BASE_SEPOLIA]: "0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E"
104
- };
105
- var INIT_CODE_HASH = "0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5";
106
- var INIT_CODE_HASH_ETH = "0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d";
107
- var INIT_CODE_HASH_MAP = {
108
- [chains.ChainId.ETHEREUM]: INIT_CODE_HASH_ETH,
109
- [chains.ChainId.GOERLI]: INIT_CODE_HASH_ETH,
110
- [chains.ChainId.BSC]: INIT_CODE_HASH,
111
- [chains.ChainId.BSC_TESTNET]: "0xd0d4c4cd0848c93cb4fd1f498d7013ee6bfb25783ea21593d5834f5d250ece66",
112
- [chains.ChainId.ARBITRUM_ONE]: INIT_CODE_HASH_ETH,
113
- [chains.ChainId.ARBITRUM_GOERLI]: INIT_CODE_HASH_ETH,
114
- [chains.ChainId.POLYGON_ZKEVM]: INIT_CODE_HASH_ETH,
115
- [chains.ChainId.POLYGON_ZKEVM_TESTNET]: INIT_CODE_HASH_ETH,
116
- [chains.ChainId.ZKSYNC]: "0x0100045707a42494392b3558029b9869f865ff9df8f375dc1bf20b0555093f43",
117
- [chains.ChainId.ZKSYNC_TESTNET]: "0x0100045707a42494392b3558029b9869f865ff9df8f375dc1bf20b0555093f43",
118
- [chains.ChainId.LINEA]: INIT_CODE_HASH_ETH,
119
- [chains.ChainId.LINEA_TESTNET]: INIT_CODE_HASH_ETH,
120
- [chains.ChainId.OPBNB]: INIT_CODE_HASH_ETH,
121
- [chains.ChainId.OPBNB_TESTNET]: INIT_CODE_HASH_ETH,
122
- [chains.ChainId.BASE]: INIT_CODE_HASH_ETH,
123
- [chains.ChainId.BASE_TESTNET]: "0xa5934690703a592a07e841ca29d5e5c79b5e22ed4749057bb216dc31100be1c0",
124
- [chains.ChainId.SCROLL_SEPOLIA]: INIT_CODE_HASH_ETH,
125
- [chains.ChainId.SEPOLIA]: INIT_CODE_HASH_ETH,
126
- [chains.ChainId.ARBITRUM_SEPOLIA]: INIT_CODE_HASH_ETH,
127
- [chains.ChainId.BASE_SEPOLIA]: INIT_CODE_HASH_ETH
128
- };
129
- var WETH9 = {
130
- [chains.ChainId.ETHEREUM]: new ERC20Token(
131
- chains.ChainId.ETHEREUM,
132
- "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
133
- 18,
134
- "WETH",
135
- "Wrapped Ether",
136
- "https://weth.io"
137
- ),
138
- [chains.ChainId.GOERLI]: new ERC20Token(
139
- chains.ChainId.GOERLI,
140
- "0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6",
141
- 18,
142
- "WETH",
143
- "Wrapped Ether",
144
- "https://weth.io"
145
- ),
146
- [chains.ChainId.BSC]: new ERC20Token(
147
- chains.ChainId.BSC,
148
- "0x2170Ed0880ac9A755fd29B2688956BD959F933F8",
149
- 18,
150
- "ETH",
151
- "Binance-Peg Ethereum Token",
152
- "https://ethereum.org"
153
- ),
154
- [chains.ChainId.BSC_TESTNET]: new ERC20Token(
155
- chains.ChainId.BSC,
156
- "0xE7bCB9e341D546b66a46298f4893f5650a56e99E",
157
- 18,
158
- "ETH",
159
- "ETH",
160
- "https://ethereum.org"
161
- ),
162
- [chains.ChainId.ARBITRUM_ONE]: new ERC20Token(
163
- chains.ChainId.ARBITRUM_ONE,
164
- "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
165
- 18,
166
- "WETH",
167
- "Wrapped Ether",
168
- "https://weth.io"
169
- ),
170
- [chains.ChainId.ARBITRUM_GOERLI]: new ERC20Token(
171
- chains.ChainId.ARBITRUM_GOERLI,
172
- "0xEe01c0CD76354C383B8c7B4e65EA88D00B06f36f",
173
- 18,
174
- "WETH",
175
- "Wrapped Ether",
176
- "https://weth.io"
177
- ),
178
- [chains.ChainId.ZKSYNC]: new ERC20Token(
179
- chains.ChainId.ZKSYNC,
180
- "0x5AEa5775959fBC2557Cc8789bC1bf90A239D9a91",
181
- 18,
182
- "WETH",
183
- "Wrapped Ether",
184
- "https://weth.io"
185
- ),
186
- [chains.ChainId.ZKSYNC_TESTNET]: new ERC20Token(
187
- chains.ChainId.ZKSYNC_TESTNET,
188
- "0x02968DB286f24cB18bB5b24903eC8eBFAcf591C0",
189
- 18,
190
- "WETH",
191
- "Wrapped Ether",
192
- "https://weth.io"
193
- ),
194
- [chains.ChainId.POLYGON_ZKEVM]: new ERC20Token(
195
- chains.ChainId.POLYGON_ZKEVM,
196
- "0x4F9A0e7FD2Bf6067db6994CF12E4495Df938E6e9",
197
- 18,
198
- "WETH",
199
- "Wrapped Ether",
200
- "https://weth.io"
201
- ),
202
- [chains.ChainId.POLYGON_ZKEVM_TESTNET]: new ERC20Token(
203
- chains.ChainId.POLYGON_ZKEVM_TESTNET,
204
- "0x30ec47F7DFae72eA79646e6cf64a8A7db538915b",
205
- 18,
206
- "WETH",
207
- "Wrapped Ether",
208
- "https://weth.io"
209
- ),
210
- [chains.ChainId.LINEA]: new ERC20Token(
211
- chains.ChainId.LINEA,
212
- "0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f",
213
- 18,
214
- "WETH",
215
- "Wrapped Ether",
216
- "https://weth.io"
217
- ),
218
- [chains.ChainId.LINEA_TESTNET]: new ERC20Token(
219
- chains.ChainId.LINEA_TESTNET,
220
- "0x2C1b868d6596a18e32E61B901E4060C872647b6C",
221
- 18,
222
- "WETH",
223
- "Wrapped Ether",
224
- "https://weth.io"
225
- ),
226
- [chains.ChainId.OPBNB_TESTNET]: new ERC20Token(
227
- chains.ChainId.OPBNB_TESTNET,
228
- "0x584f7b986d9942B0859a1E6921efA5342A673d04",
229
- 18,
230
- "WETH",
231
- "Wrapped Ether",
232
- "https://weth.io"
233
- ),
234
- [chains.ChainId.OPBNB]: new ERC20Token(
235
- chains.ChainId.OPBNB,
236
- "0xE7798f023fC62146e8Aa1b36Da45fb70855a77Ea",
237
- 18,
238
- "ETH",
239
- "Binance-Peg Ethereum Token",
240
- "https://ethereum.org"
241
- ),
242
- [chains.ChainId.BASE]: new ERC20Token(
243
- chains.ChainId.BASE,
244
- "0x4200000000000000000000000000000000000006",
245
- 18,
246
- "WETH",
247
- "Wrapped Ether",
248
- "https://weth.io"
249
- ),
250
- [chains.ChainId.BASE_TESTNET]: new ERC20Token(
251
- chains.ChainId.BASE_TESTNET,
252
- "0x4200000000000000000000000000000000000006",
253
- 18,
254
- "WETH",
255
- "Wrapped Ether",
256
- "https://weth.io"
257
- ),
258
- [chains.ChainId.SCROLL_SEPOLIA]: new ERC20Token(
259
- chains.ChainId.SCROLL_SEPOLIA,
260
- "0x5300000000000000000000000000000000000004",
261
- 18,
262
- "WETH",
263
- "Wrapped Ether",
264
- "https://weth.io"
265
- ),
266
- [chains.ChainId.SEPOLIA]: new ERC20Token(
267
- chains.ChainId.SEPOLIA,
268
- "0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14",
269
- 18,
270
- "WETH",
271
- "Wrapped Ether",
272
- "https://weth.io"
273
- ),
274
- [chains.ChainId.ARBITRUM_SEPOLIA]: new ERC20Token(
275
- chains.ChainId.ARBITRUM_SEPOLIA,
276
- "0x1bdc540dEB9Ed1fA29964DeEcCc524A8f5e2198e",
277
- 18,
278
- "WETH",
279
- "Wrapped Ether",
280
- "https://weth.io"
281
- ),
282
- [chains.ChainId.BASE_SEPOLIA]: new ERC20Token(
283
- chains.ChainId.BASE_SEPOLIA,
284
- "0x4200000000000000000000000000000000000006",
285
- 18,
286
- "WETH",
287
- "Wrapped Ether",
288
- "https://weth.io"
289
- )
290
- };
291
- var WBNB = {
292
- [chains.ChainId.ETHEREUM]: new ERC20Token(
293
- chains.ChainId.ETHEREUM,
294
- "0x418D75f65a02b3D53B2418FB8E1fe493759c7605",
295
- 18,
296
- "WBNB",
297
- "Wrapped BNB",
298
- "https://www.binance.org"
299
- ),
300
- [chains.ChainId.BSC]: new ERC20Token(
301
- chains.ChainId.BSC,
302
- "0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",
303
- 18,
304
- "WBNB",
305
- "Wrapped BNB",
306
- "https://www.binance.org"
307
- ),
308
- [chains.ChainId.BSC_TESTNET]: new ERC20Token(
309
- chains.ChainId.BSC_TESTNET,
310
- "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
311
- 18,
312
- "WBNB",
313
- "Wrapped BNB",
314
- "https://www.binance.org"
315
- ),
316
- [chains.ChainId.OPBNB_TESTNET]: new ERC20Token(
317
- chains.ChainId.OPBNB_TESTNET,
318
- "0x4200000000000000000000000000000000000006",
319
- 18,
320
- "WBNB",
321
- "Wrapped BNB",
322
- "https://www.binance.org"
323
- ),
324
- [chains.ChainId.OPBNB]: new ERC20Token(
325
- chains.ChainId.OPBNB,
326
- "0x4200000000000000000000000000000000000006",
327
- 18,
328
- "WBNB",
329
- "Wrapped BNB",
330
- "https://www.binance.org"
331
- )
332
- };
333
- var WNATIVE = {
334
- [chains.ChainId.ETHEREUM]: WETH9[chains.ChainId.ETHEREUM],
335
- [chains.ChainId.GOERLI]: WETH9[chains.ChainId.GOERLI],
336
- [chains.ChainId.BSC]: WBNB[chains.ChainId.BSC],
337
- [chains.ChainId.BSC_TESTNET]: WBNB[chains.ChainId.BSC_TESTNET],
338
- [chains.ChainId.ARBITRUM_ONE]: WETH9[chains.ChainId.ARBITRUM_ONE],
339
- [chains.ChainId.ARBITRUM_GOERLI]: WETH9[chains.ChainId.ARBITRUM_GOERLI],
340
- [chains.ChainId.POLYGON_ZKEVM]: WETH9[chains.ChainId.POLYGON_ZKEVM],
341
- [chains.ChainId.POLYGON_ZKEVM_TESTNET]: WETH9[chains.ChainId.POLYGON_ZKEVM_TESTNET],
342
- [chains.ChainId.ZKSYNC]: WETH9[chains.ChainId.ZKSYNC],
343
- [chains.ChainId.ZKSYNC_TESTNET]: WETH9[chains.ChainId.ZKSYNC_TESTNET],
344
- [chains.ChainId.LINEA]: WETH9[chains.ChainId.LINEA],
345
- [chains.ChainId.LINEA_TESTNET]: WETH9[chains.ChainId.LINEA_TESTNET],
346
- [chains.ChainId.OPBNB_TESTNET]: WBNB[chains.ChainId.OPBNB_TESTNET],
347
- [chains.ChainId.OPBNB]: WBNB[chains.ChainId.OPBNB],
348
- [chains.ChainId.BASE]: WETH9[chains.ChainId.BASE],
349
- [chains.ChainId.BASE_TESTNET]: WETH9[chains.ChainId.BASE_TESTNET],
350
- [chains.ChainId.SCROLL_SEPOLIA]: WETH9[chains.ChainId.SCROLL_SEPOLIA],
351
- [chains.ChainId.SEPOLIA]: WETH9[chains.ChainId.SEPOLIA],
352
- [chains.ChainId.ARBITRUM_SEPOLIA]: WETH9[chains.ChainId.ARBITRUM_SEPOLIA],
353
- [chains.ChainId.BASE_SEPOLIA]: WETH9[chains.ChainId.BASE_SEPOLIA]
354
- };
355
- var ETHER = { name: "Ether", symbol: "ETH", decimals: 18 };
356
- var BNB = {
357
- name: "Binance Chain Native Token",
358
- symbol: "BNB",
359
- decimals: 18
360
- };
361
- var NATIVE = {
362
- [chains.ChainId.ETHEREUM]: ETHER,
363
- [chains.ChainId.GOERLI]: { name: "Goerli Ether", symbol: "GOR", decimals: 18 },
364
- [chains.ChainId.BSC]: BNB,
365
- [chains.ChainId.BSC_TESTNET]: {
366
- name: "Binance Chain Native Token",
367
- symbol: "tBNB",
368
- decimals: 18
369
- },
370
- [chains.ChainId.ARBITRUM_ONE]: ETHER,
371
- [chains.ChainId.ARBITRUM_GOERLI]: {
372
- name: "Arbitrum Goerli Ether",
373
- symbol: "AGOR",
374
- decimals: 18
375
- },
376
- [chains.ChainId.POLYGON_ZKEVM]: ETHER,
377
- [chains.ChainId.POLYGON_ZKEVM_TESTNET]: ETHER,
378
- [chains.ChainId.ZKSYNC]: ETHER,
379
- [chains.ChainId.ZKSYNC_TESTNET]: ETHER,
380
- [chains.ChainId.LINEA]: ETHER,
381
- [chains.ChainId.LINEA_TESTNET]: ETHER,
382
- [chains.ChainId.OPBNB]: BNB,
383
- [chains.ChainId.OPBNB_TESTNET]: {
384
- name: "Binance Chain Native Token",
385
- symbol: "tBNB",
386
- decimals: 18
387
- },
388
- [chains.ChainId.BASE]: ETHER,
389
- [chains.ChainId.BASE_TESTNET]: ETHER,
390
- [chains.ChainId.SCROLL_SEPOLIA]: ETHER,
391
- [chains.ChainId.SEPOLIA]: {
392
- name: "Sepolia Ether",
393
- symbol: "SEP",
394
- decimals: 18
395
- },
396
- [chains.ChainId.ARBITRUM_SEPOLIA]: {
397
- name: "Arbitrum Sepolia Ether",
398
- symbol: "ETH",
399
- decimals: 18
400
- },
401
- [chains.ChainId.BASE_SEPOLIA]: {
402
- name: "Sepolia Ether",
403
- symbol: "ETH",
404
- decimals: 18
405
- }
406
- };
407
-
408
- // src/trade.ts
409
- function isTradeBetter(tradeA, tradeB, minimumDelta = ZERO_PERCENT) {
410
- if (tradeA && !tradeB)
411
- return false;
412
- if (tradeB && !tradeA)
413
- return true;
414
- if (!tradeA || !tradeB)
415
- return void 0;
416
- if (tradeA.tradeType !== tradeB.tradeType || !tradeA.inputAmount.currency.equals(tradeB.inputAmount.currency) || !tradeA.outputAmount.currency.equals(tradeB.outputAmount.currency)) {
417
- throw new Error("Trades are not comparable");
418
- }
419
- if (minimumDelta.equalTo(ZERO_PERCENT)) {
420
- return tradeA.executionPrice.lessThan(tradeB.executionPrice);
421
- }
422
- return tradeA.executionPrice.asFraction.multiply(minimumDelta.add(ONE_HUNDRED_PERCENT)).lessThan(tradeB.executionPrice);
423
- }
424
- var PAIR_ADDRESS_CACHE = {};
425
- var composeKey = (token0, token1) => `${token0.chainId}-${token0.address}-${token1.address}`;
426
- function getCreate2Address(from_, salt_, initCodeHash) {
427
- const from = viem.toBytes(viem.getAddress(from_));
428
- const salt = viem.pad(viem.isBytes(salt_) ? salt_ : viem.toBytes(salt_), {
429
- size: 32
430
- });
431
- return viem.getAddress(viem.slice(viem.keccak256(viem.concat([viem.toBytes("0xff"), from, salt, viem.toBytes(initCodeHash)])), 12));
432
- }
433
- var EMPTY_INPU_HASH = "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470";
434
- var ZKSYNC_PREFIX = "0x2020dba91b30cc0006188af794c2fb30dd8520db7e2c088b7fc7c103c00ca494";
435
- function getCreate2AddressZkSync(from, salt, initCodeHash) {
436
- return viem.getAddress(
437
- `0x${viem.keccak256(viem.concat([ZKSYNC_PREFIX, viem.pad(from, { size: 32 }), salt, initCodeHash, EMPTY_INPU_HASH])).slice(26)}`
438
- );
439
- }
440
- var computePairAddress = ({
441
- factoryAddress,
442
- tokenA,
443
- tokenB
444
- }) => {
445
- const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA];
446
- const key = composeKey(token0, token1);
447
- if (PAIR_ADDRESS_CACHE?.[key] === void 0) {
448
- const getCreate2Address_ = token0.chainId === chains.ChainId.ZKSYNC_TESTNET || token1.chainId === chains.ChainId.ZKSYNC ? getCreate2AddressZkSync : getCreate2Address;
449
- PAIR_ADDRESS_CACHE = {
450
- ...PAIR_ADDRESS_CACHE,
451
- [key]: getCreate2Address_(
452
- factoryAddress,
453
- viem.keccak256(viem.encodePacked(["address", "address"], [token0.address, token1.address])),
454
- INIT_CODE_HASH_MAP[token0.chainId]
455
- )
456
- };
457
- }
458
- return PAIR_ADDRESS_CACHE[key];
459
- };
460
- var Pair = class {
461
- static getAddress(tokenA, tokenB) {
462
- return computePairAddress({
463
- factoryAddress: FACTORY_ADDRESS_MAP[tokenA.chainId],
464
- tokenA,
465
- tokenB
466
- });
467
- }
468
- constructor(currencyAmountA, tokenAmountB) {
469
- const tokenAmounts = currencyAmountA.currency.sortsBefore(tokenAmountB.currency) ? [currencyAmountA, tokenAmountB] : [tokenAmountB, currencyAmountA];
470
- this.liquidityToken = new ERC20Token(
471
- tokenAmounts[0].currency.chainId,
472
- Pair.getAddress(tokenAmounts[0].currency, tokenAmounts[1].currency),
473
- 18,
474
- "Cake-LP",
475
- "Pancake LPs"
476
- );
477
- this.tokenAmounts = tokenAmounts;
478
- }
479
- /**
480
- * Returns true if the token is either token0 or token1
481
- * @param token to check
482
- */
483
- involvesToken(token) {
484
- return token.equals(this.token0) || token.equals(this.token1);
485
- }
486
- /**
487
- * Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
488
- */
489
- get token0Price() {
490
- const result = this.tokenAmounts[1].divide(this.tokenAmounts[0]);
491
- return new swapSdkCore.Price(this.token0, this.token1, result.denominator, result.numerator);
492
- }
493
- /**
494
- * Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1
495
- */
496
- get token1Price() {
497
- const result = this.tokenAmounts[0].divide(this.tokenAmounts[1]);
498
- return new swapSdkCore.Price(this.token1, this.token0, result.denominator, result.numerator);
499
- }
500
- /**
501
- * Return the price of the given token in terms of the other token in the pair.
502
- * @param token token to return price of
503
- */
504
- priceOf(token) {
505
- invariant5__default.default(this.involvesToken(token), "TOKEN");
506
- return token.equals(this.token0) ? this.token0Price : this.token1Price;
507
- }
508
- /**
509
- * Returns the chain ID of the tokens in the pair.
510
- */
511
- get chainId() {
512
- return this.token0.chainId;
513
- }
514
- get token0() {
515
- return this.tokenAmounts[0].currency;
516
- }
517
- get token1() {
518
- return this.tokenAmounts[1].currency;
519
- }
520
- get reserve0() {
521
- return this.tokenAmounts[0];
522
- }
523
- get reserve1() {
524
- return this.tokenAmounts[1];
525
- }
526
- reserveOf(token) {
527
- invariant5__default.default(this.involvesToken(token), "TOKEN");
528
- return token.equals(this.token0) ? this.reserve0 : this.reserve1;
529
- }
530
- getOutputAmount(inputAmount) {
531
- invariant5__default.default(this.involvesToken(inputAmount.currency), "TOKEN");
532
- if (this.reserve0.quotient === swapSdkCore.ZERO || this.reserve1.quotient === swapSdkCore.ZERO) {
533
- throw new swapSdkCore.InsufficientReservesError();
534
- }
535
- const inputReserve = this.reserveOf(inputAmount.currency);
536
- const outputReserve = this.reserveOf(inputAmount.currency.equals(this.token0) ? this.token1 : this.token0);
537
- const inputAmountWithFee = inputAmount.quotient * swapSdkCore._9975;
538
- const numerator = inputAmountWithFee * outputReserve.quotient;
539
- const denominator = inputReserve.quotient * swapSdkCore._10000 + inputAmountWithFee;
540
- const outputAmount = swapSdkCore.CurrencyAmount.fromRawAmount(
541
- inputAmount.currency.equals(this.token0) ? this.token1 : this.token0,
542
- numerator / denominator
543
- );
544
- if (outputAmount.quotient === swapSdkCore.ZERO) {
545
- throw new swapSdkCore.InsufficientInputAmountError();
546
- }
547
- return [outputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))];
548
- }
549
- getInputAmount(outputAmount) {
550
- invariant5__default.default(this.involvesToken(outputAmount.currency), "TOKEN");
551
- if (this.reserve0.quotient === swapSdkCore.ZERO || this.reserve1.quotient === swapSdkCore.ZERO || outputAmount.quotient >= this.reserveOf(outputAmount.currency).quotient) {
552
- throw new swapSdkCore.InsufficientReservesError();
553
- }
554
- const outputReserve = this.reserveOf(outputAmount.currency);
555
- const inputReserve = this.reserveOf(outputAmount.currency.equals(this.token0) ? this.token1 : this.token0);
556
- const numerator = inputReserve.quotient * outputAmount.quotient * swapSdkCore._10000;
557
- const denominator = (outputReserve.quotient - outputAmount.quotient) * swapSdkCore._9975;
558
- const inputAmount = swapSdkCore.CurrencyAmount.fromRawAmount(
559
- outputAmount.currency.equals(this.token0) ? this.token1 : this.token0,
560
- numerator / denominator + swapSdkCore.ONE
561
- );
562
- return [inputAmount, new Pair(inputReserve.add(inputAmount), outputReserve.subtract(outputAmount))];
563
- }
564
- getLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB) {
565
- invariant5__default.default(totalSupply.currency.equals(this.liquidityToken), "LIQUIDITY");
566
- const tokenAmounts = tokenAmountA.currency.sortsBefore(tokenAmountB.currency) ? [tokenAmountA, tokenAmountB] : [tokenAmountB, tokenAmountA];
567
- invariant5__default.default(tokenAmounts[0].currency.equals(this.token0) && tokenAmounts[1].currency.equals(this.token1), "TOKEN");
568
- let liquidity;
569
- if (totalSupply.quotient === swapSdkCore.ZERO) {
570
- liquidity = swapSdkCore.sqrt(tokenAmounts[0].quotient * tokenAmounts[1].quotient) - swapSdkCore.MINIMUM_LIQUIDITY;
571
- } else {
572
- const amount0 = tokenAmounts[0].quotient * totalSupply.quotient / this.reserve0.quotient;
573
- const amount1 = tokenAmounts[1].quotient * totalSupply.quotient / this.reserve1.quotient;
574
- liquidity = amount0 <= amount1 ? amount0 : amount1;
575
- }
576
- if (!(liquidity > swapSdkCore.ZERO)) {
577
- throw new swapSdkCore.InsufficientInputAmountError();
578
- }
579
- return swapSdkCore.CurrencyAmount.fromRawAmount(this.liquidityToken, liquidity);
580
- }
581
- getLiquidityValue(token, totalSupply, liquidity, feeOn = false, kLast) {
582
- invariant5__default.default(this.involvesToken(token), "TOKEN");
583
- invariant5__default.default(totalSupply.currency.equals(this.liquidityToken), "TOTAL_SUPPLY");
584
- invariant5__default.default(liquidity.currency.equals(this.liquidityToken), "LIQUIDITY");
585
- invariant5__default.default(liquidity.quotient <= totalSupply.quotient, "LIQUIDITY");
586
- let totalSupplyAdjusted;
587
- if (!feeOn) {
588
- totalSupplyAdjusted = totalSupply;
589
- } else {
590
- invariant5__default.default(!!kLast, "K_LAST");
591
- const kLastParsed = BigInt(kLast);
592
- if (!(kLastParsed === swapSdkCore.ZERO)) {
593
- const rootK = swapSdkCore.sqrt(this.reserve0.quotient * this.reserve1.quotient);
594
- const rootKLast = swapSdkCore.sqrt(kLastParsed);
595
- if (rootK > rootKLast) {
596
- const numerator = totalSupply.quotient * (rootK - rootKLast);
597
- const denominator = rootK * swapSdkCore.FIVE + rootKLast;
598
- const feeLiquidity = numerator / denominator;
599
- totalSupplyAdjusted = totalSupply.add(swapSdkCore.CurrencyAmount.fromRawAmount(this.liquidityToken, feeLiquidity));
600
- } else {
601
- totalSupplyAdjusted = totalSupply;
602
- }
603
- } else {
604
- totalSupplyAdjusted = totalSupply;
605
- }
606
- }
607
- return swapSdkCore.CurrencyAmount.fromRawAmount(
608
- token,
609
- liquidity.quotient * this.reserveOf(token).quotient / totalSupplyAdjusted.quotient
610
- );
611
- }
612
- };
613
- var Route = class {
614
- constructor(pairs, input, output) {
615
- this._midPrice = null;
616
- invariant5__default.default(pairs.length > 0, "PAIRS");
617
- const { chainId } = pairs[0];
618
- invariant5__default.default(
619
- pairs.every((pair) => pair.chainId === chainId),
620
- "CHAIN_IDS"
621
- );
622
- const wrappedInput = input.wrapped;
623
- invariant5__default.default(pairs[0].involvesToken(wrappedInput), "INPUT");
624
- invariant5__default.default(typeof output === "undefined" || pairs[pairs.length - 1].involvesToken(output.wrapped), "OUTPUT");
625
- const path = [wrappedInput];
626
- for (const [i, pair] of pairs.entries()) {
627
- const currentInput = path[i];
628
- invariant5__default.default(currentInput.equals(pair.token0) || currentInput.equals(pair.token1), "PATH");
629
- const output2 = currentInput.equals(pair.token0) ? pair.token1 : pair.token0;
630
- path.push(output2);
631
- }
632
- this.pairs = pairs;
633
- this.path = path;
634
- this.input = input;
635
- this.output = output;
636
- }
637
- get midPrice() {
638
- if (this._midPrice !== null)
639
- return this._midPrice;
640
- const prices = [];
641
- for (const [i, pair] of this.pairs.entries()) {
642
- prices.push(
643
- this.path[i].equals(pair.token0) ? new swapSdkCore.Price(pair.reserve0.currency, pair.reserve1.currency, pair.reserve0.quotient, pair.reserve1.quotient) : new swapSdkCore.Price(pair.reserve1.currency, pair.reserve0.currency, pair.reserve1.quotient, pair.reserve0.quotient)
644
- );
645
- }
646
- const reduced = prices.slice(1).reduce((accumulator, currentValue) => accumulator.multiply(currentValue), prices[0]);
647
- return this._midPrice = new swapSdkCore.Price(this.input, this.output, reduced.denominator, reduced.numerator);
648
- }
649
- get chainId() {
650
- return this.pairs[0].chainId;
651
- }
652
- };
653
- function inputOutputComparator(a, b) {
654
- invariant5__default.default(a.inputAmount.currency.equals(b.inputAmount.currency), "INPUT_CURRENCY");
655
- invariant5__default.default(a.outputAmount.currency.equals(b.outputAmount.currency), "OUTPUT_CURRENCY");
656
- if (a.outputAmount.equalTo(b.outputAmount)) {
657
- if (a.inputAmount.equalTo(b.inputAmount)) {
658
- return 0;
659
- }
660
- if (a.inputAmount.lessThan(b.inputAmount)) {
661
- return -1;
662
- }
663
- return 1;
664
- }
665
- if (a.outputAmount.lessThan(b.outputAmount)) {
666
- return 1;
667
- }
668
- return -1;
669
- }
670
- function tradeComparator(a, b) {
671
- const ioComp = inputOutputComparator(a, b);
672
- if (ioComp !== 0) {
673
- return ioComp;
674
- }
675
- if (a.priceImpact.lessThan(b.priceImpact)) {
676
- return -1;
677
- }
678
- if (a.priceImpact.greaterThan(b.priceImpact)) {
679
- return 1;
680
- }
681
- return a.route.path.length - b.route.path.length;
682
- }
683
- var Trade = class {
684
- /**
685
- * Constructs an exact in trade with the given amount in and route
686
- * @param route route of the exact in trade
687
- * @param amountIn the amount being passed in
688
- */
689
- static exactIn(route, amountIn) {
690
- return new Trade(route, amountIn, swapSdkCore.TradeType.EXACT_INPUT);
691
- }
692
- /**
693
- * Constructs an exact out trade with the given amount out and route
694
- * @param route route of the exact out trade
695
- * @param amountOut the amount returned by the trade
696
- */
697
- static exactOut(route, amountOut) {
698
- return new Trade(route, amountOut, swapSdkCore.TradeType.EXACT_OUTPUT);
699
- }
700
- constructor(route, amount, tradeType) {
701
- this.route = route;
702
- this.tradeType = tradeType;
703
- const tokenAmounts = new Array(route.path.length);
704
- if (tradeType === swapSdkCore.TradeType.EXACT_INPUT) {
705
- invariant5__default.default(amount.currency.equals(route.input), "INPUT");
706
- tokenAmounts[0] = amount.wrapped;
707
- for (let i = 0; i < route.path.length - 1; i++) {
708
- const pair = route.pairs[i];
709
- const [outputAmount] = pair.getOutputAmount(tokenAmounts[i]);
710
- tokenAmounts[i + 1] = outputAmount;
711
- }
712
- this.inputAmount = swapSdkCore.CurrencyAmount.fromFractionalAmount(route.input, amount.numerator, amount.denominator);
713
- this.outputAmount = swapSdkCore.CurrencyAmount.fromFractionalAmount(
714
- route.output,
715
- tokenAmounts[tokenAmounts.length - 1].numerator,
716
- tokenAmounts[tokenAmounts.length - 1].denominator
717
- );
718
- } else {
719
- invariant5__default.default(amount.currency.equals(route.output), "OUTPUT");
720
- tokenAmounts[tokenAmounts.length - 1] = amount.wrapped;
721
- for (let i = route.path.length - 1; i > 0; i--) {
722
- const pair = route.pairs[i - 1];
723
- const [inputAmount] = pair.getInputAmount(tokenAmounts[i]);
724
- tokenAmounts[i - 1] = inputAmount;
725
- }
726
- this.inputAmount = swapSdkCore.CurrencyAmount.fromFractionalAmount(
727
- route.input,
728
- tokenAmounts[0].numerator,
729
- tokenAmounts[0].denominator
730
- );
731
- this.outputAmount = swapSdkCore.CurrencyAmount.fromFractionalAmount(route.output, amount.numerator, amount.denominator);
732
- }
733
- this.executionPrice = new swapSdkCore.Price(
734
- this.inputAmount.currency,
735
- this.outputAmount.currency,
736
- this.inputAmount.quotient,
737
- this.outputAmount.quotient
738
- );
739
- this.priceImpact = swapSdkCore.computePriceImpact(route.midPrice, this.inputAmount, this.outputAmount);
740
- }
741
- /**
742
- * Get the minimum amount that must be received from this trade for the given slippage tolerance
743
- * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
744
- */
745
- minimumAmountOut(slippageTolerance) {
746
- invariant5__default.default(!slippageTolerance.lessThan(swapSdkCore.ZERO), "SLIPPAGE_TOLERANCE");
747
- if (this.tradeType === swapSdkCore.TradeType.EXACT_OUTPUT) {
748
- return this.outputAmount;
749
- }
750
- const slippageAdjustedAmountOut = new swapSdkCore.Fraction(swapSdkCore.ONE).add(slippageTolerance).invert().multiply(this.outputAmount.quotient).quotient;
751
- return swapSdkCore.CurrencyAmount.fromRawAmount(this.outputAmount.currency, slippageAdjustedAmountOut);
752
- }
753
- /**
754
- * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
755
- * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
756
- */
757
- maximumAmountIn(slippageTolerance) {
758
- invariant5__default.default(!slippageTolerance.lessThan(swapSdkCore.ZERO), "SLIPPAGE_TOLERANCE");
759
- if (this.tradeType === swapSdkCore.TradeType.EXACT_INPUT) {
760
- return this.inputAmount;
761
- }
762
- const slippageAdjustedAmountIn = new swapSdkCore.Fraction(swapSdkCore.ONE).add(slippageTolerance).multiply(this.inputAmount.quotient).quotient;
763
- return swapSdkCore.CurrencyAmount.fromRawAmount(this.inputAmount.currency, slippageAdjustedAmountIn);
764
- }
765
- /**
766
- * Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
767
- * amount to an output token, making at most `maxHops` hops.
768
- * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
769
- * the amount in among multiple routes.
770
- * @param pairs the pairs to consider in finding the best trade
771
- * @param nextAmountIn exact amount of input currency to spend
772
- * @param currencyOut the desired currency out
773
- * @param maxNumResults maximum number of results to return
774
- * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
775
- * @param currentPairs used in recursion; the current list of pairs
776
- * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
777
- * @param bestTrades used in recursion; the current list of best trades
778
- */
779
- static bestTradeExactIn(pairs, currencyAmountIn, currencyOut, { maxNumResults = 3, maxHops = 3 } = {}, currentPairs = [], nextAmountIn = currencyAmountIn, bestTrades = []) {
780
- invariant5__default.default(pairs.length > 0, "PAIRS");
781
- invariant5__default.default(maxHops > 0, "MAX_HOPS");
782
- invariant5__default.default(currencyAmountIn === nextAmountIn || currentPairs.length > 0, "INVALID_RECURSION");
783
- const amountIn = nextAmountIn.wrapped;
784
- const tokenOut = currencyOut.wrapped;
785
- for (let i = 0; i < pairs.length; i++) {
786
- const pair = pairs[i];
787
- if (!pair.token0.equals(amountIn.currency) && !pair.token1.equals(amountIn.currency))
788
- continue;
789
- if (pair.reserve0.equalTo(swapSdkCore.ZERO) || pair.reserve1.equalTo(swapSdkCore.ZERO))
790
- continue;
791
- let amountOut;
792
- try {
793
- ;
794
- [amountOut] = pair.getOutputAmount(amountIn);
795
- } catch (error) {
796
- if (error.isInsufficientInputAmountError) {
797
- continue;
798
- }
799
- throw error;
800
- }
801
- if (amountOut.currency.equals(tokenOut)) {
802
- swapSdkCore.sortedInsert(
803
- bestTrades,
804
- new Trade(
805
- new Route([...currentPairs, pair], currencyAmountIn.currency, currencyOut),
806
- currencyAmountIn,
807
- swapSdkCore.TradeType.EXACT_INPUT
808
- ),
809
- maxNumResults,
810
- tradeComparator
811
- );
812
- } else if (maxHops > 1 && pairs.length > 1) {
813
- const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
814
- Trade.bestTradeExactIn(
815
- pairsExcludingThisPair,
816
- currencyAmountIn,
817
- currencyOut,
818
- {
819
- maxNumResults,
820
- maxHops: maxHops - 1
821
- },
822
- [...currentPairs, pair],
823
- amountOut,
824
- bestTrades
825
- );
826
- }
827
- }
828
- return bestTrades;
829
- }
830
- /**
831
- * Return the execution price after accounting for slippage tolerance
832
- * @param slippageTolerance the allowed tolerated slippage
833
- */
834
- worstExecutionPrice(slippageTolerance) {
835
- return new swapSdkCore.Price(
836
- this.inputAmount.currency,
837
- this.outputAmount.currency,
838
- this.maximumAmountIn(slippageTolerance).quotient,
839
- this.minimumAmountOut(slippageTolerance).quotient
840
- );
841
- }
842
- /**
843
- * similar to the above method but instead targets a fixed output amount
844
- * given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
845
- * to an output token amount, making at most `maxHops` hops
846
- * note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting
847
- * the amount in among multiple routes.
848
- * @param pairs the pairs to consider in finding the best trade
849
- * @param currencyIn the currency to spend
850
- * @param nextAmountOut the exact amount of currency out
851
- * @param maxNumResults maximum number of results to return
852
- * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
853
- * @param currentPairs used in recursion; the current list of pairs
854
- * @param currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter
855
- * @param bestTrades used in recursion; the current list of best trades
856
- */
857
- static bestTradeExactOut(pairs, currencyIn, currencyAmountOut, { maxNumResults = 3, maxHops = 3 } = {}, currentPairs = [], nextAmountOut = currencyAmountOut, bestTrades = []) {
858
- invariant5__default.default(pairs.length > 0, "PAIRS");
859
- invariant5__default.default(maxHops > 0, "MAX_HOPS");
860
- invariant5__default.default(currencyAmountOut === nextAmountOut || currentPairs.length > 0, "INVALID_RECURSION");
861
- const amountOut = nextAmountOut.wrapped;
862
- const tokenIn = currencyIn.wrapped;
863
- for (let i = 0; i < pairs.length; i++) {
864
- const pair = pairs[i];
865
- if (!pair.token0.equals(amountOut.currency) && !pair.token1.equals(amountOut.currency))
866
- continue;
867
- if (pair.reserve0.equalTo(swapSdkCore.ZERO) || pair.reserve1.equalTo(swapSdkCore.ZERO))
868
- continue;
869
- let amountIn;
870
- try {
871
- ;
872
- [amountIn] = pair.getInputAmount(amountOut);
873
- } catch (error) {
874
- if (error.isInsufficientReservesError) {
875
- continue;
876
- }
877
- throw error;
878
- }
879
- if (amountIn.currency.equals(tokenIn)) {
880
- swapSdkCore.sortedInsert(
881
- bestTrades,
882
- new Trade(
883
- new Route([pair, ...currentPairs], currencyIn, currencyAmountOut.currency),
884
- currencyAmountOut,
885
- swapSdkCore.TradeType.EXACT_OUTPUT
886
- ),
887
- maxNumResults,
888
- tradeComparator
889
- );
890
- } else if (maxHops > 1 && pairs.length > 1) {
891
- const pairsExcludingThisPair = pairs.slice(0, i).concat(pairs.slice(i + 1, pairs.length));
892
- Trade.bestTradeExactOut(
893
- pairsExcludingThisPair,
894
- currencyIn,
895
- currencyAmountOut,
896
- {
897
- maxNumResults,
898
- maxHops: maxHops - 1
899
- },
900
- [pair, ...currentPairs],
901
- amountIn,
902
- bestTrades
903
- );
904
- }
905
- }
906
- return bestTrades;
907
- }
908
- };
909
- var _Native = class extends swapSdkCore.NativeCurrency {
910
- constructor({
911
- chainId,
912
- decimals,
913
- name,
914
- symbol
915
- }) {
916
- super(chainId, decimals, symbol, name);
917
- }
918
- get wrapped() {
919
- const wnative = WNATIVE[this.chainId];
920
- invariant5__default.default(!!wnative, "WRAPPED");
921
- return wnative;
922
- }
923
- static onChain(chainId) {
924
- if (chainId in this.cache) {
925
- return this.cache[chainId];
926
- }
927
- invariant5__default.default(!!NATIVE[chainId], "NATIVE_CURRENCY");
928
- const { decimals, name, symbol } = NATIVE[chainId];
929
- return this.cache[chainId] = new _Native({ chainId, decimals, symbol, name });
930
- }
931
- equals(other) {
932
- return other.isNative && other.chainId === this.chainId;
933
- }
934
- };
935
- var Native = _Native;
936
- Native.cache = {};
937
- function toHex(currencyAmount) {
938
- return `0x${currencyAmount.quotient.toString(16)}`;
939
- }
940
- var ZERO_HEX = "0x0";
941
- var Router = class {
942
- /**
943
- * Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
944
- * @param trade to produce call parameters for
945
- * @param options options for the call parameters
946
- */
947
- static swapCallParameters(trade, options) {
948
- const etherIn = trade.inputAmount.currency.isNative;
949
- const etherOut = trade.outputAmount.currency.isNative;
950
- invariant5__default.default(!(etherIn && etherOut), "ETHER_IN_OUT");
951
- invariant5__default.default(!("ttl" in options) || options.ttl > 0, "TTL");
952
- const to = validateAndParseAddress(options.recipient);
953
- const amountIn = toHex(trade.maximumAmountIn(options.allowedSlippage));
954
- const amountOut = toHex(trade.minimumAmountOut(options.allowedSlippage));
955
- const path = trade.route.path.map((token) => token.address);
956
- const deadline = "ttl" in options ? `0x${(Math.floor(( new Date()).getTime() / 1e3) + options.ttl).toString(16)}` : `0x${options.deadline.toString(16)}`;
957
- const useFeeOnTransfer = Boolean(options.feeOnTransfer);
958
- let methodName;
959
- let args;
960
- let value;
961
- switch (trade.tradeType) {
962
- case swapSdkCore.TradeType.EXACT_INPUT:
963
- if (etherIn) {
964
- methodName = useFeeOnTransfer ? "swapExactETHForTokensSupportingFeeOnTransferTokens" : "swapExactETHForTokens";
965
- args = [amountOut, path, to, deadline];
966
- value = amountIn;
967
- } else if (etherOut) {
968
- methodName = useFeeOnTransfer ? "swapExactTokensForETHSupportingFeeOnTransferTokens" : "swapExactTokensForETH";
969
- args = [amountIn, amountOut, path, to, deadline];
970
- value = ZERO_HEX;
971
- } else {
972
- methodName = useFeeOnTransfer ? "swapExactTokensForTokensSupportingFeeOnTransferTokens" : "swapExactTokensForTokens";
973
- args = [amountIn, amountOut, path, to, deadline];
974
- value = ZERO_HEX;
975
- }
976
- break;
977
- case swapSdkCore.TradeType.EXACT_OUTPUT:
978
- invariant5__default.default(!useFeeOnTransfer, "EXACT_OUT_FOT");
979
- if (etherIn) {
980
- methodName = "swapETHForExactTokens";
981
- args = [amountOut, path, to, deadline];
982
- value = amountIn;
983
- } else if (etherOut) {
984
- methodName = "swapTokensForExactETH";
985
- args = [amountOut, amountIn, path, to, deadline];
986
- value = ZERO_HEX;
987
- } else {
988
- methodName = "swapTokensForExactTokens";
989
- args = [amountOut, amountIn, path, to, deadline];
990
- value = ZERO_HEX;
991
- }
992
- break;
993
- }
994
- return {
995
- methodName,
996
- args,
997
- value
998
- };
999
- }
1000
- };
1001
- var _Ether = class extends swapSdkCore.NativeCurrency {
1002
- constructor(chainId) {
1003
- super(chainId, 18, "ETH", "Ether");
1004
- }
1005
- get wrapped() {
1006
- const weth9 = WETH9[this.chainId];
1007
- invariant5__default.default(!!weth9, "WRAPPED");
1008
- return weth9;
1009
- }
1010
- static onChain(chainId) {
1011
- if (!this._etherCache[chainId]) {
1012
- this._etherCache[chainId] = new _Ether(chainId);
1013
- }
1014
- return this._etherCache[chainId];
1015
- }
1016
- equals(other) {
1017
- return other.isNative && other.chainId === this.chainId;
1018
- }
1019
- };
1020
- var Ether = _Ether;
1021
- Ether._etherCache = {};
1022
-
1023
- // src/abis/ERC20.ts
1024
- var erc20Abi = [
1025
- {
1026
- constant: true,
1027
- inputs: [],
1028
- name: "decimals",
1029
- outputs: [{ name: "", type: "uint8" }],
1030
- payable: false,
1031
- stateMutability: "view",
1032
- type: "function"
1033
- },
1034
- {
1035
- constant: true,
1036
- inputs: [{ name: "", type: "address" }],
1037
- name: "balanceOf",
1038
- outputs: [{ name: "", type: "uint256" }],
1039
- payable: false,
1040
- stateMutability: "view",
1041
- type: "function"
1042
- }
1043
- ];
1044
-
1045
- // src/abis/IPancakePair.ts
1046
- var pancakePairV2ABI = [
1047
- {
1048
- anonymous: false,
1049
- inputs: [
1050
- {
1051
- indexed: true,
1052
- internalType: "address",
1053
- name: "owner",
1054
- type: "address"
1055
- },
1056
- {
1057
- indexed: true,
1058
- internalType: "address",
1059
- name: "spender",
1060
- type: "address"
1061
- },
1062
- {
1063
- indexed: false,
1064
- internalType: "uint256",
1065
- name: "value",
1066
- type: "uint256"
1067
- }
1068
- ],
1069
- name: "Approval",
1070
- type: "event"
1071
- },
1072
- {
1073
- anonymous: false,
1074
- inputs: [
1075
- {
1076
- indexed: true,
1077
- internalType: "address",
1078
- name: "sender",
1079
- type: "address"
1080
- },
1081
- {
1082
- indexed: false,
1083
- internalType: "uint256",
1084
- name: "amount0",
1085
- type: "uint256"
1086
- },
1087
- {
1088
- indexed: false,
1089
- internalType: "uint256",
1090
- name: "amount1",
1091
- type: "uint256"
1092
- },
1093
- {
1094
- indexed: true,
1095
- internalType: "address",
1096
- name: "to",
1097
- type: "address"
1098
- }
1099
- ],
1100
- name: "Burn",
1101
- type: "event"
1102
- },
1103
- {
1104
- anonymous: false,
1105
- inputs: [
1106
- {
1107
- indexed: true,
1108
- internalType: "address",
1109
- name: "sender",
1110
- type: "address"
1111
- },
1112
- {
1113
- indexed: false,
1114
- internalType: "uint256",
1115
- name: "amount0",
1116
- type: "uint256"
1117
- },
1118
- {
1119
- indexed: false,
1120
- internalType: "uint256",
1121
- name: "amount1",
1122
- type: "uint256"
1123
- }
1124
- ],
1125
- name: "Mint",
1126
- type: "event"
1127
- },
1128
- {
1129
- anonymous: false,
1130
- inputs: [
1131
- {
1132
- indexed: true,
1133
- internalType: "address",
1134
- name: "sender",
1135
- type: "address"
1136
- },
1137
- {
1138
- indexed: false,
1139
- internalType: "uint256",
1140
- name: "amount0In",
1141
- type: "uint256"
1142
- },
1143
- {
1144
- indexed: false,
1145
- internalType: "uint256",
1146
- name: "amount1In",
1147
- type: "uint256"
1148
- },
1149
- {
1150
- indexed: false,
1151
- internalType: "uint256",
1152
- name: "amount0Out",
1153
- type: "uint256"
1154
- },
1155
- {
1156
- indexed: false,
1157
- internalType: "uint256",
1158
- name: "amount1Out",
1159
- type: "uint256"
1160
- },
1161
- {
1162
- indexed: true,
1163
- internalType: "address",
1164
- name: "to",
1165
- type: "address"
1166
- }
1167
- ],
1168
- name: "Swap",
1169
- type: "event"
1170
- },
1171
- {
1172
- anonymous: false,
1173
- inputs: [
1174
- {
1175
- indexed: false,
1176
- internalType: "uint112",
1177
- name: "reserve0",
1178
- type: "uint112"
1179
- },
1180
- {
1181
- indexed: false,
1182
- internalType: "uint112",
1183
- name: "reserve1",
1184
- type: "uint112"
1185
- }
1186
- ],
1187
- name: "Sync",
1188
- type: "event"
1189
- },
1190
- {
1191
- anonymous: false,
1192
- inputs: [
1193
- {
1194
- indexed: true,
1195
- internalType: "address",
1196
- name: "from",
1197
- type: "address"
1198
- },
1199
- {
1200
- indexed: true,
1201
- internalType: "address",
1202
- name: "to",
1203
- type: "address"
1204
- },
1205
- {
1206
- indexed: false,
1207
- internalType: "uint256",
1208
- name: "value",
1209
- type: "uint256"
1210
- }
1211
- ],
1212
- name: "Transfer",
1213
- type: "event"
1214
- },
1215
- {
1216
- constant: true,
1217
- inputs: [],
1218
- name: "DOMAIN_SEPARATOR",
1219
- outputs: [
1220
- {
1221
- internalType: "bytes32",
1222
- name: "",
1223
- type: "bytes32"
1224
- }
1225
- ],
1226
- payable: false,
1227
- stateMutability: "view",
1228
- type: "function"
1229
- },
1230
- {
1231
- constant: true,
1232
- inputs: [],
1233
- name: "MINIMUM_LIQUIDITY",
1234
- outputs: [
1235
- {
1236
- internalType: "uint256",
1237
- name: "",
1238
- type: "uint256"
1239
- }
1240
- ],
1241
- payable: false,
1242
- stateMutability: "pure",
1243
- type: "function"
1244
- },
1245
- {
1246
- constant: true,
1247
- inputs: [],
1248
- name: "PERMIT_TYPEHASH",
1249
- outputs: [
1250
- {
1251
- internalType: "bytes32",
1252
- name: "",
1253
- type: "bytes32"
1254
- }
1255
- ],
1256
- payable: false,
1257
- stateMutability: "pure",
1258
- type: "function"
1259
- },
1260
- {
1261
- constant: true,
1262
- inputs: [
1263
- {
1264
- internalType: "address",
1265
- name: "owner",
1266
- type: "address"
1267
- },
1268
- {
1269
- internalType: "address",
1270
- name: "spender",
1271
- type: "address"
1272
- }
1273
- ],
1274
- name: "allowance",
1275
- outputs: [
1276
- {
1277
- internalType: "uint256",
1278
- name: "",
1279
- type: "uint256"
1280
- }
1281
- ],
1282
- payable: false,
1283
- stateMutability: "view",
1284
- type: "function"
1285
- },
1286
- {
1287
- constant: false,
1288
- inputs: [
1289
- {
1290
- internalType: "address",
1291
- name: "spender",
1292
- type: "address"
1293
- },
1294
- {
1295
- internalType: "uint256",
1296
- name: "value",
1297
- type: "uint256"
1298
- }
1299
- ],
1300
- name: "approve",
1301
- outputs: [
1302
- {
1303
- internalType: "bool",
1304
- name: "",
1305
- type: "bool"
1306
- }
1307
- ],
1308
- payable: false,
1309
- stateMutability: "nonpayable",
1310
- type: "function"
1311
- },
1312
- {
1313
- constant: true,
1314
- inputs: [
1315
- {
1316
- internalType: "address",
1317
- name: "owner",
1318
- type: "address"
1319
- }
1320
- ],
1321
- name: "balanceOf",
1322
- outputs: [
1323
- {
1324
- internalType: "uint256",
1325
- name: "",
1326
- type: "uint256"
1327
- }
1328
- ],
1329
- payable: false,
1330
- stateMutability: "view",
1331
- type: "function"
1332
- },
1333
- {
1334
- constant: false,
1335
- inputs: [
1336
- {
1337
- internalType: "address",
1338
- name: "to",
1339
- type: "address"
1340
- }
1341
- ],
1342
- name: "burn",
1343
- outputs: [
1344
- {
1345
- internalType: "uint256",
1346
- name: "amount0",
1347
- type: "uint256"
1348
- },
1349
- {
1350
- internalType: "uint256",
1351
- name: "amount1",
1352
- type: "uint256"
1353
- }
1354
- ],
1355
- payable: false,
1356
- stateMutability: "nonpayable",
1357
- type: "function"
1358
- },
1359
- {
1360
- constant: true,
1361
- inputs: [],
1362
- name: "decimals",
1363
- outputs: [
1364
- {
1365
- internalType: "uint8",
1366
- name: "",
1367
- type: "uint8"
1368
- }
1369
- ],
1370
- payable: false,
1371
- stateMutability: "pure",
1372
- type: "function"
1373
- },
1374
- {
1375
- constant: true,
1376
- inputs: [],
1377
- name: "factory",
1378
- outputs: [
1379
- {
1380
- internalType: "address",
1381
- name: "",
1382
- type: "address"
1383
- }
1384
- ],
1385
- payable: false,
1386
- stateMutability: "view",
1387
- type: "function"
1388
- },
1389
- {
1390
- constant: true,
1391
- inputs: [],
1392
- name: "getReserves",
1393
- outputs: [
1394
- {
1395
- internalType: "uint112",
1396
- name: "reserve0",
1397
- type: "uint112"
1398
- },
1399
- {
1400
- internalType: "uint112",
1401
- name: "reserve1",
1402
- type: "uint112"
1403
- },
1404
- {
1405
- internalType: "uint32",
1406
- name: "blockTimestampLast",
1407
- type: "uint32"
1408
- }
1409
- ],
1410
- payable: false,
1411
- stateMutability: "view",
1412
- type: "function"
1413
- },
1414
- {
1415
- constant: false,
1416
- inputs: [
1417
- {
1418
- internalType: "address",
1419
- name: "",
1420
- type: "address"
1421
- },
1422
- {
1423
- internalType: "address",
1424
- name: "",
1425
- type: "address"
1426
- }
1427
- ],
1428
- name: "initialize",
1429
- outputs: [],
1430
- payable: false,
1431
- stateMutability: "nonpayable",
1432
- type: "function"
1433
- },
1434
- {
1435
- constant: true,
1436
- inputs: [],
1437
- name: "kLast",
1438
- outputs: [
1439
- {
1440
- internalType: "uint256",
1441
- name: "",
1442
- type: "uint256"
1443
- }
1444
- ],
1445
- payable: false,
1446
- stateMutability: "view",
1447
- type: "function"
1448
- },
1449
- {
1450
- constant: false,
1451
- inputs: [
1452
- {
1453
- internalType: "address",
1454
- name: "to",
1455
- type: "address"
1456
- }
1457
- ],
1458
- name: "mint",
1459
- outputs: [
1460
- {
1461
- internalType: "uint256",
1462
- name: "liquidity",
1463
- type: "uint256"
1464
- }
1465
- ],
1466
- payable: false,
1467
- stateMutability: "nonpayable",
1468
- type: "function"
1469
- },
1470
- {
1471
- constant: true,
1472
- inputs: [],
1473
- name: "name",
1474
- outputs: [
1475
- {
1476
- internalType: "string",
1477
- name: "",
1478
- type: "string"
1479
- }
1480
- ],
1481
- payable: false,
1482
- stateMutability: "pure",
1483
- type: "function"
1484
- },
1485
- {
1486
- constant: true,
1487
- inputs: [
1488
- {
1489
- internalType: "address",
1490
- name: "owner",
1491
- type: "address"
1492
- }
1493
- ],
1494
- name: "nonces",
1495
- outputs: [
1496
- {
1497
- internalType: "uint256",
1498
- name: "",
1499
- type: "uint256"
1500
- }
1501
- ],
1502
- payable: false,
1503
- stateMutability: "view",
1504
- type: "function"
1505
- },
1506
- {
1507
- constant: false,
1508
- inputs: [
1509
- {
1510
- internalType: "address",
1511
- name: "owner",
1512
- type: "address"
1513
- },
1514
- {
1515
- internalType: "address",
1516
- name: "spender",
1517
- type: "address"
1518
- },
1519
- {
1520
- internalType: "uint256",
1521
- name: "value",
1522
- type: "uint256"
1523
- },
1524
- {
1525
- internalType: "uint256",
1526
- name: "deadline",
1527
- type: "uint256"
1528
- },
1529
- {
1530
- internalType: "uint8",
1531
- name: "v",
1532
- type: "uint8"
1533
- },
1534
- {
1535
- internalType: "bytes32",
1536
- name: "r",
1537
- type: "bytes32"
1538
- },
1539
- {
1540
- internalType: "bytes32",
1541
- name: "s",
1542
- type: "bytes32"
1543
- }
1544
- ],
1545
- name: "permit",
1546
- outputs: [],
1547
- payable: false,
1548
- stateMutability: "nonpayable",
1549
- type: "function"
1550
- },
1551
- {
1552
- constant: true,
1553
- inputs: [],
1554
- name: "price0CumulativeLast",
1555
- outputs: [
1556
- {
1557
- internalType: "uint256",
1558
- name: "",
1559
- type: "uint256"
1560
- }
1561
- ],
1562
- payable: false,
1563
- stateMutability: "view",
1564
- type: "function"
1565
- },
1566
- {
1567
- constant: true,
1568
- inputs: [],
1569
- name: "price1CumulativeLast",
1570
- outputs: [
1571
- {
1572
- internalType: "uint256",
1573
- name: "",
1574
- type: "uint256"
1575
- }
1576
- ],
1577
- payable: false,
1578
- stateMutability: "view",
1579
- type: "function"
1580
- },
1581
- {
1582
- constant: false,
1583
- inputs: [
1584
- {
1585
- internalType: "address",
1586
- name: "to",
1587
- type: "address"
1588
- }
1589
- ],
1590
- name: "skim",
1591
- outputs: [],
1592
- payable: false,
1593
- stateMutability: "nonpayable",
1594
- type: "function"
1595
- },
1596
- {
1597
- constant: false,
1598
- inputs: [
1599
- {
1600
- internalType: "uint256",
1601
- name: "amount0Out",
1602
- type: "uint256"
1603
- },
1604
- {
1605
- internalType: "uint256",
1606
- name: "amount1Out",
1607
- type: "uint256"
1608
- },
1609
- {
1610
- internalType: "address",
1611
- name: "to",
1612
- type: "address"
1613
- },
1614
- {
1615
- internalType: "bytes",
1616
- name: "data",
1617
- type: "bytes"
1618
- }
1619
- ],
1620
- name: "swap",
1621
- outputs: [],
1622
- payable: false,
1623
- stateMutability: "nonpayable",
1624
- type: "function"
1625
- },
1626
- {
1627
- constant: true,
1628
- inputs: [],
1629
- name: "symbol",
1630
- outputs: [
1631
- {
1632
- internalType: "string",
1633
- name: "",
1634
- type: "string"
1635
- }
1636
- ],
1637
- payable: false,
1638
- stateMutability: "pure",
1639
- type: "function"
1640
- },
1641
- {
1642
- constant: false,
1643
- inputs: [],
1644
- name: "sync",
1645
- outputs: [],
1646
- payable: false,
1647
- stateMutability: "nonpayable",
1648
- type: "function"
1649
- },
1650
- {
1651
- constant: true,
1652
- inputs: [],
1653
- name: "token0",
1654
- outputs: [
1655
- {
1656
- internalType: "address",
1657
- name: "",
1658
- type: "address"
1659
- }
1660
- ],
1661
- payable: false,
1662
- stateMutability: "view",
1663
- type: "function"
1664
- },
1665
- {
1666
- constant: true,
1667
- inputs: [],
1668
- name: "token1",
1669
- outputs: [
1670
- {
1671
- internalType: "address",
1672
- name: "",
1673
- type: "address"
1674
- }
1675
- ],
1676
- payable: false,
1677
- stateMutability: "view",
1678
- type: "function"
1679
- },
1680
- {
1681
- constant: true,
1682
- inputs: [],
1683
- name: "totalSupply",
1684
- outputs: [
1685
- {
1686
- internalType: "uint256",
1687
- name: "",
1688
- type: "uint256"
1689
- }
1690
- ],
1691
- payable: false,
1692
- stateMutability: "view",
1693
- type: "function"
1694
- },
1695
- {
1696
- constant: false,
1697
- inputs: [
1698
- {
1699
- internalType: "address",
1700
- name: "to",
1701
- type: "address"
1702
- },
1703
- {
1704
- internalType: "uint256",
1705
- name: "value",
1706
- type: "uint256"
1707
- }
1708
- ],
1709
- name: "transfer",
1710
- outputs: [
1711
- {
1712
- internalType: "bool",
1713
- name: "",
1714
- type: "bool"
1715
- }
1716
- ],
1717
- payable: false,
1718
- stateMutability: "nonpayable",
1719
- type: "function"
1720
- },
1721
- {
1722
- constant: false,
1723
- inputs: [
1724
- {
1725
- internalType: "address",
1726
- name: "from",
1727
- type: "address"
1728
- },
1729
- {
1730
- internalType: "address",
1731
- name: "to",
1732
- type: "address"
1733
- },
1734
- {
1735
- internalType: "uint256",
1736
- name: "value",
1737
- type: "uint256"
1738
- }
1739
- ],
1740
- name: "transferFrom",
1741
- outputs: [
1742
- {
1743
- internalType: "bool",
1744
- name: "",
1745
- type: "bool"
1746
- }
1747
- ],
1748
- payable: false,
1749
- stateMutability: "nonpayable",
1750
- type: "function"
1751
- }
1752
- ];
1753
-
1754
- // src/fetcher.ts
1755
- var TOKEN_DECIMALS_CACHE = {
1756
- [chains.ChainId.BSC]: {}
1757
- };
1758
- var ethClient = viem.createPublicClient({ chain: chains$1.mainnet, transport: viem.http() });
1759
- var bscClient = viem.createPublicClient({ chain: chains$1.bsc, transport: viem.http() });
1760
- var bscTestnetClient = viem.createPublicClient({ chain: chains$1.bscTestnet, transport: viem.http() });
1761
- var goerliClient = viem.createPublicClient({ chain: chains$1.goerli, transport: viem.http() });
1762
- var getDefaultClient = (chainId) => {
1763
- switch (chainId) {
1764
- case chains.ChainId.ETHEREUM:
1765
- return ethClient;
1766
- case chains.ChainId.BSC:
1767
- return bscClient;
1768
- case chains.ChainId.BSC_TESTNET:
1769
- return bscTestnetClient;
1770
- case chains.ChainId.GOERLI:
1771
- return goerliClient;
1772
- default:
1773
- return bscClient;
1774
- }
1775
- };
1776
- var Fetcher = class {
1777
- /**
1778
- * Cannot be constructed.
1779
- */
1780
- // eslint-disable-next-line no-useless-constructor,@typescript-eslint/no-empty-function
1781
- constructor() {
1782
- }
1783
- /**
1784
- * Fetch information for a given token on the given chain, using the given viem provider.
1785
- * @param chainId chain of the token
1786
- * @param address address of the token on the chain
1787
- * @param provider provider used to fetch the token
1788
- * @param symbol symbol of the token
1789
- * @param name optional name of the token
1790
- */
1791
- static async fetchTokenData(chainId, address, publicClient = getDefaultClient(chainId), symbol, name) {
1792
- const erc20 = viem.getContract({
1793
- abi: erc20Abi,
1794
- address,
1795
- client: publicClient
1796
- });
1797
- const parsedDecimals = typeof TOKEN_DECIMALS_CACHE?.[chainId]?.[address] === "number" ? TOKEN_DECIMALS_CACHE[chainId][address] : await erc20.read.decimals().then((decimals) => {
1798
- TOKEN_DECIMALS_CACHE = {
1799
- ...TOKEN_DECIMALS_CACHE,
1800
- [chainId]: {
1801
- ...TOKEN_DECIMALS_CACHE?.[chainId],
1802
- [address]: decimals
1803
- }
1804
- };
1805
- return decimals;
1806
- });
1807
- return new swapSdkCore.Token(chainId, address, parsedDecimals, symbol, name);
1808
- }
1809
- /**
1810
- * Fetches information about a pair and constructs a pair from the given two tokens.
1811
- * @param tokenA first token
1812
- * @param tokenB second token
1813
- * @param provider the provider to use to fetch the data
1814
- */
1815
- static async fetchPairData(tokenA, tokenB, publicClient = getDefaultClient(tokenA.chainId)) {
1816
- invariant5__default.default(tokenA.chainId === tokenB.chainId, "CHAIN_ID");
1817
- const address = Pair.getAddress(tokenA, tokenB);
1818
- const pairContract = viem.getContract({
1819
- abi: pancakePairV2ABI,
1820
- address,
1821
- client: publicClient
1822
- });
1823
- const [reserves0, reserves1] = await pairContract.read.getReserves();
1824
- const balances = tokenA.sortsBefore(tokenB) ? [reserves0, reserves1] : [reserves1, reserves0];
1825
- return new Pair(
1826
- swapSdkCore.CurrencyAmount.fromRawAmount(tokenA, balances[0]),
1827
- swapSdkCore.CurrencyAmount.fromRawAmount(tokenB, balances[1])
1828
- );
1829
- }
1830
- };
1831
-
1832
60
  Object.defineProperty(exports, 'ChainId', {
1833
61
  enumerable: true,
1834
62
  get: function () { return chains.ChainId; }
1835
63
  });
1836
- exports.ERC20Token = ERC20Token;
1837
- exports.Ether = Ether;
1838
- exports.FACTORY_ADDRESS = FACTORY_ADDRESS;
1839
- exports.FACTORY_ADDRESS_MAP = FACTORY_ADDRESS_MAP;
1840
- exports.Fetcher = Fetcher;
1841
- exports.INIT_CODE_HASH = INIT_CODE_HASH;
1842
- exports.INIT_CODE_HASH_MAP = INIT_CODE_HASH_MAP;
1843
- exports.NATIVE = NATIVE;
1844
- exports.Native = Native;
1845
- exports.ONE_HUNDRED_PERCENT = ONE_HUNDRED_PERCENT;
1846
64
  exports.OnRampCurrency = OnRampCurrency;
1847
- exports.Pair = Pair;
1848
- exports.Route = Route;
1849
- exports.Router = Router;
1850
- exports.Trade = Trade;
1851
- exports.WBNB = WBNB;
1852
- exports.WETH9 = WETH9;
1853
- exports.WNATIVE = WNATIVE;
1854
- exports.ZERO_PERCENT = ZERO_PERCENT;
1855
- exports.computePairAddress = computePairAddress;
1856
- exports.erc20Abi = erc20Abi;
1857
- exports.inputOutputComparator = inputOutputComparator;
1858
- exports.isTradeBetter = isTradeBetter;
1859
- exports.pancakePairV2ABI = pancakePairV2ABI;
1860
- exports.tradeComparator = tradeComparator;
1861
- exports.validateAndParseAddress = validateAndParseAddress;
1862
65
  Object.keys(swapSdkCore).forEach(function (k) {
1863
66
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
1864
67
  enumerable: true,
1865
68
  get: function () { return swapSdkCore[k]; }
1866
69
  });
1867
70
  });
71
+ Object.keys(v2Sdk).forEach(function (k) {
72
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
73
+ enumerable: true,
74
+ get: function () { return v2Sdk[k]; }
75
+ });
76
+ });
77
+ Object.keys(swapSdkEvm).forEach(function (k) {
78
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
79
+ enumerable: true,
80
+ get: function () { return swapSdkEvm[k]; }
81
+ });
82
+ });