@pancakeswap/swap-sdk-core 1.1.0 → 1.3.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/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/fractions/price.d.ts +2 -0
- package/dist/fractions/price.d.ts.map +1 -1
- package/dist/index.js +24 -0
- package/dist/index.mjs +22 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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"}
|
|
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,8CAAwD,CAAA"}
|
|
@@ -2,6 +2,7 @@ import { BigintIsh, Rounding } from '../constants';
|
|
|
2
2
|
import { Currency } from '../currency';
|
|
3
3
|
import { Fraction } from './fraction';
|
|
4
4
|
import { CurrencyAmount } from './currencyAmount';
|
|
5
|
+
import { Token } from '../token';
|
|
5
6
|
export declare class Price<TBase extends Currency, TQuote extends Currency> extends Fraction {
|
|
6
7
|
readonly baseCurrency: TBase;
|
|
7
8
|
readonly quoteCurrency: TQuote;
|
|
@@ -35,5 +36,6 @@ export declare class Price<TBase extends Currency, TQuote extends Currency> exte
|
|
|
35
36
|
private get adjustedForDecimals();
|
|
36
37
|
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
37
38
|
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
39
|
+
get wrapped(): Price<Token, Token>;
|
|
38
40
|
}
|
|
39
41
|
//# 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;
|
|
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;;;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;CACF"}
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,7 @@ var VM_TYPE_MAXIMA = {
|
|
|
44
44
|
["uint8" /* uint8 */]: BigInt("0xff"),
|
|
45
45
|
["uint256" /* uint256 */]: BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
|
46
46
|
};
|
|
47
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
47
48
|
var BaseCurrency = class {
|
|
48
49
|
/**
|
|
49
50
|
* Constructs an instance of the base class `BaseCurrency`.
|
|
@@ -315,6 +316,9 @@ var Price = class extends Fraction {
|
|
|
315
316
|
toFixed(decimalPlaces = 4, format, rounding) {
|
|
316
317
|
return this.adjustedForDecimals.toFixed(decimalPlaces, format, rounding);
|
|
317
318
|
}
|
|
319
|
+
get wrapped() {
|
|
320
|
+
return new Price(this.baseCurrency.wrapped, this.quoteCurrency.wrapped, this.denominator, this.numerator);
|
|
321
|
+
}
|
|
318
322
|
};
|
|
319
323
|
|
|
320
324
|
// src/nativeCurrency.ts
|
|
@@ -463,6 +467,23 @@ function getTokenComparator(balances) {
|
|
|
463
467
|
return tokenA.symbol ? -1 : tokenB.symbol ? -1 : 0;
|
|
464
468
|
};
|
|
465
469
|
}
|
|
470
|
+
function sortCurrencies(currencies) {
|
|
471
|
+
return currencies.sort((a, b) => {
|
|
472
|
+
if (a.isNative) {
|
|
473
|
+
return -1;
|
|
474
|
+
}
|
|
475
|
+
if (b.isNative) {
|
|
476
|
+
return 1;
|
|
477
|
+
}
|
|
478
|
+
return a.sortsBefore(b) ? -1 : 1;
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function getCurrencyAddress(currency) {
|
|
482
|
+
if (currency.isNative) {
|
|
483
|
+
return ZERO_ADDRESS;
|
|
484
|
+
}
|
|
485
|
+
return currency.address;
|
|
486
|
+
}
|
|
466
487
|
|
|
467
488
|
exports.BaseCurrency = BaseCurrency;
|
|
468
489
|
exports.CurrencyAmount = CurrencyAmount;
|
|
@@ -485,11 +506,14 @@ exports.TradeType = TradeType;
|
|
|
485
506
|
exports.VMType = VMType;
|
|
486
507
|
exports.VM_TYPE_MAXIMA = VM_TYPE_MAXIMA;
|
|
487
508
|
exports.ZERO = ZERO;
|
|
509
|
+
exports.ZERO_ADDRESS = ZERO_ADDRESS;
|
|
488
510
|
exports._100 = _100;
|
|
489
511
|
exports._10000 = _10000;
|
|
490
512
|
exports._9975 = _9975;
|
|
491
513
|
exports.computePriceImpact = computePriceImpact;
|
|
514
|
+
exports.getCurrencyAddress = getCurrencyAddress;
|
|
492
515
|
exports.getTokenComparator = getTokenComparator;
|
|
516
|
+
exports.sortCurrencies = sortCurrencies;
|
|
493
517
|
exports.sortedInsert = sortedInsert;
|
|
494
518
|
exports.sqrt = sqrt;
|
|
495
519
|
exports.validateVMTypeInstance = validateVMTypeInstance;
|
package/dist/index.mjs
CHANGED
|
@@ -35,6 +35,7 @@ var VM_TYPE_MAXIMA = {
|
|
|
35
35
|
["uint8" /* uint8 */]: BigInt("0xff"),
|
|
36
36
|
["uint256" /* uint256 */]: BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
|
|
37
37
|
};
|
|
38
|
+
var ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
38
39
|
var BaseCurrency = class {
|
|
39
40
|
/**
|
|
40
41
|
* Constructs an instance of the base class `BaseCurrency`.
|
|
@@ -306,6 +307,9 @@ var Price = class extends Fraction {
|
|
|
306
307
|
toFixed(decimalPlaces = 4, format, rounding) {
|
|
307
308
|
return this.adjustedForDecimals.toFixed(decimalPlaces, format, rounding);
|
|
308
309
|
}
|
|
310
|
+
get wrapped() {
|
|
311
|
+
return new Price(this.baseCurrency.wrapped, this.quoteCurrency.wrapped, this.denominator, this.numerator);
|
|
312
|
+
}
|
|
309
313
|
};
|
|
310
314
|
|
|
311
315
|
// src/nativeCurrency.ts
|
|
@@ -454,5 +458,22 @@ function getTokenComparator(balances) {
|
|
|
454
458
|
return tokenA.symbol ? -1 : tokenB.symbol ? -1 : 0;
|
|
455
459
|
};
|
|
456
460
|
}
|
|
461
|
+
function sortCurrencies(currencies) {
|
|
462
|
+
return currencies.sort((a, b) => {
|
|
463
|
+
if (a.isNative) {
|
|
464
|
+
return -1;
|
|
465
|
+
}
|
|
466
|
+
if (b.isNative) {
|
|
467
|
+
return 1;
|
|
468
|
+
}
|
|
469
|
+
return a.sortsBefore(b) ? -1 : 1;
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
function getCurrencyAddress(currency) {
|
|
473
|
+
if (currency.isNative) {
|
|
474
|
+
return ZERO_ADDRESS;
|
|
475
|
+
}
|
|
476
|
+
return currency.address;
|
|
477
|
+
}
|
|
457
478
|
|
|
458
|
-
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, _100, _10000, _9975, computePriceImpact, getTokenComparator, sortedInsert, sqrt, validateVMTypeInstance };
|
|
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 };
|
package/dist/utils.d.ts
CHANGED
|
@@ -15,4 +15,6 @@ export declare function computePriceImpact<TBase extends Currency, TQuote extend
|
|
|
15
15
|
export declare function getTokenComparator(balances: {
|
|
16
16
|
[tokenAddress: string]: CurrencyAmount<Token> | undefined;
|
|
17
17
|
}): (tokenA: Token, tokenB: Token) => number;
|
|
18
|
+
export declare function sortCurrencies<T extends Currency>(currencies: T[]): T[];
|
|
19
|
+
export declare function getCurrencyAddress(currency: Currency): `0x${string}`;
|
|
18
20
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
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,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,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,iBAKpD"}
|
package/package.json
CHANGED