uniswap

package module
v0.0.0-...-ccd9fc1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: MIT Imports: 5 Imported by: 0

README

Uniswap go SDK

This is the unofficial go version of uniswap-sdk written in type script.

Status

This project is a work in progress, features will be added and API will change.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ETHER = &Currency{Decimals: 18, Symbol: "ETH", Name: "Ether"}

ETHER represents ether.

Functions

func FetchPairData

func FetchPairData(client *ethclient.Client)

FetchPairData fetches information about a pair and constructs a pair from the given two tokens.

Types

type ChainID

type ChainID int

ChainID represents a chain ID.

const (
	MAINNET ChainID = 1
	ROPSTEN ChainID = 3
	RINKEBY ChainID = 4
	GÖRLI   ChainID = 5
	KOVAN   ChainID = 42
)

Define some known chain IDs.

type Currency

type Currency struct {
	// TODO: use bigint?
	Decimals uint8
	Symbol   string
	Name     string
}

Currency is any fungible financial instrument on Ethereum, including Ether and all ERC20 tokens.

func NewCurrency

func NewCurrency(decimals uint8, symbol, name string) *Currency

NewCurrency return a new currency. TODO: Is using uint8 type to represent decimals correct?

type Fetcher

type Fetcher struct {
	// contains filtered or unexported fields
}

Fetcher represents a fetcher.

func NewFetcher

func NewFetcher(client *ethclient.Client) *Fetcher

NewFetcher creates a new fetcher.

func (*Fetcher) FetchTokenData

func (f *Fetcher) FetchTokenData(chainID ChainID, address string) (*Token, error)

FetchTokenData fetches information for a given token on the given chain, using the given ethers client.

type Token

type Token struct {
	*Currency
	ChainID ChainID
	Address common.Address
}

Token represents an ERC20 token with a unique address and some metadata. TODO: To enforce read only, should Token be an interface instead?

func NewToken

func NewToken(chainID ChainID, address string, decimals uint8, symbol, name string) (*Token, error)

NewToken return a new Token.

func (*Token) Equals

func (t *Token) Equals(token *Token) bool

Equals return true if the two tokens are equivalent, i.e. have the same chainId and address.

func (*Token) SortsBefore

func (t *Token) SortsBefore(token *Token) bool

SortsBefore return true if the address of t token sorts before the address of token.

Directories

Path Synopsis
contracts

Jump to

Keyboard shortcuts

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