Documentation
¶
Index ¶
- Variables
- func FormatEther(wei decimal.Decimal) string
- func GetAddress(tokenA, tokenB Token) common.Address
- func NewCaller(link string) (*ethclient.Client, error)
- func ParseEther(i interface{}) decimal.Decimal
- type ChainId
- type Desc
- type Fetcher
- type Pair
- func (p Pair) GetInputAmount(outputAmount TokenAmount) (TokenAmount, Pair, error)
- func (p Pair) GetLiquidityAmount(token Token, totalSupply *big.Int, liquidity TokenAmount, feeOn bool, ...) (TokenAmount, error)
- func (p Pair) GetLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB TokenAmount) (TokenAmount, error)
- func (p Pair) GetOutputAmount(inputAmount TokenAmount) (TokenAmount, Pair, error)
- func (p Pair) Reverse0() TokenAmount
- func (p Pair) Reverse1() TokenAmount
- func (p Pair) ReverseOf(token Token) TokenAmount
- func (p Pair) String() string
- func (p Pair) Token0() Token
- func (p Pair) Token1() Token
- type Token
- type TokenAmount
- type Tokens
Constants ¶
This section is empty.
Variables ¶
View Source
var ( InsufficientAmountError = errors.New("insufficient amount") TokenExistError = errors.New("pair not this token") )
InsufficientAmountError errors
View Source
var BigFive = decimal.NewFromInt(5)
View Source
var BigOne = decimal.NewFromInt(1)
View Source
var BigTen = decimal.NewFromInt(10)
View Source
var BigZero = decimal.NewFromInt(0)
View Source
var FactoryAddressMap = map[ChainId]string{
BscMain: "0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73",
BscTest: "0x6725f303b657a9451d8ba641348b6761a6cc7a17",
EthMain: "0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f",
}
View Source
var FeesDenominator = decimal.NewFromInt(10000)
View Source
var FeesNumerator = decimal.NewFromInt(9975)
View Source
var InitCodeHash = map[ChainId]string{
BscMain: "0x00fb7f630766e6a796048ea87d01acd3068e8ff67d078148a3fa3f4a84f69bd5",
BscTest: "0xd0d4c4cd0848c93cb4fd1f498d7013ee6bfb25783ea21593d5834f5d250ece66",
EthMain: "0x96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f",
}
View Source
var MinimumLiquidity = decimal.NewFromInt(1000)
View Source
var PairAddressCache = map[string]common.Address{}
PairAddressCache cache already query pair
Functions ¶
func FormatEther ¶
func GetAddress ¶
GetAddress get Pair address can without Pair Constructor
func ParseEther ¶
Types ¶
type ChainId ¶
type ChainId int64
ChainId Public Blockchain Known Identify
const ( EthMain ChainId = 1 // ethereum mainnet Ropsten ChainId = 3 // ethereum Ropsten testnet Rinkeby ChainId = 4 // ethereum Rinkeby testnet Goerli ChainId = 5 // ethereum Goerli testnet Kovan ChainId = 42 // ethereum Kovan testnet BscMain ChainId = 56 // bsc mainnet BscTest ChainId = 97 // bsc testnet OkcMain ChainId = 66 // okc mainnet OkcTest ChainId = 65 // okc testnet HecoMain ChainId = 128 // heco mainnet HecoTest ChainId = 256 // heco testnet PolygonMain ChainId = 137 // polygon mainnet Mumbai ChainId = 80001 // polygon mumbai testnet Ganache ChainId = 8545 // local testnet )
type Desc ¶
type Desc struct { Name string `json:"name" yaml:"name"` // obj name Symbol string `json:"symbol" yaml:"symbol"` // obj symbol }
Desc Blockchain Object Description
type Fetcher ¶
type Fetcher struct { ChainId ChainId // contains filtered or unexported fields }
func NewFetcher ¶
func NewFetcher(b bind.ContractBackend, chainId ChainId) Fetcher
func (Fetcher) GetReverses ¶
GetReverses currently support bsc
func (Fetcher) GetTokenInfo ¶ added in v0.1.3
type Pair ¶
type Pair struct { LiquidityToken Token TokenAmounts [2]TokenAmount }
Pair trading pair
func (Pair) GetInputAmount ¶
func (p Pair) GetInputAmount(outputAmount TokenAmount) (TokenAmount, Pair, error)
GetInputAmount provide output amount calc input amount
func (Pair) GetLiquidityAmount ¶ added in v0.1.3
func (p Pair) GetLiquidityAmount(token Token, totalSupply *big.Int, liquidity TokenAmount, feeOn bool, kLast *big.Int) (TokenAmount, error)
GetLiquidityAmount get liquidity amount
func (Pair) GetLiquidityMinted ¶
func (p Pair) GetLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB TokenAmount) (TokenAmount, error)
GetLiquidityMinted calc lp has been minted
func (Pair) GetOutputAmount ¶
func (p Pair) GetOutputAmount(inputAmount TokenAmount) (TokenAmount, Pair, error)
GetOutputAmount provide input amount calc output amount
func (Pair) Reverse0 ¶
func (p Pair) Reverse0() TokenAmount
func (Pair) Reverse1 ¶
func (p Pair) Reverse1() TokenAmount
func (Pair) ReverseOf ¶
func (p Pair) ReverseOf(token Token) TokenAmount
type Token ¶
type Token struct { Desc Decimals int8 `json:"decimals" yaml:"decimals"` // token decimals Address string `json:"address" yaml:"address"` // token address ChainId ChainId `json:"chainId" yaml:"chainId"` // token chain id enum }
Token Represents an ERC20 token with a unique address and some metadata.
func (Token) SortsBefore ¶
SortsBefore check is sort before new object
type TokenAmount ¶
func NewTokenAmount ¶
func NewTokenAmount(token Token, amount decimal.Decimal) TokenAmount
func (TokenAmount) Add ¶
func (ta TokenAmount) Add(other TokenAmount) TokenAmount
func (TokenAmount) Sub ¶
func (ta TokenAmount) Sub(other TokenAmount) TokenAmount
type Tokens ¶
type Tokens struct { List []Token // contains filtered or unexported fields }
Tokens list of unique token
func (Tokens) AppendAndSort ¶
AppendAndSort Append new token to list
Source Files
¶
Click to show internal directories.
Click to hide internal directories.