Version: v2.10.2+incompatible Latest Latest

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

Go to latest
Published: Apr 13, 2021 License: GPL-3.0 Imports: 23 Imported by: 0




View Source
const (
	StakeForMining = iota + 1
View Source
const (
	Stake = iota + 1
View Source
const (
	AdminConfigOwner            = 1
	AdminConfigTimeOracle       = 2
	AdminConfigPeriodJobTrigger = 4
	AdminConfigStopDex          = 8
	AdminConfigMakerMiningAdmin = 16
	AdminConfigMaintainer       = 32


View Source
const (
	TradeAdminConfigMineMarket     = 1
	TradeAdminConfigNewQuoteToken  = 2
	TradeAdminConfigTradeThreshold = 4
	TradeAdminConfigMineThreshold  = 8
	TradeAdminStartNormalMine      = 16
	TradeAdminBurnExtraVx          = 32


View Source
const (
	MarketOwnerTransferOwner   = 1
	MarketOwnerConfigTakerRate = 2
	MarketOwnerConfigMakerRate = 4
	MarketOwnerStopMarket      = 8
View Source
const (
	ViteTokenType = iota + 1
View Source
const (
	MineForMaker = iota + 1
View Source
const (
	FeeDividendJob = iota + 1
View Source
const (
	GetTokenForNewMarket = iota + 1
View Source
const (
	GrantAgent = iota + 1
View Source
const (
	LockVx = iota + 1
View Source
const (
	StakeSubmitted = iota + 1
View Source
const (
	Pending = iota
View Source
const (
	Limited = iota
View Source
const (
	AutoLockMinedVx = iota + 1
View Source
const (
	BurnForDexViteFee = iota + 1
View Source
const CleanExpireOrdersMaxCount = 200
View Source
const (
	CommonAdminConfigStableMarket = 1
View Source
const OrderIdBytesLength = 22
View Source
const PriceBytesLength = 10


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

	InvalidOrderIdErr       = errors.New("invalid order id")
	InvalidOrderHashErr     = errors.New("invalid order hash")
	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")

	DexStoppedErr                   = errors.New("dex stopped")
	TradeMarketExistsErr            = errors.New("trade market already exists")
	TradeMarketNotExistsErr         = errors.New("trade market not exists")
	TradeMarketStoppedErr           = errors.New("trade market stopped")
	TradeMarketNotGrantedErr        = errors.New("trade market not granted")
	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")
	TradeMarketStableMarketErr      = errors.New("already stable currency market")
	TradeMarketNotStableMarketErr   = errors.New("already not stable currency market")

	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")
	InvalidOperationErr = errors.New("invalid operation")

	ExceedFundAvailableErr         = errors.New("exceed fund available")
	ExceedFundLockedErr            = errors.New("try release locked amount exceed locked")
	InvalidStakeAmountErr          = errors.New("invalid stake amount")
	InvalidStakeActionTypeErr      = errors.New("invalid stake action type")
	ExceedStakedAvailableErr       = errors.New("exceed staked available")
	StakingAmountLeavedNotValidErr = errors.New("staking amount leaved not valid")
	VIPStakingExistsErr            = errors.New("VIP staking exists")
	VIPStakingNotExistsErr         = errors.New("VIP staking not exists")
	SuperVipStakingExistsErr       = errors.New("super VIP staking exists")
	SuperVIPStakingNotExistsErr    = errors.New("super VIP staking not exists")
	StakingInfoByIdNotExistsErr    = errors.New("staking info by id not exists")

	InvalidSourceAddressErr          = errors.New("invalid source address")
	InvalidAmountForStakeCallbackErr = errors.New("invalid amount for stake callback")
	InvalidIdForStakeCallbackErr     = errors.New("invalid id for stake callback")

	InvalidTokenErr                      = errors.New("invalid token")
	PendingNewMarketInnerConflictErr     = errors.New("pending new market inner conflict")
	GetTokenInfoCallbackInnerConflictErr = errors.New("get token info callback inner conflict")
	InvalidTimestampFromTimeOracleErr    = errors.New("invalid timestamp from time oracle")
	OracleTimestampExceedPeriodGapErr    = errors.New("oracle timestamp exceed period gap")
	InvalidOperatorFeeRateErr            = errors.New("invalid operator fee rate")

	NoDexFeesFoundForValidPeriodErr = 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")
	NotSetMakerMiningAdmin          = errors.New("not set maker mining admin")

	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")

	DexFundUserNotExists            = errors.New("fund user doesn't exist.")
	LockedVxAmountLeavedNotValidErr = errors.New("locked vx amount leaved not valid")

	InternalErr = errors.New("internal error")
View Source
var (
	VxTokenId, _             = types.HexToTokenTypeId("tti_564954455820434f494e69b5")
	PreheatMinedAmtPerPeriod = new(big.Int).Mul(commonTokenPow, big.NewInt(10000))
	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))

	VxLockThreshold = new(big.Int).Set(commonTokenPow)
	SchedulePeriods = 7 // T+7 schedule

	StakeForMiningMinAmount = new(big.Int).Mul(commonTokenPow, big.NewInt(134))
	StakeForVIPAmount       = new(big.Int).Mul(commonTokenPow, big.NewInt(10000))
	StakeForMiningThreshold = new(big.Int).Mul(commonTokenPow, big.NewInt(134))
	StakeForSuperVIPAmount  = new(big.Int).Mul(commonTokenPow, big.NewInt(1000000))

	RateSumForFeeMine                = "0.6" // 15% * 4
	RateForStakingMine               = "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
	MaxOperatorFeeRate int32 = 200 // 0.002

	PerPeriodDividendRate int32 = 1000 // 0.01

	InviterBonusRate int32 = 5000 // 0.05
	InviteeBonusRate int32 = 2500 // 0.025

	RateCardinalNum int32 = 100000 // 100,000


func AccumulateAmountFromMap

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

func AddBigInt

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

func AddBurnViteEvent

func AddBurnViteEvent(db vm_db.VmDb, bizType int, amount *big.Int)

func AddCancelStake

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

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 AddGrantMarketToAgentEvent

func AddGrantMarketToAgentEvent(db vm_db.VmDb, principal, agent types.Address, marketId int32)

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 AddMinedVxForStakingEvent

func AddMinedVxForStakingEvent(db vm_db.VmDb, address types.Address, stakedAmt, minedAmt *big.Int)

func AddMinedVxForTradeFeeEvent

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

func AddOperatorFeeDividendEvent

func AddOperatorFeeDividendEvent(db vm_db.VmDb, address types.Address, operatorMarketFee *dexproto.OperatorMarketFee)

func AddPeriodWithBizEvent

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

func AddRevokeMarketFromAgentEvent

func AddRevokeMarketFromAgentEvent(db vm_db.VmDb, principal, agent types.Address, marketId int32)

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) error

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 AddVxUnlock

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

func AdjustAmountForDecimalsDiff

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

func AdjustForDecimalsDiff

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

func BatchUpdateFund

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

func BitwiseNotBytes

func BitwiseNotBytes(bytes []byte)

func BurnExtraVx

func BurnExtraVx(db vm_db.VmDb) ([]*ledger.AccountBlock, error)

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, operatorFeeRate int32, isDexFeeFork bool) (incBaseFee, executedBaseFee, incOperatorFee, executedOperatorFee []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 *Fund, order *Order, marketInfo *MarketInfo) (err error)

func CheckCancelAgentOrder

func CheckCancelAgentOrder(db vm_db.VmDb, sender types.Address, param *ParamCancelOrderByHash) (owner types.Address, err error)

func CheckMarketParam

func CheckMarketParam(marketParam *ParamOpenNewMarket) (err error)

func CheckMiningStakingsCanBeDelete

func CheckMiningStakingsCanBeDelete(miningStakings *MiningStakings) bool

func CheckSettleActions

func CheckSettleActions(actions *dexproto.SettleActions) error

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 ConfirmDelegateStakeInfo

func ConfirmDelegateStakeInfo(db vm_db.VmDb, hash types.Hash, info *DelegateStakeInfo, serialNo uint64)

func DeComposeOrderId

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

func DeleteDelegateStakeAddressIndex

func DeleteDelegateStakeAddressIndex(db vm_db.VmDb, address []byte, serialNo uint64)

func DeleteDelegateStakeInfo

func DeleteDelegateStakeInfo(db vm_db.VmDb, hash []byte)

func DeleteHashMapOrderId

func DeleteHashMapOrderId(db vm_db.VmDb, sendHash []byte)

func DeleteLastSettledMakerMinedVxPage

func DeleteLastSettledMakerMinedVxPage(db vm_db.VmDb)

func DeleteMakerMiningPoolByPeriodId

func DeleteMakerMiningPoolByPeriodId(db vm_db.VmDb, periodId uint64)

func DeleteMarketInfo

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

func DeleteMiningStakedAmount

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

func DeleteMiningStakedV2Amount

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

func DeleteMiningStakings

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

func DeleteOperatorFeesByKey

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

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 DeleteSuperVIPStaking

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

func DeleteUserFees

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

func DeleteVIPStaking

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

func DeleteVxFunds

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

func DeleteVxFundsWithForkCheck

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

func DeleteVxLockedFunds

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

func DepositAccount

func DepositAccount(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 DoCancelOrder

func DoCancelOrder(sendHash types.Hash, owner types.Address) ([]*ledger.AccountBlock, error)

func DoCancelStakeV1

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

func DoCancelStakeV2

func DoCancelStakeV2(db vm_db.VmDb, address types.Address, id types.Hash) ([]*ledger.AccountBlock, error)

func DoFeesDividend

func DoFeesDividend(db vm_db.VmDb, periodId uint64) (blocks []*ledger.AccountBlock, err error)

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

func DoFinishCancelMiningStake

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

periodId is finish period

func DoFinishVxUnlock

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

periodId is finish period

func DoMineVxForFee

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

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

func DoMineVxForMaintainer

func DoMineVxForMaintainer(db vm_db.VmDb, reader util.ConsensusReader, amount *big.Int) (err error)

func DoMineVxForMaker

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

func DoMineVxForMakerMineAndMaintainer

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

func DoMineVxForStaking

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

func DoOperatorFeesDividend

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

func DoPlaceOrder

func DoPlaceOrder(db vm_db.VmDb, param *ParamPlaceOrder, accountAddress, agent *types.Address, sendHash types.Hash) ([]*ledger.AccountBlock, error)

func DoRawCancelStakeV2

func DoRawCancelStakeV2(id types.Hash) ([]*ledger.AccountBlock, error)

func DoSettleFund

func DoSettleFund(db vm_db.VmDb, reader util.ConsensusReader, action *dexproto.FundSettle, marketInfo *MarketInfo, fundLogger log15.Logger) error

func DoSettleVxFunds

func DoSettleVxFunds(db vm_db.VmDb, reader util.ConsensusReader, addressBytes []byte, amtChange *big.Int, updatedVxAccount *dexproto.Account) error

only settle validAmount and amount changed from previous period

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.SetQuoteTokenAction, 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 FinishCancelStake

func FinishCancelStake(db vm_db.VmDb, address types.Address, amount *big.Int) (updatedAcc *dexproto.Account, err error)

func FinishVxUnlockForDividend

func FinishVxUnlockForDividend(db vm_db.VmDb, address types.Address, amount *big.Int) (*dexproto.Account, error)

func GetAbs

func GetAbs(v int32) (int32, int32)

func GetAccountByToken

func GetAccountByToken(fund *Fund, token types.TokenTypeId) (account *dexproto.Account, exists bool)

func GetCancelStakesKey

func GetCancelStakesKey(address types.Address) []byte

func GetCodeByInviter

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

func GetCurrentOperatorFeesKey

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

func GetCurrentPeriodId

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

func GetDelegateStakeAddressIndexKey

func GetDelegateStakeAddressIndexKey(address []byte, serialNo uint64) []byte

func GetDelegateStakeIndexSerialNoKey

func GetDelegateStakeIndexSerialNoKey(address []byte) []byte

func GetDelegateStakeInfoKey

func GetDelegateStakeInfoKey(hash []byte) []byte

func GetDexFeesKeyByPeriodId

func GetDexFeesKeyByPeriodId(periodId uint64) []byte

func GetDexFeesLastPeriodIdForRoll

func GetDexFeesLastPeriodIdForRoll(db vm_db.VmDb) uint64

func GetDexTimestamp

func GetDexTimestamp(db vm_db.VmDb) int64

func GetFirstMinedVxPeriodId

func GetFirstMinedVxPeriodId(db vm_db.VmDb) uint64

func GetFundKey

func GetFundKey(address types.Address) []byte

func GetGrantedMarketToAgentKey

func GetGrantedMarketToAgentKey(principal types.Address, marketId int32) []byte

func GetHashMapOrderIdKey

func GetHashMapOrderIdKey(sendHash []byte) []byte

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 GetMakerMiningAdmin

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

func GetMakerMiningPoolByPeriodId

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

func GetMarkerMiningPoolByPeriodIdKey

func GetMarkerMiningPoolByPeriodIdKey(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 GetMiningStakedAmount

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

func GetMiningStakedAmountKey

func GetMiningStakedAmountKey(address types.Address) []byte

func GetMiningStakedV2Amount

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

func GetMiningStakedV2AmountKey

func GetMiningStakedV2AmountKey(address types.Address) []byte

func GetMiningStakingsKey

func GetMiningStakingsKey(address types.Address) []byte

func GetNotFinishDividendDexFeesByPeriodMap

func GetNotFinishDividendDexFeesByPeriodMap(db vm_db.VmDb, periodId uint64) map[uint64]*DexFeesByPeriod

get all dexFeeses that not divided yet

func GetOperatorFeesKeyByPeriodIdAndAddress

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

func GetOrderIdByHash

func GetOrderIdByHash(db vm_db.VmDb, sendHash []byte) ([]byte, bool)

func GetOwner

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

func GetPeriodIdByTimestamp

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

func GetPeriodJobTrigger

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

func GetSuperVIPStakingKey

func GetSuperVIPStakingKey(address types.Address) []byte

func GetTimeOracle

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

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 GetUserFeesKey

func GetUserFeesKey(address []byte) []byte

func GetVIPStakingKey

func GetVIPStakingKey(address types.Address) []byte

func GetVxAmountByPeriodIndex

func GetVxAmountByPeriodIndex(periodIndex uint64) *big.Int

func GetVxAmountToBurn

func GetVxAmountToBurn(db vm_db.VmDb, poolAmt *big.Int) (*big.Int, error)

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 GetVxAutoLockMinedVxKey

func GetVxAutoLockMinedVxKey(address []byte) []byte

func GetVxBurnAmount

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

func GetVxFundsKey

func GetVxFundsKey(address []byte) []byte

func GetVxLockedFundsKey

func GetVxLockedFundsKey(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 GetVxUnlocksKey

func GetVxUnlocksKey(address types.Address) []byte

func GrantMarketToAgent

func GrantMarketToAgent(db vm_db.VmDb, principal, agent types.Address, marketId int32)

func HandleStakeAction

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

func IsAutoLockMinedVx

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

func IsDexFeeFork

func IsDexFeeFork(db vm_db.VmDb) bool

func IsDexMiningFork

func IsDexMiningFork(db vm_db.VmDb) bool

func IsDexRobotFork

func IsDexRobotFork(db vm_db.VmDb) bool

func IsDexStableMarketFork

func IsDexStableMarketFork(db vm_db.VmDb) bool

func IsDexStopped

func IsDexStopped(db vm_db.VmDb) bool

func IsDust

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

leave quantity is too small for calculate precision

func IsEarthFork

func IsEarthFork(db vm_db.VmDb) bool

func IsLeafFork

func IsLeafFork(db vm_db.VmDb) bool

func IsMakerMiningAdmin

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

func IsMarketGrantedToAgent

func IsMarketGrantedToAgent(db vm_db.VmDb, principal, agent types.Address, marketId int32) bool

func IsNormalMiningStarted

func IsNormalMiningStarted(db vm_db.VmDb) bool

func IsOperationValidWithMask

func IsOperationValidWithMask(operationCode, mask uint8) bool

func IsOwner

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

func IsStemFork

func IsStemFork(db vm_db.VmDb) bool

func IsValidFeeForMine

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

func IsValidMiningStakeAmount

func IsValidMiningStakeAmount(amount *big.Int) bool

func IsValidMiningStakeAmountBytes

func IsValidMiningStakeAmountBytes(amount []byte) bool

func IsValidVxAmountBytesForDividend

func IsValidVxAmountBytesForDividend(amount []byte) bool

func IsValidVxAmountForDividend

func IsValidVxAmountForDividend(amount *big.Int) bool

func IsVipStakingWithId

func IsVipStakingWithId(staking *VIPStaking) bool

func LockMinedVx

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

func LockVxForDividend

func LockVxForDividend(db vm_db.VmDb, address types.Address, amount *big.Int) (*dexproto.Account, error)

func MarkDexFeesFinishDividend

func MarkDexFeesFinishDividend(db vm_db.VmDb, dexFeesByPeriod *DexFeesByPeriod, periodId uint64)

dexFees used both by fee dividend and mined vx dividend

func MarkDexFeesFinishMine

func MarkDexFeesFinishMine(db vm_db.VmDb, dexFeesByPeriod *DexFeesByPeriod, periodId uint64)

func MatchMiningStakingByPeriod

func MatchMiningStakingByPeriod(miningStakings *MiningStakings, 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 NewDelegateStakeIndexSerialNo

func NewDelegateStakeIndexSerialNo(db vm_db.VmDb, address []byte) (serialNo uint64)

func NewInviteCode

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

func NormalizeToQuoteTokenTypeAmount

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

func OnCancelMiningStakeSuccess

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

func OnCancelMiningStakeSuccessV2

func OnCancelMiningStakeSuccessV2(db vm_db.VmDb, reader util.ConsensusReader, address types.Address, amount, updatedAmountV2 *big.Int) error

func OnDepositVx

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

func OnMiningStakeSuccess

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

func OnMiningStakeSuccessV2

func OnMiningStakeSuccessV2(db vm_db.VmDb, reader util.ConsensusReader, address types.Address, amount, updatedAmountV2 *big.Int) error

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 *ParamGetTokenInfoCallback) (appendBlocks []*ledger.AccountBlock, err error)

func OnNewMarketPending

func OnNewMarketPending(db vm_db.VmDb, param *ParamOpenNewMarket, marketInfo *MarketInfo) (data []byte, err error)

func OnNewMarketValid

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

func OnSetQuoteGetTokenInfoFailed

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

func OnSetQuoteGetTokenInfoSuccess

func OnSetQuoteGetTokenInfoSuccess(db vm_db.VmDb, tokenInfoRes *ParamGetTokenInfoCallback) 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.AccountSettle, updatedVxAccount *dexproto.Account) error

func OnTransferOwnerGetTokenInfoFailed

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

func OnTransferOwnerGetTokenInfoSuccess

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

func OnTransferTokenOwnerPending

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

func OnVxMined

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

func OnWithdrawVx

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

func PreCheckOrderParam

func PreCheckOrderParam(orderParam *ParamPlaceOrder, isStemFork bool) error

func PriceToBytes

func PriceToBytes(price string) []byte

func ReduceAccount

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

func ReduceVipStakingHash

func ReduceVipStakingHash(stakings *VIPStaking, hash types.Hash) bool

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 RevokeMarketFromAgent

func RevokeMarketFromAgent(db vm_db.VmDb, principal, agent types.Address, marketId int32)

func RoundAmount

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

func SafeSubBigInt

func SafeSubBigInt(amt []byte, sub []byte) (res, actualSub []byte, exceed bool)

func SaveCodeByInviter

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

func SaveCurrentOperatorFees

func SaveCurrentOperatorFees(db vm_db.VmDb, reader util.ConsensusReader, operator []byte, operatorFeesByPeriod *OperatorFeesByPeriod)

func SaveDelegateStakeAddressIndex

func SaveDelegateStakeAddressIndex(db vm_db.VmDb, id types.Hash, stakeType int32, address []byte) uint64

func SaveDelegateStakeInfo

func SaveDelegateStakeInfo(db vm_db.VmDb, hash types.Hash, stakeType uint8, address, principal types.Address, amount *big.Int)

func SaveDexFeesByPeriodId

func SaveDexFeesByPeriodId(db vm_db.VmDb, periodId uint64, dexFeesByPeriod *DexFeesByPeriod)

func SaveDexFeesLastPeriodIdForRoll

func SaveDexFeesLastPeriodIdForRoll(db vm_db.VmDb, periodId uint64)

func SaveDexMiningStakings

func SaveDexMiningStakings(db vm_db.VmDb, ms *MiningStakings)

func SaveDexStopped

func SaveDexStopped(db vm_db.VmDb, isStopDex bool)

func SaveFirstMinedVxPeriodId

func SaveFirstMinedVxPeriodId(db vm_db.VmDb, periodId uint64)

func SaveFund

func SaveFund(db vm_db.VmDb, address types.Address, fund *Fund)

func SaveHashMapOrderId

func SaveHashMapOrderId(db vm_db.VmDb, sendHash []byte, orderId []byte)

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 SaveMakerMiningAdmin

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

func SaveMakerMiningPoolByPeriodId

func SaveMakerMiningPoolByPeriodId(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 SaveMiningStakedAmount

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

func SaveMiningStakedV2Amount

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

func SaveMiningStakings

func SaveMiningStakings(db vm_db.VmDb, address types.Address, ps *MiningStakings)

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 *PendingTransferTokenOwnerActions)

func SaveSuperVIPStaking

func SaveSuperVIPStaking(db vm_db.VmDb, address types.Address, superVIPStaking *VIPStaking)

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 SaveVIPStaking

func SaveVIPStaking(db vm_db.VmDb, address types.Address, vipStaking *VIPStaking)

func SaveVxBurnAmount

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

func SaveVxFunds

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

func SaveVxFundsWithForkCheck

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

func SaveVxLockedFunds

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

func SaveVxLockedSumFunds

func SaveVxLockedSumFunds(db vm_db.VmDb, vxLockedSumFunds *VxFunds)

func SaveVxMinePool

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

func SaveVxSumFunds

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

func SaveVxSumFundsWithForkCheck

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

func ScheduleCancelStake

func ScheduleCancelStake(db vm_db.VmDb, address types.Address, amount *big.Int) (updatedAcc *dexproto.Account, err error)

func ScheduleVxUnlockForDividend

func ScheduleVxUnlockForDividend(db vm_db.VmDb, address types.Address, amount *big.Int) (updatedAcc *dexproto.Account, err error)

func SetAutoLockMinedVx

func SetAutoLockMinedVx(db vm_db.VmDb, address []byte, enable bool)

func SetDexTimestamp

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

func SetOwner

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

func SetPeriodJobTrigger

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

func SetTimeOracle

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

func SetTradeTimestamp

func SetTradeTimestamp(db vm_db.VmDb, timestamp int64)

func SettleFees

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

func SettleFeesWithTokenId

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

func SettleOperatorFees

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

func StartNormalMine

func StartNormalMine(db vm_db.VmDb)

func SubBigInt

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

func SubBigIntAbs

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

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 UpdateCancelStakes

func UpdateCancelStakes(db vm_db.VmDb, address types.Address, cancelStakes *CancelStakes)

func UpdateVxUnlocks

func UpdateVxUnlocks(db vm_db.VmDb, address types.Address, unlocks *VxUnlocks)

func ValidOperatorFeeRate

func ValidOperatorFeeRate(feeRate int32) bool

func ValidPrice

func ValidPrice(price string, isFork bool) bool

func ValidTimeOracle

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

func ValidTriggerAddress

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

func VerifyNewOrderPriceForRpc

func VerifyNewOrderPriceForRpc(data []byte) (valid bool)


type Account

type Account struct {
	Token           types.TokenTypeId
	Available       *big.Int
	Locked          *big.Int
	VxLocked        *big.Int
	VxUnlocking     *big.Int
	CancellingStake *big.Int

func GetAccounts

func GetAccounts(fund *Fund, 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 AccountSettleSorter

type AccountSettleSorter []*dexproto.AccountSettle

func (AccountSettleSorter) Len

func (st AccountSettleSorter) Len() int

func (AccountSettleSorter) Less

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

func (AccountSettleSorter) Swap

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

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 BurnViteEvent

type BurnViteEvent struct {

func (BurnViteEvent) FromBytes

func (bv BurnViteEvent) FromBytes(data []byte) interface{}

func (BurnViteEvent) GetTopicId

func (bv BurnViteEvent) GetTopicId() types.Hash

type CancelStakes

type CancelStakes struct {

func GetCancelStakes

func GetCancelStakes(db vm_db.VmDb, address types.Address) (cancelStakes *CancelStakes, ok bool)

func (*CancelStakes) DeSerialize

func (cs *CancelStakes) DeSerialize(data []byte) error

func (*CancelStakes) Serialize

func (cs *CancelStakes) Serialize() (data []byte, err error)

type DelegateStakeAddressIndex

type DelegateStakeAddressIndex struct {

func (*DelegateStakeAddressIndex) DeSerialize

func (dsi *DelegateStakeAddressIndex) DeSerialize(data []byte) error

func (*DelegateStakeAddressIndex) Serialize

func (dsi *DelegateStakeAddressIndex) Serialize() (data []byte, err error)

type DelegateStakeInfo

type DelegateStakeInfo struct {

func GetDelegateStakeInfo

func GetDelegateStakeInfo(db vm_db.VmDb, hash []byte) (info *DelegateStakeInfo, ok bool)

func GetStakeInfoList

func GetStakeInfoList(db vm_db.VmDb, stakeAddr types.Address, filter func(*DelegateStakeAddressIndex) bool) ([]*DelegateStakeInfo, *big.Int, error)

func GetStakeListByPage

func GetStakeListByPage(db abi.StorageDatabase, lastKey []byte, count int) (infos []*DelegateStakeInfo, newLastKey []byte, err error)

func (*DelegateStakeInfo) DeSerialize

func (dsi *DelegateStakeInfo) DeSerialize(data []byte) error

func (*DelegateStakeInfo) Serialize

func (dsi *DelegateStakeInfo) Serialize() (data []byte, err error)

type DexEvent

type DexEvent interface {
	GetTopicId() types.Hash

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

type DexFeesByPeriod

type DexFeesByPeriod struct {

func GetCurrentDexFees

func GetCurrentDexFees(db vm_db.VmDb, reader util.ConsensusReader) (*DexFeesByPeriod, bool)

func GetDexFeesByPeriodId

func GetDexFeesByPeriodId(db vm_db.VmDb, periodId uint64) (*DexFeesByPeriod, bool)

func RollAndGentNewDexFeesByPeriod

func RollAndGentNewDexFeesByPeriod(db vm_db.VmDb, periodId uint64) (rolledDexFeesByPeriod *DexFeesByPeriod)

func (*DexFeesByPeriod) DeSerialize

func (df *DexFeesByPeriod) DeSerialize(data []byte) (err error)

func (*DexFeesByPeriod) Serialize

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

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 {

func (FeeDividendEvent) FromBytes

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

func (FeeDividendEvent) GetTopicId

func (fde FeeDividendEvent) GetTopicId() types.Hash

type FeeSettleSorter

type FeeSettleSorter []*dexproto.FeeSettle

func (FeeSettleSorter) Len

func (st FeeSettleSorter) Len() int

func (FeeSettleSorter) Less

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

func (FeeSettleSorter) Swap

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

type Fund

type Fund struct {

func GetFund

func GetFund(db vm_db.VmDb, address types.Address) (fund *Fund, ok bool)

func GetUserFundsByPage

func GetUserFundsByPage(db abi.StorageDatabase, lastAddress types.Address, count int) (funds []*Fund, err error)

func (*Fund) DeSerialize

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

func (*Fund) Serialize

func (df *Fund) 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 GrantMarketToAgentEvent

type GrantMarketToAgentEvent struct {

func (GrantMarketToAgentEvent) FromBytes

func (gmta GrantMarketToAgentEvent) FromBytes(data []byte) interface{}

func (GrantMarketToAgentEvent) GetTopicId

func (gmta GrantMarketToAgentEvent) GetTopicId() types.Hash

type InviteRelationEvent

type InviteRelationEvent struct {

func (InviteRelationEvent) FromBytes

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

func (InviteRelationEvent) GetTopicId

func (ir InviteRelationEvent) GetTopicId() types.Hash

type MarketEvent

type MarketEvent struct {

func (MarketEvent) FromBytes

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

func (MarketEvent) GetTopicId

func (me MarketEvent) GetTopicId() types.Hash

type MarketInfo

type MarketInfo struct {

func CleanExpireOrders

func CleanExpireOrders(db vm_db.VmDb, orderIds []byte) (map[types.Address]map[bool]*dexproto.AccountSettle, *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 *ParamPlaceOrder, db vm_db.VmDb, accountAddress, agent *types.Address, sendHash types.Hash) (*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.FeeSettle

func (*Matcher) GetFundSettles

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

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 {

func (MinedVxForInviteeFeeEvent) FromBytes

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

func (MinedVxForInviteeFeeEvent) GetTopicId

func (mif MinedVxForInviteeFeeEvent) GetTopicId() types.Hash

type MinedVxForOperationEvent

type MinedVxForOperationEvent struct {

func (MinedVxForOperationEvent) FromBytes

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

func (MinedVxForOperationEvent) GetTopicId

func (mo MinedVxForOperationEvent) GetTopicId() types.Hash

type MinedVxForStakingEvent

type MinedVxForStakingEvent struct {

func (MinedVxForStakingEvent) FromBytes

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

func (MinedVxForStakingEvent) GetTopicId

func (mp MinedVxForStakingEvent) GetTopicId() types.Hash

type MinedVxForTradeFeeEvent

type MinedVxForTradeFeeEvent struct {

func (MinedVxForTradeFeeEvent) FromBytes

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

func (MinedVxForTradeFeeEvent) GetTopicId

func (mtf MinedVxForTradeFeeEvent) GetTopicId() types.Hash

type MiningStakings

type MiningStakings struct {

func GetDexMiningStakings

func GetDexMiningStakings(db vm_db.VmDb) (dexMiningStakings *MiningStakings, ok bool)

func GetMiningStakings

func GetMiningStakings(db vm_db.VmDb, address types.Address) (miningStakings *MiningStakings, ok bool)

func (*MiningStakings) DeSerialize

func (mss *MiningStakings) DeSerialize(data []byte) error

func (*MiningStakings) Serialize

func (mss *MiningStakings) Serialize() (data []byte, err error)

type NewOrderEvent

type NewOrderEvent struct {

func (NewOrderEvent) FromBytes

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

func (NewOrderEvent) GetTopicId

func (od NewOrderEvent) GetTopicId() types.Hash

type OperatorFeeDividendEvent

type OperatorFeeDividendEvent struct {

func (OperatorFeeDividendEvent) FromBytes

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

func (OperatorFeeDividendEvent) GetTopicId

func (bfd OperatorFeeDividendEvent) GetTopicId() types.Hash

type OperatorFeesByPeriod

type OperatorFeesByPeriod struct {

func GetCurrentOperatorFees

func GetCurrentOperatorFees(db vm_db.VmDb, reader util.ConsensusReader, operator []byte) (*OperatorFeesByPeriod, bool)

func GetOperatorFeesByPeriodId

func GetOperatorFeesByPeriodId(db vm_db.VmDb, operator []byte, periodId uint64) (*OperatorFeesByPeriod, bool)

func (*OperatorFeesByPeriod) DeSerialize

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

func (*OperatorFeesByPeriod) Serialize

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

type Order

type Order struct {

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 OrderTx

type OrderTx struct {
	// contains filtered or unexported fields

type OrderUpdateEvent

type OrderUpdateEvent struct {

func (OrderUpdateEvent) FromBytes

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

func (OrderUpdateEvent) GetTopicId

func (od OrderUpdateEvent) GetTopicId() types.Hash

type ParamCancelOrderByHash

type ParamCancelOrderByHash struct {
	SendHash   types.Hash
	Principal  types.Address
	TradeToken types.TokenTypeId
	QuoteToken types.TokenTypeId

type ParamCancelStakeById

type ParamCancelStakeById struct {
	Id types.Hash

type ParamCommonAdminConfig

type ParamCommonAdminConfig struct {
	OperationCode uint8             // 1 stableMarket
	TradeToken    types.TokenTypeId // 1 stableMarket
	QuoteToken    types.TokenTypeId // 1 stableMarket
	Enable        bool              // 1 stableMarket
	Value         int32
	Amount        *big.Int
	Address       types.Address

type ParamConfigMarketAgents

type ParamConfigMarketAgents struct {
	ActionType  uint8 // 1: grant 2: revoke
	Agent       types.Address
	TradeTokens []types.TokenTypeId
	QuoteTokens []types.TokenTypeId

type ParamDelegateStakeCallback

type ParamDelegateStakeCallback struct {
	StakeAddress types.Address
	Beneficiary  types.Address
	Amount       *big.Int
	Bid          uint8
	Success      bool

type ParamDelegateStakeCallbackV2

type ParamDelegateStakeCallbackV2 struct {
	Id      types.Hash
	Success bool

type ParamDexAdminConfig

type ParamDexAdminConfig struct {
	OperationCode    uint8
	Owner            types.Address // 1 owner
	TimeOracle       types.Address // 2 timeOracle
	PeriodJobTrigger types.Address // 4 periodJobTrigger
	StopDex          bool          // 8 stopDex
	MakerMiningAdmin types.Address // 16 maker mining admin
	Maintainer       types.Address // 32 maintainer

type ParamDexCancelOrder

type ParamDexCancelOrder struct {
	OrderId []byte

type ParamDexInnerCancelOrder

type ParamDexInnerCancelOrder struct {
	SendHash types.Hash
	Owner    types.Address

type ParamGetTokenInfoCallback

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

type ParamLockVxForDividend

type ParamLockVxForDividend struct {
	ActionType uint8 // 1: lockVx 2: unlockVx
	Amount     *big.Int

type ParamMarketAdminConfig

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

type ParamNotifyTime

type ParamNotifyTime struct {
	Timestamp int64

type ParamOpenNewMarket

type ParamOpenNewMarket struct {
	TradeToken types.TokenTypeId
	QuoteToken types.TokenTypeId

type ParamPlaceAgentOrder

type ParamPlaceAgentOrder struct {
	Principal types.Address

type ParamPlaceOrder

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

type ParamSerializedData

type ParamSerializedData struct {
	Data []byte

type ParamStakeForMining

type ParamStakeForMining struct {
	ActionType uint8 // 1: stake 2: cancel stake
	Amount     *big.Int

type ParamStakeForVIP

type ParamStakeForVIP struct {
	ActionType uint8 // 1: stake 2: cancel stake

type ParamSwitchConfig

type ParamSwitchConfig struct {
	SwitchType uint8 // 1: autoLockMinedVx
	Enable     bool

type ParamTradeAdminConfig

type ParamTradeAdminConfig struct {
	OperationCode               uint8
	TradeToken                  types.TokenTypeId // 1 mineMarket
	QuoteToken                  types.TokenTypeId // 1 mineMarket
	AllowMining                 bool              // 1 mineMarket
	NewQuoteToken               types.TokenTypeId // 2 new quote token
	QuoteTokenType              uint8             // 2 new quote token
	TokenTypeForTradeThreshold  uint8             // 4 tradeThreshold
	MinTradeThreshold           *big.Int          // 4 tradeThreshold
	TokenTypeForMiningThreshold uint8             // 8 miningThreshold
	MinMiningThreshold          *big.Int          // 8 miningThreshold

type ParamTransferTokenOwnership

type ParamTransferTokenOwnership struct {
	Token    types.TokenTypeId
	NewOwner types.Address

type ParamTriggerPeriodJob

type ParamTriggerPeriodJob struct {
	PeriodId uint64
	BizType  uint8

type ParamWithdraw

type ParamWithdraw struct {
	Token  types.TokenTypeId
	Amount *big.Int

type PendingNewMarkets

type PendingNewMarkets struct {

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 {

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 PendingTransferTokenOwnerActions

type PendingTransferTokenOwnerActions struct {

func GetPendingTransferTokenOwners

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

func (*PendingTransferTokenOwnerActions) DeSerialize

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

func (*PendingTransferTokenOwnerActions) Serialize

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

type PeriodJobWithBizEvent

type PeriodJobWithBizEvent struct {

func (PeriodJobWithBizEvent) FromBytes

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

func (PeriodJobWithBizEvent) GetTopicId

func (pb PeriodJobWithBizEvent) GetTopicId() types.Hash

type QuoteTokenTypeInfo

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

type RevokeMarketFromAgentEvent

type RevokeMarketFromAgentEvent struct {

func (RevokeMarketFromAgentEvent) FromBytes

func (rmfa RevokeMarketFromAgentEvent) FromBytes(data []byte) interface{}

func (RevokeMarketFromAgentEvent) GetTopicId

func (rmfa RevokeMarketFromAgentEvent) GetTopicId() types.Hash

type SerialNo

type SerialNo struct {

func (*SerialNo) DeSerialize

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

func (*SerialNo) Serialize

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

type SerializableDex

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

type SettleMakerMinedVxEvent

type SettleMakerMinedVxEvent struct {

func (SettleMakerMinedVxEvent) FromBytes

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

func (SettleMakerMinedVxEvent) GetTopicId

func (smmv SettleMakerMinedVxEvent) GetTopicId() types.Hash

type TokenEvent

type TokenEvent struct {

func (TokenEvent) FromBytes

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

func (TokenEvent) GetTopicId

func (te TokenEvent) GetTopicId() types.Hash

type TokenInfo

type TokenInfo struct {

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 {

func (TransactionEvent) FromBytes

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

func (TransactionEvent) GetTopicId

func (tx TransactionEvent) GetTopicId() types.Hash

type UserFees

type UserFees struct {

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 VIPStaking

type VIPStaking struct {

func GetSuperVIPStaking

func GetSuperVIPStaking(db vm_db.VmDb, address types.Address) (superVIPStaking *VIPStaking, ok bool)

func GetVIPStaking

func GetVIPStaking(db vm_db.VmDb, address types.Address) (vipStaking *VIPStaking, ok bool)

func (*VIPStaking) DeSerialize

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

func (*VIPStaking) Serialize

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

type VxFunds

type VxFunds struct {

func GetVxFunds

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

func GetVxFundsWithForkCheck

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

func GetVxLockedFunds

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

func GetVxLockedSumFunds

func GetVxLockedSumFunds(db vm_db.VmDb) (vxLockedSumFunds *VxFunds, ok bool)

func GetVxSumFunds

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

func GetVxSumFundsWithForkCheck

func GetVxSumFundsWithForkCheck(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)

type VxUnlocks

type VxUnlocks struct {

func GetVxUnlocks

func GetVxUnlocks(db vm_db.VmDb, address types.Address) (unlocks *VxUnlocks, ok bool)

func (*VxUnlocks) DeSerialize

func (vu *VxUnlocks) DeSerialize(data []byte) error

func (*VxUnlocks) Serialize

func (vu *VxUnlocks) Serialize() (data []byte, err error)


Path Synopsis

Jump to

Keyboard shortcuts

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