exchanges

package
v0.0.0-...-dee77e4 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterExchange

func RegisterExchange(name string, constructor RouterConstructor)

func Registered

func Registered() []string

Types

type Router

type Router interface {
	Name() string
	GetRouterAddress() common.Address
	GetFactoryAddress() common.Address
	GetRouterContract() RouterContract
	GetAllPairs(ctx context.Context) ([]common.Address, error)
	GetAllPairsAsync(ctx context.Context) (int64, chan *common.Address, chan error)

	GetPairInfo(address common.Address) (*models.LiquidityPool, error)
	GetPairPrice(address common.Address, token0Amount int64, token1Amount int64) (*TradeInfo, error)
	GetReserves(address common.Address) (float64, float64, error)
}

func New

func New(name string, client *ethclient.Client, address string) (Router, error)

type RouterConstructor

type RouterConstructor func(client *ethclient.Client, address string) (Router, error)

type RouterContract

type RouterContract interface {
	// GetAmountIn(opts *bind.CallOpts, amountOut *big.Int, reserveIn *big.Int, reserveOut *big.Int) (*big.Int, error)
	// GetAmountOut(opts *bind.CallOpts, amountIn *big.Int, reserveIn *big.Int, reserveOut *big.Int) (*big.Int, error)
	GetAmountsIn(opts *bind.CallOpts, amountOut *big.Int, path []common.Address) ([]*big.Int, error)
	GetAmountsOut(opts *bind.CallOpts, amountIn *big.Int, path []common.Address) ([]*big.Int, error)
}

type TradeInfo

type TradeInfo struct {
	Token0Price float64
	Token1Price float64
}

func (TradeInfo) Slippage

func (t TradeInfo) Slippage() float64

func (TradeInfo) String

func (t TradeInfo) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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