@@ -210,24 +210,18 @@ const token = new Token(
210
210
211
211
** 核心的属性包括:**
212
212
213
- chainId
214
-
215
- address
216
-
217
- decimals
218
-
219
- symbol
220
-
221
- name
222
-
213
+ + chainId
214
+ + address
215
+ + decimals
216
+ + symbol
217
+ + name
218
+ +
223
219
** 方法包括**
224
- equals
225
-
226
- 判断是不是一个币
227
-
228
- sortsBefore
229
220
230
- 按地址排序下判断相对位置
221
+ + equals
222
+ + 判断是不是一个币
223
+ + sortsBefore
224
+ 按地址排序下判断相对位置
231
225
232
226
233
227
#### Pair
@@ -264,28 +258,20 @@ const pair = new Pair(
264
258
265
259
** 关键属性**
266
260
267
- liquidityToken
268
-
269
- token0
270
-
271
- reserve0
272
-
273
- reserve1
274
-
261
+ + liquidityToken
262
+ + token0
263
+ + reserve0
264
+ + reserve1
265
+ +
275
266
276
267
** 方法**
277
268
278
- reserveOf(返回reserve0或者1余额,看传参)
279
-
280
- getOutputAmount
281
-
282
- getInputAmount
283
-
284
- getLiquidityMinted
285
-
286
- getLiquidityValue
287
-
288
- 计算总体流动性
269
+ + reserveOf(返回reserve0或者1余额,看传参)
270
+ + getOutputAmount
271
+ + getInputAmount
272
+ + getLiquidityMinted
273
+ + getLiquidityValue
274
+ + 计算总体流动性
289
275
290
276
```
291
277
getLiquidityValue(
@@ -299,7 +285,7 @@ getLiquidityValue(
299
285
300
286
静态方法:getAddress
301
287
302
- 获得交易对方法
288
+ + 获得交易对方法
303
289
304
290
```
305
291
getAddress(tokenA: Token, tokenB: Token): string
@@ -340,15 +326,11 @@ const route = new Route([HOT_NOT], NOT);
340
326
```
341
327
** 关键属性**
342
328
343
- pairs
344
-
345
- path
346
-
347
- input
348
-
349
- output
350
-
351
- midPrice
329
+ + pairs
330
+ + path
331
+ + input
332
+ + output
333
+ + midPrice
352
334
353
335
#### Trade
354
336
交易实体代表沿着特定route的一次Tx,包含所有参数信息。
@@ -396,32 +378,26 @@ const trade = new Trade(
396
378
```
397
379
** 关键属性**
398
380
399
- route
400
-
401
- tradeType
402
-
403
- inputAmount
404
-
405
- outputAmount
406
-
407
- executionPrice
408
-
409
- nextMidPrice
410
-
411
- slippage
381
+ + route
382
+ + tradeType
383
+ + inputAmount
384
+ + outputAmount
385
+ + executionPrice
386
+ + nextMidPrice
387
+ + slippage
412
388
413
389
** 方法**
414
390
415
- minimumAmountOut(2.04后)
416
-
417
- maximumAmountIn(2.04后)
391
+ + minimumAmountOut(2.04后)
392
+ + maximumAmountIn(2.04后)
418
393
419
394
420
395
Static methods:
421
396
422
- bestTradeExactIn
397
+ + bestTradeExactIn
423
398
424
- 返回最大值可能
399
+ 返回TradeIn方式的最大兑换数量结果(最低手续费),也就是最优兑换路径,包括hop数等,返回数据类型是Trade数组。
400
+ 感谢三火check指正~ !
425
401
426
402
```
427
403
Trade.bestTradeExactIn(
@@ -443,28 +419,20 @@ constructor(numerator: BigintIsh, denominator: BigintIsh = ONE)
443
419
444
420
都是JSBI
445
421
446
- numerator
447
-
448
- denominator
449
-
450
- quotient
422
+ + numerator
423
+ + denominator
424
+ + quotient
451
425
452
426
453
427
** 方法**
454
428
455
- invert
456
-
457
- add
458
-
459
- subtract
460
-
461
- multiply
462
-
463
- divide
464
-
465
- toSignificant
466
-
467
- toFixed
429
+ + invert
430
+ + add
431
+ + subtract
432
+ + multiply
433
+ + divide
434
+ + toSignificant
435
+ + toFixed
468
436
469
437
470
438
Percent:格式化百分比
@@ -474,9 +442,9 @@ import { Percent } from "@uniswap/sdk";
474
442
const percent = new Percent("60", "100");
475
443
console.log(percent.toSignificant(2)); // 60
476
444
```
477
- toSignificant
445
+ + toSignificant
478
446
479
- toFixed
447
+ + toFixed
480
448
481
449
TokenAmount:返回指定精度余额
482
450
@@ -494,16 +462,11 @@ const FRIED = new Token(
494
462
const tokenAmount = new TokenAmount(FRIED, "3000000000000000000");
495
463
console.log(tokenAmount.toExact()); // 3
496
464
```
497
- add
498
-
499
- subtract
500
-
501
- toSignificant
502
-
503
- toFixed
504
-
505
- toExact
506
-
465
+ + add
466
+ + subtract
467
+ + toSignificant
468
+ + toFixed
469
+ + toExact
507
470
508
471
Price:返回相对价格
509
472
```
@@ -533,31 +496,23 @@ console.log(price.toSignificant(3)); // 123
533
496
534
497
静态方法
535
498
536
- fromRoute
499
+ + fromRoute
537
500
538
501
属性
539
502
540
- baseToken
541
-
542
- quoteToken
543
-
544
- scalar:Fraction
545
-
546
- raw:Fraction
547
-
548
- adjusted:Fraction
549
-
503
+ + baseToken
504
+ + quoteToken
505
+ + scalar:Fraction
506
+ + raw:Fraction
507
+ + adjusted:Fraction
508
+
550
509
方法:
551
510
552
- invert
553
-
554
- multiply
555
-
556
- quote
557
-
558
- toSignificant
559
-
560
- toFixed
511
+ + invert
512
+ + multiply
513
+ + quote
514
+ + toSignificant
515
+ + toFixed
561
516
562
517
#### Fetcher
563
518
静态方法包含了获取链上交易对和token的实例,不可构造。
@@ -584,13 +539,13 @@ async fetchPairData(
584
539
585
540
586
541
#### Other Exports
587
- 1.JSBI
542
+ + 1.JSBI
588
543
```
589
544
import { JSBI } from "@uniswap/sdk";
590
545
// import JSBI from 'jsbi'
591
546
```
592
- 2.BigintIsh
593
- 3.ChainId
547
+ + 2.BigintIsh
548
+ + 3.ChainId
594
549
```
595
550
import { ChainId } from "@uniswap/sdk";
596
551
// enum ChainId {
@@ -610,7 +565,7 @@ import { TradeType } from "@uniswap/sdk";
610
565
// }
611
566
```
612
567
613
- 5.Rounding
568
+ + 5.Rounding
614
569
```
615
570
import { Rounding } from "@uniswap/sdk";
616
571
// enum Rounding {
@@ -619,15 +574,9 @@ import { Rounding } from "@uniswap/sdk";
619
574
// ROUND_UP
620
575
// }
621
576
```
622
- 6.FACTORY_ADDRESS
623
-
624
- 7.INIT_CODE_HASH
625
-
626
- 8.MINIMUM_LIQUIDITY
627
-
628
- 9.InsufficientReservesError
629
-
630
- 10.InsufficientInputAmountError
631
-
632
- 11.WETH
633
-
577
+ + 6.FACTORY_ADDRESS
578
+ + 7.INIT_CODE_HASH
579
+ + 8.MINIMUM_LIQUIDITY
580
+ + 9.InsufficientReservesError
581
+ + 10.InsufficientInputAmountError
582
+ + 11.WETH
0 commit comments