coin

package
v5.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// the uToken denom "u/uumee"
	UumeeDenom = leveragetypes.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

Functions

func Dec

func Dec(denom, amount string) sdk.DecCoin

Dec creates a DecCoin with a given base denom and amount.

func DecF

func DecF(denom string, amount float64) sdk.DecCoin

DecF creates a DecCoin based on float amount. MUST not be used in production code. Can only be used in tests.

func New

func New(denom string, amount int64) sdk.Coin

New creates a Coin with a given base denom and amount

func Normalize

func Normalize(cs sdk.Coins) sdk.Coins

Normalize transform nil coins to empty list

func UmeeDec

func UmeeDec(amount string) sdk.DecCoin

UmeeDec creates a Umee (uumee) DecCoin with given amount

func Utoken

func Utoken(denom string, amount int64) sdk.Coin

Utoken creates a uToken DecCoin.

func UtokenDec

func UtokenDec(denom string, amount string) sdk.DecCoin

UtokenDec creates a uToken DecCoin.

func UtokenDecF

func UtokenDecF(denom string, amount float64) sdk.DecCoin

UtokenDecF creates a uToken DecCoin.

func Zero

func Zero(denom string) sdk.Coin

Zero returns new coin with zero amount

func ZeroDec

func ZeroDec(denom string) sdk.DecCoin

Zero returns new coin with zero amount

Types

type DecBld

type DecBld struct {
	D sdk.DecCoin
}

TODO: add unit tests for `util/coin/math.go` DecBld is a Builder pattern for dec coin

func NewDecBld

func NewDecBld(d sdk.DecCoin) *DecBld

NewDecBld is a constructor for DecBld type

func (*DecBld) Scale

func (d *DecBld) Scale(f int64) *DecBld

Scale scales dec coin by given factor

func (*DecBld) ScaleStr

func (d *DecBld) ScaleStr(f string) *DecBld

Scale scales dec coin by given factor provided as string. Panics if f is not a correct decimal number.

func (*DecBld) ToCoin

func (d *DecBld) ToCoin() sdk.Coin

ToCoin converts DecCoin to sdk.Coin rounding up

func (*DecBld) ToCoins

func (d *DecBld) ToCoins() sdk.Coins

ToCoins converts DecCoin to sdk.Coins rounding up

func (*DecBld) ToDecCoins

func (d *DecBld) ToDecCoins() sdk.DecCoins

ToCoin converts DecCoin to sdk.DecCoins

Jump to

Keyboard shortcuts

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