Documentation
¶
Index ¶
- Variables
- func BuildCompactBulk(newBuys, newSells map[ethereum.Address]byte, indices map[string]tbindex) ([][14]byte, [][14]byte, []*big.Int)
- type Blockchain
- func (bc *Blockchain) CheckTokenIndices(tokenAddr ethereum.Address) error
- func (bc *Blockchain) FetchBalanceData(reserve ethereum.Address, atBlock uint64) (map[string]common.BalanceEntry, error)
- func (bc *Blockchain) FetchRates(atBlock uint64, currentBlock uint64) (common.AllRateEntry, error)
- func (bc *Blockchain) GeneratedGetBalances(opts blockchain.CallOpts, reserve ethereum.Address, tokens []ethereum.Address) ([]*big.Int, error)
- func (bc *Blockchain) GeneratedGetRate(opts blockchain.CallOpts, token ethereum.Address, currentBlockNumber *big.Int, ...) (*big.Int, error)
- func (bc *Blockchain) GeneratedGetStepFunctionData(opts blockchain.CallOpts, token ethereum.Address, command *big.Int, ...) (*big.Int, error)
- func (bc *Blockchain) GeneratedGetTokenIndicies(opts blockchain.CallOpts, ratesContract ethereum.Address, ...) ([]*big.Int, []*big.Int, error)
- func (bc *Blockchain) GeneratedGetTokenRates(opts blockchain.CallOpts, ratesContract ethereum.Address, ...) ([]*big.Int, []*big.Int, []int8, []int8, []*big.Int, error)
- func (bc *Blockchain) GeneratedSetBaseRate(opts blockchain.TxOpts, tokens []ethereum.Address, baseBuy []*big.Int, ...) (*types.Transaction, error)
- func (bc *Blockchain) GeneratedSetCompactData(opts blockchain.TxOpts, buy [][14]byte, sell [][14]byte, blockNumber *big.Int, ...) (*types.Transaction, error)
- func (bc *Blockchain) GeneratedSetImbalanceStepFunction(opts blockchain.TxOpts, token ethereum.Address, xBuy []*big.Int, ...) (*types.Transaction, error)
- func (bc *Blockchain) GeneratedSetQtyStepFunction(opts blockchain.TxOpts, token ethereum.Address, xBuy []*big.Int, ...) (*types.Transaction, error)
- func (bc *Blockchain) GeneratedWithdraw(opts blockchain.TxOpts, token ethereum.Address, amount *big.Int, ...) (*types.Transaction, error)
- func (bc *Blockchain) GetDepositOPAddress() ethereum.Address
- func (bc *Blockchain) GetIntermediatorOPAddress() ethereum.Address
- func (bc *Blockchain) GetPrice(token ethereum.Address, block *big.Int, priceType string, qty *big.Int, ...) (*big.Int, error)
- func (bc *Blockchain) GetPricingOPAddress() ethereum.Address
- func (bc *Blockchain) LoadAndSetTokenIndices(tokenAddrs []ethereum.Address) error
- func (bc *Blockchain) RegisterDepositOperator(signer blockchain.Signer, nonceCorpus blockchain.NonceCorpus)
- func (bc *Blockchain) RegisterPricingOperator(signer blockchain.Signer, nonceCorpus blockchain.NonceCorpus)
- func (bc *Blockchain) Send(token common.Token, amount *big.Int, dest ethereum.Address) (*types.Transaction, error)
- func (bc *Blockchain) SetImbalanceStepFunction(token ethereum.Address, xBuy []*big.Int, yBuy []*big.Int, xSell []*big.Int, ...) (*types.Transaction, error)
- func (bc *Blockchain) SetQtyStepFunction(token ethereum.Address, xBuy []*big.Int, yBuy []*big.Int, xSell []*big.Int, ...) (*types.Transaction, error)
- func (bc *Blockchain) SetRateMinedNonce() (uint64, error)
- func (bc *Blockchain) SetRates(tokens []ethereum.Address, buys []*big.Int, sells []*big.Int, block *big.Int, ...) (*types.Transaction, error)
- func (bc *Blockchain) StandardGasPrice() float64
- type CompactRate
- type Setting
Constants ¶
This section is empty.
Variables ¶
Functions ¶
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 (*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 (*Blockchain) GeneratedGetTokenRates ¶ added in v0.1.1
func (*Blockchain) GeneratedSetBaseRate ¶ added in v0.1.1
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 (*Blockchain) GeneratedSetQtyStepFunction ¶ added in v0.1.1
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) 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 (*Blockchain) SetQtyStepFunction ¶ added in v0.1.1
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
func BigIntToCompactRate ¶ added in v0.1.1
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