Documentation ¶
Index ¶
- Constants
- Variables
- func Dec(denom, amount string) sdk.DecCoin
- func DecF(denom string, amount float64) sdk.DecCoin
- func HasUTokenPrefix(denom string) bool
- func Negative1(denom string) sdk.Coin
- func New(denom string, amount int64) sdk.Coin
- func Normalize(cs sdk.Coins) sdk.Coins
- func StripUTokenDenom(denom string) string
- func ToUTokenDenom(denom string) string
- func UmeeCoins(amount int64) sdk.Coins
- func UmeeDec(amount string) sdk.DecCoin
- func Utoken(denom string, amount int64) sdk.Coin
- func UtokenDec(denom string, amount string) sdk.DecCoin
- func UtokenDecF(denom string, amount float64) sdk.DecCoin
- func Zero(denom string) sdk.Coin
- func ZeroDec(denom string) sdk.DecCoin
- type DecBld
Constants ¶
const (
// UTokenPrefix defines the uToken denomination prefix for all uToken types.
UTokenPrefix = "u/"
)
Variables ¶
var ( // the uToken denom "u/uumee" UumeeDenom = ToUTokenDenom(umee) // 1uumee Coin Umee1 = New(umee, 1) // 10_000uumee Coin Umee10k = New(umee, 10_000) // 1u/uumee Coin UUmee1 = Utoken(umee, 1) // Xuumee DecCoin Umee0dec = DecF(umee, 0) Umee1dec = DecF(umee, 1) Atom = "ibc/C4CFF46FD6DE35CA4CF4CE031E643C8FDC9BA4B99AE598E9B0ED98FE3A2319F9" // 1<atom ibc denom> Coin Atom1 = New(Atom, 1) // 1u/<atom ibc denom> Coin UAtom1 = Utoken(Atom, 1) Atom1dec = DecF(Atom, 1) // 1.25<atom ibc denom> DecCoin Atom1_25dec = DecF(Atom, 1.25) // a test denom Dollar = "dollar" )
common coins used in tests
var Exponents = map[int]sdk.Dec{ -18: sdk.MustNewDecFromStr("0.000000000000000001"), -17: sdk.MustNewDecFromStr("0.00000000000000001"), -16: sdk.MustNewDecFromStr("0.0000000000000001"), -15: sdk.MustNewDecFromStr("0.000000000000001"), -14: sdk.MustNewDecFromStr("0.00000000000001"), -13: sdk.MustNewDecFromStr("0.0000000000001"), -12: sdk.MustNewDecFromStr("0.000000000001"), -11: sdk.MustNewDecFromStr("0.00000000001"), -10: sdk.MustNewDecFromStr("0.0000000001"), -9: sdk.MustNewDecFromStr("0.000000001"), -8: sdk.MustNewDecFromStr("0.00000001"), -7: sdk.MustNewDecFromStr("0.0000001"), -6: sdk.MustNewDecFromStr("0.000001"), -5: sdk.MustNewDecFromStr("0.00001"), -4: sdk.MustNewDecFromStr("0.0001"), -3: sdk.MustNewDecFromStr("0.001"), -2: sdk.MustNewDecFromStr("0.01"), -1: sdk.MustNewDecFromStr("0.1"), 0: sdk.MustNewDecFromStr("1.0"), 1: sdk.MustNewDecFromStr("10.0"), 2: sdk.MustNewDecFromStr("100.0"), 3: sdk.MustNewDecFromStr("1000.0"), 4: sdk.MustNewDecFromStr("10000.0"), 5: sdk.MustNewDecFromStr("100000.0"), 6: sdk.MustNewDecFromStr("1000000.0"), 7: sdk.MustNewDecFromStr("10000000.0"), 8: sdk.MustNewDecFromStr("100000000.0"), 9: sdk.MustNewDecFromStr("1000000000.0"), 10: sdk.MustNewDecFromStr("10000000000.0"), 11: sdk.MustNewDecFromStr("100000000000.0"), 12: sdk.MustNewDecFromStr("1000000000000.0"), 13: sdk.MustNewDecFromStr("10000000000000.0"), 14: sdk.MustNewDecFromStr("100000000000000.0"), 15: sdk.MustNewDecFromStr("1000000000000000.0"), 16: sdk.MustNewDecFromStr("10000000000000000.0"), 17: sdk.MustNewDecFromStr("100000000000000000.0"), 18: sdk.MustNewDecFromStr("1000000000000000000.0"), }
Functions ¶
func DecF ¶
DecF creates a DecCoin based on float amount. MUST not be used in production code. Can only be used in tests.
func HasUTokenPrefix ¶
HasUTokenPrefix detects the uToken prefix on a denom.
func StripUTokenDenom ¶
StripUTokenDenom strips the uToken prefix from a denom, or returns an empty string if it was not present. Also returns an empty string if the prefix was repeated multiple times.
func ToUTokenDenom ¶
ToUTokenDenom adds the uToken prefix to a denom. Returns an empty string instead if the prefix was already present.
func UtokenDecF ¶
UtokenDecF creates a uToken DecCoin.
Types ¶
type DecBld ¶
TODO: add unit tests for `util/coin/math.go` DecBld is a Builder pattern for dec coin
func (*DecBld) ScaleStr ¶
Scale scales dec coin by given factor provided as string. Panics if f is not a correct decimal number.
func (*DecBld) ToDecCoins ¶
ToCoin converts DecCoin to sdk.DecCoins