Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Playground

consts.gno

package consts

import (
	i256 "gno.land/p/gnoswap/int256/v1"
	u256 "gno.land/p/gnoswap/uint256/v1"
)

// u256.Uint and i256.Int are little-endian [4]uint64:
// {arr[0]=least significant, arr[1], arr[2], arr[3]=most significant}.

// MaxUint256 returns 2^256 - 1.
//
// Returns:
//   - value: a fresh Uint equal to 2^256-1
func MaxUint256() *u256.Uint {
	return &u256.Uint{18446744073709551615, 18446744073709551615, 18446744073709551615, 18446744073709551615}
}

// MaxUint128 returns 2^128 - 1, the maximum uint128 value.
//
// Returns:
//   - value: a fresh Uint equal to 2^128-1
func MaxUint128() *u256.Uint {
	return &u256.Uint{18446744073709551615, 18446744073709551615, 0, 0}
}

// MaxInt256 returns 2^255 - 1, the maximum int256 value, as an unsigned u256.
//
// Returns:
//   - value: a fresh Uint equal to 2^255-1
func MaxInt256() *u256.Uint {
	return &u256.Uint{18446744073709551615, 18446744073709551615, 18446744073709551615, 9223372036854775807}
}

// Q96 returns 2^96, the Q64.96 fixed-point scaling factor.
//
// Returns:
//   - value: a fresh Uint equal to 2^96, the Q64.96 scale
func Q96() *u256.Uint {
	return &u256.Uint{0, 4294967296, 0, 0}
}

// Q128 returns 2^128, the Q128.128 fixed-point scaling factor.
//
// Returns:
//   - value: a fresh Uint equal to 2^128, the Q128.128 scale
func Q128() *u256.Uint {
	return &u256.Uint{0, 0, 1, 0}
}

// Q192 returns 2^192.
//
// Returns:
//   - value: a fresh Uint equal to 2^192
func Q192() *u256.Uint {
	return &u256.Uint{0, 0, 0, 1}
}

// Max160 returns 2^160 - 1, the maximum value representable in 160 bits.
//
// Returns:
//   - value: a fresh Uint equal to 2^160-1
func Max160() *u256.Uint {
	return &u256.Uint{18446744073709551615, 18446744073709551615, 4294967295, 0}
}

// MinSqrtRatio returns the minimum valid sqrt price ratio (4295128739),
// equal to TickMathGetSqrtRatioAtTick(minTick).
//
// Returns:
//   - value: a fresh Uint equal to the minimum valid sqrt-price ratio
func MinSqrtRatio() *u256.Uint {
	return &u256.Uint{4295128739, 0, 0, 0}
}

// MaxSqrtRatio returns the upper bound of the valid sqrt price range
// (1461446703485210103287273052203988822378723970342), equal to
// TickMathGetSqrtRatioAtTick(maxTick). TickMathGetTickAtSqrtRatio treats this
// boundary as exclusive and accepts values in [MinSqrtRatio, MaxSqrtRatio).
//
// Returns:
//   - value: a fresh Uint equal to the exclusive upper sqrt-price boundary
func MaxSqrtRatio() *u256.Uint {
	return &u256.Uint{6743328256752651558, 17280870778742802505, 4294805859, 0}
}

// MaxInt128I256 returns 2^127 - 1, the maximum int128 value, as a signed i256.
//
// Returns:
//   - value: a fresh signed Int equal to 2^127-1
func MaxInt128I256() *i256.Int {
	return &i256.Int{18446744073709551615, 9223372036854775807, 0, 0}
}

// MaxInt64I256 returns 2^63 - 1, the maximum int64 value, as a signed i256.
//
// Returns:
//   - value: a fresh signed Int equal to 2^63-1
func MaxInt64I256() *i256.Int {
	return &i256.Int{9223372036854775807, 0, 0, 0}
}

// MinInt64I256 returns -2^63, the minimum int64 value, as a signed i256.
//
// Returns:
//   - value: a fresh signed Int equal to -2^63
func MinInt64I256() *i256.Int {
	return &i256.Int{9223372036854775808, 18446744073709551615, 18446744073709551615, 18446744073709551615}
}

gnomod.toml

module = "gno.land/p/gnoswap/consts/v1"
gno = "0.9"

[addpkg]
  creator = "g1q5tjjv3kkslzwf2na9y9wk7e5a8ugph8xfsk04"
  height = 557724
  max_deposit = "100000000ugnot"