@injectivelabs/utils 0.0.58 → 0.0.62

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/numbers.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BigNumber } from './classes';
2
+ export declare const getSignificantDecimalsFromNumber: (number: BigNumber | number | string) => number;
2
3
  /**
3
4
  * On chain amounts queried from a sentry using the
4
5
  * gRPC API are returned with an extra decimal point
@@ -6,6 +7,13 @@ import { BigNumber } from './classes';
6
7
  * to get a workable amount
7
8
  */
8
9
  export declare const denomAmountFromGrpcChainDenomAmount: (value: string | number | BigNumber) => BigNumber;
10
+ /**
11
+ * On chain amounts broadcasted to a sentry directly using the
12
+ * gRPC API should be passed with an extra decimal point
13
+ * 18 places from the beginning, so we need to add it
14
+ * to get a workable amount
15
+ */
16
+ export declare const denomAmountToGrpcChainDenomAmount: (value: string | number | BigNumber) => BigNumber;
9
17
  /**
10
18
  * Amount that the chain requires is in the x * 10^(quoteDecimals) format
11
19
  * where x is a human readable number
@@ -131,6 +139,22 @@ export declare const derivativeQuantityToChainQuantityToFixed: ({ value, decimal
131
139
  decimalPlaces?: number | undefined;
132
140
  roundingMode?: BigNumber.RoundingMode | undefined;
133
141
  }) => string;
142
+ /**
143
+ * Amount that the chain requires is in the x format
144
+ * where x is a human readable number
145
+ */
146
+ export declare const derivativeQuantityFromChainQuantity: ({ value, }: {
147
+ value: number | string | BigNumber;
148
+ }) => BigNumber;
149
+ /**
150
+ * Amount that the chain requires is in the x format
151
+ * where x is a human readable number stringified
152
+ */
153
+ export declare const derivativeQuantityFromChainQuantityToFixed: ({ value, decimalPlaces, roundingMode, }: {
154
+ value: number | string | BigNumber;
155
+ decimalPlaces?: number | undefined;
156
+ roundingMode?: BigNumber.RoundingMode | undefined;
157
+ }) => string;
134
158
  /**
135
159
  * Amount that the chain requires is in the x / 10^(quoteDecimals - baseDecimals) format
136
160
  * where x is a human readable number
@@ -1 +1 @@
1
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ule", { value: true });
3
- exports.spotQuantityFromChainQuantityToFixed = exports.spotQuantityFromChainQuantity = exports.spotQuantityToChainQuantityToFixed = exports.spotQuantityToChainQuantity = exports.spotPriceFromChainPriceToFixed = exports.spotPriceFromChainPrice = exports.spotPriceToChainPriceToFixed = exports.spotPriceToChainPrice = exports.derivativeQuantityToChainQuantityToFixed = exports.derivativeQuantityToChainQuantity = exports.derivativePriceFromChainPriceToFixed = exports.derivativePriceFromChainPrice = exports.derivativePriceToChainPriceToFixed = exports.derivativePriceToChainPrice = exports.derivativeMarginFromChainMarginToFixed = exports.derivativeMarginFromChainMargin = exports.derivativeMarginToChainMarginToFixed = exports.derivativeMarginToChainMargin = exports.denomAmountFromChainDenomAmountToFixed = exports.denomAmountFromChainDenomAmount = exports.denomAmountToChainDenomAmountToFixed = exports.denomAmountToChainDenomAmount = exports.denomAmountFromGrpcChainDenomAmount = void 0;
3
+ exports.spotQuantityFromChainQuantityToFixed = exports.spotQuantityFromChainQuantity = exports.spotQuantityToChainQuantityToFixed = exports.spotQuantityToChainQuantity = exports.spotPriceFromChainPriceToFixed = exports.spotPriceFromChainPrice = exports.spotPriceToChainPriceToFixed = exports.spotPriceToChainPrice = exports.derivativeQuantityFromChainQuantityToFixed = exports.derivativeQuantityFromChainQuantity = exports.derivativeQuantityToChainQuantityToFixed = exports.derivativeQuantityToChainQuantity = exports.derivativePriceFromChainPriceToFixed = exports.derivativePriceFromChainPrice = exports.derivativePriceToChainPriceToFixed = exports.derivativePriceToChainPrice = exports.derivativeMarginFromChainMarginToFixed = exports.derivativeMarginFromChainMargin = exports.derivativeMarginToChainMarginToFixed = exports.derivativeMarginToChainMargin = exports.denomAmountFromChainDenomAmountToFixed = exports.denomAmountFromChainDenomAmount = exports.denomAmountToChainDenomAmountToFixed = exports.denomAmountToChainDenomAmount = exports.denomAmountToGrpcChainDenomAmount = exports.denomAmountFromGrpcChainDenomAmount = exports.getSignificantDecimalsFromNumber = void 0;
4
4
  const classes_1 = require("./classes");
5
+ const $BigNumber = classes_1.BigNumber.clone({ ROUNDING_MODE: classes_1.BigNumber.ROUND_DOWN });
6
+ const getSignificantDecimalsFromNumber = (number) => {
7
+ if (Math.floor(new $BigNumber(number).toNumber()) === number) {
8
+ return 0;
9
+ }
10
+ const parts = new $BigNumber(number).toFixed().split('.');
11
+ const [, decimals] = parts;
12
+ /** Number doesn't have decimals */
13
+ if (!decimals) {
14
+ return 0;
15
+ }
16
+ return decimals.length;
17
+ };
18
+ exports.getSignificantDecimalsFromNumber = getSignificantDecimalsFromNumber;
5
19
  /**
6
20
  * On chain amounts queried from a sentry using the
7
21
  * gRPC API are returned with an extra decimal point
8
22
  * 18 places from the beginning, so we need to remove it
9
23
  * to get a workable amount
10
24
  */
11
- const denomAmountFromGrpcChainDenomAmount = (value) => new classes_1.BigNumber(value).dividedBy(new classes_1.BigNumber(10).pow(18));
25
+ const denomAmountFromGrpcChainDenomAmount = (value) => new $BigNumber(value).dividedBy(new $BigNumber(10).pow(18));
12
26
  exports.denomAmountFromGrpcChainDenomAmount = denomAmountFromGrpcChainDenomAmount;
27
+ /**
28
+ * On chain amounts broadcasted to a sentry directly using the
29
+ * gRPC API should be passed with an extra decimal point
30
+ * 18 places from the beginning, so we need to add it
31
+ * to get a workable amount
32
+ */
33
+ const denomAmountToGrpcChainDenomAmount = (value) => new $BigNumber(value).multipliedBy(new $BigNumber(10).pow(18));
34
+ exports.denomAmountToGrpcChainDenomAmount = denomAmountToGrpcChainDenomAmount;
13
35
  /**
14
36
  * Amount that the chain requires is in the x * 10^(quoteDecimals) format
15
37
  * where x is a human readable number
16
38
  */
17
- const denomAmountToChainDenomAmount = ({ value, decimals = 18, }) => new classes_1.BigNumber(value).multipliedBy(new classes_1.BigNumber(10).pow(decimals));
39
+ const denomAmountToChainDenomAmount = ({ value, decimals = 18, }) => new $BigNumber(value).multipliedBy(new $BigNumber(10).pow(decimals));
18
40
  exports.denomAmountToChainDenomAmount = denomAmountToChainDenomAmount;
19
41
  /**
20
42
  * Amount that the chain returns is in the x * 10^(quoteDecimals) format
21
43
  * where x is a human readable number
22
44
  */
23
- const denomAmountToChainDenomAmountToFixed = ({ value, decimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
24
- .multipliedBy(new classes_1.BigNumber(10).pow(decimals))
25
- .toFixed(decimalPlaces, roundingMode);
45
+ const denomAmountToChainDenomAmountToFixed = ({ value, decimals = 18, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
46
+ const number = (0, exports.denomAmountToChainDenomAmount)({ value, decimals });
47
+ if (decimalPlaces === undefined) {
48
+ return number.toFixed();
49
+ }
50
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
51
+ };
26
52
  exports.denomAmountToChainDenomAmountToFixed = denomAmountToChainDenomAmountToFixed;
27
53
  /**
28
54
  * Amount that the chain returns is in the x * 10^(quoteDecimals) format
29
55
  * where x is a human readable number
30
56
  */
31
- const denomAmountFromChainDenomAmount = ({ value, decimals = 18, }) => new classes_1.BigNumber(value).dividedBy(new classes_1.BigNumber(10).pow(decimals));
57
+ const denomAmountFromChainDenomAmount = ({ value, decimals = 18, }) => new $BigNumber(value).dividedBy(new $BigNumber(10).pow(decimals));
32
58
  exports.denomAmountFromChainDenomAmount = denomAmountFromChainDenomAmount;
33
59
  /**
34
60
  *
35
61
  * Amount that the chain returns is in the x * 10^(quoteDecimals) format
36
62
  * where x is a human readable number stringified
37
63
  */
38
- const denomAmountFromChainDenomAmountToFixed = ({ value, decimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
39
- .dividedBy(new classes_1.BigNumber(10).pow(decimals))
40
- .toFixed(decimalPlaces, roundingMode);
64
+ const denomAmountFromChainDenomAmountToFixed = ({ value, decimals = 18, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
65
+ const number = (0, exports.denomAmountFromChainDenomAmount)({ value, decimals });
66
+ if (decimalPlaces === undefined) {
67
+ return number.toFixed();
68
+ }
69
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
70
+ };
41
71
  exports.denomAmountFromChainDenomAmountToFixed = denomAmountFromChainDenomAmountToFixed;
42
72
  /**
43
73
  * Amount that the chain requires is in the x * 10^(quoteDecimals) format
44
74
  * where x is a human readable number
45
75
  */
46
- const derivativeMarginToChainMargin = ({ value, quoteDecimals = 18, }) => new classes_1.BigNumber(value).multipliedBy(new classes_1.BigNumber(10).pow(quoteDecimals));
76
+ const derivativeMarginToChainMargin = ({ value, quoteDecimals = 18, }) => new $BigNumber(value).multipliedBy(new $BigNumber(10).pow(quoteDecimals));
47
77
  exports.derivativeMarginToChainMargin = derivativeMarginToChainMargin;
48
78
  /**
49
79
  * Amount that the chain requires is in the x * 10^(quoteDecimals) format
50
80
  * where x is a human readable number stringified
51
81
  */
52
- const derivativeMarginToChainMarginToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
53
- .multipliedBy(new classes_1.BigNumber(10).pow(quoteDecimals))
54
- .toFixed(decimalPlaces, roundingMode);
82
+ const derivativeMarginToChainMarginToFixed = ({ value, quoteDecimals = 18, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
83
+ const number = (0, exports.derivativeMarginToChainMargin)({ value, quoteDecimals });
84
+ if (decimalPlaces === undefined) {
85
+ return number.toFixed();
86
+ }
87
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
88
+ };
55
89
  exports.derivativeMarginToChainMarginToFixed = derivativeMarginToChainMarginToFixed;
56
90
  /**
57
91
  * Amount that the chain returns is in the x * 10^(quoteDecimals) format
58
92
  * where x is a human readable number
59
93
  */
60
- const derivativeMarginFromChainMargin = ({ value, quoteDecimals = 18, }) => new classes_1.BigNumber(value).dividedBy(new classes_1.BigNumber(10).pow(quoteDecimals));
94
+ const derivativeMarginFromChainMargin = ({ value, quoteDecimals = 18, }) => new $BigNumber(value).dividedBy(new $BigNumber(10).pow(quoteDecimals));
61
95
  exports.derivativeMarginFromChainMargin = derivativeMarginFromChainMargin;
62
96
  /**
63
97
  * Amount that the chain returns is in the x * 10^(quoteDecimals) format
64
98
  * where x is a human readable number
65
99
  */
66
- const derivativeMarginFromChainMarginToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
67
- .dividedBy(new classes_1.BigNumber(10).pow(quoteDecimals))
68
- .toFixed(decimalPlaces, roundingMode);
100
+ const derivativeMarginFromChainMarginToFixed = ({ value, quoteDecimals = 18, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
101
+ const number = (0, exports.derivativeMarginFromChainMargin)({ value, quoteDecimals });
102
+ if (decimalPlaces === undefined) {
103
+ return number.toFixed();
104
+ }
105
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
106
+ };
69
107
  exports.derivativeMarginFromChainMarginToFixed = derivativeMarginFromChainMarginToFixed;
70
108
  /**
71
109
  * Amount that the chain requires is in the x * 10^(quoteDecimals) format
72
110
  * where x is a human readable number
73
111
  */
74
- const derivativePriceToChainPrice = ({ value, quoteDecimals = 18, }) => new classes_1.BigNumber(value).multipliedBy(new classes_1.BigNumber(10).pow(quoteDecimals));
112
+ const derivativePriceToChainPrice = ({ value, quoteDecimals = 18, }) => new $BigNumber(value).multipliedBy(new $BigNumber(10).pow(quoteDecimals));
75
113
  exports.derivativePriceToChainPrice = derivativePriceToChainPrice;
76
114
  /**
77
115
  * Amount that the chain requires is in the x * 10^(quoteDecimals) format
78
116
  * where x is a human readable number stringified
79
117
  */
80
- const derivativePriceToChainPriceToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
81
- .multipliedBy(new classes_1.BigNumber(10).pow(quoteDecimals))
82
- .toFixed(decimalPlaces, roundingMode);
118
+ const derivativePriceToChainPriceToFixed = ({ value, quoteDecimals = 18, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
119
+ const number = (0, exports.derivativePriceToChainPrice)({ value, quoteDecimals });
120
+ if (decimalPlaces === undefined) {
121
+ return number.toFixed();
122
+ }
123
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
124
+ };
83
125
  exports.derivativePriceToChainPriceToFixed = derivativePriceToChainPriceToFixed;
84
126
  /**
85
127
  * Amount that the chain returns is in the x * 10^(quoteDecimals) format
86
128
  * where x is a human readable number
87
129
  */
88
- const derivativePriceFromChainPrice = ({ value, quoteDecimals = 18, }) => new classes_1.BigNumber(value).dividedBy(new classes_1.BigNumber(10).pow(quoteDecimals));
130
+ const derivativePriceFromChainPrice = ({ value, quoteDecimals = 18, }) => new $BigNumber(value).dividedBy(new $BigNumber(10).pow(quoteDecimals));
89
131
  exports.derivativePriceFromChainPrice = derivativePriceFromChainPrice;
90
132
  /**
91
133
  * Amount that the chain returns is in the x * 10^(quoteDecimals) format
92
134
  * where x is a human readable number stringified
93
135
  */
94
- const derivativePriceFromChainPriceToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
95
- .dividedBy(new classes_1.BigNumber(10).pow(quoteDecimals))
96
- .toFixed(decimalPlaces, roundingMode);
136
+ const derivativePriceFromChainPriceToFixed = ({ value, quoteDecimals = 18, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
137
+ const number = (0, exports.derivativePriceFromChainPrice)({ value, quoteDecimals });
138
+ if (decimalPlaces === undefined) {
139
+ return number.toFixed();
140
+ }
141
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
142
+ };
97
143
  exports.derivativePriceFromChainPriceToFixed = derivativePriceFromChainPriceToFixed;
98
144
  /**
99
145
  * Amount that the chain requires is in the x format
100
146
  * where x is a human readable number
101
147
  */
102
- const derivativeQuantityToChainQuantity = ({ value, }) => new classes_1.BigNumber(value);
148
+ const derivativeQuantityToChainQuantity = ({ value, }) => new $BigNumber(value);
103
149
  exports.derivativeQuantityToChainQuantity = derivativeQuantityToChainQuantity;
104
150
  /**
105
151
  * Amount that the chain requires is in the x format
106
152
  * where x is a human readable number stringified
107
153
  */
108
- const derivativeQuantityToChainQuantityToFixed = ({ value, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value).toFixed(decimalPlaces, roundingMode);
154
+ const derivativeQuantityToChainQuantityToFixed = ({ value, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
155
+ const number = (0, exports.derivativeQuantityToChainQuantity)({ value });
156
+ if (decimalPlaces === undefined) {
157
+ return number.toFixed();
158
+ }
159
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
160
+ };
109
161
  exports.derivativeQuantityToChainQuantityToFixed = derivativeQuantityToChainQuantityToFixed;
162
+ /**
163
+ * Amount that the chain requires is in the x format
164
+ * where x is a human readable number
165
+ */
166
+ const derivativeQuantityFromChainQuantity = ({ value, }) => new $BigNumber(value);
167
+ exports.derivativeQuantityFromChainQuantity = derivativeQuantityFromChainQuantity;
168
+ /**
169
+ * Amount that the chain requires is in the x format
170
+ * where x is a human readable number stringified
171
+ */
172
+ const derivativeQuantityFromChainQuantityToFixed = ({ value, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
173
+ const number = (0, exports.derivativeQuantityFromChainQuantity)({ value });
174
+ if (decimalPlaces === undefined) {
175
+ return number.toFixed();
176
+ }
177
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
178
+ };
179
+ exports.derivativeQuantityFromChainQuantityToFixed = derivativeQuantityFromChainQuantityToFixed;
110
180
  /**
111
181
  * Amount that the chain requires is in the x / 10^(quoteDecimals - baseDecimals) format
112
182
  * where x is a human readable number
113
183
  */
114
- const spotPriceToChainPrice = ({ value, baseDecimals = 18, quoteDecimals = 6, }) => new classes_1.BigNumber(value).multipliedBy(new classes_1.BigNumber(10).pow(new classes_1.BigNumber(quoteDecimals).minus(baseDecimals)));
184
+ const spotPriceToChainPrice = ({ value, baseDecimals = 18, quoteDecimals = 6, }) => new $BigNumber(value).multipliedBy(new $BigNumber(10).pow(new $BigNumber(quoteDecimals).minus(baseDecimals)));
115
185
  exports.spotPriceToChainPrice = spotPriceToChainPrice;
116
186
  /**
117
187
  * Amount that the chain requires is in the x / 10^(quoteDecimals - baseDecimals) format
118
188
  * where x is a human readable number stringified
119
189
  */
120
- const spotPriceToChainPriceToFixed = ({ value, baseDecimals = 18, quoteDecimals = 6, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
121
- .multipliedBy(new classes_1.BigNumber(10).pow(new classes_1.BigNumber(quoteDecimals).minus(baseDecimals)))
122
- .toFixed(decimalPlaces, roundingMode);
190
+ const spotPriceToChainPriceToFixed = ({ value, baseDecimals = 18, quoteDecimals = 6, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
191
+ const number = (0, exports.spotPriceToChainPrice)({ value, baseDecimals, quoteDecimals });
192
+ if (decimalPlaces === undefined) {
193
+ return number.toFixed();
194
+ }
195
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
196
+ };
123
197
  exports.spotPriceToChainPriceToFixed = spotPriceToChainPriceToFixed;
124
198
  /**
125
199
  * Amount that the chain returns is in the x / 10^(quoteDecimals - baseDecimals) format
126
200
  * where x is a human readable number
127
201
  */
128
- const spotPriceFromChainPrice = ({ value, baseDecimals = 18, quoteDecimals = 6, }) => new classes_1.BigNumber(value).dividedBy(new classes_1.BigNumber(10).pow(new classes_1.BigNumber(quoteDecimals).minus(baseDecimals)));
202
+ const spotPriceFromChainPrice = ({ value, baseDecimals = 18, quoteDecimals = 6, }) => new $BigNumber(value).dividedBy(new $BigNumber(10).pow(new $BigNumber(quoteDecimals).minus(baseDecimals)));
129
203
  exports.spotPriceFromChainPrice = spotPriceFromChainPrice;
130
204
  /**
131
205
  * Amount that the chain returns is in the x / 10^(quoteDecimals - baseDecimals) format
132
206
  * where x is a human readable number stringified
133
207
  */
134
- const spotPriceFromChainPriceToFixed = ({ value, baseDecimals = 18, quoteDecimals = 6, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
135
- .dividedBy(new classes_1.BigNumber(10).pow(new classes_1.BigNumber(quoteDecimals).minus(baseDecimals)))
136
- .toFixed(decimalPlaces, roundingMode);
208
+ const spotPriceFromChainPriceToFixed = ({ value, baseDecimals = 18, quoteDecimals = 6, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
209
+ const number = (0, exports.spotPriceFromChainPrice)({ value, baseDecimals, quoteDecimals });
210
+ if (decimalPlaces === undefined) {
211
+ return number.toFixed();
212
+ }
213
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
214
+ };
137
215
  exports.spotPriceFromChainPriceToFixed = spotPriceFromChainPriceToFixed;
138
216
  /**
139
217
  * Amount that the chain requires is in the x * 10^(baseDecimals) format
140
218
  * where x is a human readable number
141
219
  */
142
- const spotQuantityToChainQuantity = ({ value, baseDecimals = 18, }) => new classes_1.BigNumber(value).multipliedBy(new classes_1.BigNumber(10).pow(baseDecimals));
220
+ const spotQuantityToChainQuantity = ({ value, baseDecimals = 18, }) => new $BigNumber(value).multipliedBy(new $BigNumber(10).pow(baseDecimals));
143
221
  exports.spotQuantityToChainQuantity = spotQuantityToChainQuantity;
144
222
  /**
145
223
  * Amount that the chain requires is in the x * 10^(baseDecimals) format
146
224
  * where x is a human readable number
147
225
  */
148
- const spotQuantityToChainQuantityToFixed = ({ value, baseDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
149
- .multipliedBy(new classes_1.BigNumber(10).pow(baseDecimals))
150
- .toFixed(decimalPlaces, roundingMode);
226
+ const spotQuantityToChainQuantityToFixed = ({ value, baseDecimals = 18, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
227
+ const number = (0, exports.spotQuantityToChainQuantity)({
228
+ value,
229
+ baseDecimals,
230
+ });
231
+ if (decimalPlaces === undefined) {
232
+ return number.toFixed();
233
+ }
234
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
235
+ };
151
236
  exports.spotQuantityToChainQuantityToFixed = spotQuantityToChainQuantityToFixed;
152
237
  /**
153
238
  * Amount that the chain returns is in the x * 10^(baseDecimals) format
154
239
  * where x is a human readable number
155
240
  */
156
- const spotQuantityFromChainQuantity = ({ value, baseDecimals = 18, }) => new classes_1.BigNumber(value).multipliedBy(new classes_1.BigNumber(10).pow(baseDecimals));
241
+ const spotQuantityFromChainQuantity = ({ value, baseDecimals = 18, }) => new $BigNumber(value).multipliedBy(new $BigNumber(10).pow(baseDecimals));
157
242
  exports.spotQuantityFromChainQuantity = spotQuantityFromChainQuantity;
158
243
  /**
159
244
  * Amount that the chain returns is in the x * 10^(baseDecimals) format
160
245
  * where x is a human readable number
161
246
  */
162
- const spotQuantityFromChainQuantityToFixed = ({ value, baseDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => new classes_1.BigNumber(value)
163
- .multipliedBy(new classes_1.BigNumber(10).pow(baseDecimals))
164
- .toFixed(decimalPlaces, roundingMode);
247
+ const spotQuantityFromChainQuantityToFixed = ({ value, baseDecimals = 18, decimalPlaces = undefined, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => {
248
+ const number = (0, exports.spotQuantityFromChainQuantity)({
249
+ value,
250
+ baseDecimals,
251
+ });
252
+ if (decimalPlaces === undefined) {
253
+ return number.toFixed();
254
+ }
255
+ return number.toFixed((0, exports.getSignificantDecimalsFromNumber)(number), roundingMode);
256
+ };
165
257
  exports.spotQuantityFromChainQuantityToFixed = spotQuantityFromChainQuantityToFixed;
166
258
  //# sourceMappingURL=numbers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"numbers.js","sourceRoot":"","sources":["../src/numbers.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;AAErC;;;;;GAKG;AACI,MAAM,mCAAmC,GAAG,CACjD,KAAkC,EAClC,EAAE,CAAC,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,mBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAA;AAFjD,QAAA,mCAAmC,uCAEc;AAE9D;;;GAGG;AACI,MAAM,6BAA6B,GAAG,CAAC,EAC5C,KAAK,EACL,QAAQ,GAAG,EAAE,GAId,EAAE,EAAE,CAAC,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,mBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAA;AAN3D,QAAA,6BAA6B,iCAM8B;AAExE;;;GAGG;AACI,MAAM,oCAAoC,GAAG,CAAC,EACnD,KAAK,EACL,QAAQ,GAAG,EAAE,EACb,aAAa,GAAG,CAAC,EACjB,YAAY,GAAG,mBAAS,CAAC,UAAU,GAMpC,EAAE,EAAE,CACH,IAAI,mBAAS,CAAC,KAAK,CAAC;KACjB,YAAY,CAAC,IAAI,mBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;KAC7C,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;AAb5B,QAAA,oCAAoC,wCAaR;AAEzC;;;GAGG;AACI,MAAM,+BAA+B,GAAG,CAAC,EAC9C,KAAK,EACL,QAAQ,GAAG,EAAE,GAId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AY,CAAC,CAAA;AAC/E,CAAC,CAAA;AArBY,QAAA,oCAAoC,wCAqBhD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@injectivelabs/utils",
3
3
  "description": "List of utils and helper functions that can be reused throughout Injective's projects.",
4
- "version": "0.0.58",
4
+ "version": "0.0.62",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -27,13 +27,13 @@
27
27
  "start": "node dist/index.js"
28
28
  },
29
29
  "dependencies": {
30
- "@injectivelabs/exceptions": "^0.0.42",
31
- "@injectivelabs/ts-types": "^0.0.38",
30
+ "@injectivelabs/exceptions": "^0.0.44",
31
+ "@injectivelabs/ts-types": "^0.0.40",
32
32
  "axios": "^0.21.1",
33
33
  "bignumber.js": "^9.0.1",
34
34
  "link-module-alias": "^1.2.0",
35
35
  "shx": "^0.3.2",
36
36
  "store2": "^2.12.0"
37
37
  },
38
- "gitHead": "bc0ec90c28bdf3e990165c64af39a91b2895a3b0"
38
+ "gitHead": "3266b85e0331fd9f2bf87f02efc9cf90e7ce85a2"
39
39
  }