Documentation ¶
Index ¶
- func FromRoute(route *Route) *fractions.Price
- func InputOutputComparator(a, b *InputOutput) int
- type BestTradeOptions
- type InputOutput
- type Pair
- func (p *Pair) ChainID() int
- func (p *Pair) GetInputAmount(outputAmount *fractions.TokenAmount) (*fractions.TokenAmount, Pair)
- func (p *Pair) GetLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB *fractions.TokenAmount) fractions.TokenAmount
- func (p *Pair) GetLiquidityValue(token *entities.Token, totalSupply, liquidity *fractions.TokenAmount, ...) fractions.TokenAmount
- func (p *Pair) GetOutputAmount(inputAmount *fractions.TokenAmount) (*fractions.TokenAmount, Pair)
- func (p *Pair) InvolvesToken(token *entities.Token) bool
- func (p *Pair) PriceOf(token *entities.Token) fractions.Price
- func (p *Pair) Reserve0() *fractions.TokenAmount
- func (p *Pair) Reserve1() *fractions.TokenAmount
- func (p *Pair) ReserveOf(token *entities.Token) *fractions.TokenAmount
- func (p *Pair) Token0() *entities.Token
- func (p *Pair) Token0Price() *fractions.Price
- func (p *Pair) Token1() *entities.Token
- func (p *Pair) Token1Price() *fractions.Price
- type Route
- type Trade
- func BestTradeExactIn(pairs []Pair, currencyAmountIn *fractions.TokenAmount, ...) []Trade
- func ExactIn(route *Route, amountIn *fractions.TokenAmount) *Trade
- func ExactOut(route *Route, amountOut *fractions.TokenAmount) *Trade
- func NewTrade(route *Route, amount *fractions.TokenAmount, tradeType constants.TradeType) *Trade
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InputOutputComparator ¶
func InputOutputComparator(a, b *InputOutput) int
InputOutputComparator is used to compare the two inuts and outputs
Types ¶
type BestTradeOptions ¶
type BestTradeOptions struct {
// contains filtered or unexported fields
}
BestTradeOptions can define how complex the trade calculation should be
type InputOutput ¶
type InputOutput struct {
// contains filtered or unexported fields
}
InputOutput the input and output amount for the trade
type Pair ¶
type Pair struct { LiquidityToken entities.Token `json:"liquidityToken,omitempty"` TokenAmount0 fractions.TokenAmount `json:"tokenAmount0,omitempty"` TokenAmount1 fractions.TokenAmount `json:"tokenAmount1,omitempty"` }
Pair the token pair used for exchange
func NewPair ¶
func NewPair(tokenAmount0, tokenAmount1 *fractions.TokenAmount, pairAddress string) *Pair
NewPair the main constructor for Pairs
func (*Pair) GetInputAmount ¶
func (p *Pair) GetInputAmount(outputAmount *fractions.TokenAmount) (*fractions.TokenAmount, Pair)
GetInputAmount get the input amount token in exchange for the output token
Example: BNB-BTT pair GetInputAmount(2 BNB) should check the current price of the BNB-BTT pair And return the exchangable amount of BTT as result
func (*Pair) GetLiquidityMinted ¶
func (p *Pair) GetLiquidityMinted(totalSupply, tokenAmountA, tokenAmountB *fractions.TokenAmount) fractions.TokenAmount
GetLiquidityMinted get the minted LiquidityToken amount depending on the input amounts
func (*Pair) GetLiquidityValue ¶
func (p *Pair) GetLiquidityValue(token *entities.Token, totalSupply, liquidity *fractions.TokenAmount, feeOn bool, last *big.Int) fractions.TokenAmount
GetLiquidityValue returns the actual value of the LiquidityToken
func (*Pair) GetOutputAmount ¶
func (p *Pair) GetOutputAmount(inputAmount *fractions.TokenAmount) (*fractions.TokenAmount, Pair)
GetOutputAmount get the output amount token in exchange for the input token
Example: BNB-BTT pair GetOutputAmount(2 BNB) should check the current price of the BNB-BTT pair And return the exchangable amount of BTT as result
func (*Pair) InvolvesToken ¶
InvolvesToken check wether the input token is part of the pair
func (*Pair) Reserve0 ¶
func (p *Pair) Reserve0() *fractions.TokenAmount
Reserve0 get the reserve amount of the first token
func (*Pair) Reserve1 ¶
func (p *Pair) Reserve1() *fractions.TokenAmount
Reserve1 get the reserve amount of the second token
func (*Pair) ReserveOf ¶
func (p *Pair) ReserveOf(token *entities.Token) *fractions.TokenAmount
ReserveOf get the reserve of the input token
func (*Pair) Token0Price ¶
Token0Price the price of the first token
func (*Pair) Token1Price ¶
Token1Price the price of the second token
type Route ¶
type Route struct { Pairs []Pair Path []*entities.Token Input, Output entities.Token // contains filtered or unexported fields }
Route defines which exchange route to take when trading
type Trade ¶
type Trade struct { Route TradeType constants.TradeType InputAmount, OutputAmount *fractions.CurrencyAmount ExecutionPrice, NextMidPrice *fractions.Price PriceImpact *fractions.Percent }
Trade is used for exchange trade deinitions
func BestTradeExactIn ¶
func BestTradeExactIn( pairs []Pair, currencyAmountIn *fractions.TokenAmount, currencyOut entities.Token, bestTradeOptions BestTradeOptions, currentPairs []Pair, originalAmountIn *fractions.TokenAmount, bestTrades []Trade, ) []Trade
BestTradeExactIn gets the best trade for the given pairs, when the exact input amount is set
func ExactIn ¶
func ExactIn(route *Route, amountIn *fractions.TokenAmount) *Trade
ExactIn calculates a trade for an exact input amount
func ExactOut ¶
func ExactOut(route *Route, amountOut *fractions.TokenAmount) *Trade
ExactOut calculates a trade for an exact output amount
func (*Trade) MinimumAmountIn ¶
func (t *Trade) MinimumAmountIn(slippageTolerance *fractions.Percent) fractions.CurrencyAmount
MinimumAmountIn defines what is the minimum amount wanted by exact input
func (*Trade) MinimumAmountOut ¶
func (t *Trade) MinimumAmountOut(slippageTolerance *fractions.Percent) fractions.CurrencyAmount
MinimumAmountOut defined what is the minimum amount wantd for the trade