Documentation
¶
Index ¶
- Constants
- Variables
- func AppendUint24(b []byte, v uint32) []byte
- func ComputePoolAddress(key PoolKey) common.Address
- func ReadUint24(b []byte) uint32
- func WriteUint24(dst []byte, v uint32)
- type PoolKey
- type SwapPath
- func (s SwapPath) DecodeFirstPool() (tokenIn common.Address, tokenOut common.Address, fee uint32)
- func (s SwapPath) FeeAt(pos int) uint32
- func (s SwapPath) HasMultiplePools() bool
- func (s SwapPath) NumPools() int
- func (s SwapPath) Pools() []PoolKey
- func (s SwapPath) SkipToken() SwapPath
- func (s SwapPath) String() string
- func (s SwapPath) TokenAt(pos int) common.Address
- type SwapPathBuilder
- type SwapPathBuilderSetFee
- type SwapPathBuilderSetNext
Constants ¶
const ( // Uint24Max is the maximum value representable as a uint24. Uint24Max = 0xffffff // Uint24Size is the byte length of a uint24. Uint24Size = 3 )
Variables ¶
var FactoryAddress = common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984")
FactoryAddress is the Uniswap V3 factory address on Ethereum mainnet.
var ( // PoolInitCodeHash is the Uniswap V3 pool init code hash. PoolInitCodeHash = common.HexToHash("0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54") )
Functions ¶
func AppendUint24 ¶
AppendUint24 appends v as a big-endian uint24.
func ComputePoolAddress ¶
ComputePoolAddress returns the deterministic Uniswap V3 pool address for key.
func WriteUint24 ¶
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 ¶
NewPoolKey returns the canonical key for token0, token1, and fee.
type SwapPath ¶
type SwapPath []byte
SwapPath is an encoded Uniswap V3 swap path.
func (SwapPath) DecodeFirstPool ¶
DecodeFirstPool returns the first pool encoded in the path.
func (SwapPath) FeeAt ¶
FeeAt returns the pool fee at position pos.
from [--fee--> hop]... --fee--> to
0 1..n-1 n
func (SwapPath) HasMultiplePools ¶
HasMultiplePools reports whether the path contains more than one pool.
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.