pricecurve

package
v1.3.9 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2021 License: Apache-2.0 Imports: 10 Imported by: 9

Documentation

Index

Constants

View Source
const (
	// Dollar is 10^11 nanocents
	Dollar = 100000000000
)
View Source
const (

	// SaleBlockQty is the number of ndau in a sale block
	SaleBlockQty = 1000
)

Variables

This section is empty.

Functions

func ApproxPriceAtUnit

func ApproxPriceAtUnit(nunitsSold types.Ndau) float64

ApproxPriceAtUnit returns the price of the next ndau in USD given the number already sold

func ApproxTotalPriceFor

func ApproxTotalPriceFor(numNdau, alreadySold types.Ndau) float64

ApproxTotalPriceFor returns the total price for a group of ndau given the amount to be purchased and the number already sold The numbers passed in are integer number of napu NOT ndau

func ApproxUnitAtPrice

func ApproxUnitAtPrice(price float64) int

ApproxUnitAtPrice does a binary search for the lowest multiple of 1000 units that exceeds the price

Types

type Nanocent

type Nanocent int64

A Nanocent is one billionth of one hundredth of one USD.

It is fundamentally an integer and is computed using only integer math, for perfect determinism.

func ParseDollars

func ParseDollars(dollars string) (Nanocent, error)

ParseDollars parses strings expressed in dollars and returns nanocents

func PriceAtUnit

func PriceAtUnit(nunitsSold types.Ndau) (Nanocent, error)

PriceAtUnit returns the price of the next ndau given the number already sold

func PriceAtUnit10000

func PriceAtUnit10000(nunitsSold types.Ndau) (Nanocent, error)

PriceAtUnit10000 returns the price of the next ndau given the number already sold, using the (incorrect) end-point of the 10000th block as the one at which the price reaches 16384.

This function is provided to ensure deterministic playback of early blocks. It should _never_ be used in new code.

func PriceAtUnit9999

func PriceAtUnit9999(nunitsSold types.Ndau) (Nanocent, error)

PriceAtUnit9999 returns the price of the next ndau given the number already sold, using the (correct) end-point of the 9999th block as the one at which the price reaches 16384.

func (*Nanocent) DecodeMsg

func (z *Nanocent) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (Nanocent) EncodeMsg

func (z Nanocent) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (Nanocent) MarshalMsg

func (z Nanocent) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (Nanocent) Msgsize

func (z Nanocent) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (*Nanocent) UnmarshalMsg

func (z *Nanocent) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

Jump to

Keyboard shortcuts

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