@pancakeswap/swap-sdk-core 1.0.1 → 1.2.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/fractions/percent.d.ts +7 -0
- package/dist/fractions/percent.d.ts.map +1 -1
- package/dist/index.js +13 -0
- package/dist/index.mjs +13 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { BigintIsh, Rounding } from '../constants';
|
|
2
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;
|
|
3
8
|
export declare class Percent extends Fraction {
|
|
4
9
|
/**
|
|
5
10
|
* This boolean prevents a fraction from being interpreted as a Percent
|
|
6
11
|
*/
|
|
7
12
|
readonly isPercent: true;
|
|
13
|
+
static toPercent: typeof toPercent;
|
|
8
14
|
add(other: Fraction | BigintIsh): Percent;
|
|
9
15
|
subtract(other: Fraction | BigintIsh): Percent;
|
|
10
16
|
multiply(other: Fraction | BigintIsh): Percent;
|
|
@@ -12,4 +18,5 @@ export declare class Percent extends Fraction {
|
|
|
12
18
|
toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
|
|
13
19
|
toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
|
|
14
20
|
}
|
|
21
|
+
export {};
|
|
15
22
|
//# sourceMappingURL=percent.d.ts.map
|
|
@@ -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;
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -190,6 +190,7 @@ var Percent = class extends Fraction {
|
|
|
190
190
|
return super.multiply(ONE_HUNDRED).toFixed(decimalPlaces, format, rounding);
|
|
191
191
|
}
|
|
192
192
|
};
|
|
193
|
+
Percent.toPercent = toPercent;
|
|
193
194
|
var Big2 = toFormat__default.default(_Big__default.default);
|
|
194
195
|
var CurrencyAmount = class extends Fraction {
|
|
195
196
|
constructor(currency, numerator, denominator) {
|
|
@@ -462,6 +463,17 @@ function getTokenComparator(balances) {
|
|
|
462
463
|
return tokenA.symbol ? -1 : tokenB.symbol ? -1 : 0;
|
|
463
464
|
};
|
|
464
465
|
}
|
|
466
|
+
function sortCurrencies(currencies) {
|
|
467
|
+
return currencies.sort((a, b) => {
|
|
468
|
+
if (a.isNative) {
|
|
469
|
+
return -1;
|
|
470
|
+
}
|
|
471
|
+
if (b.isNative) {
|
|
472
|
+
return 1;
|
|
473
|
+
}
|
|
474
|
+
return a.sortsBefore(b) ? -1 : 1;
|
|
475
|
+
});
|
|
476
|
+
}
|
|
465
477
|
|
|
466
478
|
exports.BaseCurrency = BaseCurrency;
|
|
467
479
|
exports.CurrencyAmount = CurrencyAmount;
|
|
@@ -489,6 +501,7 @@ exports._10000 = _10000;
|
|
|
489
501
|
exports._9975 = _9975;
|
|
490
502
|
exports.computePriceImpact = computePriceImpact;
|
|
491
503
|
exports.getTokenComparator = getTokenComparator;
|
|
504
|
+
exports.sortCurrencies = sortCurrencies;
|
|
492
505
|
exports.sortedInsert = sortedInsert;
|
|
493
506
|
exports.sqrt = sqrt;
|
|
494
507
|
exports.validateVMTypeInstance = validateVMTypeInstance;
|
package/dist/index.mjs
CHANGED
|
@@ -181,6 +181,7 @@ var Percent = class extends Fraction {
|
|
|
181
181
|
return super.multiply(ONE_HUNDRED).toFixed(decimalPlaces, format, rounding);
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
+
Percent.toPercent = toPercent;
|
|
184
185
|
var Big2 = toFormat(_Big);
|
|
185
186
|
var CurrencyAmount = class extends Fraction {
|
|
186
187
|
constructor(currency, numerator, denominator) {
|
|
@@ -453,5 +454,16 @@ function getTokenComparator(balances) {
|
|
|
453
454
|
return tokenA.symbol ? -1 : tokenB.symbol ? -1 : 0;
|
|
454
455
|
};
|
|
455
456
|
}
|
|
457
|
+
function sortCurrencies(currencies) {
|
|
458
|
+
return currencies.sort((a, b) => {
|
|
459
|
+
if (a.isNative) {
|
|
460
|
+
return -1;
|
|
461
|
+
}
|
|
462
|
+
if (b.isNative) {
|
|
463
|
+
return 1;
|
|
464
|
+
}
|
|
465
|
+
return a.sortsBefore(b) ? -1 : 1;
|
|
466
|
+
});
|
|
467
|
+
}
|
|
456
468
|
|
|
457
|
-
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 };
|
|
469
|
+
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, sortCurrencies, sortedInsert, sqrt, validateVMTypeInstance };
|
package/dist/utils.d.ts
CHANGED
|
@@ -15,4 +15,5 @@ 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[];
|
|
18
19
|
//# 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,EAAwB,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,KAAK,EAAE,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