math

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2023 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsDifferenceWithSign

func AbsDifferenceWithSign(a, b sdk.Dec) (sdk.Dec, bool)

AbsDifferenceWithSign returns | a - b |, (a - b).sign() a is mutated and returned

func AddMut

func AddMut(a, b sdk.Dec) sdk.Dec

func Clone

func Clone(a sdk.Dec) sdk.Dec

func MulMut

func MulMut(a, b sdk.Dec) sdk.Dec

func NegMut

func NegMut(a sdk.Dec) sdk.Dec

func Pow

func Pow(base sdk.Dec, exp sdk.Dec) sdk.Dec

Pow computes base^(exp) However since the exponent is not an integer, we must do an approximation algorithm. TODO: In the future, lets add some optimized routines for common exponents, e.g. for common wIn / wOut ratios Many simple exponents like 2:1 pools

func PowApprox

func PowApprox(base sdk.Dec, exp sdk.Dec, precision sdk.Dec) sdk.Dec

Contract: 0 < base <= 2 0 < exp < 1

func SigFigRound added in v1.1.0

func SigFigRound(d sdk.Dec, tenToSigFig sdk.Int) sdk.Dec

func SubMut

func SubMut(a, b sdk.Dec) sdk.Dec

Types

This section is empty.

Jump to

Keyboard shortcuts

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