Skip to content

Commit 1e7b00e

Browse files
committed
fix bestTradeExactIn
1 parent d847749 commit 1e7b00e

File tree

1 file changed

+78
-129
lines changed

1 file changed

+78
-129
lines changed

defi/Uniswap-V2/SDK/readme.md

+78-129
Original file line numberDiff line numberDiff line change
@@ -210,24 +210,18 @@ const token = new Token(
210210

211211
**核心的属性包括:**
212212

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+
+
223219
**方法包括**
224-
equals
225-
226-
判断是不是一个币
227-
228-
sortsBefore
229220

230-
按地址排序下判断相对位置
221+
+ equals
222+
+ 判断是不是一个币
223+
+ sortsBefore
224+
按地址排序下判断相对位置
231225

232226

233227
#### Pair
@@ -264,28 +258,20 @@ const pair = new Pair(
264258

265259
**关键属性**
266260

267-
liquidityToken
268-
269-
token0
270-
271-
reserve0
272-
273-
reserve1
274-
261+
+ liquidityToken
262+
+ token0
263+
+ reserve0
264+
+ reserve1
265+
+
275266

276267
**方法**
277268

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+
+ 计算总体流动性
289275

290276
```
291277
getLiquidityValue(
@@ -299,7 +285,7 @@ getLiquidityValue(
299285

300286
静态方法:getAddress
301287

302-
获得交易对方法
288+
+ 获得交易对方法
303289

304290
```
305291
getAddress(tokenA: Token, tokenB: Token): string
@@ -340,15 +326,11 @@ const route = new Route([HOT_NOT], NOT);
340326
```
341327
**关键属性**
342328

343-
pairs
344-
345-
path
346-
347-
input
348-
349-
output
350-
351-
midPrice
329+
+ pairs
330+
+ path
331+
+ input
332+
+ output
333+
+ midPrice
352334

353335
#### Trade
354336
交易实体代表沿着特定route的一次Tx,包含所有参数信息。
@@ -396,32 +378,26 @@ const trade = new Trade(
396378
```
397379
**关键属性**
398380

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
412388

413389
**方法**
414390

415-
minimumAmountOut(2.04后)
416-
417-
maximumAmountIn(2.04后)
391+
+ minimumAmountOut(2.04后)
392+
+ maximumAmountIn(2.04后)
418393

419394

420395
Static methods:
421396

422-
bestTradeExactIn
397+
+ bestTradeExactIn
423398

424-
返回最大值可能
399+
返回TradeIn方式的最大兑换数量结果(最低手续费),也就是最优兑换路径,包括hop数等,返回数据类型是Trade数组。
400+
感谢三火check指正~
425401

426402
```
427403
Trade.bestTradeExactIn(
@@ -443,28 +419,20 @@ constructor(numerator: BigintIsh, denominator: BigintIsh = ONE)
443419

444420
都是JSBI
445421

446-
numerator
447-
448-
denominator
449-
450-
quotient
422+
+ numerator
423+
+ denominator
424+
+ quotient
451425

452426

453427
**方法**
454428

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
468436

469437

470438
Percent:格式化百分比
@@ -474,9 +442,9 @@ import { Percent } from "@uniswap/sdk";
474442
const percent = new Percent("60", "100");
475443
console.log(percent.toSignificant(2)); // 60
476444
```
477-
toSignificant
445+
+ toSignificant
478446

479-
toFixed
447+
+ toFixed
480448

481449
TokenAmount:返回指定精度余额
482450

@@ -494,16 +462,11 @@ const FRIED = new Token(
494462
const tokenAmount = new TokenAmount(FRIED, "3000000000000000000");
495463
console.log(tokenAmount.toExact()); // 3
496464
```
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
507470

508471
Price:返回相对价格
509472
```
@@ -533,31 +496,23 @@ console.log(price.toSignificant(3)); // 123
533496

534497
静态方法
535498

536-
fromRoute
499+
+ fromRoute
537500

538501
属性
539502

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+
550509
方法:
551510

552-
invert
553-
554-
multiply
555-
556-
quote
557-
558-
toSignificant
559-
560-
toFixed
511+
+ invert
512+
+ multiply
513+
+ quote
514+
+ toSignificant
515+
+ toFixed
561516

562517
#### Fetcher
563518
静态方法包含了获取链上交易对和token的实例,不可构造。
@@ -584,13 +539,13 @@ async fetchPairData(
584539

585540

586541
#### Other Exports
587-
1.JSBI
542+
+ 1.JSBI
588543
```
589544
import { JSBI } from "@uniswap/sdk";
590545
// import JSBI from 'jsbi'
591546
```
592-
2.BigintIsh
593-
3.ChainId
547+
+ 2.BigintIsh
548+
+ 3.ChainId
594549
```
595550
import { ChainId } from "@uniswap/sdk";
596551
// enum ChainId {
@@ -610,7 +565,7 @@ import { TradeType } from "@uniswap/sdk";
610565
// }
611566
```
612567

613-
5.Rounding
568+
+ 5.Rounding
614569
```
615570
import { Rounding } from "@uniswap/sdk";
616571
// enum Rounding {
@@ -619,15 +574,9 @@ import { Rounding } from "@uniswap/sdk";
619574
// ROUND_UP
620575
// }
621576
```
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

Comments
 (0)