diff --git a/common/util/format.ts b/common/util/format.ts
index 05a8f702..d1be7086 100644
--- a/common/util/format.ts
+++ b/common/util/format.ts
@@ -7,12 +7,27 @@ const formatter = new Intl.NumberFormat('en-US', {
minimumFractionDigits: 0,
})
+const formatterCents = new Intl.NumberFormat('en-US', {
+ style: 'currency',
+ currency: 'USD',
+ maximumFractionDigits: 2,
+ minimumFractionDigits: 2,
+})
+
export function formatMoney(amount: number) {
const newAmount = Math.round(amount) === 0 ? 0 : amount // handle -0 case
return (
ENV_CONFIG.moneyMoniker + ' ' + formatter.format(newAmount).replace('$', '')
)
}
+export function formatCents(probability: number) {
+ const newAmount = Math.round(probability * 100) === 0 ? 0 : probability // handle -0 case
+ return (
+ ENV_CONFIG.moneyMoniker +
+ ' ' +
+ formatterCents.format(newAmount).replace('$', '')
+ )
+}
export function formatWithCommas(amount: number) {
return formatter.format(amount).replace('$', '')
diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx
index f0a64a6b..ff4802d3 100644
--- a/web/components/amount-input.tsx
+++ b/web/components/amount-input.tsx
@@ -9,6 +9,7 @@ import { InfoTooltip } from './info-tooltip'
import { Spacer } from './layout/spacer'
import { calculateCpmmSale } from '../../common/calculate-cpmm'
import { Binary, CPMM, FullContract } from '../../common/contract'
+import { ENV_CONFIG } from '../../common/envs/constants'
export function AmountInput(props: {
amount: number | undefined
@@ -50,10 +51,10 @@ export function AmountInput(props: {
return (