Versions in this module Expand all Collapse all v1 v1.1.0 Dec 2, 2025 Changes in this version + var ErrAssetMismatch = errors.New("money: asset mismatch") + var ErrDivisionByZero = errors.New("money: division by zero") + var ErrInvalidFormat = errors.New("money: invalid format") + var ErrNegativeAmount = errors.New("money: negative amount not allowed") + var ErrOverflow = errors.New("money: arithmetic overflow") + var KnownStablecoins = map[string]string + func GetMintAddressForSymbol(symbol string) string + func GetStablecoinSymbol(mintAddress string) string + func IsStablecoin(mintAddress string) bool + func RegisterAsset(asset Asset) error + func ValidateStablecoinMint(mintAddress string) (string, error) + type Asset struct + Code string + Decimals uint8 + Metadata AssetMetadata + Type AssetType + func GetAsset(code string) (Asset, error) + func ListAssets() []Asset + func MustGetAsset(code string) Asset + func (a Asset) GetSolanaMint() (string, error) + func (a Asset) GetStripeCurrency() (string, error) + func (a Asset) IsSPLToken() bool + func (a Asset) IsStripeCurrency() bool + type AssetMetadata struct + SolanaMint string + StripeCurrency string + type AssetType int + const AssetTypeFiat + const AssetTypeSPL + type Money struct + Asset Asset + Atomic int64 + func FromAtomic(asset Asset, atomic string) (Money, error) + func FromMajor(asset Asset, major string) (Money, error) + func New(asset Asset, atomic int64) Money + func SumMoney(amounts ...Money) (Money, error) + func Zero(asset Asset) Money + func (m *Money) UnmarshalJSON(data []byte) error + func (m Money) Abs() Money + func (m Money) Add(other Money) (Money, error) + func (m Money) ApplyFixedDiscount(discount Money) (Money, error) + func (m Money) ApplyPercentageDiscount(discountPercent float64) (Money, error) + func (m Money) ApplyPercentageDiscountWithRounding(discountPercent float64, mode RoundingMode) (Money, error) + func (m Money) Div(divisor int64) (Money, error) + func (m Money) Equal(other Money) bool + func (m Money) GreaterThan(other Money) bool + func (m Money) IsNegative() bool + func (m Money) IsPositive() bool + func (m Money) IsZero() bool + func (m Money) LessThan(other Money) bool + func (m Money) MarshalJSON() ([]byte, error) + func (m Money) Mul(multiplier int64) (Money, error) + func (m Money) MulBasisPoints(basisPoints int64) (Money, error) + func (m Money) MulBasisPointsWithRounding(basisPoints int64, mode RoundingMode) (Money, error) + func (m Money) MulPercent(percent int64) (Money, error) + func (m Money) MultiplyByFloat(multiplier float64) (Money, error) + func (m Money) Negate() Money + func (m Money) RoundUpToCents() Money + func (m Money) String() string + func (m Money) Sub(other Money) (Money, error) + func (m Money) ToAtomic() string + func (m Money) ToMajor() string + type MoneyJSON struct + Asset string + Atomic string + type MoneyRequest Money + func (mr *MoneyRequest) UnmarshalJSON(data []byte) error + func (mr MoneyRequest) MarshalJSON() ([]byte, error) + func (mr MoneyRequest) ToMoney() Money + type MoneyResponse Money + func FromMoney(m Money) MoneyResponse + func (mr *MoneyResponse) UnmarshalJSON(data []byte) error + func (mr MoneyResponse) MarshalJSON() ([]byte, error) + func (mr MoneyResponse) ToMoney() Money + type RoundingMode int + const RoundingCeiling + const RoundingStandard + func ParseRoundingMode(mode string) RoundingMode + type SPLAdapter struct + func NewSPLAdapter() *SPLAdapter + func (a *SPLAdapter) FromSPLAmount(mint string, amount uint64) (Money, error) + func (a *SPLAdapter) GetMintDecimals(mint string) (uint8, error) + func (a *SPLAdapter) ToSPLAmount(m Money) (mint string, amount uint64, err error) + func (a *SPLAdapter) ValidateSPLAmount(m Money) error + type StripeAdapter struct + func NewStripeAdapter() *StripeAdapter + func (a *StripeAdapter) FromStripeAmount(currency string, amount int64) (Money, error) + func (a *StripeAdapter) ToStripeAmount(m Money) (currency string, amount int64, err error) + func (a *StripeAdapter) ValidateStripeAmount(m Money) error