@qidao/sdk 5.0.0-canary.117
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 +53 -0
- package/dist/constants/addresses.d.ts +31 -0
- package/dist/constants/index.d.ts +20 -0
- package/dist/constants/kashi.d.ts +29 -0
- package/dist/constants/natives.d.ts +30 -0
- package/dist/constants/numbers.d.ts +11 -0
- package/dist/constants/tokens.d.ts +5 -0
- package/dist/entities/AbstractCurrency.d.ts +53 -0
- package/dist/entities/ConstantProductPool.d.ts +43 -0
- package/dist/entities/Currency.d.ts +3 -0
- package/dist/entities/CurrencyAmount.d.ts +38 -0
- package/dist/entities/Fraction.d.ts +25 -0
- package/dist/entities/MultiRouter.d.ts +59 -0
- package/dist/entities/Native/Avalanche.d.ts +10 -0
- package/dist/entities/Native/Binance.d.ts +10 -0
- package/dist/entities/Native/Celo.d.ts +10 -0
- package/dist/entities/Native/Ether.d.ts +13 -0
- package/dist/entities/Native/Fantom.d.ts +10 -0
- package/dist/entities/Native/Fuse.d.ts +10 -0
- package/dist/entities/Native/Harmony.d.ts +10 -0
- package/dist/entities/Native/Heco.d.ts +10 -0
- package/dist/entities/Native/Matic.d.ts +10 -0
- package/dist/entities/Native/Movr.d.ts +10 -0
- package/dist/entities/Native/Okex.d.ts +10 -0
- package/dist/entities/Native/Palm.d.ts +10 -0
- package/dist/entities/Native/Telos.d.ts +10 -0
- package/dist/entities/Native/index.d.ts +14 -0
- package/dist/entities/Native/xDai.d.ts +10 -0
- package/dist/entities/NativeCurrency.d.ts +8 -0
- package/dist/entities/Pair.d.ts +41 -0
- package/dist/entities/Percent.d.ts +15 -0
- package/dist/entities/Price.d.ts +39 -0
- package/dist/entities/Route.d.ts +14 -0
- package/dist/entities/Token.d.ts +33 -0
- package/dist/entities/Trade.d.ts +107 -0
- package/dist/entities/eip712.d.ts +78 -0
- package/dist/entities/index.d.ts +14 -0
- package/dist/enums/ChainId.d.ts +31 -0
- package/dist/enums/Fee.d.ts +3 -0
- package/dist/enums/KashiAction.d.ts +18 -0
- package/dist/enums/OrderStatus.d.ts +6 -0
- package/dist/enums/Rounding.d.ts +5 -0
- package/dist/enums/TradeType.d.ts +4 -0
- package/dist/enums/index.d.ts +6 -0
- package/dist/errors.d.ts +16 -0
- package/dist/functions/bentobox.d.ts +3 -0
- package/dist/functions/computeConstantProductPoolAddress.d.ts +9 -0
- package/dist/functions/computePairAddress.d.ts +6 -0
- package/dist/functions/computePoolInitCodeHash.d.ts +5 -0
- package/dist/functions/computePriceImpact.d.ts +11 -0
- package/dist/functions/index.d.ts +8 -0
- package/dist/functions/kashi.d.ts +9 -0
- package/dist/functions/rebase.d.ts +4 -0
- package/dist/functions/sortedInsert.d.ts +1 -0
- package/dist/functions/sqrt.d.ts +7 -0
- package/dist/functions/validateAndParseAddress.d.ts +1 -0
- package/dist/functions/validateSolidityTypeInstance.d.ts +3 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +8 -0
- package/dist/interfaces/AccrueInfo.d.ts +6 -0
- package/dist/interfaces/Rebase.d.ts +5 -0
- package/dist/interfaces/index.d.ts +2 -0
- package/dist/limitorder.d.ts +115 -0
- package/dist/router.d.ts +68 -0
- package/dist/sdk.cjs.development.js +5303 -0
- package/dist/sdk.cjs.development.js.map +1 -0
- package/dist/sdk.cjs.production.min.js +2 -0
- package/dist/sdk.cjs.production.min.js.map +1 -0
- package/dist/sdk.esm.js +5164 -0
- package/dist/sdk.esm.js.map +1 -0
- package/dist/types/AddressMap.d.ts +3 -0
- package/dist/types/BigIntIsh.d.ts +2 -0
- package/dist/types/ChainTokenMap.d.ts +5 -0
- package/dist/types/LimitOrderTypes.d.ts +21 -0
- package/dist/types/MultiRouterTypes.d.ts +97 -0
- package/dist/types/TokenMap.d.ts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/utils/MultiRouterMath.d.ts +15 -0
- package/package.json +70 -0
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { AbstractCurrency } from './AbstractCurrency';
|
|
2
|
+
import { ChainId } from '../enums';
|
|
3
|
+
import { Currency } from './Currency';
|
|
4
|
+
/**
|
|
5
|
+
* Represents an ERC20 token with a unique address and some metadata.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Token extends AbstractCurrency {
|
|
8
|
+
readonly chainId: ChainId;
|
|
9
|
+
readonly address: string;
|
|
10
|
+
readonly isNative: false;
|
|
11
|
+
readonly isToken: true;
|
|
12
|
+
constructor(chainId: ChainId, address: string, decimals: number, symbol?: string, name?: string);
|
|
13
|
+
/**
|
|
14
|
+
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
|
15
|
+
* @param other other token to compare
|
|
16
|
+
*/
|
|
17
|
+
equals(other: Currency): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Returns true if the address of this token sorts before the address of the other token
|
|
20
|
+
* @param other other token to compare
|
|
21
|
+
* @throws if the tokens have the same address
|
|
22
|
+
* @throws if the tokens are on different chains
|
|
23
|
+
*/
|
|
24
|
+
sortsBefore(other: Token): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Return this token, which does not need to be wrapped
|
|
27
|
+
*/
|
|
28
|
+
get wrapped(): Token;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Compares two currencies for equality
|
|
32
|
+
*/
|
|
33
|
+
export declare function currencyEquals(currencyA: Currency, currencyB: Currency): boolean;
|
|
@@ -0,0 +1,107 @@
|
|
|
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 {};
|
|
@@ -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
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
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,31 @@
|
|
|
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
|
+
AVALANCHE = 43114,
|
|
18
|
+
AVALANCHE_TESTNET = 43113,
|
|
19
|
+
HECO = 128,
|
|
20
|
+
HECO_TESTNET = 256,
|
|
21
|
+
HARMONY = 1666600000,
|
|
22
|
+
HARMONY_TESTNET = 1666700000,
|
|
23
|
+
OKEX = 66,
|
|
24
|
+
OKEX_TESTNET = 65,
|
|
25
|
+
CELO = 42220,
|
|
26
|
+
PALM = 11297108109,
|
|
27
|
+
PALM_TESTNET = 11297108099,
|
|
28
|
+
MOONRIVER = 1285,
|
|
29
|
+
FUSE = 122,
|
|
30
|
+
TELOS = 40
|
|
31
|
+
}
|
|
@@ -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
|
+
}
|
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
|
+
}
|
|
@@ -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,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 @@
|
|
|
1
|
+
export declare function validateAndParseAddress(address: string): string;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import JSBI from 'jsbi';
|
|
2
|
+
export { JSBI };
|
|
3
|
+
export * from './constants';
|
|
4
|
+
export * from './errors';
|
|
5
|
+
export * from './entities';
|
|
6
|
+
export * from './functions';
|
|
7
|
+
export * from './router';
|
|
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
ADDED