@drift-labs/sdk 2.136.0-beta.1 → 2.136.0-beta.2
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 +1 -1
- package/lib/browser/factory/bigNum.d.ts +2 -2
- package/lib/browser/factory/bigNum.js +20 -5
- package/lib/node/factory/bigNum.d.ts +2 -2
- package/lib/node/factory/bigNum.d.ts.map +1 -1
- package/lib/node/factory/bigNum.js +20 -5
- package/package.json +1 -1
- package/src/factory/bigNum.ts +22 -5
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.136.0-beta.
|
|
1
|
+
2.136.0-beta.2
|
|
@@ -57,7 +57,7 @@ export declare class BigNum {
|
|
|
57
57
|
* @returns
|
|
58
58
|
*/
|
|
59
59
|
print(): string;
|
|
60
|
-
prettyPrint(useTradePrecision?: boolean, precisionOverride?: number): string;
|
|
60
|
+
prettyPrint(useTradePrecision?: boolean, precisionOverride?: number, decimalOverride?: number): string;
|
|
61
61
|
/**
|
|
62
62
|
* Print and remove unnecessary trailing zeroes
|
|
63
63
|
* @returns
|
|
@@ -85,7 +85,7 @@ export declare class BigNum {
|
|
|
85
85
|
* @param precisionOverride
|
|
86
86
|
* @returns
|
|
87
87
|
*/
|
|
88
|
-
toNotional(useTradePrecision?: boolean, precisionOverride?: number): string;
|
|
88
|
+
toNotional(useTradePrecision?: boolean, precisionOverride?: number, decimalOverride?: number): string;
|
|
89
89
|
toMillified(precision?: number, rounded?: boolean, type?: 'financial' | 'scientific'): string;
|
|
90
90
|
toJSON(): {
|
|
91
91
|
val: string;
|
|
@@ -167,9 +167,24 @@ class BigNum {
|
|
|
167
167
|
printString = printString.slice(0, printString.length - 1);
|
|
168
168
|
return printString;
|
|
169
169
|
}
|
|
170
|
-
prettyPrint(useTradePrecision, precisionOverride) {
|
|
170
|
+
prettyPrint(useTradePrecision, precisionOverride, decimalOverride) {
|
|
171
171
|
const [leftSide, rightSide] = this.printShort(useTradePrecision, precisionOverride).split(BigNum.delim);
|
|
172
172
|
let formattedLeftSide = leftSide;
|
|
173
|
+
let formattedRightSide = rightSide;
|
|
174
|
+
// Apply decimal override if specified
|
|
175
|
+
if (decimalOverride !== undefined) {
|
|
176
|
+
if (decimalOverride === 0) {
|
|
177
|
+
formattedRightSide = undefined;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
// If no decimal part exists, create one with zeros
|
|
181
|
+
const currentRightSide = rightSide || '';
|
|
182
|
+
// Pad with zeros if needed or truncate if too long
|
|
183
|
+
formattedRightSide = currentRightSide
|
|
184
|
+
.padEnd(decimalOverride, '0')
|
|
185
|
+
.substring(0, decimalOverride);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
173
188
|
const isNeg = formattedLeftSide.includes('-');
|
|
174
189
|
if (isNeg) {
|
|
175
190
|
formattedLeftSide = formattedLeftSide.replace('-', '');
|
|
@@ -181,7 +196,7 @@ class BigNum {
|
|
|
181
196
|
formattedLeftSide = formattedLeftSideArray.join('');
|
|
182
197
|
index -= 3;
|
|
183
198
|
}
|
|
184
|
-
return `${isNeg ? '-' : ''}${formattedLeftSide}${
|
|
199
|
+
return `${isNeg ? '-' : ''}${formattedLeftSide}${formattedRightSide ? `${BigNum.delim}${formattedRightSide}` : ''}`;
|
|
185
200
|
}
|
|
186
201
|
/**
|
|
187
202
|
* Print and remove unnecessary trailing zeroes
|
|
@@ -338,12 +353,12 @@ class BigNum {
|
|
|
338
353
|
* @param precisionOverride
|
|
339
354
|
* @returns
|
|
340
355
|
*/
|
|
341
|
-
toNotional(useTradePrecision, precisionOverride) {
|
|
356
|
+
toNotional(useTradePrecision, precisionOverride, decimalOverride) {
|
|
342
357
|
var _a;
|
|
343
358
|
const prefix = `${this.lt(BigNum.zero()) ? `-` : ``}$`;
|
|
344
|
-
const usingCustomPrecision = true && (useTradePrecision || precisionOverride);
|
|
359
|
+
const usingCustomPrecision = true && (useTradePrecision || precisionOverride || decimalOverride);
|
|
345
360
|
let val = usingCustomPrecision
|
|
346
|
-
? this.prettyPrint(useTradePrecision, precisionOverride)
|
|
361
|
+
? this.prettyPrint(useTradePrecision, precisionOverride, decimalOverride)
|
|
347
362
|
: BigNum.fromPrint(this.toFixed(2), new anchor_1.BN(2)).prettyPrint();
|
|
348
363
|
// Append trailing zeroes out to 2 decimal places if not using custom precision
|
|
349
364
|
if (!usingCustomPrecision) {
|
|
@@ -57,7 +57,7 @@ export declare class BigNum {
|
|
|
57
57
|
* @returns
|
|
58
58
|
*/
|
|
59
59
|
print(): string;
|
|
60
|
-
prettyPrint(useTradePrecision?: boolean, precisionOverride?: number): string;
|
|
60
|
+
prettyPrint(useTradePrecision?: boolean, precisionOverride?: number, decimalOverride?: number): string;
|
|
61
61
|
/**
|
|
62
62
|
* Print and remove unnecessary trailing zeroes
|
|
63
63
|
* @returns
|
|
@@ -85,7 +85,7 @@ export declare class BigNum {
|
|
|
85
85
|
* @param precisionOverride
|
|
86
86
|
* @returns
|
|
87
87
|
*/
|
|
88
|
-
toNotional(useTradePrecision?: boolean, precisionOverride?: number): string;
|
|
88
|
+
toNotional(useTradePrecision?: boolean, precisionOverride?: number, decimalOverride?: number): string;
|
|
89
89
|
toMillified(precision?: number, rounded?: boolean, type?: 'financial' | 'scientific'): string;
|
|
90
90
|
toJSON(): {
|
|
91
91
|
val: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bigNum.d.ts","sourceRoot":"","sources":["../../../src/factory/bigNum.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,mBAAmB,CAAC;AAIvC,qBAAa,MAAM;IAClB,GAAG,EAAE,EAAE,CAAC;IACR,SAAS,EAAE,EAAE,CAAC;IAEd,MAAM,CAAC,KAAK,SAAO;IACnB,MAAM,CAAC,MAAM,SAAO;WAEN,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;gBAM5C,GAAG,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,EACzB,YA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AAQ,GACb,MAAM;IAkHF,gBAAgB,CAAC,OAAO,UAAQ,GAAG,MAAM;IAIhD;;;;;OAKG;IACI,UAAU,CAChB,iBAAiB,CAAC,EAAE,OAAO,EAC3B,iBAAiB,CAAC,EAAE,MAAM,EAC1B,eAAe,CAAC,EAAE,MAAM,GACtB,MAAM;IAyBF,WAAW,CACjB,SAAS,SAAI,EACb,OAAO,UAAQ,EACf,IAAI,GAAE,WAAW,GAAG,YAA0B,GAC5C,MAAM;IAwDF,MAAM;;;;IAON,KAAK;IAIL,KAAK;IAIZ;;;OAGG;IACI,KAAK;IAkBZ,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAIxD;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CACV,GAAG,GAAE,EAAE,GAAG,MAAM,GAAG,MAAa,EAChC,SAAS,CAAC,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM,GAC9B,MAAM;IAQT;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,EAAE,GAAG,MAAM;IAyB1D,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAIxC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;IAIxC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,EAAE,GAAG,MAAM,GAAG,MAAM;CAG5C"}
|
|
@@ -167,9 +167,24 @@ class BigNum {
|
|
|
167
167
|
printString = printString.slice(0, printString.length - 1);
|
|
168
168
|
return printString;
|
|
169
169
|
}
|
|
170
|
-
prettyPrint(useTradePrecision, precisionOverride) {
|
|
170
|
+
prettyPrint(useTradePrecision, precisionOverride, decimalOverride) {
|
|
171
171
|
const [leftSide, rightSide] = this.printShort(useTradePrecision, precisionOverride).split(BigNum.delim);
|
|
172
172
|
let formattedLeftSide = leftSide;
|
|
173
|
+
let formattedRightSide = rightSide;
|
|
174
|
+
// Apply decimal override if specified
|
|
175
|
+
if (decimalOverride !== undefined) {
|
|
176
|
+
if (decimalOverride === 0) {
|
|
177
|
+
formattedRightSide = undefined;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
// If no decimal part exists, create one with zeros
|
|
181
|
+
const currentRightSide = rightSide || '';
|
|
182
|
+
// Pad with zeros if needed or truncate if too long
|
|
183
|
+
formattedRightSide = currentRightSide
|
|
184
|
+
.padEnd(decimalOverride, '0')
|
|
185
|
+
.substring(0, decimalOverride);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
173
188
|
const isNeg = formattedLeftSide.includes('-');
|
|
174
189
|
if (isNeg) {
|
|
175
190
|
formattedLeftSide = formattedLeftSide.replace('-', '');
|
|
@@ -181,7 +196,7 @@ class BigNum {
|
|
|
181
196
|
formattedLeftSide = formattedLeftSideArray.join('');
|
|
182
197
|
index -= 3;
|
|
183
198
|
}
|
|
184
|
-
return `${isNeg ? '-' : ''}${formattedLeftSide}${
|
|
199
|
+
return `${isNeg ? '-' : ''}${formattedLeftSide}${formattedRightSide ? `${BigNum.delim}${formattedRightSide}` : ''}`;
|
|
185
200
|
}
|
|
186
201
|
/**
|
|
187
202
|
* Print and remove unnecessary trailing zeroes
|
|
@@ -338,12 +353,12 @@ class BigNum {
|
|
|
338
353
|
* @param precisionOverride
|
|
339
354
|
* @returns
|
|
340
355
|
*/
|
|
341
|
-
toNotional(useTradePrecision, precisionOverride) {
|
|
356
|
+
toNotional(useTradePrecision, precisionOverride, decimalOverride) {
|
|
342
357
|
var _a;
|
|
343
358
|
const prefix = `${this.lt(BigNum.zero()) ? `-` : ``}$`;
|
|
344
|
-
const usingCustomPrecision = true && (useTradePrecision || precisionOverride);
|
|
359
|
+
const usingCustomPrecision = true && (useTradePrecision || precisionOverride || decimalOverride);
|
|
345
360
|
let val = usingCustomPrecision
|
|
346
|
-
? this.prettyPrint(useTradePrecision, precisionOverride)
|
|
361
|
+
? this.prettyPrint(useTradePrecision, precisionOverride, decimalOverride)
|
|
347
362
|
: BigNum.fromPrint(this.toFixed(2), new anchor_1.BN(2)).prettyPrint();
|
|
348
363
|
// Append trailing zeroes out to 2 decimal places if not using custom precision
|
|
349
364
|
if (!usingCustomPrecision) {
|
package/package.json
CHANGED
package/src/factory/bigNum.ts
CHANGED
|
@@ -250,7 +250,8 @@ export class BigNum {
|
|
|
250
250
|
|
|
251
251
|
public prettyPrint(
|
|
252
252
|
useTradePrecision?: boolean,
|
|
253
|
-
precisionOverride?: number
|
|
253
|
+
precisionOverride?: number,
|
|
254
|
+
decimalOverride?: number
|
|
254
255
|
): string {
|
|
255
256
|
const [leftSide, rightSide] = this.printShort(
|
|
256
257
|
useTradePrecision,
|
|
@@ -258,6 +259,21 @@ export class BigNum {
|
|
|
258
259
|
).split(BigNum.delim);
|
|
259
260
|
|
|
260
261
|
let formattedLeftSide = leftSide;
|
|
262
|
+
let formattedRightSide = rightSide;
|
|
263
|
+
|
|
264
|
+
// Apply decimal override if specified
|
|
265
|
+
if (decimalOverride !== undefined) {
|
|
266
|
+
if (decimalOverride === 0) {
|
|
267
|
+
formattedRightSide = undefined;
|
|
268
|
+
} else {
|
|
269
|
+
// If no decimal part exists, create one with zeros
|
|
270
|
+
const currentRightSide = rightSide || '';
|
|
271
|
+
// Pad with zeros if needed or truncate if too long
|
|
272
|
+
formattedRightSide = currentRightSide
|
|
273
|
+
.padEnd(decimalOverride, '0')
|
|
274
|
+
.substring(0, decimalOverride);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
261
277
|
|
|
262
278
|
const isNeg = formattedLeftSide.includes('-');
|
|
263
279
|
if (isNeg) {
|
|
@@ -277,7 +293,7 @@ export class BigNum {
|
|
|
277
293
|
}
|
|
278
294
|
|
|
279
295
|
return `${isNeg ? '-' : ''}${formattedLeftSide}${
|
|
280
|
-
|
|
296
|
+
formattedRightSide ? `${BigNum.delim}${formattedRightSide}` : ''
|
|
281
297
|
}`;
|
|
282
298
|
}
|
|
283
299
|
|
|
@@ -503,15 +519,16 @@ export class BigNum {
|
|
|
503
519
|
*/
|
|
504
520
|
public toNotional(
|
|
505
521
|
useTradePrecision?: boolean,
|
|
506
|
-
precisionOverride?: number
|
|
522
|
+
precisionOverride?: number,
|
|
523
|
+
decimalOverride?: number
|
|
507
524
|
): string {
|
|
508
525
|
const prefix = `${this.lt(BigNum.zero()) ? `-` : ``}$`;
|
|
509
526
|
|
|
510
527
|
const usingCustomPrecision =
|
|
511
|
-
true && (useTradePrecision || precisionOverride);
|
|
528
|
+
true && (useTradePrecision || precisionOverride || decimalOverride);
|
|
512
529
|
|
|
513
530
|
let val = usingCustomPrecision
|
|
514
|
-
? this.prettyPrint(useTradePrecision, precisionOverride)
|
|
531
|
+
? this.prettyPrint(useTradePrecision, precisionOverride, decimalOverride)
|
|
515
532
|
: BigNum.fromPrint(this.toFixed(2), new BN(2)).prettyPrint();
|
|
516
533
|
|
|
517
534
|
// Append trailing zeroes out to 2 decimal places if not using custom precision
|