amount

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NanoAUMPerAUM is the number of NanoAUM in one AUM.
	NanoAUMPerAUM = 1e9

	// DefaultMaxNanoAUM is the default maximum transaction amount allowed in NanoAUM (42 million for mainnet).
	DefaultMaxNanoAUM = 42e6 * NanoAUMPerAUM

	// TestnetMaxNanoAUM is the maximum amount for testnet (9 billion).
	TestnetMaxNanoAUM = 9e9 * NanoAUMPerAUM
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

type Amount int64

Amount represents the atomic unit in Aerium blockchain. Each unit equals to 1e-9 of a AUM.

func FromString

func FromString(str string) (Amount, error)

FromString parses a string representing a value in AUM. It then uses NewAmount to create an Amount based on the parsed floating-point value. If the parsing of the string fails, it returns an error.

func MaxNanoAUM

func MaxNanoAUM() Amount

MaxNanoAUM returns the maximum amount based on chain type.

func NewAmount

func NewAmount(aum float64) (Amount, error)

NewAmount creates an Amount from a floating-point value representing an amount in AUM. NewAmount returns an error if f is NaN or +-Infinity, but it does not check whether the amount is within the total amount of AUM producible, as it may not refer to an amount at a single moment in time.

NewAmount is specifically for converting AUM to NanoAUM. For creating a new Amount with an int64 value which denotes a quantity of NanoAUM, do a simple type conversion from type int64 to Amount.

func (Amount) Format

func (a Amount) Format(u Unit) string

Format formats a monetary amount counted in Aerium base units as a string for a given unit. The conversion will succeed for any unit, however, known units will be formatted with an appended label describing the units with SI notation, and "NanoAUM" for the base unit.

func (Amount) MulF64

func (a Amount) MulF64(f float64) Amount

MulF64 multiplies an Amount by a floating point value.

func (Amount) String

func (a Amount) String() string

String is the equivalent of calling Format with AmountAUM.

func (Amount) ToAUM

func (a Amount) ToAUM() float64

ToAUM is equivalent to calling ToUnit with AmountAUM.

func (Amount) ToNanoAUM

func (a Amount) ToNanoAUM() int64

ToNanoAUM is equivalent to calling ToUnit with AmountNanoAUM. It returns the amount of NanoAUM or atomic unit as a 64-bit integer.

func (Amount) ToUnit

func (a Amount) ToUnit(u Unit) float64

ToUnit converts a monetary amount counted in Aerium base units to a floating-point value representing an amount of Aerium (AUM).

type Unit

type Unit int

Unit describes a method of converting an Amount to something other than the base unit of a Aerium. The value of the Unit is the exponent component of the decadic multiple to convert from an amount in Aerium to an amount counted in units.

const (
	UnitMegaAUM  Unit = 6
	UnitKiloAUM  Unit = 3
	UnitAUM      Unit = 0
	UnitMilliAUM Unit = -3
	UnitMicroAUM Unit = -6
	UnitNanoAUM  Unit = -9
)

These constants define various units used when describing a Aerium monetary amount.

func (Unit) String

func (u Unit) String() string

String returns the unit as a string. For recognized units, the SI prefix is used, or "NanoAUM" for the base unit. For all unrecognized units, "1eN AUM" is returned, where N is the AmountUnit.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL