Documentation ¶
Index ¶
- Constants
- Variables
- type Blockchain
- type CryptoCurrency
- func (c CryptoCurrency) ChooseContractAddress(isTest bool) string
- func (c CryptoCurrency) ChooseNetwork(isTest bool) string
- func (c CryptoCurrency) DisplayName() string
- func (c CryptoCurrency) MakeAmount(raw string) (Money, error)
- func (c CryptoCurrency) MakeAmountFromBigInt(amount *big.Int) (Money, error)
- type CryptoCurrencyType
- type FiatCurrency
- type Money
- func CryptoFromFloat64(ticker string, f float64, decimals int64) (Money, error)
- func CryptoFromRaw(ticker, value string, decimals int64) (Money, error)
- func CryptoFromStringFloat(ticker, floatString string, decimals int64) (Money, error)
- func CryptoToFiat(crypto Money, fiat FiatCurrency, exchangeRate float64) (Money, error)
- func FiatFromFloat64(ticker FiatCurrency, f float64) (Money, error)
- func MustCryptoFromRaw(ticker, value string, decimals int64) Money
- func New(moneyType Type, ticker, value string, decimals int64) (Money, error)
- func NewFromBigInt(moneyType Type, ticker string, bigInt *big.Int, decimals int64) (Money, error)
- func (m Money) Add(amount Money) (Money, error)
- func (m Money) BigInt() (*big.Int, int64)
- func (m Money) CompatibleTo(b Money) bool
- func (m Money) Decimals() int64
- func (m Money) Equals(b Money) bool
- func (m Money) FiatToFloat64() (float64, error)
- func (m Money) GreaterThan(b Money) bool
- func (m Money) GreaterThanOrEqual(b Money) bool
- func (m Money) IsNegative() bool
- func (m Money) IsPositive() bool
- func (m Money) IsZero() bool
- func (m Money) LessThan(b Money) bool
- func (m Money) LessThanOrEqual(b Money) bool
- func (m Money) MultiplyFloat64(by float64) (Money, error)
- func (m Money) MultiplyInt64(by int64) (Money, error)
- func (m Money) String() string
- func (m Money) StringRaw() string
- func (m Money) Sub(amount Money) (Money, error)
- func (m Money) Ticker() string
- func (m Money) Type() Type
- type Type
Constants ¶
View Source
const ( FiatDecimals = int64(2) FiatMin = float64(0.01) FiatMax = float64(10_000_000) )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Blockchain ¶
type Blockchain string
CRYPTO ------------------
func (Blockchain) String ¶
func (b Blockchain) String() string
type CryptoCurrency ¶
type CryptoCurrency struct { Blockchain Blockchain BlockchainName string NetworkID string TestNetworkID string Type CryptoCurrencyType Ticker string Name string Decimals int64 TokenContractAddress string TestTokenContractAddress string Aliases []string Deprecated bool }
CryptoCurrency represents CRYPTO coin or token.
func (CryptoCurrency) ChooseContractAddress ¶
func (c CryptoCurrency) ChooseContractAddress(isTest bool) string
ChooseContractAddress returns contract address and tries to return specific contract for testnet if present
func (CryptoCurrency) ChooseNetwork ¶
func (c CryptoCurrency) ChooseNetwork(isTest bool) string
func (CryptoCurrency) DisplayName ¶
func (c CryptoCurrency) DisplayName() string
func (CryptoCurrency) MakeAmount ¶
func (c CryptoCurrency) MakeAmount(raw string) (Money, error)
func (CryptoCurrency) MakeAmountFromBigInt ¶ added in v0.3.0
func (c CryptoCurrency) MakeAmountFromBigInt(amount *big.Int) (Money, error)
type CryptoCurrencyType ¶
type CryptoCurrencyType string
const ( Coin CryptoCurrencyType = "coin" Token CryptoCurrencyType = "token" )
type FiatCurrency ¶
type FiatCurrency string
FIAT ------------------
const EUR FiatCurrency = "EUR"
const USD FiatCurrency = "USD"
func MakeFiatCurrency ¶
func MakeFiatCurrency(s string) (FiatCurrency, error)
func (FiatCurrency) MakeAmount ¶
func (f FiatCurrency) MakeAmount(raw string) (Money, error)
func (FiatCurrency) String ¶
func (f FiatCurrency) String() string
type Money ¶
type Money struct {
// contains filtered or unexported fields
}
func CryptoFromFloat64 ¶
func CryptoFromStringFloat ¶
CryptoFromStringFloat constructs crypto from floats string e.g. "0.042"
func CryptoToFiat ¶
func CryptoToFiat(crypto Money, fiat FiatCurrency, exchangeRate float64) (Money, error)
func FiatFromFloat64 ¶
func FiatFromFloat64(ticker FiatCurrency, f float64) (Money, error)
func MustCryptoFromRaw ¶
func NewFromBigInt ¶
func (Money) CompatibleTo ¶
func (Money) FiatToFloat64 ¶
func (Money) GreaterThan ¶
func (Money) GreaterThanOrEqual ¶
func (Money) IsNegative ¶
func (Money) IsPositive ¶
func (Money) LessThanOrEqual ¶
func (Money) MultiplyInt64 ¶
MultiplyInt64 has less error than MultiplyFloat64
Click to show internal directories.
Click to hide internal directories.