math

package
v0.0.0-...-c0e68af Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	One  = new(big.Int).SetInt64(1)
	Zero = new(big.Int).SetInt64(0)

	// Two192 for some calculations (2 ** 192)
	//6277101735386680763835789423207666416102355444464034512896
	Two192 = new(big.Rat).SetInt(new(big.Int).SetBits([]big.Word{0, 0, 0, 1}))
)
View Source
var (
	// MinTick that could be used in the tick range.
	MinTick = new(big.Int).SetInt64(-887272)

	// MaxTick that could be used.
	MaxTick = new(big.Int).SetInt64(887272)

	// MinSqrtRatio (price) that could be set.
	MinSqrtRatio = new(big.Int).SetInt64(4295128739)

	// MaxSqrtRatio that could be used as price data.
	//1461446703485210103287273052203988822378723970342n
	MaxSqrtRatio = new(big.Int).SetBits([]big.Word{0x5d951d5263988d26, 0xefd1fc6a50648849, 0xfffd8963})
)
View Source
var Q96 = new(big.Int).SetBits([]big.Word{0, 0x100000000})

Q96 to use for some math operations 79228162514264337593543950336

Functions

func ExponentiateDecimals

func ExponentiateDecimals(decimals int64) *big.Rat

func GetAmount0ForLiq

func GetAmount0ForLiq(sqrtRatioAX96, sqrtRatioBX96, liq *big.Int) (amount0 *big.Rat)

func GetAmount1ForLiq

func GetAmount1ForLiq(sqrtRatioAX96, sqrtRatioBX96, liq *big.Int) (amount1 *big.Rat)

func GetAmountsForLiq

func GetAmountsForLiq(sqrtRatioX96, sqrtRatioAX96, sqrtRatioBX96, liq *big.Int) (amount0 *big.Rat, amount1 *big.Rat)

GetAmountsForLiq with sqrtRatioX96 being the first tick boundary, and sqrtRatioAX96 being the second. liq being the amount of liquidity in the position.

func GetPriceAtSqrtRatio

func GetPriceAtSqrtRatio(x *big.Int) *big.Rat

func GetSqrtRatioAtTick

func GetSqrtRatioAtTick(t *big.Int) *big.Int

Types

This section is empty.

Jump to

Keyboard shortcuts

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