@gearbox-protocol/ui-kit 4.0.0-next.65 → 4.0.0-next.66
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function m(t){const i=Math.abs(t),o=t<0?"-":"",n=i>=1e3?0:2,s=i>0&&i<1?{minimumSignificantDigits:2,maximumSignificantDigits:2}:{minimumFractionDigits:n,maximumFractionDigits:n};return`${o}$${i.toLocaleString("en-US",s)}`}exports.formatUsdPrice=m;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
function
|
|
2
|
-
const
|
|
3
|
-
return `${
|
|
4
|
-
minimumFractionDigits: t,
|
|
5
|
-
maximumFractionDigits: t
|
|
6
|
-
})}`;
|
|
1
|
+
function o(t) {
|
|
2
|
+
const i = Math.abs(t), s = t < 0 ? "-" : "", n = i >= 1e3 ? 0 : 2, m = i > 0 && i < 1 ? { minimumSignificantDigits: 2, maximumSignificantDigits: 2 } : { minimumFractionDigits: n, maximumFractionDigits: n };
|
|
3
|
+
return `${s}$${i.toLocaleString("en-US", m)}`;
|
|
7
4
|
}
|
|
8
5
|
export {
|
|
9
|
-
|
|
6
|
+
o as formatUsdPrice
|
|
10
7
|
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A price as a table shows it: no `K`/`M` abbreviation, and precision that
|
|
3
|
-
* follows magnitude —
|
|
3
|
+
* follows magnitude — whole units at or above a thousand, cents down to one,
|
|
4
|
+
* and two significant digits below that, where cents would round everything
|
|
5
|
+
* to `$0.00`.
|
|
4
6
|
*
|
|
5
7
|
* `formatMoney` cannot do this: it routes through the SDK's `formatBN`, which
|
|
6
8
|
* abbreviates unconditionally and has no switch.
|
|
7
9
|
*
|
|
8
10
|
* @example
|
|
9
11
|
* ```ts
|
|
10
|
-
* formatUsdPrice(4.2055)
|
|
11
|
-
* formatUsdPrice(3412.5)
|
|
12
|
+
* formatUsdPrice(4.2055) // "$4.21"
|
|
13
|
+
* formatUsdPrice(3412.5) // "$3,413"
|
|
14
|
+
* formatUsdPrice(0.0004205) // "$0.00042"
|
|
12
15
|
* ```
|
|
13
16
|
*/
|
|
14
17
|
export declare function formatUsdPrice(value: number): string;
|