@pancakeswap/sdk 3.0.0-0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +506 -7
- package/dist/index.js +993 -5
- package/dist/index.mjs +926 -0
- package/package.json +14 -12
- package/dist/constants.d.ts +0 -49
- package/dist/entities/currency.d.ts +0 -23
- package/dist/entities/fractions/currencyAmount.d.ts +0 -19
- package/dist/entities/fractions/fraction.d.ts +0 -23
- package/dist/entities/fractions/index.d.ts +0 -5
- package/dist/entities/fractions/percent.d.ts +0 -6
- package/dist/entities/fractions/price.d.ts +0 -19
- package/dist/entities/fractions/tokenAmount.d.ts +0 -9
- package/dist/entities/index.d.ts +0 -6
- package/dist/entities/pair.d.ts +0 -41
- package/dist/entities/route.d.ts +0 -14
- package/dist/entities/token.d.ts +0 -41
- package/dist/entities/trade.d.ts +0 -106
- package/dist/errors.d.ts +0 -16
- package/dist/fetcher.d.ts +0 -28
- package/dist/router.d.ts +0 -63
- package/dist/sdk.cjs.development.js +0 -2351
- package/dist/sdk.cjs.development.js.map +0 -1
- package/dist/sdk.cjs.production.min.js +0 -2
- package/dist/sdk.cjs.production.min.js.map +0 -1
- package/dist/sdk.esm.js +0 -2325
- package/dist/sdk.esm.js.map +0 -1
- package/dist/test/constants.test.d.ts +0 -1
- package/dist/test/data.test.d.ts +0 -1
- package/dist/test/entities.test.d.ts +0 -1
- package/dist/test/fraction.test.d.ts +0 -1
- package/dist/test/miscellaneous.test.d.ts +0 -1
- package/dist/test/pair.test.d.ts +0 -1
- package/dist/test/route.test.d.ts +0 -1
- package/dist/test/router.test.d.ts +0 -1
- package/dist/test/token.test.d.ts +0 -1
- package/dist/test/trade.test.d.ts +0 -1
- package/dist/utils.d.ts +0 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,506 @@
|
|
|
1
|
-
import JSBI from 'jsbi';
|
|
2
|
-
export { JSBI };
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import JSBI from 'jsbi';
|
|
2
|
+
export { default as JSBI } from 'jsbi';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents the native currency of the chain on which it resides, e.g.
|
|
6
|
+
*/
|
|
7
|
+
declare abstract class NativeCurrency extends BaseCurrency {
|
|
8
|
+
readonly isNative: true;
|
|
9
|
+
readonly isToken: false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare type Currency = NativeCurrency | Token;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies
|
|
16
|
+
*/
|
|
17
|
+
declare abstract class BaseCurrency {
|
|
18
|
+
/**
|
|
19
|
+
* Returns whether the currency is native to the chain and must be wrapped (e.g. Ether)
|
|
20
|
+
*/
|
|
21
|
+
abstract readonly isNative: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Returns whether the currency is a token that is usable in PancakeSwap without wrapping
|
|
24
|
+
*/
|
|
25
|
+
abstract readonly isToken: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The chain ID on which this currency resides
|
|
28
|
+
*/
|
|
29
|
+
readonly chainId: number;
|
|
30
|
+
/**
|
|
31
|
+
* The decimals used in representing currency amounts
|
|
32
|
+
*/
|
|
33
|
+
readonly decimals: number;
|
|
34
|
+
/**
|
|
35
|
+
* The symbol of the currency, i.e. a short textual non-unique identifier
|
|
36
|
+
*/
|
|
37
|
+
readonly symbol?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The name of the currency, i.e. a descriptive textual non-unique identifier
|
|
40
|
+
*/
|
|
41
|
+
readonly name?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Constructs an instance of the base class `BaseCurrency`.
|
|
44
|
+
* @param chainId the chain ID on which this currency resides
|
|
45
|
+
* @param decimals decimals of the currency
|
|
46
|
+
* @param symbol symbol of the currency
|
|
47
|
+
* @param name of the currency
|
|
48
|
+
*/
|
|
49
|
+
protected constructor(chainId: number, decimals: number, symbol?: string, name?: string);
|
|
50
|
+
/**
|
|
51
|
+
* Returns whether this currency is functionally equivalent to the other currency
|
|
52
|
+
* @param other the other currency
|
|
53
|
+
*/
|
|
54
|
+
abstract equals(other: Currency): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Return the wrapped version of this currency that can be used with the PancakeSwap contracts. Currencies must
|
|
57
|
+
* implement this to be used in PancakeSwap
|
|
58
|
+
*/
|
|
59
|
+
abstract get wrapped(): Token;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Represents an ERC20 token with a unique address and some metadata.
|
|
64
|
+
*/
|
|
65
|
+
declare class Token extends BaseCurrency {
|
|
66
|
+
readonly isNative: false;
|
|
67
|
+
readonly isToken: true;
|
|
68
|
+
/**
|
|
69
|
+
* The contract address on the chain on which this token lives
|
|
70
|
+
*/
|
|
71
|
+
readonly address: string;
|
|
72
|
+
readonly projectLink?: string;
|
|
73
|
+
constructor(chainId: number, address: string, decimals: number, symbol?: string, name?: string, projectLink?: string);
|
|
74
|
+
/**
|
|
75
|
+
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
|
76
|
+
* @param other other token to compare
|
|
77
|
+
*/
|
|
78
|
+
equals(other: Currency): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Returns true if the address of this token sorts before the address of the other token
|
|
81
|
+
* @param other other token to compare
|
|
82
|
+
* @throws if the tokens have the same address
|
|
83
|
+
* @throws if the tokens are on different chains
|
|
84
|
+
*/
|
|
85
|
+
sortsBefore(other: Token): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Return this token, which does not need to be wrapped
|
|
88
|
+
*/
|
|
89
|
+
get wrapped(): Token;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
declare type BigintIsh = JSBI | number | string;
|
|
93
|
+
declare enum ChainId {
|
|
94
|
+
ETHEREUM = 1,
|
|
95
|
+
RINKEBY = 4,
|
|
96
|
+
GOERLI = 5,
|
|
97
|
+
BSC = 56,
|
|
98
|
+
BSC_TESTNET = 97
|
|
99
|
+
}
|
|
100
|
+
declare enum TradeType {
|
|
101
|
+
EXACT_INPUT = 0,
|
|
102
|
+
EXACT_OUTPUT = 1
|
|
103
|
+
}
|
|
104
|
+
declare enum Rounding {
|
|
105
|
+
ROUND_DOWN = 0,
|
|
106
|
+
ROUND_HALF_UP = 1,
|
|
107
|
+
ROUND_UP = 2
|
|
108
|
+
}
|
|
109
|
+
declare const FACTORY_ADDRESS = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73";
|
|
110
|
+
declare const FACTORY_ADDRESS_MAP: Record<number, string>;
|
|
111
|
+
declare const INIT_CODE_HASH = "0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5";
|
|
112
|
+
declare const INIT_CODE_HASH_MAP: Record<number, string>;
|
|
113
|
+
declare const MINIMUM_LIQUIDITY: JSBI;
|
|
114
|
+
declare const ZERO: JSBI;
|
|
115
|
+
declare const ONE: JSBI;
|
|
116
|
+
declare const TWO: JSBI;
|
|
117
|
+
declare const THREE: JSBI;
|
|
118
|
+
declare const FIVE: JSBI;
|
|
119
|
+
declare const TEN: JSBI;
|
|
120
|
+
declare const _100: JSBI;
|
|
121
|
+
declare const _9975: JSBI;
|
|
122
|
+
declare const _10000: JSBI;
|
|
123
|
+
declare const MaxUint256: JSBI;
|
|
124
|
+
declare enum SolidityType {
|
|
125
|
+
uint8 = "uint8",
|
|
126
|
+
uint256 = "uint256"
|
|
127
|
+
}
|
|
128
|
+
declare const SOLIDITY_TYPE_MAXIMA: {
|
|
129
|
+
uint8: JSBI;
|
|
130
|
+
uint256: JSBI;
|
|
131
|
+
};
|
|
132
|
+
declare const WETH9: {
|
|
133
|
+
1: Token;
|
|
134
|
+
4: Token;
|
|
135
|
+
5: Token;
|
|
136
|
+
};
|
|
137
|
+
declare const WBNB: {
|
|
138
|
+
1: Token;
|
|
139
|
+
56: Token;
|
|
140
|
+
97: Token;
|
|
141
|
+
};
|
|
142
|
+
declare const WNATIVE: Record<number, Token>;
|
|
143
|
+
declare const NATIVE: Record<number, {
|
|
144
|
+
name: string;
|
|
145
|
+
symbol: string;
|
|
146
|
+
decimals: number;
|
|
147
|
+
}>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Indicates that the pair has insufficient reserves for a desired output amount. I.e. the amount of output cannot be
|
|
151
|
+
* obtained by sending any amount of input.
|
|
152
|
+
*/
|
|
153
|
+
declare class InsufficientReservesError extends Error {
|
|
154
|
+
readonly isInsufficientReservesError: true;
|
|
155
|
+
constructor();
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Indicates that the input amount is too small to produce any amount of output. I.e. the amount of input sent is less
|
|
159
|
+
* than the price of a single unit of output after fees.
|
|
160
|
+
*/
|
|
161
|
+
declare class InsufficientInputAmountError extends Error {
|
|
162
|
+
readonly isInsufficientInputAmountError: true;
|
|
163
|
+
constructor();
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
declare class Fraction {
|
|
167
|
+
readonly numerator: JSBI;
|
|
168
|
+
readonly denominator: JSBI;
|
|
169
|
+
constructor(numerator: BigintIsh, denominator?: BigintIsh);
|
|
170
|
+
private static tryParseFraction;
|
|
171
|
+
get quotient(): JSBI;
|
|
172
|
+
get remainder(): Fraction;
|
|
173
|
+
invert(): Fraction;
|
|
174
|
+
add(other: Fraction | BigintIsh): Fraction;
|
|
175
|
+
subtract(other: Fraction | BigintIsh): Fraction;
|
|
176
|
+
lessThan(other: Fraction | BigintIsh): boolean;
|
|
177
|
+
equalTo(other: Fraction | BigintIsh): boolean;
|
|
178
|
+
greaterThan(other: Fraction | BigintIsh): boolean;
|
|
179
|
+
multiply(other: Fraction | BigintIsh): Fraction;
|
|
180
|
+
divide(other: Fraction | BigintIsh): Fraction;
|
|
181
|
+
toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
|
|
182
|
+
toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
|
|
183
|
+
/**
|
|
184
|
+
* Helper method for converting any super class back to a fraction
|
|
185
|
+
*/
|
|
186
|
+
get asFraction(): Fraction;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class CurrencyAmount<T extends Currency> extends Fraction {
|
|
190
|
+
readonly currency: T;
|
|
191
|
+
readonly decimalScale: JSBI;
|
|
192
|
+
/**
|
|
193
|
+
* Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
|
|
194
|
+
* @param currency the currency in the amount
|
|
195
|
+
* @param rawAmount the raw token or ether amount
|
|
196
|
+
*/
|
|
197
|
+
static fromRawAmount<T extends Currency>(currency: T, rawAmount: BigintIsh): CurrencyAmount<T>;
|
|
198
|
+
/**
|
|
199
|
+
* Construct a currency amount with a denominator that is not equal to 1
|
|
200
|
+
* @param currency the currency
|
|
201
|
+
* @param numerator the numerator of the fractional token amount
|
|
202
|
+
* @param denominator the denominator of the fractional token amount
|
|
203
|
+
*/
|
|
204
|
+
static fromFractionalAmount<T extends Currency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): CurrencyAmount<T>;
|
|
205
|
+
protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
|
|
206
|
+
add(other: CurrencyAmount<T>): CurrencyAmount<T>;
|
|
207
|
+
subtract(other: CurrencyAmount<T>): CurrencyAmount<T>;
|
|
208
|
+
multiply(other: Fraction | BigintIsh): CurrencyAmount<T>;
|
|
209
|
+
divide(other: Fraction | BigintIsh): CurrencyAmount<T>;
|
|
210
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
211
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
212
|
+
toExact(format?: object): string;
|
|
213
|
+
get wrapped(): CurrencyAmount<Token>;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
declare class Price<TBase extends Currency, TQuote extends Currency> extends Fraction {
|
|
217
|
+
readonly baseCurrency: TBase;
|
|
218
|
+
readonly quoteCurrency: TQuote;
|
|
219
|
+
readonly scalar: Fraction;
|
|
220
|
+
/**
|
|
221
|
+
* Construct a price, either with the base and quote currency amount, or the
|
|
222
|
+
* @param args
|
|
223
|
+
*/
|
|
224
|
+
constructor(...args: [TBase, TQuote, BigintIsh, BigintIsh] | [{
|
|
225
|
+
baseAmount: CurrencyAmount<TBase>;
|
|
226
|
+
quoteAmount: CurrencyAmount<TQuote>;
|
|
227
|
+
}]);
|
|
228
|
+
/**
|
|
229
|
+
* Flip the price, switching the base and quote currency
|
|
230
|
+
*/
|
|
231
|
+
invert(): Price<TQuote, TBase>;
|
|
232
|
+
/**
|
|
233
|
+
* 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
|
|
234
|
+
* @param other the other price
|
|
235
|
+
*/
|
|
236
|
+
multiply<TOtherQuote extends Currency>(other: Price<TQuote, TOtherQuote>): Price<TBase, TOtherQuote>;
|
|
237
|
+
/**
|
|
238
|
+
* Return the amount of quote currency corresponding to a given amount of the base currency
|
|
239
|
+
* @param currencyAmount the amount of base currency to quote against the price
|
|
240
|
+
*/
|
|
241
|
+
quote(currencyAmount: CurrencyAmount<TBase>): CurrencyAmount<TQuote>;
|
|
242
|
+
/**
|
|
243
|
+
* Get the value scaled by decimals for formatting
|
|
244
|
+
* @private
|
|
245
|
+
*/
|
|
246
|
+
private get adjustedForDecimals();
|
|
247
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
248
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
declare class Percent extends Fraction {
|
|
252
|
+
/**
|
|
253
|
+
* This boolean prevents a fraction from being interpreted as a Percent
|
|
254
|
+
*/
|
|
255
|
+
readonly isPercent: true;
|
|
256
|
+
add(other: Fraction | BigintIsh): Percent;
|
|
257
|
+
subtract(other: Fraction | BigintIsh): Percent;
|
|
258
|
+
multiply(other: Fraction | BigintIsh): Percent;
|
|
259
|
+
divide(other: Fraction | BigintIsh): Percent;
|
|
260
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
261
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
declare const computePairAddress: ({ factoryAddress, tokenA, tokenB, }: {
|
|
265
|
+
factoryAddress: string;
|
|
266
|
+
tokenA: Token;
|
|
267
|
+
tokenB: Token;
|
|
268
|
+
}) => string;
|
|
269
|
+
declare class Pair {
|
|
270
|
+
readonly liquidityToken: Token;
|
|
271
|
+
private readonly tokenAmounts;
|
|
272
|
+
static getAddress(tokenA: Token, tokenB: Token): string;
|
|
273
|
+
constructor(currencyAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>);
|
|
274
|
+
/**
|
|
275
|
+
* Returns true if the token is either token0 or token1
|
|
276
|
+
* @param token to check
|
|
277
|
+
*/
|
|
278
|
+
involvesToken(token: Token): boolean;
|
|
279
|
+
/**
|
|
280
|
+
* Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
|
|
281
|
+
*/
|
|
282
|
+
get token0Price(): Price<Token, Token>;
|
|
283
|
+
/**
|
|
284
|
+
* Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1
|
|
285
|
+
*/
|
|
286
|
+
get token1Price(): Price<Token, Token>;
|
|
287
|
+
/**
|
|
288
|
+
* Return the price of the given token in terms of the other token in the pair.
|
|
289
|
+
* @param token token to return price of
|
|
290
|
+
*/
|
|
291
|
+
priceOf(token: Token): Price<Token, Token>;
|
|
292
|
+
/**
|
|
293
|
+
* Returns the chain ID of the tokens in the pair.
|
|
294
|
+
*/
|
|
295
|
+
get chainId(): number;
|
|
296
|
+
get token0(): Token;
|
|
297
|
+
get token1(): Token;
|
|
298
|
+
get reserve0(): CurrencyAmount<Token>;
|
|
299
|
+
get reserve1(): CurrencyAmount<Token>;
|
|
300
|
+
reserveOf(token: Token): CurrencyAmount<Token>;
|
|
301
|
+
getOutputAmount(inputAmount: CurrencyAmount<Token>): [CurrencyAmount<Token>, Pair];
|
|
302
|
+
getInputAmount(outputAmount: CurrencyAmount<Token>): [CurrencyAmount<Token>, Pair];
|
|
303
|
+
getLiquidityMinted(totalSupply: CurrencyAmount<Token>, tokenAmountA: CurrencyAmount<Token>, tokenAmountB: CurrencyAmount<Token>): CurrencyAmount<Token>;
|
|
304
|
+
getLiquidityValue(token: Token, totalSupply: CurrencyAmount<Token>, liquidity: CurrencyAmount<Token>, feeOn?: boolean, kLast?: BigintIsh): CurrencyAmount<Token>;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
declare class Route<TInput extends Currency, TOutput extends Currency> {
|
|
308
|
+
readonly pairs: Pair[];
|
|
309
|
+
readonly path: Token[];
|
|
310
|
+
readonly input: TInput;
|
|
311
|
+
readonly output: TOutput;
|
|
312
|
+
constructor(pairs: Pair[], input: TInput, output: TOutput);
|
|
313
|
+
private _midPrice;
|
|
314
|
+
get midPrice(): Price<TInput, TOutput>;
|
|
315
|
+
get chainId(): number;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
interface InputOutput<TInput extends Currency, TOutput extends Currency> {
|
|
319
|
+
readonly inputAmount: CurrencyAmount<TInput>;
|
|
320
|
+
readonly outputAmount: CurrencyAmount<TOutput>;
|
|
321
|
+
}
|
|
322
|
+
declare function inputOutputComparator<TInput extends Currency, TOutput extends Currency>(a: InputOutput<TInput, TOutput>, b: InputOutput<TInput, TOutput>): number;
|
|
323
|
+
declare function tradeComparator<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType>(a: Trade<TInput, TOutput, TTradeType>, b: Trade<TInput, TOutput, TTradeType>): number;
|
|
324
|
+
interface BestTradeOptions {
|
|
325
|
+
maxNumResults?: number;
|
|
326
|
+
maxHops?: number;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Represents a trade executed against a list of pairs.
|
|
330
|
+
* Does not account for slippage, i.e. trades that front run this trade and move the price.
|
|
331
|
+
*/
|
|
332
|
+
declare class Trade<TInput extends Currency, TOutput extends Currency, TTradeType extends TradeType> {
|
|
333
|
+
/**
|
|
334
|
+
* The route of the trade, i.e. which pairs the trade goes through and the input/output currencies.
|
|
335
|
+
*/
|
|
336
|
+
readonly route: Route<TInput, TOutput>;
|
|
337
|
+
/**
|
|
338
|
+
* The type of the trade, either exact in or exact out.
|
|
339
|
+
*/
|
|
340
|
+
readonly tradeType: TTradeType;
|
|
341
|
+
/**
|
|
342
|
+
* The input amount for the trade assuming no slippage.
|
|
343
|
+
*/
|
|
344
|
+
readonly inputAmount: CurrencyAmount<TInput>;
|
|
345
|
+
/**
|
|
346
|
+
* The output amount for the trade assuming no slippage.
|
|
347
|
+
*/
|
|
348
|
+
readonly outputAmount: CurrencyAmount<TOutput>;
|
|
349
|
+
/**
|
|
350
|
+
* The price expressed in terms of output amount/input amount.
|
|
351
|
+
*/
|
|
352
|
+
readonly executionPrice: Price<TInput, TOutput>;
|
|
353
|
+
/**
|
|
354
|
+
* The percent difference between the mid price before the trade and the trade execution price.
|
|
355
|
+
*/
|
|
356
|
+
readonly priceImpact: Percent;
|
|
357
|
+
/**
|
|
358
|
+
* Constructs an exact in trade with the given amount in and route
|
|
359
|
+
* @param route route of the exact in trade
|
|
360
|
+
* @param amountIn the amount being passed in
|
|
361
|
+
*/
|
|
362
|
+
static exactIn<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountIn: CurrencyAmount<TInput>): Trade<TInput, TOutput, TradeType.EXACT_INPUT>;
|
|
363
|
+
/**
|
|
364
|
+
* Constructs an exact out trade with the given amount out and route
|
|
365
|
+
* @param route route of the exact out trade
|
|
366
|
+
* @param amountOut the amount returned by the trade
|
|
367
|
+
*/
|
|
368
|
+
static exactOut<TInput extends Currency, TOutput extends Currency>(route: Route<TInput, TOutput>, amountOut: CurrencyAmount<TOutput>): Trade<TInput, TOutput, TradeType.EXACT_OUTPUT>;
|
|
369
|
+
constructor(route: Route<TInput, TOutput>, amount: TTradeType extends TradeType.EXACT_INPUT ? CurrencyAmount<TInput> : CurrencyAmount<TOutput>, tradeType: TTradeType);
|
|
370
|
+
/**
|
|
371
|
+
* Get the minimum amount that must be received from this trade for the given slippage tolerance
|
|
372
|
+
* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
|
|
373
|
+
*/
|
|
374
|
+
minimumAmountOut(slippageTolerance: Percent): CurrencyAmount<TOutput>;
|
|
375
|
+
/**
|
|
376
|
+
* Get the maximum amount in that can be spent via this trade for the given slippage tolerance
|
|
377
|
+
* @param slippageTolerance tolerance of unfavorable slippage from the execution price of this trade
|
|
378
|
+
*/
|
|
379
|
+
maximumAmountIn(slippageTolerance: Percent): CurrencyAmount<TInput>;
|
|
380
|
+
/**
|
|
381
|
+
* Given a list of pairs, and a fixed amount in, returns the top `maxNumResults` trades that go from an input token
|
|
382
|
+
* amount to an output token, making at most `maxHops` hops.
|
|
383
|
+
* Note this does not consider aggregation, as routes are linear. It's possible a better route exists by splitting
|
|
384
|
+
* the amount in among multiple routes.
|
|
385
|
+
* @param pairs the pairs to consider in finding the best trade
|
|
386
|
+
* @param nextAmountIn exact amount of input currency to spend
|
|
387
|
+
* @param currencyOut the desired currency out
|
|
388
|
+
* @param maxNumResults maximum number of results to return
|
|
389
|
+
* @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
|
|
390
|
+
* @param currentPairs used in recursion; the current list of pairs
|
|
391
|
+
* @param currencyAmountIn used in recursion; the original value of the currencyAmountIn parameter
|
|
392
|
+
* @param bestTrades used in recursion; the current list of best trades
|
|
393
|
+
*/
|
|
394
|
+
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>[];
|
|
395
|
+
/**
|
|
396
|
+
* Return the execution price after accounting for slippage tolerance
|
|
397
|
+
* @param slippageTolerance the allowed tolerated slippage
|
|
398
|
+
*/
|
|
399
|
+
worstExecutionPrice(slippageTolerance: Percent): Price<TInput, TOutput>;
|
|
400
|
+
/**
|
|
401
|
+
* similar to the above method but instead targets a fixed output amount
|
|
402
|
+
* given a list of pairs, and a fixed amount out, returns the top `maxNumResults` trades that go from an input token
|
|
403
|
+
* to an output token amount, making at most `maxHops` hops
|
|
404
|
+
* note this does not consider aggregation, as routes are linear. it's possible a better route exists by splitting
|
|
405
|
+
* the amount in among multiple routes.
|
|
406
|
+
* @param pairs the pairs to consider in finding the best trade
|
|
407
|
+
* @param currencyIn the currency to spend
|
|
408
|
+
* @param nextAmountOut the exact amount of currency out
|
|
409
|
+
* @param maxNumResults maximum number of results to return
|
|
410
|
+
* @param maxHops maximum number of hops a returned trade can make, e.g. 1 hop goes through a single pair
|
|
411
|
+
* @param currentPairs used in recursion; the current list of pairs
|
|
412
|
+
* @param currencyAmountOut used in recursion; the original value of the currencyAmountOut parameter
|
|
413
|
+
* @param bestTrades used in recursion; the current list of best trades
|
|
414
|
+
*/
|
|
415
|
+
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>[];
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
*
|
|
420
|
+
* Native is the main usage of a 'native' currency, i.e. for BSC mainnet and all testnets
|
|
421
|
+
*/
|
|
422
|
+
declare class Native extends NativeCurrency {
|
|
423
|
+
protected constructor({ chainId, decimals, name, symbol, }: {
|
|
424
|
+
chainId: number;
|
|
425
|
+
decimals: number;
|
|
426
|
+
symbol: string;
|
|
427
|
+
name: string;
|
|
428
|
+
});
|
|
429
|
+
get wrapped(): Token;
|
|
430
|
+
private static cache;
|
|
431
|
+
static onChain(chainId: number): Native;
|
|
432
|
+
equals(other: Currency): boolean;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Options for producing the arguments to send call to the router.
|
|
437
|
+
*/
|
|
438
|
+
interface TradeOptions {
|
|
439
|
+
/**
|
|
440
|
+
* How much the execution price is allowed to move unfavorably from the trade execution price.
|
|
441
|
+
*/
|
|
442
|
+
allowedSlippage: Percent;
|
|
443
|
+
/**
|
|
444
|
+
* How long the swap is valid until it expires, in seconds.
|
|
445
|
+
* This will be used to produce a `deadline` parameter which is computed from when the swap call parameters
|
|
446
|
+
* are generated.
|
|
447
|
+
*/
|
|
448
|
+
ttl: number;
|
|
449
|
+
/**
|
|
450
|
+
* The account that should receive the output of the swap.
|
|
451
|
+
*/
|
|
452
|
+
recipient: string;
|
|
453
|
+
/**
|
|
454
|
+
* Whether any of the tokens in the path are fee on transfer tokens, which should be handled with special methods
|
|
455
|
+
*/
|
|
456
|
+
feeOnTransfer?: boolean;
|
|
457
|
+
}
|
|
458
|
+
interface TradeOptionsDeadline extends Omit<TradeOptions, 'ttl'> {
|
|
459
|
+
/**
|
|
460
|
+
* When the transaction expires.
|
|
461
|
+
* This is an atlernate to specifying the ttl, for when you do not want to use local time.
|
|
462
|
+
*/
|
|
463
|
+
deadline: number;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* The parameters to use in the call to the Pancake Router to execute a trade.
|
|
467
|
+
*/
|
|
468
|
+
interface SwapParameters {
|
|
469
|
+
/**
|
|
470
|
+
* The method to call on the Pancake Router.
|
|
471
|
+
*/
|
|
472
|
+
methodName: string;
|
|
473
|
+
/**
|
|
474
|
+
* The arguments to pass to the method, all hex encoded.
|
|
475
|
+
*/
|
|
476
|
+
args: (string | string[])[];
|
|
477
|
+
/**
|
|
478
|
+
* The amount of wei to send in hex.
|
|
479
|
+
*/
|
|
480
|
+
value: string;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Represents the Pancake Router, and has static methods for helping execute trades.
|
|
484
|
+
*/
|
|
485
|
+
declare abstract class Router {
|
|
486
|
+
/**
|
|
487
|
+
* Cannot be constructed.
|
|
488
|
+
*/
|
|
489
|
+
private constructor();
|
|
490
|
+
/**
|
|
491
|
+
* Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
|
|
492
|
+
* @param trade to produce call parameters for
|
|
493
|
+
* @param options options for the call parameters
|
|
494
|
+
*/
|
|
495
|
+
static swapCallParameters(trade: Trade<Currency, Currency, TradeType>, options: TradeOptions | TradeOptionsDeadline): SwapParameters;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Returns the percent difference between the mid price and the execution price, i.e. price impact.
|
|
500
|
+
* @param midPrice mid price before the trade
|
|
501
|
+
* @param inputAmount the input amount of the trade
|
|
502
|
+
* @param outputAmount the output amount of the trade
|
|
503
|
+
*/
|
|
504
|
+
declare function computePriceImpact<TBase extends Currency, TQuote extends Currency>(midPrice: Price<TBase, TQuote>, inputAmount: CurrencyAmount<TBase>, outputAmount: CurrencyAmount<TQuote>): Percent;
|
|
505
|
+
|
|
506
|
+
export { BaseCurrency, BestTradeOptions, BigintIsh, ChainId, Currency, CurrencyAmount, FACTORY_ADDRESS, FACTORY_ADDRESS_MAP, FIVE, Fraction, INIT_CODE_HASH, INIT_CODE_HASH_MAP, InsufficientInputAmountError, InsufficientReservesError, MINIMUM_LIQUIDITY, MaxUint256, NATIVE, Native, NativeCurrency, ONE, Pair, Percent, Price, Rounding, Route, Router, SOLIDITY_TYPE_MAXIMA, SolidityType, SwapParameters, TEN, THREE, TWO, Token, Trade, TradeOptions, TradeOptionsDeadline, TradeType, WBNB, WETH9, WNATIVE, ZERO, _100, _10000, _9975, computePairAddress, computePriceImpact, inputOutputComparator, tradeComparator };
|