trade

package
v0.0.0-...-a9b3359 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientManager

type ClientManager interface {
	GetClient(c.Context) interface{}
}

type ContractStorage

type ContractStorage interface {
	AddPair(
		c.Context, entities.TradePair,
	) error

	RemovePair(
		c.Context, string, string,
	) error

	GetPair(
		c.Context, string, string,
	) (entities.TradePair, error)

	GetPairs(
		c.Context, entities.SwapProtocol, entities.TokenPair,
	) ([]entities.TradePair, bool)

	SetPairs(
		c.Context, []entities.TradePair,
	) error

	ListPairs(c.Context) []entities.TradePair

	ClearPairs(c.Context)
}

type ParseCase

type ParseCase struct {
	Parser
	Repository
}

func NewParseCase

func NewParseCase(
	repo Repository,
	parse Parser,
) (
	pc ParseCase,
)

func (*ParseCase) AddProtocol

func (pc *ParseCase) AddProtocol(
	ctx context.Context,
	sp entities.SwapProtocol,
) (
	err error,
)

func (*ParseCase) Clear

func (pc *ParseCase) Clear(
	ctx context.Context,
)

func (*ParseCase) GetPairs

func (pc *ParseCase) GetPairs(
	ctx context.Context,
) (
	p []entities.TokenPair,
	err error,
)

func (*ParseCase) GetPools

func (pc *ParseCase) GetPools(
	ctx context.Context,
) (
	pools []entities.Pool,
	err error,
)

func (*ParseCase) JustParse

func (pc *ParseCase) JustParse(
	ctx context.Context,
) (
	pools []entities.Pool,
	err error,
)

func (*ParseCase) ParseAndStore

func (pc *ParseCase) ParseAndStore(
	ctx context.Context,
) (
	err error,
)

func (*ParseCase) ParsePairs

func (pc *ParseCase) ParsePairs(
	ctx context.Context,
	pairs []entities.TokenPair,
) (
	err error,
)

func (*ParseCase) RmProtocol

func (pc *ParseCase) RmProtocol(
	ctx context.Context,
	sp entities.SwapProtocol,
) (
	err error,
)

type ParseStore

type ParseStore interface {
	AddPool(
		entities.Pool,
	) error

	RemovePool(
		entities.Pool,
	) error

	GetPairPools(
		entities.TokenPair,
	) ([]entities.Pool, error)

	AddPools(
		[]entities.Pool,
	)

	ListPools() []entities.Pool

	Clear()
}

type Parser

type Parser interface {
	Parse([]entities.TokenPair) error

	ParseStore

	ProtocolManager
}

type PoolRepo

type PoolRepo interface {
	ListPools(
		c.Context, string,
	) ([]entities.Pool, error)

	StorePools(
		c.Context, string, []entities.Pool,
	) error

	AddPool(
		c.Context, entities.Pool, string,
	) error

	GetByTokens(
		c.Context, string, entities.TokenPair,
	) ([]entities.Pool, error)

	RemovePool(
		c.Context, string, entities.Pool,
	) error

	RemovePools(
		c.Context, string, []entities.Pool,
	) ([]entities.Pool, error)
}

type ProtocolManager

type ProtocolManager interface {
	ListProtocols() []entities.SwapProtocol

	AddProtocol(entities.SwapProtocol) error

	RemoveProtocol(entities.SwapProtocol) error

	GetPoolAddresses(entities.TokenPair) (map[entities.SwapProtocol]string, error)
}

type ProviderStorage

type ProviderStorage interface {
	AddToken(
		c.Context, entities.Token,
	) error

	GetToken(
		c.Context, string,
	) (entities.Token, error)

	RemoveToken(
		c.Context, entities.Token,
	) error

	SetTokens(
		c.Context, []entities.Token,
	) error

	ListTokens(
		c.Context,
	) []entities.Token

	Clear()
}

type Repository

type Repository interface {
	PoolRepo

	TokenRepo

	GetStorage() Storage
}

type SmartContract

type SmartContract interface {
	ContractStorage

	contract.Api
}

type Storage

type Storage interface {
	Store(
		c.Context, string, interface{},
	) error

	Read(
		c.Context, string, interface{},
	) error

	Remove(
		c.Context, string, interface{},
	) error

	Clear(
		c.Context, string,
	) error

	ClearAll(
		c.Context,
	) error
}

type TokenRepo

type TokenRepo interface {
	StoreTokens(
		c.Context, string, []entities.Token,
	) error

	AddToken(
		c.Context, string, entities.Token,
	) error

	ListTokens(
		c.Context, string,
	) ([]entities.Token, error)

	GetTokenByAddress(
		c.Context, string, string,
	) (entities.Token, error)

	RemoveToken(
		c.Context, string, entities.Token,
	) error

	RemoveTokens(
		c.Context, string, []entities.Token,
	) ([]entities.Token, error)
}

type TradeCase

type TradeCase struct {
	Repo     Repository
	Provider TradeProvider
	Contract SmartContract
}

func New

func New(
	r Repository,
	p TradeProvider,
	c SmartContract,
) (
	tc *TradeCase,
)

func (*TradeCase) AddBaseToken

func (tc *TradeCase) AddBaseToken(
	ctx context.Context,
	address string,
) (
	tx interface{},
	err error,
)

func (*TradeCase) Arbitrage

func (tc *TradeCase) Arbitrage(ctx context.Context, pool0, pool1 string) (
	tx interface{},
	err error,
)

func (*TradeCase) GetProfit

func (tc *TradeCase) GetProfit(ctx context.Context, pool0, pool1 string) (
	profit int,
	baseToken string,
	err error,
)

func (*TradeCase) GetProfitable

func (tc *TradeCase) GetProfitable(ctx context.Context, from []entities.TradePair) (
	out []entities.TradePair,
	ok bool,
	err error,
)

func (*TradeCase) ReplaceTxWithAddBaseToken

func (tc *TradeCase) ReplaceTxWithAddBaseToken(
	ctx context.Context,
	token, hash string,
) (
	tx interface{},
	err error,
)

func (*TradeCase) ReplaceTxWithRmBaseToken

func (tc *TradeCase) ReplaceTxWithRmBaseToken(
	ctx context.Context,
	token, hash string,
) (
	tx interface{},
	err error,
)

func (*TradeCase) RmBaseToken

func (tc *TradeCase) RmBaseToken(
	ctx context.Context,
	address string,
) (
	tx interface{},
	err error,
)

func (*TradeCase) SetContract

func (tc *TradeCase) SetContract() (
	contract SmartContract,
)

func (*TradeCase) SetProfitablePairs

func (tc *TradeCase) SetProfitablePairs(
	ctx context.Context, where string,
) (
	err error,
)

func (*TradeCase) SetProvider

func (tc *TradeCase) SetProvider() (
	provider TradeProvider,
)

func (*TradeCase) SetRepo

func (tc *TradeCase) SetRepo() (
	repo Repository,
)

func (*TradeCase) SetTokens

func (tc *TradeCase) SetTokens(
	ctx context.Context,
	where string,
) (
	err error,
)

func (*TradeCase) Withdraw

func (tc *TradeCase) Withdraw(
	ctx context.Context,
) (
	tx interface{},
	err error,
)

type TradeProvider

type TradeProvider interface {
	ClientManager

	ProviderStorage
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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