uniswapv3

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2026 License: MIT Imports: 4 Imported by: 0

README

univ3indexer

Documentation

Index

Constants

View Source
const (
	// Uint24Max is the maximum value representable as a uint24.
	Uint24Max = 0xffffff

	// Uint24Size is the byte length of a uint24.
	Uint24Size = 3
)

Variables

View Source
var FactoryAddress = common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984")

FactoryAddress is the Uniswap V3 factory address on Ethereum mainnet.

View Source
var (
	// PoolInitCodeHash is the Uniswap V3 pool init code hash.
	PoolInitCodeHash = common.HexToHash("0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54")
)

Functions

func AppendUint24

func AppendUint24(b []byte, v uint32) []byte

AppendUint24 appends v as a big-endian uint24.

func ComputePoolAddress

func ComputePoolAddress(key PoolKey) common.Address

ComputePoolAddress returns the deterministic Uniswap V3 pool address for key.

func ReadUint24

func ReadUint24(b []byte) uint32

ReadUint24 reads a big-endian uint24.

func WriteUint24

func WriteUint24(dst []byte, v uint32)

WriteUint24 writes v as a big-endian uint24.

Types

type PoolKey

type PoolKey [common.AddressLength*2 + Uint24Size]byte

PoolKey identifies a Uniswap V3 pool by its sorted token pair and fee.

func NewPoolKey

func NewPoolKey(token0, token1 common.Address, fee uint32) PoolKey

NewPoolKey returns the canonical key for token0, token1, and fee.

func (PoolKey) Fee

func (p PoolKey) Fee() uint32

Fee returns the pool fee.

func (PoolKey) String

func (p PoolKey) String() string

func (PoolKey) Token0

func (p PoolKey) Token0() common.Address

Token0 returns the lower-sorted token address.

func (PoolKey) Token1

func (p PoolKey) Token1() common.Address

Token1 returns the higher-sorted token address.

type SwapPath

type SwapPath []byte

SwapPath is an encoded Uniswap V3 swap path.

func (SwapPath) DecodeFirstPool

func (s SwapPath) DecodeFirstPool() (tokenIn common.Address, tokenOut common.Address, fee uint32)

DecodeFirstPool returns the first pool encoded in the path.

func (SwapPath) FeeAt

func (s SwapPath) FeeAt(pos int) uint32

FeeAt returns the pool fee at position pos.

from [--fee--> hop]... --fee--> to
        0        1..n-1          n

func (SwapPath) HasMultiplePools

func (s SwapPath) HasMultiplePools() bool

HasMultiplePools reports whether the path contains more than one pool.

func (SwapPath) NumPools

func (s SwapPath) NumPools() int

NumPools returns the number of pools encoded in the path.

func (SwapPath) Pools

func (s SwapPath) Pools() []PoolKey

Pools returns the pools encoded in the path, in swap order.

func (SwapPath) SkipToken

func (s SwapPath) SkipToken() SwapPath

SkipToken returns the path without its first token and fee.

func (SwapPath) String

func (s SwapPath) String() string

func (SwapPath) TokenAt

func (s SwapPath) TokenAt(pos int) common.Address

TokenAt returns the token at position pos.

from [--fee--> hop]... --fee--> to
  0           1..n              n+1

type SwapPathBuilder

type SwapPathBuilder interface {
	// From sets the input token.
	From(common.Address) SwapPathBuilderSetFee
}

SwapPathBuilder builds a swap path from the input token.

func NewPathBuilder

func NewPathBuilder() SwapPathBuilder

NewPathBuilder returns a new swap path builder.

type SwapPathBuilderSetFee

type SwapPathBuilderSetFee interface {
	// Fee appends the fee for the next pool.
	Fee(uint32) SwapPathBuilderSetNext
}

SwapPathBuilderSetFee continues a swap path by setting the next pool fee.

type SwapPathBuilderSetNext

type SwapPathBuilderSetNext interface {
	// Hop appends an intermediate token.
	Hop(common.Address) SwapPathBuilderSetFee

	// To appends the output token and returns the encoded path.
	To(common.Address) SwapPath
}

SwapPathBuilderSetNext continues or completes a swap path.

Jump to

Keyboard shortcuts

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