finance

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package finance provides shared financial types and utilities for USDC operations. It is a leaf package with no internal dependencies, designed to break the coupling between wallet (key management) and packages that only need monetary parsing/formatting.

Index

Constants

View Source
const CurrencyUSDC = "USDC"

CurrencyUSDC is the ticker symbol for the USDC stablecoin.

View Source
const DefaultQuoteExpiry = 5 * time.Minute

DefaultQuoteExpiry is the default validity window for a price quote.

View Source
const USDCDecimals = 6

USDCDecimals is the number of decimal places for USDC (6).

Variables

This section is empty.

Functions

func FloatToMicroUSDC

func FloatToMicroUSDC(amount float64) *big.Int

FloatToMicroUSDC converts a float64 dollar amount to the smallest USDC unit (6 decimals). Uses shopspring/decimal for exact conversion — no floating-point rounding hacks needed.

func FormatUSDC

func FormatUSDC(amount *big.Int) string

FormatUSDC converts smallest USDC units back to a decimal string. Trailing zeros are trimmed but at least 2 decimal places are kept. e.g., 1500000 -> "1.50", 0 -> "0.00", 50 -> "0.00005"

func ParseUSDC

func ParseUSDC(amount string) (*big.Int, error)

ParseUSDC converts a decimal string (e.g. "1.50") to the smallest USDC unit. Returns an error if the string is not a valid decimal or has more than 6 decimal places.

Types

This section is empty.

Jump to

Keyboard shortcuts

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