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 ¶
- Variables
- func GeneratePairAddress(token0, token1 common.Address, isUniswap bool) common.Address
- func Quote(amount, reserve0, reserve1 *big.Int) *big.Int
- type Client
- func (c *Client) BC() utils.Blockchain
- func (c *Client) Factory(addr *common.Address) (*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) GetReserves(token0, token1 common.Address) (*Reserve, error)
- func (c *Client) IsUniswap() bool
- func (c *Client) Router() (*uniswapv2router.Uniswapv2router, error)
- type Pair
- type Reserve
Constants ¶
This section is empty.
Variables ¶
var ( // UniFactoryAddress is the address of the uniswap factory contract UniFactoryAddress = common.HexToAddress("0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f") // UniRouter02Address is the address of the uniswap v2 02 router UniRouter02Address = common.HexToAddress("0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D") // PanFactoryAddress is the address of the pancake swap factory contract PanFactoryAddress = common.HexToAddress("0xBCfCcbde45cE874adCB698cC183deBcF17952812") // PanRouter02Address is the address of the pancake v2 02 router PanRouter02Address = common.HexToAddress("0x05fF2B0DB69458A0750badebc4f9e13aDd608C7F") )
Functions ¶
func GeneratePairAddress ¶
GeneratePairAddress generates a pair address for the given tokens if isUniswap is set to false than we assume pancake swap, otherwise we assume uniswap
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, uniswap bool) *Client
NewClient returns a new instance of uniswap client.
func (*Client) Factory ¶
func (c *Client) Factory(addr *common.Address) (*uniswapv2factory.Uniswapv2factory, error)
Factory returns the corresponding factory contract if addr is not nil we use that, otherwise use an address based off configuration
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) GetReserves ¶
GetReserves retursn the available reserves in a pair
func (*Client) IsUniswap ¶
IsUniswap returns true if this client is for uniswap or false for pancake swap
func (*Client) Router ¶
func (c *Client) Router() (*uniswapv2router.Uniswapv2router, error)
Router returns the corresponding router contract
type Pair ¶
Pair represents a token pair.
func GetPathPairs ¶
GetPathPairs takes in the given token path and returns the corresponding pairs.