@pancakeswap/sdk 3.0.0 → 3.1.1
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/README.md +1 -1
- package/dist/index.d.ts +30 -257
- package/dist/index.js +134 -502
- package/dist/index.mjs +140 -467
- package/package.json +10 -5
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,95 +1,11 @@
|
|
|
1
|
-
import JSBI from 'jsbi';
|
|
2
1
|
export { default as JSBI } from 'jsbi';
|
|
2
|
+
import { Token, CurrencyAmount, Price, BigintIsh, Currency, TradeType, Percent, NativeCurrency } from '@pancakeswap/swap-sdk-core';
|
|
3
|
+
export * from '@pancakeswap/swap-sdk-core';
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
|
5
|
+
declare class ERC20Token extends Token {
|
|
6
|
+
constructor(chainId: number, address: string, decimals: number, symbol: string, name?: string, projectLink?: string);
|
|
90
7
|
}
|
|
91
8
|
|
|
92
|
-
declare type BigintIsh = JSBI | number | string;
|
|
93
9
|
declare enum ChainId {
|
|
94
10
|
ETHEREUM = 1,
|
|
95
11
|
RINKEBY = 4,
|
|
@@ -97,211 +13,68 @@ declare enum ChainId {
|
|
|
97
13
|
BSC = 56,
|
|
98
14
|
BSC_TESTNET = 97
|
|
99
15
|
}
|
|
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
16
|
declare const FACTORY_ADDRESS = "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73";
|
|
110
17
|
declare const FACTORY_ADDRESS_MAP: Record<number, string>;
|
|
111
18
|
declare const INIT_CODE_HASH = "0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5";
|
|
112
19
|
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
20
|
declare const WETH9: {
|
|
133
|
-
1:
|
|
134
|
-
4:
|
|
135
|
-
5:
|
|
21
|
+
1: ERC20Token;
|
|
22
|
+
4: ERC20Token;
|
|
23
|
+
5: ERC20Token;
|
|
136
24
|
};
|
|
137
25
|
declare const WBNB: {
|
|
138
|
-
1:
|
|
139
|
-
56:
|
|
140
|
-
97:
|
|
26
|
+
1: ERC20Token;
|
|
27
|
+
56: ERC20Token;
|
|
28
|
+
97: ERC20Token;
|
|
141
29
|
};
|
|
142
|
-
declare const WNATIVE: Record<number,
|
|
30
|
+
declare const WNATIVE: Record<number, ERC20Token>;
|
|
143
31
|
declare const NATIVE: Record<number, {
|
|
144
32
|
name: string;
|
|
145
33
|
symbol: string;
|
|
146
34
|
decimals: number;
|
|
147
35
|
}>;
|
|
148
36
|
|
|
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
37
|
declare const computePairAddress: ({ factoryAddress, tokenA, tokenB, }: {
|
|
265
38
|
factoryAddress: string;
|
|
266
|
-
tokenA:
|
|
267
|
-
tokenB:
|
|
39
|
+
tokenA: ERC20Token;
|
|
40
|
+
tokenB: ERC20Token;
|
|
268
41
|
}) => string;
|
|
269
42
|
declare class Pair {
|
|
270
|
-
readonly liquidityToken:
|
|
43
|
+
readonly liquidityToken: ERC20Token;
|
|
271
44
|
private readonly tokenAmounts;
|
|
272
|
-
static getAddress(tokenA:
|
|
273
|
-
constructor(currencyAmountA: CurrencyAmount<
|
|
45
|
+
static getAddress(tokenA: ERC20Token, tokenB: ERC20Token): string;
|
|
46
|
+
constructor(currencyAmountA: CurrencyAmount<ERC20Token>, tokenAmountB: CurrencyAmount<ERC20Token>);
|
|
274
47
|
/**
|
|
275
48
|
* Returns true if the token is either token0 or token1
|
|
276
49
|
* @param token to check
|
|
277
50
|
*/
|
|
278
|
-
involvesToken(token:
|
|
51
|
+
involvesToken(token: ERC20Token): boolean;
|
|
279
52
|
/**
|
|
280
53
|
* Returns the current mid price of the pair in terms of token0, i.e. the ratio of reserve1 to reserve0
|
|
281
54
|
*/
|
|
282
|
-
get token0Price(): Price<
|
|
55
|
+
get token0Price(): Price<ERC20Token, ERC20Token>;
|
|
283
56
|
/**
|
|
284
57
|
* Returns the current mid price of the pair in terms of token1, i.e. the ratio of reserve0 to reserve1
|
|
285
58
|
*/
|
|
286
|
-
get token1Price(): Price<
|
|
59
|
+
get token1Price(): Price<ERC20Token, ERC20Token>;
|
|
287
60
|
/**
|
|
288
61
|
* Return the price of the given token in terms of the other token in the pair.
|
|
289
62
|
* @param token token to return price of
|
|
290
63
|
*/
|
|
291
|
-
priceOf(token:
|
|
64
|
+
priceOf(token: ERC20Token): Price<ERC20Token, ERC20Token>;
|
|
292
65
|
/**
|
|
293
66
|
* Returns the chain ID of the tokens in the pair.
|
|
294
67
|
*/
|
|
295
68
|
get chainId(): number;
|
|
296
|
-
get token0():
|
|
297
|
-
get token1():
|
|
298
|
-
get reserve0(): CurrencyAmount<
|
|
299
|
-
get reserve1(): CurrencyAmount<
|
|
300
|
-
reserveOf(token:
|
|
301
|
-
getOutputAmount(inputAmount: CurrencyAmount<
|
|
302
|
-
getInputAmount(outputAmount: CurrencyAmount<
|
|
303
|
-
getLiquidityMinted(totalSupply: CurrencyAmount<
|
|
304
|
-
getLiquidityValue(token:
|
|
69
|
+
get token0(): ERC20Token;
|
|
70
|
+
get token1(): ERC20Token;
|
|
71
|
+
get reserve0(): CurrencyAmount<ERC20Token>;
|
|
72
|
+
get reserve1(): CurrencyAmount<ERC20Token>;
|
|
73
|
+
reserveOf(token: ERC20Token): CurrencyAmount<ERC20Token>;
|
|
74
|
+
getOutputAmount(inputAmount: CurrencyAmount<ERC20Token>): [CurrencyAmount<ERC20Token>, Pair];
|
|
75
|
+
getInputAmount(outputAmount: CurrencyAmount<ERC20Token>): [CurrencyAmount<ERC20Token>, Pair];
|
|
76
|
+
getLiquidityMinted(totalSupply: CurrencyAmount<ERC20Token>, tokenAmountA: CurrencyAmount<ERC20Token>, tokenAmountB: CurrencyAmount<ERC20Token>): CurrencyAmount<ERC20Token>;
|
|
77
|
+
getLiquidityValue(token: ERC20Token, totalSupply: CurrencyAmount<ERC20Token>, liquidity: CurrencyAmount<ERC20Token>, feeOn?: boolean, kLast?: BigintIsh): CurrencyAmount<ERC20Token>;
|
|
305
78
|
}
|
|
306
79
|
|
|
307
80
|
declare class Route<TInput extends Currency, TOutput extends Currency> {
|
|
@@ -503,4 +276,4 @@ declare abstract class Router {
|
|
|
503
276
|
*/
|
|
504
277
|
declare function computePriceImpact<TBase extends Currency, TQuote extends Currency>(midPrice: Price<TBase, TQuote>, inputAmount: CurrencyAmount<TBase>, outputAmount: CurrencyAmount<TQuote>): Percent;
|
|
505
278
|
|
|
506
|
-
export {
|
|
279
|
+
export { BestTradeOptions, ChainId, ERC20Token, FACTORY_ADDRESS, FACTORY_ADDRESS_MAP, INIT_CODE_HASH, INIT_CODE_HASH_MAP, NATIVE, Native, Pair, Route, Router, SwapParameters, Trade, TradeOptions, TradeOptionsDeadline, WBNB, WETH9, WNATIVE, computePairAddress, computePriceImpact, inputOutputComparator, tradeComparator };
|