Documentation
¶
Index ¶
- func AdjustAmount(amount sdkmath.Int, factor float64) sdkmath.Int
- func AdjustSlippageFloat64(price float64, slippage float64, isBuy bool) float64
- func BpsToDecimal(bps int64) float64
- func CalculatePriceFromCoins(base, baseDenom string, baseDecimals int, quote, quoteDenom string, ...) (*big.Float, error)
- func ComparePercentageChange(oldValue, newValue float64, threshold int64) (float64, bool)
- func ConvertDecimalsBigInt(value *big.Int, fromDecimals, toDecimals int) *big.Int
- func ConvertDecimalsSDK(value sdkmath.Int, fromDecimals, toDecimals int) sdkmath.Int
- func DivideWithDecimals(f float64, b *big.Int, decimals int) *big.Int
- func FloatToFixedInt(price float64, decimals int64) sdkmath.Int
- func FloatToLegacyDec(value float64) sdkmath.LegacyDec
- func FloatToQuantumPrice(price float64, quantumConversionExponent int64) sdkmath.Int
- func GenerateDeviation(baseValue float64, rng *rand.Rand) int64
- func Interpolate(x, x1, y1, x2, y2 sdkmath.LegacyDec) sdkmath.LegacyDec
- func MultiplyWithDecimals(f float64, b *big.Int) *big.Int
- func ParseCoinString(token string, denom string, decimals int) (*big.Float, error)
- func RoundFixedPointInt(value sdkmath.Int, roundTo uint64) sdkmath.Int
- func RoundToNearestTickSpacing(value, r int64) (int64, error)
- func SaturatingSub(minuend, subtrahend sdkmath.Int) sdkmath.Int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustAmount ¶
AdjustAmount adjusts the given amount based on the provided adjustment factor.
func AdjustSlippageFloat64 ¶
func BpsToDecimal ¶
func CalculatePriceFromCoins ¶
func CalculatePriceFromCoins(base, baseDenom string, baseDecimals int, quote, quoteDenom string, quoteDecimals int) (*big.Float, error)
CalculatePriceFromCoins computes base/quote as a big.Float
func ComparePercentageChange ¶
ComparePercentageChange calculates the percentage change and checks if it is significant.
func ConvertDecimalsBigInt ¶
ConvertDecimalsBigInt truncates a fixed-point decimal from `fromDecimals` to `toDecimals`
func ConvertDecimalsSDK ¶
ConvertDecimalsSDK truncates sdkmath.Int from `fromDecimals` to `toDecimals`
func DivideWithDecimals ¶ added in v0.0.6
DivideWithDecimals divides a big.Int by a float64 considering the decimals and returns the result as a fixed-point big.Int with the specified decimals.
func FloatToFixedInt ¶ added in v0.0.6
FloatToQuantumPrice converts a floating point price to a quantum-adjusted fixed-point integer Example: floatToQuantumPrice(1.234567899, -9) returns sdkmath.NewInt(1234567899)
func FloatToLegacyDec ¶
Convert float64 to sdkmath.LegacyDec
func FloatToQuantumPrice ¶
FloatToQuantumPrice converts a floating point price to a quantum-adjusted fixed-point integer Example: floatToQuantumPrice(1.234567899, -9) returns sdkmath.NewInt(1234567899)
func Interpolate ¶ added in v0.0.6
interpolate linearly interpolates between two points (x1,y1) and (x2,y2) to find the y-value corresponding to the provided x-value
func MultiplyWithDecimals ¶
MultiplyWithDecimals multiplies a float64 and a big.Int considering the decimals and returns the result as a fixed-point big.Int with the specified decimals.
func ParseCoinString ¶
ParseCoinString converts a coin string to a big.Float value based on decimals
func RoundToNearestTickSpacing ¶
RoundToNearestTickSpacing rounds a value to the nearest multiple of r.
Types ¶
This section is empty.