core

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityStorage

type ActivityStorage interface {
	Record(
		action string,
		id common.ActivityID,
		destination string,
		params map[string]interface{},
		result map[string]interface{},
		estatus string,
		mstatus string,
		timepoint uint64) error
	HasPendingDeposit(
		token common.Token, exchange common.Exchange) (bool, error)

	GetActivity(id common.ActivityID) (common.ActivityRecord, error)

	// PendingSetRate return the last pending set rate and number of pending
	// transactions.
	PendingSetRate(minedNonce uint64) (*common.ActivityRecord, uint64, error)
}

ActivityStorage is the interface contains all database operations of core.

type Blockchain

type Blockchain interface {
	StandardGasPrice() float64
	Send(
		token common.Token,
		amount *big.Int,
		address ethereum.Address) (*types.Transaction, error)
	SetRates(
		tokens []ethereum.Address,
		buys []*big.Int,
		sells []*big.Int,
		block *big.Int,
		nonce *big.Int,
		gasPrice *big.Int) (*types.Transaction, error)
	SetRateMinedNonce() (uint64, error)
}

Blockchain is the interface wraps around all core methods to interact with Ethereum blockchain.

type ReserveCore

type ReserveCore struct {
	// contains filtered or unexported fields
}

func NewReserveCore

func NewReserveCore(
	blockchain Blockchain,
	storage ActivityStorage,
	setting Setting) *ReserveCore

func (ReserveCore) CancelOrder

func (rc ReserveCore) CancelOrder(id common.ActivityID, exchange common.Exchange) error

func (ReserveCore) Deposit

func (rc ReserveCore) Deposit(
	exchange common.Exchange,
	token common.Token,
	amount *big.Int,
	timepoint uint64) (common.ActivityID, error)

func (ReserveCore) GetSetRateResult added in v0.1.1

func (rc ReserveCore) GetSetRateResult(tokens []common.Token,
	buys, sells, afpMids []*big.Int,
	block *big.Int) (*types.Transaction, error)

func (ReserveCore) SetRates

func (rc ReserveCore) SetRates(
	tokens []common.Token,
	buys []*big.Int,
	sells []*big.Int,
	block *big.Int,
	afpMids []*big.Int,
	additionalMsgs []string) (common.ActivityID, error)

func (ReserveCore) Trade

func (rc ReserveCore) Trade(
	exchange common.Exchange,
	tradeType string,
	base common.Token,
	quote common.Token,
	rate float64,
	amount float64,
	timepoint uint64) (common.ActivityID, float64, float64, bool, error)

func (ReserveCore) Withdraw

func (rc ReserveCore) Withdraw(
	exchange common.Exchange, token common.Token,
	amount *big.Int, timepoint uint64) (common.ActivityID, error)

type Setting added in v0.1.1

type Setting interface {
	GetAddress(settings.AddressName) (ethereum.Address, error)
}

Jump to

Keyboard shortcuts

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