pdex_v3

package
v1.0.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxPaths      = 5
	BaseAmplifier = 10000
)
View Source
const (
	TradeDirectionSell0 = iota
)

Variables

This section is empty.

Functions

func FindGoodTradePath

func FindGoodTradePath(
	maxPathLen uint,
	poolPairStates map[string]*jsonresult.Pdexv3PoolPairState,
	tokenIDStrSource string,
	tokenIDStrDest string,
	originalSellAmount uint64,
) ([]*jsonresult.Pdexv3PoolPair, []string, uint64)

FindGoodTradePath attempts to find a good enough trading path for the given trading pair, selling amount, and pool pairs.

func TradePathFromState

func TradePathFromState(
	sellToken common.Hash,
	tradePath []string,
	pairs map[string]*jsonresult.Pdexv3PoolPairState,
) (
	[]*jsonresult.Pdexv3PoolPair, []v2.OrderBookIterator, []byte, error,
)

Types

type Node

type Node struct {
	TokenIDStr     string
	TokenPoolValue *big.Int
}

type Order

type Order = jsonresult.Pdexv3Order

type OrderBook

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

func NewOrderBook

func NewOrderBook(tmpOrder jsonresult.Pdexv3Orderbook) OrderBook

func (*OrderBook) InsertOrder

func (ob *OrderBook) InsertOrder(ord *Order)

InsertOrder appends a new order while keeping the list sorted (ascending by Token1Rate / Token0Rate)

func (OrderBook) MarshalJSON

func (ob OrderBook) MarshalJSON() ([]byte, error)

func (*OrderBook) NextOrder

func (ob *OrderBook) NextOrder(tradeDirection byte) (*v2.MatchingOrder, string, error)

NextOrder returns the matchable order with the best rate that has any outstanding balance to sell

func (*OrderBook) RemoveOrder

func (ob *OrderBook) RemoveOrder(index int) error

RemoveOrder removes one order by its index

func (*OrderBook) UnmarshalJSON

func (ob *OrderBook) UnmarshalJSON(data []byte) error

type PriceCalculator

type PriceCalculator struct {
	Graph map[string][]Node
}

type SimplePoolNodeData

type SimplePoolNodeData struct {
	Token0ID  string
	Token1ID  string
	Token0Liq *big.Int
	Token1Liq *big.Int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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