Documentation ¶
Index ¶
- Constants
- Variables
- func BigintToHex(b *big.Int) string
- func HexToBigint(h string) *big.Int
- func InUnchangeableStatus(status OrderStatus) bool
- func Int2BlockNumHex(height int) string
- func IsZeroAddress(addr common.Address) bool
- func IsZeroHash(hash common.Hash) bool
- func StatusStr(status TxStatus) string
- func Xor(bytes1, bytes2 []byte) []byte
- type AddressAuthorizedEvent
- type AddressDeAuthorizedEvent
- type ApprovalEvent
- type BalanceUpdateEvent
- type Big
- type Block
- type BlockEvent
- type Bytes32
- type CheckNull
- type CurrencyMarketCap
- type CutoffEvent
- type CutoffPairEvent
- type DepthUpdateEvent
- type ExtractorWarningEvent
- type FilledOrder
- type ForkedEvent
- type NameRegistryInfo
- type Order
- func (o *Order) GenerateAndSetSignature(singerAddr common.Address) error
- func (o *Order) GenerateHash() common.Hash
- func (o *Order) GeneratePrice()
- func (o Order) MarshalJSON() ([]byte, error)
- func (o *Order) SignerAddress() (common.Address, error)
- func (o *Order) UnmarshalJSON(input []byte) error
- func (o *Order) ValidateSignatureValues() bool
- type OrderCancelledEvent
- type OrderDelayList
- type OrderFilledEvent
- type OrderJsonRequest
- type OrderState
- func (state *OrderState) DealtAndSplitAmount() (totalAmountS *big.Rat, totalAmountB *big.Rat)
- func (ord *OrderState) IsEffective() bool
- func (ord *OrderState) IsExpired() bool
- func (orderState *OrderState) RemainedAmount() (remainedAmountS *big.Rat, remainedAmountB *big.Rat)
- func (ord *OrderState) ResolveStatus(allowance, balance *big.Int)
- type OrderStatus
- type Rat
- type Ring
- type RingMinedEvent
- type RingSubmitInfo
- type RingSubmitResultEvent
- type SubmitRingMethodEvent
- type Token
- type TokenRegisterEvent
- type TokenUnRegisterEvent
- type TransactionEvent
- type TransferEvent
- type TxInfo
- type TxStatus
- type WethDepositEvent
- type WethWithdrawalEvent
- type WhiteListUser
Constants ¶
View Source
const (
Bytes32Length = 32
)
Variables ¶
View Source
var ( NilHash = common.HexToHash("0x") NilAddress = common.HexToAddress("0x") )
View Source
var MaxUint256 = maxUint256()
Functions ¶
func BigintToHex ¶
func HexToBigint ¶
func InUnchangeableStatus ¶
func InUnchangeableStatus(status OrderStatus) bool
func Int2BlockNumHex ¶
func IsZeroAddress ¶
func IsZeroHash ¶
Types ¶
type AddressAuthorizedEvent ¶
type ApprovalEvent ¶
type BalanceUpdateEvent ¶
type BlockEvent ¶
type Bytes32 ¶
type Bytes32 [Bytes32Length]byte
func BitToBytes32 ¶
func BytesToBytes32 ¶
func HexToBytes32 ¶
func (*Bytes32) UnmarshalText ¶
type CurrencyMarketCap ¶
type CurrencyMarketCap struct { Id string `json:"id"` Name string `json:"name"` Symbol string `json:"symbol"` Address common.Address `json:"address"` PriceUsd *big.Rat `json:"price_usd"` PriceBtc *big.Rat `json:"price_btc"` PriceCny *big.Rat `json:"price_cny"` Volume24HCNY *big.Rat `json:"24h_volume_cny"` Volume24HUSD *big.Rat `json:"24h_volume_usd"` LastUpdated int64 `json:"last_updated"` Decimals *big.Int }
func (*CurrencyMarketCap) UnmarshalJSON ¶
func (cap *CurrencyMarketCap) UnmarshalJSON(input []byte) error
type CutoffEvent ¶
type CutoffPairEvent ¶
type DepthUpdateEvent ¶
type ExtractorWarningEvent ¶
type ExtractorWarningEvent struct{}
type FilledOrder ¶
type FilledOrder struct { OrderState OrderState `json:"orderState" gencodec:"required"` FeeSelection uint8 `json:"feeSelection"` //0 -> lrc RateAmountS *big.Rat `json:"rateAmountS"` //提交需要 AvailableAmountS *big.Rat `json:"availableAmountS"` //需要,也是用于计算fee AvailableAmountB *big.Rat //需要,也是用于计算fee FillAmountS *big.Rat `json:"fillAmountS"` FillAmountB *big.Rat `json:"fillAmountB"` //计算需要 LrcReward *big.Rat `json:"lrcReward"` LrcFee *big.Rat `json:"lrcFee"` LegalLrcFee *big.Rat `json:"legalLrcFee"` FeeS *big.Rat `json:"feeS"` LegalFeeS *big.Rat `json:"legalFeeS"` LegalFee *big.Rat `json:"legalFee"` //法币计算的fee SPrice *big.Rat `json:"SPrice"` BPrice *big.Rat `json:"BPrice"` AvailableLrcBalance *big.Rat AvailableTokenSBalance *big.Rat }
RateAmountS、FeeSelection 需要提交到contract
func ConvertOrderStateToFilledOrder ¶
func ConvertOrderStateToFilledOrder(orderState OrderState, lrcBalance, tokenSBalance *big.Rat, lrcAddress common.Address) *FilledOrder
type ForkedEvent ¶
type NameRegistryInfo ¶
type Order ¶
type Order struct { Protocol common.Address `json:"protocol" gencodec:"required"` // 智能合约地址 DelegateAddress common.Address `json:"delegateAddress" gencodec:"required"` // 智能合约地址 AuthAddr common.Address `json:"authAddr" gencodec:"required"` // AuthPrivateKey crypto.EthPrivateKeyCrypto `json:"authPrivateKey" gencodec:"required"` // WalletAddress common.Address `json:"walletAddress" gencodec:"required"` TokenS common.Address `json:"tokenS" gencodec:"required"` // 卖出erc20代币智能合约地址 TokenB common.Address `json:"tokenB" gencodec:"required"` // 买入erc20代币智能合约地址 AmountS *big.Int `json:"amountS" gencodec:"required"` // 卖出erc20代币数量上限 AmountB *big.Int `json:"amountB" gencodec:"required"` // 买入erc20代币数量上限 ValidSince *big.Int `json:"validSince" gencodec:"required"` // ValidUntil *big.Int `json:"validUntil" gencodec:"required"` // 订单过期时间 LrcFee *big.Int `json:"lrcFee" ` // 交易总费用,部分成交的费用按该次撮合实际卖出代币额与比例计算 BuyNoMoreThanAmountB bool `json:"buyNoMoreThanAmountB" gencodec:"required"` MarginSplitPercentage uint8 `json:"marginSplitPercentage" gencodec:"required"` // 不为0时支付给交易所的分润比例,否则视为100% V uint8 `json:"v" gencodec:"required"` R Bytes32 `json:"r" gencodec:"required"` S Bytes32 `json:"s" gencodec:"required"` Price *big.Rat `json:"price"` Owner common.Address `json:"owner"` Hash common.Hash `json:"hash"` Market string `json:"market"` CreateTime int64 `json:"createTime"` PowNonce uint64 `json:"powNonce"` Side string `json:"side"` OrderType string `json:"orderType"` }
func ToOrder ¶
func ToOrder(request *OrderJsonRequest) *Order
func (*Order) GenerateAndSetSignature ¶
func (*Order) GenerateHash ¶
func (*Order) GeneratePrice ¶
func (o *Order) GeneratePrice()
func (Order) MarshalJSON ¶
func (*Order) UnmarshalJSON ¶
func (*Order) ValidateSignatureValues ¶
type OrderCancelledEvent ¶
type OrderDelayList ¶
type OrderFilledEvent ¶
type OrderFilledEvent struct { TxInfo Ringhash common.Hash PreOrderHash common.Hash OrderHash common.Hash NextOrderHash common.Hash Owner common.Address TokenS common.Address TokenB common.Address SellTo common.Address BuyFrom common.Address RingIndex *big.Int AmountS *big.Int AmountB *big.Int LrcReward *big.Int LrcFee *big.Int SplitS *big.Int SplitB *big.Int Market string FillIndex *big.Int }
type OrderJsonRequest ¶
type OrderJsonRequest struct { Protocol common.Address `json:"protocol" gencodec:"required"` // 智能合约地址 DelegateAddress common.Address `json:"delegateAddress" gencodec:"required"` // 智能合约地址 TokenS common.Address `json:"tokenS" gencodec:"required"` // 卖出erc20代币智能合约地址 TokenB common.Address `json:"tokenB" gencodec:"required"` // 买入erc20代币智能合约地址 AuthAddr common.Address `json:"authAddr" gencodec:"required"` // AuthPrivateKey crypto.EthPrivateKeyCrypto `json:"authPrivateKey"` // WalletAddress common.Address `json:"walletAddress" gencodec:"required"` AmountS *big.Int `json:"amountS" gencodec:"required"` // 卖出erc20代币数量上限 AmountB *big.Int `json:"amountB" gencodec:"required"` // 买入erc20代币数量上限 ValidSince *big.Int `json:"validSince" gencodec:"required"` // ValidUntil *big.Int `json:"validUntil" gencodec:"required"` // 订单过期时间 // Salt int64 `json:"salt" gencodec:"required"` LrcFee *big.Int `json:"lrcFee" ` // 交易总费用,部分成交的费用按该次撮合实际卖出代币额与比例计算 BuyNoMoreThanAmountB bool `json:"buyNoMoreThanAmountB" gencodec:"required"` MarginSplitPercentage uint8 `json:"marginSplitPercentage" gencodec:"required"` // 不为0时支付给交易所的分润比例,否则视为100% V uint8 `json:"v" gencodec:"required"` R Bytes32 `json:"r" gencodec:"required"` S Bytes32 `json:"s" gencodec:"required"` Price *big.Rat `json:"price"` Owner common.Address `json:"owner"` Hash common.Hash `json:"hash"` CreateTime int64 `json:"createTime"` PowNonce uint64 `json:"powNonce"` Side string `json:"side"` OrderType string `json:"orderType"` }
func (OrderJsonRequest) MarshalJSON ¶
func (o OrderJsonRequest) MarshalJSON() ([]byte, error)
func (*OrderJsonRequest) UnmarshalJSON ¶
func (o *OrderJsonRequest) UnmarshalJSON(input []byte) error
type OrderState ¶
type OrderState struct { RawOrder Order `json:"rawOrder"` UpdatedBlock *big.Int `json:"updatedBlock"` DealtAmountS *big.Int `json:"dealtAmountS"` DealtAmountB *big.Int `json:"dealtAmountB"` SplitAmountS *big.Int `json:"splitAmountS"` SplitAmountB *big.Int `json:"splitAmountB"` CancelledAmountS *big.Int `json:"cancelledAmountS"` CancelledAmountB *big.Int `json:"cancelledAmountB"` Status OrderStatus `json:"status"` BroadcastTime int `json:"broadcastTime"` }
从[]byte解析时使用json.Unmarshal
func (*OrderState) DealtAndSplitAmount ¶
func (state *OrderState) DealtAndSplitAmount() (totalAmountS *big.Rat, totalAmountB *big.Rat)
func (*OrderState) IsEffective ¶
func (ord *OrderState) IsEffective() bool
func (*OrderState) IsExpired ¶
func (ord *OrderState) IsExpired() bool
func (*OrderState) RemainedAmount ¶
func (orderState *OrderState) RemainedAmount() (remainedAmountS *big.Rat, remainedAmountB *big.Rat)
func (*OrderState) ResolveStatus ¶
func (ord *OrderState) ResolveStatus(allowance, balance *big.Int)
解释订单最终状态
type OrderStatus ¶
type OrderStatus uint8
const ( ORDER_UNKNOWN OrderStatus = 0 ORDER_NEW OrderStatus = 1 ORDER_PARTIAL OrderStatus = 2 ORDER_FINISHED OrderStatus = 3 ORDER_CANCEL OrderStatus = 4 ORDER_CUTOFF OrderStatus = 5 ORDER_EXPIRE OrderStatus = 6 ORDER_PENDING OrderStatus = 7 ORDER_PENDING_FOR_P2P OrderStatus = 17 ORDER_TYPE_MARKET = "market_order" ORDER_TYPE_P2P = "p2p_order" )
type Ring ¶
type Ring struct { Orders []*FilledOrder `json:"orderes"` V uint8 `json:"v"` R Bytes32 `json:"r"` S Bytes32 `json:"s"` Hash common.Hash `json:"hash"` ReducedRate *big.Rat `json:"reducedRate"` //成环之后,折价比例 LegalFee *big.Rat `json:"legalFee"` //法币计算的fee UniqueId common.Hash `json:"uniquedId"` // Received *big.Rat LegalCost *big.Rat Gas *big.Int GasPrice *big.Int }
func (*Ring) FeeSelections ¶
func (*Ring) GenerateUniqueId ¶
func (*Ring) ValidSinceTime ¶
type RingMinedEvent ¶
type RingSubmitInfo ¶
type RingSubmitResultEvent ¶
type SubmitRingMethodEvent ¶
type TokenRegisterEvent ¶
type TokenUnRegisterEvent ¶
type TransactionEvent ¶
type TransactionEvent struct {
Tx TxInfo
}
type TransferEvent ¶
type TxInfo ¶
type TxInfo struct { Protocol common.Address `json:"from"` DelegateAddress common.Address `json:"to"` From common.Address `json:"from"` To common.Address `json:"to"` BlockHash common.Hash `json:"block_hash"` BlockNumber *big.Int `json:"block_number"` BlockTime int64 `json:"block_time"` TxHash common.Hash `json:"tx_hash"` TxIndex int64 `json:"tx_index"` TxLogIndex int64 `json:"tx_log_index"` Value *big.Int `json:"value"` Status TxStatus `json:"status"` GasLimit *big.Int `json:"gas_limit"` GasUsed *big.Int `json:"gas_used"` GasPrice *big.Int `json:"gas_price"` Nonce *big.Int `json:"nonce"` Identify string `json:"identify"` }
type WethWithdrawalEvent ¶
type WhiteListUser ¶
type WhiteListUser struct { Owner common.Address `json:"owner"` CreateTime int64 `json:"create_time"` }
func (WhiteListUser) MarshalJSON ¶
func (w WhiteListUser) MarshalJSON() ([]byte, error)
func (*WhiteListUser) UnmarshalJSON ¶
func (w *WhiteListUser) UnmarshalJSON(input []byte) error
Click to show internal directories.
Click to hide internal directories.