uniswap_v2

package
v0.0.0-...-19dd61d Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPoolNotFound = errors.New("uniswap v2 factory: pair not found")
)
View Source
var (
	ErrWrongToken = errors.New("uniswap v2 pool: PriceOf: token not in pool")
)

Functions

This section is empty.

Types

type Pair

type Pair struct {
	Name    string
	Address common.Address

	Immutables PairOpts
	State      PairState
	// contains filtered or unexported fields
}

func Decode

func Decode(poolBytes []byte) (*Pair, error)

func NewPair

func NewPair(client *ethclient.Client, name string, pairAddress string, immutables PairOpts) (*Pair, error)

func (Pair) Encode

func (p Pair) Encode() ([]byte, error)

func (*Pair) PriceOf

func (p *Pair) PriceOf(token string) (float64, error)

func (*Pair) UpdateState

func (p *Pair) UpdateState(ctx context.Context) error

type PairOpts

type PairOpts struct {
	Token0 token.Token
	Token1 token.Token
}

type PairState

type PairState struct {
	BlockTimestampLast uint32
	Reserve0           *big.Int
	Reserve1           *big.Int
}

type UniswapV2

type UniswapV2 struct {
	Client *ethclient.Client

	Factory *univ2factory.FactoryCaller
	// contains filtered or unexported fields
}

func New

func New(client *ethclient.Client, tokenManager token.TokenManager, factoryAddress string) *UniswapV2

func (*UniswapV2) GetPair

func (v2 *UniswapV2) GetPair(ctx context.Context, token0, token1 string) (*Pair, error)

func (*UniswapV2) GetPairAddress

func (v2 *UniswapV2) GetPairAddress(ctx context.Context, token0, token1 string) (common.Address, error)

func (*UniswapV2) GetPrice

func (v2 *UniswapV2) GetPrice(ctx context.Context, token0, token1 string) (float64, error)

Jump to

Keyboard shortcuts

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