@qidao/sdk 5.0.8 → 5.0.9

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 (104) hide show
  1. package/dist/constants/addresses.d.ts +31 -0
  2. package/dist/constants/index.d.ts +20 -0
  3. package/dist/constants/kashi.d.ts +29 -0
  4. package/dist/constants/natives.d.ts +30 -0
  5. package/dist/constants/numbers.d.ts +11 -0
  6. package/dist/constants/tokens.d.ts +5 -0
  7. package/dist/entities/AbstractCurrency.d.ts +53 -0
  8. package/dist/entities/ConstantProductPool.d.ts +43 -0
  9. package/dist/entities/Currency.d.ts +3 -0
  10. package/dist/entities/CurrencyAmount.d.ts +38 -0
  11. package/dist/entities/{fractions/fraction.d.ts → Fraction.d.ts} +7 -1
  12. package/dist/entities/MultiRouter.d.ts +59 -0
  13. package/dist/entities/Native/Avalanche.d.ts +10 -0
  14. package/dist/entities/Native/Binance.d.ts +10 -0
  15. package/dist/entities/Native/Celo.d.ts +10 -0
  16. package/dist/entities/Native/Ether.d.ts +13 -0
  17. package/dist/entities/Native/Fantom.d.ts +10 -0
  18. package/dist/entities/Native/Fuse.d.ts +10 -0
  19. package/dist/entities/Native/Harmony.d.ts +10 -0
  20. package/dist/entities/Native/Heco.d.ts +10 -0
  21. package/dist/entities/Native/Matic.d.ts +10 -0
  22. package/dist/entities/Native/Movr.d.ts +10 -0
  23. package/dist/entities/Native/Okex.d.ts +10 -0
  24. package/dist/entities/Native/Palm.d.ts +10 -0
  25. package/dist/entities/Native/Telos.d.ts +10 -0
  26. package/dist/entities/Native/index.d.ts +14 -0
  27. package/dist/entities/Native/xDai.d.ts +10 -0
  28. package/dist/entities/NativeCurrency.d.ts +8 -0
  29. package/dist/entities/Pair.d.ts +41 -0
  30. package/dist/entities/Percent.d.ts +15 -0
  31. package/dist/entities/Price.d.ts +39 -0
  32. package/dist/entities/Route.d.ts +14 -0
  33. package/dist/entities/{token.d.ts → Token.d.ts} +11 -40
  34. package/dist/entities/{trade.d.ts → Trade.d.ts} +35 -34
  35. package/dist/entities/eip712.d.ts +78 -0
  36. package/dist/entities/index.d.ts +14 -6
  37. package/dist/enums/ChainId.d.ts +32 -0
  38. package/dist/enums/Fee.d.ts +3 -0
  39. package/dist/enums/KashiAction.d.ts +18 -0
  40. package/dist/enums/OrderStatus.d.ts +6 -0
  41. package/dist/enums/Rounding.d.ts +5 -0
  42. package/dist/enums/TradeType.d.ts +4 -0
  43. package/dist/enums/index.d.ts +6 -0
  44. package/dist/functions/bentobox.d.ts +3 -0
  45. package/dist/functions/computeConstantProductPoolAddress.d.ts +9 -0
  46. package/dist/functions/computePairAddress.d.ts +6 -0
  47. package/dist/functions/computePoolInitCodeHash.d.ts +5 -0
  48. package/dist/functions/computePriceImpact.d.ts +11 -0
  49. package/dist/functions/index.d.ts +8 -0
  50. package/dist/functions/kashi.d.ts +9 -0
  51. package/dist/functions/rebase.d.ts +4 -0
  52. package/dist/functions/sortedInsert.d.ts +1 -0
  53. package/dist/functions/sqrt.d.ts +7 -0
  54. package/dist/functions/validateAndParseAddress.d.ts +1 -0
  55. package/dist/functions/validateSolidityTypeInstance.d.ts +3 -0
  56. package/dist/index.d.ts +7 -2
  57. package/dist/index.js +2 -2
  58. package/dist/interfaces/AccrueInfo.d.ts +6 -0
  59. package/dist/interfaces/Rebase.d.ts +5 -0
  60. package/dist/interfaces/index.d.ts +2 -0
  61. package/dist/limitorder.d.ts +115 -0
  62. package/dist/qidao-sdk.cjs.development.js +5301 -0
  63. package/dist/qidao-sdk.cjs.development.js.map +1 -0
  64. package/dist/qidao-sdk.cjs.production.min.js +2 -0
  65. package/dist/qidao-sdk.cjs.production.min.js.map +1 -0
  66. package/dist/qidao-sdk.esm.js +5162 -0
  67. package/dist/qidao-sdk.esm.js.map +1 -0
  68. package/dist/router.d.ts +7 -2
  69. package/dist/types/AddressMap.d.ts +3 -0
  70. package/dist/types/BigIntIsh.d.ts +2 -0
  71. package/dist/types/ChainTokenMap.d.ts +5 -0
  72. package/dist/types/LimitOrderTypes.d.ts +21 -0
  73. package/dist/types/MultiRouterTypes.d.ts +97 -0
  74. package/dist/types/TokenMap.d.ts +4 -0
  75. package/dist/types/index.d.ts +4 -0
  76. package/dist/utils/MultiRouterMath.d.ts +15 -0
  77. package/package.json +57 -31
  78. package/dist/constants.d.ts +0 -87
  79. package/dist/entities/currency.d.ts +0 -83
  80. package/dist/entities/fractions/currencyAmount.d.ts +0 -19
  81. package/dist/entities/fractions/index.d.ts +0 -5
  82. package/dist/entities/fractions/percent.d.ts +0 -6
  83. package/dist/entities/fractions/price.d.ts +0 -19
  84. package/dist/entities/fractions/tokenAmount.d.ts +0 -9
  85. package/dist/entities/pair.d.ts +0 -41
  86. package/dist/entities/route.d.ts +0 -14
  87. package/dist/fetcher.d.ts +0 -28
  88. package/dist/sdk.cjs.development.js +0 -1709
  89. package/dist/sdk.cjs.development.js.map +0 -1
  90. package/dist/sdk.cjs.production.min.js +0 -2
  91. package/dist/sdk.cjs.production.min.js.map +0 -1
  92. package/dist/sdk.esm.js +0 -1681
  93. package/dist/sdk.esm.js.map +0 -1
  94. package/dist/test/constants.test.d.ts +0 -1
  95. package/dist/test/data.test.d.ts +0 -1
  96. package/dist/test/entities.test.d.ts +0 -1
  97. package/dist/test/fraction.test.d.ts +0 -1
  98. package/dist/test/miscellaneous.test.d.ts +0 -1
  99. package/dist/test/pair.test.d.ts +0 -1
  100. package/dist/test/route.test.d.ts +0 -1
  101. package/dist/test/router.test.d.ts +0 -1
  102. package/dist/test/token.test.d.ts +0 -1
  103. package/dist/test/trade.test.d.ts +0 -1
  104. package/dist/utils.d.ts +0 -7
@@ -0,0 +1,14 @@
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,17 +1,20 @@
1
- import { ChainId } from '../constants';
2
- import { Currency } from './currency';
1
+ import { AbstractCurrency } from './AbstractCurrency';
2
+ import { ChainId } from '../enums';
3
+ import { Currency } from './Currency';
3
4
  /**
4
5
  * Represents an ERC20 token with a unique address and some metadata.
5
6
  */
6
- export declare class Token extends Currency {
7
+ export declare class Token extends AbstractCurrency {
7
8
  readonly chainId: ChainId;
8
9
  readonly address: string;
10
+ readonly isNative: false;
11
+ readonly isToken: true;
9
12
  constructor(chainId: ChainId, address: string, decimals: number, symbol?: string, name?: string);
10
13
  /**
11
14
  * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
12
15
  * @param other other token to compare
13
16
  */
14
- equals(other: Token): boolean;
17
+ equals(other: Currency): boolean;
15
18
  /**
16
19
  * Returns true if the address of this token sorts before the address of the other token
17
20
  * @param other other token to compare
@@ -19,44 +22,12 @@ export declare class Token extends Currency {
19
22
  * @throws if the tokens are on different chains
20
23
  */
21
24
  sortsBefore(other: Token): boolean;
25
+ /**
26
+ * Return this token, which does not need to be wrapped
27
+ */
28
+ get wrapped(): Token;
22
29
  }
23
30
  /**
24
31
  * Compares two currencies for equality
25
32
  */
26
33
  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
- 1285: Token;
49
- 25: Token;
50
- 10: Token;
51
- 57: Token;
52
- 1088: Token;
53
- 1284: Token;
54
- 2001: Token;
55
- 2222: Token;
56
- 4689: Token;
57
- 8217: Token;
58
- 42220: Token;
59
- 1313161554: Token;
60
- 288: Token;
61
- 1818: Token;
62
- };
@@ -1,16 +1,16 @@
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;
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
11
  }
12
- export declare function inputOutputComparator(a: InputOutput, b: InputOutput): number;
13
- export declare function tradeComparator(a: Trade, b: Trade): number;
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
14
  export interface BestTradeOptions {
15
15
  maxNumResults?: number;
16
16
  maxHops?: number;
@@ -19,31 +19,27 @@ 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 {
22
+ export declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
23
23
  /**
24
- * The route of the trade, i.e. which pairs the trade goes through.
24
+ * The route of the trade, i.e. which pairs the trade goes through and the input/output currencies.
25
25
  */
26
- readonly route: Route;
26
+ readonly route: Route<TInput, TOutput>;
27
27
  /**
28
28
  * The type of the trade, either exact in or exact out.
29
29
  */
30
- readonly tradeType: TradeType;
30
+ readonly tradeType: TTradeType;
31
31
  /**
32
32
  * The input amount for the trade assuming no slippage.
33
33
  */
34
- readonly inputAmount: CurrencyAmount;
34
+ readonly inputAmount: CurrencyAmount<TInput>;
35
35
  /**
36
36
  * The output amount for the trade assuming no slippage.
37
37
  */
38
- readonly outputAmount: CurrencyAmount;
38
+ readonly outputAmount: CurrencyAmount<TOutput>;
39
39
  /**
40
40
  * The price expressed in terms of output amount/input amount.
41
41
  */
42
- readonly executionPrice: Price;
43
- /**
44
- * The mid price after the trade executes assuming no slippage.
45
- */
46
- readonly nextMidPrice: Price;
42
+ readonly executionPrice: Price<TInput, TOutput>;
47
43
  /**
48
44
  * The percent difference between the mid price before the trade and the trade execution price.
49
45
  */
@@ -53,39 +49,44 @@ export declare class Trade {
53
49
  * @param route route of the exact in trade
54
50
  * @param amountIn the amount being passed in
55
51
  */
56
- static exactIn(route: Route, amountIn: CurrencyAmount): Trade;
52
+ static exactIn<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountIn: CurrencyAmount<TInput>): Trade<TInput, TOutput, TradeType.EXACT_INPUT>;
57
53
  /**
58
54
  * Constructs an exact out trade with the given amount out and route
59
55
  * @param route route of the exact out trade
60
56
  * @param amountOut the amount returned by the trade
61
57
  */
62
- static exactOut(route: Route, amountOut: CurrencyAmount): Trade;
63
- constructor(route: Route, amount: CurrencyAmount, tradeType: TradeType);
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);
64
60
  /**
65
61
  * Get the minimum amount that must be received from this trade for the given slippage tolerance
66
62
  * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
67
63
  */
68
- minimumAmountOut(slippageTolerance: Percent): CurrencyAmount;
64
+ minimumAmountOut(slippageTolerance: Percent): CurrencyAmount<TOutput>;
69
65
  /**
70
66
  * Get the maximum amount in that can be spent via this trade for the given slippage tolerance
71
67
  * @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
72
68
  */
73
- maximumAmountIn(slippageTolerance: Percent): CurrencyAmount;
69
+ maximumAmountIn(slippageTolerance: Percent): CurrencyAmount<TInput>;
74
70
  /**
75
71
  * Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
76
72
  * amount to an output token, making at most `maxHops` hops.
77
73
  * Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
78
74
  * the amount in among multiple routes.
79
75
  * @param pairs the pairs to consider in finding the best trade
80
- * @param currencyAmountIn exact amount of input currency to spend
76
+ * @param nextAmountIn exact amount of input currency to spend
81
77
  * @param currencyOut the desired currency out
82
78
  * @param maxNumResults maximum number of results to return
83
79
  * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
84
80
  * @param currentPairs used in recursion; the current list of pairs
85
- * @param originalAmountIn used in recursion; the original value of the currencyAmountIn parameter
81
+ * @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
86
82
  * @param bestTrades used in recursion; the current list of best trades
87
83
  */
88
- static bestTradeExactIn(pairs: Pair[], currencyAmountIn: CurrencyAmount, currencyOut: Currency, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: Pair[], originalAmountIn?: CurrencyAmount, bestTrades?: Trade[]): Trade[];
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>;
89
90
  /**
90
91
  * similar to the above method but instead targets a fixed output amount
91
92
  * given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
@@ -94,13 +95,13 @@ export declare class Trade {
94
95
  * the amount in among multiple routes.
95
96
  * @param pairs the pairs to consider in finding the best trade
96
97
  * @param currencyIn the currency to spend
97
- * @param currencyAmountOut the exact amount of currency out
98
+ * @param nextAmountOut the exact amount of currency out
98
99
  * @param maxNumResults maximum number of results to return
99
100
  * @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
100
101
  * @param currentPairs used in recursion; the current list of pairs
101
- * @param originalAmountOut used in recursion; the original value of the currencyAmountOut parameter
102
+ * @param currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter
102
103
  * @param bestTrades used in recursion; the current list of best trades
103
104
  */
104
- static bestTradeExactOut(pairs: Pair[], currencyIn: Currency, currencyAmountOut: CurrencyAmount, { maxNumResults, maxHops }?: BestTradeOptions, currentPairs?: Pair[], originalAmountOut?: CurrencyAmount, bestTrades?: Trade[]): Trade[];
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>[];
105
106
  }
106
107
  export {};
@@ -0,0 +1,78 @@
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,6 +1,14 @@
1
- export * from './token';
2
- export * from './pair';
3
- export * from './route';
4
- export * from './trade';
5
- export * from './currency';
6
- export * from './fractions';
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';
@@ -0,0 +1,32 @@
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
+ }
@@ -0,0 +1,3 @@
1
+ export declare enum Fee {
2
+ DEFAULT = 30
3
+ }
@@ -0,0 +1,18 @@
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
+ }
@@ -0,0 +1,6 @@
1
+ export declare enum OrderStatus {
2
+ FILLED = "FILLED",
3
+ CANCELLED = "CANCELLED",
4
+ EXPIRED = "EXPIRED",
5
+ PENDING = "PENDING"
6
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum Rounding {
2
+ ROUND_DOWN = 0,
3
+ ROUND_HALF_UP = 1,
4
+ ROUND_UP = 2
5
+ }
@@ -0,0 +1,4 @@
1
+ export declare enum TradeType {
2
+ EXACT_INPUT = 0,
3
+ EXACT_OUTPUT = 1
4
+ }
@@ -0,0 +1,6 @@
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';
@@ -0,0 +1,3 @@
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;
@@ -0,0 +1,9 @@
1
+ import { Fee } from '../enums';
2
+ import { Token } from '../entities';
3
+ export declare const computeConstantProductPoolAddress: ({ factoryAddress, tokenA, tokenB, fee, twap }: {
4
+ factoryAddress: string;
5
+ tokenA: Token;
6
+ tokenB: Token;
7
+ fee: Fee;
8
+ twap: boolean;
9
+ }) => string;
@@ -0,0 +1,6 @@
1
+ import { Token } from '../entities';
2
+ export declare const computePairAddress: ({ factoryAddress, tokenA, tokenB }: {
3
+ factoryAddress: string;
4
+ tokenA: Token;
5
+ tokenB: Token;
6
+ }) => string;
@@ -0,0 +1,5 @@
1
+ export declare const computePoolInitCodeHash: ({ creationCode, deployData, masterDeployerAddress }: {
2
+ creationCode: string;
3
+ deployData: string;
4
+ masterDeployerAddress: string;
5
+ }) => string;
@@ -0,0 +1,11 @@
1
+ import { Currency } from '../entities/Currency';
2
+ import { CurrencyAmount } from '../entities/CurrencyAmount';
3
+ import { Percent } from '../entities/Percent';
4
+ import { Price } from '../entities/Price';
5
+ /**
6
+ * Returns the percent difference between the mid price and the execution price, i.e. price impact.
7
+ * @param midPrice mid price before the trade
8
+ * @param inputAmount the input amount of the trade
9
+ * @param outputAmount the output amount of the trade
10
+ */
11
+ export declare function computePriceImpact<TBase extends Currency, TQuote extends Currency>(midPrice: Price<TBase, TQuote>, inputAmount: CurrencyAmount<TBase>, outputAmount: CurrencyAmount<TQuote>): Percent;
@@ -0,0 +1,8 @@
1
+ export { computePairAddress } from './computePairAddress';
2
+ export { computePriceImpact } from './computePriceImpact';
3
+ export { computeConstantProductPoolAddress } from './computeConstantProductPoolAddress';
4
+ export { computePoolInitCodeHash } from './computePoolInitCodeHash';
5
+ export { sortedInsert } from './sortedInsert';
6
+ export { sqrt } from './sqrt';
7
+ export { validateAndParseAddress } from './validateAndParseAddress';
8
+ export { validateSolidityTypeInstance } from './validateSolidityTypeInstance';
@@ -0,0 +1,9 @@
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ export declare function accrue(pair: any, amount: BigNumber, includePrincipal?: boolean): BigNumber;
3
+ export declare function accrueTotalAssetWithFee(pair: any): {
4
+ elastic: BigNumber;
5
+ base: BigNumber;
6
+ };
7
+ export declare function interestAccrue(pair: any, interest: BigNumber): BigNumber;
8
+ export declare function takeFee(amount: BigNumber): BigNumber;
9
+ export declare function addBorrowFee(amount: BigNumber): BigNumber;
@@ -0,0 +1,4 @@
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ import { Rebase } from '../interfaces';
3
+ export declare function rebase(value: BigNumber, from: BigNumber, to: BigNumber): BigNumber;
4
+ export declare function toElastic(total: Rebase, base: BigNumber, roundUp: boolean): BigNumber;
@@ -0,0 +1 @@
1
+ export declare function sortedInsert<T>(items: T[], add: T, maxSize: number, comparator: (a: T, b: T) => number): T | null;
@@ -0,0 +1,7 @@
1
+ import JSBI from 'jsbi';
2
+ export declare const MAX_SAFE_INTEGER: JSBI;
3
+ /**
4
+ * Computes floor(sqrt(value))
5
+ * @param value the value for which to compute the square root, rounded down
6
+ */
7
+ export declare function sqrt(value: JSBI): JSBI;
@@ -0,0 +1 @@
1
+ export declare function validateAndParseAddress(address: string): string;
@@ -0,0 +1,3 @@
1
+ import { SolidityType } from '../constants';
2
+ import JSBI from 'jsbi';
3
+ export declare function validateSolidityTypeInstance(value: JSBI, solidityType: SolidityType): void;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  import JSBI from 'jsbi';
2
2
  export { JSBI };
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';
3
+ export * from './constants';
4
4
  export * from './errors';
5
5
  export * from './entities';
6
+ export * from './functions';
6
7
  export * from './router';
7
- export * from './fetcher';
8
+ export * from './enums';
9
+ export * from './router';
10
+ export * from './types';
11
+ export * from './utils/MultiRouterMath';
12
+ export * from './limitorder';
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  'use strict'
3
3
 
4
4
  if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./sdk.cjs.production.min.js')
5
+ module.exports = require('./qidao-sdk.cjs.production.min.js')
6
6
  } else {
7
- module.exports = require('./sdk.cjs.development.js')
7
+ module.exports = require('./qidao-sdk.cjs.development.js')
8
8
  }
@@ -0,0 +1,6 @@
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ export interface AccrueInfo {
3
+ interestPerSecond: BigNumber;
4
+ lastAccrued: BigNumber;
5
+ feesEarnedFraction: BigNumber;
6
+ }
@@ -0,0 +1,5 @@
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ export interface Rebase {
3
+ base: BigNumber;
4
+ elastic: BigNumber;
5
+ }
@@ -0,0 +1,2 @@
1
+ export { AccrueInfo } from './AccrueInfo';
2
+ export { Rebase } from './Rebase';