Documentation
¶
Overview ¶
Package money provides the fixed-point representation used by every accounting ledger. One unit is one millionth of a US dollar (microUSD).
Index ¶
Constants ¶
const MicroPerUSD int64 = 1_000_000
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MicroUSD ¶
type MicroUSD int64
MicroUSD is an exact, non-floating-point monetary amount.
func FromUSD ¶
FromUSD converts an API-boundary dollar value into fixed-point microUSD. Values are rounded to the public contract's six-decimal precision.
func MustFromUSD ¶
MustFromUSD is intended for trusted constants and tests.
func TokenCost ¶
TokenCost calculates tokens * price-per-million-tokens without a floating intermediate. Fractions of one microUSD are rounded up so metering never silently undercharges a provider call.
func (MicroUSD) MarshalJSON ¶
MarshalJSON preserves the existing public costUsd contract while keeping the in-memory representation fixed-point.
func (*MicroUSD) UnmarshalJSON ¶
UnmarshalJSON accepts a JSON dollar number with at most six decimal places.