contracts

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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,
	contractAddress 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 (e *Exchange) CallBatchTrades(matches *types.Matches, call *ethereum.CallMsg) (uint64, error)

func (*Exchange) CallTrade

func (e *Exchange) CallTrade(match *types.Matches, call *ethereum.CallMsg) (uint64, error)

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

func (e *Exchange) FeeAccount() (common.Address, error)

FeeAccount is the Ethereum towards the exchange trading fees are sent

func (*Exchange) GetAddress

func (e *Exchange) GetAddress() common.Address

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 (e *Exchange) GetTxCallOptions() *bind.CallOpts

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) Operator

func (e *Exchange) Operator(a common.Address) (bool, error)

func (*Exchange) PrintErrors

func (e *Exchange) PrintErrors() error

func (*Exchange) PrintTrades

func (e *Exchange) PrintTrades() error

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.Token
}

func NewToken

func NewToken(
	w interfaces.WalletService,
	tx interfaces.TxService,
	contractAddress common.Address,
	backend bind.ContractBackend,
) (*Token, error)

func (*Token) Allowance

func (t *Token) Allowance(owner common.Address, spender common.Address) (*big.Int, error)

func (*Token) Approve

func (t *Token) Approve(spender common.Address, amount *big.Int) (*eth.Transaction, error)

func (*Token) ApproveFrom

func (t *Token) ApproveFrom(w *types.Wallet, spender common.Address, amount *big.Int) (*eth.Transaction, error)

func (*Token) BalanceOf

func (t *Token) BalanceOf(owner common.Address) (*big.Int, error)

func (*Token) GetCustomTxSendOptions

func (t *Token) GetCustomTxSendOptions(w *types.Wallet) *bind.TransactOpts

func (*Token) GetTxCallOptions

func (t *Token) GetTxCallOptions() *bind.CallOpts

func (*Token) GetTxSendOptions

func (t *Token) GetTxSendOptions() (*bind.TransactOpts, error)

func (*Token) ListenToTransferEvents

func (t *Token) ListenToTransferEvents() (chan *contractsinterfaces.TokenTransfer, error)

func (*Token) PrintTransferEvents

func (t *Token) PrintTransferEvents() error

func (*Token) SetTxSender

func (t *Token) SetTxSender(w *types.Wallet)

func (*Token) TotalSupply

func (t *Token) TotalSupply() (*big.Int, error)

func (*Token) Transfer

func (t *Token) Transfer(receiver common.Address, amount *big.Int) (*eth.Transaction, error)

func (*Token) TransferFrom

func (t *Token) TransferFrom(sender, receiver common.Address, amount *big.Int) (*eth.Transaction, error)

func (*Token) TransferFromCustomWallet

func (t *Token) TransferFromCustomWallet(w *types.Wallet, receiver common.Address, amount *big.Int) (*eth.Transaction, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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