dex

package
v0.0.0-...-96daba7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PledgeForVx = iota + 1
	PledgeForVip
)
View Source
const (
	Pledge = iota + 1
	CancelPledge
)
View Source
const (
	OwnerConfigOwner          = 1
	OwnerConfigTimer          = 2
	OwnerConfigTrigger        = 4
	OwnerConfigStopViteX      = 8
	OwnerConfigMakerMineProxy = 16
	OwnerConfigMaintainer     = 32
)

MethodNameDexFundOwnerConfig

View Source
const (
	OwnerConfigMineMarket     = 1
	OwnerConfigNewQuoteToken  = 2
	OwnerConfigTradeThreshold = 4
	OwnerConfigMineThreshold  = 8
)

MethodNameDexFundOwnerConfigTrade

View Source
const (
	MarketOwnerTransferOwner   = 1
	MarketOwnerConfigTakerRate = 2
	MarketOwnerConfigMakerRate = 4
	MarketOwnerStopMarket      = 8
)
View Source
const (
	ViteTokenType = iota + 1
	EthTokenType
	BtcTokenType
	UsdTokenType
)
View Source
const (
	MineForMaker = iota + 1
	MineForMaintainer
)
View Source
const (
	FeeDividendJob = iota + 1
	BrokerFeeDividendJob
	MineVxForFeeJob
	MineVxForPledgeJob
	MineVxForMakerAndMaintainerJob
)
View Source
const (
	GetTokenForNewMarket = iota + 1
	GetTokenForSetQuote
	GetTokenForTransferOwner
)
View Source
const (
	Pending = iota
	PartialExecuted
	FullyExecuted
	Cancelled
	NewFailed
)
View Source
const (
	Limited = iota
	Market
)
View Source
const CleanExpireOrdersMaxCount = 200
View Source
const OrderIdBytesLength = 22
View Source
const PriceBytesLength = 10

Variables

View Source
var (
	InvalidInputParamErr = errors.New("invalid input param")

	InvalidOrderIdErr       = errors.New("invalid order id")
	InvalidOrderTypeErr     = errors.New("invalid order type")
	InvalidOrderPriceErr    = errors.New("invalid order price format")
	InvalidOrderQuantityErr = errors.New("invalid order quantity")
	OrderNotExistsErr       = errors.New("order not exists")
	OrderAmountTooSmallErr  = errors.New("order amount too small")

	ViteXStoppedErr                 = errors.New("viteX stopped")
	TradeMarketExistsErr            = errors.New("trade market already exists")
	TradeMarketNotExistsErr         = errors.New("trade market not exists")
	TradeMarketStoppedErr           = errors.New("trade market stopped")
	ComposeOrderIdFailErr           = errors.New("compose order id fail")
	DeComposeOrderIdFailErr         = errors.New("decompose order id fail")
	TradeMarketInvalidQuoteTokenErr = errors.New("invalid quote token")
	TradeMarketInvalidTokenPairErr  = errors.New("invalid token pair")
	TradeMarketAllowMineErr         = errors.New("token pair already allow mine")
	TradeMarketNotAllowMineErr      = errors.New("token pair already not allow mine")

	CancelOrderOwnerInvalidErr  = errors.New("order to cancel not own to initiator")
	CancelOrderInvalidStatusErr = errors.New("order status is invalid to cancel")

	OnlyOwnerAllowErr = errors.New("only owner allow")

	ExceedFundAvailableErr        = errors.New("exceed fund available")
	ExceedFundLockedErr           = errors.New("try release locked amount exceed locked")
	InvalidPledgeAmountErr        = errors.New("invalid pledge amount")
	InvalidPledgeActionTypeErr    = errors.New("invalid pledge action type")
	ExceedPledgeAvailableErr      = errors.New("exceed pledge available")
	PledgeAmountLeavedNotValidErr = errors.New("pledge amount leaved not valid")
	PledgeForVipExistsErr         = errors.New("pledge for vip exists")
	PledgeForVipNotExistsErr      = errors.New("pledge for vip not exists")

	InvalidSourceAddressErr           = errors.New("invalid source address")
	InvalidAmountForPledgeCallbackErr = errors.New("invalid amouznt for pledge callback")

	InvalidTokenErr                      = errors.New("invalid token")
	PendingNewMarketInnerConflictErr     = errors.New("pending new market inner conflict")
	GetTokenInfoCallbackInnerConflictErr = errors.New("get token info callback inner conflict")
	InvalidTimestampFromTimerErr         = errors.New("invalid timestamp from timer")
	InvalidBrokerFeeRateErr              = errors.New("invalid broker fee rate")

	NoFeeSumFoundForValidPeriodErr = errors.New("no fee sum found for valid period")
	NotSetTimestampErr             = errors.New("not set timestamp")
	IterateVmDbFailedErr           = errors.New("iterate vm db failed")
	NotSetMaintainerErr            = errors.New("not set maintainer")
	NotSetMineProxyErr             = errors.New("not set mine proxy")

	InvalidInviterFeeAmountErr = errors.New("invalid inviter fee amount")
	AlreadyIsInviterErr        = errors.New("already is inviter")

	InvalidInviteCodeErr     = errors.New("invalid invite code")
	NotBindInviterErr        = errors.New("not bind invite code")
	AlreadyBindInviterErr    = errors.New("already bind inviter")
	NewInviteCodeFailErr     = errors.New("new invite code fail")
	AlreadyQuoteType         = errors.New("already quote type")
	InvalidQuoteTokenTypeErr = errors.New("invalid quote token type")
	FundOwnerNotConfigErr    = errors.New("fund owner not config")

	MultiMarketsInOneActionErr = errors.New("multi markets one action")

	InternalErr = errors.New("internal error")
)
View Source
var (
	VxFundKeyPrefix = []byte("vxF:") // vxFund:types.Address

	VxTokenId, _          = types.HexToTokenTypeId("tti_564954455820434f494e69b5")
	VxMinedAmtFirstPeriod = new(big.Int).Mul(new(big.Int).Exp(helper.Big10, new(big.Int).SetUint64(uint64(13)), nil), big.NewInt(47703236213)) // 477032.36213

	VxDividendThreshold      = new(big.Int).Mul(commonTokenPow, big.NewInt(10))
	NewMarketFeeAmount       = new(big.Int).Mul(commonTokenPow, big.NewInt(10000))
	NewMarketFeeMineAmount   = new(big.Int).Mul(commonTokenPow, big.NewInt(1000))
	NewMarketFeeDonateAmount = new(big.Int).Mul(commonTokenPow, big.NewInt(4000))
	NewMarketFeeBurnAmount   = new(big.Int).Mul(commonTokenPow, big.NewInt(5000))
	NewInviterFeeAmount      = new(big.Int).Mul(commonTokenPow, big.NewInt(1000))

	PledgeForVxMinAmount = new(big.Int).Mul(commonTokenPow, big.NewInt(134))
	PledgeForVipAmount   = new(big.Int).Mul(commonTokenPow, big.NewInt(10000))
	PledgeForVxThreshold = new(big.Int).Mul(commonTokenPow, big.NewInt(134))

	RateSumForFeeMine                = "0.6" // 15% * 4
	RateForPledgeMine                = "0.2" // 20%
	RateSumForMakerAndMaintainerMine = "0.2" // 10% + 10%

	ViteTokenDecimals int32 = 18

	QuoteTokenTypeInfos = map[int32]*QuoteTokenTypeInfo{
		ViteTokenType: &QuoteTokenTypeInfo{Decimals: 18, DefaultTradeThreshold: viteMinAmount, DefaultMineThreshold: viteMineThreshold},
		EthTokenType:  &QuoteTokenTypeInfo{Decimals: 18, DefaultTradeThreshold: ethMinAmount, DefaultMineThreshold: ethMineThreshold},
		BtcTokenType:  &QuoteTokenTypeInfo{Decimals: 8, DefaultTradeThreshold: bitcoinMinAmount, DefaultMineThreshold: bitcoinMineThreshold},
		UsdTokenType:  &QuoteTokenTypeInfo{Decimals: 6, DefaultTradeThreshold: usdMinAmount, DefaultMineThreshold: usdMineThreshold},
	}
)
View Source
var (
	BaseFeeRate      int32 = 200 // 200/100,000 = 0.002
	VipReduceFeeRate int32 = 100 // 0.001
	MaxBrokerFeeRate int32 = 200 // 0.002

	PerPeriodDividendRate int32 = 1000 // 0.01

	InviteBonusRate int32 = 5000 // 0.05

	RateCardinalNum int32 = 100000 // 100,000
)

Functions

func AccumulateAmountFromMap

func AccumulateAmountFromMap(amountMap map[int32]*big.Int) *big.Int

func AddBigInt

func AddBigInt(a []byte, b []byte) []byte

func AddBrokerFeeDividendEvent

func AddBrokerFeeDividendEvent(db vm_db.VmDb, address types.Address, brokerMarketFee *dexproto.BrokerMarketFee)

func AddErrEvent

func AddErrEvent(db vm_db.VmDb, err error)

func AddFeeDividendEvent

func AddFeeDividendEvent(db vm_db.VmDb, address types.Address, feeToken types.TokenTypeId, vxAmount, feeDividend *big.Int)

func AddInviteRelationEvent

func AddInviteRelationEvent(db vm_db.VmDb, inviter, invitee types.Address, inviteCode uint32)

func AddMarketEvent

func AddMarketEvent(db vm_db.VmDb, marketInfo *MarketInfo)

func AddMinedVxForInviteeFeeEvent

func AddMinedVxForInviteeFeeEvent(db vm_db.VmDb, address types.Address, quoteTokenType int32, feeAmount []byte, vxMined *big.Int)

func AddMinedVxForOperationEvent

func AddMinedVxForOperationEvent(db vm_db.VmDb, bizType int32, address types.Address, amount *big.Int)

func AddMinedVxForPledgeEvent

func AddMinedVxForPledgeEvent(db vm_db.VmDb, address types.Address, pledgeAmt, minedAmt *big.Int)

func AddMinedVxForTradeFeeEvent

func AddMinedVxForTradeFeeEvent(db vm_db.VmDb, address types.Address, quoteTokenType int32, feeAmount []byte, vxMined *big.Int)

func AddPeriodWithBizEvent

func AddPeriodWithBizEvent(db vm_db.VmDb, periodId uint64, bizType uint8)

func AddSettleMakerMinedVxEvent

func AddSettleMakerMinedVxEvent(db vm_db.VmDb, periodId uint64, page int32, finish bool)

func AddToPendingNewMarkets

func AddToPendingNewMarkets(db vm_db.VmDb, tradeToken, quoteToken types.TokenTypeId)

func AddToPendingSetQuotes

func AddToPendingSetQuotes(db vm_db.VmDb, token types.TokenTypeId, quoteType uint8)

func AddToPendingTransferTokenOwners

func AddToPendingTransferTokenOwners(db vm_db.VmDb, token types.TokenTypeId, origin, new types.Address)

func AddTokenEvent

func AddTokenEvent(db vm_db.VmDb, tokenInfo *TokenInfo)

func AdjustAmountForDecimalsDiff

func AdjustAmountForDecimalsDiff(amount []byte, decimalsDiff int32) *big.Int

func AdjustForDecimalsDiff

func AdjustForDecimalsDiff(sourceAmountF *big.Float, decimalsDiff int32) *big.Float

func BatchSaveUserFund

func BatchSaveUserFund(db vm_db.VmDb, address types.Address, funds map[types.TokenTypeId]*big.Int) error

func BitwiseNotBytes

func BitwiseNotBytes(bytes []byte)

func BytesToPrice

func BytesToPrice(priceBytes []byte) string

func BytesToUint32

func BytesToUint32(bytes []byte) uint32

func BytesToUint64

func BytesToUint64(bytes []byte) uint64

func CalculateAmountForRate

func CalculateAmountForRate(amount []byte, rate int32) []byte

func CalculateFeeAndExecutedFee

func CalculateFeeAndExecutedFee(order *Order, amount []byte, feeRate, brokerFeeRate int32) (incBaseFee, executedBaseFee, incBrokerFee, executedBrokerFee []byte)

func CalculateRawAmount

func CalculateRawAmount(quantity []byte, price []byte, decimalsDiff int32) []byte

func CalculateRawAmountF

func CalculateRawAmountF(quantity []byte, price []byte, decimalsDiff int32) *big.Float

func CardinalRateToString

func CardinalRateToString(rawRate int32) string

func CheckAndLockFundForNewOrder

func CheckAndLockFundForNewOrder(dexFund *UserFund, order *Order, marketInfo *MarketInfo) (err error)

func CheckMarketParam

func CheckMarketParam(marketParam *ParamDexFundNewMarket) (err error)

func CheckSettleActions

func CheckSettleActions(actions *dexproto.SettleActions) error

func CheckUserPledgesForVxCanBeDelete

func CheckUserPledgesForVxCanBeDelete(pledgesForVx *PledgesForVx) bool

func CheckUserVxFundsCanBeDelete

func CheckUserVxFundsCanBeDelete(vxFunds *VxFunds) bool

func CmpForBigInt

func CmpForBigInt(a []byte, b []byte) int

func CmpToBigZero

func CmpToBigZero(a []byte) int

func ComposeOrderId

func ComposeOrderId(db vm_db.VmDb, marketId int32, side bool, price string) (idBytes []byte)

MarketId[0..2]Side[3]Price[4..13]timestamp[14..18]serialNo[19..21] = 22

func DeComposeOrderId

func DeComposeOrderId(idBytes []byte) (marketId int32, side bool, price []byte, timestamp int64, err error)

func DeleteBrokerFeeSumByKey

func DeleteBrokerFeeSumByKey(db vm_db.VmDb, key []byte)

func DeleteLastSettledMakerMinedVxPage

func DeleteLastSettledMakerMinedVxPage(db vm_db.VmDb)

func DeleteMakerProxyAmountByPeriodId

func DeleteMakerProxyAmountByPeriodId(db vm_db.VmDb, periodId uint64)

func DeleteMarketInfo

func DeleteMarketInfo(db vm_db.VmDb, tradeToken, quoteToken types.TokenTypeId)

func DeletePendingNewMarkets

func DeletePendingNewMarkets(db vm_db.VmDb)

func DeletePendingSetQuotes

func DeletePendingSetQuotes(db vm_db.VmDb)

func DeletePendingTransferTokenOwners

func DeletePendingTransferTokenOwners(db vm_db.VmDb)

func DeletePledgeForVip

func DeletePledgeForVip(db vm_db.VmDb, address types.Address)

func DeletePledgeForVx

func DeletePledgeForVx(db vm_db.VmDb, address types.Address)

func DeletePledgesForVx

func DeletePledgesForVx(db vm_db.VmDb, address types.Address)

func DeleteUserFees

func DeleteUserFees(db vm_db.VmDb, address []byte)

func DeleteVxFunds

func DeleteVxFunds(db vm_db.VmDb, address []byte)

func DepositUserAccount

func DepositUserAccount(db vm_db.VmDb, address types.Address, token types.TokenTypeId, amount *big.Int) (updatedAcc *dexproto.Account)

func DivideByProportion

func DivideByProportion(totalReferAmt, partReferAmt, dividedReferAmt, toDivideTotalAmt, toDivideLeaveAmt *big.Int) (proportionAmt *big.Int, finished bool)

func DoCancelPledge

func DoCancelPledge(db vm_db.VmDb, address types.Address, pledgeType uint8, amount *big.Int) ([]*ledger.AccountBlock, error)

func DoDivideBrokerFees

func DoDivideBrokerFees(db vm_db.VmDb, periodId uint64) error

func DoDivideFees

func DoDivideFees(db vm_db.VmDb, periodId uint64) error

Note: allow dividend from specify periodId, former periods will be divided at that period

func DoMineVxForFee

func DoMineVxForFee(db vm_db.VmDb, reader util.ConsensusReader, periodId uint64, amtForMarkets map[int32]*big.Int) (*big.Int, error)

Note: allow mine from specify periodId, former periods will be ignore

func DoMineVxForMakerMineAndMaintainer

func DoMineVxForMakerMineAndMaintainer(db vm_db.VmDb, periodId uint64, reader util.ConsensusReader, amtForMakerAndMaintainer map[int32]*big.Int) error

func DoMineVxForPledge

func DoMineVxForPledge(db vm_db.VmDb, reader util.ConsensusReader, periodId uint64, amtForPledge *big.Int) (*big.Int, error)

func DoSettleFund

func DoSettleFund(db vm_db.VmDb, reader util.ConsensusReader, action *dexproto.UserFundSettle, marketInfo *MarketInfo) error

func FilterPendingNewMarkets

func FilterPendingNewMarkets(db vm_db.VmDb, tradeToken types.TokenTypeId) (quoteTokens [][]byte, err error)

handle case on duplicate callback for getTokenInfo

func FilterPendingSetQuotes

func FilterPendingSetQuotes(db vm_db.VmDb, token types.TokenTypeId) (action *dexproto.SetQuoteAction, err error)

handle case on duplicate callback for getTokenInfo

func FilterPendingTransferTokenOwners

func FilterPendingTransferTokenOwners(db vm_db.VmDb, token types.TokenTypeId) (action *dexproto.TransferTokenOwnerAction, err error)

handle case on duplicate callback for getTokenInfo

func GetAbs

func GetAbs(v int32) (int32, int32)

func GetAccountByTokeIdFromFund

func GetAccountByTokeIdFromFund(dexFund *UserFund, token types.TokenTypeId) (account *dexproto.Account, exists bool)

func GetBrokerFeeSumKeyByPeriodIdAndAddress

func GetBrokerFeeSumKeyByPeriodIdAndAddress(periodId uint64, address []byte) []byte

func GetCodeByInviter

func GetCodeByInviter(db vm_db.VmDb, address types.Address) uint32

func GetCurrentBrokerFeeSumKey

func GetCurrentBrokerFeeSumKey(db vm_db.VmDb, reader util.ConsensusReader, broker []byte) []byte

func GetCurrentPeriodId

func GetCurrentPeriodId(db vm_db.VmDb, reader util.ConsensusReader) uint64

func GetFeeSumCurrentKey

func GetFeeSumCurrentKey(db vm_db.VmDb, reader util.ConsensusReader) []byte

func GetFeeSumKeyByPeriodId

func GetFeeSumKeyByPeriodId(periodId uint64) []byte

func GetFeeSumLastPeriodIdForRoll

func GetFeeSumLastPeriodIdForRoll(db vm_db.VmDb) uint64

func GetFirstMinedVxPeriodId

func GetFirstMinedVxPeriodId(db vm_db.VmDb) uint64

func GetInviterByCode

func GetInviterByCode(db vm_db.VmDb, inviteCode uint32) (*types.Address, error)

func GetInviterByInvitee

func GetInviterByInvitee(db vm_db.VmDb, invitee types.Address) (*types.Address, error)

func GetLastJobPeriodIdByBizType

func GetLastJobPeriodIdByBizType(db vm_db.VmDb, bizType uint8) uint64

func GetLastJobPeriodIdKey

func GetLastJobPeriodIdKey(bizType uint8) []byte

func GetLastSettledMakerMinedVxPage

func GetLastSettledMakerMinedVxPage(db vm_db.VmDb) int32

func GetLastSettledMakerMinedVxPeriod

func GetLastSettledMakerMinedVxPeriod(db vm_db.VmDb) uint64

func GetMaintainer

func GetMaintainer(db vm_db.VmDb) *types.Address

func GetMakerMineProxy

func GetMakerMineProxy(db vm_db.VmDb) *types.Address

func GetMakerProxyAmountByPeriodId

func GetMakerProxyAmountByPeriodId(db vm_db.VmDb, periodId uint64) *big.Int

func GetMarkerProxyAmountByPeriodIdKey

func GetMarkerProxyAmountByPeriodIdKey(periodId uint64) []byte

func GetMarketInfoKey

func GetMarketInfoKey(tradeToken, quoteToken types.TokenTypeId) []byte

func GetMarketInfoKeyById

func GetMarketInfoKeyById(marketId int32) []byte

func GetMineThreshold

func GetMineThreshold(db vm_db.VmDb, quoteTokenType int32) *big.Int

func GetMineThresholdKey

func GetMineThresholdKey(quoteTokenType uint8) []byte

func GetNotDividedFeeSumsByPeriodId

func GetNotDividedFeeSumsByPeriodId(db vm_db.VmDb, periodId uint64) map[uint64]*FeeSumByPeriod

get all feeSums that not divided yet

func GetOwner

func GetOwner(db vm_db.VmDb) (*types.Address, error)

func GetPeriodIdByTimestamp

func GetPeriodIdByTimestamp(reader util.ConsensusReader, timestamp int64) uint64

func GetPledgeForVipKey

func GetPledgeForVipKey(address types.Address) []byte

func GetPledgeForVx

func GetPledgeForVx(db vm_db.VmDb, address types.Address) *big.Int

func GetPledgeForVxKey

func GetPledgeForVxKey(address types.Address) []byte

func GetPledgesForVxKey

func GetPledgesForVxKey(address types.Address) []byte

func GetTimer

func GetTimer(db vm_db.VmDb) *types.Address

func GetTimerTimestamp

func GetTimerTimestamp(db vm_db.VmDb) int64

func GetTimestampInt64

func GetTimestampInt64(db vm_db.VmDb) int64

func GetTokenInfoKey

func GetTokenInfoKey(token types.TokenTypeId) []byte

func GetTradeThreshold

func GetTradeThreshold(db vm_db.VmDb, quoteTokenType int32) *big.Int

func GetTradeThresholdKey

func GetTradeThresholdKey(quoteTokenType uint8) []byte

func GetTradeTimestamp

func GetTradeTimestamp(db vm_db.VmDb) int64

func GetTrigger

func GetTrigger(db vm_db.VmDb) *types.Address

func GetUserFeesKey

func GetUserFeesKey(address []byte) []byte

func GetUserFundKey

func GetUserFundKey(address types.Address) []byte

func GetVxAmountToMine

func GetVxAmountToMine(db vm_db.VmDb, periodId uint64, vxPool *big.Int, rate string) (amount, vxAmtLeaved *big.Int, success bool)

func GetVxAmountsForEqualItems

func GetVxAmountsForEqualItems(db vm_db.VmDb, periodId uint64, vxPool *big.Int, rateSum string, begin, end int) (amountForItems map[int32]*big.Int, vxAmtLeaved *big.Int, success bool)

func GetVxFundsKey

func GetVxFundsKey(address []byte) []byte

func GetVxMinePool

func GetVxMinePool(db vm_db.VmDb) *big.Int

func GetVxToMineByPeriodId

func GetVxToMineByPeriodId(db vm_db.VmDb, periodId uint64) *big.Int

func HandlePledgeAction

func HandlePledgeAction(db vm_db.VmDb, pledgeType uint8, actionType uint8, address types.Address, amount *big.Int, stakeHeight uint64) ([]*ledger.AccountBlock, error)

func IsDust

func IsDust(order *Order, quantity []byte, decimalsDiff int32) bool

leave quantity is too small for calculate precision

func IsMakerMineProxy

func IsMakerMineProxy(db vm_db.VmDb, addr types.Address) bool

func IsOperationValidWithMask

func IsOperationValidWithMask(operationCode, mask uint8) bool

func IsOwner

func IsOwner(db vm_db.VmDb, address types.Address) bool

func IsValidFeeForMine

func IsValidFeeForMine(userFee *dexproto.UserFeeAccount, mineThreshold *big.Int) bool

func IsValidPledgeAmountBytesForVx

func IsValidPledgeAmountBytesForVx(amount []byte) bool

func IsValidPledgeAmountForVx

func IsValidPledgeAmountForVx(amount *big.Int) bool

func IsValidVxAmountBytesForDividend

func IsValidVxAmountBytesForDividend(amount []byte) bool

func IsValidVxAmountForDividend

func IsValidVxAmountForDividend(amount *big.Int) bool

func IsViteXStopped

func IsViteXStopped(db vm_db.VmDb) bool

func MarkFeeSumAsFeeDivided

func MarkFeeSumAsFeeDivided(db vm_db.VmDb, feeSum *FeeSumByPeriod, periodId uint64)

fee sum used both by fee dividend and mined vx dividend

func MarkFeeSumAsMinedVxDivided

func MarkFeeSumAsMinedVxDivided(db vm_db.VmDb, feeSum *FeeSumByPeriod, periodId uint64)

func MatchPledgeForVxByPeriod

func MatchPledgeForVxByPeriod(pledgesForVx *PledgesForVx, periodId uint64, checkDelete bool) (bool, []byte, bool, bool)

func MatchVxFundsByPeriod

func MatchVxFundsByPeriod(vxFunds *VxFunds, periodId uint64, checkDelete bool) (bool, []byte, bool, bool)

func MaxTotalFeeRate

func MaxTotalFeeRate(order Order) int32

func MinBigInt

func MinBigInt(a []byte, b []byte) []byte

func NegativeAmount

func NegativeAmount(amount []byte) *big.Int

func NewAndSaveMarketId

func NewAndSaveMarketId(db vm_db.VmDb) (newId int32)

func NewAndSaveOrderSerialNo

func NewAndSaveOrderSerialNo(db vm_db.VmDb, timestamp int64) (newSerialNo int32)

func NewInviteCode

func NewInviteCode(db vm_db.VmDb, hash types.Hash) uint32

func NormalizeToQuoteTokenTypeAmount

func NormalizeToQuoteTokenTypeAmount(amount []byte, tokenDecimals, quoteTokenType int32) []byte

func OnCancelPledgeForVxSuccess

func OnCancelPledgeForVxSuccess(db vm_db.VmDb, reader util.ConsensusReader, address types.Address, amount, updatedAmount *big.Int)

func OnDepositVx

func OnDepositVx(db vm_db.VmDb, reader util.ConsensusReader, address types.Address, depositAmount *big.Int, updatedVxAccount *dexproto.Account)

func OnNewMarketGetTokenInfoFailed

func OnNewMarketGetTokenInfoFailed(db vm_db.VmDb, tradeTokenId types.TokenTypeId) (err error)

func OnNewMarketGetTokenInfoSuccess

func OnNewMarketGetTokenInfoSuccess(db vm_db.VmDb, reader util.ConsensusReader, tradeTokenId types.TokenTypeId, tokenInfoRes *ParamDexFundGetTokenInfoCallback) (appendBlocks []*ledger.AccountBlock, err error)

func OnNewMarketPending

func OnNewMarketPending(db vm_db.VmDb, param *ParamDexFundNewMarket, marketInfo *MarketInfo) []byte

func OnNewMarketValid

func OnNewMarketValid(db vm_db.VmDb, reader util.ConsensusReader, marketInfo *MarketInfo, tradeToken, quoteToken types.TokenTypeId, address *types.Address) (block []*ledger.AccountBlock, err error)

func OnPledgeForVxSuccess

func OnPledgeForVxSuccess(db vm_db.VmDb, reader util.ConsensusReader, address types.Address, amount, updatedAmount *big.Int)

func OnSetQuoteGetTokenInfoFailed

func OnSetQuoteGetTokenInfoFailed(db vm_db.VmDb, tokenId types.TokenTypeId) (err error)

func OnSetQuoteGetTokenInfoSuccess

func OnSetQuoteGetTokenInfoSuccess(db vm_db.VmDb, tokenInfoRes *ParamDexFundGetTokenInfoCallback) error

func OnSetQuoteTokenPending

func OnSetQuoteTokenPending(db vm_db.VmDb, token types.TokenTypeId, quoteTokenType uint8) []byte

func OnSettleVx

func OnSettleVx(db vm_db.VmDb, reader util.ConsensusReader, address []byte, fundSettle *dexproto.FundSettle, updatedVxAccount *dexproto.Account)

func OnTransferOwnerGetTokenInfoFailed

func OnTransferOwnerGetTokenInfoFailed(db vm_db.VmDb, tradeTokenId types.TokenTypeId) (err error)

func OnTransferOwnerGetTokenInfoSuccess

func OnTransferOwnerGetTokenInfoSuccess(db vm_db.VmDb, param *ParamDexFundGetTokenInfoCallback) error

func OnTransferTokenOwnerPending

func OnTransferTokenOwnerPending(db vm_db.VmDb, token types.TokenTypeId, origin, new types.Address) []byte

func OnWithdrawVx

func OnWithdrawVx(db vm_db.VmDb, reader util.ConsensusReader, address types.Address, withdrawAmount *big.Int, updatedVxAccount *dexproto.Account)

func PreCheckOrderParam

func PreCheckOrderParam(orderParam *ParamDexFundNewOrder) error

func PriceToBytes

func PriceToBytes(price string) []byte

func RenderFeeRate

func RenderFeeRate(address types.Address, order *Order, marketInfo *MarketInfo, db vm_db.VmDb)

func RenderMarketInfo

func RenderMarketInfo(db vm_db.VmDb, marketInfo *MarketInfo, tradeToken, quoteToken types.TokenTypeId, tradeTokenInfo *TokenInfo, creator *types.Address) error

func RoundAmount

func RoundAmount(amountF *big.Float) *big.Int

func SaveCodeByInviter

func SaveCodeByInviter(db vm_db.VmDb, address types.Address, inviteCode uint32)

func SaveCurrentBrokerFeeSum

func SaveCurrentBrokerFeeSum(db vm_db.VmDb, reader util.ConsensusReader, broker []byte, brokerFeeSum *BrokerFeeSumByPeriod)

func SaveCurrentFeeSum

func SaveCurrentFeeSum(db vm_db.VmDb, reader util.ConsensusReader, feeSum *FeeSumByPeriod)

func SaveFeeSumLastPeriodIdForRoll

func SaveFeeSumLastPeriodIdForRoll(db vm_db.VmDb, periodId uint64)

func SaveFeeSumWithPeriodId

func SaveFeeSumWithPeriodId(db vm_db.VmDb, feeSum *FeeSumByPeriod, periodId uint64)

func SaveFirstMinedVxPeriodId

func SaveFirstMinedVxPeriodId(db vm_db.VmDb, periodId uint64)

func SaveInviterByCode

func SaveInviterByCode(db vm_db.VmDb, address types.Address, inviteCode uint32)

func SaveInviterByInvitee

func SaveInviterByInvitee(db vm_db.VmDb, invitee, inviter types.Address)

func SaveLastJobPeriodIdByBizType

func SaveLastJobPeriodIdByBizType(db vm_db.VmDb, periodId uint64, bizType uint8)

func SaveLastSettledMakerMinedVxPage

func SaveLastSettledMakerMinedVxPage(db vm_db.VmDb, pageId int32)

func SaveLastSettledMakerMinedVxPeriod

func SaveLastSettledMakerMinedVxPeriod(db vm_db.VmDb, periodId uint64)

func SaveMaintainer

func SaveMaintainer(db vm_db.VmDb, addr types.Address)

func SaveMakerMineProxy

func SaveMakerMineProxy(db vm_db.VmDb, addr types.Address)

func SaveMakerProxyAmountByPeriodId

func SaveMakerProxyAmountByPeriodId(db vm_db.VmDb, periodId uint64, amount *big.Int)

func SaveMarketInfo

func SaveMarketInfo(db vm_db.VmDb, marketInfo *MarketInfo, tradeToken, quoteToken types.TokenTypeId)

func SaveMarketInfoById

func SaveMarketInfoById(db vm_db.VmDb, marketInfo *MarketInfo)

func SaveMineThreshold

func SaveMineThreshold(db vm_db.VmDb, quoteTokenType uint8, amount *big.Int)

func SavePendingNewMarkets

func SavePendingNewMarkets(db vm_db.VmDb, pendingNewMarkets *PendingNewMarkets)

func SavePendingSetQuotes

func SavePendingSetQuotes(db vm_db.VmDb, pendingSetQuotes *PendingSetQuotes)

func SavePendingTransferTokenOwners

func SavePendingTransferTokenOwners(db vm_db.VmDb, pendings *PendingTransferTokenOwners)

func SavePledgeForVip

func SavePledgeForVip(db vm_db.VmDb, address types.Address, pledgeVip *PledgeVip)

func SavePledgeForVx

func SavePledgeForVx(db vm_db.VmDb, address types.Address, amount *big.Int)

func SavePledgesForVx

func SavePledgesForVx(db vm_db.VmDb, address types.Address, ps *PledgesForVx)

func SavePledgesForVxSum

func SavePledgesForVxSum(db vm_db.VmDb, ps *PledgesForVx)

func SaveTokenInfo

func SaveTokenInfo(db vm_db.VmDb, token types.TokenTypeId, tokenInfo *TokenInfo)

func SaveTradeThreshold

func SaveTradeThreshold(db vm_db.VmDb, quoteTokenType uint8, amount *big.Int)

func SaveUserFees

func SaveUserFees(db vm_db.VmDb, address []byte, userFees *UserFees)

func SaveUserFund

func SaveUserFund(db vm_db.VmDb, address types.Address, dexFund *UserFund)

func SaveViteXStopped

func SaveViteXStopped(db vm_db.VmDb, isStopViteX bool)

func SaveVxFunds

func SaveVxFunds(db vm_db.VmDb, address []byte, vxFunds *VxFunds)

func SaveVxMinePool

func SaveVxMinePool(db vm_db.VmDb, amount *big.Int)

func SaveVxSumFunds

func SaveVxSumFunds(db vm_db.VmDb, vxSumFunds *VxFunds)

func SetFeeRate

func SetFeeRate(baseRate int32)

only for unit test

func SetOwner

func SetOwner(db vm_db.VmDb, address types.Address)

func SetTimerAddress

func SetTimerAddress(db vm_db.VmDb, address types.Address)

func SetTimerTimestamp

func SetTimerTimestamp(db vm_db.VmDb, timestamp int64, reader util.ConsensusReader) error

func SetTradeTimestamp

func SetTradeTimestamp(db vm_db.VmDb, timestamp int64)

func SetTriggerAddress

func SetTriggerAddress(db vm_db.VmDb, address types.Address)

func SettleBrokerFeeSum

func SettleBrokerFeeSum(db vm_db.VmDb, reader util.ConsensusReader, feeActions []*dexproto.UserFeeSettle, marketInfo *MarketInfo)

func SettleFees

func SettleFees(db vm_db.VmDb, reader util.ConsensusReader, allowMine bool, feeToken []byte, feeTokenDecimals, quoteTokenType int32, feeActions []*dexproto.UserFeeSettle, feeForDividend *big.Int, inviteRelations map[types.Address]*types.Address)

func SettleFeesWithTokenId

func SettleFeesWithTokenId(db vm_db.VmDb, reader util.ConsensusReader, allowMine bool, tokenId types.TokenTypeId, feeTokenDecimals, quoteTokenType int32, feeActions []*dexproto.UserFeeSettle, feeForDividend *big.Int, inviteRelations map[types.Address]*types.Address)

func SubBigInt

func SubBigInt(a []byte, b []byte) *big.Int

func SubBigIntAbs

func SubBigIntAbs(a []byte, b []byte) []byte

func SubUserFund

func SubUserFund(db vm_db.VmDb, address types.Address, tokenId []byte, amount *big.Int) (updatedAcc *dexproto.Account, err error)

func TruncateUserFeesToPeriod

func TruncateUserFeesToPeriod(userFees *UserFees, periodId uint64) (truncated bool)

func TryUpdateTimestamp

func TryUpdateTimestamp(db vm_db.VmDb, timestamp int64, preHash types.Hash)

func Uint32ToBytes

func Uint32ToBytes(value uint32) []byte

func Uint64ToBytes

func Uint64ToBytes(value uint64) []byte

func ValidBrokerFeeRate

func ValidBrokerFeeRate(feeRate int32) bool

func ValidPrice

func ValidPrice(price string) bool

func ValidTimerAddress

func ValidTimerAddress(db vm_db.VmDb, address types.Address) bool

func ValidTriggerAddress

func ValidTriggerAddress(db vm_db.VmDb, address types.Address) bool

Types

type Account

type Account struct {
	Token     types.TokenTypeId
	Available *big.Int
	Locked    *big.Int
}

func GetAccountFundInfo

func GetAccountFundInfo(dexFund *UserFund, tokenId *types.TokenTypeId) ([]*Account, error)

func (*Account) Deserialize

func (account *Account) Deserialize(pb *dexProto.Account)

func (*Account) Serialize

func (account *Account) Serialize() *dexProto.Account

type AmountWithToken

type AmountWithToken struct {
	Token   types.TokenTypeId
	Amount  *big.Int
	Deleted bool
}

func MapToAmountWithTokens

func MapToAmountWithTokens(mp map[types.TokenTypeId]*big.Int) []*AmountWithToken

type AmountWithTokenSorter

type AmountWithTokenSorter []*AmountWithToken

func (AmountWithTokenSorter) Len

func (st AmountWithTokenSorter) Len() int

func (AmountWithTokenSorter) Less

func (st AmountWithTokenSorter) Less(i, j int) bool

func (AmountWithTokenSorter) Swap

func (st AmountWithTokenSorter) Swap(i, j int)

type BrokerFeeDividendEvent

type BrokerFeeDividendEvent struct {
	dexproto.BrokerFeeDividend
}

func (BrokerFeeDividendEvent) FromBytes

func (bfd BrokerFeeDividendEvent) FromBytes(data []byte) interface{}

func (BrokerFeeDividendEvent) GetTopicId

func (bfd BrokerFeeDividendEvent) GetTopicId() types.Hash

type BrokerFeeSumByPeriod

type BrokerFeeSumByPeriod struct {
	dexproto.BrokerFeeSumByPeriod
}

func GetBrokerFeeSumByPeriodId

func GetBrokerFeeSumByPeriodId(db vm_db.VmDb, broker []byte, periodId uint64) (*BrokerFeeSumByPeriod, bool)

func GetCurrentBrokerFeeSum

func GetCurrentBrokerFeeSum(db vm_db.VmDb, reader util.ConsensusReader, broker []byte) (*BrokerFeeSumByPeriod, bool)

func (*BrokerFeeSumByPeriod) DeSerialize

func (bfs *BrokerFeeSumByPeriod) DeSerialize(data []byte) (err error)

func (*BrokerFeeSumByPeriod) Serialize

func (bfs *BrokerFeeSumByPeriod) Serialize() (data []byte, err error)

type DexEvent

type DexEvent interface {
	GetTopicId() types.Hash

	FromBytes([]byte) interface{}
	// contains filtered or unexported methods
}

type ErrEvent

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

func (ErrEvent) FromBytes

func (err ErrEvent) FromBytes(data []byte) interface{}

func (ErrEvent) GetTopicId

func (err ErrEvent) GetTopicId() types.Hash

type FeeDividendEvent

type FeeDividendEvent struct {
	dexproto.FeeDividendForVxHolder
}

func (FeeDividendEvent) FromBytes

func (fde FeeDividendEvent) FromBytes(data []byte) interface{}

func (FeeDividendEvent) GetTopicId

func (fde FeeDividendEvent) GetTopicId() types.Hash

type FeeSumByPeriod

type FeeSumByPeriod struct {
	dexproto.FeeSumByPeriod
}

func GetCurrentFeeSum

func GetCurrentFeeSum(db vm_db.VmDb, reader util.ConsensusReader) (*FeeSumByPeriod, bool)

func GetFeeSumByPeriodId

func GetFeeSumByPeriodId(db vm_db.VmDb, periodId uint64) (*FeeSumByPeriod, bool)

func RollAndGentNewFeeSumByPeriod

func RollAndGentNewFeeSumByPeriod(db vm_db.VmDb, periodId uint64) (rolledFeeSumByPeriod *FeeSumByPeriod)

func (*FeeSumByPeriod) DeSerialize

func (df *FeeSumByPeriod) DeSerialize(feeSumData []byte) (err error)

func (*FeeSumByPeriod) Serialize

func (df *FeeSumByPeriod) Serialize() (data []byte, err error)

type FundSettleSorter

type FundSettleSorter []*dexproto.FundSettle

func (FundSettleSorter) Len

func (st FundSettleSorter) Len() int

func (FundSettleSorter) Less

func (st FundSettleSorter) Less(i, j int) bool

func (FundSettleSorter) Swap

func (st FundSettleSorter) Swap(i, j int)

type FundVerifyItem

type FundVerifyItem struct {
	TokenId        types.TokenTypeId `json:"tokenId"`
	Balance        string            `json:"balance"`
	Amount         string            `json:"amount"`
	UserAmount     string            `json:"userAmount"`
	FeeAmount      string            `json:"feeAmount"`
	FeeOccupy      string            `json:"feeOccupy"`
	BalanceMatched bool              `json:"balanceMatched"`
}

type FundVerifyRes

type FundVerifyRes struct {
	UserCount      int                                   `json:"userCount"`
	BalanceMatched bool                                  `json:"balanceMatched"`
	VerifyItems    map[types.TokenTypeId]*FundVerifyItem `json:"balances"`
}

func VerifyDexFundBalance

func VerifyDexFundBalance(db vm_db.VmDb, reader *util.VMConsensusReader) *FundVerifyRes

type InviteRelationEvent

type InviteRelationEvent struct {
	dexproto.InviteRelation
}

func (InviteRelationEvent) FromBytes

func (ir InviteRelationEvent) FromBytes(data []byte) interface{}

func (InviteRelationEvent) GetTopicId

func (ir InviteRelationEvent) GetTopicId() types.Hash

type MarketEvent

type MarketEvent struct {
	dexproto.MarketInfo
}

func (MarketEvent) FromBytes

func (me MarketEvent) FromBytes(data []byte) interface{}

func (MarketEvent) GetTopicId

func (me MarketEvent) GetTopicId() types.Hash

type MarketInfo

type MarketInfo struct {
	dexproto.MarketInfo
}

func CleanExpireOrders

func CleanExpireOrders(db vm_db.VmDb, orderIds []byte) (map[types.Address]map[bool]*dexproto.FundSettle, *MarketInfo, error)

func GetMarketInfo

func GetMarketInfo(db vm_db.VmDb, tradeToken, quoteToken types.TokenTypeId) (marketInfo *MarketInfo, ok bool)

func GetMarketInfoById

func GetMarketInfoById(db vm_db.VmDb, marketId int32) (marketInfo *MarketInfo, ok bool)

func GetMarketInfoByTokens

func GetMarketInfoByTokens(db vm_db.VmDb, tradeTokenData, quoteTokenData []byte) (marketInfo *MarketInfo, ok bool)

func RenderOrder

func RenderOrder(order *Order, param *ParamDexFundNewOrder, db vm_db.VmDb, address types.Address) (*MarketInfo, error)

func (*MarketInfo) DeSerialize

func (mi *MarketInfo) DeSerialize(data []byte) error

func (*MarketInfo) Serialize

func (mi *MarketInfo) Serialize() (data []byte, err error)

type Matcher

type Matcher struct {
	MarketInfo *MarketInfo
	// contains filtered or unexported fields
}

func NewMatcher

func NewMatcher(db vm_db.VmDb, marketId int32) (mc *Matcher, err error)

func NewMatcherWithMarketInfo

func NewMatcherWithMarketInfo(db vm_db.VmDb, marketInfo *MarketInfo) (mc *Matcher)

func NewRawMatcher

func NewRawMatcher(db vm_db.VmDb) (mc *Matcher)

func (*Matcher) CancelOrderById

func (mc *Matcher) CancelOrderById(order *Order)

func (*Matcher) GetFees

func (mc *Matcher) GetFees() map[types.Address]*proto.UserFeeSettle

func (*Matcher) GetFundSettles

func (mc *Matcher) GetFundSettles() map[types.Address]map[bool]*proto.FundSettle

func (*Matcher) GetOrderById

func (mc *Matcher) GetOrderById(orderId []byte) (*Order, error)

func (*Matcher) GetOrdersFromMarket

func (mc *Matcher) GetOrdersFromMarket(side bool, begin, end int) ([]*Order, int, error)

func (*Matcher) MatchOrder

func (mc *Matcher) MatchOrder(taker *Order, preHash types.Hash) (err error)

type MinedVxForInviteeFeeEvent

type MinedVxForInviteeFeeEvent struct {
	dexproto.MinedVxForFee
}

func (MinedVxForInviteeFeeEvent) FromBytes

func (mif MinedVxForInviteeFeeEvent) FromBytes(data []byte) interface{}

func (MinedVxForInviteeFeeEvent) GetTopicId

func (mif MinedVxForInviteeFeeEvent) GetTopicId() types.Hash

type MinedVxForOperationEvent

type MinedVxForOperationEvent struct {
	dexproto.MinedVxForOperation
}

func (MinedVxForOperationEvent) FromBytes

func (mo MinedVxForOperationEvent) FromBytes(data []byte) interface{}

func (MinedVxForOperationEvent) GetTopicId

func (mo MinedVxForOperationEvent) GetTopicId() types.Hash

type MinedVxForPledgeEvent

type MinedVxForPledgeEvent struct {
	dexproto.MinedVxForPledge
}

func (MinedVxForPledgeEvent) FromBytes

func (mp MinedVxForPledgeEvent) FromBytes(data []byte) interface{}

func (MinedVxForPledgeEvent) GetTopicId

func (mp MinedVxForPledgeEvent) GetTopicId() types.Hash

type MinedVxForTradeFeeEvent

type MinedVxForTradeFeeEvent struct {
	dexproto.MinedVxForFee
}

func (MinedVxForTradeFeeEvent) FromBytes

func (mtf MinedVxForTradeFeeEvent) FromBytes(data []byte) interface{}

func (MinedVxForTradeFeeEvent) GetTopicId

func (mtf MinedVxForTradeFeeEvent) GetTopicId() types.Hash

type NewOrderEvent

type NewOrderEvent struct {
	dexproto.NewOrderInfo
}

func (NewOrderEvent) FromBytes

func (od NewOrderEvent) FromBytes(data []byte) interface{}

func (NewOrderEvent) GetTopicId

func (od NewOrderEvent) GetTopicId() types.Hash

type Order

type Order struct {
	dexproto.Order
}

func (*Order) DeSerialize

func (od *Order) DeSerialize(orderData []byte) error

func (*Order) DeSerializeCompact

func (od *Order) DeSerializeCompact(orderData []byte, orderId []byte) error

func (*Order) RenderOrderById

func (od *Order) RenderOrderById(orderId []byte) error

func (*Order) Serialize

func (od *Order) Serialize() ([]byte, error)

func (*Order) SerializeCompact

func (od *Order) SerializeCompact() ([]byte, error)

type OrderIdSerialNo

type OrderIdSerialNo struct {
	dexproto.OrderIdSerialNo
}

func (*OrderIdSerialNo) DeSerialize

func (osn *OrderIdSerialNo) DeSerialize(data []byte) error

func (*OrderIdSerialNo) Serialize

func (osn *OrderIdSerialNo) Serialize() (data []byte, err error)

type OrderTx

type OrderTx struct {
	proto.Transaction
	// contains filtered or unexported fields
}

type OrderUpdateEvent

type OrderUpdateEvent struct {
	dexproto.OrderUpdateInfo
}

func (OrderUpdateEvent) FromBytes

func (od OrderUpdateEvent) FromBytes(data []byte) interface{}

func (OrderUpdateEvent) GetTopicId

func (od OrderUpdateEvent) GetTopicId() types.Hash

type ParamDexCancelOrder

type ParamDexCancelOrder struct {
	OrderId []byte
}

type ParamDexFundCancelPledge

type ParamDexFundCancelPledge struct {
	PledgeAddress types.Address
	Beneficial    types.Address
	Amount        *big.Int
	Bid           uint8
}

type ParamDexFundGetTokenInfoCallback

type ParamDexFundGetTokenInfoCallback struct {
	TokenId     types.TokenTypeId
	Bid         uint8
	Exist       bool
	Decimals    uint8
	TokenSymbol string
	Index       uint16
	Owner       types.Address
}

type ParamDexFundMarketOwnerConfig

type ParamDexFundMarketOwnerConfig struct {
	OperationCode uint8 // 1 owner, 2 takerRate, 4 makerRate, 8 stopMarket
	TradeToken    types.TokenTypeId
	QuoteToken    types.TokenTypeId
	Owner         types.Address
	TakerFeeRate  int32
	MakerFeeRate  int32
	StopMarket    bool
}

type ParamDexFundNewMarket

type ParamDexFundNewMarket struct {
	TradeToken types.TokenTypeId
	QuoteToken types.TokenTypeId
}

type ParamDexFundNewOrder

type ParamDexFundNewOrder struct {
	TradeToken types.TokenTypeId
	QuoteToken types.TokenTypeId
	Side       bool
	OrderType  uint8
	Price      string
	Quantity   *big.Int
}

type ParamDexFundNotifyTime

type ParamDexFundNotifyTime struct {
	Timestamp int64
}

type ParamDexFundOwnerConfig

type ParamDexFundOwnerConfig struct {
	OperationCode  uint8
	Owner          types.Address // 1 owner
	Timer          types.Address // 2 timerAddress
	Trigger        types.Address // 4 maintainer
	StopViteX      bool          // 8 stopViteX
	MakerMineProxy types.Address // 16 maker mine proxy
	Maintainer     types.Address // 32 maintainer
}

type ParamDexFundOwnerConfigTrade

type ParamDexFundOwnerConfigTrade struct {
	OperationCode      uint8
	TradeToken         types.TokenTypeId // 1 mineMarket
	QuoteToken         types.TokenTypeId // 1 mineMarket
	AllowMine          bool              // 1 mineMarket
	NewQuoteToken      types.TokenTypeId // 2 new quote token
	QuoteTokenType     uint8             // 2 new quote token
	TokenType4TradeThr uint8             // 4 maintainer
	TradeThreshold     *big.Int          // 4 maintainer
	TokenType4MineThr  uint8             // 8 maintainer
	MineThreshold      *big.Int          // 8 maintainer
}

type ParamDexFundPledge

type ParamDexFundPledge struct {
	PledgeAddress types.Address
	Beneficial    types.Address
	Bid           uint8
}

type ParamDexFundPledgeCallBack

type ParamDexFundPledgeCallBack struct {
	PledgeAddress types.Address
	Beneficial    types.Address
	Amount        *big.Int
	Bid           uint8
	Success       bool
}

type ParamDexFundPledgeForVip

type ParamDexFundPledgeForVip struct {
	ActionType uint8 // 1: pledge 2: cancel pledge
}

type ParamDexFundPledgeForVx

type ParamDexFundPledgeForVx struct {
	ActionType uint8 // 1: pledge 2: cancel pledge
	Amount     *big.Int
}

type ParamDexFundTransferTokenOwner

type ParamDexFundTransferTokenOwner struct {
	Token types.TokenTypeId
	Owner types.Address
}

type ParamDexFundWithDraw

type ParamDexFundWithDraw struct {
	Token  types.TokenTypeId
	Amount *big.Int
}

type ParamDexPeriodJob

type ParamDexPeriodJob struct {
	PeriodId uint64
	BizType  uint8
}

type ParamDexSerializedData

type ParamDexSerializedData struct {
	Data []byte
}

type PendingNewMarkets

type PendingNewMarkets struct {
	dexproto.PendingNewMarkets
}

func GetPendingNewMarkets

func GetPendingNewMarkets(db vm_db.VmDb) (pendingNewMarkets *PendingNewMarkets, ok bool)

func (*PendingNewMarkets) DeSerialize

func (pnm *PendingNewMarkets) DeSerialize(data []byte) error

func (*PendingNewMarkets) Serialize

func (pnm *PendingNewMarkets) Serialize() (data []byte, err error)

type PendingSetQuotes

type PendingSetQuotes struct {
	dexproto.PendingSetQuotes
}

func GetPendingSetQuotes

func GetPendingSetQuotes(db vm_db.VmDb) (pendingSetQuotes *PendingSetQuotes, ok bool)

func (*PendingSetQuotes) DeSerialize

func (psq *PendingSetQuotes) DeSerialize(data []byte) error

func (*PendingSetQuotes) Serialize

func (psq *PendingSetQuotes) Serialize() (data []byte, err error)

type PendingTransferTokenOwners

type PendingTransferTokenOwners struct {
	dexproto.PendingTransferTokenOwners
}

func GetPendingTransferTokenOwners

func GetPendingTransferTokenOwners(db vm_db.VmDb) (pendings *PendingTransferTokenOwners, ok bool)

func (*PendingTransferTokenOwners) DeSerialize

func (psq *PendingTransferTokenOwners) DeSerialize(data []byte) error

func (*PendingTransferTokenOwners) Serialize

func (psq *PendingTransferTokenOwners) Serialize() (data []byte, err error)

type PeriodWithBizEvent

type PeriodWithBizEvent struct {
	dexproto.PeriodWithBiz
}

func (PeriodWithBizEvent) FromBytes

func (pb PeriodWithBizEvent) FromBytes(data []byte) interface{}

func (PeriodWithBizEvent) GetTopicId

func (pb PeriodWithBizEvent) GetTopicId() types.Hash

type PledgeVip

type PledgeVip struct {
	dexproto.PledgeVip
}

func GetPledgeForVip

func GetPledgeForVip(db vm_db.VmDb, address types.Address) (pledgeVip *PledgeVip, ok bool)

func (*PledgeVip) DeSerialize

func (pv *PledgeVip) DeSerialize(data []byte) error

func (*PledgeVip) Serialize

func (pv *PledgeVip) Serialize() (data []byte, err error)

type PledgesForVx

type PledgesForVx struct {
	dexproto.PledgesForVx
}

func GetPledgesForVx

func GetPledgesForVx(db vm_db.VmDb, address types.Address) (pledgesForVx *PledgesForVx, ok bool)

func GetPledgesForVxSum

func GetPledgesForVxSum(db vm_db.VmDb) (pledgesForVx *PledgesForVx, ok bool)

func (*PledgesForVx) DeSerialize

func (psv *PledgesForVx) DeSerialize(data []byte) error

func (*PledgesForVx) Serialize

func (psv *PledgesForVx) Serialize() (data []byte, err error)

type QuoteTokenTypeInfo

type QuoteTokenTypeInfo struct {
	Decimals              int32
	DefaultTradeThreshold *big.Int
	DefaultMineThreshold  *big.Int
}

type SerializableDex

type SerializableDex interface {
	Serialize() ([]byte, error)
	DeSerialize([]byte) error
}

type SettleMakerMinedVxEvent

type SettleMakerMinedVxEvent struct {
	dexproto.SettleMakerMinedVx
}

func (SettleMakerMinedVxEvent) FromBytes

func (smmv SettleMakerMinedVxEvent) FromBytes(data []byte) interface{}

func (SettleMakerMinedVxEvent) GetTopicId

func (smmv SettleMakerMinedVxEvent) GetTopicId() types.Hash

type TokenEvent

type TokenEvent struct {
	dexproto.TokenInfo
}

func (TokenEvent) FromBytes

func (te TokenEvent) FromBytes(data []byte) interface{}

func (TokenEvent) GetTopicId

func (te TokenEvent) GetTopicId() types.Hash

type TokenInfo

type TokenInfo struct {
	dexproto.TokenInfo
}

func GetTokenInfo

func GetTokenInfo(db vm_db.VmDb, token types.TokenTypeId) (tokenInfo *TokenInfo, ok bool)

func (*TokenInfo) DeSerialize

func (tk *TokenInfo) DeSerialize(data []byte) error

func (*TokenInfo) Serialize

func (tk *TokenInfo) Serialize() (data []byte, err error)

type TransactionEvent

type TransactionEvent struct {
	dexproto.Transaction
}

func (TransactionEvent) FromBytes

func (tx TransactionEvent) FromBytes(data []byte) interface{}

func (TransactionEvent) GetTopicId

func (tx TransactionEvent) GetTopicId() types.Hash

type UserFeeSettleSorter

type UserFeeSettleSorter []*dexproto.UserFeeSettle

func (UserFeeSettleSorter) Len

func (st UserFeeSettleSorter) Len() int

func (UserFeeSettleSorter) Less

func (st UserFeeSettleSorter) Less(i, j int) bool

func (UserFeeSettleSorter) Swap

func (st UserFeeSettleSorter) Swap(i, j int)

type UserFees

type UserFees struct {
	dexproto.UserFees
}

func GetUserFees

func GetUserFees(db vm_db.VmDb, address []byte) (userFees *UserFees, ok bool)

func (*UserFees) DeSerialize

func (ufs *UserFees) DeSerialize(userFeesData []byte) error

func (*UserFees) Serialize

func (ufs *UserFees) Serialize() (data []byte, err error)

type UserFund

type UserFund struct {
	dexproto.Fund
}

func GetUserFund

func GetUserFund(db vm_db.VmDb, address types.Address) (dexFund *UserFund, ok bool)

func (*UserFund) DeSerialize

func (df *UserFund) DeSerialize(fundData []byte) (err error)

func (*UserFund) Serialize

func (df *UserFund) Serialize() (data []byte, err error)

type UserFundSettleSorter

type UserFundSettleSorter []*dexproto.UserFundSettle

func (UserFundSettleSorter) Len

func (st UserFundSettleSorter) Len() int

func (UserFundSettleSorter) Less

func (st UserFundSettleSorter) Less(i, j int) bool

func (UserFundSettleSorter) Swap

func (st UserFundSettleSorter) Swap(i, j int)

type VxFunds

type VxFunds struct {
	dexproto.VxFunds
}

func GetVxFunds

func GetVxFunds(db vm_db.VmDb, address []byte) (vxFunds *VxFunds, ok bool)

func GetVxSumFunds

func GetVxSumFunds(db vm_db.VmDb) (vxSumFunds *VxFunds, ok bool)

func (*VxFunds) DeSerialize

func (dvf *VxFunds) DeSerialize(vxFundsData []byte) error

func (*VxFunds) Serialize

func (dvf *VxFunds) Serialize() (data []byte, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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