uniswap_v3

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 v3 factory: pool not found")
)
View Source
var (
	ErrWrongToken = errors.New("uniswap v3 pool: PriceOf: token not in pool")
)

Functions

This section is empty.

Types

type Pool

type Pool struct {
	Name    string
	Address common.Address

	Immutables PoolOpts
	State      PoolState
	// contains filtered or unexported fields
}

func Decode

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

func NewPool

func NewPool(client *ethclient.Client, name string, poolAddress string, immutables PoolOpts) (*Pool, error)

func (Pool) Encode

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

func (*Pool) PriceOf

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

func (*Pool) UpdateState

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

UpdateState updates the internal pool state. Should be called every time the state changes on-chain i.e. on a new block. Note that cached pools should have their states refreshed as well.

type PoolOpts

type PoolOpts struct {
	Token0 token.Token
	Token1 token.Token
	Fee    int64
}

type PoolState

type PoolState struct {
	SqrtPriceX96 *big.Int
	Tick         *big.Int
}

type UniswapV3

type UniswapV3 struct {
	Client *ethclient.Client

	Factory *univ3factory.Univ3factoryCaller
	// contains filtered or unexported fields
}

func New

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

func (*UniswapV3) GetPool

func (v3 *UniswapV3) GetPool(ctx context.Context, token0, token1 string, fee int64) (*Pool, error)

func (*UniswapV3) GetPoolAddress

func (v3 *UniswapV3) GetPoolAddress(ctx context.Context, token0, token1 string, fee int64) (common.Address, error)

func (*UniswapV3) GetPrice

func (v3 *UniswapV3) GetPrice(ctx context.Context, token0, token1 string, fee int64) (float64, error)

Jump to

Keyboard shortcuts

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