model

package
v0.0.0-...-2b2340b Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatsLockCollection             = "stats_lock"
	OverallStatsCollection          = "overall_stats"
	FinalityProviderStatsCollection = "finality_providers_stats"
	StakerStatsCollection           = "staker_stats"
	DelegationCollection            = "delegations"
	TimeLockCollection              = "timelock_queue"
	UnbondingCollection             = "unbonding_queue"
	BtcInfoCollection               = "btc_info"
	UnprocessableMsgCollection      = "unprocessable_messages"
	DAppCollection                  = "dapps"
	GMPCollection                   = "gmps"
)
View Source
const LatestBtcInfoId = "latest"
View Source
const (
	UnbondingInitialState = "INSERTED"
)

Variables

This section is empty.

Functions

func BuildDelegationByStakerPaginationToken

func BuildDelegationByStakerPaginationToken(d DelegationDocument) (string, error)

func BuildFinalityProviderStatsPaginationToken

func BuildFinalityProviderStatsPaginationToken(d *FinalityProviderStatsDocument) (string, error)

func BuildStakerStatsByStakerPaginationToken

func BuildStakerStatsByStakerPaginationToken(d *StakerStatsDocument) (string, error)

func DecodePaginationToken

func DecodePaginationToken[T any](token string) (*T, error)

func GetPaginationToken

func GetPaginationToken[PaginationType any](d PaginationType) (string, error)

Types

type BtcInfo

type BtcInfo struct {
	ID             string `bson:"_id"`
	BtcHeight      uint64 `bson:"btc_height"`
	ConfirmedTvl   uint64 `bson:"confirmed_tvl"`
	UnconfirmedTvl uint64 `bson:"unconfirmed_tvl"`
}

type DAppDocument

type DAppDocument struct {
	ID                   string `bson:"_id,omitempty"`
	ChainName            string `bson:"chain_name"`
	BTCAddressHex        string `bson:"btc_address_hex"`
	PublicKeyHex         string `bson:"public_key_hex"`
	SmartContractAddress string `bson:"smart_contract_address"`
	State                bool   `bson:"state"`
	ChainID              string `bson:"chain_id"`
	ChainEndpoint        string `bson:"chain_endpoint"`
	RPCUrl               string `bson:"rpc_url"`
	AccessToken          string `bson:"access_token"`
	TokenContractAddress string `bson:"token_contract_address"`
}

type DelegationByStakerPagination

type DelegationByStakerPagination struct {
	StakingTxHashHex   string `json:"staking_tx_hash_hex"`
	StakingStartHeight uint64 `json:"staking_start_height"`
}

type DelegationDocument

type DelegationDocument struct {
	StakingTxHashHex      string                `bson:"_id"` // Primary key
	StakerPkHex           string                `bson:"staker_pk_hex"`
	FinalityProviderPkHex string                `bson:"finality_provider_pk_hex"`
	StakingValue          uint64                `bson:"staking_value"`
	State                 types.DelegationState `bson:"state"`
	StakingTx             *TimelockTransaction  `bson:"staking_tx"` // Always exist
	UnbondingTx           *TimelockTransaction  `bson:"unbonding_tx,omitempty"`
	IsOverflow            bool                  `bson:"is_overflow"`
	StakerBtcAddress      *StakerBtcAddress     `bson:"staker_btc_address,omitempty"`
}

type FinalityProviderStatsDocument

type FinalityProviderStatsDocument struct {
	FinalityProviderPkHex string `bson:"_id"` // FinalityProviderPkHex
	ActiveTvl             int64  `bson:"active_tvl"`
	TotalTvl              int64  `bson:"total_tvl"`
	ActiveDelegations     int64  `bson:"active_delegations"`
	TotalDelegations      int64  `bson:"total_delegations"`
}

type FinalityProviderStatsPagination

type FinalityProviderStatsPagination struct {
	FinalityProviderPkHex string `json:"finality_provider_pk_hex"`
	ActiveTvl             int64  `json:"active_tvl"`
}

type OverallStatsDocument

type OverallStatsDocument struct {
	Id                string `bson:"_id"`
	ActiveTvl         int64  `bson:"active_tvl"`
	TotalTvl          int64  `bson:"total_tvl"`
	ActiveDelegations int64  `bson:"active_delegations"`
	TotalDelegations  int64  `bson:"total_delegations"`
	TotalStakers      uint64 `bson:"total_stakers"`
}

type StakerBtcAddress

type StakerBtcAddress struct {
	TaprootAddress string `bson:"taproot_address"`
}

The available addresses that can be derived from the given StakerPkHex

type StakerStatsByStakerPagination

type StakerStatsByStakerPagination struct {
	StakerPkHex string `json:"staker_pk_hex"`
	ActiveTvl   int64  `json:"active_tvl"`
}

StakerStatsByStakerPagination is used to paginate the top stakers by active tvl ActiveTvl is used as the sorting key, whereas StakerPkHex is used as the secondary sorting key

type StakerStatsDocument

type StakerStatsDocument struct {
	StakerPkHex       string `bson:"_id"`
	ActiveTvl         int64  `bson:"active_tvl"`
	TotalTvl          int64  `bson:"total_tvl"`
	ActiveDelegations int64  `bson:"active_delegations"`
	TotalDelegations  int64  `bson:"total_delegations"`
}

type StatsLockDocument

type StatsLockDocument struct {
	Id                    string `bson:"_id"`
	OverallStats          bool   `bson:"overall_stats"`
	StakerStats           bool   `bson:"staker_stats"`
	FinalityProviderStats bool   `bson:"finality_provider_stats"`
}

StatsLockDocument represents the document in the stats lock collection It's used as a lock to prevent concurrent stats calculation for the same staking tx hash As well as to prevent the same staking tx hash + txType to be processed multiple times The already processed stats will be marked as true in the document

func NewStatsLockDocument

func NewStatsLockDocument(
	id string, overallStats, stakerStats, finalityProviderStats bool,
) *StatsLockDocument

type TimeLockDocument

type TimeLockDocument struct {
	StakingTxHashHex string `bson:"staking_tx_hash_hex"`
	ExpireHeight     uint64 `bson:"expire_height"`
	TxType           string `bson:"tx_type"`
}

func NewTimeLockDocument

func NewTimeLockDocument(stakingTxHashHex string, expireHeight uint64, txType string) *TimeLockDocument

type TimelockTransaction

type TimelockTransaction struct {
	TxHex          string `bson:"tx_hex"`
	OutputIndex    uint64 `bson:"output_index"`
	StartTimestamp int64  `bson:"start_timestamp"`
	StartHeight    uint64 `bson:"start_height"`
	TimeLock       uint64 `bson:"timelock"`
}

type UnbondingDocument

type UnbondingDocument struct {
	StakerPkHex        string `bson:"staker_pk_hex"`
	FinalityPkHex      string `bson:"finality_pk_hex"`
	UnbondingTxSigHex  string `bson:"unbonding_tx_sig_hex"`
	State              string `bson:"state"`
	UnbondingTxHashHex string `bson:"unbonding_tx_hash_hex"` // Unique Index
	UnbondingTxHex     string `bson:"unbonding_tx_hex"`
	StakingTxHex       string `bson:"staking_tx_hex"`
	StakingOutputIndex uint64 `bson:"staking_output_index"`
	StakingTimelock    uint64 `bson:"staking_timelock"`
	StakingAmount      uint64 `bson:"staking_amount"`
	StakingTxHashHex   string `json:"staking_tx_hash_hex"`
}

type UnprocessableMessageDocument

type UnprocessableMessageDocument struct {
	MessageBody string `bson:"message_body"`
	Receipt     string `bson:"receipt"`
}

func NewUnprocessableMessageDocument

func NewUnprocessableMessageDocument(messageBody, receipt string) *UnprocessableMessageDocument

Jump to

Keyboard shortcuts

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