Documentation
¶
Index ¶
- Constants
- Variables
- func AppendUint24(b []byte, v uint32) []byte
- func ComputePoolAddress(key PoolKey) common.Address
- func ReadInt24(b []byte) int32
- func ReadUint24(b []byte) uint32
- func WriteUint24(dst []byte, v uint32)
- type BurnEvent
- type FactoryHandler
- type MintEvent
- type Path
- func (p Path) DecodeFirstPool() (tokenIn common.Address, tokenOut common.Address, fee uint32)
- func (p Path) FeeAt(pos int) uint32
- func (p Path) HasMultiplePools() bool
- func (p Path) NumPools() int
- func (p Path) Pools() []PoolKey
- func (p Path) SkipToken() Path
- func (p Path) String() string
- func (p Path) TokenAt(pos int) common.Address
- type PathBuilder
- type PathBuilderSetFee
- type PathBuilderSetNext
- type PoolCreatedEvent
- type PoolKey
- type PoolState
- type Slot0
- type SwapEvent
Constants ¶
const ( // Uint24Max is the maximum value representable as a uint24. Uint24Max = 0xFFFFFF // Uint24Size is the byte length of a uint24. Uint24Size = 3 )
const (
// FactoryCreationBlock is the Uniswap V3 factory deployment block on Ethereum mainnet.
FactoryCreationBlock = 12369621
)
Variables ¶
var ( // PoolCreatedEventID is the Uniswap V3 Factory PoolCreated event ID. // // PoolCreated(address,address,uint24,int24,address) PoolCreatedEventID = crypto.Keccak256Hash([]byte("PoolCreated(address,address,uint24,int24,address)")) // MintEventID is the Uniswap V3 Pool Mint event ID. // // Mint(address,address,int24,int24,uint128,uint256,uint256) MintEventID = crypto.Keccak256Hash([]byte("Mint(address,address,int24,int24,uint128,uint256,uint256)")) // SwapEventID is the Uniswap V3 Pool Swap event ID. // // Swap(address,address,int256,int256,uint160,uint128,int24) SwapEventID = crypto.Keccak256Hash([]byte("Swap(address,address,int256,int256,uint160,uint128,int24)")) // BurnEventID is the Uniswap V3 Pool Burn event ID. // // Burn(address,int24,int24,uint128,uint256,uint256) BurnEventID = crypto.Keccak256Hash([]byte("Burn(address,int24,int24,uint128,uint256,uint256)")) )
var ( // FactoryAddress is the Uniswap V3 factory address on Ethereum mainnet. FactoryAddress = common.HexToAddress("0x1F98431c8aD98523631AE4a59f267346ea31F984") )
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 BurnEvent ¶ added in v0.1.5
type BurnEvent struct {
// The owner of the position for which liquidity is removed
Owner common.Address
// The lower tick of the position
TickLower int32 // int24
// The upper tick of the position
TickUpper int32 // int24
// The amount of liquidity to remove
Amount uint256.Int // uint128
// The amount of token0 withdrawn
Amount0 uint256.Int // uint256
// The amount of token1 withdrawn
Amount1 uint256.Int // uint256
}
BurnEvent is a decoded Uniswap V3 Pool Burn event.
type FactoryHandler ¶ added in v0.1.5
func NewFactoryHandler ¶ added in v0.1.5
func NewFactoryHandler() *FactoryHandler
func (*FactoryHandler) Filter ¶ added in v0.1.5
func (f *FactoryHandler) Filter() ethindexer.Filter
type MintEvent ¶ added in v0.1.5
type MintEvent struct {
// The address that minted the liquidity
Sender common.Address
// The owner of the position and recipient of any minted liquidity
Owner common.Address
// The lower tick of the position
TickLower int32 // int24
// The upper tick of the position
TickUpper int32 // int24
// The amount of liquidity minted to the position range
Amount uint256.Int // uint128
// How much token0 was required for the minted liquidity
Amount0 uint256.Int // uint256
// How much token1 was required for the minted liquidity
Amount1 uint256.Int // uint256
}
MintEvent is a decoded Uniswap V3 Pool Mint event.
type Path ¶ added in v0.1.4
type Path []byte
Path is an encoded Uniswap V3 swap path.
func (Path) DecodeFirstPool ¶ added in v0.1.4
DecodeFirstPool returns the first pool encoded in the path.
func (Path) FeeAt ¶ added in v0.1.4
FeeAt returns the pool fee at position pos.
from [--fee--> hop]... --fee--> to
0 1..n-1 n
func (Path) HasMultiplePools ¶ added in v0.1.4
HasMultiplePools reports whether the path contains more than one pool.
type PathBuilder ¶ added in v0.1.4
type PathBuilder interface {
// From sets the input token.
From(common.Address) PathBuilderSetFee
}
PathBuilder builds a swap path from the input token.
func NewPathBuilder ¶
func NewPathBuilder() PathBuilder
NewPathBuilder returns a new swap path builder.
type PathBuilderSetFee ¶ added in v0.1.4
type PathBuilderSetFee interface {
// Fee appends the fee for the next pool.
Fee(uint32) PathBuilderSetNext
}
PathBuilderSetFee continues a swap path by setting the next pool fee.
type PathBuilderSetNext ¶ added in v0.1.4
type PathBuilderSetNext interface {
// Hop appends an intermediate token.
Hop(common.Address) PathBuilderSetFee
// To appends the output token and returns the encoded path.
To(common.Address) Path
}
PathBuilderSetNext continues or completes a swap path.
type PoolCreatedEvent ¶ added in v0.1.5
type PoolCreatedEvent struct {
// The first token of the pool by address sort order
Token0 common.Address
// The second token of the pool by address sort order
Token1 common.Address
// The fee collected upon every swap in the pool, denominated in hundredths of a bip
Fee uint32 // uint24
// The minimum number of ticks between initialized ticks
TickSpacing int32 // int24
// The address of the created pool
Pool common.Address
}
PoolCreatedEvent is a decoded Uniswap V3 Factory PoolCreated event.
func UnpackPoolCreatedEvent ¶ added in v0.1.5
func UnpackPoolCreatedEvent(log types.Log) (*PoolCreatedEvent, error)
UnpackPoolCreatedEvent decodes a Uniswap V3 Factory PoolCreated event.
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 PoolState ¶ added in v0.1.5
type PoolState struct {
Slot0 Slot0
Liquidity uint256.Int // uint128
TickSpacing int32 // in24
TickBitmap map[int16]uint256.Int
Ticks map[int32]tick_Info
}
func (*PoolState) Initialized ¶ added in v0.1.6
type SwapEvent ¶ added in v0.1.5
type SwapEvent struct {
// The address that initiated the swap call, and that received the callback
Sender common.Address
// The address that received the output of the swap
Recipient common.Address
// The delta of the token0 balance of the pool
Amount0 uint256.Int // int256
// The delta of the token1 balance of the pool
Amount1 uint256.Int // int256
// The sqrt(price) of the pool after the swap, as a Q64.96
SqrtPriceX96 uint256.Int // uint160
// The liquidity of the pool after the swap
Liquidity uint256.Int // uint128
// The log base 1.0001 of price of the pool after the swap
Tick int32 // int24
}
SwapEvent is a decoded Uniswap V3 Pool Swap event.