blockchain

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Big0   = big.NewInt(0)
	BigMax = big.NewInt(10).Exp(big.NewInt(10), big.NewInt(33), nil)
)

Functions

func BuildCompactBulk added in v0.1.1

func BuildCompactBulk(newBuys, newSells map[ethereum.Address]byte, indices map[string]tbindex) ([][14]byte, [][14]byte, []*big.Int)

Types

type Blockchain

type Blockchain struct {
	*blockchain.BaseBlockchain
	// contains filtered or unexported fields
}

func NewBlockchain

func NewBlockchain(base *blockchain.BaseBlockchain, setting Setting) (*Blockchain, error)

func (*Blockchain) CheckTokenIndices added in v0.1.1

func (bc *Blockchain) CheckTokenIndices(tokenAddr ethereum.Address) error

func (*Blockchain) FetchBalanceData

func (bc *Blockchain) FetchBalanceData(reserve ethereum.Address, atBlock uint64) (map[string]common.BalanceEntry, error)

====================== Readonly calls ============================

func (*Blockchain) FetchRates

func (bc *Blockchain) FetchRates(atBlock uint64, currentBlock uint64) (common.AllRateEntry, error)

func (*Blockchain) GeneratedGetBalances added in v0.1.1

func (bc *Blockchain) GeneratedGetBalances(opts blockchain.CallOpts, reserve ethereum.Address, tokens []ethereum.Address) ([]*big.Int, error)

func (*Blockchain) GeneratedGetRate added in v0.1.1

func (bc *Blockchain) GeneratedGetRate(opts blockchain.CallOpts, token ethereum.Address, currentBlockNumber *big.Int, buy bool, qty *big.Int) (*big.Int, error)

func (*Blockchain) GeneratedGetStepFunctionData added in v0.1.1

func (bc *Blockchain) GeneratedGetStepFunctionData(opts blockchain.CallOpts, token ethereum.Address, command *big.Int, param *big.Int) (*big.Int, error)

GeneratedGetStepFunctionData get step function data for an token

func (*Blockchain) GeneratedGetTokenIndicies added in v0.1.1

func (bc *Blockchain) GeneratedGetTokenIndicies(opts blockchain.CallOpts, ratesContract ethereum.Address, tokenList []ethereum.Address) ([]*big.Int, []*big.Int, error)

func (*Blockchain) GeneratedGetTokenRates added in v0.1.1

func (bc *Blockchain) GeneratedGetTokenRates(
	opts blockchain.CallOpts,
	ratesContract ethereum.Address,
	tokenList []ethereum.Address) ([]*big.Int, []*big.Int, []int8, []int8, []*big.Int, error)

func (*Blockchain) GeneratedSetBaseRate added in v0.1.1

func (bc *Blockchain) GeneratedSetBaseRate(opts blockchain.TxOpts, tokens []ethereum.Address, baseBuy []*big.Int, baseSell []*big.Int, buy [][14]byte, sell [][14]byte, blockNumber *big.Int, indices []*big.Int) (*types.Transaction, error)

func (*Blockchain) GeneratedSetCompactData added in v0.1.1

func (bc *Blockchain) GeneratedSetCompactData(opts blockchain.TxOpts, buy [][14]byte, sell [][14]byte, blockNumber *big.Int, indices []*big.Int) (*types.Transaction, error)

func (*Blockchain) GeneratedSetImbalanceStepFunction added in v0.1.1

func (bc *Blockchain) GeneratedSetImbalanceStepFunction(opts blockchain.TxOpts, token ethereum.Address, xBuy []*big.Int, yBuy []*big.Int, xSell []*big.Int, ySell []*big.Int) (*types.Transaction, error)

func (*Blockchain) GeneratedSetQtyStepFunction added in v0.1.1

func (bc *Blockchain) GeneratedSetQtyStepFunction(opts blockchain.TxOpts, token ethereum.Address, xBuy []*big.Int, yBuy []*big.Int, xSell []*big.Int, ySell []*big.Int) (*types.Transaction, error)

func (*Blockchain) GeneratedWithdraw added in v0.1.1

func (bc *Blockchain) GeneratedWithdraw(opts blockchain.TxOpts, token ethereum.Address, amount *big.Int, destination ethereum.Address) (*types.Transaction, error)

func (*Blockchain) GetDepositOPAddress added in v0.1.1

func (bc *Blockchain) GetDepositOPAddress() ethereum.Address

func (*Blockchain) GetIntermediatorOPAddress added in v0.1.1

func (bc *Blockchain) GetIntermediatorOPAddress() ethereum.Address

func (*Blockchain) GetPrice added in v0.1.1

func (bc *Blockchain) GetPrice(token ethereum.Address, block *big.Int, priceType string, qty *big.Int, atBlock uint64) (*big.Int, error)

func (*Blockchain) GetPricingOPAddress added in v0.1.1

func (bc *Blockchain) GetPricingOPAddress() ethereum.Address

func (*Blockchain) LoadAndSetTokenIndices added in v0.1.1

func (bc *Blockchain) LoadAndSetTokenIndices(tokenAddrs []ethereum.Address) error

func (*Blockchain) RegisterDepositOperator added in v0.1.1

func (bc *Blockchain) RegisterDepositOperator(signer blockchain.Signer, nonceCorpus blockchain.NonceCorpus)

func (*Blockchain) RegisterPricingOperator added in v0.1.1

func (bc *Blockchain) RegisterPricingOperator(signer blockchain.Signer, nonceCorpus blockchain.NonceCorpus)

func (*Blockchain) Send

func (bc *Blockchain) Send(
	token common.Token,
	amount *big.Int,
	dest ethereum.Address) (*types.Transaction, error)

func (*Blockchain) SetImbalanceStepFunction added in v0.1.1

func (bc *Blockchain) SetImbalanceStepFunction(token ethereum.Address, xBuy []*big.Int, yBuy []*big.Int, xSell []*big.Int, ySell []*big.Int) (*types.Transaction, error)

func (*Blockchain) SetQtyStepFunction added in v0.1.1

func (bc *Blockchain) SetQtyStepFunction(token ethereum.Address, xBuy []*big.Int, yBuy []*big.Int, xSell []*big.Int, ySell []*big.Int) (*types.Transaction, error)

func (*Blockchain) SetRateMinedNonce added in v0.1.1

func (bc *Blockchain) SetRateMinedNonce() (uint64, error)

SetRateMinedNonce returns nonce of the pricing operator in confirmed state (not pending state).

Getting mined nonce is not simple because there might be lag between node leading us to get outdated mined nonce from an unsynced node. To overcome this situation, we will keep a local nonce and require the nonce from node to be equal or greater than it. If the nonce from node is smaller than the local one, we will use the local one. However, if the local one stay with the same value for more than 15 mins, the local one is considered incorrect because the chain might be reorganized so we will invalidate it and assign it to the nonce from node.

func (*Blockchain) SetRates

func (bc *Blockchain) SetRates(
	tokens []ethereum.Address,
	buys []*big.Int,
	sells []*big.Int,
	block *big.Int,
	nonce *big.Int,
	gasPrice *big.Int) (*types.Transaction, error)

TODO: Need better test coverage we got a bug when compact is not set to old compact or when one of buy/sell got overflowed, it discards the other's compact

func (*Blockchain) StandardGasPrice added in v0.1.1

func (bc *Blockchain) StandardGasPrice() float64

type CompactRate added in v0.1.1

type CompactRate struct {
	Base    *big.Int
	Compact byte
}

func BigIntToCompactRate added in v0.1.1

func BigIntToCompactRate(rate *big.Int, base *big.Int) (compactrate *CompactRate, overflow bool)

Convert rate to compact rate with preferred base if it is impossible to use preferred base because Compact doesnt fit 8bits, the base is changed to the rate, Compact is set to 0 and return overflow = true

type Setting added in v0.1.1

type Setting interface {
	GetInternalTokens() ([]common.Token, error)
	ETHToken() common.Token
	GetAddress(settings.AddressName) (ethereum.Address, error)
}

Jump to

Keyboard shortcuts

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