Documentation ¶
Overview ¶
Package uniswap provdies a Golang client wrapper for UniswapV2
Package uniswap contains the required bindings as well as corresponding wrappers for those bindings for interacting with the uniswap smart contracts.
Index ¶
- Constants
- Variables
- func GeneratePairAddress(token0, token1 common.Address, chain int) common.Address
- func Quote(amount, reserve0, reserve1 *big.Int) *big.Int
- type Client
- func (c *Client) Factory() (*uniswapv2factory.Uniswapv2factory, error)
- func (c *Client) GetExchangeAmount(amount *big.Int, token0, token1 common.Address) (*big.Int, error)
- func (c *Client) GetExchangeAmountForPath(amount *big.Int, tokens ...common.Address) (*big.Int, error)
- func (c *Client) GetFactory(addr common.Address) (common.Address, error)
- func (c *Client) GetReserveFromPair(addr common.Address) (*Reserve, error)
- func (c *Client) GetReserves(token0, token1 common.Address) (*Reserve, error)
- func (c *Client) GetReservesInBlock(token0, token1 common.Address, bn int64) (*Reserve, error)
- func (c *Client) GetReservesInBlockByPair(pair common.Address, bn int64) (*Reserve, error)
- func (c *Client) GetTokens(addr common.Address) ([]common.Address, error)
- type Pair
- type Reserve
Constants ¶
const ( Ethereum = iota Base BSC Unsupported )
Variables ¶
var FactoryAddressBSC = common.HexToAddress("0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6")
var FactoryAddressBase = common.HexToAddress("0x8909Dc15e40173Ff4699343b6eB8132c65e18eC6")
var FactoryAddressEth = common.HexToAddress("0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f")
FactoryAddressEth points to the uniswap factory.
var Router02Address = common.HexToAddress("0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D")
Router02Address points to the uniswap v2 02 router.
Functions ¶
func GeneratePairAddress ¶
GeneratePairAddress generates a pair address for the given tokens
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client allows to do operations on uniswap smart contracts.
func NewClient ¶
func NewClient(bc utils.Blockchain, chain int) *Client
NewClient returns a new instance of uniswap client.
func (*Client) Factory ¶
func (c *Client) Factory() (*uniswapv2factory.Uniswapv2factory, error)
Factory returns a uniswap cactory factory binding
func (*Client) GetExchangeAmount ¶
func (c *Client) GetExchangeAmount(amount *big.Int, token0, token1 common.Address) (*big.Int, error)
GetExchangeAmount returns the amount of tokens you'd receive when exchanging the given amount of token0 to token1.
func (*Client) GetExchangeAmountForPath ¶
func (c *Client) GetExchangeAmountForPath(amount *big.Int, tokens ...common.Address) (*big.Int, error)
GetExchangeAmountForPath calculates the amount for a given path.
func (*Client) GetFactory ¶
GetFactory returns the factory address for a given pair
func (*Client) GetReserveFromPair ¶
GetReserves retursn the available reserves in a pair
func (*Client) GetReserves ¶
GetReserves retursn the available reserves in a pair
func (*Client) GetReservesInBlock ¶
GetReserves retursn the available reserves in a pair
func (*Client) GetReservesInBlockByPair ¶
GetReserves retursn the available reserves in a pair
type Pair ¶
Pair represents a token pair.
func GetPathPairs ¶
GetPathPairs takes in the given token path and returns the corresponding pairs.