@pancakeswap/sdk 4.0.0 → 5.0.0

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.
@@ -0,0 +1,27 @@
1
+ export declare const erc20ABI: readonly [{
2
+ readonly constant: true;
3
+ readonly inputs: readonly [];
4
+ readonly name: "decimals";
5
+ readonly outputs: readonly [{
6
+ readonly name: "";
7
+ readonly type: "uint8";
8
+ }];
9
+ readonly payable: false;
10
+ readonly stateMutability: "view";
11
+ readonly type: "function";
12
+ }, {
13
+ readonly constant: true;
14
+ readonly inputs: readonly [{
15
+ readonly name: "";
16
+ readonly type: "address";
17
+ }];
18
+ readonly name: "balanceOf";
19
+ readonly outputs: readonly [{
20
+ readonly name: "";
21
+ readonly type: "uint256";
22
+ }];
23
+ readonly payable: false;
24
+ readonly stateMutability: "view";
25
+ readonly type: "function";
26
+ }];
27
+ //# sourceMappingURL=ERC20.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ERC20.d.ts","sourceRoot":"","sources":["../../src/abis/ERC20.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;EAmBX,CAAA"}
@@ -0,0 +1,561 @@
1
+ export declare const pancakePairV2ABI: readonly [{
2
+ readonly anonymous: false;
3
+ readonly inputs: readonly [{
4
+ readonly indexed: true;
5
+ readonly internalType: "address";
6
+ readonly name: "owner";
7
+ readonly type: "address";
8
+ }, {
9
+ readonly indexed: true;
10
+ readonly internalType: "address";
11
+ readonly name: "spender";
12
+ readonly type: "address";
13
+ }, {
14
+ readonly indexed: false;
15
+ readonly internalType: "uint256";
16
+ readonly name: "value";
17
+ readonly type: "uint256";
18
+ }];
19
+ readonly name: "Approval";
20
+ readonly type: "event";
21
+ }, {
22
+ readonly anonymous: false;
23
+ readonly inputs: readonly [{
24
+ readonly indexed: true;
25
+ readonly internalType: "address";
26
+ readonly name: "sender";
27
+ readonly type: "address";
28
+ }, {
29
+ readonly indexed: false;
30
+ readonly internalType: "uint256";
31
+ readonly name: "amount0";
32
+ readonly type: "uint256";
33
+ }, {
34
+ readonly indexed: false;
35
+ readonly internalType: "uint256";
36
+ readonly name: "amount1";
37
+ readonly type: "uint256";
38
+ }, {
39
+ readonly indexed: true;
40
+ readonly internalType: "address";
41
+ readonly name: "to";
42
+ readonly type: "address";
43
+ }];
44
+ readonly name: "Burn";
45
+ readonly type: "event";
46
+ }, {
47
+ readonly anonymous: false;
48
+ readonly inputs: readonly [{
49
+ readonly indexed: true;
50
+ readonly internalType: "address";
51
+ readonly name: "sender";
52
+ readonly type: "address";
53
+ }, {
54
+ readonly indexed: false;
55
+ readonly internalType: "uint256";
56
+ readonly name: "amount0";
57
+ readonly type: "uint256";
58
+ }, {
59
+ readonly indexed: false;
60
+ readonly internalType: "uint256";
61
+ readonly name: "amount1";
62
+ readonly type: "uint256";
63
+ }];
64
+ readonly name: "Mint";
65
+ readonly type: "event";
66
+ }, {
67
+ readonly anonymous: false;
68
+ readonly inputs: readonly [{
69
+ readonly indexed: true;
70
+ readonly internalType: "address";
71
+ readonly name: "sender";
72
+ readonly type: "address";
73
+ }, {
74
+ readonly indexed: false;
75
+ readonly internalType: "uint256";
76
+ readonly name: "amount0In";
77
+ readonly type: "uint256";
78
+ }, {
79
+ readonly indexed: false;
80
+ readonly internalType: "uint256";
81
+ readonly name: "amount1In";
82
+ readonly type: "uint256";
83
+ }, {
84
+ readonly indexed: false;
85
+ readonly internalType: "uint256";
86
+ readonly name: "amount0Out";
87
+ readonly type: "uint256";
88
+ }, {
89
+ readonly indexed: false;
90
+ readonly internalType: "uint256";
91
+ readonly name: "amount1Out";
92
+ readonly type: "uint256";
93
+ }, {
94
+ readonly indexed: true;
95
+ readonly internalType: "address";
96
+ readonly name: "to";
97
+ readonly type: "address";
98
+ }];
99
+ readonly name: "Swap";
100
+ readonly type: "event";
101
+ }, {
102
+ readonly anonymous: false;
103
+ readonly inputs: readonly [{
104
+ readonly indexed: false;
105
+ readonly internalType: "uint112";
106
+ readonly name: "reserve0";
107
+ readonly type: "uint112";
108
+ }, {
109
+ readonly indexed: false;
110
+ readonly internalType: "uint112";
111
+ readonly name: "reserve1";
112
+ readonly type: "uint112";
113
+ }];
114
+ readonly name: "Sync";
115
+ readonly type: "event";
116
+ }, {
117
+ readonly anonymous: false;
118
+ readonly inputs: readonly [{
119
+ readonly indexed: true;
120
+ readonly internalType: "address";
121
+ readonly name: "from";
122
+ readonly type: "address";
123
+ }, {
124
+ readonly indexed: true;
125
+ readonly internalType: "address";
126
+ readonly name: "to";
127
+ readonly type: "address";
128
+ }, {
129
+ readonly indexed: false;
130
+ readonly internalType: "uint256";
131
+ readonly name: "value";
132
+ readonly type: "uint256";
133
+ }];
134
+ readonly name: "Transfer";
135
+ readonly type: "event";
136
+ }, {
137
+ readonly constant: true;
138
+ readonly inputs: readonly [];
139
+ readonly name: "DOMAIN_SEPARATOR";
140
+ readonly outputs: readonly [{
141
+ readonly internalType: "bytes32";
142
+ readonly name: "";
143
+ readonly type: "bytes32";
144
+ }];
145
+ readonly payable: false;
146
+ readonly stateMutability: "view";
147
+ readonly type: "function";
148
+ }, {
149
+ readonly constant: true;
150
+ readonly inputs: readonly [];
151
+ readonly name: "MINIMUM_LIQUIDITY";
152
+ readonly outputs: readonly [{
153
+ readonly internalType: "uint256";
154
+ readonly name: "";
155
+ readonly type: "uint256";
156
+ }];
157
+ readonly payable: false;
158
+ readonly stateMutability: "pure";
159
+ readonly type: "function";
160
+ }, {
161
+ readonly constant: true;
162
+ readonly inputs: readonly [];
163
+ readonly name: "PERMIT_TYPEHASH";
164
+ readonly outputs: readonly [{
165
+ readonly internalType: "bytes32";
166
+ readonly name: "";
167
+ readonly type: "bytes32";
168
+ }];
169
+ readonly payable: false;
170
+ readonly stateMutability: "pure";
171
+ readonly type: "function";
172
+ }, {
173
+ readonly constant: true;
174
+ readonly inputs: readonly [{
175
+ readonly internalType: "address";
176
+ readonly name: "owner";
177
+ readonly type: "address";
178
+ }, {
179
+ readonly internalType: "address";
180
+ readonly name: "spender";
181
+ readonly type: "address";
182
+ }];
183
+ readonly name: "allowance";
184
+ readonly outputs: readonly [{
185
+ readonly internalType: "uint256";
186
+ readonly name: "";
187
+ readonly type: "uint256";
188
+ }];
189
+ readonly payable: false;
190
+ readonly stateMutability: "view";
191
+ readonly type: "function";
192
+ }, {
193
+ readonly constant: false;
194
+ readonly inputs: readonly [{
195
+ readonly internalType: "address";
196
+ readonly name: "spender";
197
+ readonly type: "address";
198
+ }, {
199
+ readonly internalType: "uint256";
200
+ readonly name: "value";
201
+ readonly type: "uint256";
202
+ }];
203
+ readonly name: "approve";
204
+ readonly outputs: readonly [{
205
+ readonly internalType: "bool";
206
+ readonly name: "";
207
+ readonly type: "bool";
208
+ }];
209
+ readonly payable: false;
210
+ readonly stateMutability: "nonpayable";
211
+ readonly type: "function";
212
+ }, {
213
+ readonly constant: true;
214
+ readonly inputs: readonly [{
215
+ readonly internalType: "address";
216
+ readonly name: "owner";
217
+ readonly type: "address";
218
+ }];
219
+ readonly name: "balanceOf";
220
+ readonly outputs: readonly [{
221
+ readonly internalType: "uint256";
222
+ readonly name: "";
223
+ readonly type: "uint256";
224
+ }];
225
+ readonly payable: false;
226
+ readonly stateMutability: "view";
227
+ readonly type: "function";
228
+ }, {
229
+ readonly constant: false;
230
+ readonly inputs: readonly [{
231
+ readonly internalType: "address";
232
+ readonly name: "to";
233
+ readonly type: "address";
234
+ }];
235
+ readonly name: "burn";
236
+ readonly outputs: readonly [{
237
+ readonly internalType: "uint256";
238
+ readonly name: "amount0";
239
+ readonly type: "uint256";
240
+ }, {
241
+ readonly internalType: "uint256";
242
+ readonly name: "amount1";
243
+ readonly type: "uint256";
244
+ }];
245
+ readonly payable: false;
246
+ readonly stateMutability: "nonpayable";
247
+ readonly type: "function";
248
+ }, {
249
+ readonly constant: true;
250
+ readonly inputs: readonly [];
251
+ readonly name: "decimals";
252
+ readonly outputs: readonly [{
253
+ readonly internalType: "uint8";
254
+ readonly name: "";
255
+ readonly type: "uint8";
256
+ }];
257
+ readonly payable: false;
258
+ readonly stateMutability: "pure";
259
+ readonly type: "function";
260
+ }, {
261
+ readonly constant: true;
262
+ readonly inputs: readonly [];
263
+ readonly name: "factory";
264
+ readonly outputs: readonly [{
265
+ readonly internalType: "address";
266
+ readonly name: "";
267
+ readonly type: "address";
268
+ }];
269
+ readonly payable: false;
270
+ readonly stateMutability: "view";
271
+ readonly type: "function";
272
+ }, {
273
+ readonly constant: true;
274
+ readonly inputs: readonly [];
275
+ readonly name: "getReserves";
276
+ readonly outputs: readonly [{
277
+ readonly internalType: "uint112";
278
+ readonly name: "reserve0";
279
+ readonly type: "uint112";
280
+ }, {
281
+ readonly internalType: "uint112";
282
+ readonly name: "reserve1";
283
+ readonly type: "uint112";
284
+ }, {
285
+ readonly internalType: "uint32";
286
+ readonly name: "blockTimestampLast";
287
+ readonly type: "uint32";
288
+ }];
289
+ readonly payable: false;
290
+ readonly stateMutability: "view";
291
+ readonly type: "function";
292
+ }, {
293
+ readonly constant: false;
294
+ readonly inputs: readonly [{
295
+ readonly internalType: "address";
296
+ readonly name: "";
297
+ readonly type: "address";
298
+ }, {
299
+ readonly internalType: "address";
300
+ readonly name: "";
301
+ readonly type: "address";
302
+ }];
303
+ readonly name: "initialize";
304
+ readonly outputs: readonly [];
305
+ readonly payable: false;
306
+ readonly stateMutability: "nonpayable";
307
+ readonly type: "function";
308
+ }, {
309
+ readonly constant: true;
310
+ readonly inputs: readonly [];
311
+ readonly name: "kLast";
312
+ readonly outputs: readonly [{
313
+ readonly internalType: "uint256";
314
+ readonly name: "";
315
+ readonly type: "uint256";
316
+ }];
317
+ readonly payable: false;
318
+ readonly stateMutability: "view";
319
+ readonly type: "function";
320
+ }, {
321
+ readonly constant: false;
322
+ readonly inputs: readonly [{
323
+ readonly internalType: "address";
324
+ readonly name: "to";
325
+ readonly type: "address";
326
+ }];
327
+ readonly name: "mint";
328
+ readonly outputs: readonly [{
329
+ readonly internalType: "uint256";
330
+ readonly name: "liquidity";
331
+ readonly type: "uint256";
332
+ }];
333
+ readonly payable: false;
334
+ readonly stateMutability: "nonpayable";
335
+ readonly type: "function";
336
+ }, {
337
+ readonly constant: true;
338
+ readonly inputs: readonly [];
339
+ readonly name: "name";
340
+ readonly outputs: readonly [{
341
+ readonly internalType: "string";
342
+ readonly name: "";
343
+ readonly type: "string";
344
+ }];
345
+ readonly payable: false;
346
+ readonly stateMutability: "pure";
347
+ readonly type: "function";
348
+ }, {
349
+ readonly constant: true;
350
+ readonly inputs: readonly [{
351
+ readonly internalType: "address";
352
+ readonly name: "owner";
353
+ readonly type: "address";
354
+ }];
355
+ readonly name: "nonces";
356
+ readonly outputs: readonly [{
357
+ readonly internalType: "uint256";
358
+ readonly name: "";
359
+ readonly type: "uint256";
360
+ }];
361
+ readonly payable: false;
362
+ readonly stateMutability: "view";
363
+ readonly type: "function";
364
+ }, {
365
+ readonly constant: false;
366
+ readonly inputs: readonly [{
367
+ readonly internalType: "address";
368
+ readonly name: "owner";
369
+ readonly type: "address";
370
+ }, {
371
+ readonly internalType: "address";
372
+ readonly name: "spender";
373
+ readonly type: "address";
374
+ }, {
375
+ readonly internalType: "uint256";
376
+ readonly name: "value";
377
+ readonly type: "uint256";
378
+ }, {
379
+ readonly internalType: "uint256";
380
+ readonly name: "deadline";
381
+ readonly type: "uint256";
382
+ }, {
383
+ readonly internalType: "uint8";
384
+ readonly name: "v";
385
+ readonly type: "uint8";
386
+ }, {
387
+ readonly internalType: "bytes32";
388
+ readonly name: "r";
389
+ readonly type: "bytes32";
390
+ }, {
391
+ readonly internalType: "bytes32";
392
+ readonly name: "s";
393
+ readonly type: "bytes32";
394
+ }];
395
+ readonly name: "permit";
396
+ readonly outputs: readonly [];
397
+ readonly payable: false;
398
+ readonly stateMutability: "nonpayable";
399
+ readonly type: "function";
400
+ }, {
401
+ readonly constant: true;
402
+ readonly inputs: readonly [];
403
+ readonly name: "price0CumulativeLast";
404
+ readonly outputs: readonly [{
405
+ readonly internalType: "uint256";
406
+ readonly name: "";
407
+ readonly type: "uint256";
408
+ }];
409
+ readonly payable: false;
410
+ readonly stateMutability: "view";
411
+ readonly type: "function";
412
+ }, {
413
+ readonly constant: true;
414
+ readonly inputs: readonly [];
415
+ readonly name: "price1CumulativeLast";
416
+ readonly outputs: readonly [{
417
+ readonly internalType: "uint256";
418
+ readonly name: "";
419
+ readonly type: "uint256";
420
+ }];
421
+ readonly payable: false;
422
+ readonly stateMutability: "view";
423
+ readonly type: "function";
424
+ }, {
425
+ readonly constant: false;
426
+ readonly inputs: readonly [{
427
+ readonly internalType: "address";
428
+ readonly name: "to";
429
+ readonly type: "address";
430
+ }];
431
+ readonly name: "skim";
432
+ readonly outputs: readonly [];
433
+ readonly payable: false;
434
+ readonly stateMutability: "nonpayable";
435
+ readonly type: "function";
436
+ }, {
437
+ readonly constant: false;
438
+ readonly inputs: readonly [{
439
+ readonly internalType: "uint256";
440
+ readonly name: "amount0Out";
441
+ readonly type: "uint256";
442
+ }, {
443
+ readonly internalType: "uint256";
444
+ readonly name: "amount1Out";
445
+ readonly type: "uint256";
446
+ }, {
447
+ readonly internalType: "address";
448
+ readonly name: "to";
449
+ readonly type: "address";
450
+ }, {
451
+ readonly internalType: "bytes";
452
+ readonly name: "data";
453
+ readonly type: "bytes";
454
+ }];
455
+ readonly name: "swap";
456
+ readonly outputs: readonly [];
457
+ readonly payable: false;
458
+ readonly stateMutability: "nonpayable";
459
+ readonly type: "function";
460
+ }, {
461
+ readonly constant: true;
462
+ readonly inputs: readonly [];
463
+ readonly name: "symbol";
464
+ readonly outputs: readonly [{
465
+ readonly internalType: "string";
466
+ readonly name: "";
467
+ readonly type: "string";
468
+ }];
469
+ readonly payable: false;
470
+ readonly stateMutability: "pure";
471
+ readonly type: "function";
472
+ }, {
473
+ readonly constant: false;
474
+ readonly inputs: readonly [];
475
+ readonly name: "sync";
476
+ readonly outputs: readonly [];
477
+ readonly payable: false;
478
+ readonly stateMutability: "nonpayable";
479
+ readonly type: "function";
480
+ }, {
481
+ readonly constant: true;
482
+ readonly inputs: readonly [];
483
+ readonly name: "token0";
484
+ readonly outputs: readonly [{
485
+ readonly internalType: "address";
486
+ readonly name: "";
487
+ readonly type: "address";
488
+ }];
489
+ readonly payable: false;
490
+ readonly stateMutability: "view";
491
+ readonly type: "function";
492
+ }, {
493
+ readonly constant: true;
494
+ readonly inputs: readonly [];
495
+ readonly name: "token1";
496
+ readonly outputs: readonly [{
497
+ readonly internalType: "address";
498
+ readonly name: "";
499
+ readonly type: "address";
500
+ }];
501
+ readonly payable: false;
502
+ readonly stateMutability: "view";
503
+ readonly type: "function";
504
+ }, {
505
+ readonly constant: true;
506
+ readonly inputs: readonly [];
507
+ readonly name: "totalSupply";
508
+ readonly outputs: readonly [{
509
+ readonly internalType: "uint256";
510
+ readonly name: "";
511
+ readonly type: "uint256";
512
+ }];
513
+ readonly payable: false;
514
+ readonly stateMutability: "view";
515
+ readonly type: "function";
516
+ }, {
517
+ readonly constant: false;
518
+ readonly inputs: readonly [{
519
+ readonly internalType: "address";
520
+ readonly name: "to";
521
+ readonly type: "address";
522
+ }, {
523
+ readonly internalType: "uint256";
524
+ readonly name: "value";
525
+ readonly type: "uint256";
526
+ }];
527
+ readonly name: "transfer";
528
+ readonly outputs: readonly [{
529
+ readonly internalType: "bool";
530
+ readonly name: "";
531
+ readonly type: "bool";
532
+ }];
533
+ readonly payable: false;
534
+ readonly stateMutability: "nonpayable";
535
+ readonly type: "function";
536
+ }, {
537
+ readonly constant: false;
538
+ readonly inputs: readonly [{
539
+ readonly internalType: "address";
540
+ readonly name: "from";
541
+ readonly type: "address";
542
+ }, {
543
+ readonly internalType: "address";
544
+ readonly name: "to";
545
+ readonly type: "address";
546
+ }, {
547
+ readonly internalType: "uint256";
548
+ readonly name: "value";
549
+ readonly type: "uint256";
550
+ }];
551
+ readonly name: "transferFrom";
552
+ readonly outputs: readonly [{
553
+ readonly internalType: "bool";
554
+ readonly name: "";
555
+ readonly type: "bool";
556
+ }];
557
+ readonly payable: false;
558
+ readonly stateMutability: "nonpayable";
559
+ readonly type: "function";
560
+ }];
561
+ //# sourceMappingURL=IPancakePair.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IPancakePair.d.ts","sourceRoot":"","sources":["../../src/abis/IPancakePair.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAksBnB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  import { Percent } from '@pancakeswap/swap-sdk-core';
2
+ import { Address, Hash } from 'viem';
2
3
  import { ERC20Token } from './entities/token';
3
4
  export declare enum ChainId {
4
5
  ETHEREUM = 1,
@@ -9,9 +10,9 @@ export declare enum ChainId {
9
10
  export declare const ZERO_PERCENT: Percent;
10
11
  export declare const ONE_HUNDRED_PERCENT: Percent;
11
12
  export declare const FACTORY_ADDRESS = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73";
12
- export declare const FACTORY_ADDRESS_MAP: Record<number, string>;
13
+ export declare const FACTORY_ADDRESS_MAP: Record<number, Address>;
13
14
  export declare const INIT_CODE_HASH = "0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5";
14
- export declare const INIT_CODE_HASH_MAP: Record<number, string>;
15
+ export declare const INIT_CODE_HASH_MAP: Record<number, Hash>;
15
16
  export declare const WETH9: {
16
17
  1: ERC20Token;
17
18
  5: ERC20Token;
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,oBAAY,OAAO;IACjB,QAAQ,IAAI;IACZ,MAAM,IAAI;IACV,GAAG,KAAK;IACR,WAAW,KAAK;CACjB;AAED,eAAO,MAAM,YAAY,SAAmB,CAAA;AAC5C,eAAO,MAAM,mBAAmB,SAAmB,CAAA;AAEnD,eAAO,MAAM,eAAe,+CAA+C,CAAA;AAI3E,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKtD,CAAA;AACD,eAAO,MAAM,cAAc,uEAAuE,CAAA;AAGlG,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKrD,CAAA;AAED,eAAO,MAAM,KAAK;;;;;CAiCjB,CAAA;AAED,eAAO,MAAM,IAAI;;;;CAyBhB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAK9C,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,MAAM,CACzB,MAAM,EACN;IACE,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB,CAcF,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C,oBAAY,OAAO;IACjB,QAAQ,IAAI;IACZ,MAAM,IAAI;IACV,GAAG,KAAK;IACR,WAAW,KAAK;CACjB;AAED,eAAO,MAAM,YAAY,SAAmB,CAAA;AAC5C,eAAO,MAAM,mBAAmB,SAAmB,CAAA;AAEnD,eAAO,MAAM,eAAe,+CAA+C,CAAA;AAI3E,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAKvD,CAAA;AACD,eAAO,MAAM,cAAc,uEAAuE,CAAA;AAGlG,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAKnD,CAAA;AAED,eAAO,MAAM,KAAK;;;;;CAiCjB,CAAA;AAED,eAAO,MAAM,IAAI;;;;CAyBhB,CAAA;AAED,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAK9C,CAAA;AAED,eAAO,MAAM,MAAM,EAAE,MAAM,CACzB,MAAM,EACN;IACE,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;CACjB,CAcF,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/entities/native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAG5E;;;GAGG;AACH,qBAAa,MAAO,SAAQ,cAAc;IACxC,SAAS,aAAa,EACpB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,MAAM,GACP,EAAE;QACD,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;KACb;IAID,IAAW,OAAO,IAAI,KAAK,CAI1B;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAoC;WAE1C,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IASvC,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;CAGxC"}
1
+ {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../../src/entities/native.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAG5E;;;GAGG;AACH,qBAAa,MAAO,SAAQ,cAAc;IACxC,SAAS,aAAa,EACpB,OAAO,EACP,QAAQ,EACR,IAAI,EACJ,MAAM,GACP,EAAE;QACD,OAAO,EAAE,MAAM,CAAA;QACf,QAAQ,EAAE,MAAM,CAAA;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,EAAE,MAAM,CAAA;KACb;IAID,IAAW,OAAO,IAAI,KAAK,CAI1B;IAED,OAAO,CAAC,MAAM,CAAC,KAAK,CAAoC;WAE1C,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAUvC,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;CAGxC"}
@@ -1,14 +1,15 @@
1
1
  import { CurrencyAmount, Price, BigintIsh } from '@pancakeswap/swap-sdk-core';
2
+ import { Address } from 'viem';
2
3
  import { ERC20Token } from './token';
3
4
  export declare const computePairAddress: ({ factoryAddress, tokenA, tokenB, }: {
4
- factoryAddress: string;
5
+ factoryAddress: Address;
5
6
  tokenA: ERC20Token;
6
7
  tokenB: ERC20Token;
7
- }) => string;
8
+ }) => Address;
8
9
  export declare class Pair {
9
10
  readonly liquidityToken: ERC20Token;
10
11
  private readonly tokenAmounts;
11
- static getAddress(tokenA: ERC20Token, tokenB: ERC20Token): string;
12
+ static getAddress(tokenA: ERC20Token, tokenB: ERC20Token): Address;
12
13
  constructor(currencyAmountA: CurrencyAmount<ERC20Token>, tokenAmountB: CurrencyAmount<ERC20Token>);
13
14
  /**
14
15
  * Returns true if the token is either token0 or token1
@@ -1 +1 @@
1
- {"version":3,"file":"pair.d.ts","sourceRoot":"","sources":["../../src/entities/pair.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,cAAc,EACd,KAAK,EAML,SAAS,EAEV,MAAM,4BAA4B,CAAA;AAMnC,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAMpC,eAAO,MAAM,kBAAkB;oBAKb,MAAM;YACd,UAAU;YACV,UAAU;MAChB,MAgBH,CAAA;AAED,qBAAa,IAAI;IACf,SAAgB,cAAc,EAAE,UAAU,CAAA;IAE1C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0D;WAEzE,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM;gBAIrD,eAAe,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,YAAY,EAAE,cAAc,CAAC,UAAU,CAAC;IAcxG;;;OAGG;IACI,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO;IAIhD;;OAEG;IACH,IAAW,WAAW,IAAI,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,CAGtD;IAED;;OAEG;IACH,IAAW,WAAW,IAAI,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC,CAGtD;IAED;;;OAGG;IACI,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,KAAK,CAAC,UAAU,EAAE,UAAU,CAAC;IAKhE;;OAEG;IACH,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED,IAAW,MAAM,IAAI,UAAU,CAE9B;IAED,IAAW,MAAM,IAAI,UAAU,CAE9B;IAED,IAAW,QAAQ,IAAI,cAAc,CAAC,UAAU,CAAC,CAEhD;IAED,IAAW,QAAQ,IAAI,c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AChB,cAAc,CAAC,UAAU,CAAC;CAiC9B"}
@@ -1,13 +1,14 @@
1
1
  import { Token } from '@pancakeswap/swap-sdk-core';
2
+ import { Address } from 'viem';
2
3
  export interface SerializedToken {
3
4
  chainId: number;
4
- address: string;
5
+ address: Address;
5
6
  decimals: number;
6
7
  symbol: string;
7
8
  name?: string;
8
9
  projectLink?: string;
9
10
  }
10
11
  export declare class ERC20Token extends Token {
11
- constructor(chainId: number, address: string, decimals: number, symbol: string, name?: string, projectLink?: string);
12
+ constructor(chainId: number, address: Address, decimals: number, symbol: string, name?: string, projectLink?: string);
12
13
  }
13
14
  //# sourceMappingURL=token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/entities/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAGlD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAKD,qBAAa,UAAW,SAAQ,KAAK;gBAEjC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM;CAIvB"}
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/entities/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAG9B,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAKD,qBAAa,UAAW,SAAQ,KAAK;gBAEjC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM;CAIvB"}
package/dist/fetcher.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Address } from 'viem';
1
2
  import { Token } from '@pancakeswap/swap-sdk-core';
2
3
  import { Pair } from './entities/pair';
3
4
  import { ChainId } from './constants';
@@ -10,20 +11,20 @@ export declare abstract class Fetcher {
10
11
  */
11
12
  private constructor();
12
13
  /**
13
- * Fetch information for a given token on the given chain, using the given ethers provider.
14
+ * Fetch information for a given token on the given chain, using the given viem provider.
14
15
  * @param chainId chain of the token
15
16
  * @param address address of the token on the chain
16
17
  * @param provider provider used to fetch the token
17
18
  * @param symbol symbol of the token
18
19
  * @param name optional name of the token
19
20
  */
20
- static fetchTokenData(chainId: ChainId, address: string, provider: import("@ethersproject/providers").BaseProvider | undefined, symbol: string, name?: string): Promise<Token>;
21
+ static fetchTokenData(chainId: ChainId, address: Address, publicClient: any, symbol: string, name?: string): Promise<Token>;
21
22
  /**
22
23
  * Fetches information about a pair and constructs a pair from the given two tokens.
23
24
  * @param tokenA first token
24
25
  * @param tokenB second token
25
26
  * @param provider the provider to use to fetch the data
26
27
  */
27
- static fetchPairData(tokenA: Token, tokenB: Token, provider?: import("@ethersproject/providers").BaseProvider): Promise<Pair>;
28
+ static fetchPairData(tokenA: Token, tokenB: Token, publicClient?: any): Promise<Pair>;
28
29
  }
29
30
  //# sourceMappingURL=fetcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetcher.d.ts","sourceRoot":"","sources":["../src/fetcher.ts"],"names":[],"m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 @@ export * from './utils';
6
6
  export * from './ether';
7
7
  export * from './fetcher';
8
8
  export * from '@pancakeswap/swap-sdk-core';
9
+ export * from './abis/IPancakePair';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AAEvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AAExB,cAAc,SAAS,CAAA;AAEvB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AAEzB,cAAc,4BAA4B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,SAAS,CAAA;AAEvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AAExB,cAAc,SAAS,CAAA;AAEvB,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AAEzB,cAAc,4BAA4B,CAAA;AAE1C,cAAc,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -1,13 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var swapSdkCore = require('@pancakeswap/swap-sdk-core');
4
- var address = require('@ethersproject/address');
4
+ var viem = require('viem');
5
5
  var invariant4 = require('tiny-invariant');
6
6
  var warning = require('tiny-warning');
7
- var solidity = require('@ethersproject/solidity');
8
- var contracts = require('@ethersproject/contracts');
9
- var networks = require('@ethersproject/networks');
10
- var providers = require('@ethersproject/providers');
7
+ var chains = require('viem/chains');
11
8
 
12
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
10
 
@@ -15,13 +12,13 @@ var invariant4__default = /*#__PURE__*/_interopDefault(invariant4);
15
12
  var warning__default = /*#__PURE__*/_interopDefault(warning);
16
13
 
17
14
  // src/constants.ts
18
- function validateAndParseAddress(address$1) {
15
+ function validateAndParseAddress(address) {
19
16
  try {
20
- const checksummedAddress = address.getAddress(address$1);
21
- warning__default.default(address$1 === checksummedAddress, `${address$1} is not checksummed.`);
17
+ const checksummedAddress = viem.getAddress(address);
18
+ warning__default.default(address === checksummedAddress, `${address} is not checksummed.`);
22
19
  return checksummedAddress;
23
20
  } catch (error) {
24
- invariant4__default.default(false, `${address$1} is not a valid address.`);
21
+ invariant4__default.default(false, `${address} is not a valid address.`);
25
22
  }
26
23
  }
27
24
 
@@ -157,6 +154,13 @@ function isTradeBetter(tradeA, tradeB, minimumDelta = ZERO_PERCENT) {
157
154
  }
158
155
  var PAIR_ADDRESS_CACHE = {};
159
156
  var composeKey = (token0, token1) => `${token0.chainId}-${token0.address}-${token1.address}`;
157
+ function getCreate2Address(from_, salt_, initCodeHash) {
158
+ const from = viem.toBytes(viem.getAddress(from_));
159
+ const salt = viem.pad(viem.isBytes(salt_) ? salt_ : viem.toBytes(salt_), {
160
+ size: 32
161
+ });
162
+ return viem.getAddress(viem.slice(viem.keccak256(viem.concat([viem.toBytes("0xff"), from, salt, viem.toBytes(initCodeHash)])), 12));
163
+ }
160
164
  var computePairAddress = ({
161
165
  factoryAddress,
162
166
  tokenA,
@@ -167,9 +171,9 @@ var computePairAddress = ({
167
171
  if (PAIR_ADDRESS_CACHE?.[key] === void 0) {
168
172
  PAIR_ADDRESS_CACHE = {
169
173
  ...PAIR_ADDRESS_CACHE,
170
- [key]: address.getCreate2Address(
174
+ [key]: getCreate2Address(
171
175
  factoryAddress,
172
- solidity.keccak256(["bytes"], [solidity.pack(["address", "address"], [token0.address, token1.address])]),
176
+ viem.keccak256(viem.encodePacked(["address", "address"], [token0.address, token1.address])),
173
177
  INIT_CODE_HASH_MAP[token0.chainId]
174
178
  )
175
179
  };
@@ -735,8 +739,8 @@ var _Ether = class extends swapSdkCore.NativeCurrency {
735
739
  var Ether = _Ether;
736
740
  Ether._etherCache = {};
737
741
 
738
- // src/abis/ERC20.json
739
- var ERC20_default = [
742
+ // src/abis/ERC20.ts
743
+ var erc20ABI = [
740
744
  {
741
745
  constant: true,
742
746
  inputs: [],
@@ -757,8 +761,8 @@ var ERC20_default = [
757
761
  }
758
762
  ];
759
763
 
760
- // src/abis/IPancakePair.json
761
- var IPancakePair_default = [
764
+ // src/abis/IPancakePair.ts
765
+ var pancakePairV2ABI = [
762
766
  {
763
767
  anonymous: false,
764
768
  inputs: [
@@ -1470,6 +1474,24 @@ var IPancakePair_default = [
1470
1474
  var TOKEN_DECIMALS_CACHE = {
1471
1475
  [56 /* BSC */]: {}
1472
1476
  };
1477
+ var ethClient = viem.createPublicClient({ chain: chains.mainnet, transport: viem.http() });
1478
+ var bscClient = viem.createPublicClient({ chain: chains.bsc, transport: viem.http() });
1479
+ var bscTestnetClient = viem.createPublicClient({ chain: chains.bscTestnet, transport: viem.http() });
1480
+ var goerliClient = viem.createPublicClient({ chain: chains.goerli, transport: viem.http() });
1481
+ var getDefaultClient = (chainId) => {
1482
+ switch (chainId) {
1483
+ case 1 /* ETHEREUM */:
1484
+ return ethClient;
1485
+ case 56 /* BSC */:
1486
+ return bscClient;
1487
+ case 97 /* BSC_TESTNET */:
1488
+ return bscTestnetClient;
1489
+ case 5 /* GOERLI */:
1490
+ return goerliClient;
1491
+ default:
1492
+ return bscClient;
1493
+ }
1494
+ };
1473
1495
  var Fetcher = class {
1474
1496
  /**
1475
1497
  * Cannot be constructed.
@@ -1478,15 +1500,20 @@ var Fetcher = class {
1478
1500
  constructor() {
1479
1501
  }
1480
1502
  /**
1481
- * Fetch information for a given token on the given chain, using the given ethers provider.
1503
+ * Fetch information for a given token on the given chain, using the given viem provider.
1482
1504
  * @param chainId chain of the token
1483
1505
  * @param address address of the token on the chain
1484
1506
  * @param provider provider used to fetch the token
1485
1507
  * @param symbol symbol of the token
1486
1508
  * @param name optional name of the token
1487
1509
  */
1488
- static async fetchTokenData(chainId, address, provider = providers.getDefaultProvider(networks.getNetwork(chainId)), symbol, name) {
1489
- const parsedDecimals = typeof TOKEN_DECIMALS_CACHE?.[chainId]?.[address] === "number" ? TOKEN_DECIMALS_CACHE[chainId][address] : await new contracts.Contract(address, ERC20_default, provider).decimals().then((decimals) => {
1510
+ static async fetchTokenData(chainId, address, publicClient = getDefaultClient(chainId), symbol, name) {
1511
+ const erc20 = viem.getContract({
1512
+ abi: erc20ABI,
1513
+ address,
1514
+ publicClient
1515
+ });
1516
+ const parsedDecimals = typeof TOKEN_DECIMALS_CACHE?.[chainId]?.[address] === "number" ? TOKEN_DECIMALS_CACHE[chainId][address] : await erc20.read.decimals().then((decimals) => {
1490
1517
  TOKEN_DECIMALS_CACHE = {
1491
1518
  ...TOKEN_DECIMALS_CACHE,
1492
1519
  [chainId]: {
@@ -1504,10 +1531,15 @@ var Fetcher = class {
1504
1531
  * @param tokenB second token
1505
1532
  * @param provider the provider to use to fetch the data
1506
1533
  */
1507
- static async fetchPairData(tokenA, tokenB, provider = providers.getDefaultProvider(networks.getNetwork(tokenA.chainId))) {
1534
+ static async fetchPairData(tokenA, tokenB, publicClient = getDefaultClient(tokenA.chainId)) {
1508
1535
  invariant4__default.default(tokenA.chainId === tokenB.chainId, "CHAIN_ID");
1509
1536
  const address = Pair.getAddress(tokenA, tokenB);
1510
- const [reserves0, reserves1] = await new contracts.Contract(address, IPancakePair_default, provider).getReserves();
1537
+ const pairContract = viem.getContract({
1538
+ abi: pancakePairV2ABI,
1539
+ address,
1540
+ publicClient
1541
+ });
1542
+ const [reserves0, reserves1] = await pairContract.read.getReserves();
1511
1543
  const balances = tokenA.sortsBefore(tokenB) ? [reserves0, reserves1] : [reserves1, reserves0];
1512
1544
  return new Pair(
1513
1545
  swapSdkCore.CurrencyAmount.fromRawAmount(tokenA, balances[0]),
@@ -1538,6 +1570,7 @@ exports.ZERO_PERCENT = ZERO_PERCENT;
1538
1570
  exports.computePairAddress = computePairAddress;
1539
1571
  exports.inputOutputComparator = inputOutputComparator;
1540
1572
  exports.isTradeBetter = isTradeBetter;
1573
+ exports.pancakePairV2ABI = pancakePairV2ABI;
1541
1574
  exports.tradeComparator = tradeComparator;
1542
1575
  exports.validateAndParseAddress = validateAndParseAddress;
1543
1576
  Object.keys(swapSdkCore).forEach(function (k) {
package/dist/index.mjs CHANGED
@@ -1,12 +1,9 @@
1
1
  import { Percent, Token, Price, ZERO, InsufficientReservesError, _9975, _10000, CurrencyAmount, InsufficientInputAmountError, ONE, sqrt, MINIMUM_LIQUIDITY, TradeType, computePriceImpact, Fraction, sortedInsert, NativeCurrency, FIVE } from '@pancakeswap/swap-sdk-core';
2
2
  export * from '@pancakeswap/swap-sdk-core';
3
- import { getAddress, getCreate2Address } from '@ethersproject/address';
3
+ import { createPublicClient, http, getAddress, keccak256, encodePacked, getContract, toBytes, pad, isBytes, slice, concat } from 'viem';
4
4
  import invariant4 from 'tiny-invariant';
5
5
  import warning from 'tiny-warning';
6
- import { keccak256, pack } from '@ethersproject/solidity';
7
- import { Contract } from '@ethersproject/contracts';
8
- import { getNetwork } from '@ethersproject/networks';
9
- import { getDefaultProvider } from '@ethersproject/providers';
6
+ import { mainnet, bsc, bscTestnet, goerli } from 'viem/chains';
10
7
 
11
8
  // src/constants.ts
12
9
  function validateAndParseAddress(address) {
@@ -151,6 +148,13 @@ function isTradeBetter(tradeA, tradeB, minimumDelta = ZERO_PERCENT) {
151
148
  }
152
149
  var PAIR_ADDRESS_CACHE = {};
153
150
  var composeKey = (token0, token1) => `${token0.chainId}-${token0.address}-${token1.address}`;
151
+ function getCreate2Address(from_, salt_, initCodeHash) {
152
+ const from = toBytes(getAddress(from_));
153
+ const salt = pad(isBytes(salt_) ? salt_ : toBytes(salt_), {
154
+ size: 32
155
+ });
156
+ return getAddress(slice(keccak256(concat([toBytes("0xff"), from, salt, toBytes(initCodeHash)])), 12));
157
+ }
154
158
  var computePairAddress = ({
155
159
  factoryAddress,
156
160
  tokenA,
@@ -163,7 +167,7 @@ var computePairAddress = ({
163
167
  ...PAIR_ADDRESS_CACHE,
164
168
  [key]: getCreate2Address(
165
169
  factoryAddress,
166
- keccak256(["bytes"], [pack(["address", "address"], [token0.address, token1.address])]),
170
+ keccak256(encodePacked(["address", "address"], [token0.address, token1.address])),
167
171
  INIT_CODE_HASH_MAP[token0.chainId]
168
172
  )
169
173
  };
@@ -729,8 +733,8 @@ var _Ether = class extends NativeCurrency {
729
733
  var Ether = _Ether;
730
734
  Ether._etherCache = {};
731
735
 
732
- // src/abis/ERC20.json
733
- var ERC20_default = [
736
+ // src/abis/ERC20.ts
737
+ var erc20ABI = [
734
738
  {
735
739
  constant: true,
736
740
  inputs: [],
@@ -751,8 +755,8 @@ var ERC20_default = [
751
755
  }
752
756
  ];
753
757
 
754
- // src/abis/IPancakePair.json
755
- var IPancakePair_default = [
758
+ // src/abis/IPancakePair.ts
759
+ var pancakePairV2ABI = [
756
760
  {
757
761
  anonymous: false,
758
762
  inputs: [
@@ -1464,6 +1468,24 @@ var IPancakePair_default = [
1464
1468
  var TOKEN_DECIMALS_CACHE = {
1465
1469
  [56 /* BSC */]: {}
1466
1470
  };
1471
+ var ethClient = createPublicClient({ chain: mainnet, transport: http() });
1472
+ var bscClient = createPublicClient({ chain: bsc, transport: http() });
1473
+ var bscTestnetClient = createPublicClient({ chain: bscTestnet, transport: http() });
1474
+ var goerliClient = createPublicClient({ chain: goerli, transport: http() });
1475
+ var getDefaultClient = (chainId) => {
1476
+ switch (chainId) {
1477
+ case 1 /* ETHEREUM */:
1478
+ return ethClient;
1479
+ case 56 /* BSC */:
1480
+ return bscClient;
1481
+ case 97 /* BSC_TESTNET */:
1482
+ return bscTestnetClient;
1483
+ case 5 /* GOERLI */:
1484
+ return goerliClient;
1485
+ default:
1486
+ return bscClient;
1487
+ }
1488
+ };
1467
1489
  var Fetcher = class {
1468
1490
  /**
1469
1491
  * Cannot be constructed.
@@ -1472,15 +1494,20 @@ var Fetcher = class {
1472
1494
  constructor() {
1473
1495
  }
1474
1496
  /**
1475
- * Fetch information for a given token on the given chain, using the given ethers provider.
1497
+ * Fetch information for a given token on the given chain, using the given viem provider.
1476
1498
  * @param chainId chain of the token
1477
1499
  * @param address address of the token on the chain
1478
1500
  * @param provider provider used to fetch the token
1479
1501
  * @param symbol symbol of the token
1480
1502
  * @param name optional name of the token
1481
1503
  */
1482
- static async fetchTokenData(chainId, address, provider = getDefaultProvider(getNetwork(chainId)), symbol, name) {
1483
- const parsedDecimals = typeof TOKEN_DECIMALS_CACHE?.[chainId]?.[address] === "number" ? TOKEN_DECIMALS_CACHE[chainId][address] : await new Contract(address, ERC20_default, provider).decimals().then((decimals) => {
1504
+ static async fetchTokenData(chainId, address, publicClient = getDefaultClient(chainId), symbol, name) {
1505
+ const erc20 = getContract({
1506
+ abi: erc20ABI,
1507
+ address,
1508
+ publicClient
1509
+ });
1510
+ const parsedDecimals = typeof TOKEN_DECIMALS_CACHE?.[chainId]?.[address] === "number" ? TOKEN_DECIMALS_CACHE[chainId][address] : await erc20.read.decimals().then((decimals) => {
1484
1511
  TOKEN_DECIMALS_CACHE = {
1485
1512
  ...TOKEN_DECIMALS_CACHE,
1486
1513
  [chainId]: {
@@ -1498,10 +1525,15 @@ var Fetcher = class {
1498
1525
  * @param tokenB second token
1499
1526
  * @param provider the provider to use to fetch the data
1500
1527
  */
1501
- static async fetchPairData(tokenA, tokenB, provider = getDefaultProvider(getNetwork(tokenA.chainId))) {
1528
+ static async fetchPairData(tokenA, tokenB, publicClient = getDefaultClient(tokenA.chainId)) {
1502
1529
  invariant4(tokenA.chainId === tokenB.chainId, "CHAIN_ID");
1503
1530
  const address = Pair.getAddress(tokenA, tokenB);
1504
- const [reserves0, reserves1] = await new Contract(address, IPancakePair_default, provider).getReserves();
1531
+ const pairContract = getContract({
1532
+ abi: pancakePairV2ABI,
1533
+ address,
1534
+ publicClient
1535
+ });
1536
+ const [reserves0, reserves1] = await pairContract.read.getReserves();
1505
1537
  const balances = tokenA.sortsBefore(tokenB) ? [reserves0, reserves1] : [reserves1, reserves0];
1506
1538
  return new Pair(
1507
1539
  CurrencyAmount.fromRawAmount(tokenA, balances[0]),
@@ -1510,4 +1542,4 @@ var Fetcher = class {
1510
1542
  }
1511
1543
  };
1512
1544
 
1513
- export { ChainId, ERC20Token, Ether, FACTORY_ADDRESS, FACTORY_ADDRESS_MAP, Fetcher, INIT_CODE_HASH, INIT_CODE_HASH_MAP, NATIVE, Native, ONE_HUNDRED_PERCENT, Pair, Route, Router, Trade, WBNB, WETH9, WNATIVE, ZERO_PERCENT, computePairAddress, inputOutputComparator, isTradeBetter, tradeComparator, validateAndParseAddress };
1545
+ export { ChainId, ERC20Token, Ether, FACTORY_ADDRESS, FACTORY_ADDRESS_MAP, Fetcher, INIT_CODE_HASH, INIT_CODE_HASH_MAP, NATIVE, Native, ONE_HUNDRED_PERCENT, Pair, Route, Router, Trade, WBNB, WETH9, WNATIVE, ZERO_PERCENT, computePairAddress, inputOutputComparator, isTradeBetter, pancakePairV2ABI, tradeComparator, validateAndParseAddress };
package/dist/router.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { TradeType, Currency, Percent } from '@pancakeswap/swap-sdk-core';
2
+ import { Hex } from 'viem';
2
3
  import { Trade } from './entities';
3
4
  /**
4
5
  * Options for producing the arguments to send call to the router.
@@ -41,11 +42,11 @@ export interface SwapParameters {
41
42
  /**
42
43
  * The arguments to pass to the method, all hex encoded.
43
44
  */
44
- args: (string | string[])[];
45
+ args: (Hex | Hex[])[];
45
46
  /**
46
47
  * The amount of wei to send in hex.
47
48
  */
48
- value: string;
49
+ value: Hex;
49
50
  }
50
51
  /**
51
52
  * Represents the Pancake Router, and has static methods for helping execute trades.
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAyB,QAAQ,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEhG,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAGlC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,eA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AQ,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,IAAI,EAAE,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,EAAE,CAAA;IACrB;;OAEG;IACH,KAAK,EAAE,GAAG,CAAA;CACX;AAQD;;GAEG;AACH,8BAAsB,MAAM;IAC1B;;;;OAIG;WACW,kBAAkB,CAC9B,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,CAAC,EAC3C,OAAO,EAAE,YAAY,GAAG,oBAAoB,GAC3C,cAAc;CAuElB"}
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export declare function validateAndParseAddress(address: string): string;
1
+ import { Address } from 'viem';
2
+ export declare function validateAndParseAddress(address: string): Address;
2
3
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAMA,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAQ/D"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAc,MAAM,MAAM,CAAA;AAM1C,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAQhE"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pancakeswap/sdk",
3
3
  "license": "MIT",
4
- "version": "4.0.0",
4
+ "version": "5.0.0",
5
5
  "description": "🛠 An SDK for building applications on top of Pancakeswap.",
6
6
  "main": "dist/index.js",
7
7
  "typings": "dist/index.d.ts",
@@ -27,6 +27,7 @@
27
27
  "./package.json": "./package.json"
28
28
  },
29
29
  "dependencies": {
30
+ "viem": "^1.0.7",
30
31
  "big.js": "^5.2.2",
31
32
  "decimal.js-light": "^2.5.0",
32
33
  "tiny-invariant": "^1.1.0",
@@ -34,19 +35,7 @@
34
35
  "toformat": "^2.0.0",
35
36
  "@pancakeswap/swap-sdk-core": "1.0.0"
36
37
  },
37
- "peerDependencies": {
38
- "@ethersproject/address": "^5.0.0",
39
- "@ethersproject/contracts": "^5.0.0",
40
- "@ethersproject/networks": "^5.0.0",
41
- "@ethersproject/providers": "^5.0.0",
42
- "@ethersproject/solidity": "^5.0.0"
43
- },
44
38
  "devDependencies": {
45
- "@ethersproject/address": "^5.0.0",
46
- "@ethersproject/contracts": "^5.0.0",
47
- "@ethersproject/networks": "^5.0.0",
48
- "@ethersproject/providers": "^5.0.0",
49
- "@ethersproject/solidity": "^5.0.0",
50
39
  "@swc/core": "^1.2.215",
51
40
  "@swc/jest": "^0.2.21",
52
41
  "@types/big.js": "^4.0.5",