@qidao/sdk 5.0.0-canary.117 → 5.0.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.
Files changed (97) hide show
  1. package/dist/constants.d.ts +77 -0
  2. package/dist/entities/currency.d.ts +61 -0
  3. package/dist/entities/fractions/currencyAmount.d.ts +19 -0
  4. package/dist/entities/{Fraction.d.ts → fractions/fraction.d.ts} +1 -7
  5. package/dist/entities/fractions/index.d.ts +5 -0
  6. package/dist/entities/fractions/percent.d.ts +6 -0
  7. package/dist/entities/fractions/price.d.ts +19 -0
  8. package/dist/entities/fractions/tokenAmount.d.ts +9 -0
  9. package/dist/entities/index.d.ts +6 -14
  10. package/dist/entities/pair.d.ts +41 -0
  11. package/dist/entities/route.d.ts +14 -0
  12. package/dist/entities/{Token.d.ts → token.d.ts} +29 -11
  13. package/dist/entities/{Trade.d.ts → trade.d.ts} +34 -35
  14. package/dist/fetcher.d.ts +28 -0
  15. package/dist/index.d.ts +2 -7
  16. package/dist/router.d.ts +2 -7
  17. package/dist/sdk.cjs.development.js +1050 -4663
  18. package/dist/sdk.cjs.development.js.map +1 -1
  19. package/dist/sdk.cjs.production.min.js +1 -1
  20. package/dist/sdk.cjs.production.min.js.map +1 -1
  21. package/dist/sdk.esm.js +1045 -4547
  22. package/dist/sdk.esm.js.map +1 -1
  23. package/dist/test/constants.test.d.ts +1 -0
  24. package/dist/test/data.test.d.ts +1 -0
  25. package/dist/test/entities.test.d.ts +1 -0
  26. package/dist/test/fraction.test.d.ts +1 -0
  27. package/dist/test/miscellaneous.test.d.ts +1 -0
  28. package/dist/test/pair.test.d.ts +1 -0
  29. package/dist/test/route.test.d.ts +1 -0
  30. package/dist/test/router.test.d.ts +1 -0
  31. package/dist/test/token.test.d.ts +1 -0
  32. package/dist/test/trade.test.d.ts +1 -0
  33. package/dist/utils.d.ts +7 -0
  34. package/package.json +31 -45
  35. package/dist/constants/addresses.d.ts +0 -31
  36. package/dist/constants/index.d.ts +0 -20
  37. package/dist/constants/kashi.d.ts +0 -29
  38. package/dist/constants/natives.d.ts +0 -30
  39. package/dist/constants/numbers.d.ts +0 -11
  40. package/dist/constants/tokens.d.ts +0 -5
  41. package/dist/entities/AbstractCurrency.d.ts +0 -53
  42. package/dist/entities/ConstantProductPool.d.ts +0 -43
  43. package/dist/entities/Currency.d.ts +0 -3
  44. package/dist/entities/CurrencyAmount.d.ts +0 -38
  45. package/dist/entities/MultiRouter.d.ts +0 -59
  46. package/dist/entities/Native/Avalanche.d.ts +0 -10
  47. package/dist/entities/Native/Binance.d.ts +0 -10
  48. package/dist/entities/Native/Celo.d.ts +0 -10
  49. package/dist/entities/Native/Ether.d.ts +0 -13
  50. package/dist/entities/Native/Fantom.d.ts +0 -10
  51. package/dist/entities/Native/Fuse.d.ts +0 -10
  52. package/dist/entities/Native/Harmony.d.ts +0 -10
  53. package/dist/entities/Native/Heco.d.ts +0 -10
  54. package/dist/entities/Native/Matic.d.ts +0 -10
  55. package/dist/entities/Native/Movr.d.ts +0 -10
  56. package/dist/entities/Native/Okex.d.ts +0 -10
  57. package/dist/entities/Native/Palm.d.ts +0 -10
  58. package/dist/entities/Native/Telos.d.ts +0 -10
  59. package/dist/entities/Native/index.d.ts +0 -14
  60. package/dist/entities/Native/xDai.d.ts +0 -10
  61. package/dist/entities/NativeCurrency.d.ts +0 -8
  62. package/dist/entities/Pair.d.ts +0 -41
  63. package/dist/entities/Percent.d.ts +0 -15
  64. package/dist/entities/Price.d.ts +0 -39
  65. package/dist/entities/Route.d.ts +0 -14
  66. package/dist/entities/eip712.d.ts +0 -78
  67. package/dist/enums/ChainId.d.ts +0 -31
  68. package/dist/enums/Fee.d.ts +0 -3
  69. package/dist/enums/KashiAction.d.ts +0 -18
  70. package/dist/enums/OrderStatus.d.ts +0 -6
  71. package/dist/enums/Rounding.d.ts +0 -5
  72. package/dist/enums/TradeType.d.ts +0 -4
  73. package/dist/enums/index.d.ts +0 -6
  74. package/dist/functions/bentobox.d.ts +0 -3
  75. package/dist/functions/computeConstantProductPoolAddress.d.ts +0 -9
  76. package/dist/functions/computePairAddress.d.ts +0 -6
  77. package/dist/functions/computePoolInitCodeHash.d.ts +0 -5
  78. package/dist/functions/computePriceImpact.d.ts +0 -11
  79. package/dist/functions/index.d.ts +0 -8
  80. package/dist/functions/kashi.d.ts +0 -9
  81. package/dist/functions/rebase.d.ts +0 -4
  82. package/dist/functions/sortedInsert.d.ts +0 -1
  83. package/dist/functions/sqrt.d.ts +0 -7
  84. package/dist/functions/validateAndParseAddress.d.ts +0 -1
  85. package/dist/functions/validateSolidityTypeInstance.d.ts +0 -3
  86. package/dist/interfaces/AccrueInfo.d.ts +0 -6
  87. package/dist/interfaces/Rebase.d.ts +0 -5
  88. package/dist/interfaces/index.d.ts +0 -2
  89. package/dist/limitorder.d.ts +0 -115
  90. package/dist/types/AddressMap.d.ts +0 -3
  91. package/dist/types/BigIntIsh.d.ts +0 -2
  92. package/dist/types/ChainTokenMap.d.ts +0 -5
  93. package/dist/types/LimitOrderTypes.d.ts +0 -21
  94. package/dist/types/MultiRouterTypes.d.ts +0 -97
  95. package/dist/types/TokenMap.d.ts +0 -4
  96. package/dist/types/index.d.ts +0 -4
  97. package/dist/utils/MultiRouterMath.d.ts +0 -15
@@ -0,0 +1,77 @@
1
+ import JSBI from 'jsbi';
2
+ export declare type BigintIsh = JSBI | bigint | string;
3
+ export declare enum ChainId {
4
+ MAINNET = 1,
5
+ ROPSTEN = 3,
6
+ RINKEBY = 4,
7
+ GÖRLI = 5,
8
+ KOVAN = 42,
9
+ MATIC = 137,
10
+ MATIC_TESTNET = 80001,
11
+ FANTOM = 250,
12
+ FANTOM_TESTNET = 4002,
13
+ XDAI = 100,
14
+ BSC = 56,
15
+ BSC_TESTNET = 97,
16
+ ARBITRUM = 42161,
17
+ MOONBASE = 1287,
18
+ MOONBEAM = 1284,
19
+ AVALANCHE = 43114,
20
+ FUJI = 43113,
21
+ HECO = 128,
22
+ HECO_TESTNET = 256,
23
+ HARMONY = 1666600000,
24
+ HARMONY_TESTNET = 1666700000,
25
+ MOONRIVER = 1285,
26
+ CRONOS = 25,
27
+ OPTIMISM = 10
28
+ }
29
+ export declare enum TradeType {
30
+ EXACT_INPUT = 0,
31
+ EXACT_OUTPUT = 1
32
+ }
33
+ export declare enum Rounding {
34
+ ROUND_DOWN = 0,
35
+ ROUND_HALF_UP = 1,
36
+ ROUND_UP = 2
37
+ }
38
+ export declare const INIT_CODE_HASH: string;
39
+ export declare const FACTORY_ADDRESS: {
40
+ [chainId in ChainId]: string;
41
+ };
42
+ export declare const ROUTER_ADDRESS: {
43
+ [chainId in ChainId]: string;
44
+ };
45
+ export declare const SUSHI_ADDRESS: {
46
+ [chainId in ChainId]: string;
47
+ };
48
+ export declare const MASTERCHEF_ADDRESS: {
49
+ [chainId in ChainId]: string;
50
+ };
51
+ export declare const BAR_ADDRESS: {
52
+ [chainId in ChainId]: string;
53
+ };
54
+ export declare const MAKER_ADDRESS: {
55
+ [chainId in ChainId]: string;
56
+ };
57
+ export declare const TIMELOCK_ADDRESS: {
58
+ [chainId in ChainId]: string;
59
+ };
60
+ export declare const MINIMUM_LIQUIDITY: JSBI;
61
+ export declare const ZERO: JSBI;
62
+ export declare const ONE: JSBI;
63
+ export declare const TWO: JSBI;
64
+ export declare const THREE: JSBI;
65
+ export declare const FIVE: JSBI;
66
+ export declare const TEN: JSBI;
67
+ export declare const _100: JSBI;
68
+ export declare const _997: JSBI;
69
+ export declare const _1000: JSBI;
70
+ export declare enum SolidityType {
71
+ uint8 = "uint8",
72
+ uint256 = "uint256"
73
+ }
74
+ export declare const SOLIDITY_TYPE_MAXIMA: {
75
+ uint8: JSBI;
76
+ uint256: JSBI;
77
+ };
@@ -0,0 +1,61 @@
1
+ import { ChainId } from '../constants';
2
+ /**
3
+ * A currency is any fungible financial instrument on Ethereum, including Ether and all ERC20 tokens.
4
+ *
5
+ * The only instance of the base class `Currency` is Ether.
6
+ */
7
+ export declare class Currency {
8
+ readonly decimals: number;
9
+ readonly symbol?: string;
10
+ readonly name?: string;
11
+ static readonly ETHER: Currency;
12
+ static readonly BNB: Currency;
13
+ static readonly FTM: Currency;
14
+ static readonly MATIC: Currency;
15
+ static readonly XDAI: Currency;
16
+ static readonly GLMR: Currency;
17
+ static readonly AVAX: Currency;
18
+ static readonly HT: Currency;
19
+ static readonly ONE: Currency;
20
+ static readonly MOVR: Currency;
21
+ static readonly CRO: Currency;
22
+ static readonly NATIVE: {
23
+ 1: Currency;
24
+ 3: Currency;
25
+ 4: Currency;
26
+ 5: Currency;
27
+ 42: Currency;
28
+ 250: Currency;
29
+ 4002: Currency;
30
+ 137: Currency;
31
+ 80001: Currency;
32
+ 100: Currency;
33
+ 56: Currency;
34
+ 97: Currency;
35
+ 42161: Currency;
36
+ 1287: Currency;
37
+ 43114: Currency;
38
+ 43113: Currency;
39
+ 128: Currency;
40
+ 256: Currency;
41
+ 1666600000: Currency;
42
+ 1666700000: Currency;
43
+ 25: Currency;
44
+ 1285: Currency;
45
+ 10: Currency;
46
+ };
47
+ /**
48
+ * Constructs an instance of the base class `Currency`. The only instance of the base class `Currency` is `Currency.ETHER`.
49
+ * @param decimals decimals of the currency
50
+ * @param symbol symbol of the currency
51
+ * @param name of the currency
52
+ */
53
+ protected constructor(decimals: number, symbol?: string, name?: string);
54
+ static getNativeCurrency(chainId?: ChainId): Currency;
55
+ static getNativeCurrencySymbol(chainId?: ChainId): string | undefined;
56
+ static getNativeCurrencyName(chainId?: ChainId): string | undefined;
57
+ getSymbol(chainId?: ChainId): string | undefined;
58
+ getName(chainId?: ChainId): string | undefined;
59
+ }
60
+ declare const ETHER: Currency;
61
+ export { ETHER };
@@ -0,0 +1,19 @@
1
+ import { Currency } from '../currency';
2
+ import JSBI from 'jsbi';
3
+ import { BigintIsh, Rounding } from '../../constants';
4
+ import { Fraction } from './fraction';
5
+ export declare class CurrencyAmount extends Fraction {
6
+ readonly currency: Currency;
7
+ /**
8
+ * Helper that calls the constructor with the ETHER currency
9
+ * @param amount ether amount in wei
10
+ */
11
+ static ether(amount: BigintIsh): CurrencyAmount;
12
+ protected constructor(currency: Currency, amount: BigintIsh);
13
+ get raw(): JSBI;
14
+ add(other: CurrencyAmount): CurrencyAmount;
15
+ subtract(other: CurrencyAmount): CurrencyAmount;
16
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
17
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
18
+ toExact(format?: object): string;
19
+ }
@@ -1,11 +1,9 @@
1
- import { BigintIsh } from '../types';
2
1
  import JSBI from 'jsbi';
3
- import { Rounding } from '../enums';
2
+ import { BigintIsh, Rounding } from '../../constants';
4
3
  export declare class Fraction {
5
4
  readonly numerator: JSBI;
6
5
  readonly denominator: JSBI;
7
6
  constructor(numerator: BigintIsh, denominator?: BigintIsh);
8
- private static tryParseFraction;
9
7
  get quotient(): JSBI;
10
8
  get remainder(): Fraction;
11
9
  invert(): Fraction;
@@ -18,8 +16,4 @@ export declare class Fraction {
18
16
  divide(other: Fraction | BigintIsh): Fraction;
19
17
  toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
20
18
  toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
21
- /**
22
- * Helper method for converting any super class back to a fraction
23
- */
24
- get asFraction(): Fraction;
25
19
  }
@@ -0,0 +1,5 @@
1
+ export * from './fraction';
2
+ export * from './percent';
3
+ export * from './tokenAmount';
4
+ export * from './currencyAmount';
5
+ export * from './price';
@@ -0,0 +1,6 @@
1
+ import { Rounding } from '../../constants';
2
+ import { Fraction } from './fraction';
3
+ export declare class Percent extends Fraction {
4
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
5
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
6
+ }
@@ -0,0 +1,19 @@
1
+ import { BigintIsh, Rounding } from '../../constants';
2
+ import { Currency } from '../currency';
3
+ import { Route } from '../route';
4
+ import { Fraction } from './fraction';
5
+ import { CurrencyAmount } from './currencyAmount';
6
+ export declare class Price extends Fraction {
7
+ readonly baseCurrency: Currency;
8
+ readonly quoteCurrency: Currency;
9
+ readonly scalar: Fraction;
10
+ static fromRoute(route: Route): Price;
11
+ constructor(baseCurrency: Currency, quoteCurrency: Currency, denominator: BigintIsh, numerator: BigintIsh);
12
+ get raw(): Fraction;
13
+ get adjusted(): Fraction;
14
+ invert(): Price;
15
+ multiply(other: Price): Price;
16
+ quote(currencyAmount: CurrencyAmount): CurrencyAmount;
17
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
18
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
19
+ }
@@ -0,0 +1,9 @@
1
+ import { CurrencyAmount } from './currencyAmount';
2
+ import { Token } from '../token';
3
+ import { BigintIsh } from '../../constants';
4
+ export declare class TokenAmount extends CurrencyAmount {
5
+ readonly token: Token;
6
+ constructor(token: Token, amount: BigintIsh);
7
+ add(other: TokenAmount): TokenAmount;
8
+ subtract(other: TokenAmount): TokenAmount;
9
+ }
@@ -1,14 +1,6 @@
1
- export * from './AbstractCurrency';
2
- export * from './Currency';
3
- export * from './CurrencyAmount';
4
- export * from './ConstantProductPool';
5
- export * from './Fraction';
6
- export * from './NativeCurrency';
7
- export * from './Pair';
8
- export * from './Percent';
9
- export * from './Price';
10
- export * from './Route';
11
- export * from './Token';
12
- export * from './Trade';
13
- export * from './Native';
14
- export * from './eip712';
1
+ export * from './token';
2
+ export * from './pair';
3
+ export * from './route';
4
+ export * from './trade';
5
+ export * from './currency';
6
+ export * from './fractions';
@@ -0,0 +1,41 @@
1
+ import { Price } from './fractions/price';
2
+ import { TokenAmount } from './fractions/tokenAmount';
3
+ import { BigintIsh, ChainId } from '../constants';
4
+ import { Token } from './token';
5
+ export declare class Pair {
6
+ readonly liquidityToken: Token;
7
+ private readonly tokenAmounts;
8
+ static getAddress(tokenA: Token, tokenB: Token): string;
9
+ constructor(tokenAmountA: TokenAmount, tokenAmountB: TokenAmount);
10
+ /**
11
+ * Returns true if the token is either token0 or token1
12
+ * @param token to check
13
+ */
14
+ involvesToken(token: Token): boolean;
15
+ /**
16
+ * Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
17
+ */
18
+ get token0Price(): Price;
19
+ /**
20
+ * Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1
21
+ */
22
+ get token1Price(): Price;
23
+ /**
24
+ * Return the price of the given token in terms of the other token in the pair.
25
+ * @param token token to return price of
26
+ */
27
+ priceOf(token: Token): Price;
28
+ /**
29
+ * Returns the chain ID of the tokens in the pair.
30
+ */
31
+ get chainId(): ChainId;
32
+ get token0(): Token;
33
+ get token1(): Token;
34
+ get reserve0(): TokenAmount;
35
+ get reserve1(): TokenAmount;
36
+ reserveOf(token: Token): TokenAmount;
37
+ getOutputAmount(inputAmount: TokenAmount): [TokenAmount, Pair];
38
+ getInputAmount(outputAmount: TokenAmount): [TokenAmount, Pair];
39
+ getLiquidityMinted(totalSupply: TokenAmount, tokenAmountA: TokenAmount, tokenAmountB: TokenAmount): TokenAmount;
40
+ getLiquidityValue(token: Token, totalSupply: TokenAmount, liquidity: TokenAmount, feeOn?: boolean, kLast?: BigintIsh): TokenAmount;
41
+ }
@@ -0,0 +1,14 @@
1
+ import { ChainId } from '../constants';
2
+ import { Currency } from './currency';
3
+ import { Token } from './token';
4
+ import { Pair } from './pair';
5
+ import { Price } from './fractions/price';
6
+ export declare class Route {
7
+ readonly pairs: Pair[];
8
+ readonly path: Token[];
9
+ readonly input: Currency;
10
+ readonly output: Currency;
11
+ readonly midPrice: Price;
12
+ constructor(pairs: Pair[], input: Currency, output?: Currency);
13
+ get chainId(): ChainId;
14
+ }
@@ -1,20 +1,17 @@
1
- import { AbstractCurrency } from './AbstractCurrency';
2
- import { ChainId } from '../enums';
3
- import { Currency } from './Currency';
1
+ import { ChainId } from '../constants';
2
+ import { Currency } from './currency';
4
3
  /**
5
4
  * Represents an ERC20 token with a unique address and some metadata.
6
5
  */
7
- export declare class Token extends AbstractCurrency {
6
+ export declare class Token extends Currency {
8
7
  readonly chainId: ChainId;
9
8
  readonly address: string;
10
- readonly isNative: false;
11
- readonly isToken: true;
12
9
  constructor(chainId: ChainId, address: string, decimals: number, symbol?: string, name?: string);
13
10
  /**
14
11
  * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
15
12
  * @param other other token to compare
16
13
  */
17
- equals(other: Currency): boolean;
14
+ equals(other: Token): boolean;
18
15
  /**
19
16
  * Returns true if the address of this token sorts before the address of the other token
20
17
  * @param other other token to compare
@@ -22,12 +19,33 @@ export declare class Token extends AbstractCurrency {
22
19
  * @throws if the tokens are on different chains
23
20
  */
24
21
  sortsBefore(other: Token): boolean;
25
- /**
26
- * Return this token, which does not need to be wrapped
27
- */
28
- get wrapped(): Token;
29
22
  }
30
23
  /**
31
24
  * Compares two currencies for equality
32
25
  */
33
26
  export declare function currencyEquals(currencyA: Currency, currencyB: Currency): boolean;
27
+ export declare const WETH: {
28
+ 1: Token;
29
+ 3: Token;
30
+ 4: Token;
31
+ 5: Token;
32
+ 42: Token;
33
+ 250: Token;
34
+ 4002: Token;
35
+ 137: Token;
36
+ 80001: Token;
37
+ 100: Token;
38
+ 56: Token;
39
+ 97: Token;
40
+ 42161: Token;
41
+ 1287: Token;
42
+ 43114: Token;
43
+ 43113: Token;
44
+ 128: Token;
45
+ 256: Token;
46
+ 1666600000: Token;
47
+ 1666700000: Token;
48
+ 25: Token;
49
+ 10: Token;
50
+ 1285: Token;
51
+ };
@@ -1,16 +1,16 @@
1
- import { Currency } from './Currency';
2
- import { CurrencyAmount } from './CurrencyAmount';
3
- import { Pair } from './Pair';
4
- import { Percent } from './Percent';
5
- import { Price } from './Price';
6
- import { Route } from './Route';
7
- import { TradeType } from '../enums';
8
- interface InputOutput<TInput extends Currency, TOutput extends Currency> {
9
- readonly inputAmount: CurrencyAmount<TInput>;
10
- readonly outputAmount: CurrencyAmount<TOutput>;
1
+ import { TradeType } from '../constants';
2
+ import { Currency } from './currency';
3
+ import { CurrencyAmount } from './fractions/currencyAmount';
4
+ import { Percent } from './fractions/percent';
5
+ import { Price } from './fractions/price';
6
+ import { Pair } from './pair';
7
+ import { Route } from './route';
8
+ interface InputOutput {
9
+ readonly inputAmount: CurrencyAmount;
10
+ readonly outputAmount: CurrencyAmount;
11
11
  }
12
- export declare function inputOutputComparator<TInput extends Currency, TOutput extends Currency>(a: InputOutput<TInput, TOutput>, b: InputOutput<TInput, TOutput>): number;
13
- export declare function tradeComparator<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(a: Trade<TInput, TOutput, TTradeType>, b: Trade<TInput, TOutput, TTradeType>): number;
12
+ export declare function inputOutputComparator(a: InputOutput, b: InputOutput): number;
13
+ export declare function tradeComparator(a: Trade, b: Trade): number;
14
14
  export interface BestTradeOptions {
15
15
  maxNumResults?: number;
16
16
  maxHops?: number;
@@ -19,27 +19,31 @@ export interface BestTradeOptions {
19
19
  * Represents a trade executed against a list of pairs.
20
20
  * Does not account for slippage, i.e. trades that front run this trade and move the price.
21
21
  */
22
- export declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
22
+ export declare class Trade {
23
23
  /**
24
- * The route of the trade, i.e. which pairs the trade goes through and the input/output currencies.
24
+ * The route of the trade, i.e. which pairs the trade goes through.
25
25
  */
26
- readonly route: Route<TInput, TOutput>;
26
+ readonly route: Route;
27
27
  /**
28
28
  * The type of the trade, either exact in or exact out.
29
29
  */
30
- readonly tradeType: TTradeType;
30
+ readonly tradeType: TradeType;
31
31
  /**
32
32
  * The input amount for the trade assuming no slippage.
33
33
  */
34
- readonly inputAmount: CurrencyAmount<TInput>;
34
+ readonly inputAmount: CurrencyAmount;
35
35
  /**
36
36
  * The output amount for the trade assuming no slippage.
37
37
  */
38
- readonly outputAmount: CurrencyAmount<TOutput>;
38
+ readonly outputAmount: CurrencyAmount;
39
39
  /**
40
40
  * The price expressed in terms of output amount/input amount.
41
41
  */
42
- readonly executionPrice: Price<TInput, TOutput>;
42
+ readonly executionPrice: Price;
43
+ /**
44
+ * The mid price after the trade executes assuming no slippage.
45
+ */
46
+ readonly nextMidPrice: Price;
43
47
  /**
44
48
  * The percent difference between the mid price before the trade and the trade execution price.
45
49
  */
@@ -49,44 +53,39 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
49
53
  * @param route route of the exact in trade
50
54
  * @param amountIn the amount being passed in
51
55
  */
52
- static exactIn<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountIn: CurrencyAmount<TInput>): Trade<TInput, TOutput, TradeType.EXACT_INPUT>;
56
+ static exactIn(route: Route, amountIn: CurrencyAmount): Trade;
53
57
  /**
54
58
  * Constructs an exact out trade with the given amount out and route
55
59
  * @param route route of the exact out trade
56
60
  * @param amountOut the amount returned by the trade
57
61
  */
58
- static exactOut<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountOut: CurrencyAmount<TOutput>): Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>;
59
- constructor(route: Route<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType);
62
+ static exactOut(route: Route, amountOut: CurrencyAmount): Trade;
63
+ constructor(route: Route, amount: CurrencyAmount, tradeType: TradeType);
60
64
  /**
61
65
  * Get the minimum amount that must be received from this trade for the given slippage tolerance
62
66
  * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
63
67
  */
64
- minimumAmountOut(slippageTolerance: Percent): CurrencyAmount<TOutput>;
68
+ minimumAmountOut(slippageTolerance: Percent): CurrencyAmount;
65
69
  /**
66
70
  * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
67
71
  * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
68
72
  */
69
- maximumAmountIn(slippageTolerance: Percent): CurrencyAmount<TInput>;
73
+ maximumAmountIn(slippageTolerance: Percent): CurrencyAmount;
70
74
  /**
71
75
  * Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
72
76
  * amount to an output token, making at most `maxHops` hops.
73
77
  * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
74
78
  * the amount in among multiple routes.
75
79
  * @param pairs the pairs to consider in finding the best trade
76
- * @param nextAmountIn exact amount of input currency to spend
80
+ * @param currencyAmountIn exact amount of input currency to spend
77
81
  * @param currencyOut the desired currency out
78
82
  * @param maxNumResults maximum number of results to return
79
83
  * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
80
84
  * @param currentPairs used in recursion; the current list of pairs
81
- * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
85
+ * @param originalAmountIn used in recursion; the original value of the currencyAmountIn parameter
82
86
  * @param bestTrades used in recursion; the current list of best trades
83
87
  */
84
- 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>[];
85
- /**
86
- * Return the execution price after accounting for slippage tolerance
87
- * @param slippageTolerance the allowed tolerated slippage
88
- */
89
- worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput>;
88
+ static bestTradeExactIn(pairs: Pair[], currencyAmountIn: CurrencyAmount, currencyOut: Currency, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: Pair[], originalAmountIn?: CurrencyAmount, bestTrades?: Trade[]): Trade[];
90
89
  /**
91
90
  * similar to the above method but instead targets a fixed output amount
92
91
  * given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
@@ -95,13 +94,13 @@ export declare class Trade<TInput extends Currency, TOutput extends Currency, TT
95
94
  * the amount in among multiple routes.
96
95
  * @param pairs the pairs to consider in finding the best trade
97
96
  * @param currencyIn the currency to spend
98
- * @param nextAmountOut the exact amount of currency out
97
+ * @param currencyAmountOut the exact amount of currency out
99
98
  * @param maxNumResults maximum number of results to return
100
99
  * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
101
100
  * @param currentPairs used in recursion; the current list of pairs
102
- * @param currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter
101
+ * @param originalAmountOut used in recursion; the original value of the currencyAmountOut parameter
103
102
  * @param bestTrades used in recursion; the current list of best trades
104
103
  */
105
- 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>[];
104
+ static bestTradeExactOut(pairs: Pair[], currencyIn: Currency, currencyAmountOut: CurrencyAmount, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: Pair[], originalAmountOut?: CurrencyAmount, bestTrades?: Trade[]): Trade[];
106
105
  }
107
106
  export {};
@@ -0,0 +1,28 @@
1
+ import { Pair } from './entities/pair';
2
+ import { ChainId } from './constants';
3
+ import { Token } from './entities/token';
4
+ /**
5
+ * Contains methods for constructing instances of pairs and tokens from on-chain data.
6
+ */
7
+ export declare abstract class Fetcher {
8
+ /**
9
+ * Cannot be constructed.
10
+ */
11
+ private constructor();
12
+ /**
13
+ * Fetch information for a given token on the given chain, using the given ethers provider.
14
+ * @param chainId chain of the token
15
+ * @param address address of the token on the chain
16
+ * @param provider provider used to fetch the token
17
+ * @param symbol optional symbol of the token
18
+ * @param name optional name of the token
19
+ */
20
+ static fetchTokenData(chainId: ChainId, address: string, provider?: import("@ethersproject/providers").BaseProvider, symbol?: string, name?: string): Promise<Token>;
21
+ /**
22
+ * Fetches information about a pair and constructs a pair from the given two tokens.
23
+ * @param tokenA first token
24
+ * @param tokenB second token
25
+ * @param provider the provider to use to fetch the data
26
+ */
27
+ static fetchPairData(tokenA: Token, tokenB: Token, provider?: import("@ethersproject/providers").BaseProvider): Promise<Pair>;
28
+ }
package/dist/index.d.ts CHANGED
@@ -1,12 +1,7 @@
1
1
  import JSBI from 'jsbi';
2
2
  export { JSBI };
3
- export * from './constants';
3
+ export { BigintIsh, ChainId, TradeType, Rounding, FACTORY_ADDRESS, INIT_CODE_HASH, ROUTER_ADDRESS, SUSHI_ADDRESS, MASTERCHEF_ADDRESS, BAR_ADDRESS, MAKER_ADDRESS, TIMELOCK_ADDRESS, MINIMUM_LIQUIDITY } from './constants';
4
4
  export * from './errors';
5
5
  export * from './entities';
6
- export * from './functions';
7
6
  export * from './router';
8
- export * from './enums';
9
- export * from './router';
10
- export * from './types';
11
- export * from './utils/MultiRouterMath';
12
- export * from './limitorder';
7
+ export * from './fetcher';
package/dist/router.d.ts CHANGED
@@ -1,8 +1,4 @@
1
- import { Currency } from './entities/Currency';
2
- import { CurrencyAmount } from './entities/CurrencyAmount';
3
- import { Percent } from './entities/Percent';
4
- import { Trade } from './entities/Trade';
5
- import { TradeType } from './enums/TradeType';
1
+ import { Percent, Trade } from './entities';
6
2
  /**
7
3
  * Options for producing the arguments to send call to the router.
8
4
  */
@@ -50,7 +46,6 @@ export interface SwapParameters {
50
46
  */
51
47
  value: string;
52
48
  }
53
- export declare function toHex(currencyAmount: CurrencyAmount<Currency>): string;
54
49
  /**
55
50
  * Represents the Uniswap V2 Router, and has static methods for helping execute trades.
56
51
  */
@@ -64,5 +59,5 @@ export declare abstract class Router {
64
59
  * @param trade to produce call parameters for
65
60
  * @param options options for the call parameters
66
61
  */
67
- static swapCallParameters(trade: Trade<Currency, Currency, TradeType>, options: TradeOptions | TradeOptionsDeadline): SwapParameters;
62
+ static swapCallParameters(trade: Trade, options: TradeOptions | TradeOptionsDeadline): SwapParameters;
68
63
  }