@pancakeswap/swap-sdk-core 1.3.0 → 1.4.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.
@@ -46,5 +46,6 @@ export declare abstract class BaseCurrency {
46
46
  * implement this to be used in PancakeSwap
47
47
  */
48
48
  abstract get wrapped(): Token;
49
+ get asToken(): Token;
49
50
  }
50
51
  //# sourceMappingURL=baseCurrency.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"baseCurrency.d.ts","sourceRoot":"","sources":["../src/baseCurrency.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC;;GAEG;AACH,8BAAsB,YAAY;IAChC;;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;IAUtF;;;OAGG;aACa,MAAM,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO;IAEhD;;;OAGG;IACH,aAAoB,OAAO,IAAI,KAAK,CAAA;CACrC"}
1
+ {"version":3,"file":"baseCurrency.d.ts","sourceRoot":"","sources":["../src/baseCurrency.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,KAAK,EAAE,KAAK,EAA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AAA;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,8CAAwD,CAAA"}
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"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,SAAgB,2BAA2B,OAAgB;;CAO5D;AAED;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,SAAgB,8BAA8B,OAAgB;;CAO/D"}
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"}
@@ -20,6 +20,7 @@ export declare class CurrencyAmount<T extends Currency> extends Fraction {
20
20
  static fromFractionalAmount<T extends Currency>(currency: T, numerator: BigintIsh, denominator: BigintIsh): CurrencyAmount<T>;
21
21
  protected constructor(currency: T, numerator: BigintIsh, denominator?: BigintIsh);
22
22
  add(other: CurrencyAmount<T>): CurrencyAmount<T>;
23
+ subtract(value: bigint): CurrencyAmount<T>;
23
24
  subtract(other: CurrencyAmount<T>): CurrencyAmount<T>;
24
25
  multiply(other: Fraction | BigintIsh): CurrencyAmount<T>;
25
26
  divide(other: Fraction | BigintIsh): CurrencyAmount<T>;
@@ -27,5 +28,6 @@ export declare class CurrencyAmount<T extends Currency> extends Fraction {
27
28
  toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
28
29
  toExact(format?: object): string;
29
30
  get wrapped(): CurrencyAmount<Token>;
31
+ info(): string;
30
32
  }
31
33
  //# sourceMappingURL=currencyAmount.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"currencyAmount.d.ts","sourceRoot":"","sources":["../../src/fractions/currencyAmount.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAErC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAA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AAE,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 +1 @@
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,OAAgB;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
+ {"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,8 +1,8 @@
1
1
  import { BigintIsh, Rounding } from '../constants';
2
2
  import { Currency } from '../currency';
3
- import { Fraction } from './fraction';
4
- import { CurrencyAmount } from './currencyAmount';
5
3
  import { Token } from '../token';
4
+ import { CurrencyAmount } from './currencyAmount';
5
+ import { Fraction } from './fraction';
6
6
  export declare class Price<TBase extends Currency, TQuote extends Currency> extends Fraction {
7
7
  readonly baseCurrency: TBase;
8
8
  readonly quoteCurrency: TQuote;
@@ -37,5 +37,13 @@ export declare class Price<TBase extends Currency, TQuote extends Currency> exte
37
37
  toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
38
38
  toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
39
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;
40
48
  }
41
49
  //# sourceMappingURL=price.d.ts.map
@@ -1 +1 @@
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,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAA;AAEhC,qBAAa,KAAK,CAAC,KAAK,SAAS,QAAQ,EAAE,MAAM,SAAS,QAAQ,CAAE,SAAQ,QAAQ;IAClF,SAAgB,YAAY,EAAE,KAAK,CAAA;IAEnC,SAAgB,aAAa,EAAE,MAAM,CAAA;IAErC,SAAgB,MAAM,EAAE,QAAQ,CAAA;IAEhC;;;OAGG;gBAED,GAAG,IAAI,EACH,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,CAAC,GACrC,CAAC;QAAE,UAAU,EAAE,cAAc,CAAC,KAAK,CAAC,CAAC;QAAC,WAAW,EAAE,cAAc,CAAC,MAAM,CAAC,CAAA;KAAE,CAAC;IA0BlF;;OAEG;IACI,MAAM,IAAI,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;IAIrC;;;OAGG;IACI,QAAQ,CAAC,WAAW,SAAS,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC;IAM3G;;;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K,CAAC;IAIrC;;;OAGG;IACI,QAAQ,CAAC,WAAW,SAAS,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,WAAW,CAAC;IAM3G;;;OAGG;IACI,KAAK,CAAC,cAAc,EAAE,cAAc,CAAC,KAAK,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC;IAM3E;;;OAGG;IACH,OAAO,KAAK,mBAAmB,GAE9B;IAEM,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;IAI/E,IAAW,OAAO,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,CAExC;IAED;;;;;;OAMG;WACW,WAAW,CAAC,KAAK,SAAS,QAAQ,EAAE,MAAM,SAAS,QAAQ,EACvE,IAAI,EAAE,KAAK,EACX,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACZ,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS;CAiBpC"}
package/dist/index.js CHANGED
@@ -61,6 +61,9 @@ var BaseCurrency = class {
61
61
  this.symbol = symbol;
62
62
  this.name = name;
63
63
  }
64
+ get asToken() {
65
+ return this.wrapped;
66
+ }
64
67
  };
65
68
  var Decimal = toFormat__default.default(_Decimal__default.default);
66
69
  var Big = toFormat__default.default(_Big__default.default);
@@ -222,9 +225,16 @@ var CurrencyAmount = class extends Fraction {
222
225
  const added = super.add(other);
223
226
  return CurrencyAmount.fromFractionalAmount(this.currency, added.numerator, added.denominator);
224
227
  }
225
- subtract(other) {
226
- invariant6__default.default(this.currency.equals(other.currency), "CURRENCY");
227
- const subtracted = super.subtract(other);
228
+ subtract(value) {
229
+ if (typeof value === "bigint") {
230
+ return CurrencyAmount.fromFractionalAmount(
231
+ this.currency,
232
+ this.numerator - value * this.denominator,
233
+ this.denominator
234
+ );
235
+ }
236
+ invariant6__default.default(this.currency.equals(value.currency), "CURRENCY");
237
+ const subtracted = super.subtract(value);
228
238
  return CurrencyAmount.fromFractionalAmount(this.currency, subtracted.numerator, subtracted.denominator);
229
239
  }
230
240
  multiply(other) {
@@ -251,6 +261,9 @@ var CurrencyAmount = class extends Fraction {
251
261
  return this;
252
262
  return CurrencyAmount.fromFractionalAmount(this.currency.wrapped, this.numerator, this.denominator);
253
263
  }
264
+ info() {
265
+ return `${this.toExact()}${this.currency.symbol}`;
266
+ }
254
267
  };
255
268
  var Price = class extends Fraction {
256
269
  // used to adjust the raw fraction w/r/t the decimals of the {base,quote}Token
@@ -319,14 +332,26 @@ var Price = class extends Fraction {
319
332
  get wrapped() {
320
333
  return new Price(this.baseCurrency.wrapped, this.quoteCurrency.wrapped, this.denominator, this.numerator);
321
334
  }
322
- };
323
-
324
- // src/nativeCurrency.ts
325
- var NativeCurrency = class extends BaseCurrency {
326
- constructor() {
327
- super(...arguments);
328
- this.isNative = true;
329
- this.isToken = false;
335
+ /**
336
+ * Create a price from base and quote currency and a decimal string
337
+ * @param base
338
+ * @param quote
339
+ * @param value
340
+ * @returns Price<TBase, TQuote> | undefined
341
+ */
342
+ static fromDecimal(base, quote, value) {
343
+ if (!value || value.length > 257 || !value.match(/^\d*\.?\d+$/)) {
344
+ return void 0;
345
+ }
346
+ const [whole, fraction] = value.split(".");
347
+ const decimals = fraction?.length ?? 0;
348
+ const withoutDecimals = BigInt((whole ?? "") + (fraction ?? ""));
349
+ return new Price(
350
+ base,
351
+ quote,
352
+ BigInt(10 ** decimals) * BigInt(10 ** base.decimals),
353
+ withoutDecimals * BigInt(10 ** quote.decimals)
354
+ );
330
355
  }
331
356
  };
332
357
  var Token = class extends BaseCurrency {
@@ -373,6 +398,18 @@ var Token = class extends BaseCurrency {
373
398
  }
374
399
  };
375
400
 
401
+ // src/nativeCurrency.ts
402
+ var NativeCurrency = class extends BaseCurrency {
403
+ constructor() {
404
+ super(...arguments);
405
+ this.isNative = true;
406
+ this.isToken = false;
407
+ }
408
+ get asToken() {
409
+ return new Token(this.chainId, ZERO_ADDRESS, this.decimals, this.symbol, this.name);
410
+ }
411
+ };
412
+
376
413
  // src/errors.ts
377
414
  var CAN_SET_PROTOTYPE = "setPrototypeOf" in Object;
378
415
  var InsufficientReservesError = class extends Error {
@@ -478,12 +515,26 @@ function sortCurrencies(currencies) {
478
515
  return a.sortsBefore(b) ? -1 : 1;
479
516
  });
480
517
  }
518
+ var isCurrencySorted = (currencyA, currencyB) => {
519
+ const [currency0] = sortCurrencies([currencyA, currencyB]);
520
+ return currency0 === currencyA;
521
+ };
481
522
  function getCurrencyAddress(currency) {
482
523
  if (currency.isNative) {
483
524
  return ZERO_ADDRESS;
484
525
  }
485
526
  return currency.address;
486
527
  }
528
+ function getMatchedCurrency(currency, list, matchWrappedCurrency = true) {
529
+ const c = matchWrappedCurrency ? currency.wrapped : currency;
530
+ for (const current of list) {
531
+ const checkAgainst = matchWrappedCurrency ? current.wrapped : current;
532
+ if (checkAgainst.equals(c)) {
533
+ return current;
534
+ }
535
+ }
536
+ return void 0;
537
+ }
487
538
 
488
539
  exports.BaseCurrency = BaseCurrency;
489
540
  exports.CurrencyAmount = CurrencyAmount;
@@ -512,7 +563,9 @@ exports._10000 = _10000;
512
563
  exports._9975 = _9975;
513
564
  exports.computePriceImpact = computePriceImpact;
514
565
  exports.getCurrencyAddress = getCurrencyAddress;
566
+ exports.getMatchedCurrency = getMatchedCurrency;
515
567
  exports.getTokenComparator = getTokenComparator;
568
+ exports.isCurrencySorted = isCurrencySorted;
516
569
  exports.sortCurrencies = sortCurrencies;
517
570
  exports.sortedInsert = sortedInsert;
518
571
  exports.sqrt = sqrt;
package/dist/index.mjs CHANGED
@@ -52,6 +52,9 @@ var BaseCurrency = class {
52
52
  this.symbol = symbol;
53
53
  this.name = name;
54
54
  }
55
+ get asToken() {
56
+ return this.wrapped;
57
+ }
55
58
  };
56
59
  var Decimal = toFormat(_Decimal);
57
60
  var Big = toFormat(_Big);
@@ -213,9 +216,16 @@ var CurrencyAmount = class extends Fraction {
213
216
  const added = super.add(other);
214
217
  return CurrencyAmount.fromFractionalAmount(this.currency, added.numerator, added.denominator);
215
218
  }
216
- subtract(other) {
217
- invariant6(this.currency.equals(other.currency), "CURRENCY");
218
- const subtracted = super.subtract(other);
219
+ subtract(value) {
220
+ if (typeof value === "bigint") {
221
+ return CurrencyAmount.fromFractionalAmount(
222
+ this.currency,
223
+ this.numerator - value * this.denominator,
224
+ this.denominator
225
+ );
226
+ }
227
+ invariant6(this.currency.equals(value.currency), "CURRENCY");
228
+ const subtracted = super.subtract(value);
219
229
  return CurrencyAmount.fromFractionalAmount(this.currency, subtracted.numerator, subtracted.denominator);
220
230
  }
221
231
  multiply(other) {
@@ -242,6 +252,9 @@ var CurrencyAmount = class extends Fraction {
242
252
  return this;
243
253
  return CurrencyAmount.fromFractionalAmount(this.currency.wrapped, this.numerator, this.denominator);
244
254
  }
255
+ info() {
256
+ return `${this.toExact()}${this.currency.symbol}`;
257
+ }
245
258
  };
246
259
  var Price = class extends Fraction {
247
260
  // used to adjust the raw fraction w/r/t the decimals of the {base,quote}Token
@@ -310,14 +323,26 @@ var Price = class extends Fraction {
310
323
  get wrapped() {
311
324
  return new Price(this.baseCurrency.wrapped, this.quoteCurrency.wrapped, this.denominator, this.numerator);
312
325
  }
313
- };
314
-
315
- // src/nativeCurrency.ts
316
- var NativeCurrency = class extends BaseCurrency {
317
- constructor() {
318
- super(...arguments);
319
- this.isNative = true;
320
- this.isToken = false;
326
+ /**
327
+ * Create a price from base and quote currency and a decimal string
328
+ * @param base
329
+ * @param quote
330
+ * @param value
331
+ * @returns Price<TBase, TQuote> | undefined
332
+ */
333
+ static fromDecimal(base, quote, value) {
334
+ if (!value || value.length > 257 || !value.match(/^\d*\.?\d+$/)) {
335
+ return void 0;
336
+ }
337
+ const [whole, fraction] = value.split(".");
338
+ const decimals = fraction?.length ?? 0;
339
+ const withoutDecimals = BigInt((whole ?? "") + (fraction ?? ""));
340
+ return new Price(
341
+ base,
342
+ quote,
343
+ BigInt(10 ** decimals) * BigInt(10 ** base.decimals),
344
+ withoutDecimals * BigInt(10 ** quote.decimals)
345
+ );
321
346
  }
322
347
  };
323
348
  var Token = class extends BaseCurrency {
@@ -364,6 +389,18 @@ var Token = class extends BaseCurrency {
364
389
  }
365
390
  };
366
391
 
392
+ // src/nativeCurrency.ts
393
+ var NativeCurrency = class extends BaseCurrency {
394
+ constructor() {
395
+ super(...arguments);
396
+ this.isNative = true;
397
+ this.isToken = false;
398
+ }
399
+ get asToken() {
400
+ return new Token(this.chainId, ZERO_ADDRESS, this.decimals, this.symbol, this.name);
401
+ }
402
+ };
403
+
367
404
  // src/errors.ts
368
405
  var CAN_SET_PROTOTYPE = "setPrototypeOf" in Object;
369
406
  var InsufficientReservesError = class extends Error {
@@ -469,11 +506,25 @@ function sortCurrencies(currencies) {
469
506
  return a.sortsBefore(b) ? -1 : 1;
470
507
  });
471
508
  }
509
+ var isCurrencySorted = (currencyA, currencyB) => {
510
+ const [currency0] = sortCurrencies([currencyA, currencyB]);
511
+ return currency0 === currencyA;
512
+ };
472
513
  function getCurrencyAddress(currency) {
473
514
  if (currency.isNative) {
474
515
  return ZERO_ADDRESS;
475
516
  }
476
517
  return currency.address;
477
518
  }
519
+ function getMatchedCurrency(currency, list, matchWrappedCurrency = true) {
520
+ const c = matchWrappedCurrency ? currency.wrapped : currency;
521
+ for (const current of list) {
522
+ const checkAgainst = matchWrappedCurrency ? current.wrapped : current;
523
+ if (checkAgainst.equals(c)) {
524
+ return current;
525
+ }
526
+ }
527
+ return void 0;
528
+ }
478
529
 
479
- export { BaseCurrency, CurrencyAmount, FIVE, Fraction, InsufficientInputAmountError, InsufficientReservesError, MINIMUM_LIQUIDITY, MaxUint256, NativeCurrency, ONE, Percent, Price, Rounding, TEN, THREE, TWO, Token, TradeType, VMType, VM_TYPE_MAXIMA, ZERO, ZERO_ADDRESS, _100, _10000, _9975, computePriceImpact, getCurrencyAddress, getTokenComparator, sortCurrencies, sortedInsert, sqrt, validateVMTypeInstance };
530
+ export { BaseCurrency, CurrencyAmount, FIVE, Fraction, InsufficientInputAmountError, InsufficientReservesError, MINIMUM_LIQUIDITY, MaxUint256, NativeCurrency, ONE, Percent, Price, Rounding, TEN, THREE, TWO, Token, TradeType, VMType, VM_TYPE_MAXIMA, ZERO, ZERO_ADDRESS, _100, _10000, _9975, computePriceImpact, getCurrencyAddress, getMatchedCurrency, getTokenComparator, isCurrencySorted, sortCurrencies, sortedInsert, sqrt, validateVMTypeInstance };
@@ -1,9 +1,11 @@
1
1
  import { BaseCurrency } from './baseCurrency';
2
+ import { Token } from './token';
2
3
  /**
3
4
  * Represents the native currency of the chain on which it resides, e.g.
4
5
  */
5
6
  export declare abstract class NativeCurrency extends BaseCurrency {
6
7
  readonly isNative: true;
7
8
  readonly isToken: false;
9
+ get asToken(): Token;
8
10
  }
9
11
  //# sourceMappingURL=nativeCurrency.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"nativeCurrency.d.ts","sourceRoot":"","sources":["../src/nativeCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAE7C;;GAEG;AACH,8BAAsB,cAAe,SAAQ,YAAY;IACvD,SAAgB,QAAQ,OAAgB;IAExC,SAAgB,OAAO,QAAiB;CACzC"}
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;IACvD,SAAgB,QAAQ,EAAG,IAAI,CAAS;IAExC,SAAgB,OAAO,EAAG,KAAK,CAAS;IAExC,IAAoB,OAAO,IAAI,KAAK,CAEnC;CACF"}
package/dist/utils.d.ts CHANGED
@@ -16,5 +16,7 @@ export declare function getTokenComparator(balances: {
16
16
  [tokenAddress: string]: CurrencyAmount<Token> | undefined;
17
17
  }): (tokenA: Token, tokenB: Token) => number;
18
18
  export declare function sortCurrencies<T extends Currency>(currencies: T[]): T[];
19
+ export declare const isCurrencySorted: (currencyA: Currency, currencyB: Currency) => boolean;
19
20
  export declare function getCurrencyAddress(currency: Currency): `0x${string}`;
21
+ export declare function getMatchedCurrency(currency: Currency, list: Currency[], matchWrappedCurrency?: boolean): Currency | undefined;
20
22
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
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,EAAE,MAAM,GAAG,MAAM,CAgBtC;AAKD,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,MAAM,GAAG,CAAC,GAAG,IAAI,CA8BjH;AAGD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAS,QAAQ,EAAE,MAAM,SAAS,QAAQ,EAChF,QAAQ,EAAE,KAAK,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MAAM,SAAS,QAAQ,EAChF,QAAQ,EAAE,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,EAC9B,WAAW,EAAE,cAAc,CAAC,KAAK,CAAC,EAClC,YAAY,EAAE,cAAc,CAAC,MAAM,CAAC,GACnC,OAAO,CAKT;AAgBD,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE;IAC3C,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;CAC1D,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,KAAK,MAAM,CAkB3C;AAED,wBAAgB,cAAc,CAAC,CAAC,SAAS,QAAQ,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAUvE;AAED,eAAO,MAAM,gBAAgB,cAAe,QAAQ,aAAa,QAAQ,KAAG,OAG3E,CAAA;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,iBAKpD;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,QAAQ,EAAE,EAChB,oBAAoB,UAAO,GAC1B,QAAQ,GAAG,SAAS,CAStB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pancakeswap/swap-sdk-core",
3
3
  "license": "MIT",
4
- "version": "1.3.0",
4
+ "version": "1.4.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",