@qidao/sdk 5.0.10 → 5.1.2

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 (121) hide show
  1. package/dist/index.js +2 -8
  2. package/dist/index.js.map +1 -0
  3. package/dist/index.modern.mjs +2 -0
  4. package/dist/index.modern.mjs.map +1 -0
  5. package/dist/index.module.js +2 -0
  6. package/dist/index.module.js.map +1 -0
  7. package/dist/index.umd.js +2 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/src/src/constants.d.ts +69 -0
  10. package/dist/src/src/contracts/CrosschainNativeQiStablecoin.d.ts +978 -0
  11. package/dist/src/src/contracts/CrosschainQiStablecoin.d.ts +974 -0
  12. package/dist/src/src/contracts/CrosschainQiStablecoinSlim.d.ts +942 -0
  13. package/dist/src/src/contracts/CrosschainQiStablecoinSlimV2.d.ts +950 -0
  14. package/dist/src/src/contracts/CrosschainQiStablecoinV2.d.ts +910 -0
  15. package/dist/src/src/contracts/CrosschainQiStablecoinwbtc.d.ts +958 -0
  16. package/dist/src/src/contracts/Erc20QiStablecoincamwbtc.d.ts +986 -0
  17. package/dist/src/src/contracts/Erc20QiStablecoinwbtc.d.ts +994 -0
  18. package/dist/src/src/contracts/Erc20Stablecoin.d.ts +938 -0
  19. package/dist/src/src/contracts/StableQiVault.d.ts +1522 -0
  20. package/dist/src/src/contracts/common.d.ts +22 -0
  21. package/dist/src/src/contracts/factories/CrosschainNativeQiStablecoin__factory.d.ts +61 -0
  22. package/dist/src/src/contracts/factories/CrosschainQiStablecoinSlimV2__factory.d.ts +52 -0
  23. package/dist/src/src/contracts/factories/CrosschainQiStablecoinSlim__factory.d.ts +52 -0
  24. package/dist/src/src/contracts/factories/CrosschainQiStablecoinV2__factory.d.ts +52 -0
  25. package/dist/src/src/contracts/factories/CrosschainQiStablecoin__factory.d.ts +52 -0
  26. package/dist/src/src/contracts/factories/CrosschainQiStablecoinwbtc__factory.d.ts +52 -0
  27. package/dist/src/src/contracts/factories/Erc20QiStablecoincamwbtc__factory.d.ts +52 -0
  28. package/dist/src/src/contracts/factories/Erc20QiStablecoinwbtc__factory.d.ts +52 -0
  29. package/dist/src/src/contracts/factories/Erc20Stablecoin__factory.d.ts +52 -0
  30. package/dist/src/src/contracts/factories/StableQiVault__factory.d.ts +46 -0
  31. package/dist/src/src/contracts/factories/index.d.ts +10 -0
  32. package/dist/src/src/contracts/index.d.ts +21 -0
  33. package/dist/src/src/entities/currency.d.ts +83 -0
  34. package/dist/src/src/entities/fractions/currencyAmount.d.ts +19 -0
  35. package/dist/{entities/Fraction.d.ts → src/src/entities/fractions/fraction.d.ts} +1 -7
  36. package/dist/src/src/entities/fractions/index.d.ts +5 -0
  37. package/dist/src/src/entities/fractions/percent.d.ts +6 -0
  38. package/dist/src/src/entities/fractions/price.d.ts +17 -0
  39. package/dist/src/src/entities/fractions/tokenAmount.d.ts +9 -0
  40. package/dist/src/src/entities/index.d.ts +3 -0
  41. package/dist/{entities/Token.d.ts → src/src/entities/token.d.ts} +40 -11
  42. package/dist/{errors.d.ts → src/src/errors.d.ts} +0 -0
  43. package/dist/src/src/index.d.ts +7 -0
  44. package/dist/src/src/utils.d.ts +7 -0
  45. package/dist/src/src/vaultInfo.d.ts +27 -0
  46. package/dist/src/test/fraction.test.d.ts +1 -0
  47. package/dist/src/test/token.test.d.ts +1 -0
  48. package/package.json +47 -66
  49. package/dist/constants/addresses.d.ts +0 -31
  50. package/dist/constants/index.d.ts +0 -20
  51. package/dist/constants/kashi.d.ts +0 -29
  52. package/dist/constants/natives.d.ts +0 -30
  53. package/dist/constants/numbers.d.ts +0 -11
  54. package/dist/constants/tokens.d.ts +0 -5
  55. package/dist/entities/AbstractCurrency.d.ts +0 -53
  56. package/dist/entities/ConstantProductPool.d.ts +0 -43
  57. package/dist/entities/Currency.d.ts +0 -3
  58. package/dist/entities/CurrencyAmount.d.ts +0 -38
  59. package/dist/entities/MultiRouter.d.ts +0 -59
  60. package/dist/entities/Native/Avalanche.d.ts +0 -10
  61. package/dist/entities/Native/Binance.d.ts +0 -10
  62. package/dist/entities/Native/Celo.d.ts +0 -10
  63. package/dist/entities/Native/Ether.d.ts +0 -13
  64. package/dist/entities/Native/Fantom.d.ts +0 -10
  65. package/dist/entities/Native/Fuse.d.ts +0 -10
  66. package/dist/entities/Native/Harmony.d.ts +0 -10
  67. package/dist/entities/Native/Heco.d.ts +0 -10
  68. package/dist/entities/Native/Matic.d.ts +0 -10
  69. package/dist/entities/Native/Movr.d.ts +0 -10
  70. package/dist/entities/Native/Okex.d.ts +0 -10
  71. package/dist/entities/Native/Palm.d.ts +0 -10
  72. package/dist/entities/Native/Telos.d.ts +0 -10
  73. package/dist/entities/Native/index.d.ts +0 -14
  74. package/dist/entities/Native/xDai.d.ts +0 -10
  75. package/dist/entities/NativeCurrency.d.ts +0 -8
  76. package/dist/entities/Pair.d.ts +0 -41
  77. package/dist/entities/Percent.d.ts +0 -15
  78. package/dist/entities/Price.d.ts +0 -39
  79. package/dist/entities/Route.d.ts +0 -14
  80. package/dist/entities/Trade.d.ts +0 -107
  81. package/dist/entities/eip712.d.ts +0 -78
  82. package/dist/entities/index.d.ts +0 -14
  83. package/dist/enums/ChainId.d.ts +0 -32
  84. package/dist/enums/Fee.d.ts +0 -3
  85. package/dist/enums/KashiAction.d.ts +0 -18
  86. package/dist/enums/OrderStatus.d.ts +0 -6
  87. package/dist/enums/Rounding.d.ts +0 -5
  88. package/dist/enums/TradeType.d.ts +0 -4
  89. package/dist/enums/index.d.ts +0 -6
  90. package/dist/functions/bentobox.d.ts +0 -3
  91. package/dist/functions/computeConstantProductPoolAddress.d.ts +0 -9
  92. package/dist/functions/computePairAddress.d.ts +0 -6
  93. package/dist/functions/computePoolInitCodeHash.d.ts +0 -5
  94. package/dist/functions/computePriceImpact.d.ts +0 -11
  95. package/dist/functions/index.d.ts +0 -8
  96. package/dist/functions/kashi.d.ts +0 -9
  97. package/dist/functions/rebase.d.ts +0 -4
  98. package/dist/functions/sortedInsert.d.ts +0 -1
  99. package/dist/functions/sqrt.d.ts +0 -7
  100. package/dist/functions/validateAndParseAddress.d.ts +0 -1
  101. package/dist/functions/validateSolidityTypeInstance.d.ts +0 -3
  102. package/dist/index.d.ts +0 -12
  103. package/dist/interfaces/AccrueInfo.d.ts +0 -6
  104. package/dist/interfaces/Rebase.d.ts +0 -5
  105. package/dist/interfaces/index.d.ts +0 -2
  106. package/dist/limitorder.d.ts +0 -115
  107. package/dist/router.d.ts +0 -68
  108. package/dist/sdk.cjs.development.js +0 -5301
  109. package/dist/sdk.cjs.development.js.map +0 -1
  110. package/dist/sdk.cjs.production.min.js +0 -2
  111. package/dist/sdk.cjs.production.min.js.map +0 -1
  112. package/dist/sdk.esm.js +0 -5162
  113. package/dist/sdk.esm.js.map +0 -1
  114. package/dist/types/AddressMap.d.ts +0 -3
  115. package/dist/types/BigIntIsh.d.ts +0 -2
  116. package/dist/types/ChainTokenMap.d.ts +0 -5
  117. package/dist/types/LimitOrderTypes.d.ts +0 -21
  118. package/dist/types/MultiRouterTypes.d.ts +0 -97
  119. package/dist/types/TokenMap.d.ts +0 -4
  120. package/dist/types/index.d.ts +0 -4
  121. package/dist/utils/MultiRouterMath.d.ts +0 -15
@@ -1,59 +0,0 @@
1
- import { BigNumber } from '@ethersproject/bignumber';
2
- import { Pool, RToken, RouteLeg, MultiRoute } from '../types/MultiRouterTypes';
3
- export declare class Edge {
4
- readonly GasConsumption = 40000;
5
- readonly MINIMUM_LIQUIDITY = 1000;
6
- pool: Pool;
7
- vert0: Vertice;
8
- vert1: Vertice;
9
- canBeUsed: boolean;
10
- direction: boolean;
11
- amountInPrevious: number;
12
- amountOutPrevious: number;
13
- bestEdgeIncome: number;
14
- constructor(p: Pool, v0: Vertice, v1: Vertice);
15
- reserve(v: Vertice): BigNumber;
16
- calcOutput(v: Vertice, amountIn: number): number[];
17
- checkMinimalLiquidityExceededAfterSwap(from: Vertice, amountOut: number): boolean;
18
- testApply(from: Vertice, amountIn: number, amountOut: number): boolean;
19
- applySwap(from: Vertice): void;
20
- }
21
- export declare class Vertice {
22
- token: RToken;
23
- edges: Edge[];
24
- price: number;
25
- gasPrice: number;
26
- bestIncome: number;
27
- gasSpent: number;
28
- bestTotal: number;
29
- bestSource?: Edge;
30
- checkLine: number;
31
- constructor(t: RToken);
32
- getNeibour(e?: Edge): Vertice | undefined;
33
- }
34
- export declare class Graph {
35
- vertices: Vertice[];
36
- edges: Edge[];
37
- tokens: Map<RToken, Vertice>;
38
- constructor(pools: Pool[], baseToken: RToken, gasPrice: number);
39
- setPrices(from: Vertice, price: number, gasPrice: number): void;
40
- getOrCreateVertice(token: RToken): Vertice;
41
- findBestPath(from: RToken, to: RToken, amountIn: number): {
42
- path: Edge[];
43
- output: number;
44
- gasSpent: number;
45
- totalOutput: number;
46
- } | undefined;
47
- addPath(from: Vertice | undefined, to: Vertice | undefined, path: Edge[]): void;
48
- findBestRoute(from: RToken, to: RToken, amountIn: number, mode: number | number[]): MultiRoute;
49
- getRouteLegs(from: Vertice, to: Vertice): [RouteLeg[], number, boolean];
50
- edgeFrom(e: Edge): [Vertice, number] | undefined;
51
- getOutputEdges(v: Vertice): Edge[];
52
- getInputEdges(v: Vertice): Edge[];
53
- calcLegsAmountOut(legs: RouteLeg[], amountIn: number, to: RToken): number;
54
- cleanTopology(from: Vertice, to: Vertice): [Vertice[], boolean];
55
- removeDeadEnds(verts: Vertice[]): void;
56
- removeWeakestEdge(verts: Vertice[]): void;
57
- topologySort(from: Vertice, to: Vertice): [number, Vertice[]];
58
- }
59
- export declare function findMultiRouting(from: RToken, to: RToken, amountIn: number, pools: Pool[], baseToken: RToken, gasPrice: number, steps?: number | number[]): MultiRoute;
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Avalanche extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Avalanche;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Binance extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Binance;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Celo extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Celo;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,13 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- /**
5
- * Ether is the main usage of a 'native' currency, i.e. for Ethereum mainnet and all testnets
6
- */
7
- export declare class Ether extends NativeCurrency {
8
- protected constructor(chainId: number);
9
- get wrapped(): Token;
10
- private static _etherCache;
11
- static onChain(chainId: number): Ether;
12
- equals(other: Currency): boolean;
13
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Fantom extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Fantom;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Fuse extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Fuse;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Harmony extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Harmony;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Heco extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Heco;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Matic extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Matic;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Movr extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Movr;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Okex extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Okex;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Palm extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Palm;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class Telos extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): Telos;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,14 +0,0 @@
1
- export { Avalanche } from './Avalanche';
2
- export { Binance } from './Binance';
3
- export { Celo } from './Celo';
4
- export { Ether } from './Ether';
5
- export { Fantom } from './Fantom';
6
- export { Harmony } from './Harmony';
7
- export { Heco } from './Heco';
8
- export { Matic } from './Matic';
9
- export { Movr } from './Movr';
10
- export { Okex } from './Okex';
11
- export { xDai } from './xDai';
12
- export { Palm } from './Palm';
13
- export { Fuse } from './Fuse';
14
- export { Telos } from './Telos';
@@ -1,10 +0,0 @@
1
- import { Currency } from '../Currency';
2
- import { NativeCurrency } from '../NativeCurrency';
3
- import { Token } from '../Token';
4
- export declare class xDai extends NativeCurrency {
5
- protected constructor(chainId: number);
6
- get wrapped(): Token;
7
- private static _cache;
8
- static onChain(chainId: number): xDai;
9
- equals(other: Currency): boolean;
10
- }
@@ -1,8 +0,0 @@
1
- import { AbstractCurrency } from './AbstractCurrency';
2
- /**
3
- * Represents the native currency of the chain on which it resides, e.g.
4
- */
5
- export declare abstract class NativeCurrency extends AbstractCurrency {
6
- readonly isNative: true;
7
- readonly isToken: false;
8
- }
@@ -1,41 +0,0 @@
1
- import { BigintIsh } from '../types';
2
- import { CurrencyAmount } from './CurrencyAmount';
3
- import { Price } from './Price';
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(currencyAmountA: CurrencyAmount<Token>, currencyAmountB: CurrencyAmount<Token>);
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<Token, Token>;
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<Token, Token>;
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<Token, Token>;
28
- /**
29
- * Returns the chain ID of the tokens in the pair.
30
- */
31
- get chainId(): number;
32
- get token0(): Token;
33
- get token1(): Token;
34
- get reserve0(): CurrencyAmount<Token>;
35
- get reserve1(): CurrencyAmount<Token>;
36
- reserveOf(token: Token): CurrencyAmount<Token>;
37
- getOutputAmount(inputAmount: CurrencyAmount<Token>): [CurrencyAmount<Token>, Pair];
38
- getInputAmount(outputAmount: CurrencyAmount<Token>): [CurrencyAmount<Token>, Pair];
39
- getLiquidityMinted(totalSupply: CurrencyAmount<Token>, tokenAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>): CurrencyAmount<Token>;
40
- getLiquidityValue(token: Token, totalSupply: CurrencyAmount<Token>, liquidity: CurrencyAmount<Token>, feeOn?: boolean, kLast?: BigintIsh): CurrencyAmount<Token>;
41
- }
@@ -1,15 +0,0 @@
1
- import { BigintIsh } from '../types';
2
- import { Fraction } from './Fraction';
3
- import { Rounding } from '../enums';
4
- export declare class Percent extends Fraction {
5
- /**
6
- * This boolean prevents a fraction from being interpreted as a Percent
7
- */
8
- readonly isPercent: true;
9
- add(other: Fraction | BigintIsh): Percent;
10
- subtract(other: Fraction | BigintIsh): Percent;
11
- multiply(other: Fraction | BigintIsh): Percent;
12
- divide(other: Fraction | BigintIsh): Percent;
13
- toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
14
- toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
15
- }
@@ -1,39 +0,0 @@
1
- import { BigintIsh } from '../types';
2
- import { Currency } from './Currency';
3
- import { CurrencyAmount } from './CurrencyAmount';
4
- import { Fraction } from './Fraction';
5
- import { Rounding } from '../enums';
6
- export declare class Price<TBase extends Currency, TQuote extends Currency> extends Fraction {
7
- readonly baseCurrency: TBase;
8
- readonly quoteCurrency: TQuote;
9
- readonly scalar: Fraction;
10
- /**
11
- * Construct a price, either with the base and quote currency amount, or the
12
- * @param args
13
- */
14
- constructor(...args: [TBase, TQuote, BigintIsh, BigintIsh] | [{
15
- baseAmount: CurrencyAmount<TBase>;
16
- quoteAmount: CurrencyAmount<TQuote>;
17
- }]);
18
- /**
19
- * Flip the price, switching the base and quote currency
20
- */
21
- invert(): Price<TQuote, TBase>;
22
- /**
23
- * Multiply the price by another price, returning a new price. The other price must have the same base currency as this price's quote currency
24
- * @param other the other price
25
- */
26
- multiply<TOtherQuote extends Currency>(other: Price<TQuote, TOtherQuote>): Price<TBase, TOtherQuote>;
27
- /**
28
- * Return the amount of quote currency corresponding to a given amount of the base currency
29
- * @param currencyAmount the amount of base currency to quote against the price
30
- */
31
- quote(currencyAmount: CurrencyAmount<TBase>): CurrencyAmount<TQuote>;
32
- /**
33
- * Get the value scaled by decimals for formatting
34
- * @private
35
- */
36
- private get adjustedForDecimals();
37
- toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
38
- toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
39
- }
@@ -1,14 +0,0 @@
1
- import { Currency } from './Currency';
2
- import { Pair } from './Pair';
3
- import { Price } from './Price';
4
- import { Token } from './Token';
5
- export declare class Route<TInput extends Currency, TOutput extends Currency> {
6
- readonly pairs: Pair[];
7
- readonly path: Token[];
8
- readonly input: TInput;
9
- readonly output: TOutput;
10
- constructor(pairs: Pair[], input: TInput, output: TOutput);
11
- private _midPrice;
12
- get midPrice(): Price<TInput, TOutput>;
13
- get chainId(): number;
14
- }
@@ -1,107 +0,0 @@
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>;
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;
14
- export interface BestTradeOptions {
15
- maxNumResults?: number;
16
- maxHops?: number;
17
- }
18
- /**
19
- * Represents a trade executed against a list of pairs.
20
- * Does not account for slippage, i.e. trades that front run this trade and move the price.
21
- */
22
- export declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
23
- /**
24
- * The route of the trade, i.e. which pairs the trade goes through and the input/output currencies.
25
- */
26
- readonly route: Route<TInput, TOutput>;
27
- /**
28
- * The type of the trade, either exact in or exact out.
29
- */
30
- readonly tradeType: TTradeType;
31
- /**
32
- * The input amount for the trade assuming no slippage.
33
- */
34
- readonly inputAmount: CurrencyAmount<TInput>;
35
- /**
36
- * The output amount for the trade assuming no slippage.
37
- */
38
- readonly outputAmount: CurrencyAmount<TOutput>;
39
- /**
40
- * The price expressed in terms of output amount/input amount.
41
- */
42
- readonly executionPrice: Price<TInput, TOutput>;
43
- /**
44
- * The percent difference between the mid price before the trade and the trade execution price.
45
- */
46
- readonly priceImpact: Percent;
47
- /**
48
- * Constructs an exact in trade with the given amount in and route
49
- * @param route route of the exact in trade
50
- * @param amountIn the amount being passed in
51
- */
52
- static exactIn<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountIn: CurrencyAmount<TInput>): Trade<TInput, TOutput, TradeType.EXACT_INPUT>;
53
- /**
54
- * Constructs an exact out trade with the given amount out and route
55
- * @param route route of the exact out trade
56
- * @param amountOut the amount returned by the trade
57
- */
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);
60
- /**
61
- * Get the minimum amount that must be received from this trade for the given slippage tolerance
62
- * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
63
- */
64
- minimumAmountOut(slippageTolerance: Percent): CurrencyAmount<TOutput>;
65
- /**
66
- * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
67
- * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
68
- */
69
- maximumAmountIn(slippageTolerance: Percent): CurrencyAmount<TInput>;
70
- /**
71
- * Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
72
- * amount to an output token, making at most `maxHops` hops.
73
- * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
74
- * the amount in among multiple routes.
75
- * @param pairs the pairs to consider in finding the best trade
76
- * @param nextAmountIn exact amount of input currency to spend
77
- * @param currencyOut the desired currency out
78
- * @param maxNumResults maximum number of results to return
79
- * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
80
- * @param currentPairs used in recursion; the current list of pairs
81
- * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
82
- * @param bestTrades used in recursion; the current list of best trades
83
- */
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>;
90
- /**
91
- * similar to the above method but instead targets a fixed output amount
92
- * given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
93
- * to an output token amount, making at most `maxHops` hops
94
- * note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting
95
- * the amount in among multiple routes.
96
- * @param pairs the pairs to consider in finding the best trade
97
- * @param currencyIn the currency to spend
98
- * @param nextAmountOut the exact amount of currency out
99
- * @param maxNumResults maximum number of results to return
100
- * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
101
- * @param currentPairs used in recursion; the current list of pairs
102
- * @param currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter
103
- * @param bestTrades used in recursion; the current list of best trades
104
- */
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>[];
106
- }
107
- export {};
@@ -1,78 +0,0 @@
1
- import { ChainId } from '../enums';
2
- import { Web3Provider } from '@ethersproject/providers';
3
- export interface Domain {
4
- name: string;
5
- chainId: ChainId;
6
- verifyingContract: string;
7
- }
8
- export interface Message {
9
- maker: string;
10
- tokenIn: string;
11
- tokenOut: string;
12
- amountIn: string;
13
- amountOut: string;
14
- recipient: string;
15
- startTime: string;
16
- endTime: string;
17
- stopPrice: string;
18
- oracleAddress: string;
19
- oracleData: string;
20
- }
21
- export interface BentoApprovalMessage {
22
- warning: string;
23
- user: string;
24
- masterContract: string;
25
- approved: boolean;
26
- nonce: number;
27
- }
28
- export declare const getSignature: (message: Message, chainId: ChainId, privateKey: string) => {
29
- v: number;
30
- r: string;
31
- s: string;
32
- };
33
- export declare const getTypedData: (message: Message, chainId: ChainId) => {
34
- types: {
35
- EIP712Domain: {
36
- name: string;
37
- type: string;
38
- }[];
39
- LimitOrder: {
40
- name: string;
41
- type: string;
42
- }[];
43
- };
44
- primaryType: string;
45
- domain: Domain;
46
- message: Message;
47
- };
48
- export declare const getTypedDataBento: (message: BentoApprovalMessage, chainId: ChainId) => {
49
- types: {
50
- EIP712Domain: {
51
- name: string;
52
- type: string;
53
- }[];
54
- SetMasterContractApproval: {
55
- name: string;
56
- type: string;
57
- }[];
58
- };
59
- primaryType: string;
60
- domain: Domain;
61
- message: BentoApprovalMessage;
62
- };
63
- export declare const getTypeHash: (typedData: any) => string;
64
- export declare const getSignatureWithProvider: (message: Message, chainId: ChainId, provider: Web3Provider) => Promise<{
65
- v: number;
66
- r: string;
67
- s: string;
68
- }>;
69
- export declare const getSignatureWithProviderBentobox: (message: BentoApprovalMessage, chainId: ChainId, provider: Web3Provider) => Promise<{
70
- v: number;
71
- r: string;
72
- s: string;
73
- }>;
74
- export declare const getSignatureBento: (bentoApproval: BentoApprovalMessage, chainId: ChainId, privateKey: string) => Promise<{
75
- v: number;
76
- r: string;
77
- s: string;
78
- }>;
@@ -1,14 +0,0 @@
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,32 +0,0 @@
1
- export declare enum ChainId {
2
- MAINNET = 1,
3
- ROPSTEN = 3,
4
- RINKEBY = 4,
5
- GÖRLI = 5,
6
- KOVAN = 42,
7
- MATIC = 137,
8
- MATIC_TESTNET = 80001,
9
- FANTOM = 250,
10
- FANTOM_TESTNET = 4002,
11
- XDAI = 100,
12
- BSC = 56,
13
- BSC_TESTNET = 97,
14
- ARBITRUM = 42161,
15
- ARBITRUM_TESTNET = 79377087078960,
16
- MOONBEAM_TESTNET = 1287,
17
- MOONBEAM = 1284,
18
- AVALANCHE = 43114,
19
- AVALANCHE_TESTNET = 43113,
20
- HECO = 128,
21
- HECO_TESTNET = 256,
22
- HARMONY = 1666600000,
23
- HARMONY_TESTNET = 1666700000,
24
- OKEX = 66,
25
- OKEX_TESTNET = 65,
26
- CELO = 42220,
27
- PALM = 11297108109,
28
- PALM_TESTNET = 11297108099,
29
- MOONRIVER = 1285,
30
- FUSE = 122,
31
- TELOS = 40
32
- }
@@ -1,3 +0,0 @@
1
- export declare enum Fee {
2
- DEFAULT = 30
3
- }
@@ -1,18 +0,0 @@
1
- export declare enum KashiAction {
2
- ADD_ASSET = 1,
3
- REPAY = 2,
4
- REMOVE_ASSET = 3,
5
- REMOVE_COLLATERAL = 4,
6
- BORROW = 5,
7
- GET_REPAY_SHARE = 6,
8
- GET_REPAY_PART = 7,
9
- ACCRUE = 8,
10
- ADD_COLLATERAL = 10,
11
- UPDATE_EXCHANGE_RATE = 11,
12
- BENTO_DEPOSIT = 20,
13
- BENTO_WITHDRAW = 21,
14
- BENTO_TRANSFER = 22,
15
- BENTO_TRANSFER_MULTIPLE = 23,
16
- BENTO_SETAPPROVAL = 24,
17
- CALL = 30
18
- }
@@ -1,6 +0,0 @@
1
- export declare enum OrderStatus {
2
- FILLED = "FILLED",
3
- CANCELLED = "CANCELLED",
4
- EXPIRED = "EXPIRED",
5
- PENDING = "PENDING"
6
- }
@@ -1,5 +0,0 @@
1
- export declare enum Rounding {
2
- ROUND_DOWN = 0,
3
- ROUND_HALF_UP = 1,
4
- ROUND_UP = 2
5
- }
@@ -1,4 +0,0 @@
1
- export declare enum TradeType {
2
- EXACT_INPUT = 0,
3
- EXACT_OUTPUT = 1
4
- }
@@ -1,6 +0,0 @@
1
- export { ChainId } from './ChainId';
2
- export { Rounding } from './Rounding';
3
- export { TradeType } from './TradeType';
4
- export { KashiAction } from './KashiAction';
5
- export { Fee } from './Fee';
6
- export { OrderStatus } from './OrderStatus';
@@ -1,3 +0,0 @@
1
- import { BigNumber } from '@ethersproject/bignumber';
2
- export declare function toAmount(token: any, shares: BigNumber): BigNumber;
3
- export declare function toShare(token: any, amount: BigNumber): BigNumber;