@pancakeswap/swap-sdk-core 1.5.0 → 1.6.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 +366 -11
- package/dist/index.js +39 -4
- package/dist/index.mjs +36 -5
- package/package.json +4 -1
- package/dist/baseCurrency.d.ts +0 -49
- package/dist/baseCurrency.d.ts.map +0 -1
- package/dist/constants.d.ts +0 -31
- package/dist/constants.d.ts.map +0 -1
- package/dist/currency.d.ts +0 -9
- package/dist/currency.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -17
- package/dist/errors.d.ts.map +0 -1
- package/dist/fractions/currencyAmount.d.ts +0 -33
- package/dist/fractions/currencyAmount.d.ts.map +0 -1
- package/dist/fractions/fraction.d.ts +0 -24
- package/dist/fractions/fraction.d.ts.map +0 -1
- package/dist/fractions/index.d.ts +0 -6
- package/dist/fractions/index.d.ts.map +0 -1
- package/dist/fractions/percent.d.ts +0 -22
- package/dist/fractions/percent.d.ts.map +0 -1
- package/dist/fractions/price.d.ts +0 -49
- package/dist/fractions/price.d.ts.map +0 -1
- package/dist/fractions/unifiedCurrencyAmount.d.ts +0 -32
- package/dist/fractions/unifiedCurrencyAmount.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.test.d.ts +0 -2
- package/dist/index.test.d.ts.map +0 -1
- package/dist/nativeCurrency.d.ts +0 -11
- package/dist/nativeCurrency.d.ts.map +0 -1
- package/dist/splNativeCurrency.d.ts +0 -11
- package/dist/splNativeCurrency.d.ts.map +0 -1
- package/dist/splToken.d.ts +0 -43
- package/dist/splToken.d.ts.map +0 -1
- package/dist/token.d.ts +0 -40
- package/dist/token.d.ts.map +0 -1
- package/dist/utils.d.ts +0 -22
- package/dist/utils.d.ts.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,366 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
type BigintIsh = bigint | number | string;
|
|
2
|
+
declare enum TradeType {
|
|
3
|
+
EXACT_INPUT = 0,
|
|
4
|
+
EXACT_OUTPUT = 1
|
|
5
|
+
}
|
|
6
|
+
declare enum Rounding {
|
|
7
|
+
ROUND_DOWN = 0,
|
|
8
|
+
ROUND_HALF_UP = 1,
|
|
9
|
+
ROUND_UP = 2
|
|
10
|
+
}
|
|
11
|
+
declare const MINIMUM_LIQUIDITY = 1000n;
|
|
12
|
+
declare const ZERO = 0n;
|
|
13
|
+
declare const ONE = 1n;
|
|
14
|
+
declare const TWO = 2n;
|
|
15
|
+
declare const THREE = 3n;
|
|
16
|
+
declare const FIVE = 5n;
|
|
17
|
+
declare const TEN = 10n;
|
|
18
|
+
declare const _100 = 100n;
|
|
19
|
+
declare const _9975 = 9975n;
|
|
20
|
+
declare const _10000 = 10000n;
|
|
21
|
+
declare const MaxUint256: bigint;
|
|
22
|
+
declare enum VMType {
|
|
23
|
+
uint8 = "uint8",
|
|
24
|
+
uint256 = "uint256"
|
|
25
|
+
}
|
|
26
|
+
declare const VM_TYPE_MAXIMA: {
|
|
27
|
+
uint8: bigint;
|
|
28
|
+
uint256: bigint;
|
|
29
|
+
};
|
|
30
|
+
declare const ZERO_ADDRESS: "0x0000000000000000000000000000000000000000";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies
|
|
34
|
+
*/
|
|
35
|
+
declare abstract class BaseCurrency<T extends BaseCurrency<any> = BaseCurrency<any>> {
|
|
36
|
+
/**
|
|
37
|
+
* Returns whether the currency is native to the chain and must be wrapped (e.g. Ether)
|
|
38
|
+
*/
|
|
39
|
+
abstract readonly isNative: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Returns whether the currency is a token that is usable in PancakeSwap without wrapping
|
|
42
|
+
*/
|
|
43
|
+
abstract readonly isToken: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The chain ID on which this currency resides
|
|
46
|
+
*/
|
|
47
|
+
readonly chainId: number;
|
|
48
|
+
/**
|
|
49
|
+
* The decimals used in representing currency amounts
|
|
50
|
+
*/
|
|
51
|
+
readonly decimals: number;
|
|
52
|
+
/**
|
|
53
|
+
* The symbol of the currency, i.e. a short textual non-unique identifier
|
|
54
|
+
*/
|
|
55
|
+
readonly symbol: string;
|
|
56
|
+
/**
|
|
57
|
+
* The name of the currency, i.e. a descriptive textual non-unique identifier
|
|
58
|
+
*/
|
|
59
|
+
readonly name?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Constructs an instance of the base class `BaseCurrency`.
|
|
62
|
+
* @param chainId the chain ID on which this currency resides
|
|
63
|
+
* @param decimals decimals of the currency
|
|
64
|
+
* @param symbol symbol of the currency
|
|
65
|
+
* @param name of the currency
|
|
66
|
+
*/
|
|
67
|
+
protected constructor(chainId: number, decimals: number, symbol: string, name?: string);
|
|
68
|
+
/**
|
|
69
|
+
* Returns whether this currency is functionally equivalent to the other currency
|
|
70
|
+
* @param other the other currency
|
|
71
|
+
*/
|
|
72
|
+
abstract equals(other: BaseCurrency<any>): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Return the wrapped version of this currency that can be used with the PancakeSwap contracts. Currencies must
|
|
75
|
+
* implement this to be used in PancakeSwap
|
|
76
|
+
*/
|
|
77
|
+
abstract get wrapped(): T;
|
|
78
|
+
get asToken(): T;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
interface SerializedToken {
|
|
82
|
+
chainId: number;
|
|
83
|
+
address: `0x${string}`;
|
|
84
|
+
decimals: number;
|
|
85
|
+
symbol: string;
|
|
86
|
+
name?: string;
|
|
87
|
+
projectLink?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Represents an ERC20 token with a unique address and some metadata.
|
|
91
|
+
*/
|
|
92
|
+
declare class Token extends BaseCurrency<Token> {
|
|
93
|
+
readonly isNative: false;
|
|
94
|
+
readonly isToken: true;
|
|
95
|
+
/**
|
|
96
|
+
* The contract address on the chain on which this token lives
|
|
97
|
+
*/
|
|
98
|
+
readonly address: `0x${string}`;
|
|
99
|
+
readonly projectLink?: string;
|
|
100
|
+
constructor(chainId: number, address: `0x${string}`, decimals: number, symbol: string, name?: string, projectLink?: string);
|
|
101
|
+
/**
|
|
102
|
+
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
|
103
|
+
* @param other other token to compare
|
|
104
|
+
*/
|
|
105
|
+
equals(other: BaseCurrency): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Returns true if the address of this token sorts before the address of the other token
|
|
108
|
+
* @param other other token to compare
|
|
109
|
+
* @throws if the tokens have the same address
|
|
110
|
+
* @throws if the tokens are on different chains
|
|
111
|
+
*/
|
|
112
|
+
sortsBefore(other: Token): boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Return this token, which does not need to be wrapped
|
|
115
|
+
*/
|
|
116
|
+
get wrapped(): Token;
|
|
117
|
+
get serialize(): SerializedToken;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Represents the native currency of the chain on which it resides, e.g.
|
|
122
|
+
*/
|
|
123
|
+
declare abstract class NativeCurrency extends BaseCurrency<Token> {
|
|
124
|
+
readonly isNative: true;
|
|
125
|
+
readonly isToken: false;
|
|
126
|
+
get asToken(): Token;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface SerializedSPLToken {
|
|
130
|
+
chainId: number;
|
|
131
|
+
address: string;
|
|
132
|
+
programId: string;
|
|
133
|
+
decimals: number;
|
|
134
|
+
symbol: string;
|
|
135
|
+
name?: string;
|
|
136
|
+
projectLink?: string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Represents an SPL token on Solana or other non-EVM chains.
|
|
140
|
+
*/
|
|
141
|
+
declare class SPLToken extends BaseCurrency<SPLToken> {
|
|
142
|
+
readonly isNative: false;
|
|
143
|
+
readonly isToken: true;
|
|
144
|
+
readonly address: string;
|
|
145
|
+
readonly programId: string;
|
|
146
|
+
readonly logoURI: string;
|
|
147
|
+
readonly projectLink?: string;
|
|
148
|
+
static isSPLToken(token?: UnifiedCurrency): boolean;
|
|
149
|
+
constructor({ chainId, programId, address, decimals, symbol, logoURI, name, projectLink, }: {
|
|
150
|
+
chainId: number;
|
|
151
|
+
programId: string;
|
|
152
|
+
address: string;
|
|
153
|
+
decimals: number;
|
|
154
|
+
symbol: string;
|
|
155
|
+
logoURI: string;
|
|
156
|
+
name?: string;
|
|
157
|
+
projectLink?: string;
|
|
158
|
+
isNative?: boolean;
|
|
159
|
+
});
|
|
160
|
+
/**
|
|
161
|
+
* Returns true if the two tokens are equivalent, i.e. have the same chainId and programId.
|
|
162
|
+
* @param other other token to compare
|
|
163
|
+
*/
|
|
164
|
+
equals(other: BaseCurrency): boolean;
|
|
165
|
+
sortsBefore(other: SPLToken): boolean;
|
|
166
|
+
get wrapped(): SPLToken;
|
|
167
|
+
get serialize(): SerializedSPLToken;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Represents the native currency of the chain on which it resides, e.g.
|
|
172
|
+
*/
|
|
173
|
+
declare abstract class SPLNativeCurrency extends BaseCurrency<SPLToken> {
|
|
174
|
+
readonly isNative: true;
|
|
175
|
+
readonly isToken: false;
|
|
176
|
+
readonly address: string;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
type Currency = NativeCurrency | Token;
|
|
180
|
+
type UnifiedNativeCurrency = NativeCurrency | SPLNativeCurrency;
|
|
181
|
+
type UnifiedCurrency = SPLToken | SPLNativeCurrency | Currency;
|
|
182
|
+
type UnifiedToken = SPLToken | Token;
|
|
183
|
+
|
|
184
|
+
declare class Fraction {
|
|
185
|
+
readonly numerator: bigint;
|
|
186
|
+
readonly denominator: bigint;
|
|
187
|
+
constructor(numerator: BigintIsh, denominator?: BigintIsh);
|
|
188
|
+
private static tryParseFraction;
|
|
189
|
+
get quotient(): bigint;
|
|
190
|
+
get remainder(): Fraction;
|
|
191
|
+
invert(): Fraction;
|
|
192
|
+
add(other: Fraction | BigintIsh): Fraction;
|
|
193
|
+
subtract(other: Fraction | BigintIsh): Fraction;
|
|
194
|
+
lessThan(other: Fraction | BigintIsh): boolean;
|
|
195
|
+
equalTo(other: Fraction | BigintIsh): boolean;
|
|
196
|
+
greaterThan(other: Fraction | BigintIsh): boolean;
|
|
197
|
+
multiply(other: Fraction | BigintIsh): Fraction;
|
|
198
|
+
divide(other: Fraction | BigintIsh): Fraction;
|
|
199
|
+
toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
|
|
200
|
+
toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
|
|
201
|
+
/**
|
|
202
|
+
* Helper method for converting any super class back to a fraction
|
|
203
|
+
*/
|
|
204
|
+
get asFraction(): Fraction;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Converts a fraction to a percent
|
|
209
|
+
* @param fraction the fraction to convert
|
|
210
|
+
*/
|
|
211
|
+
declare function toPercent(fraction: Fraction): Percent;
|
|
212
|
+
declare class Percent extends Fraction {
|
|
213
|
+
/**
|
|
214
|
+
* This boolean prevents a fraction from being interpreted as a Percent
|
|
215
|
+
*/
|
|
216
|
+
readonly isPercent: true;
|
|
217
|
+
static toPercent: typeof toPercent;
|
|
218
|
+
add(other: Fraction | BigintIsh): Percent;
|
|
219
|
+
subtract(other: Fraction | BigintIsh): Percent;
|
|
220
|
+
multiply(other: Fraction | BigintIsh): Percent;
|
|
221
|
+
divide(other: Fraction | BigintIsh): Percent;
|
|
222
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
223
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
declare class CurrencyAmount<T extends Currency> extends Fraction {
|
|
227
|
+
readonly currency: T;
|
|
228
|
+
readonly decimalScale: bigint;
|
|
229
|
+
/**
|
|
230
|
+
* Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
|
|
231
|
+
* @param currency the currency in the amount
|
|
232
|
+
* @param rawAmount the raw token or ether amount
|
|
233
|
+
*/
|
|
234
|
+
static fromRawAmount<T extends Currency>(currency: T, rawAmount: BigintIsh): CurrencyAmount<T>;
|
|
235
|
+
/**
|
|
236
|
+
* Construct a currency amount with a denominator that is not equal to 1
|
|
237
|
+
* @param currency the currency
|
|
238
|
+
* @param numerator the numerator of the fractional token amount
|
|
239
|
+
* @param denominator the denominator of the fractional token amount
|
|
240
|
+
*/
|
|
241
|
+
static fromFractionalAmount<T extends Currency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): CurrencyAmount<T>;
|
|
242
|
+
protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
|
|
243
|
+
add(other: CurrencyAmount<T>): CurrencyAmount<T>;
|
|
244
|
+
subtract(value: bigint): CurrencyAmount<T>;
|
|
245
|
+
subtract(other: CurrencyAmount<T>): CurrencyAmount<T>;
|
|
246
|
+
multiply(other: Fraction | BigintIsh): CurrencyAmount<T>;
|
|
247
|
+
divide(other: Fraction | BigintIsh): CurrencyAmount<T>;
|
|
248
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
249
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
250
|
+
toExact(format?: object): string;
|
|
251
|
+
get wrapped(): CurrencyAmount<Token>;
|
|
252
|
+
info(): string;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
declare class UnifiedCurrencyAmount<T extends UnifiedCurrency> extends Fraction {
|
|
256
|
+
readonly currency: T;
|
|
257
|
+
readonly decimalScale: bigint;
|
|
258
|
+
/**
|
|
259
|
+
* Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
|
|
260
|
+
* @param currency the currency in the amount
|
|
261
|
+
* @param rawAmount the raw token or ether amount
|
|
262
|
+
*/
|
|
263
|
+
static fromRawAmount<T extends UnifiedCurrency>(currency: T, rawAmount: BigintIsh): UnifiedCurrencyAmount<T>;
|
|
264
|
+
/**
|
|
265
|
+
* Construct a currency amount with a denominator that is not equal to 1
|
|
266
|
+
* @param currency the currency
|
|
267
|
+
* @param numerator the numerator of the fractional token amount
|
|
268
|
+
* @param denominator the denominator of the fractional token amount
|
|
269
|
+
*/
|
|
270
|
+
static fromFractionalAmount<T extends UnifiedCurrency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): UnifiedCurrencyAmount<T>;
|
|
271
|
+
protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
|
|
272
|
+
add(other: UnifiedCurrencyAmount<T>): UnifiedCurrencyAmount<T>;
|
|
273
|
+
subtract(value: bigint): UnifiedCurrencyAmount<T>;
|
|
274
|
+
subtract(other: UnifiedCurrencyAmount<T>): UnifiedCurrencyAmount<T>;
|
|
275
|
+
multiply(other: Fraction | BigintIsh): UnifiedCurrencyAmount<T>;
|
|
276
|
+
divide(other: Fraction | BigintIsh): UnifiedCurrencyAmount<T>;
|
|
277
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
278
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
279
|
+
toExact(format?: object): string;
|
|
280
|
+
get wrapped(): UnifiedCurrencyAmount<UnifiedToken>;
|
|
281
|
+
info(): string;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
declare class Price<TBase extends UnifiedCurrency, TQuote extends UnifiedCurrency> extends Fraction {
|
|
285
|
+
readonly baseCurrency: TBase;
|
|
286
|
+
readonly quoteCurrency: TQuote;
|
|
287
|
+
readonly scalar: Fraction;
|
|
288
|
+
/**
|
|
289
|
+
* Construct a price, either with the base and quote currency amount, or the
|
|
290
|
+
* @param args
|
|
291
|
+
*/
|
|
292
|
+
constructor(...args: [TBase, TQuote, BigintIsh, BigintIsh] | [{
|
|
293
|
+
baseAmount: UnifiedCurrencyAmount<TBase>;
|
|
294
|
+
quoteAmount: UnifiedCurrencyAmount<TQuote>;
|
|
295
|
+
}]);
|
|
296
|
+
/**
|
|
297
|
+
* Flip the price, switching the base and quote currency
|
|
298
|
+
*/
|
|
299
|
+
invert(): Price<TQuote, TBase>;
|
|
300
|
+
/**
|
|
301
|
+
* 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
|
|
302
|
+
* @param other the other price
|
|
303
|
+
*/
|
|
304
|
+
multiply<TOtherQuote extends UnifiedCurrency>(other: Price<TQuote, TOtherQuote>): Price<TBase, TOtherQuote>;
|
|
305
|
+
/**
|
|
306
|
+
* Return the amount of quote currency corresponding to a given amount of the base currency
|
|
307
|
+
* @param currencyAmount the amount of base currency to quote against the price
|
|
308
|
+
*/
|
|
309
|
+
quote(currencyAmount: UnifiedCurrencyAmount<TBase>): UnifiedCurrencyAmount<TQuote>;
|
|
310
|
+
/**
|
|
311
|
+
* Get the value scaled by decimals for formatting
|
|
312
|
+
* @private
|
|
313
|
+
*/
|
|
314
|
+
private get adjustedForDecimals();
|
|
315
|
+
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
316
|
+
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
317
|
+
get wrapped(): Price<TBase['wrapped'], TQuote['wrapped']>;
|
|
318
|
+
/**
|
|
319
|
+
* Create a price from base and quote currency and a decimal string
|
|
320
|
+
* @param base
|
|
321
|
+
* @param quote
|
|
322
|
+
* @param value
|
|
323
|
+
* @returns Price<TBase, TQuote> | undefined
|
|
324
|
+
*/
|
|
325
|
+
static fromDecimal<TBase extends UnifiedCurrency, TQuote extends UnifiedCurrency>(base: TBase, quote: TQuote, value: string): Price<TBase, TQuote> | undefined;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Indicates that the pair has insufficient reserves for a desired output amount. I.e. the amount of output cannot be
|
|
330
|
+
* obtained by sending any amount of input.
|
|
331
|
+
*/
|
|
332
|
+
declare class InsufficientReservesError extends Error {
|
|
333
|
+
readonly isInsufficientReservesError: true;
|
|
334
|
+
constructor();
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Indicates that the input amount is too small to produce any amount of output. I.e. the amount of input sent is less
|
|
338
|
+
* than the price of a single unit of output after fees.
|
|
339
|
+
*/
|
|
340
|
+
declare class InsufficientInputAmountError extends Error {
|
|
341
|
+
readonly isInsufficientInputAmountError: true;
|
|
342
|
+
constructor();
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
declare function validateVMTypeInstance(value: bigint, vmType: VMType): void;
|
|
346
|
+
declare function sqrt(y: bigint): bigint;
|
|
347
|
+
declare function sortedInsert<T>(items: T[], add: T, maxSize: number, comparator: (a: T, b: T) => number): T | null;
|
|
348
|
+
/**
|
|
349
|
+
* Returns the percent difference between the mid price and the execution price, i.e. price impact.
|
|
350
|
+
* @param midPrice mid price before the trade
|
|
351
|
+
* @param inputAmount the input amount of the trade
|
|
352
|
+
* @param outputAmount the output amount of the trade
|
|
353
|
+
*/
|
|
354
|
+
declare function computePriceImpact<TBase extends Currency, TQuote extends Currency>(midPrice: Price<TBase, TQuote>, inputAmount: CurrencyAmount<TBase>, outputAmount: CurrencyAmount<TQuote>): Percent;
|
|
355
|
+
declare function getTokenComparator(balances: {
|
|
356
|
+
[tokenAddress: string]: CurrencyAmount<Token> | undefined;
|
|
357
|
+
}): (tokenA: Token, tokenB: Token) => number;
|
|
358
|
+
declare function sortCurrencies<T extends Currency>(currencies: T[]): T[];
|
|
359
|
+
declare function sortUnifiedCurrencies<T extends UnifiedCurrency>(currencies: T[]): T[];
|
|
360
|
+
declare const isCurrencySorted: (currencyA: Currency, currencyB: Currency) => boolean;
|
|
361
|
+
declare const isUnifiedCurrencySorted: (currencyA: UnifiedCurrency, currencyB: UnifiedCurrency) => boolean;
|
|
362
|
+
declare function getCurrencyAddress(currency: Currency): `0x${string}`;
|
|
363
|
+
declare function getUnifiedCurrencyAddress(currency: UnifiedCurrency): string;
|
|
364
|
+
declare function getMatchedCurrency(currency: Currency, list: Currency[], matchWrappedCurrency?: boolean): Currency | undefined;
|
|
365
|
+
|
|
366
|
+
export { BaseCurrency, BigintIsh, Currency, CurrencyAmount, FIVE, Fraction, InsufficientInputAmountError, InsufficientReservesError, MINIMUM_LIQUIDITY, MaxUint256, NativeCurrency, ONE, Percent, Price, Rounding, SPLNativeCurrency, SPLToken, SerializedSPLToken, SerializedToken, TEN, THREE, TWO, Token, TradeType, UnifiedCurrency, UnifiedCurrencyAmount, UnifiedNativeCurrency, UnifiedToken, VMType, VM_TYPE_MAXIMA, ZERO, ZERO_ADDRESS, _100, _10000, _9975, computePriceImpact, getCurrencyAddress, getMatchedCurrency, getTokenComparator, getUnifiedCurrencyAddress, isCurrencySorted, isUnifiedCurrencySorted, sortCurrencies, sortUnifiedCurrencies, sortedInsert, sqrt, validateVMTypeInstance };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ var invariant8 = require('tiny-invariant');
|
|
|
4
4
|
var _Decimal = require('decimal.js-light');
|
|
5
5
|
var _Big = require('big.js');
|
|
6
6
|
var toFormat = require('toformat');
|
|
7
|
+
var web3_js = require('@solana/web3.js');
|
|
8
|
+
var BN = require('bn.js');
|
|
7
9
|
|
|
8
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
11
|
|
|
@@ -11,6 +13,7 @@ var invariant8__default = /*#__PURE__*/_interopDefault(invariant8);
|
|
|
11
13
|
var _Decimal__default = /*#__PURE__*/_interopDefault(_Decimal);
|
|
12
14
|
var _Big__default = /*#__PURE__*/_interopDefault(_Big);
|
|
13
15
|
var toFormat__default = /*#__PURE__*/_interopDefault(toFormat);
|
|
16
|
+
var BN__default = /*#__PURE__*/_interopDefault(BN);
|
|
14
17
|
|
|
15
18
|
// src/constants.ts
|
|
16
19
|
var TradeType = /* @__PURE__ */ ((TradeType2) => {
|
|
@@ -383,7 +386,7 @@ var Price = class extends Fraction {
|
|
|
383
386
|
quote(currencyAmount) {
|
|
384
387
|
invariant8__default.default(currencyAmount.currency.equals(this.baseCurrency), "TOKEN");
|
|
385
388
|
const result = super.multiply(currencyAmount);
|
|
386
|
-
return
|
|
389
|
+
return UnifiedCurrencyAmount.fromFractionalAmount(this.quoteCurrency, result.numerator, result.denominator);
|
|
387
390
|
}
|
|
388
391
|
/**
|
|
389
392
|
* Get the value scaled by decimals for formatting
|
|
@@ -520,9 +523,8 @@ var SPLToken = class extends BaseCurrency {
|
|
|
520
523
|
return this.chainId === other.chainId && this.address === other.address;
|
|
521
524
|
}
|
|
522
525
|
sortsBefore(other) {
|
|
523
|
-
invariant8__default.default(this.chainId === other.chainId, "
|
|
524
|
-
|
|
525
|
-
return this.programId.toLowerCase() < other.programId.toLowerCase();
|
|
526
|
+
invariant8__default.default(this.chainId === other.chainId, "CHAIN_IDS_MUST_MATCH");
|
|
527
|
+
return new BN__default.default(new web3_js.PublicKey(this.address).toBuffer()).lt(new BN__default.default(new web3_js.PublicKey(other.address).toBuffer()));
|
|
526
528
|
}
|
|
527
529
|
/* For compatibility */
|
|
528
530
|
get wrapped() {
|
|
@@ -646,16 +648,46 @@ function sortCurrencies(currencies) {
|
|
|
646
648
|
return a.sortsBefore(b) ? -1 : 1;
|
|
647
649
|
});
|
|
648
650
|
}
|
|
651
|
+
function sortUnifiedCurrencies(currencies) {
|
|
652
|
+
return currencies.sort((a, b) => {
|
|
653
|
+
if (a instanceof SPLToken && a.chainId === b.chainId) {
|
|
654
|
+
return a.sortsBefore(b.wrapped) ? -1 : 1;
|
|
655
|
+
}
|
|
656
|
+
if (b instanceof SPLToken && a.chainId === b.chainId) {
|
|
657
|
+
return b.sortsBefore(a.wrapped) ? 1 : -1;
|
|
658
|
+
}
|
|
659
|
+
if (a.isNative) {
|
|
660
|
+
return -1;
|
|
661
|
+
}
|
|
662
|
+
if (b.isNative) {
|
|
663
|
+
return 1;
|
|
664
|
+
}
|
|
665
|
+
if (a instanceof Token && b instanceof Token) {
|
|
666
|
+
return a.sortsBefore(b) ? -1 : 1;
|
|
667
|
+
}
|
|
668
|
+
return 0;
|
|
669
|
+
});
|
|
670
|
+
}
|
|
649
671
|
var isCurrencySorted = (currencyA, currencyB) => {
|
|
650
672
|
const [currency0] = sortCurrencies([currencyA, currencyB]);
|
|
651
673
|
return currency0 === currencyA;
|
|
652
674
|
};
|
|
675
|
+
var isUnifiedCurrencySorted = (currencyA, currencyB) => {
|
|
676
|
+
const [currency0] = sortUnifiedCurrencies([currencyA, currencyB]);
|
|
677
|
+
return currency0 === currencyA;
|
|
678
|
+
};
|
|
653
679
|
function getCurrencyAddress(currency) {
|
|
654
680
|
if (currency.isNative) {
|
|
655
681
|
return ZERO_ADDRESS;
|
|
656
682
|
}
|
|
657
683
|
return currency.address;
|
|
658
684
|
}
|
|
685
|
+
function getUnifiedCurrencyAddress(currency) {
|
|
686
|
+
if (currency.isNative) {
|
|
687
|
+
return currency instanceof SPLNativeCurrency ? currency.address : ZERO_ADDRESS;
|
|
688
|
+
}
|
|
689
|
+
return currency.address;
|
|
690
|
+
}
|
|
659
691
|
function getMatchedCurrency(currency, list, matchWrappedCurrency = true) {
|
|
660
692
|
const c = matchWrappedCurrency ? currency.wrapped : currency;
|
|
661
693
|
for (const current of list) {
|
|
@@ -699,8 +731,11 @@ exports.computePriceImpact = computePriceImpact;
|
|
|
699
731
|
exports.getCurrencyAddress = getCurrencyAddress;
|
|
700
732
|
exports.getMatchedCurrency = getMatchedCurrency;
|
|
701
733
|
exports.getTokenComparator = getTokenComparator;
|
|
734
|
+
exports.getUnifiedCurrencyAddress = getUnifiedCurrencyAddress;
|
|
702
735
|
exports.isCurrencySorted = isCurrencySorted;
|
|
736
|
+
exports.isUnifiedCurrencySorted = isUnifiedCurrencySorted;
|
|
703
737
|
exports.sortCurrencies = sortCurrencies;
|
|
738
|
+
exports.sortUnifiedCurrencies = sortUnifiedCurrencies;
|
|
704
739
|
exports.sortedInsert = sortedInsert;
|
|
705
740
|
exports.sqrt = sqrt;
|
|
706
741
|
exports.validateVMTypeInstance = validateVMTypeInstance;
|
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import invariant8 from 'tiny-invariant';
|
|
|
2
2
|
import _Decimal from 'decimal.js-light';
|
|
3
3
|
import _Big from 'big.js';
|
|
4
4
|
import toFormat from 'toformat';
|
|
5
|
+
import { PublicKey } from '@solana/web3.js';
|
|
6
|
+
import BN from 'bn.js';
|
|
5
7
|
|
|
6
8
|
// src/constants.ts
|
|
7
9
|
var TradeType = /* @__PURE__ */ ((TradeType2) => {
|
|
@@ -374,7 +376,7 @@ var Price = class extends Fraction {
|
|
|
374
376
|
quote(currencyAmount) {
|
|
375
377
|
invariant8(currencyAmount.currency.equals(this.baseCurrency), "TOKEN");
|
|
376
378
|
const result = super.multiply(currencyAmount);
|
|
377
|
-
return
|
|
379
|
+
return UnifiedCurrencyAmount.fromFractionalAmount(this.quoteCurrency, result.numerator, result.denominator);
|
|
378
380
|
}
|
|
379
381
|
/**
|
|
380
382
|
* Get the value scaled by decimals for formatting
|
|
@@ -511,9 +513,8 @@ var SPLToken = class extends BaseCurrency {
|
|
|
511
513
|
return this.chainId === other.chainId && this.address === other.address;
|
|
512
514
|
}
|
|
513
515
|
sortsBefore(other) {
|
|
514
|
-
invariant8(this.chainId === other.chainId, "
|
|
515
|
-
|
|
516
|
-
return this.programId.toLowerCase() < other.programId.toLowerCase();
|
|
516
|
+
invariant8(this.chainId === other.chainId, "CHAIN_IDS_MUST_MATCH");
|
|
517
|
+
return new BN(new PublicKey(this.address).toBuffer()).lt(new BN(new PublicKey(other.address).toBuffer()));
|
|
517
518
|
}
|
|
518
519
|
/* For compatibility */
|
|
519
520
|
get wrapped() {
|
|
@@ -637,16 +638,46 @@ function sortCurrencies(currencies) {
|
|
|
637
638
|
return a.sortsBefore(b) ? -1 : 1;
|
|
638
639
|
});
|
|
639
640
|
}
|
|
641
|
+
function sortUnifiedCurrencies(currencies) {
|
|
642
|
+
return currencies.sort((a, b) => {
|
|
643
|
+
if (a instanceof SPLToken && a.chainId === b.chainId) {
|
|
644
|
+
return a.sortsBefore(b.wrapped) ? -1 : 1;
|
|
645
|
+
}
|
|
646
|
+
if (b instanceof SPLToken && a.chainId === b.chainId) {
|
|
647
|
+
return b.sortsBefore(a.wrapped) ? 1 : -1;
|
|
648
|
+
}
|
|
649
|
+
if (a.isNative) {
|
|
650
|
+
return -1;
|
|
651
|
+
}
|
|
652
|
+
if (b.isNative) {
|
|
653
|
+
return 1;
|
|
654
|
+
}
|
|
655
|
+
if (a instanceof Token && b instanceof Token) {
|
|
656
|
+
return a.sortsBefore(b) ? -1 : 1;
|
|
657
|
+
}
|
|
658
|
+
return 0;
|
|
659
|
+
});
|
|
660
|
+
}
|
|
640
661
|
var isCurrencySorted = (currencyA, currencyB) => {
|
|
641
662
|
const [currency0] = sortCurrencies([currencyA, currencyB]);
|
|
642
663
|
return currency0 === currencyA;
|
|
643
664
|
};
|
|
665
|
+
var isUnifiedCurrencySorted = (currencyA, currencyB) => {
|
|
666
|
+
const [currency0] = sortUnifiedCurrencies([currencyA, currencyB]);
|
|
667
|
+
return currency0 === currencyA;
|
|
668
|
+
};
|
|
644
669
|
function getCurrencyAddress(currency) {
|
|
645
670
|
if (currency.isNative) {
|
|
646
671
|
return ZERO_ADDRESS;
|
|
647
672
|
}
|
|
648
673
|
return currency.address;
|
|
649
674
|
}
|
|
675
|
+
function getUnifiedCurrencyAddress(currency) {
|
|
676
|
+
if (currency.isNative) {
|
|
677
|
+
return currency instanceof SPLNativeCurrency ? currency.address : ZERO_ADDRESS;
|
|
678
|
+
}
|
|
679
|
+
return currency.address;
|
|
680
|
+
}
|
|
650
681
|
function getMatchedCurrency(currency, list, matchWrappedCurrency = true) {
|
|
651
682
|
const c = matchWrappedCurrency ? currency.wrapped : currency;
|
|
652
683
|
for (const current of list) {
|
|
@@ -658,4 +689,4 @@ function getMatchedCurrency(currency, list, matchWrappedCurrency = true) {
|
|
|
658
689
|
return void 0;
|
|
659
690
|
}
|
|
660
691
|
|
|
661
|
-
export { BaseCurrency, CurrencyAmount, FIVE, Fraction, InsufficientInputAmountError, InsufficientReservesError, MINIMUM_LIQUIDITY, MaxUint256, NativeCurrency, ONE, Percent, Price, Rounding, SPLNativeCurrency, SPLToken, TEN, THREE, TWO, Token, TradeType, UnifiedCurrencyAmount, VMType, VM_TYPE_MAXIMA, ZERO, ZERO_ADDRESS, _100, _10000, _9975, computePriceImpact, getCurrencyAddress, getMatchedCurrency, getTokenComparator, isCurrencySorted, sortCurrencies, sortedInsert, sqrt, validateVMTypeInstance };
|
|
692
|
+
export { BaseCurrency, CurrencyAmount, FIVE, Fraction, InsufficientInputAmountError, InsufficientReservesError, MINIMUM_LIQUIDITY, MaxUint256, NativeCurrency, ONE, Percent, Price, Rounding, SPLNativeCurrency, SPLToken, TEN, THREE, TWO, Token, TradeType, UnifiedCurrencyAmount, VMType, VM_TYPE_MAXIMA, ZERO, ZERO_ADDRESS, _100, _10000, _9975, computePriceImpact, getCurrencyAddress, getMatchedCurrency, getTokenComparator, getUnifiedCurrencyAddress, isCurrencySorted, isUnifiedCurrencySorted, sortCurrencies, sortUnifiedCurrencies, sortedInsert, sqrt, validateVMTypeInstance };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pancakeswap/swap-sdk-core",
|
|
3
3
|
"license": "MIT",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"description": "🛠 An SDK for building applications on top of Pancakeswap.",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"typings": "dist/index.d.ts",
|
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
"pancakeswap"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@solana/web3.js": "1.98.4",
|
|
29
30
|
"big.js": "^5.2.2",
|
|
31
|
+
"bn.js": "5.2.1",
|
|
30
32
|
"decimal.js-light": "^2.5.0",
|
|
31
33
|
"tiny-invariant": "^1.3.0",
|
|
32
34
|
"tiny-warning": "^1.0.3",
|
|
@@ -35,6 +37,7 @@
|
|
|
35
37
|
"peerDependencies": {},
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@types/big.js": "^4.0.5",
|
|
40
|
+
"@types/bn.js": "5.2.0",
|
|
38
41
|
"tsup": "^6.7.0"
|
|
39
42
|
},
|
|
40
43
|
"engines": {
|
package/dist/baseCurrency.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A currency is any fungible financial instrument, including Ether, all ERC20 tokens, and other chain-native currencies
|
|
3
|
-
*/
|
|
4
|
-
export declare abstract class BaseCurrency<T extends BaseCurrency<any> = BaseCurrency<any>> {
|
|
5
|
-
/**
|
|
6
|
-
* Returns whether the currency is native to the chain and must be wrapped (e.g. Ether)
|
|
7
|
-
*/
|
|
8
|
-
abstract readonly isNative: boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Returns whether the currency is a token that is usable in PancakeSwap without wrapping
|
|
11
|
-
*/
|
|
12
|
-
abstract readonly isToken: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* The chain ID on which this currency resides
|
|
15
|
-
*/
|
|
16
|
-
readonly chainId: number;
|
|
17
|
-
/**
|
|
18
|
-
* The decimals used in representing currency amounts
|
|
19
|
-
*/
|
|
20
|
-
readonly decimals: number;
|
|
21
|
-
/**
|
|
22
|
-
* The symbol of the currency, i.e. a short textual non-unique identifier
|
|
23
|
-
*/
|
|
24
|
-
readonly symbol: string;
|
|
25
|
-
/**
|
|
26
|
-
* The name of the currency, i.e. a descriptive textual non-unique identifier
|
|
27
|
-
*/
|
|
28
|
-
readonly name?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Constructs an instance of the base class `BaseCurrency`.
|
|
31
|
-
* @param chainId the chain ID on which this currency resides
|
|
32
|
-
* @param decimals decimals of the currency
|
|
33
|
-
* @param symbol symbol of the currency
|
|
34
|
-
* @param name of the currency
|
|
35
|
-
*/
|
|
36
|
-
protected constructor(chainId: number, decimals: number, symbol: string, name?: string);
|
|
37
|
-
/**
|
|
38
|
-
* Returns whether this currency is functionally equivalent to the other currency
|
|
39
|
-
* @param other the other currency
|
|
40
|
-
*/
|
|
41
|
-
abstract equals(other: BaseCurrency<any>): boolean;
|
|
42
|
-
/**
|
|
43
|
-
* Return the wrapped version of this currency that can be used with the PancakeSwap contracts. Currencies must
|
|
44
|
-
* implement this to be used in PancakeSwap
|
|
45
|
-
*/
|
|
46
|
-
abstract get wrapped(): T;
|
|
47
|
-
get asToken(): T;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=baseCurrency.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"baseCurrency.d.ts","sourceRoot":"","sources":["../src/baseCurrency.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,8BAAsB,YAAY,CAAC,CAAC,SAAS,YAAY,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC;IAChF;;OAEG;IACH,kBAAyB,QAAQ,EAAE,OAAO,CAAA;IAE1C;;OAEG;IACH,kBAAyB,OAAO,EAAE,OAAO,CAAA;IAEzC;;OAEG;IACH,SAAgB,OAAO,EAAE,MAAM,CAAA;IAE/B;;OAEG;IACH,SAAgB,QAAQ,EAAE,MAAM,CAAA;IAEhC;;OAEG;IACH,SAAgB,MAAM,EAAE,MAAM,CAAA;IAE9B;;OAEG;IACH,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAA;IAE7B;;;;;;OAMG;IACH,SAAS,aAAa,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;IAWtF;;;OAGG;aACa,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,OAAO;IAEzD;;;OAGG;IACH,aAAoB,OAAO,IAAI,CAAC,CAAA;IAEhC,IAAW,OAAO,IAAI,CAAC,CAEtB;CACF"}
|
package/dist/constants.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type BigintIsh = bigint | number | string;
|
|
2
|
-
export declare enum TradeType {
|
|
3
|
-
EXACT_INPUT = 0,
|
|
4
|
-
EXACT_OUTPUT = 1
|
|
5
|
-
}
|
|
6
|
-
export declare enum Rounding {
|
|
7
|
-
ROUND_DOWN = 0,
|
|
8
|
-
ROUND_HALF_UP = 1,
|
|
9
|
-
ROUND_UP = 2
|
|
10
|
-
}
|
|
11
|
-
export declare const MINIMUM_LIQUIDITY = 1000n;
|
|
12
|
-
export declare const ZERO = 0n;
|
|
13
|
-
export declare const ONE = 1n;
|
|
14
|
-
export declare const TWO = 2n;
|
|
15
|
-
export declare const THREE = 3n;
|
|
16
|
-
export declare const FIVE = 5n;
|
|
17
|
-
export declare const TEN = 10n;
|
|
18
|
-
export declare const _100 = 100n;
|
|
19
|
-
export declare const _9975 = 9975n;
|
|
20
|
-
export declare const _10000 = 10000n;
|
|
21
|
-
export declare const MaxUint256: bigint;
|
|
22
|
-
export declare enum VMType {
|
|
23
|
-
uint8 = "uint8",
|
|
24
|
-
uint256 = "uint256"
|
|
25
|
-
}
|
|
26
|
-
export declare const VM_TYPE_MAXIMA: {
|
|
27
|
-
uint8: bigint;
|
|
28
|
-
uint256: bigint;
|
|
29
|
-
};
|
|
30
|
-
export declare const ZERO_ADDRESS: "0x0000000000000000000000000000000000000000";
|
|
31
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAA;AAEhD,oBAAY,SAAS;IACnB,WAAW,IAAA;IACX,YAAY,IAAA;CACb;AAED,oBAAY,QAAQ;IAClB,UAAU,IAAA;IACV,aAAa,IAAA;IACb,QAAQ,IAAA;CACT;AAED,eAAO,MAAM,iBAAiB,QAAQ,CAAA;AAGtC,eAAO,MAAM,IAAI,KAAK,CAAA;AACtB,eAAO,MAAM,GAAG,KAAK,CAAA;AACrB,eAAO,MAAM,GAAG,KAAK,CAAA;AACrB,eAAO,MAAM,KAAK,KAAK,CAAA;AACvB,eAAO,MAAM,IAAI,KAAK,CAAA;AACtB,eAAO,MAAM,GAAG,MAAM,CAAA;AACtB,eAAO,MAAM,IAAI,OAAO,CAAA;AACxB,eAAO,MAAM,KAAK,QAAQ,CAAA;AAC1B,eAAO,MAAM,MAAM,SAAS,CAAA;AAE5B,eAAO,MAAM,UAAU,QAA+E,CAAA;AAEtG,oBAAY,MAAM;IAChB,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED,eAAO,MAAM,cAAc;;;CAG1B,CAAA;AAED,eAAO,MAAM,YAAY,EAAG,4CAAqD,CAAA"}
|
package/dist/currency.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { NativeCurrency } from './nativeCurrency';
|
|
2
|
-
import { SPLNativeCurrency } from './splNativeCurrency';
|
|
3
|
-
import { SPLToken } from './splToken';
|
|
4
|
-
import type { Token } from './token';
|
|
5
|
-
export type Currency = NativeCurrency | Token;
|
|
6
|
-
export type UnifiedNativeCurrency = NativeCurrency | SPLNativeCurrency;
|
|
7
|
-
export type UnifiedCurrency = SPLToken | SPLNativeCurrency | Currency;
|
|
8
|
-
export type UnifiedToken = SPLToken | Token;
|
|
9
|
-
//# sourceMappingURL=currency.d.ts.map
|
package/dist/currency.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../src/currency.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,KAAK,CAAA;AAE7C,MAAM,MAAM,qBAAqB,GAAG,cAAc,GAAG,iBAAiB,CAAA;AACtE,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,iBAAiB,GAAG,QAAQ,CAAA;AACrE,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,KAAK,CAAA"}
|
package/dist/errors.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
17
|
-
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,SAAgB,2BAA2B,EAAG,IAAI,CAAS;;CAO5D;AAED;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,SAAgB,8BAA8B,EAAG,IAAI,CAAS;;CAO/D"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Currency } from '../currency';
|
|
2
|
-
import { Token } from '../token';
|
|
3
|
-
import { Fraction } from './fraction';
|
|
4
|
-
import { BigintIsh, Rounding } from '../constants';
|
|
5
|
-
export declare class CurrencyAmount<T extends Currency> extends Fraction {
|
|
6
|
-
readonly currency: T;
|
|
7
|
-
readonly decimalScale: bigint;
|
|
8
|
-
/**
|
|
9
|
-
* Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
|
|
10
|
-
* @param currency the currency in the amount
|
|
11
|
-
* @param rawAmount the raw token or ether amount
|
|
12
|
-
*/
|
|
13
|
-
static fromRawAmount<T extends Currency>(currency: T, rawAmount: BigintIsh): CurrencyAmount<T>;
|
|
14
|
-
/**
|
|
15
|
-
* Construct a currency amount with a denominator that is not equal to 1
|
|
16
|
-
* @param currency the currency
|
|
17
|
-
* @param numerator the numerator of the fractional token amount
|
|
18
|
-
* @param denominator the denominator of the fractional token amount
|
|
19
|
-
*/
|
|
20
|
-
static fromFractionalAmount<T extends Currency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): CurrencyAmount<T>;
|
|
21
|
-
protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
|
|
22
|
-
add(other: CurrencyAmount<T>): CurrencyAmount<T>;
|
|
23
|
-
subtract(value: bigint): CurrencyAmount<T>;
|
|
24
|
-
subtract(other: CurrencyAmount<T>): CurrencyAmount<T>;
|
|
25
|
-
multiply(other: Fraction | BigintIsh): CurrencyAmount<T>;
|
|
26
|
-
divide(other: Fraction | BigintIsh): CurrencyAmount<T>;
|
|
27
|
-
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
28
|
-
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
29
|
-
toExact(format?: object): string;
|
|
30
|
-
get wrapped(): CurrencyAmount<Token>;
|
|
31
|
-
info(): string;
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=currencyAmount.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,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BAAiB,SAAI,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,QAA8B,GAAG,MAAM;IAIvG,OAAO,CACZ,aAAa,GAAE,MAA+B,EAC9C,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,GAAE,QAA8B,GACvC,MAAM;IAKF,OAAO,CAAC,MAAM,GAAE,MAA+B,GAAG,MAAM;IAK/D,IAAW,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,CAG1C;IAEM,IAAI;CAGZ"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BigintIsh, Rounding } from '../constants';
|
|
2
|
-
export declare class Fraction {
|
|
3
|
-
readonly numerator: bigint;
|
|
4
|
-
readonly denominator: bigint;
|
|
5
|
-
constructor(numerator: BigintIsh, denominator?: BigintIsh);
|
|
6
|
-
private static tryParseFraction;
|
|
7
|
-
get quotient(): bigint;
|
|
8
|
-
get remainder(): Fraction;
|
|
9
|
-
invert(): Fraction;
|
|
10
|
-
add(other: Fraction | BigintIsh): Fraction;
|
|
11
|
-
subtract(other: Fraction | BigintIsh): Fraction;
|
|
12
|
-
lessThan(other: Fraction | BigintIsh): boolean;
|
|
13
|
-
equalTo(other: Fraction | BigintIsh): boolean;
|
|
14
|
-
greaterThan(other: Fraction | BigintIsh): boolean;
|
|
15
|
-
multiply(other: Fraction | BigintIsh): Fraction;
|
|
16
|
-
divide(other: Fraction | BigintIsh): Fraction;
|
|
17
|
-
toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
|
|
18
|
-
toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
|
|
19
|
-
/**
|
|
20
|
-
* Helper method for converting any super class back to a fraction
|
|
21
|
-
*/
|
|
22
|
-
get asFraction(): Fraction;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=fraction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fraction.d.ts","sourceRoot":"","sources":["../../src/fractions/fraction.ts"],"names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Ac,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,SAAS,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BigintIsh, Rounding } from '../constants';
|
|
2
|
-
import { Fraction } from './fraction';
|
|
3
|
-
/**
|
|
4
|
-
* Converts a fraction to a percent
|
|
5
|
-
* @param fraction the fraction to convert
|
|
6
|
-
*/
|
|
7
|
-
declare function toPercent(fraction: Fraction): Percent;
|
|
8
|
-
export declare class Percent extends Fraction {
|
|
9
|
-
/**
|
|
10
|
-
* This boolean prevents a fraction from being interpreted as a Percent
|
|
11
|
-
*/
|
|
12
|
-
readonly isPercent: true;
|
|
13
|
-
static toPercent: typeof toPercent;
|
|
14
|
-
add(other: Fraction | BigintIsh): Percent;
|
|
15
|
-
subtract(other: Fraction | BigintIsh): Percent;
|
|
16
|
-
multiply(other: Fraction | BigintIsh): Percent;
|
|
17
|
-
divide(other: Fraction | BigintIsh): Percent;
|
|
18
|
-
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
19
|
-
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
20
|
-
}
|
|
21
|
-
export {};
|
|
22
|
-
//# sourceMappingURL=percent.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"percent.d.ts","sourceRoot":"","sources":["../../src/fractions/percent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAIrC;;;GAGG;AACH,iBAAS,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAE9C;AAED,qBAAa,OAAQ,SAAQ,QAAQ;IACnC;;OAEG;IACH,SAAgB,SAAS,EAAG,IAAI,CAAS;IAEzC,MAAM,CAAC,SAAS,mBAAY;IAE5B,GAAG,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO;IAIzC,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO;IAI9C,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO;IAI9C,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO;IAIrC,aAAa,CAAC,iBAAiB,SAAI,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;IAIlF,OAAO,CAAC,aAAa,SAAI,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM;CAGhF"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { BigintIsh, Rounding } from '../constants';
|
|
2
|
-
import { Currency } from '../currency';
|
|
3
|
-
import { Token } from '../token';
|
|
4
|
-
import { CurrencyAmount } from './currencyAmount';
|
|
5
|
-
import { Fraction } from './fraction';
|
|
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
|
-
get wrapped(): Price<Token, Token>;
|
|
40
|
-
/**
|
|
41
|
-
* Create a price from base and quote currency and a decimal string
|
|
42
|
-
* @param base
|
|
43
|
-
* @param quote
|
|
44
|
-
* @param value
|
|
45
|
-
* @returns Price<TBase, TQuote> | undefined
|
|
46
|
-
*/
|
|
47
|
-
static fromDecimal<TBase extends Currency, TQuote extends Currency>(base: TBase, quote: TQuote, value: string): Price<TBase, TQuote> | undefined;
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=price.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../src/fractions/price.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,qBAAa,KAAK,CAAC,KAAK,SAAS,QAAQ,EAAE,MAAM,SAAS,QAAQ,CAAE,SAAQ,QAAQ;IAClF,SAAgB,YAAY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../currency';
|
|
2
|
-
import { Fraction } from './fraction';
|
|
3
|
-
import { BigintIsh, Rounding } from '../constants';
|
|
4
|
-
export declare class UnifiedCurrencyAmount<T extends UnifiedCurrency> extends Fraction {
|
|
5
|
-
readonly currency: T;
|
|
6
|
-
readonly decimalScale: bigint;
|
|
7
|
-
/**
|
|
8
|
-
* Returns a new currency amount instance from the unitless amount of token, i.e. the raw amount
|
|
9
|
-
* @param currency the currency in the amount
|
|
10
|
-
* @param rawAmount the raw token or ether amount
|
|
11
|
-
*/
|
|
12
|
-
static fromRawAmount<T extends UnifiedCurrency>(currency: T, rawAmount: BigintIsh): UnifiedCurrencyAmount<T>;
|
|
13
|
-
/**
|
|
14
|
-
* Construct a currency amount with a denominator that is not equal to 1
|
|
15
|
-
* @param currency the currency
|
|
16
|
-
* @param numerator the numerator of the fractional token amount
|
|
17
|
-
* @param denominator the denominator of the fractional token amount
|
|
18
|
-
*/
|
|
19
|
-
static fromFractionalAmount<T extends UnifiedCurrency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): UnifiedCurrencyAmount<T>;
|
|
20
|
-
protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
|
|
21
|
-
add(other: UnifiedCurrencyAmount<T>): UnifiedCurrencyAmount<T>;
|
|
22
|
-
subtract(value: bigint): UnifiedCurrencyAmount<T>;
|
|
23
|
-
subtract(other: UnifiedCurrencyAmount<T>): UnifiedCurrencyAmount<T>;
|
|
24
|
-
multiply(other: Fraction | BigintIsh): UnifiedCurrencyAmount<T>;
|
|
25
|
-
divide(other: Fraction | BigintIsh): UnifiedCurrencyAmount<T>;
|
|
26
|
-
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
27
|
-
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
28
|
-
toExact(format?: object): string;
|
|
29
|
-
get wrapped(): UnifiedCurrencyAmount<UnifiedToken>;
|
|
30
|
-
info(): string;
|
|
31
|
-
}
|
|
32
|
-
//# sourceM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QAAQ,GAAG,SAAS,GAAG,qBAAqB,CAAC,CAAC,CAAC;IAK7D,aAAa,CAAC,iBAAiB,SAAI,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,GAAE,QAA8B,GAAG,MAAM;IAIvG,OAAO,CACZ,aAAa,GAAE,MAA+B,EAC9C,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,GAAE,QAA8B,GACvC,MAAM;IAKF,OAAO,CAAC,MAAM,GAAE,MAA+B,GAAG,MAAM;IAK/D,IAAW,OAAO,IAAI,qBAAqB,CAAC,YAAY,CAAC,CAGxD;IAEM,IAAI;CAGZ"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA"}
|
package/dist/index.test.d.ts
DELETED
package/dist/index.test.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
|
package/dist/nativeCurrency.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseCurrency } from './baseCurrency';
|
|
2
|
-
import { Token } from './token';
|
|
3
|
-
/**
|
|
4
|
-
* Represents the native currency of the chain on which it resides, e.g.
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class NativeCurrency extends BaseCurrency<Token> {
|
|
7
|
-
readonly isNative: true;
|
|
8
|
-
readonly isToken: false;
|
|
9
|
-
get asToken(): Token;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=nativeCurrency.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nativeCurrency.d.ts","sourceRoot":"","sources":["../src/nativeCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B;;GAEG;AACH,8BAAsB,cAAe,SAAQ,YAAY,CAAC,KAAK,CAAC;IAC9D,SAAgB,QAAQ,EAAG,IAAI,CAAS;IAExC,SAAgB,OAAO,EAAG,KAAK,CAAS;IAExC,IAAoB,OAAO,IAAI,KAAK,CAEnC;CACF"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BaseCurrency } from './baseCurrency';
|
|
2
|
-
import { SPLToken } from './splToken';
|
|
3
|
-
/**
|
|
4
|
-
* Represents the native currency of the chain on which it resides, e.g.
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class SPLNativeCurrency extends BaseCurrency<SPLToken> {
|
|
7
|
-
readonly isNative: true;
|
|
8
|
-
readonly isToken: false;
|
|
9
|
-
readonly address: string;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=splNativeCurrency.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"splNativeCurrency.d.ts","sourceRoot":"","sources":["../src/splNativeCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC;;GAEG;AACH,8BAAsB,iBAAkB,SAAQ,YAAY,CAAC,QAAQ,CAAC;IACpE,SAAgB,QAAQ,EAAG,IAAI,CAAS;IAExC,SAAgB,OAAO,EAAG,KAAK,CAAS;IAExC,SAAgB,OAAO,EAAE,MAAM,CAAK;CACrC"}
|
package/dist/splToken.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { BaseCurrency } from './baseCurrency';
|
|
2
|
-
import { type UnifiedCurrency } from './currency';
|
|
3
|
-
export interface SerializedSPLToken {
|
|
4
|
-
chainId: number;
|
|
5
|
-
address: string;
|
|
6
|
-
programId: string;
|
|
7
|
-
decimals: number;
|
|
8
|
-
symbol: string;
|
|
9
|
-
name?: string;
|
|
10
|
-
projectLink?: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Represents an SPL token on Solana or other non-EVM chains.
|
|
14
|
-
*/
|
|
15
|
-
export declare class SPLToken extends BaseCurrency<SPLToken> {
|
|
16
|
-
readonly isNative: false;
|
|
17
|
-
readonly isToken: true;
|
|
18
|
-
readonly address: string;
|
|
19
|
-
readonly programId: string;
|
|
20
|
-
readonly logoURI: string;
|
|
21
|
-
readonly projectLink?: string;
|
|
22
|
-
static isSPLToken(token?: UnifiedCurrency): boolean;
|
|
23
|
-
constructor({ chainId, programId, address, decimals, symbol, logoURI, name, projectLink, }: {
|
|
24
|
-
chainId: number;
|
|
25
|
-
programId: string;
|
|
26
|
-
address: string;
|
|
27
|
-
decimals: number;
|
|
28
|
-
symbol: string;
|
|
29
|
-
logoURI: string;
|
|
30
|
-
name?: string;
|
|
31
|
-
projectLink?: string;
|
|
32
|
-
isNative?: boolean;
|
|
33
|
-
});
|
|
34
|
-
/**
|
|
35
|
-
* Returns true if the two tokens are equivalent, i.e. have the same chainId and programId.
|
|
36
|
-
* @param other other token to compare
|
|
37
|
-
*/
|
|
38
|
-
equals(other: BaseCurrency): boolean;
|
|
39
|
-
sortsBefore(other: SPLToken): boolean;
|
|
40
|
-
get wrapped(): SPLToken;
|
|
41
|
-
get serialize(): SerializedSPLToken;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=splToken.d.ts.map
|
package/dist/splToken.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"splToken.d.ts","sourceRoot":"","sources":["../src/splToken.ts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AO5C,IAAW,OAAO,IAAI,QAAQ,CAE7B;IAED,IAAW,SAAS,IAAI,kBAAkB,CAUzC;CACF"}
|
package/dist/token.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { BaseCurrency } from './baseCurrency';
|
|
2
|
-
export interface SerializedToken {
|
|
3
|
-
chainId: number;
|
|
4
|
-
address: `0x${string}`;
|
|
5
|
-
decimals: number;
|
|
6
|
-
symbol: string;
|
|
7
|
-
name?: string;
|
|
8
|
-
projectLink?: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Represents an ERC20 token with a unique address and some metadata.
|
|
12
|
-
*/
|
|
13
|
-
export declare class Token extends BaseCurrency<Token> {
|
|
14
|
-
readonly isNative: false;
|
|
15
|
-
readonly isToken: true;
|
|
16
|
-
/**
|
|
17
|
-
* The contract address on the chain on which this token lives
|
|
18
|
-
*/
|
|
19
|
-
readonly address: `0x${string}`;
|
|
20
|
-
readonly projectLink?: string;
|
|
21
|
-
constructor(chainId: number, address: `0x${string}`, decimals: number, symbol: string, name?: string, projectLink?: string);
|
|
22
|
-
/**
|
|
23
|
-
* Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
|
|
24
|
-
* @param other other token to compare
|
|
25
|
-
*/
|
|
26
|
-
equals(other: BaseCurrency): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Returns true if the address of this token sorts before the address of the other token
|
|
29
|
-
* @param other other token to compare
|
|
30
|
-
* @throws if the tokens have the same address
|
|
31
|
-
* @throws if the tokens are on different chains
|
|
32
|
-
*/
|
|
33
|
-
sortsBefore(other: Token): boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Return this token, which does not need to be wrapped
|
|
36
|
-
*/
|
|
37
|
-
get wrapped(): Token;
|
|
38
|
-
get serialize(): SerializedToken;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=token.d.ts.map
|
package/dist/token.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;GAEG;AACH,qBAAa,KAAM,SAAQ,YAAY,CAAC,KAAK,CAAC;IAC5C,SAAgB,QAAQ,EAAE,KAAK,CAAiB;IAEhD,SAAgB,OAAO,EAAE,IAAI,CAAgB;IAE7C;;OAEG;IACH,SAAgB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IAEtC,SAAgB,WAAW,CAAC,EAAE,MAAM,CAAA;gBAGlC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,KAAK,MAAM,EAAE,EACtB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,MAAM;IAOtB;;;OAGG;IACI,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO;IAI3C;;;;;OAKG;IACI,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAMzC;;OAEG;IACH,IAAW,OAAO,IAAI,KAAK,CAE1B;IAED,IAAW,SAAS,IAAI,eAAe,CAStC;CACF"}
|
package/dist/utils.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { VMType } from './constants';
|
|
2
|
-
import { Currency } from './currency';
|
|
3
|
-
import { CurrencyAmount, Percent, Price } from './fractions';
|
|
4
|
-
import { Token } from './token';
|
|
5
|
-
export declare function validateVMTypeInstance(value: bigint, vmType: VMType): void;
|
|
6
|
-
export declare function sqrt(y: bigint): bigint;
|
|
7
|
-
export declare function sortedInsert<T>(items: T[], add: T, maxSize: number, comparator: (a: T, b: T) => number): T | null;
|
|
8
|
-
/**
|
|
9
|
-
* Returns the percent difference between the mid price and the execution price, i.e. price impact.
|
|
10
|
-
* @param midPrice mid price before the trade
|
|
11
|
-
* @param inputAmount the input amount of the trade
|
|
12
|
-
* @param outputAmount the output amount of the trade
|
|
13
|
-
*/
|
|
14
|
-
export declare function computePriceImpact<TBase extends Currency, TQuote extends Currency>(midPrice: Price<TBase, TQuote>, inputAmount: CurrencyAmount<TBase>, outputAmount: CurrencyAmount<TQuote>): Percent;
|
|
15
|
-
export declare function getTokenComparator(balances: {
|
|
16
|
-
[tokenAddress: string]: CurrencyAmount<Token> | undefined;
|
|
17
|
-
}): (tokenA: Token, tokenB: Token) => number;
|
|
18
|
-
export declare function sortCurrencies<T extends Currency>(currencies: T[]): T[];
|
|
19
|
-
export declare const isCurrencySorted: (currencyA: Currency, currencyB: Currency) => boolean;
|
|
20
|
-
export declare function getCurrencyAddress(currency: Currency): `0x${string}`;
|
|
21
|
-
export declare function getMatchedCurrency(currency: Currency, list: Currency[], matchWrappedCurrency?: boolean): Currency | undefined;
|
|
22
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,MAAM,EAAsC,MAAM,aAAa,CAAA;AACzF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE/B,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAG1E;AAGD,wBAAgB,IAAI,CAAC,CAAC,EA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