univ3

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddrSwapRouterV1 = "0xE592427A0AEce92De3Edee1F18E0157C05861564" // SwapRouter (has deadline)
	AddrSwapRouter02 = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45" // SwapRouter02 (no deadline)
)

UniswapV3 router addresses on Arbitrum One (chain ID 42161)

View Source
const (
	SelectorExactInputSingleV1 = "414bf389" // exactInputSingle – SwapRouter v1
	SelectorExactInputSingleV2 = "04e45aaf" // exactInputSingle – SwapRouter02
	SelectorMulticall          = "ac9650d8" // multicall(bytes[])
	SelectorMulticallDeadline  = "5ae401dc" // multicall(uint256,bytes[]) – SwapRouter02
)

4-byte function selectors (hex, no 0x prefix)

Variables

This section is empty.

Functions

func EncodeExactInputSingle

func EncodeExactInputSingle(info *SwapInfo, recipient common.Address, deadline *big.Int, routerVer int) ([]byte, error)

EncodeExactInputSingle builds calldata for exactInputSingle on the given router version. For V1, deadline defaults to now+60s when nil.

func IsUniV3Router

func IsUniV3Router(addr string) (int, bool)

IsUniV3Router returns (routerVersion, true) when addr is a known UniV3 router.

Types

type SwapInfo

type SwapInfo struct {
	TokenIn           common.Address
	TokenOut          common.Address
	Fee               uint32 // uint24 in Solidity; go-ethereum maps uint24 → uint32
	Recipient         common.Address
	Deadline          *big.Int // nil for SwapRouter02 (no deadline field)
	AmountIn          *big.Int
	AmountOutMinimum  *big.Int
	SqrtPriceLimitX96 *big.Int
	RouterVersion     int // 1 = SwapRouterV1, 2 = SwapRouter02
}

SwapInfo holds decoded parameters from a UniV3 exactInputSingle call.

func DecodeSwapInfo

func DecodeSwapInfo(calldata []byte, routerVer int) (*SwapInfo, error)

DecodeSwapInfo decodes a UniV3 exactInputSingle calldata (direct call or inside multicall). routerVer is 1 or 2 and is used only when the selector is multicall.

Jump to

Keyboard shortcuts

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