novaswap-v2-sdk 1.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.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/constants.d.ts +19 -0
- package/dist/entities/index.d.ts +3 -0
- package/dist/entities/pair.d.ts +147 -0
- package/dist/entities/route.d.ts +12 -0
- package/dist/entities/trade.d.ts +103 -0
- package/dist/errors.d.ts +16 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +8 -0
- package/dist/novaswap-v2-sdk.cjs.development.js +1069 -0
- package/dist/novaswap-v2-sdk.cjs.development.js.map +1 -0
- package/dist/novaswap-v2-sdk.cjs.production.min.js +2 -0
- package/dist/novaswap-v2-sdk.cjs.production.min.js.map +1 -0
- package/dist/novaswap-v2-sdk.esm.js +1052 -0
- package/dist/novaswap-v2-sdk.esm.js.map +1 -0
- package/dist/router.d.ts +64 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021 Uniswap Labs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# @uniswap/v2-sdk - Now at `Uniswap/sdks`
|
|
2
|
+
|
|
3
|
+
All versions after 4.3.0 of this SDK can be found in the [SDK monorepo](https://github.com/Uniswap/sdks/tree/main/sdks/v2-sdk)! Please file all future issues, PR’s, and discussions there.
|
|
4
|
+
|
|
5
|
+
### Old Issues and PR’s
|
|
6
|
+
|
|
7
|
+
If you have an issue or open PR that is still active on this SDK in this repository, please recreate it in the new repository. Some existing issues and PR’s may be automatically migrated by the Uniswap Labs team.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Percent } from '@uniswap/sdk-core';
|
|
2
|
+
import JSBI from 'jsbi';
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated use FACTORY_ADDRESS_MAP instead
|
|
5
|
+
*/
|
|
6
|
+
export declare const FACTORY_ADDRESS = "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f";
|
|
7
|
+
export declare const FACTORY_ADDRESS_MAP: {
|
|
8
|
+
[chainId: number]: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const INIT_CODE_HASH = "0x0ef7ca4700ff7e705236379af2cdac62d4fa0bbd010fb163697b63379941118e";
|
|
11
|
+
export declare const MINIMUM_LIQUIDITY: JSBI;
|
|
12
|
+
export declare const ZERO: JSBI;
|
|
13
|
+
export declare const ONE: JSBI;
|
|
14
|
+
export declare const FIVE: JSBI;
|
|
15
|
+
export declare const _997: JSBI;
|
|
16
|
+
export declare const _1000: JSBI;
|
|
17
|
+
export declare const BASIS_POINTS: JSBI;
|
|
18
|
+
export declare const ZERO_PERCENT: Percent;
|
|
19
|
+
export declare const ONE_HUNDRED_PERCENT: Percent;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { BigintIsh, CurrencyAmount, Price, Token } from '@uniswap/sdk-core';
|
|
2
|
+
export declare const computePairAddress: ({ factoryAddress, tokenA, tokenB }: {
|
|
3
|
+
factoryAddress: string;
|
|
4
|
+
tokenA: Token;
|
|
5
|
+
tokenB: Token;
|
|
6
|
+
}) => string;
|
|
7
|
+
export declare class Pair {
|
|
8
|
+
readonly liquidityToken: Token;
|
|
9
|
+
private readonly tokenAmounts;
|
|
10
|
+
static getAddress(tokenA: Token, tokenB: Token): string;
|
|
11
|
+
constructor(currencyAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>);
|
|
12
|
+
/**
|
|
13
|
+
* Returns true if the token is either token0 or token1
|
|
14
|
+
* @param token to check
|
|
15
|
+
*/
|
|
16
|
+
involvesToken(token: Token): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
|
|
19
|
+
*/
|
|
20
|
+
get token0Price(): Price<Token, Token>;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1
|
|
23
|
+
*/
|
|
24
|
+
get token1Price(): Price<Token, Token>;
|
|
25
|
+
/**
|
|
26
|
+
* Return the price of the given token in terms of the other token in the pair.
|
|
27
|
+
* @param token token to return price of
|
|
28
|
+
*/
|
|
29
|
+
priceOf(token: Token): Price<Token, Token>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the chain ID of the tokens in the pair.
|
|
32
|
+
*/
|
|
33
|
+
get chainId(): number;
|
|
34
|
+
get token0(): Token;
|
|
35
|
+
get token1(): Token;
|
|
36
|
+
get reserve0(): CurrencyAmount<Token>;
|
|
37
|
+
get reserve1(): CurrencyAmount<Token>;
|
|
38
|
+
reserveOf(token: Token): CurrencyAmount<Token>;
|
|
39
|
+
/**
|
|
40
|
+
* getAmountOut is the linear algebra of reserve ratio against amountIn:amountOut.
|
|
41
|
+
* https://ethereum.stackexchange.com/questions/101629/what-is-math-for-uniswap-calculates-the-amountout-and-amountin-why-997-and-1000
|
|
42
|
+
* has the math deduction for the reserve calculation without fee-on-transfer fees.
|
|
43
|
+
*
|
|
44
|
+
* With fee-on-transfer tax, intuitively it's just:
|
|
45
|
+
* inputAmountWithFeeAndTax = 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn
|
|
46
|
+
* = (1 - amountIn.sellFeesBips / 10000) * amountInWithFee
|
|
47
|
+
* where amountInWithFee is the amountIn after taking out the LP fees
|
|
48
|
+
* outputAmountWithTax = amountOut * (1 - amountOut.buyFeesBips / 10000)
|
|
49
|
+
*
|
|
50
|
+
* But we are illustrating the math deduction below to ensure that's the case.
|
|
51
|
+
*
|
|
52
|
+
* before swap A * B = K where A = reserveIn B = reserveOut
|
|
53
|
+
*
|
|
54
|
+
* after swap A' * B' = K where only k is a constant value
|
|
55
|
+
*
|
|
56
|
+
* getAmountOut
|
|
57
|
+
*
|
|
58
|
+
* A' = A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn # here 0.3% is deducted
|
|
59
|
+
* B' = B - amountOut * (1 - amountOut.buyFeesBips / 10000)
|
|
60
|
+
* amountOut = (B - B') / (1 - amountOut.buyFeesBips / 10000) # where A' * B' still is k
|
|
61
|
+
* = (B - K/(A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn))
|
|
62
|
+
* /
|
|
63
|
+
* (1 - amountOut.buyFeesBips / 10000)
|
|
64
|
+
* = (B - AB/(A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn))
|
|
65
|
+
* /
|
|
66
|
+
* (1 - amountOut.buyFeesBips / 10000)
|
|
67
|
+
* = ((BA + B * 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn - AB)/(A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn))
|
|
68
|
+
* /
|
|
69
|
+
* (1 - amountOut.buyFeesBips / 10000)
|
|
70
|
+
* = (B * 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn / (A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn)
|
|
71
|
+
* /
|
|
72
|
+
* (1 - amountOut.buyFeesBips / 10000)
|
|
73
|
+
* amountOut * (1 - amountOut.buyFeesBips / 10000) = (B * 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn
|
|
74
|
+
* /
|
|
75
|
+
* (A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn)
|
|
76
|
+
*
|
|
77
|
+
* outputAmountWithTax = (B * 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn
|
|
78
|
+
* /
|
|
79
|
+
* (A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn)
|
|
80
|
+
* = (B * 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn * 1000
|
|
81
|
+
* /
|
|
82
|
+
* ((A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn) * 1000)
|
|
83
|
+
* = (B * (1 - amountIn.sellFeesBips / 10000) 997 * * amountIn
|
|
84
|
+
* /
|
|
85
|
+
* (1000 * A + (1 - amountIn.sellFeesBips / 10000) * 997 * amountIn)
|
|
86
|
+
* = (B * (1 - amountIn.sellFeesBips / 10000) * inputAmountWithFee)
|
|
87
|
+
* /
|
|
88
|
+
* (1000 * A + (1 - amountIn.sellFeesBips / 10000) * inputAmountWithFee)
|
|
89
|
+
* = (B * inputAmountWithFeeAndTax)
|
|
90
|
+
* /
|
|
91
|
+
* (1000 * A + inputAmountWithFeeAndTax)
|
|
92
|
+
*
|
|
93
|
+
* inputAmountWithFeeAndTax = (1 - amountIn.sellFeesBips / 10000) * inputAmountWithFee
|
|
94
|
+
* outputAmountWithTax = amountOut * (1 - amountOut.buyFeesBips / 10000)
|
|
95
|
+
*
|
|
96
|
+
* @param inputAmount
|
|
97
|
+
* @param calculateFotFees
|
|
98
|
+
*/
|
|
99
|
+
getOutputAmount(inputAmount: CurrencyAmount<Token>, calculateFotFees?: boolean): [CurrencyAmount<Token>, Pair];
|
|
100
|
+
/**
|
|
101
|
+
* getAmountIn is the linear algebra of reserve ratio against amountIn:amountOut.
|
|
102
|
+
* https://ethereum.stackexchange.com/questions/101629/what-is-math-for-uniswap-calculates-the-amountout-and-amountin-why-997-and-1000
|
|
103
|
+
* has the math deduction for the reserve calculation without fee-on-transfer fees.
|
|
104
|
+
*
|
|
105
|
+
* With fee-on-transfer fees, intuitively it's just:
|
|
106
|
+
* outputAmountWithTax = amountOut / (1 - amountOut.buyFeesBips / 10000)
|
|
107
|
+
* inputAmountWithTax = amountIn / (1 - amountIn.sellFeesBips / 10000) / 0.997
|
|
108
|
+
*
|
|
109
|
+
* But we are illustrating the math deduction below to ensure that's the case.
|
|
110
|
+
*
|
|
111
|
+
* before swap A * B = K where A = reserveIn B = reserveOut
|
|
112
|
+
*
|
|
113
|
+
* after swap A' * B' = K where only k is a constant value
|
|
114
|
+
*
|
|
115
|
+
* getAmountIn
|
|
116
|
+
*
|
|
117
|
+
* B' = B - amountOut * (1 - amountOut.buyFeesBips / 10000)
|
|
118
|
+
* A' = A + 0.997 * (1 - amountIn.sellFeesBips / 10000) * amountIn # here 0.3% is deducted
|
|
119
|
+
* amountIn = (A' - A) / (0.997 * (1 - amountIn.sellFeesBips / 10000))
|
|
120
|
+
* = (K / (B - amountOut / (1 - amountOut.buyFeesBips / 10000)) - A)
|
|
121
|
+
* /
|
|
122
|
+
* (0.997 * (1 - amountIn.sellFeesBips / 10000))
|
|
123
|
+
* = (AB / (B - amountOut / (1 - amountOut.buyFeesBips / 10000)) - A)
|
|
124
|
+
* /
|
|
125
|
+
* (0.997 * (1 - amountIn.sellFeesBips / 10000))
|
|
126
|
+
* = ((AB - AB + A * amountOut / (1 - amountOut.buyFeesBips / 10000)) / (B - amountOut / (1 - amountOut.buyFeesBips / 10000)))
|
|
127
|
+
* /
|
|
128
|
+
* (0.997 * (1 - amountIn.sellFeesBips / 10000))
|
|
129
|
+
* = ((A * amountOut / (1 - amountOut.buyFeesBips / 10000)) / (B - amountOut / (1 - amountOut.buyFeesBips / 10000)))
|
|
130
|
+
* /
|
|
131
|
+
* (0.997 * (1 - amountIn.sellFeesBips / 10000))
|
|
132
|
+
* = ((A * 1000 * amountOut / (1 - amountOut.buyFeesBips / 10000)) / (B - amountOut / (1 - amountOut.buyFeesBips / 10000)))
|
|
133
|
+
* /
|
|
134
|
+
* (997 * (1 - amountIn.sellFeesBips / 10000))
|
|
135
|
+
*
|
|
136
|
+
* outputAmountWithTax = amountOut / (1 - amountOut.buyFeesBips / 10000)
|
|
137
|
+
* inputAmountWithTax = amountIn / (997 * (1 - amountIn.sellFeesBips / 10000))
|
|
138
|
+
* = (A * outputAmountWithTax * 1000) / ((B - outputAmountWithTax) * 997)
|
|
139
|
+
*
|
|
140
|
+
* @param outputAmount
|
|
141
|
+
*/
|
|
142
|
+
getInputAmount(outputAmount: CurrencyAmount<Token>, calculateFotFees?: boolean): [CurrencyAmount<Token>, Pair];
|
|
143
|
+
getLiquidityMinted(totalSupply: CurrencyAmount<Token>, tokenAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>): CurrencyAmount<Token>;
|
|
144
|
+
getLiquidityValue(token: Token, totalSupply: CurrencyAmount<Token>, liquidity: CurrencyAmount<Token>, feeOn?: boolean, kLast?: BigintIsh): CurrencyAmount<Token>;
|
|
145
|
+
private derivePercentAfterSellFees;
|
|
146
|
+
private derivePercentAfterBuyFees;
|
|
147
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Currency, Price, Token } from '@uniswap/sdk-core';
|
|
2
|
+
import { Pair } from './pair';
|
|
3
|
+
export declare class Route<TInput extends Currency, TOutput extends Currency> {
|
|
4
|
+
readonly pairs: Pair[];
|
|
5
|
+
readonly path: Token[];
|
|
6
|
+
readonly input: TInput;
|
|
7
|
+
readonly output: TOutput;
|
|
8
|
+
constructor(pairs: Pair[], input: TInput, output: TOutput);
|
|
9
|
+
private _midPrice;
|
|
10
|
+
get midPrice(): Price<TInput, TOutput>;
|
|
11
|
+
get chainId(): number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Currency, CurrencyAmount, Percent, Price, TradeType } from '@uniswap/sdk-core';
|
|
2
|
+
import { Pair } from './pair';
|
|
3
|
+
import { Route } from './route';
|
|
4
|
+
interface InputOutput<TInput extends Currency, TOutput extends Currency> {
|
|
5
|
+
readonly inputAmount: CurrencyAmount<TInput>;
|
|
6
|
+
readonly outputAmount: CurrencyAmount<TOutput>;
|
|
7
|
+
}
|
|
8
|
+
export declare function inputOutputComparator<TInput extends Currency, TOutput extends Currency>(a: InputOutput<TInput, TOutput>, b: InputOutput<TInput, TOutput>): number;
|
|
9
|
+
export declare function tradeComparator<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(a: Trade<TInput, TOutput, TTradeType>, b: Trade<TInput, TOutput, TTradeType>): number;
|
|
10
|
+
export interface BestTradeOptions {
|
|
11
|
+
maxNumResults?: number;
|
|
12
|
+
maxHops?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Represents a trade executed against a list of pairs.
|
|
16
|
+
* Does not account for slippage, i.e. trades that front run this trade and move the price.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
|
|
19
|
+
/**
|
|
20
|
+
* The route of the trade, i.e. which pairs the trade goes through and the input/output currencies.
|
|
21
|
+
*/
|
|
22
|
+
readonly route: Route<TInput, TOutput>;
|
|
23
|
+
/**
|
|
24
|
+
* The type of the trade, either exact in or exact out.
|
|
25
|
+
*/
|
|
26
|
+
readonly tradeType: TTradeType;
|
|
27
|
+
/**
|
|
28
|
+
* The input amount for the trade assuming no slippage.
|
|
29
|
+
*/
|
|
30
|
+
readonly inputAmount: CurrencyAmount<TInput>;
|
|
31
|
+
/**
|
|
32
|
+
* The output amount for the trade assuming no slippage.
|
|
33
|
+
*/
|
|
34
|
+
readonly outputAmount: CurrencyAmount<TOutput>;
|
|
35
|
+
/**
|
|
36
|
+
* The price expressed in terms of output amount/input amount.
|
|
37
|
+
*/
|
|
38
|
+
readonly executionPrice: Price<TInput, TOutput>;
|
|
39
|
+
/**
|
|
40
|
+
* The percent difference between the mid price before the trade and the trade execution price.
|
|
41
|
+
*/
|
|
42
|
+
readonly priceImpact: Percent;
|
|
43
|
+
/**
|
|
44
|
+
* Constructs an exact in trade with the given amount in and route
|
|
45
|
+
* @param route route of the exact in trade
|
|
46
|
+
* @param amountIn the amount being passed in
|
|
47
|
+
*/
|
|
48
|
+
static exactIn<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountIn: CurrencyAmount<TInput>): Trade<TInput, TOutput, TradeType.EXACT_INPUT>;
|
|
49
|
+
/**
|
|
50
|
+
* Constructs an exact out trade with the given amount out and route
|
|
51
|
+
* @param route route of the exact out trade
|
|
52
|
+
* @param amountOut the amount returned by the trade
|
|
53
|
+
*/
|
|
54
|
+
static exactOut<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountOut: CurrencyAmount<TOutput>): Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>;
|
|
55
|
+
constructor(route: Route<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType);
|
|
56
|
+
/**
|
|
57
|
+
* Get the minimum amount that must be received from this trade for the given slippage tolerance
|
|
58
|
+
* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
|
|
59
|
+
*/
|
|
60
|
+
minimumAmountOut(slippageTolerance: Percent): CurrencyAmount<TOutput>;
|
|
61
|
+
/**
|
|
62
|
+
* Get the maximum amount in that can be spent via this trade for the given slippage tolerance
|
|
63
|
+
* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
|
|
64
|
+
*/
|
|
65
|
+
maximumAmountIn(slippageTolerance: Percent): CurrencyAmount<TInput>;
|
|
66
|
+
/**
|
|
67
|
+
* Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
|
|
68
|
+
* amount to an output token, making at most `maxHops` hops.
|
|
69
|
+
* Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
|
|
70
|
+
* the amount in among multiple routes.
|
|
71
|
+
* @param pairs the pairs to consider in finding the best trade
|
|
72
|
+
* @param nextAmountIn exact amount of input currency to spend
|
|
73
|
+
* @param currencyOut the desired currency out
|
|
74
|
+
* @param maxNumResults maximum number of results to return
|
|
75
|
+
* @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
|
|
76
|
+
* @param currentPairs used in recursion; the current list of pairs
|
|
77
|
+
* @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
|
|
78
|
+
* @param bestTrades used in recursion; the current list of best trades
|
|
79
|
+
*/
|
|
80
|
+
static bestTradeExactIn<TInput extends Currency, TOutput extends Currency>(pairs: Pair[], currencyAmountIn: CurrencyAmount<TInput>, currencyOut: TOutput, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: Pair[], nextAmountIn?: CurrencyAmount<Currency>, bestTrades?: Trade<TInput, TOutput, TradeType.EXACT_INPUT>[]): Trade<TInput, TOutput, TradeType.EXACT_INPUT>[];
|
|
81
|
+
/**
|
|
82
|
+
* Return the execution price after accounting for slippage tolerance
|
|
83
|
+
* @param slippageTolerance the allowed tolerated slippage
|
|
84
|
+
*/
|
|
85
|
+
worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput>;
|
|
86
|
+
/**
|
|
87
|
+
* similar to the above method but instead targets a fixed output amount
|
|
88
|
+
* given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
|
|
89
|
+
* to an output token amount, making at most `maxHops` hops
|
|
90
|
+
* note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting
|
|
91
|
+
* the amount in among multiple routes.
|
|
92
|
+
* @param pairs the pairs to consider in finding the best trade
|
|
93
|
+
* @param currencyIn the currency to spend
|
|
94
|
+
* @param nextAmountOut the exact amount of currency out
|
|
95
|
+
* @param maxNumResults maximum number of results to return
|
|
96
|
+
* @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
|
|
97
|
+
* @param currentPairs used in recursion; the current list of pairs
|
|
98
|
+
* @param currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter
|
|
99
|
+
* @param bestTrades used in recursion; the current list of best trades
|
|
100
|
+
*/
|
|
101
|
+
static bestTradeExactOut<TInput extends Currency, TOutput extends Currency>(pairs: Pair[], currencyIn: TInput, currencyAmountOut: CurrencyAmount<TOutput>, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: Pair[], nextAmountOut?: CurrencyAmount<Currency>, bestTrades?: Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[]): Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>[];
|
|
102
|
+
}
|
|
103
|
+
export {};
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Indicates that the pair has insufficient reserves for a desired output amount. I.e. the amount of output cannot be
|
|
3
|
+
* obtained by sending any amount of input.
|
|
4
|
+
*/
|
|
5
|
+
export declare class InsufficientReservesError extends Error {
|
|
6
|
+
readonly isInsufficientReservesError: true;
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Indicates that the input amount is too small to produce any amount of output. I.e. the amount of input sent is less
|
|
11
|
+
* than the price of a single unit of output after fees.
|
|
12
|
+
*/
|
|
13
|
+
export declare class InsufficientInputAmountError extends Error {
|
|
14
|
+
readonly isInsufficientInputAmountError: true;
|
|
15
|
+
constructor();
|
|
16
|
+
}
|
package/dist/index.d.ts
ADDED