tickmath

package
v3.0.0-...-6ddf7be Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxTick int64 = 262143   // Equivalent to 2**18 - 1
	MinTick int64 = -MaxTick // Equivalent to -2**18 + 1
	Offset  int64 = 262144   // Equivalent to 2**18
)

Variables

This section is empty.

Functions

func PriceToTick

func PriceToTick(price uint64) (uint64, error)

PriceToTick converts the price to tick, it will return the nearest tick that yields less than or equal to the given price. ref: https://en.wikipedia.org/wiki/Binary_logarithm#Iterative_approximation

func TickToPrice

func TickToPrice(tick int64) (uint64, error)

TickToPrice converts the tick to price with 10^9 precision. It will return an error if the tick is out of range or the tick is so large that cannot be converted to uint64. NOTE: the result is rounded up to the nearest integer, this is aligned with the UniswapV3 calculation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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