@drift-labs/sdk 2.108.0-beta.11 → 2.108.0-beta.12
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/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.108.0-beta.
|
|
1
|
+
2.108.0-beta.12
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToNumber = void 0;
|
|
3
|
+
exports.convertToBN = exports.convertToNumber = void 0;
|
|
4
|
+
const __1 = require("../");
|
|
4
5
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
5
6
|
const convertToNumber = (bigNumber, precision = numericConstants_1.PRICE_PRECISION) => {
|
|
6
7
|
if (!bigNumber)
|
|
@@ -9,3 +10,12 @@ const convertToNumber = (bigNumber, precision = numericConstants_1.PRICE_PRECISI
|
|
|
9
10
|
bigNumber.mod(precision).toNumber() / precision.toNumber());
|
|
10
11
|
};
|
|
11
12
|
exports.convertToNumber = convertToNumber;
|
|
13
|
+
function convertToBN(value, precision) {
|
|
14
|
+
// Get the whole part using Math.floor
|
|
15
|
+
const wholePart = Math.floor(value);
|
|
16
|
+
// Get decimal part by subtracting whole part and multiplying by precision
|
|
17
|
+
const decimalPart = Math.round((value - wholePart) * precision.toNumber());
|
|
18
|
+
// Combine: wholePart * PRECISION + decimalPart
|
|
19
|
+
return new __1.BN(wholePart).mul(precision).add(new __1.BN(decimalPart));
|
|
20
|
+
}
|
|
21
|
+
exports.convertToBN = convertToBN;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertToNumber = void 0;
|
|
3
|
+
exports.convertToBN = exports.convertToNumber = void 0;
|
|
4
|
+
const __1 = require("../");
|
|
4
5
|
const numericConstants_1 = require("../constants/numericConstants");
|
|
5
6
|
const convertToNumber = (bigNumber, precision = numericConstants_1.PRICE_PRECISION) => {
|
|
6
7
|
if (!bigNumber)
|
|
@@ -9,3 +10,12 @@ const convertToNumber = (bigNumber, precision = numericConstants_1.PRICE_PRECISI
|
|
|
9
10
|
bigNumber.mod(precision).toNumber() / precision.toNumber());
|
|
10
11
|
};
|
|
11
12
|
exports.convertToNumber = convertToNumber;
|
|
13
|
+
function convertToBN(value, precision) {
|
|
14
|
+
// Get the whole part using Math.floor
|
|
15
|
+
const wholePart = Math.floor(value);
|
|
16
|
+
// Get decimal part by subtracting whole part and multiplying by precision
|
|
17
|
+
const decimalPart = Math.round((value - wholePart) * precision.toNumber());
|
|
18
|
+
// Combine: wholePart * PRECISION + decimalPart
|
|
19
|
+
return new __1.BN(wholePart).mul(precision).add(new __1.BN(decimalPart));
|
|
20
|
+
}
|
|
21
|
+
exports.convertToBN = convertToBN;
|
package/package.json
CHANGED
package/src/math/conversion.ts
CHANGED
|
@@ -11,3 +11,14 @@ export const convertToNumber = (
|
|
|
11
11
|
bigNumber.mod(precision).toNumber() / precision.toNumber()
|
|
12
12
|
);
|
|
13
13
|
};
|
|
14
|
+
|
|
15
|
+
export function convertToBN(value: number, precision: BN): BN {
|
|
16
|
+
// Get the whole part using Math.floor
|
|
17
|
+
const wholePart = Math.floor(value);
|
|
18
|
+
|
|
19
|
+
// Get decimal part by subtracting whole part and multiplying by precision
|
|
20
|
+
const decimalPart = Math.round((value - wholePart) * precision.toNumber());
|
|
21
|
+
|
|
22
|
+
// Combine: wholePart * PRECISION + decimalPart
|
|
23
|
+
return new BN(wholePart).mul(precision).add(new BN(decimalPart));
|
|
24
|
+
}
|