Documentation ¶
Index ¶
- func Compare(t *testing.T, expected interface{}, value interface{})
- func CompareAccount(t *testing.T, a, b *types.Account)
- func CompareAccountStrict(t *testing.T, a, b *types.Account)
- func CompareEngineResponse(t *testing.T, a, b *types.EngineResponse)
- func CompareMatches(t *testing.T, a, b *types.Matches)
- func CompareOrder(t *testing.T, a, b *types.Order)
- func ComparePair(t *testing.T, a, b *types.Pair)
- func ComparePublicOrder(t *testing.T, a, b *types.Order)
- func ComparePublicTrade(t *testing.T, a, b *types.Trade)
- func CompareStructs(t *testing.T, expected interface{}, order interface{})
- func CompareToken(t *testing.T, a, b *types.Token)
- func CompareTrade(t *testing.T, a, b *types.Trade)
- func GetTestAddress1() common.Address
- func GetTestAddress2() common.Address
- func GetTestAddress3() common.Address
- func GetTestOrder1() types.Order
- func GetTestOrder2() types.Order
- func GetTestOrder3() types.Order
- func GetTestTrade1() types.Trade
- func GetTestTrade2() types.Trade
- func GetTestWETHToken() types.Token
- func GetTestWallet() *types.Wallet
- func GetTestWallet1() *types.Wallet
- func GetTestWallet2() *types.Wallet
- func GetTestWallet3() *types.Wallet
- func GetTestWallet4() *types.Wallet
- func GetTestWallet5() *types.Wallet
- func GetTestZRXToken() types.Token
- func GetZRXWETHTestPair() *types.Pair
- func Mine(client *ethereum.SimulatedClient)
- func NewDBTestServer() *dbtest.DBServer
- type Client
- type ClientLogMessage
- type Deployer
- func (d *Deployer) DeployExchange(wethToken common.Address, feeAccount common.Address) (*contracts.Exchange, common.Address, *ethTypes.Transaction, error)
- func (d *Deployer) DeployToken(receiver common.Address, amount *big.Int) (*contracts.Token, common.Address, *ethTypes.Transaction, error)
- func (d *Deployer) GetNonce() (*big.Int, error)
- func (d *Deployer) NewExchange(addr common.Address) (*contracts.Exchange, error)
- func (d *Deployer) NewToken(addr common.Address) (*contracts.Token, error)
- func (d *Deployer) WaitMined(tx *ethTypes.Transaction) (*ethTypes.Receipt, error)
- type MockDaos
- type MockServices
- type OrderFactory
- func (f *OrderFactory) GetAddress() common.Address
- func (f *OrderFactory) GetExchangeAddress() common.Address
- func (f *OrderFactory) GetWallet() *types.Wallet
- func (f *OrderFactory) NewBuyOrder(pricepoint int64, value float64, filled ...float64) (types.Order, error)
- func (f *OrderFactory) NewBuyOrderMessage(price int64, amount float64) (*types.WebsocketMessage, *types.Order, error)
- func (f *OrderFactory) NewCancelOrder(o *types.Order) (*types.OrderCancel, error)
- func (f *OrderFactory) NewCancelOrderMessage(o *types.Order) (*types.WebsocketMessage, *types.OrderCancel, error)
- func (f *OrderFactory) NewLargeOrder(baseToken common.Address, quoteToken common.Address, amount *big.Int, ...) (*types.Order, error)
- func (f *OrderFactory) NewOrder(baseToken common.Address, quoteToken common.Address, amount int64, ...) (*types.Order, error)
- func (f *OrderFactory) NewOrderMessage(baseToken, quoteToken common.Address, amount, pricepoint int64) (*types.WebsocketMessage, *types.Order, error)
- func (f *OrderFactory) NewSellOrder(pricepoint int64, value float64, filled ...float64) (types.Order, error)
- func (f *OrderFactory) NewSellOrderMessage(price int64, amount float64) (*types.WebsocketMessage, *types.Order, error)
- func (f *OrderFactory) NewTrade(o *types.Order, amount int64) (types.Trade, error)
- func (f *OrderFactory) SetExchangeAddress(addr common.Address) error
- type OrderParams
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CompareEngineResponse ¶
func CompareEngineResponse(t *testing.T, a, b *types.EngineResponse)
func CompareStructs ¶
func GetTestAddress1 ¶
func GetTestAddress2 ¶
func GetTestAddress3 ¶
func GetTestOrder1 ¶
func GetTestOrder2 ¶
func GetTestOrder3 ¶
func GetTestTrade1 ¶
func GetTestTrade2 ¶
func GetTestWETHToken ¶
func GetTestWallet ¶
func GetTestWallet1 ¶
func GetTestWallet2 ¶
func GetTestWallet3 ¶
func GetTestWallet4 ¶
func GetTestWallet5 ¶
func GetTestZRXToken ¶
func GetZRXWETHTestPair ¶
func Mine ¶
func Mine(client *ethereum.SimulatedClient)
func NewDBTestServer ¶
Types ¶
type Client ¶
type Client struct { Requests chan *types.WebsocketMessage Responses chan *types.WebsocketMessage Logs chan *ClientLogMessage Wallet *types.Wallet RequestLogs []types.WebsocketMessage ResponseLogs []types.WebsocketMessage NonceGenerator *rand.Rand // contains filtered or unexported fields }
Client simulates the client websocket handler that will be used to perform trading. requests and responses are respectively the outbound and incoming messages. requestLogs and responseLogs are arrays of messages that denote the history of received messages wallet is the ethereum account used for orders and trades. mutex is used to prevent concurrent writes on the websocket connection
type ClientLogMessage ¶
type ClientLogMessage struct { MessageType string `json:"messageType"` Orders []*types.Order `json:"order"` Trades []*types.Trade `json:"trade"` Matches *types.Matches `json:"matches"` Tx *common.Hash `json:"tx"` ErrorID int8 `json:"errorID"` }
The client log is mostly used for testing. It optionally takes orders, trade, error ids and transaction hashes. All these parameters are optional in order to allow the client log message to take in a lot of different types of messages An error id of -1 means that there was no error.
type Deployer ¶
type Deployer struct { WalletService interfaces.WalletService TxService interfaces.TxService Client bind.ContractBackend }
func NewDefaultDeployer ¶
func NewDefaultDeployer(w interfaces.WalletService, tx interfaces.TxService) (*Deployer, error)
func NewDeployer ¶
func NewDeployer( w interfaces.WalletService, tx interfaces.TxService, client bind.ContractBackend, ) *Deployer
func NewWebSocketDeployer ¶
func NewWebSocketDeployer(w interfaces.WalletService, tx interfaces.TxService) (*Deployer, error)
func (*Deployer) DeployExchange ¶
func (d *Deployer) DeployExchange(wethToken common.Address, feeAccount common.Address) (*contracts.Exchange, common.Address, *ethTypes.Transaction, error)
DeployExchange
func (*Deployer) DeployToken ¶
func (d *Deployer) DeployToken(receiver common.Address, amount *big.Int) (*contracts.Token, common.Address, *ethTypes.Transaction, error)
DeployToken
func (*Deployer) NewExchange ¶
NewExchange
type MockDaos ¶
type MockDaos struct { WalletDao *mocks.WalletDao AccountDao *mocks.AccountDao OrderDao *mocks.OrderDao TokenDao *mocks.TokenDao TradeDao *mocks.TradeDao PairDao *mocks.PairDao }
func NewMockDaos ¶
func NewMockDaos() *MockDaos
type MockServices ¶
type MockServices struct { WalletService *mocks.WalletService AccountService *mocks.AccountService EthereumService *mocks.EthereumService OrderService *mocks.OrderService OrderBookService *mocks.OrderBookService TokenService *mocks.TokenService TxService *mocks.TxService PairService *mocks.PairService TradeService *mocks.TradeService }
func NewMockServices ¶
func NewMockServices() *MockServices
type OrderFactory ¶
type OrderFactory struct { Wallet *types.Wallet Pair *types.Pair Params *OrderParams OrderNonce uint64 NonceGenerator *rand.Rand }
Orderfactory simplifies creating orders, trades and cancelOrders objects Pair is the token pair for which the order is created Exchange is the Ethereum address of the exchange smart contract CurrentOrderID increments for each new order
func NewOrderFactory ¶
func NewOrderFactory(p *types.Pair, w *types.Wallet, exchangeAddress common.Address) (*OrderFactory, error)
NewOrderFactory returns an order factory from a given token pair and a given wallet TODO: Refactor this function to send back an error
func (*OrderFactory) GetAddress ¶
func (f *OrderFactory) GetAddress() common.Address
GetAddress returns the order factory address
func (*OrderFactory) GetExchangeAddress ¶
func (f *OrderFactory) GetExchangeAddress() common.Address
func (*OrderFactory) GetWallet ¶
func (f *OrderFactory) GetWallet() *types.Wallet
GetWallet returns the order factory wallet
func (*OrderFactory) NewBuyOrder ¶
func (f *OrderFactory) NewBuyOrder(pricepoint int64, value float64, filled ...float64) (types.Order, error)
NewBuyOrder creates a new buy order from the order factory
func (*OrderFactory) NewBuyOrderMessage ¶
func (f *OrderFactory) NewBuyOrderMessage(price int64, amount float64) (*types.WebsocketMessage, *types.Order, error)
func (*OrderFactory) NewCancelOrder ¶
func (f *OrderFactory) NewCancelOrder(o *types.Order) (*types.OrderCancel, error)
func (*OrderFactory) NewCancelOrderMessage ¶
func (f *OrderFactory) NewCancelOrderMessage(o *types.Order) (*types.WebsocketMessage, *types.OrderCancel, error)
func (*OrderFactory) NewLargeOrder ¶
func (*OrderFactory) NewOrder ¶
func (f *OrderFactory) NewOrder(baseToken common.Address, quoteToken common.Address, amount int64, pricepoint int64) (*types.Order, error)
NewOrder returns a new order with the given params. The order is signed by the factory wallet. Currently the nonce is chosen randomly which will be changed in the future
func (*OrderFactory) NewOrderMessage ¶
func (f *OrderFactory) NewOrderMessage(baseToken, quoteToken common.Address, amount, pricepoint int64) (*types.WebsocketMessage, *types.Order, error)
NewOrderMessage creates an order with the given params and returns a new PLACE_ORDER message
func (*OrderFactory) NewSellOrder ¶
func (f *OrderFactory) NewSellOrder(pricepoint int64, value float64, filled ...float64) (types.Order, error)
NewBuyOrder returns a new order with the given params. The order is signed by the factory wallet NewBuyOrder computes the AmountBuy and AmountSell parameters from the given amount and price. Currently, the amount, price and order type are also kept. This could be amended in the future (meaning we would let the engine compute OrderBuy, Amount and Price. Ultimately this does not really matter except maybe for convenience/readability purposes)
func (*OrderFactory) NewSellOrderMessage ¶
func (f *OrderFactory) NewSellOrderMessage(price int64, amount float64) (*types.WebsocketMessage, *types.Order, error)
func (*OrderFactory) NewTrade ¶
NewTrade returns a new trade with the given params. The trade is signed by the factory wallet. Currently the nonce is chosen randomly which will be changed in the future
func (*OrderFactory) SetExchangeAddress ¶
func (f *OrderFactory) SetExchangeAddress(addr common.Address) error
SetExchangeAddress changes the default exchange address for orders created by this factory
type OrderParams ¶
type OrderParams struct { ExchangeAddress common.Address MakeFee *big.Int TakeFee *big.Int Nonce *big.Int }
OrderParams groups FeeMake, FeeTake, Nonce, Exipres FeeMake and FeeTake are the default fees imposed on makers and takers Nonce is the ethereum account nonce that tracks the numbers of transactions for the order factory account