Documentation ¶
Index ¶
- func PrintCancelOrderLog(log *contractsinterfaces.ExchangeLogCancelOrder) string
- func PrintErrorLog(log *contractsinterfaces.ExchangeLogError) string
- func PrintTradeLog(log *contractsinterfaces.ExchangeLogTrade) string
- type Exchange
- func (e *Exchange) CallBatchTrades(matches *types.Matches, call *ethereum.CallMsg) (uint64, error)
- func (e *Exchange) CallTrade(match *types.Matches, call *ethereum.CallMsg) (uint64, error)
- func (e *Exchange) DefaultTxOptions() (*bind.TransactOpts, error)
- func (e *Exchange) ExecuteBatchTrades(matches *types.Matches, txOpts *bind.TransactOpts) (*eth.Transaction, error)
- func (e *Exchange) FeeAccount() (common.Address, error)
- func (e *Exchange) GetAddress() common.Address
- func (e *Exchange) GetErrorEvents(logs chan *contractsinterfaces.ExchangeLogError) error
- func (e *Exchange) GetTrades(logs chan *contractsinterfaces.ExchangeLogTrade) error
- func (e *Exchange) GetTxCallOptions() *bind.CallOpts
- func (e *Exchange) ListenToBatchTrades() (chan *contractsinterfaces.ExchangeLogBatchTrades, error)
- func (e *Exchange) ListenToErrors() (chan *contractsinterfaces.ExchangeLogError, error)
- func (e *Exchange) ListenToTrades() (chan *contractsinterfaces.ExchangeLogTrade, error)
- func (e *Exchange) Operator(a common.Address) (bool, error)
- func (e *Exchange) PrintErrors() error
- func (e *Exchange) PrintTrades() error
- func (e *Exchange) SetFeeAccount(a common.Address, txOpts *bind.TransactOpts) (*eth.Transaction, error)
- func (e *Exchange) SetOperator(a common.Address, isOperator bool, txOpts *bind.TransactOpts) (*eth.Transaction, error)
- func (e *Exchange) Trade(match *types.Matches, txOpts *bind.TransactOpts) (*eth.Transaction, error)
- type Token
- func (t *Token) Allowance(owner common.Address, spender common.Address) (*big.Int, error)
- func (t *Token) Approve(spender common.Address, amount *big.Int) (*eth.Transaction, error)
- func (t *Token) ApproveFrom(w *types.Wallet, spender common.Address, amount *big.Int) (*eth.Transaction, error)
- func (t *Token) BalanceOf(owner common.Address) (*big.Int, error)
- func (t *Token) GetCustomTxSendOptions(w *types.Wallet) *bind.TransactOpts
- func (t *Token) GetTxCallOptions() *bind.CallOpts
- func (t *Token) GetTxSendOptions() (*bind.TransactOpts, error)
- func (t *Token) ListenToTransferEvents() (chan *contractsinterfaces.ERC20Transfer, error)
- func (t *Token) PrintTransferEvents() error
- func (t *Token) SetTxSender(w *types.Wallet)
- func (t *Token) TotalSupply() (*big.Int, error)
- func (t *Token) Transfer(receiver common.Address, amount *big.Int) (*eth.Transaction, error)
- func (t *Token) TransferFrom(sender, receiver common.Address, amount *big.Int) (*eth.Transaction, error)
- func (t *Token) TransferFromCustomWallet(w *types.Wallet, receiver common.Address, amount *big.Int) (*eth.Transaction, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintCancelOrderLog ¶
func PrintCancelOrderLog(log *contractsinterfaces.ExchangeLogCancelOrder) string
func PrintErrorLog ¶
func PrintErrorLog(log *contractsinterfaces.ExchangeLogError) string
func PrintTradeLog ¶
func PrintTradeLog(log *contractsinterfaces.ExchangeLogTrade) string
Types ¶
type Exchange ¶
type Exchange struct { Address common.Address WalletService interfaces.WalletService Interface *contractsinterfaces.Exchange Client ethereumClientInterface }
Exchange is an augmented interface to the Exchange.sol smart-contract. It uses the smart-contract bindings generated with abigen and adds additional functionality and simplifications to these bindings. Address is the Ethereum address of the exchange contract Contract is the original abigen bindings CallOptions are options for making read calls to the connected backend TxOptions are options for making write txs to the connected backend
func NewExchange ¶
func NewExchange( w interfaces.WalletService, address common.Address, backend ethereumClientInterface, ) (*Exchange, error)
Returns a new exchange interface for a given wallet, contract address and connected backend. The exchange contract need to be already deployed at the given address. The given wallet will be used by default when sending transactions with this object.
func (*Exchange) CallBatchTrades ¶
func (*Exchange) DefaultTxOptions ¶
func (e *Exchange) DefaultTxOptions() (*bind.TransactOpts, error)
func (*Exchange) ExecuteBatchTrades ¶
func (e *Exchange) ExecuteBatchTrades(matches *types.Matches, txOpts *bind.TransactOpts) (*eth.Transaction, error)
func (*Exchange) FeeAccount ¶
FeeAccount is the Ethereum towards the exchange trading fees are sent
func (*Exchange) GetAddress ¶
func (*Exchange) GetErrorEvents ¶
func (e *Exchange) GetErrorEvents(logs chan *contractsinterfaces.ExchangeLogError) error
func (*Exchange) GetTrades ¶
func (e *Exchange) GetTrades(logs chan *contractsinterfaces.ExchangeLogTrade) error
func (*Exchange) GetTxCallOptions ¶
func (*Exchange) ListenToBatchTrades ¶
func (e *Exchange) ListenToBatchTrades() (chan *contractsinterfaces.ExchangeLogBatchTrades, error)
func (*Exchange) ListenToErrors ¶
func (e *Exchange) ListenToErrors() (chan *contractsinterfaces.ExchangeLogError, error)
ListenToErrorEvents returns a channel that receives errors logs (events) from the exchange smart contract. The error IDs correspond to the following codes: 1. MAKER_INSUFFICIENT_BALANCE, 2. TAKER_INSUFFICIENT_BALANCE, 3. WITHDRAW_INSUFFICIENT_BALANCE, 4. WITHDRAW_FEE_TO_HIGH, 5. ORDER_EXPIRED, 6. WITHDRAW_ALREADY_COMPLETED, 7. TRADE_ALREADY_COMPLETED, 8. TRADE_AMOUNT_TOO_BIG, 9. SIGNATURE_INVALID, 10. MAKER_SIGNATURE_INVALID, 11. TAKER_SIGNATURE_INVALID
func (*Exchange) ListenToTrades ¶
func (e *Exchange) ListenToTrades() (chan *contractsinterfaces.ExchangeLogTrade, error)
ListenToTrades returns a channel that receivs trade logs (events) from the underlying exchange smart contract
func (*Exchange) PrintErrors ¶
func (*Exchange) PrintTrades ¶
func (*Exchange) SetFeeAccount ¶
func (e *Exchange) SetFeeAccount(a common.Address, txOpts *bind.TransactOpts) (*eth.Transaction, error)
SetFeeAccount sets the fee account of the exchange contract. The fee account receives the trading fees whenever a trade is settled.
func (*Exchange) SetOperator ¶
func (e *Exchange) SetOperator(a common.Address, isOperator bool, txOpts *bind.TransactOpts) (*eth.Transaction, error)
SetOperator updates the operator settings of the given address. Only addresses with an operator access can execute Withdraw and Trade transactions to the Exchange smart contract
func (*Exchange) Trade ¶
func (e *Exchange) Trade(match *types.Matches, txOpts *bind.TransactOpts) (*eth.Transaction, error)
Trade executes a settlements transaction. The order and trade payloads need to be signed respectively by the Maker and the Taker of the trade. Only the operator account can send a Trade function to the Exchange smart contract.
type Token ¶
type Token struct { WalletService interfaces.WalletService TxService interfaces.TxService Interface *contractsinterfaces.ERC20 }
func NewToken ¶
func NewToken( w interfaces.WalletService, tx interfaces.TxService, address common.Address, backend bind.ContractBackend, ) (*Token, error)
func (*Token) ApproveFrom ¶
func (*Token) GetCustomTxSendOptions ¶
func (t *Token) GetCustomTxSendOptions(w *types.Wallet) *bind.TransactOpts
func (*Token) GetTxCallOptions ¶
func (*Token) GetTxSendOptions ¶
func (t *Token) GetTxSendOptions() (*bind.TransactOpts, error)
func (*Token) ListenToTransferEvents ¶
func (t *Token) ListenToTransferEvents() (chan *contractsinterfaces.ERC20Transfer, error)