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 DexAgent
- func (dA *DexAgent) JustAssetBalance(asset horizon.Asset) (float64, error)
- func (dA *DexAgent) MakePathPayment(path *PaymentPath, amount *model.Number, minRatio *model.Number) (build.PaymentBuilder, error)
- func (dA *DexAgent) SendByFoundPath(path *PathRecord, holdAsset *horizon.Asset, maxAmount *model.Number) error
- func (dA *DexAgent) SendPaymentCycle(path *PaymentPath, maxAmount *model.Number) error
- func (dA *DexAgent) SubmitOps(ops []build.TransactionMutator, asyncCallback func(hash string, e error)) error
- type DexWatcher
- 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) (*FindPathResponse, error)
- func (w *DexWatcher) GetTopBid(pair TradingPair) (*model.Number, *model.Number, error)
- type FindPathResponse
- type PathAsset
- type PathFinder
- type PathRecord
- type PathRequester
- type PaymentPath
- type TradingPair
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 { HoldAssetCode string `valid:"-" toml:"HOLD_ASSET_CODE"` HoldAssetIssuer string `valid:"-" toml:"HOLD_ASSET_ISSUER"` MinRatio float64 `valid:"-" toml:"MIN_RATIO"` UseBalance bool `valid:"-" toml:"USE_BALANCE"` StaticAmount float64 `valid:"-" toml:"STATIC_AMOUNT"` MinAmount float64 `valid:"-" toml:"MIN_AMOUNT"` Assets []assetInput `valid:"-" toml:"ASSETS"` }
ArbitCycleConfig holds the arbitrage strategy settings
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, operationalBuffer float64, minRatio float64, useBalance bool, staticAmount float64, minAmount float64, simMode bool, l logger.Logger, ) *DexAgent
MakeDexAgent is the factory method
func (*DexAgent) JustAssetBalance ¶
JustAssetBalance returns asset balance
func (*DexAgent) MakePathPayment ¶
func (dA *DexAgent) MakePathPayment(path *PaymentPath, amount *model.Number, minRatio *model.Number) (build.PaymentBuilder, error)
MakePathPayment constructs and returns a path payment transaction for a given path object
func (*DexAgent) SendByFoundPath ¶
func (dA *DexAgent) SendByFoundPath(path *PathRecord, holdAsset *horizon.Asset, maxAmount *model.Number) error
SendByFoundPath executes a payment cycle for the find-path protocol
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 SourceAccount string TradingAccount string // contains filtered or unexported fields }
DexWatcher is an object that queries the DEX
func MakeDexWatcher ¶
func MakeDexWatcher( api *horizon.Client, network build.Network, sourceAccount string, tradingAccount string, l logger.Logger) *DexWatcher
MakeDexWatcher is the factory method
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) (*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
type FindPathResponse ¶
type FindPathResponse struct { Embedded struct { Records []PathRecord `json:"records"` } `json:"_embedded"` }
FindPathResponse holds the raw JSON for a horizon call
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 PathFinder ¶
PathFinder keeps track of all the possible payment paths
func MakePathFinder ¶
func MakePathFinder( dexWatcher DexWatcher, stratConfig ArbitCycleConfig, l logger.Logger, ) (*PathFinder, error)
MakePathFinder is a factory method
func (*PathFinder) FindBestPath ¶
func (p *PathFinder) FindBestPath() (*PaymentPath, *model.Number, bool, error)
FindBestPath determines and returns the most profitable payment path, its max amount, and whether its good enough
func (*PathFinder) WhatAmount ¶
func (p *PathFinder) WhatAmount() (bool, *model.Number)
WhatAmount returns the payment amount settings
func (*PathFinder) WhatRatio ¶
func (p *PathFinder) WhatRatio() *model.Number
WhatRatio returns the minimum ratio
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 PathRequester ¶
PathRequester keeps the assetbook and settings for the path-requesting method this prototype performed strictly worse than pathFinder so it's not implemented at this time preserving this for future revamp ideas
func MakePathRequester ¶
func MakePathRequester( dexWatcher DexWatcher, stratConfig ArbitCycleConfig, l logger.Logger, ) (*PathRequester, error)
MakePathRequester is a factory method
func (*PathRequester) AnalysePaths ¶
func (p *PathRequester) AnalysePaths() (*PathRecord, *model.Number, bool, error)
AnalysePaths asks horizon about available paths and checks if any are profitable
type PaymentPath ¶
type PaymentPath struct { HoldAsset horizon.Asset PathAssetA horizon.Asset PathAssetB horizon.Asset FirstPair TradingPair MidPair TradingPair LastPair TradingPair }
PaymentPath is a pair of assets for a payment path and their encoded tradingPair