Documentation
¶
Index ¶
- func Pair2Assets(pair TradingPair) (horizon.Asset, horizon.Asset)
- func ParseAsset(code string, issuer string) horizon.Asset
- func Path2Assets(path *PaymentPath) (horizon.Asset, horizon.Asset, horizon.Asset)
- func PathAsset2Asset(p PathAsset) horizon.Asset
- func PathAsset2BuildAsset(p PathAsset) build.Asset
- type ArbitCycleConfig
- type AssetGroup
- type BasicOrderBookLevel
- type DexAgent
- type DexWatcher
- func (w *DexWatcher) AddTrackedBook(ctx context.Context, pair TradingPair, limit string) error
- func (w *DexWatcher) GetLowAsk(pair TradingPair) (*model.Number, *model.Number, error)
- func (w *DexWatcher) GetOrderBook(api *horizon.Client, pair TradingPair) (orderBook horizon.OrderBookSummary, e error)
- func (w *DexWatcher) GetPaths(endAsset horizon.Asset, amount *model.Number, tradingAccount string) (*FindPathResponse, error)
- func (w *DexWatcher) GetTopBid(pair TradingPair) (*model.Number, *model.Number, error)
- func (w *DexWatcher) StreamLedgers(ctx context.Context, cursor *horizon.Cursor, handler horizon.LedgerHandler, ...)
- func (w *DexWatcher) StreamManager(pairList []TradingPair)
- type FindPathResponse
- type GroupInput
- type PairBookEntry
- type PathAsset
- type PathFindOutcome
- type PathFinder
- type PathPair
- type PathRecord
- type PaymentPath
- type TradingPair
- type TransData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Pair2Assets ¶
func Pair2Assets(pair TradingPair) (horizon.Asset, horizon.Asset)
Pair2Assets splits a TradingPair into its assets
func ParseAsset ¶
ParseAsset returns a horizon asset from strings
func Path2Assets ¶
Path2Assets returns the assets inside a PaymentPath
func PathAsset2Asset ¶
PathAsset2Asset turns a PathRecord asset into a horizon asset
func PathAsset2BuildAsset ¶
PathAsset2BuildAsset turns a PathRecord asset into a build asset
Types ¶
type ArbitCycleConfig ¶
type ArbitCycleConfig struct {
MinRatio float64 `valid:"-" toml:"MIN_RATIO"`
Groups []GroupInput `valid:"-" toml:"GROUPS"`
}
ArbitCycleConfig holds the arbitrage strategy settings
type AssetGroup ¶
type AssetGroup struct {
HoldAsset horizon.Asset
AssetBook []horizon.Asset
PathList []*PaymentPath
PairBook []PairBookEntry
MinAmount *model.Number
// contains filtered or unexported fields
}
AssetGroup is an operational asset set and its settings
type BasicOrderBookLevel ¶
BasicOrderBookLevel is just a price and an amount
type DexAgent ¶
type DexAgent struct {
API *horizon.Client
SourceSeed string
TradingSeed string
SourceAccount string
TradingAccount string
Network build.Network
// contains filtered or unexported fields
}
DexAgent manages all transactions with the Stellar DEX
func MakeDexAgent ¶
func MakeDexAgent( api *horizon.Client, sourceSeed string, tradingSeed string, sourceAccount string, tradingAccount string, network build.Network, threadTracker *multithreading.ThreadTracker, rateLimiter func(), submitDone chan<- bool, operationalBuffer float64, minRatio float64, simMode bool, l logger.Logger, ) *DexAgent
MakeDexAgent is the factory method
func (*DexAgent) JustAssetBalance ¶
JustAssetBalance returns asset balance
func (*DexAgent) SendPaymentCycle ¶
func (dA *DexAgent) SendPaymentCycle(path *PaymentPath, maxAmount *model.Number) error
SendPaymentCycle executes a payment cycle
type DexWatcher ¶
type DexWatcher struct {
API *horizon.Client
Network build.Network
// contains filtered or unexported fields
}
DexWatcher is an object that queries the DEX
func MakeDexWatcher ¶
func MakeDexWatcher( api *horizon.Client, network build.Network, threadTracker *multithreading.ThreadTracker, rateLimiter func(), booksOut chan<- *horizon.OrderBookSummary, ledgerOut chan horizon.Ledger, l logger.Logger) *DexWatcher
MakeDexWatcher is the factory method
func (*DexWatcher) AddTrackedBook ¶
func (w *DexWatcher) AddTrackedBook(ctx context.Context, pair TradingPair, limit string) error
AddTrackedBook adds a pair's orderbook to the BookTracker
func (*DexWatcher) GetLowAsk ¶
func (w *DexWatcher) GetLowAsk(pair TradingPair) (*model.Number, *model.Number, error)
GetLowAsk returns the low ask's price and amount for a trading pair
func (*DexWatcher) GetOrderBook ¶
func (w *DexWatcher) GetOrderBook(api *horizon.Client, pair TradingPair) (orderBook horizon.OrderBookSummary, e error)
GetOrderBook gets the SDEX order book
func (*DexWatcher) GetPaths ¶
func (w *DexWatcher) GetPaths(endAsset horizon.Asset, amount *model.Number, tradingAccount string) (*FindPathResponse, error)
GetPaths gets and parses the find-path data for an asset from horizon
func (*DexWatcher) GetTopBid ¶
func (w *DexWatcher) GetTopBid(pair TradingPair) (*model.Number, *model.Number, error)
GetTopBid returns the top bid's price and amount for a trading pair
func (*DexWatcher) StreamLedgers ¶
func (w *DexWatcher) StreamLedgers( ctx context.Context, cursor *horizon.Cursor, handler horizon.LedgerHandler, limit int, order string, )
StreamLedgers streams Stellar ledgers
func (*DexWatcher) StreamManager ¶
func (w *DexWatcher) StreamManager(pairList []TradingPair)
StreamManager just refreshes the streams as they expire; horizon closes them after 55 seconds on its own
type FindPathResponse ¶
type FindPathResponse struct {
Embedded struct {
Records []PathRecord `json:"records"`
} `json:"_embedded"`
}
FindPathResponse holds the raw JSON for a horizon call
type GroupInput ¶
type GroupInput struct {
HoldAssetCode string `valid:"-" toml:"HOLD_ASSET_CODE"`
HoldAssetIssuer string `valid:"-" toml:"HOLD_ASSET_ISSUER"`
UseBalance bool `valid:"-" toml:"USE_BALANCE"`
StaticAmount float64 `valid:"-" toml:"STATIC_AMOUNT"`
MinAmount float64 `valid:"-" toml:"MIN_AMOUNT"`
Assets []assetInput `valid:"-" toml:"ASSETS"`
}
GroupInput holds the inbound strings for the asset groups
type PairBookEntry ¶
type PairBookEntry struct {
ID int
Pair TradingPair
}
PairBookEntry is a numbered trading pair
type PathAsset ¶
type PathAsset struct {
AssetType string `json:"asset_type"`
AssetCode string `json:"asset_code"`
AssetIssuer string `json:"asset_issuer"`
}
PathAsset is a single asset in a path
type PathFindOutcome ¶
type PathFindOutcome struct {
BestPath *PaymentPath
MaxAmount *model.Number
MetThreshold bool
}
PathFindOutcome sends the outcome of the find-best-path
type PathFinder ¶
type PathFinder struct {
AssetGroups []*AssetGroup
// contains filtered or unexported fields
}
PathFinder keeps track of all the possible payment paths
func MakePathFinder ¶
func MakePathFinder( dexWatcher DexWatcher, stratConfig ArbitCycleConfig, rateLimiter func(), findIt chan bool, pathReturn chan<- PathFindOutcome, refresh <-chan bool, l logger.Logger, ) (*PathFinder, error)
MakePathFinder is a factory method
func (*PathFinder) FindBestPathConcurrent ¶
func (p *PathFinder) FindBestPathConcurrent()
FindBestPathConcurrent determines and returns the most profitable payment path with goroutines
type PathPair ¶
type PathPair struct {
PairID int
Pair TradingPair
}
PathPair is a trading pair with a price inversion flag
type PathRecord ¶
type PathRecord struct {
SourceAssetType string `json:"source_asset_type"`
SourceAmount string `json:"source_amount"`
DestinationAssetType string `json:"destination_asset_type"`
DestinationAssetCode string `json:"destination_asset_code"`
DestinationAssetIssuer string `json:"destination_asset_issuer"`
DestinationAmount string `json:"destination_amount"`
Path []PathAsset `json:"path"`
}
PathRecord is a single horizon find path record
type PaymentPath ¶
type PaymentPath struct {
HoldAsset horizon.Asset
PathAssetA horizon.Asset
PathAssetB horizon.Asset
PathSequence []PathPair
UseBalance bool
StaticAmount *model.Number
MinAmount *model.Number
}
PaymentPath is a pair of assets for a payment path and their encoded tradingPair
type TradingPair ¶
TradingPair represents a trading pair
type TransData ¶
type TransData struct {
Path *PaymentPath
Amount *model.Number
}
TransData contains the data needed to contruct a path payment