@uniswap/sdk-core 7.12.2 → 7.13.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.
Files changed (162) hide show
  1. package/dist/{addresses.d.ts → cjs/src/addresses.d.ts} +58 -58
  2. package/dist/cjs/src/addresses.js +549 -0
  3. package/dist/cjs/src/addresses.js.map +1 -0
  4. package/dist/{chains.d.ts → cjs/src/chains.d.ts} +48 -48
  5. package/dist/cjs/src/chains.js +88 -0
  6. package/dist/cjs/src/chains.js.map +1 -0
  7. package/dist/{constants.d.ts → cjs/src/constants.d.ts} +12 -12
  8. package/dist/cjs/src/constants.js +18 -0
  9. package/dist/cjs/src/constants.js.map +1 -0
  10. package/dist/{entities → cjs/src/entities}/baseCurrency.d.ts +49 -49
  11. package/dist/cjs/src/entities/baseCurrency.js +27 -0
  12. package/dist/cjs/src/entities/baseCurrency.js.map +1 -0
  13. package/dist/{entities → cjs/src/entities}/currency.d.ts +3 -3
  14. package/dist/cjs/src/entities/currency.js +3 -0
  15. package/dist/cjs/src/entities/currency.js.map +1 -0
  16. package/dist/{entities → cjs/src/entities}/ether.d.ts +13 -13
  17. package/dist/cjs/src/entities/ether.js +30 -0
  18. package/dist/cjs/src/entities/ether.js.map +1 -0
  19. package/dist/{entities → cjs/src/entities}/fractions/currencyAmount.d.ts +31 -31
  20. package/dist/cjs/src/entities/fractions/currencyAmount.js +72 -0
  21. package/dist/cjs/src/entities/fractions/currencyAmount.js.map +1 -0
  22. package/dist/{entities → cjs/src/entities}/fractions/fraction.d.ts +24 -24
  23. package/dist/cjs/src/entities/fractions/fraction.js +104 -0
  24. package/dist/cjs/src/entities/fractions/fraction.js.map +1 -0
  25. package/dist/{entities → cjs/src/entities}/fractions/index.d.ts +4 -4
  26. package/dist/cjs/src/entities/fractions/index.js +12 -0
  27. package/dist/cjs/src/entities/fractions/index.js.map +1 -0
  28. package/dist/{entities → cjs/src/entities}/fractions/percent.d.ts +14 -14
  29. package/dist/cjs/src/entities/fractions/percent.js +43 -0
  30. package/dist/cjs/src/entities/fractions/percent.js.map +1 -0
  31. package/dist/{entities → cjs/src/entities}/fractions/price.d.ts +38 -38
  32. package/dist/cjs/src/entities/fractions/price.js +73 -0
  33. package/dist/cjs/src/entities/fractions/price.js.map +1 -0
  34. package/dist/{entities → cjs/src/entities}/index.d.ts +6 -6
  35. package/dist/cjs/src/entities/index.js +10 -0
  36. package/dist/cjs/src/entities/index.js.map +1 -0
  37. package/dist/{entities → cjs/src/entities}/nativeCurrency.d.ts +8 -8
  38. package/dist/cjs/src/entities/nativeCurrency.js +16 -0
  39. package/dist/cjs/src/entities/nativeCurrency.js.map +1 -0
  40. package/dist/{entities → cjs/src/entities}/token.d.ts +48 -48
  41. package/dist/cjs/src/entities/token.js +69 -0
  42. package/dist/cjs/src/entities/token.js.map +1 -0
  43. package/dist/{entities → cjs/src/entities}/weth9.d.ts +7 -7
  44. package/dist/cjs/src/entities/weth9.js +37 -0
  45. package/dist/cjs/src/entities/weth9.js.map +1 -0
  46. package/dist/{index.d.ts → cjs/src/index.d.ts} +5 -5
  47. package/dist/cjs/src/index.js +9 -0
  48. package/dist/cjs/src/index.js.map +1 -0
  49. package/dist/{utils → cjs/src/utils}/computePriceImpact.d.ts +8 -8
  50. package/dist/cjs/src/utils/computePriceImpact.js +18 -0
  51. package/dist/cjs/src/utils/computePriceImpact.js.map +1 -0
  52. package/dist/{utils → cjs/src/utils}/computeZksyncCreate2Address.d.ts +2 -2
  53. package/dist/cjs/src/utils/computeZksyncCreate2Address.js +15 -0
  54. package/dist/cjs/src/utils/computeZksyncCreate2Address.js.map +1 -0
  55. package/dist/{utils → cjs/src/utils}/index.d.ts +5 -5
  56. package/dist/cjs/src/utils/index.js +14 -0
  57. package/dist/cjs/src/utils/index.js.map +1 -0
  58. package/dist/{utils → cjs/src/utils}/sortedInsert.d.ts +1 -1
  59. package/dist/cjs/src/utils/sortedInsert.js +38 -0
  60. package/dist/cjs/src/utils/sortedInsert.js.map +1 -0
  61. package/dist/{utils → cjs/src/utils}/sqrt.d.ts +7 -7
  62. package/dist/cjs/src/utils/sqrt.js +32 -0
  63. package/dist/cjs/src/utils/sqrt.js.map +1 -0
  64. package/dist/{utils → cjs/src/utils}/validateAndParseAddress.d.ts +10 -10
  65. package/dist/cjs/src/utils/validateAndParseAddress.js +31 -0
  66. package/dist/cjs/src/utils/validateAndParseAddress.js.map +1 -0
  67. package/dist/esm/src/addresses.d.ts +58 -0
  68. package/dist/esm/src/addresses.js +545 -0
  69. package/dist/esm/src/addresses.js.map +1 -0
  70. package/dist/esm/src/chains.d.ts +48 -0
  71. package/dist/esm/src/chains.js +85 -0
  72. package/dist/esm/src/chains.js.map +1 -0
  73. package/dist/esm/src/constants.d.ts +12 -0
  74. package/dist/esm/src/constants.js +14 -0
  75. package/dist/esm/src/constants.js.map +1 -0
  76. package/dist/esm/src/entities/baseCurrency.d.ts +49 -0
  77. package/dist/esm/src/entities/baseCurrency.js +22 -0
  78. package/dist/esm/src/entities/baseCurrency.js.map +1 -0
  79. package/dist/esm/src/entities/currency.d.ts +3 -0
  80. package/dist/esm/src/entities/currency.js +2 -0
  81. package/dist/esm/src/entities/currency.js.map +1 -0
  82. package/dist/esm/src/entities/ether.d.ts +13 -0
  83. package/dist/esm/src/entities/ether.js +25 -0
  84. package/dist/esm/src/entities/ether.js.map +1 -0
  85. package/dist/esm/src/entities/fractions/currencyAmount.d.ts +31 -0
  86. package/dist/esm/src/entities/fractions/currencyAmount.js +67 -0
  87. package/dist/esm/src/entities/fractions/currencyAmount.js.map +1 -0
  88. package/dist/esm/src/entities/fractions/fraction.d.ts +24 -0
  89. package/dist/esm/src/entities/fractions/fraction.js +99 -0
  90. package/dist/esm/src/entities/fractions/fraction.js.map +1 -0
  91. package/dist/esm/src/entities/fractions/index.d.ts +4 -0
  92. package/dist/esm/src/entities/fractions/index.js +5 -0
  93. package/dist/esm/src/entities/fractions/index.js.map +1 -0
  94. package/dist/esm/src/entities/fractions/percent.d.ts +14 -0
  95. package/dist/esm/src/entities/fractions/percent.js +38 -0
  96. package/dist/esm/src/entities/fractions/percent.js.map +1 -0
  97. package/dist/esm/src/entities/fractions/price.d.ts +38 -0
  98. package/dist/esm/src/entities/fractions/price.js +68 -0
  99. package/dist/esm/src/entities/fractions/price.js.map +1 -0
  100. package/dist/esm/src/entities/index.d.ts +6 -0
  101. package/dist/esm/src/entities/index.js +7 -0
  102. package/dist/esm/src/entities/index.js.map +1 -0
  103. package/dist/esm/src/entities/nativeCurrency.d.ts +8 -0
  104. package/dist/esm/src/entities/nativeCurrency.js +12 -0
  105. package/dist/esm/src/entities/nativeCurrency.js.map +1 -0
  106. package/dist/esm/src/entities/token.d.ts +48 -0
  107. package/dist/esm/src/entities/token.js +64 -0
  108. package/dist/esm/src/entities/token.js.map +1 -0
  109. package/dist/esm/src/entities/weth9.d.ts +7 -0
  110. package/dist/esm/src/entities/weth9.js +34 -0
  111. package/dist/esm/src/entities/weth9.js.map +1 -0
  112. package/dist/esm/src/index.d.ts +5 -0
  113. package/dist/esm/src/index.js +6 -0
  114. package/dist/esm/src/index.js.map +1 -0
  115. package/dist/esm/src/utils/computePriceImpact.d.ts +8 -0
  116. package/dist/esm/src/utils/computePriceImpact.js +14 -0
  117. package/dist/esm/src/utils/computePriceImpact.js.map +1 -0
  118. package/dist/esm/src/utils/computeZksyncCreate2Address.d.ts +2 -0
  119. package/dist/esm/src/utils/computeZksyncCreate2Address.js +11 -0
  120. package/dist/esm/src/utils/computeZksyncCreate2Address.js.map +1 -0
  121. package/dist/esm/src/utils/index.d.ts +5 -0
  122. package/dist/esm/src/utils/index.js +6 -0
  123. package/dist/esm/src/utils/index.js.map +1 -0
  124. package/dist/esm/src/utils/sortedInsert.d.ts +1 -0
  125. package/dist/esm/src/utils/sortedInsert.js +33 -0
  126. package/dist/esm/src/utils/sortedInsert.js.map +1 -0
  127. package/dist/esm/src/utils/sqrt.d.ts +7 -0
  128. package/dist/esm/src/utils/sqrt.js +27 -0
  129. package/dist/esm/src/utils/sqrt.js.map +1 -0
  130. package/dist/esm/src/utils/validateAndParseAddress.d.ts +10 -0
  131. package/dist/esm/src/utils/validateAndParseAddress.js +26 -0
  132. package/dist/esm/src/utils/validateAndParseAddress.js.map +1 -0
  133. package/dist/types/src/addresses.d.ts +58 -0
  134. package/dist/types/src/chains.d.ts +48 -0
  135. package/dist/types/src/constants.d.ts +12 -0
  136. package/dist/types/src/entities/baseCurrency.d.ts +49 -0
  137. package/dist/types/src/entities/currency.d.ts +3 -0
  138. package/dist/types/src/entities/ether.d.ts +13 -0
  139. package/dist/types/src/entities/fractions/currencyAmount.d.ts +31 -0
  140. package/dist/types/src/entities/fractions/fraction.d.ts +24 -0
  141. package/dist/types/src/entities/fractions/index.d.ts +4 -0
  142. package/dist/types/src/entities/fractions/percent.d.ts +14 -0
  143. package/dist/types/src/entities/fractions/price.d.ts +38 -0
  144. package/dist/types/src/entities/index.d.ts +6 -0
  145. package/dist/types/src/entities/nativeCurrency.d.ts +8 -0
  146. package/dist/types/src/entities/token.d.ts +48 -0
  147. package/dist/types/src/entities/weth9.d.ts +7 -0
  148. package/dist/types/src/index.d.ts +5 -0
  149. package/dist/types/src/utils/computePriceImpact.d.ts +8 -0
  150. package/dist/types/src/utils/computeZksyncCreate2Address.d.ts +2 -0
  151. package/dist/types/src/utils/index.d.ts +5 -0
  152. package/dist/types/src/utils/sortedInsert.d.ts +1 -0
  153. package/dist/types/src/utils/sqrt.d.ts +7 -0
  154. package/dist/types/src/utils/validateAndParseAddress.d.ts +10 -0
  155. package/package.json +21 -11
  156. package/dist/index.js +0 -8
  157. package/dist/sdk-core.cjs.development.js +0 -1185
  158. package/dist/sdk-core.cjs.development.js.map +0 -1
  159. package/dist/sdk-core.cjs.production.min.js +0 -2
  160. package/dist/sdk-core.cjs.production.min.js.map +0 -1
  161. package/dist/sdk-core.esm.js +0 -1146
  162. package/dist/sdk-core.esm.js.map +0 -1
@@ -1,24 +1,24 @@
1
- import JSBI from 'jsbi';
2
- import { BigintIsh, Rounding } from '../../constants';
3
- export declare class Fraction {
4
- readonly numerator: JSBI;
5
- readonly denominator: JSBI;
6
- constructor(numerator: BigintIsh, denominator?: BigintIsh);
7
- private static tryParseFraction;
8
- get quotient(): JSBI;
9
- get remainder(): Fraction;
10
- invert(): Fraction;
11
- add(other: Fraction | BigintIsh): Fraction;
12
- subtract(other: Fraction | BigintIsh): Fraction;
13
- lessThan(other: Fraction | BigintIsh): boolean;
14
- equalTo(other: Fraction | BigintIsh): boolean;
15
- greaterThan(other: Fraction | BigintIsh): boolean;
16
- multiply(other: Fraction | BigintIsh): Fraction;
17
- divide(other: Fraction | BigintIsh): Fraction;
18
- toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
19
- toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
20
- /**
21
- * Helper method for converting any super class back to a fraction
22
- */
23
- get asFraction(): Fraction;
24
- }
1
+ import JSBI from 'jsbi';
2
+ import { BigintIsh, Rounding } from '../../constants';
3
+ export declare class Fraction {
4
+ readonly numerator: JSBI;
5
+ readonly denominator: JSBI;
6
+ constructor(numerator: BigintIsh, denominator?: BigintIsh);
7
+ private static tryParseFraction;
8
+ get quotient(): JSBI;
9
+ get remainder(): Fraction;
10
+ invert(): Fraction;
11
+ add(other: Fraction | BigintIsh): Fraction;
12
+ subtract(other: Fraction | BigintIsh): Fraction;
13
+ lessThan(other: Fraction | BigintIsh): boolean;
14
+ equalTo(other: Fraction | BigintIsh): boolean;
15
+ greaterThan(other: Fraction | BigintIsh): boolean;
16
+ multiply(other: Fraction | BigintIsh): Fraction;
17
+ divide(other: Fraction | BigintIsh): Fraction;
18
+ toSignificant(significantDigits: number, format?: object, rounding?: Rounding): string;
19
+ toFixed(decimalPlaces: number, format?: object, rounding?: Rounding): string;
20
+ /**
21
+ * Helper method for converting any super class back to a fraction
22
+ */
23
+ get asFraction(): Fraction;
24
+ }
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Fraction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsbi_1 = tslib_1.__importDefault(require("jsbi"));
6
+ const tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
7
+ const decimal_js_light_1 = tslib_1.__importDefault(require("decimal.js-light"));
8
+ const big_js_1 = tslib_1.__importDefault(require("big.js"));
9
+ const toformat_1 = tslib_1.__importDefault(require("toformat"));
10
+ const constants_1 = require("../../constants");
11
+ const Decimal = (0, toformat_1.default)(decimal_js_light_1.default);
12
+ const Big = (0, toformat_1.default)(big_js_1.default);
13
+ const toSignificantRounding = {
14
+ [constants_1.Rounding.ROUND_DOWN]: Decimal.ROUND_DOWN,
15
+ [constants_1.Rounding.ROUND_HALF_UP]: Decimal.ROUND_HALF_UP,
16
+ [constants_1.Rounding.ROUND_UP]: Decimal.ROUND_UP,
17
+ };
18
+ const toFixedRounding = {
19
+ [constants_1.Rounding.ROUND_DOWN]: 0,
20
+ [constants_1.Rounding.ROUND_HALF_UP]: 1,
21
+ [constants_1.Rounding.ROUND_UP]: 3, // Big.RoundUp
22
+ };
23
+ class Fraction {
24
+ constructor(numerator, denominator = jsbi_1.default.BigInt(1)) {
25
+ this.numerator = jsbi_1.default.BigInt(numerator);
26
+ this.denominator = jsbi_1.default.BigInt(denominator);
27
+ }
28
+ static tryParseFraction(fractionish) {
29
+ if (fractionish instanceof jsbi_1.default || typeof fractionish === 'number' || typeof fractionish === 'string')
30
+ return new Fraction(fractionish);
31
+ if ('numerator' in fractionish && 'denominator' in fractionish)
32
+ return fractionish;
33
+ throw new Error('Could not parse fraction');
34
+ }
35
+ // performs floor division
36
+ get quotient() {
37
+ return jsbi_1.default.divide(this.numerator, this.denominator);
38
+ }
39
+ // remainder after floor division
40
+ get remainder() {
41
+ return new Fraction(jsbi_1.default.remainder(this.numerator, this.denominator), this.denominator);
42
+ }
43
+ invert() {
44
+ return new Fraction(this.denominator, this.numerator);
45
+ }
46
+ add(other) {
47
+ const otherParsed = Fraction.tryParseFraction(other);
48
+ if (jsbi_1.default.equal(this.denominator, otherParsed.denominator)) {
49
+ return new Fraction(jsbi_1.default.add(this.numerator, otherParsed.numerator), this.denominator);
50
+ }
51
+ return new Fraction(jsbi_1.default.add(jsbi_1.default.multiply(this.numerator, otherParsed.denominator), jsbi_1.default.multiply(otherParsed.numerator, this.denominator)), jsbi_1.default.multiply(this.denominator, otherParsed.denominator));
52
+ }
53
+ subtract(other) {
54
+ const otherParsed = Fraction.tryParseFraction(other);
55
+ if (jsbi_1.default.equal(this.denominator, otherParsed.denominator)) {
56
+ return new Fraction(jsbi_1.default.subtract(this.numerator, otherParsed.numerator), this.denominator);
57
+ }
58
+ return new Fraction(jsbi_1.default.subtract(jsbi_1.default.multiply(this.numerator, otherParsed.denominator), jsbi_1.default.multiply(otherParsed.numerator, this.denominator)), jsbi_1.default.multiply(this.denominator, otherParsed.denominator));
59
+ }
60
+ lessThan(other) {
61
+ const otherParsed = Fraction.tryParseFraction(other);
62
+ return jsbi_1.default.lessThan(jsbi_1.default.multiply(this.numerator, otherParsed.denominator), jsbi_1.default.multiply(otherParsed.numerator, this.denominator));
63
+ }
64
+ equalTo(other) {
65
+ const otherParsed = Fraction.tryParseFraction(other);
66
+ return jsbi_1.default.equal(jsbi_1.default.multiply(this.numerator, otherParsed.denominator), jsbi_1.default.multiply(otherParsed.numerator, this.denominator));
67
+ }
68
+ greaterThan(other) {
69
+ const otherParsed = Fraction.tryParseFraction(other);
70
+ return jsbi_1.default.greaterThan(jsbi_1.default.multiply(this.numerator, otherParsed.denominator), jsbi_1.default.multiply(otherParsed.numerator, this.denominator));
71
+ }
72
+ multiply(other) {
73
+ const otherParsed = Fraction.tryParseFraction(other);
74
+ return new Fraction(jsbi_1.default.multiply(this.numerator, otherParsed.numerator), jsbi_1.default.multiply(this.denominator, otherParsed.denominator));
75
+ }
76
+ divide(other) {
77
+ const otherParsed = Fraction.tryParseFraction(other);
78
+ return new Fraction(jsbi_1.default.multiply(this.numerator, otherParsed.denominator), jsbi_1.default.multiply(this.denominator, otherParsed.numerator));
79
+ }
80
+ toSignificant(significantDigits, format = { groupSeparator: '' }, rounding = constants_1.Rounding.ROUND_HALF_UP) {
81
+ (0, tiny_invariant_1.default)(Number.isInteger(significantDigits), `${significantDigits} is not an integer.`);
82
+ (0, tiny_invariant_1.default)(significantDigits > 0, `${significantDigits} is not positive.`);
83
+ Decimal.set({ precision: significantDigits + 1, rounding: toSignificantRounding[rounding] });
84
+ const quotient = new Decimal(this.numerator.toString())
85
+ .div(this.denominator.toString())
86
+ .toSignificantDigits(significantDigits);
87
+ return quotient.toFormat(quotient.decimalPlaces(), format);
88
+ }
89
+ toFixed(decimalPlaces, format = { groupSeparator: '' }, rounding = constants_1.Rounding.ROUND_HALF_UP) {
90
+ (0, tiny_invariant_1.default)(Number.isInteger(decimalPlaces), `${decimalPlaces} is not an integer.`);
91
+ (0, tiny_invariant_1.default)(decimalPlaces >= 0, `${decimalPlaces} is negative.`);
92
+ Big.DP = decimalPlaces;
93
+ Big.RM = toFixedRounding[rounding];
94
+ return new Big(this.numerator.toString()).div(this.denominator.toString()).toFormat(decimalPlaces, format);
95
+ }
96
+ /**
97
+ * Helper method for converting any super class back to a fraction
98
+ */
99
+ get asFraction() {
100
+ return new Fraction(this.numerator, this.denominator);
101
+ }
102
+ }
103
+ exports.Fraction = Fraction;
104
+ //# sourceMappingURL=fraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fraction.js","sourceRoot":"","sources":["../../../../../src/entities/fractions/fraction.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AACvB,4EAAsC;AACtC,gFAAuC;AACvC,4DAAyB;AACzB,gEAA+B;AAE/B,+CAAqD;AAErD,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,0BAAQ,CAAC,CAAA;AAClC,MAAM,GAAG,GAAG,IAAA,kBAAQ,EAAC,gBAAI,CAAC,CAAA;AAE1B,MAAM,qBAAqB,GAAG;IAC5B,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5D,CAAC;IAEM,OAAO,CACZ,aAAqB,EACrB,SAAiB,EAAE,cAAc,EAAE,EAAE,EAAE,EACvC,WAAqB,oBAAQ,CAAC,aAAa;QAE3C,IAAA,wBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,GAAG,aAAa,qBAAqB,CAAC,CAAA;QACjF,IAAA,wBAAS,EAAC,aAAa,IAAI,CAAC,EAAE,GAAG,aAAa,eAAe,CAAC,CAAA;QAE9D,GAAG,CAAC,EAAE,GAAG,aAAa,CAAA;QACtB,GAAG,CAAC,EAAE,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;QAClC,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;IAC5G,CAAC;IAED;;OAEG;IACH,IAAW,UAAU;QACnB,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACvD,CAAC;CACF;AArID,4BAqIC"}
@@ -1,4 +1,4 @@
1
- export { CurrencyAmount } from './currencyAmount';
2
- export { Fraction } from './fraction';
3
- export { Percent } from './percent';
4
- export { Price } from './price';
1
+ export { CurrencyAmount } from './currencyAmount';
2
+ export { Fraction } from './fraction';
3
+ export { Percent } from './percent';
4
+ export { Price } from './price';
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Price = exports.Percent = exports.Fraction = exports.CurrencyAmount = void 0;
4
+ var currencyAmount_1 = require("./currencyAmount");
5
+ Object.defineProperty(exports, "CurrencyAmount", { enumerable: true, get: function () { return currencyAmount_1.CurrencyAmount; } });
6
+ var fraction_1 = require("./fraction");
7
+ Object.defineProperty(exports, "Fraction", { enumerable: true, get: function () { return fraction_1.Fraction; } });
8
+ var percent_1 = require("./percent");
9
+ Object.defineProperty(exports, "Percent", { enumerable: true, get: function () { return percent_1.Percent; } });
10
+ var price_1 = require("./price");
11
+ Object.defineProperty(exports, "Price", { enumerable: true, get: function () { return price_1.Price; } });
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/entities/fractions/index.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAAxC,gHAAA,cAAc,OAAA;AACvB,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,iCAA+B;AAAtB,8FAAA,KAAK,OAAA"}
@@ -1,14 +1,14 @@
1
- import { BigintIsh, Rounding } from '../../constants';
2
- import { Fraction } from './fraction';
3
- export declare class Percent extends Fraction {
4
- /**
5
- * This boolean prevents a fraction from being interpreted as a Percent
6
- */
7
- readonly isPercent: true;
8
- add(other: Fraction | BigintIsh): Percent;
9
- subtract(other: Fraction | BigintIsh): Percent;
10
- multiply(other: Fraction | BigintIsh): Percent;
11
- divide(other: Fraction | BigintIsh): Percent;
12
- toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
13
- toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
14
- }
1
+ import { BigintIsh, Rounding } from '../../constants';
2
+ import { Fraction } from './fraction';
3
+ export declare class Percent extends Fraction {
4
+ /**
5
+ * This boolean prevents a fraction from being interpreted as a Percent
6
+ */
7
+ readonly isPercent: true;
8
+ add(other: Fraction | BigintIsh): Percent;
9
+ subtract(other: Fraction | BigintIsh): Percent;
10
+ multiply(other: Fraction | BigintIsh): Percent;
11
+ divide(other: Fraction | BigintIsh): Percent;
12
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
13
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
14
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Percent = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsbi_1 = tslib_1.__importDefault(require("jsbi"));
6
+ const fraction_1 = require("./fraction");
7
+ const ONE_HUNDRED = new fraction_1.Fraction(jsbi_1.default.BigInt(100));
8
+ /**
9
+ * Converts a fraction to a percent
10
+ * @param fraction the fraction to convert
11
+ */
12
+ function toPercent(fraction) {
13
+ return new Percent(fraction.numerator, fraction.denominator);
14
+ }
15
+ class Percent extends fraction_1.Fraction {
16
+ constructor() {
17
+ super(...arguments);
18
+ /**
19
+ * This boolean prevents a fraction from being interpreted as a Percent
20
+ */
21
+ this.isPercent = true;
22
+ }
23
+ add(other) {
24
+ return toPercent(super.add(other));
25
+ }
26
+ subtract(other) {
27
+ return toPercent(super.subtract(other));
28
+ }
29
+ multiply(other) {
30
+ return toPercent(super.multiply(other));
31
+ }
32
+ divide(other) {
33
+ return toPercent(super.divide(other));
34
+ }
35
+ toSignificant(significantDigits = 5, format, rounding) {
36
+ return super.multiply(ONE_HUNDRED).toSignificant(significantDigits, format, rounding);
37
+ }
38
+ toFixed(decimalPlaces = 2, format, rounding) {
39
+ return super.multiply(ONE_HUNDRED).toFixed(decimalPlaces, format, rounding);
40
+ }
41
+ }
42
+ exports.Percent = Percent;
43
+ //# sourceMappingURL=percent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"percent.js","sourceRoot":"","sources":["../../../../../src/entities/fractions/percent.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AAEvB,yCAAqC;AAErC,MAAM,WAAW,GAAG,IAAI,mBAAQ,CAAC,cAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;AAElD;;;GAGG;AACH,SAAS,SAAS,CAAC,QAAkB;IACnC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;AAC9D,CAAC;AAED,MAAa,OAAQ,SAAQ,mBAAQ;IAArC;;QACE;;WAEG;QACa,cAAS,GAAS,IAAI,CAAA;IAyBxC,CAAC;IAvBC,GAAG,CAAC,KAA2B;QAC7B,OAAO,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACpC,CAAC;IAED,QAAQ,CAAC,KAA2B;QAClC,OAAO,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IACzC,CAAC;IAED,QAAQ,CAAC,KAA2B;QAClC,OAAO,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;IACzC,CAAC;IAED,MAAM,CAAC,KAA2B;QAChC,OAAO,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;IACvC,CAAC;IAEM,aAAa,CAAC,oBAA4B,CAAC,EAAE,MAAe,EAAE,QAAmB;QACtF,OAAO,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,aAAa,CAAC,iBAAiB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IACvF,CAAC;IAEM,OAAO,CAAC,gBAAwB,CAAC,EAAE,MAAe,EAAE,QAAmB;QAC5E,OAAO,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC7E,CAAC;CACF;AA7BD,0BA6BC"}
@@ -1,38 +1,38 @@
1
- import { BigintIsh, Rounding } from '../../constants';
2
- import { Currency } from '../currency';
3
- import { Fraction } from './fraction';
4
- import { CurrencyAmount } from './currencyAmount';
5
- export declare class Price<TBase extends Currency, TQuote extends Currency> extends Fraction {
6
- readonly baseCurrency: TBase;
7
- readonly quoteCurrency: TQuote;
8
- readonly scalar: Fraction;
9
- /**
10
- * Construct a price, either with the base and quote currency amount, or the
11
- * @param args
12
- */
13
- constructor(...args: [TBase, TQuote, BigintIsh, BigintIsh] | [{
14
- baseAmount: CurrencyAmount<TBase>;
15
- quoteAmount: CurrencyAmount<TQuote>;
16
- }]);
17
- /**
18
- * Flip the price, switching the base and quote currency
19
- */
20
- invert(): Price<TQuote, TBase>;
21
- /**
22
- * 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
23
- * @param other the other price
24
- */
25
- multiply<TOtherQuote extends Currency>(other: Price<TQuote, TOtherQuote>): Price<TBase, TOtherQuote>;
26
- /**
27
- * Return the amount of quote currency corresponding to a given amount of the base currency
28
- * @param currencyAmount the amount of base currency to quote against the price
29
- */
30
- quote(currencyAmount: CurrencyAmount<TBase>): CurrencyAmount<TQuote>;
31
- /**
32
- * Get the value scaled by decimals for formatting
33
- * @private
34
- */
35
- private get adjustedForDecimals();
36
- toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
37
- toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
38
- }
1
+ import { BigintIsh, Rounding } from '../../constants';
2
+ import { Currency } from '../currency';
3
+ import { Fraction } from './fraction';
4
+ import { CurrencyAmount } from './currencyAmount';
5
+ export declare class Price<TBase extends Currency, TQuote extends Currency> extends Fraction {
6
+ readonly baseCurrency: TBase;
7
+ readonly quoteCurrency: TQuote;
8
+ readonly scalar: Fraction;
9
+ /**
10
+ * Construct a price, either with the base and quote currency amount, or the
11
+ * @param args
12
+ */
13
+ constructor(...args: [TBase, TQuote, BigintIsh, BigintIsh] | [{
14
+ baseAmount: CurrencyAmount<TBase>;
15
+ quoteAmount: CurrencyAmount<TQuote>;
16
+ }]);
17
+ /**
18
+ * Flip the price, switching the base and quote currency
19
+ */
20
+ invert(): Price<TQuote, TBase>;
21
+ /**
22
+ * 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
23
+ * @param other the other price
24
+ */
25
+ multiply<TOtherQuote extends Currency>(other: Price<TQuote, TOtherQuote>): Price<TBase, TOtherQuote>;
26
+ /**
27
+ * Return the amount of quote currency corresponding to a given amount of the base currency
28
+ * @param currencyAmount the amount of base currency to quote against the price
29
+ */
30
+ quote(currencyAmount: CurrencyAmount<TBase>): CurrencyAmount<TQuote>;
31
+ /**
32
+ * Get the value scaled by decimals for formatting
33
+ * @private
34
+ */
35
+ private get adjustedForDecimals();
36
+ toSignificant(significantDigits?: number, format?: object, rounding?: Rounding): string;
37
+ toFixed(decimalPlaces?: number, format?: object, rounding?: Rounding): string;
38
+ }
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Price = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const jsbi_1 = tslib_1.__importDefault(require("jsbi"));
6
+ const tiny_invariant_1 = tslib_1.__importDefault(require("tiny-invariant"));
7
+ const fraction_1 = require("./fraction");
8
+ const currencyAmount_1 = require("./currencyAmount");
9
+ class Price extends fraction_1.Fraction {
10
+ /**
11
+ * Construct a price, either with the base and quote currency amount, or the
12
+ * @param args
13
+ */
14
+ constructor(...args) {
15
+ let baseCurrency, quoteCurrency, denominator, numerator;
16
+ if (args.length === 4) {
17
+ ;
18
+ [baseCurrency, quoteCurrency, denominator, numerator] = args;
19
+ }
20
+ else {
21
+ const result = args[0].quoteAmount.divide(args[0].baseAmount);
22
+ [baseCurrency, quoteCurrency, denominator, numerator] = [
23
+ args[0].baseAmount.currency,
24
+ args[0].quoteAmount.currency,
25
+ result.denominator,
26
+ result.numerator,
27
+ ];
28
+ }
29
+ super(numerator, denominator);
30
+ this.baseCurrency = baseCurrency;
31
+ this.quoteCurrency = quoteCurrency;
32
+ this.scalar = new fraction_1.Fraction(jsbi_1.default.exponentiate(jsbi_1.default.BigInt(10), jsbi_1.default.BigInt(baseCurrency.decimals)), jsbi_1.default.exponentiate(jsbi_1.default.BigInt(10), jsbi_1.default.BigInt(quoteCurrency.decimals)));
33
+ }
34
+ /**
35
+ * Flip the price, switching the base and quote currency
36
+ */
37
+ invert() {
38
+ return new Price(this.quoteCurrency, this.baseCurrency, this.numerator, this.denominator);
39
+ }
40
+ /**
41
+ * 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
42
+ * @param other the other price
43
+ */
44
+ multiply(other) {
45
+ (0, tiny_invariant_1.default)(this.quoteCurrency.equals(other.baseCurrency), 'TOKEN');
46
+ const fraction = super.multiply(other);
47
+ return new Price(this.baseCurrency, other.quoteCurrency, fraction.denominator, fraction.numerator);
48
+ }
49
+ /**
50
+ * Return the amount of quote currency corresponding to a given amount of the base currency
51
+ * @param currencyAmount the amount of base currency to quote against the price
52
+ */
53
+ quote(currencyAmount) {
54
+ (0, tiny_invariant_1.default)(currencyAmount.currency.equals(this.baseCurrency), 'TOKEN');
55
+ const result = super.multiply(currencyAmount);
56
+ return currencyAmount_1.CurrencyAmount.fromFractionalAmount(this.quoteCurrency, result.numerator, result.denominator);
57
+ }
58
+ /**
59
+ * Get the value scaled by decimals for formatting
60
+ * @private
61
+ */
62
+ get adjustedForDecimals() {
63
+ return super.multiply(this.scalar);
64
+ }
65
+ toSignificant(significantDigits = 6, format, rounding) {
66
+ return this.adjustedForDecimals.toSignificant(significantDigits, format, rounding);
67
+ }
68
+ toFixed(decimalPlaces = 4, format, rounding) {
69
+ return this.adjustedForDecimals.toFixed(decimalPlaces, format, rounding);
70
+ }
71
+ }
72
+ exports.Price = Price;
73
+ //# sourceMappingURL=price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"price.js","sourceRoot":"","sources":["../../../../../src/entities/fractions/price.ts"],"names":[],"mappings":";;;;AAAA,wDAAuB;AACvB,4EAAsC;AAItC,yCAAqC;AACrC,qDAAiD;AAEjD,MAAa,KAAuD,SAAQ,mBAAQ;IAKlF;;;OAGG;IACH,YACE,GAAG,IAE6E;QAEhF,IAAI,YAAmB,EAAE,aAAqB,EAAE,WAAsB,EAAE,SAAoB,CAAA;QAE5F,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACrB,CAAC;YAAA,CAAC,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,CAAC,GAAG,IAAI,CAAA;SAC9D;aAAM;Y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,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAA;IACpG,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,cAAqC;QAChD,IAAA,wBAAS,EAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC,CAAA;QACrE,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;QAC7C,OAAO,+BAAc,CAAC,oBAAoB,CAAC,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,WAAW,CAAC,CAAA;IACtG,CAAC;IAED;;;OAGG;IACH,IAAY,mBAAmB;QAC7B,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACpC,CAAC;IAEM,aAAa,CAAC,oBAA4B,CAAC,EAAE,MAAe,EAAE,QAAmB;QACtF,OAAO,IAAI,CAAC,mBAAmB,CAAC,aAAa,CAAC,iBAAiB,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IACpF,CAAC;IAEM,OAAO,CAAC,gBAAwB,CAAC,EAAE,MAAe,EAAE,QAAmB;QAC5E,OAAO,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC1E,CAAC;CACF;AA/ED,sBA+EC"}
@@ -1,6 +1,6 @@
1
- export * from './fractions';
2
- export * from './currency';
3
- export * from './ether';
4
- export * from './nativeCurrency';
5
- export * from './token';
6
- export * from './weth9';
1
+ export * from './fractions';
2
+ export * from './currency';
3
+ export * from './ether';
4
+ export * from './nativeCurrency';
5
+ export * from './token';
6
+ export * from './weth9';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./fractions"), exports);
5
+ tslib_1.__exportStar(require("./currency"), exports);
6
+ tslib_1.__exportStar(require("./ether"), exports);
7
+ tslib_1.__exportStar(require("./nativeCurrency"), exports);
8
+ tslib_1.__exportStar(require("./token"), exports);
9
+ tslib_1.__exportStar(require("./weth9"), exports);
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/entities/index.ts"],"names":[],"mappings":";;;AAAA,sDAA2B;AAE3B,qDAA0B;AAC1B,kDAAuB;AACvB,2DAAgC;AAChC,kDAAuB;AACvB,kDAAuB"}
@@ -1,8 +1,8 @@
1
- import { BaseCurrency } from './baseCurrency';
2
- /**
3
- * Represents the native currency of the chain on which it resides, e.g.
4
- */
5
- export declare abstract class NativeCurrency extends BaseCurrency {
6
- readonly isNative: true;
7
- readonly isToken: false;
8
- }
1
+ import { BaseCurrency } from './baseCurrency';
2
+ /**
3
+ * Represents the native currency of the chain on which it resides, e.g.
4
+ */
5
+ export declare abstract class NativeCurrency extends BaseCurrency {
6
+ readonly isNative: true;
7
+ readonly isToken: false;
8
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NativeCurrency = void 0;
4
+ const baseCurrency_1 = require("./baseCurrency");
5
+ /**
6
+ * Represents the native currency of the chain on which it resides, e.g.
7
+ */
8
+ class NativeCurrency extends baseCurrency_1.BaseCurrency {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.isNative = true;
12
+ this.isToken = false;
13
+ }
14
+ }
15
+ exports.NativeCurrency = NativeCurrency;
16
+ //# sourceMappingURL=nativeCurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nativeCurrency.js","sourceRoot":"","sources":["../../../../src/entities/nativeCurrency.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AAE7C;;GAEG;AACH,MAAsB,cAAe,SAAQ,2BAAY;IAAzD;;QACkB,aAAQ,GAAS,IAAI,CAAA;QACrB,YAAO,GAAU,KAAK,CAAA;IACxC,CAAC;CAAA;AAHD,wCAGC"}
@@ -1,48 +1,48 @@
1
- import { BigNumber } from '@ethersproject/bignumber';
2
- import { BaseCurrency } from './baseCurrency';
3
- import { Currency } from './currency';
4
- /**
5
- * Represents an ERC20 token with a unique address and some metadata.
6
- */
7
- export declare class Token extends BaseCurrency {
8
- readonly isNative: false;
9
- readonly isToken: true;
10
- /**
11
- * The contract address on the chain on which this token lives
12
- */
13
- readonly address: string;
14
- /**
15
- * Relevant for fee-on-transfer (FOT) token taxes,
16
- * Not every ERC20 token is FOT token, so this field is optional
17
- */
18
- readonly buyFeeBps?: BigNumber;
19
- readonly sellFeeBps?: BigNumber;
20
- /**
21
- *
22
- * @param chainId {@link BaseCurrency#chainId}
23
- * @param address The contract address on the chain on which this token lives
24
- * @param decimals {@link BaseCurrency#decimals}
25
- * @param symbol {@link BaseCurrency#symbol}
26
- * @param name {@link BaseCurrency#name}
27
- * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
28
- * @param buyFeeBps Buy fee tax for FOT tokens, in basis points
29
- * @param sellFeeBps Sell fee tax for FOT tokens, in basis points
30
- */
31
- constructor(chainId: number, address: string, decimals: number, symbol?: string, name?: string, bypassChecksum?: boolean, buyFeeBps?: BigNumber, sellFeeBps?: BigNumber);
32
- /**
33
- * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
34
- * @param other other token to compare
35
- */
36
- equals(other: Currency): boolean;
37
- /**
38
- * Returns true if the address of this token sorts before the address of the other token
39
- * @param other other token to compare
40
- * @throws if the tokens have the same address
41
- * @throws if the tokens are on different chains
42
- */
43
- sortsBefore(other: Token): boolean;
44
- /**
45
- * Return this token, which does not need to be wrapped
46
- */
47
- get wrapped(): Token;
48
- }
1
+ import { BigNumber } from '@ethersproject/bignumber';
2
+ import { BaseCurrency } from './baseCurrency';
3
+ import { Currency } from './currency';
4
+ /**
5
+ * Represents an ERC20 token with a unique address and some metadata.
6
+ */
7
+ export declare class Token extends BaseCurrency {
8
+ readonly isNative: false;
9
+ readonly isToken: true;
10
+ /**
11
+ * The contract address on the chain on which this token lives
12
+ */
13
+ readonly address: string;
14
+ /**
15
+ * Relevant for fee-on-transfer (FOT) token taxes,
16
+ * Not every ERC20 token is FOT token, so this field is optional
17
+ */
18
+ readonly buyFeeBps?: BigNumber;
19
+ readonly sellFeeBps?: BigNumber;
20
+ /**
21
+ *
22
+ * @param chainId {@link BaseCurrency#chainId}
23
+ * @param address The contract address on the chain on which this token lives
24
+ * @param decimals {@link BaseCurrency#decimals}
25
+ * @param symbol {@link BaseCurrency#symbol}
26
+ * @param name {@link BaseCurrency#name}
27
+ * @param bypassChecksum If true it only checks for length === 42, startsWith 0x and contains only hex characters
28
+ * @param buyFeeBps Buy fee tax for FOT tokens, in basis points
29
+ * @param sellFeeBps Sell fee tax for FOT tokens, in basis points
30
+ */
31
+ constructor(chainId: number, address: string, decimals: number, symbol?: string, name?: string, bypassChecksum?: boolean, buyFeeBps?: BigNumber, sellFeeBps?: BigNumber);
32
+ /**
33
+ * Returns true if the two tokens are equivalent, i.e. have the same chainId and address.
34
+ * @param other other token to compare
35
+ */
36
+ equals(other: Currency): boolean;
37
+ /**
38
+ * Returns true if the address of this token sorts before the address of the other token
39
+ * @param other other token to compare
40
+ * @throws if the tokens have the same address
41
+ * @throws if the tokens are on different chains
42
+ */
43
+ sortsBefore(other: Token): boolean;
44
+ /**
45
+ * Return this token, which does not need to be wrapped
46
+ */
47
+ get wrapped(): Token;
48
+ }