PathrockNetwork Gno Explorer
HomeBlocksTransactionsRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/r/gnoswap/pool/v1

Realm
Open in gnoweb ↗

Overview

Kind
Realm (renderable)
Name
v1
Namespace
gnoswap / pool
Files
24 (README)(gnomod.toml)
Exported functions
3
Module
gno.land/r/gnoswap/pool/v1
gno
0.9

Files (24)

  • README.mdmarkdown
  • gnomod.tomltoml
  • assert.gnogno
  • doc.gnogno
  • errors.gnogno
  • event_info.gnogno
  • factory_param.gnogno
  • getter_utils.gnogno
  • getter.gnogno
  • init.gnogno
  • instance.gnogno
  • lock.gnogno
  • manager.gnogno
  • oracle.gnogno
  • pool.gnogno
  • position.gnogno
  • protocol_fee.gnogno
  • render.gnogno
  • swap.gnogno
  • tick_bitmap.gnogno
  • tick.gnogno
  • transfer.gnogno
  • type.gnogno
  • utils.gnogno
  • utils.gnogno
    1package pool23import (4	i256 "gno.land/p/gnoswap/int256/v1"5	u256 "gno.land/p/gnoswap/uint256/v1"6	ufmt "gno.land/p/nt/ufmt/v0"7)8

    Functions

    • GetPoolPath(token0Path string, token1Path string, fee uint32) string

    • NewPoolV1(store interface {GetFeeAmountTickSpacing func() map[uint32]int32; GetObservations func() *gno.land/p/nt/bptree/v0.BPTree; GetPendingProtocolFee func(string) int64; GetPendingProtocolFees func() map[string]int64; GetPoolCreationFee func() int64; GetPools func() *gno.land/p/nt/bptree/v0.BPTree; GetSlot0FeeProtocol func() uint8; GetSwapEndHook func() func(.uverse.realm, string) .uverse.error; GetSwapStartHook func() func(.uverse.realm, string, int64); GetTickCrossHook func() func(.uverse.realm, string, int32, bool, int64); GetUnlocked func() bool; GetWithdrawalFeeBPS func() uint64; HasFeeAmountTickSpacing func() bool; HasObservations func() bool; HasPendingProtocolFees func() bool; HasPoolCreationFee func() bool; HasPools func() bool; HasSlot0FeeProtocol func() bool; HasSwapEndHook func() bool; HasSwapStartHook func() bool; HasTickCrossHook func() bool; HasUnlocked func() bool; HasWithdrawalFeeBPS func() bool; RemovePendingProtocolFee func(int, .uverse.realm, string) .uverse.error; SetFeeAmountTickSpacing func(int, .uverse.realm, map[uint32]int32) .uverse.error; SetObservations func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetPendingProtocolFee func(int, .uverse.realm, string, int64) .uverse.error; SetPendingProtocolFees func(int, .uverse.realm, map[string]int64) .uverse.error; SetPoolCreationFee func(int, .uverse.realm, int64) .uverse.error; SetPools func(int, .uverse.realm, *gno.land/p/nt/bptree/v0.BPTree) .uverse.error; SetSlot0FeeProtocol func(int, .uverse.realm, uint8) .uverse.error; SetSwapEndHook func(int, .uverse.realm, func(.uverse.realm, string) .uverse.error) .uverse.error; SetSwapStartHook func(int, .uverse.realm, func(.uverse.realm, string, int64)) .uverse.error; SetTickCrossHook func(int, .uverse.realm, func(.uverse.realm, string, int32, bool, int64)) .uverse.error; SetUnlocked func(int, .uverse.realm, bool) .uverse.error; SetWithdrawalFeeBPS func(int, .uverse.realm, uint64) .uverse.error}) interface {Burn func(int, .uverse.realm, string, string, uint32, int32, int32, string, .uverse.address) (string, string); Collect func(int, .uverse.realm, string, string, uint32, .uverse.address, int32, int32, string, string) (string, string); CollectProtocol func(int, .uverse.realm, string, string, uint32, .uverse.address, string, string) (string, string); CollectSwapFee func(int, .uverse.realm, string, string, uint32, .uverse.address, int32, int32, string, string) (string, string, string, string); CreatePool func(int, .uverse.realm, string, string, uint32, string); DrySwap func(string, string, uint32, bool, string, string) (string, string, .uverse.error); ExistsPoolPath func(string) bool; GetBalanceToken0 func(string) (int64, .uverse.error); GetBalanceToken1 func(string) (int64, .uverse.error); GetFee func(string) (uint32, .uverse.error); GetFeeAmountTickSpacing func(uint32) (int32, .uverse.error); GetFeeAmountTickSpacings func() map[uint32]int32; GetFeeGrowthGlobal0X128 func(string) (*gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); GetFeeGrowthGlobal1X128 func(string) (*gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); GetFeeGrowthGlobalX128 func(string) (*gno.land/p/gnoswap/uint256/v1.Uint, *gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); GetInitializedTicksInRange func(string, int32, int32) ([]int32, .uverse.error); GetLiquidity func(string) (*gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); GetObservationAt func(string, uint16) (gno.land/r/gnoswap/pool.Observation, .uverse.error); GetPendingProtocolFees func() map[string]int64; GetPoolCreationFee func() int64; GetPoolPositions func(string) *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree; GetPools func() *gno.land/p/nt/bptree/rotree/v0.ReadOnlyTree; GetPositionFeeGrowthInside0LastX128 func(string, string) (string, .uverse.error); GetPositionFeeGrowthInside1LastX128 func(string, string) (string, .uverse.error); GetPositionFeeGrowthInsideLastX128 func(string, string) (string, string, .uverse.error); GetPositionLiquidity func(string, string) (string, .uverse.error); GetPositionTokensOwed0 func(string, string) (int64, .uverse.error); GetPositionTokensOwed1 func(string, string) (int64, .uverse.error); GetProtocolFeesToken0 func(string) (int64, .uverse.error); GetProtocolFeesToken1 func(string) (int64, .uverse.error); GetSlot0 func(string) gno.land/r/gnoswap/pool.Slot0; GetSlot0FeeProtocol func(string) (uint8, .uverse.error); GetSlot0SqrtPriceX96 func(string) (*gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); GetSlot0Tick func(string) (int32, .uverse.error); GetSlot0Unlocked func(string) (bool, .uverse.error); GetTickBitmaps func(string, int16) (string, .uverse.error); GetTickCumulativeOutside func(string, int32) (int64, .uverse.error); GetTickFeeGrowthOutside0X128 func(string, int32) (string, .uverse.error); GetTickFeeGrowthOutside1X128 func(string, int32) (string, .uverse.error); GetTickFeeGrowthOutsideX128 func(string, int32) (string, string, .uverse.error); GetTickInfo func(string, int32) (gno.land/r/gnoswap/pool.TickInfo, .uverse.error); GetTickInitialized func(string, int32) (bool, .uverse.error); GetTickLiquidityGross func(string, int32) (string, .uverse.error); GetTickLiquidityNet func(string, int32) (string, .uverse.error); GetTickSecondsOutside func(string, int32) (uint32, .uverse.error); GetTickSecondsPerLiquidityOutsideX128 func(string, int32) (string, .uverse.error); GetTickSpacing func(string) (int32, .uverse.error); GetToken0Path func(string) (string, .uverse.error); GetToken1Path func(string) (string, .uverse.error); GetWithdrawalFee func() uint64; IncreaseObservationCardinalityNext func(int, .uverse.realm, string, string, uint32, uint16); Mint func(int, .uverse.realm, string, string, uint32, int32, int32, string, .uverse.address) (string, string); Observe func(string, []uint32) ([]int64, []string, .uverse.error); OracleConsult func(string, uint32) (int32, *gno.land/p/gnoswap/uint256/v1.Uint, .uverse.error); Render func(string) string; SetFeeProtocol func(int, .uverse.realm, uint8, uint8); SetPoolCreationFee func(int, .uverse.realm, int64); SetSwapEndHook func(int, .uverse.realm, func(.uverse.realm, string) .uverse.error); SetSwapStartHook func(int, .uverse.realm, func(.uverse.realm, string, int64)); SetTickCrossHook func(int, .uverse.realm, func(.uverse.realm, string, int32, bool, int64)); SetWithdrawalFee func(int, .uverse.realm, uint64); SnapshotCumulativesInside func(string, int32, int32) (int64, *gno.land/p/gnoswap/uint256/v1.Uint, uint32, .uverse.error); Swap func(int, .uverse.realm, string, string, uint32, .uverse.address, bool, string, string, func(.uverse.realm, int64, int64, *gno.land/r/gnoswap/pool.CallbackMarker) .uverse.error) (string, string)}

    • NewTickEventInfo(tickID int32, tickInfo struct{liquidityGross string; liquidityNet string; feeGrowthOutside0X128 string; feeGrowthOutside1X128 string; tickCumulativeOutside int64; secondsPerLiquidityOutsideX128 string; secondsOutside uint32; initialized bool}) *gno.land/r/gnoswap/pool/v1.tickEventInfo

    Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.

    Rendered

    RenderedRawgnoweb ↗
    This realm does not provide renderable output (vm/qrender → NoRenderDeclError). View on gnoweb ↗

    vm/qrender output, sanitized (docs/render-security.md) and displayed in an empty-sandbox iframe — scripts, forms and popups cannot run. Links stay inert in-preview; right-click to open.

    9const (
    10 MAX_UINT64 string = "18446744073709551615"
    11 MAX_INT64 string = "9223372036854775807"
    12 MAX_INT128 string = "170141183460469231731687303715884105727"
    13 MIN_INT128 string = "-170141183460469231731687303715884105728"
    14 MAX_UINT128 string = "340282366920938463463374607431768211455"
    15 MAX_INT256 string = "57896044618658097711785492504343953926634992332820282019728792003956564819967"
    16
    17 INT64_MIN int64 = -9223372036854775808
    18 INT64_MAX int64 = 9223372036854775807
    19
    20 Q96_RESOLUTION uint = 96
    21 Q128_RESOLUTION uint = 128
    22
    23 Q64 string = "18446744073709551616" // 2 ** 64
    24 Q96 string = "79228162514264337593543950336" // 2 ** 96
    25 Q128 string = "340282366920938463463374607431768211456" // 2 ** 128
    26)
    27
    28var (
    29 maxInt128FromDecimal = i256.MustFromDecimal(MAX_INT128)
    30 minInt128FromDecimal = i256.MustFromDecimal(MIN_INT128)
    31 maxUint128FromDecimal = u256.MustFromDecimal(MAX_UINT128)
    32 q128FromDecimal = u256.MustFromDecimal(Q128)
    33)
    34
    35var uint128Mask = func() *u256.Uint {
    36 m := u256.Zero().Lsh(u256.One(), Q128_RESOLUTION)
    37 return m.Sub(m, u256.One())
    38}()
    39
    40// toUint128 ensures a *u256.Uint value fits within the uint128 range.
    41//
    42// This function validates that the given `value` is properly initialized and checks whether
    43// it exceeds the maximum value of uint128. If the value exceeds the uint128 range,
    44// it applies a masking operation to truncate the value to fit within the uint128 limit.
    45//
    46// Parameters:
    47// - value: *u256.Uint, the value to be checked and possibly truncated.
    48//
    49// Returns:
    50// - *u256.Uint: A value guaranteed to fit within the uint128 range.
    51//
    52// Notes:
    53// - The function first checks if the value is not nil to avoid potential runtime errors.
    54// - The mask ensures that only the lower 128 bits of the value are retained.
    55// - If the input value is already within the uint128 range, it is returned unchanged.
    56// - If masking is required, a new instance is returned without modifying the input.
    57// - MAX_UINT128 is a constant representing `2^128 - 1`.
    58func toUint128(value *u256.Uint) *u256.Uint {
    59 if value == nil {
    60 panic(newErrorWithDetail(errInvalidInput, "value is nil"))
    61 }
    62
    63 if value.Gt(maxUint128FromDecimal) {
    64 return u256.Zero().And(value, uint128Mask)
    65 }
    66 return value
    67}
    68
    69// u256Min returns the smaller of two *u256.Uint values.
    70//
    71// This function compares two unsigned 256-bit integers and returns the smaller of the two.
    72// If `num1` is less than `num2`, it returns `num1`; otherwise, it returns `num2`.
    73//
    74// Parameters:
    75// - num1 (*u256.Uint): The first unsigned 256-bit integer.
    76// - num2 (*u256.Uint): The second unsigned 256-bit integer.
    77//
    78// Returns:
    79// - *u256.Uint: The smaller of `num1` and `num2`.
    80//
    81// Notes:
    82// - This function uses the `Lt` (less than) method of `*u256.Uint` to perform the comparison.
    83// - The function assumes both input values are non-nil. If nil inputs are possible in the usage context,
    84// additional validation may be needed.
    85//
    86// Example:
    87// smaller := u256Min(u256.MustFromDecimal("10"), u256.MustFromDecimal("20")) // Returns 10
    88// smaller := u256Min(u256.MustFromDecimal("30"), u256.MustFromDecimal("20")) // Returns 20
    89func u256Min(num1, num2 *u256.Uint) *u256.Uint {
    90 if num1.Lt(num2) {
    91 return num1
    92 }
    93 return num2
    94}
    95
    96// checkOverFlowInt128 checks if the value overflows the int128 range.
    97func checkOverFlowInt128(value *i256.Int) {
    98 if value.Gt(maxInt128FromDecimal) || value.Lt(minInt128FromDecimal) {
    99 panic(ufmt.Sprintf(
    100 "%v: amount(%s) overflows int128 range",
    101 errOverflow, value.ToString(),
    102 ))
    103 }
    104}
    105
    106// checkTickSpacing checks if the tick is divisible by the tickSpacing.
    107func checkTickSpacing(tick, tickSpacing int32) {
    108 if tick%tickSpacing != 0 {
    109 panic(newErrorWithDetail(
    110 errInvalidTickAndTickSpacing,
    111 ufmt.Sprintf("tick(%d) MOD tickSpacing(%d) != 0(%d)", tick, tickSpacing, tick%tickSpacing),
    112 ))
    113 }
    114}
    115