@injectivelabs/utils 0.0.58 → 0.0.59
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 +23 -0
- package/dist/numbers.d.ts.map +1 -1
- package/dist/numbers.js +32 -32
- package/dist/numbers.js.map +1 -1
- package/package.json +2 -2
package/dist/numbers.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ import { BigNumber } from './classes';
|
|
|
6
6
|
* to get a workable amount
|
|
7
7
|
*/
|
|
8
8
|
export declare const denomAmountFromGrpcChainDenomAmount: (value: string | number | BigNumber) => BigNumber;
|
|
9
|
+
/**
|
|
10
|
+
* On chain amounts broadcasted to a sentry directly using the
|
|
11
|
+
* gRPC API should be passed with an extra decimal point
|
|
12
|
+
* 18 places from the beginning, so we need to add it
|
|
13
|
+
* to get a workable amount
|
|
14
|
+
*/
|
|
15
|
+
export declare const denomAmountToGrpcChainDenomAmount: (value: string | number | BigNumber) => BigNumber;
|
|
9
16
|
/**
|
|
10
17
|
* Amount that the chain requires is in the x * 10^(quoteDecimals) format
|
|
11
18
|
* where x is a human readable number
|
|
@@ -131,6 +138,22 @@ export declare const derivativeQuantityToChainQuantityToFixed: ({ value, decimal
|
|
|
131
138
|
decimalPlaces?: number | undefined;
|
|
132
139
|
roundingMode?: BigNumber.RoundingMode | undefined;
|
|
133
140
|
}) => string;
|
|
141
|
+
/**
|
|
142
|
+
* Amount that the chain requires is in the x format
|
|
143
|
+
* where x is a human readable number
|
|
144
|
+
*/
|
|
145
|
+
export declare const derivativeQuantityFromChainQuantity: ({ value, }: {
|
|
146
|
+
value: number | string | BigNumber;
|
|
147
|
+
}) => BigNumber;
|
|
148
|
+
/**
|
|
149
|
+
* Amount that the chain requires is in the x format
|
|
150
|
+
* where x is a human readable number stringified
|
|
151
|
+
*/
|
|
152
|
+
export declare const derivativeQuantityFromChainQuantityToFixed: ({ value, decimalPlaces, roundingMode, }: {
|
|
153
|
+
value: number | string | BigNumber;
|
|
154
|
+
decimalPlaces?: number | undefined;
|
|
155
|
+
roundingMode?: BigNumber.RoundingMode | undefined;
|
|
156
|
+
}) => string;
|
|
134
157
|
/**
|
|
135
158
|
* Amount that the chain requires is in the x / 10^(quoteDecimals - baseDecimals) format
|
|
136
159
|
* where x is a human readable number
|
package/dist/numbers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../src/numbers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,UACvC,MAAM,GAAG,MAAM,GAAG,SAAS,cAC0B,CAAA;AAE9D;;;GAGG;AACH,eAAO,MAAM,6BAA6B;WAIjC,MAAM,GAAG,MAAM,GAAG,SAAS;;eAEoC,CAAA;AAExE;;;GAGG;AACH,eAAO,MAAM,oCAAoC;WAMxC,MAAM,GAAG,MAAM,GAAG,SAAS;;;;
|
|
1
|
+
{"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../src/numbers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,UACvC,MAAM,GAAG,MAAM,GAAG,SAAS,cAC0B,CAAA;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,UACrC,MAAM,GAAG,MAAM,GAAG,SAAS,cAC6B,CAAA;AAEjE;;;GAGG;AACH,eAAO,MAAM,6BAA6B;WAIjC,MAAM,GAAG,MAAM,GAAG,SAAS;;eAEoC,CAAA;AAExE;;;GAGG;AACH,eAAO,MAAM,oCAAoC;WAMxC,MAAM,GAAG,MAAM,GAAG,SAAS;;;;YAQjC,CAAA;AAEH;;;GAGG;AACH,eAAO,MAAM,+BAA+B;WAInC,MAAM,GAAG,MAAM,GAAG,SAAS;;eAEiC,CAAA;AACrE;;;;GAIG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zB,MAAM,GAAG,MAAM,GAAG,SAAS;;;eAMjC,CAAA;AAEH;;;GAGG;AACH,eAAO,MAAM,4BAA4B;WAOhC,MAAM,GAAG,MAAM,GAAG,SAAS;;;;;YASjC,CAAA;AAEH;;;GAGG;AACH,eAAO,MAAM,uBAAuB;WAK3B,MAAM,GAAG,MAAM,GAAG,SAAS;;;eAMjC,CAAA;AAEH;;;GAGG;AACH,eAAO,MAAM,8BAA8B;WAOlC,MAAM,GAAG,MAAM,GAAG,SAAS;;;;;YASjC,CAAA;AAEH;;;GAGG;AACH,eAAO,MAAM,2BAA2B;WAI/B,MAAM,GAAG,MAAM,GAAG,SAAS;;eAEwC,CAAA;AAE5E;;;GAGG;AACH,eAAO,MAAM,kCAAkC;WAMtC,MAAM,GAAG,MAAM,GAAG,SAAS;;;;YAQjC,CAAA;AAEH;;;GAGG;AACH,eAAO,MAAM,6BAA6B;WAIjC,MAAM,GAAG,MAAM,GAAG,SAAS;;eAEwC,CAAA;AAE5E;;;GAGG;AACH,eAAO,MAAM,oCAAoC;WAMxC,MAAM,GAAG,MAAM,GAAG,SAAS;;;;YAQjC,CAAA"}
|
package/dist/numbers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { 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 = void 0;
|
|
4
4
|
const classes_1 = require("./classes");
|
|
5
5
|
/**
|
|
6
6
|
* On chain amounts queried from a sentry using the
|
|
@@ -10,6 +10,14 @@ const classes_1 = require("./classes");
|
|
|
10
10
|
*/
|
|
11
11
|
const denomAmountFromGrpcChainDenomAmount = (value) => new classes_1.BigNumber(value).dividedBy(new classes_1.BigNumber(10).pow(18));
|
|
12
12
|
exports.denomAmountFromGrpcChainDenomAmount = denomAmountFromGrpcChainDenomAmount;
|
|
13
|
+
/**
|
|
14
|
+
* On chain amounts broadcasted to a sentry directly using the
|
|
15
|
+
* gRPC API should be passed with an extra decimal point
|
|
16
|
+
* 18 places from the beginning, so we need to add it
|
|
17
|
+
* to get a workable amount
|
|
18
|
+
*/
|
|
19
|
+
const denomAmountToGrpcChainDenomAmount = (value) => new classes_1.BigNumber(value).multipliedBy(new classes_1.BigNumber(10).pow(18));
|
|
20
|
+
exports.denomAmountToGrpcChainDenomAmount = denomAmountToGrpcChainDenomAmount;
|
|
13
21
|
/**
|
|
14
22
|
* Amount that the chain requires is in the x * 10^(quoteDecimals) format
|
|
15
23
|
* where x is a human readable number
|
|
@@ -20,9 +28,7 @@ exports.denomAmountToChainDenomAmount = denomAmountToChainDenomAmount;
|
|
|
20
28
|
* Amount that the chain returns is in the x * 10^(quoteDecimals) format
|
|
21
29
|
* where x is a human readable number
|
|
22
30
|
*/
|
|
23
|
-
const denomAmountToChainDenomAmountToFixed = ({ value, decimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
24
|
-
.multipliedBy(new classes_1.BigNumber(10).pow(decimals))
|
|
25
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
31
|
+
const denomAmountToChainDenomAmountToFixed = ({ value, decimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.denomAmountToChainDenomAmount)({ value, decimals }).toFixed(decimalPlaces, roundingMode);
|
|
26
32
|
exports.denomAmountToChainDenomAmountToFixed = denomAmountToChainDenomAmountToFixed;
|
|
27
33
|
/**
|
|
28
34
|
* Amount that the chain returns is in the x * 10^(quoteDecimals) format
|
|
@@ -35,9 +41,7 @@ exports.denomAmountFromChainDenomAmount = denomAmountFromChainDenomAmount;
|
|
|
35
41
|
* Amount that the chain returns is in the x * 10^(quoteDecimals) format
|
|
36
42
|
* where x is a human readable number stringified
|
|
37
43
|
*/
|
|
38
|
-
const denomAmountFromChainDenomAmountToFixed = ({ value, decimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
39
|
-
.dividedBy(new classes_1.BigNumber(10).pow(decimals))
|
|
40
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
44
|
+
const denomAmountFromChainDenomAmountToFixed = ({ value, decimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.denomAmountFromChainDenomAmount)({ value, decimals }).toFixed(decimalPlaces, roundingMode);
|
|
41
45
|
exports.denomAmountFromChainDenomAmountToFixed = denomAmountFromChainDenomAmountToFixed;
|
|
42
46
|
/**
|
|
43
47
|
* Amount that the chain requires is in the x * 10^(quoteDecimals) format
|
|
@@ -49,9 +53,7 @@ exports.derivativeMarginToChainMargin = derivativeMarginToChainMargin;
|
|
|
49
53
|
* Amount that the chain requires is in the x * 10^(quoteDecimals) format
|
|
50
54
|
* where x is a human readable number stringified
|
|
51
55
|
*/
|
|
52
|
-
const derivativeMarginToChainMarginToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
53
|
-
.multipliedBy(new classes_1.BigNumber(10).pow(quoteDecimals))
|
|
54
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
56
|
+
const derivativeMarginToChainMarginToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.derivativeMarginToChainMargin)({ value, quoteDecimals }).toFixed(decimalPlaces, roundingMode);
|
|
55
57
|
exports.derivativeMarginToChainMarginToFixed = derivativeMarginToChainMarginToFixed;
|
|
56
58
|
/**
|
|
57
59
|
* Amount that the chain returns is in the x * 10^(quoteDecimals) format
|
|
@@ -63,9 +65,7 @@ exports.derivativeMarginFromChainMargin = derivativeMarginFromChainMargin;
|
|
|
63
65
|
* Amount that the chain returns is in the x * 10^(quoteDecimals) format
|
|
64
66
|
* where x is a human readable number
|
|
65
67
|
*/
|
|
66
|
-
const derivativeMarginFromChainMarginToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
67
|
-
.dividedBy(new classes_1.BigNumber(10).pow(quoteDecimals))
|
|
68
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
68
|
+
const derivativeMarginFromChainMarginToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.derivativeMarginFromChainMargin)({ value, quoteDecimals }).toFixed(decimalPlaces, roundingMode);
|
|
69
69
|
exports.derivativeMarginFromChainMarginToFixed = derivativeMarginFromChainMarginToFixed;
|
|
70
70
|
/**
|
|
71
71
|
* Amount that the chain requires is in the x * 10^(quoteDecimals) format
|
|
@@ -77,9 +77,7 @@ exports.derivativePriceToChainPrice = derivativePriceToChainPrice;
|
|
|
77
77
|
* Amount that the chain requires is in the x * 10^(quoteDecimals) format
|
|
78
78
|
* where x is a human readable number stringified
|
|
79
79
|
*/
|
|
80
|
-
const derivativePriceToChainPriceToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
81
|
-
.multipliedBy(new classes_1.BigNumber(10).pow(quoteDecimals))
|
|
82
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
80
|
+
const derivativePriceToChainPriceToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.derivativePriceToChainPrice)({ value, quoteDecimals }).toFixed(decimalPlaces, roundingMode);
|
|
83
81
|
exports.derivativePriceToChainPriceToFixed = derivativePriceToChainPriceToFixed;
|
|
84
82
|
/**
|
|
85
83
|
* Amount that the chain returns is in the x * 10^(quoteDecimals) format
|
|
@@ -91,9 +89,7 @@ exports.derivativePriceFromChainPrice = derivativePriceFromChainPrice;
|
|
|
91
89
|
* Amount that the chain returns is in the x * 10^(quoteDecimals) format
|
|
92
90
|
* where x is a human readable number stringified
|
|
93
91
|
*/
|
|
94
|
-
const derivativePriceFromChainPriceToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
95
|
-
.dividedBy(new classes_1.BigNumber(10).pow(quoteDecimals))
|
|
96
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
92
|
+
const derivativePriceFromChainPriceToFixed = ({ value, quoteDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.derivativePriceFromChainPrice)({ value, quoteDecimals }).toFixed(decimalPlaces, roundingMode);
|
|
97
93
|
exports.derivativePriceFromChainPriceToFixed = derivativePriceFromChainPriceToFixed;
|
|
98
94
|
/**
|
|
99
95
|
* Amount that the chain requires is in the x format
|
|
@@ -105,8 +101,20 @@ exports.derivativeQuantityToChainQuantity = derivativeQuantityToChainQuantity;
|
|
|
105
101
|
* Amount that the chain requires is in the x format
|
|
106
102
|
* where x is a human readable number stringified
|
|
107
103
|
*/
|
|
108
|
-
const derivativeQuantityToChainQuantityToFixed = ({ value, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
104
|
+
const derivativeQuantityToChainQuantityToFixed = ({ value, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.derivativeQuantityToChainQuantity)({ value }).toFixed(decimalPlaces, roundingMode);
|
|
109
105
|
exports.derivativeQuantityToChainQuantityToFixed = derivativeQuantityToChainQuantityToFixed;
|
|
106
|
+
/**
|
|
107
|
+
* Amount that the chain requires is in the x format
|
|
108
|
+
* where x is a human readable number
|
|
109
|
+
*/
|
|
110
|
+
const derivativeQuantityFromChainQuantity = ({ value, }) => new classes_1.BigNumber(value);
|
|
111
|
+
exports.derivativeQuantityFromChainQuantity = derivativeQuantityFromChainQuantity;
|
|
112
|
+
/**
|
|
113
|
+
* Amount that the chain requires is in the x format
|
|
114
|
+
* where x is a human readable number stringified
|
|
115
|
+
*/
|
|
116
|
+
const derivativeQuantityFromChainQuantityToFixed = ({ value, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.derivativeQuantityFromChainQuantity)({ value }).toFixed(decimalPlaces, roundingMode);
|
|
117
|
+
exports.derivativeQuantityFromChainQuantityToFixed = derivativeQuantityFromChainQuantityToFixed;
|
|
110
118
|
/**
|
|
111
119
|
* Amount that the chain requires is in the x / 10^(quoteDecimals - baseDecimals) format
|
|
112
120
|
* where x is a human readable number
|
|
@@ -117,9 +125,7 @@ exports.spotPriceToChainPrice = spotPriceToChainPrice;
|
|
|
117
125
|
* Amount that the chain requires is in the x / 10^(quoteDecimals - baseDecimals) format
|
|
118
126
|
* where x is a human readable number stringified
|
|
119
127
|
*/
|
|
120
|
-
const spotPriceToChainPriceToFixed = ({ value, baseDecimals = 18, quoteDecimals = 6, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
121
|
-
.multipliedBy(new classes_1.BigNumber(10).pow(new classes_1.BigNumber(quoteDecimals).minus(baseDecimals)))
|
|
122
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
128
|
+
const spotPriceToChainPriceToFixed = ({ value, baseDecimals = 18, quoteDecimals = 6, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.spotPriceToChainPrice)({ value, baseDecimals, quoteDecimals }).toFixed(decimalPlaces, roundingMode);
|
|
123
129
|
exports.spotPriceToChainPriceToFixed = spotPriceToChainPriceToFixed;
|
|
124
130
|
/**
|
|
125
131
|
* Amount that the chain returns is in the x / 10^(quoteDecimals - baseDecimals) format
|
|
@@ -131,9 +137,7 @@ exports.spotPriceFromChainPrice = spotPriceFromChainPrice;
|
|
|
131
137
|
* Amount that the chain returns is in the x / 10^(quoteDecimals - baseDecimals) format
|
|
132
138
|
* where x is a human readable number stringified
|
|
133
139
|
*/
|
|
134
|
-
const spotPriceFromChainPriceToFixed = ({ value, baseDecimals = 18, quoteDecimals = 6, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
135
|
-
.dividedBy(new classes_1.BigNumber(10).pow(new classes_1.BigNumber(quoteDecimals).minus(baseDecimals)))
|
|
136
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
140
|
+
const spotPriceFromChainPriceToFixed = ({ value, baseDecimals = 18, quoteDecimals = 6, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.spotPriceFromChainPrice)({ value, baseDecimals, quoteDecimals }).toFixed(decimalPlaces, roundingMode);
|
|
137
141
|
exports.spotPriceFromChainPriceToFixed = spotPriceFromChainPriceToFixed;
|
|
138
142
|
/**
|
|
139
143
|
* Amount that the chain requires is in the x * 10^(baseDecimals) format
|
|
@@ -145,9 +149,7 @@ exports.spotQuantityToChainQuantity = spotQuantityToChainQuantity;
|
|
|
145
149
|
* Amount that the chain requires is in the x * 10^(baseDecimals) format
|
|
146
150
|
* where x is a human readable number
|
|
147
151
|
*/
|
|
148
|
-
const spotQuantityToChainQuantityToFixed = ({ value, baseDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
149
|
-
.multipliedBy(new classes_1.BigNumber(10).pow(baseDecimals))
|
|
150
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
152
|
+
const spotQuantityToChainQuantityToFixed = ({ value, baseDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.spotQuantityToChainQuantity)({ value, baseDecimals }).toFixed(decimalPlaces, roundingMode);
|
|
151
153
|
exports.spotQuantityToChainQuantityToFixed = spotQuantityToChainQuantityToFixed;
|
|
152
154
|
/**
|
|
153
155
|
* Amount that the chain returns is in the x * 10^(baseDecimals) format
|
|
@@ -159,8 +161,6 @@ exports.spotQuantityFromChainQuantity = spotQuantityFromChainQuantity;
|
|
|
159
161
|
* Amount that the chain returns is in the x * 10^(baseDecimals) format
|
|
160
162
|
* where x is a human readable number
|
|
161
163
|
*/
|
|
162
|
-
const spotQuantityFromChainQuantityToFixed = ({ value, baseDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) =>
|
|
163
|
-
.multipliedBy(new classes_1.BigNumber(10).pow(baseDecimals))
|
|
164
|
-
.toFixed(decimalPlaces, roundingMode);
|
|
164
|
+
const spotQuantityFromChainQuantityToFixed = ({ value, baseDecimals = 18, decimalPlaces = 0, roundingMode = classes_1.BigNumber.ROUND_DOWN, }) => (0, exports.spotQuantityFromChainQuantity)({ value, baseDecimals }).toFixed(decimalPlaces, roundingMode);
|
|
165
165
|
exports.spotQuantityFromChainQuantityToFixed = spotQuantityFromChainQuantityToFixed;
|
|
166
166
|
//# sourceMappingURL=numbers.js.map
|
package/dist/numbers.js.map
CHANGED
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"numbers.js","sourceRoot":"","sources":["../src/numbers.ts"],"names":[],"mappings":";;;AAAA,uCAAqC;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,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;AAN/D,QAAA,2BAA2B,+BAMoC;AAE5E;;;GAGG;AACI,MAAM,kCAAkC,GAAG,CAAC,EACjD,KAAK,EACL,YAAY,GAAG,EAAE,EACjB,aAAa,GAAG,CAAC,EACjB,YAAY,GAAG,mBAAS,CAAC,UAAU,GAMpC,EAAE,EAAE,CACH,IAAA,mCAA2B,EAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,OAAO,CAC1D,aAAa,EACb,YAAY,CACb,CAAA;AAdU,QAAA,kCAAkC,sCAc5C;AAEH;;;GAGG;AACI,MAAM,6BAA6B,GAAG,CAAC,EAC5C,KAAK,EACL,YAAY,GAAG,EAAE,GAIlB,EAAE,EAAE,CAAC,IAAI,mBAAS,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,IAAI,mBAAS,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAA;AAN/D,QAAA,6BAA6B,iCAMkC;AAE5E;;;GAGG;AACI,MAAM,oCAAoC,GAAG,CAAC,EACnD,KAAK,EACL,YAAY,GAAG,EAAE,EACjB,aAAa,GAAG,CAAC,EACjB,YAAY,GAAG,mBAAS,CAAC,UAAU,GAMpC,EAAE,EAAE,CACH,IAAA,qCAA6B,EAAC,EAAE,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,OAAO,CAC5D,aAAa,EACb,YAAY,CACb,CAAA;AAdU,QAAA,oCAAoC,wCAc9C"}
|
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.
|
|
4
|
+
"version": "0.0.59",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"shx": "^0.3.2",
|
|
36
36
|
"store2": "^2.12.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "dcf9dfb14ce45486649915c061412ce32beb350c"
|
|
39
39
|
}
|