pancakev2

package
v0.0.0-...-bfe7aad Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ethereum = iota
	Base
	BSC
	Unsupported
)

Variables

View Source
var FactoryAddressBSC = common.HexToAddress("0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73")
View Source
var FactoryAddressBase = common.HexToAddress("0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E")
View Source
var FactoryAddressEth = common.HexToAddress("0x1097053Fd2ea711dad45caCcc45EfF7548fCB362")

FactoryAddressEth points to the uniswap factory.

View Source
var Router02AddressBSC = common.HexToAddress("0x10ED43C718714eb63d5aA57B78B54704E256024E")
View Source
var Router02AddressBase = common.HexToAddress("0x8cFe327CEc66d1C090Dd72bd0FF11d690C33a2Eb")
View Source
var Router02AddressEth = common.HexToAddress("0xEfF92A263d31888d860bD50809A8D171709b7b1c")

Router02Address points to the uniswap v2 02 router.

Functions

func GeneratePairAddress

func GeneratePairAddress(token0, token1 common.Address, chain int) common.Address

GeneratePairAddress generates a pair address for the given tokens

func Quote

func Quote(amount, reserve0, reserve1 *big.Int) *big.Int

Quote gets the exchange quote for a given amount of tokens and the respective pairs reserves.

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) 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

func (c *Client) GetFactory(addr common.Address) (common.Address, error)

GetFactory returns the factory address for a given pair

func (*Client) GetReserveFromPair

func (c *Client) GetReserveFromPair(addr common.Address) (*Reserve, error)

GetReserves retursn the available reserves in a pair

func (*Client) GetReserves

func (c *Client) GetReserves(token0, token1 common.Address) (*Reserve, error)

GetReserves retursn the available reserves in a pair

func (*Client) GetReservesInBlock

func (c *Client) GetReservesInBlock(token0, token1 common.Address, bn int64) (*Reserve, error)

GetReserves retursn the available reserves in a pair

func (*Client) GetReservesInBlockByPair

func (c *Client) GetReservesInBlockByPair(pair common.Address, bn int64) (*Reserve, error)

GetReserves retursn the available reserves in a pair

func (*Client) GetTokens

func (c *Client) GetTokens(pair common.Address) ([]common.Address, error)

type Pair

type Pair struct {
	Token0, Token1 common.Address
}

Pair represents a token pair.

func GetPathPairs

func GetPathPairs(tokens []common.Address) []Pair

GetPathPairs takes in the given token path and returns the corresponding pairs.

type Reserve

type Reserve struct {
	Reserve0           *big.Int // Token
	Reserve1           *big.Int // QuoteToken
	BlockTimestampLast uint32
}

Reserve represents a given uniswap pair reserve

Jump to

Keyboard shortcuts

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