staking_service

package
v0.0.0-...-a8bb530 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AddDepositAddressRequest

type AddDepositAddressRequest struct {
	DepositAddresses []string `json:"deposit_addresses"`
}

type Assignment

type Assignment struct {
	UID            string `json:"uid"`
	ValidatorCount int    `json:"validatorCount"`
}

type BatchValidatorAssignmentParams

type BatchValidatorAssignmentParams struct {
	Assignments []Assignment `json:"assignments"`
	TxHashs     []string     `json:"tx_hashs"`
}

type BroadcastBabylonStakingTxResp

type BroadcastBabylonStakingTxResp struct {
	TxHex string `json:"txHex"`
}

type CreateUserParams

type CreateUserParams struct {
	UID              string   `json:"uid"`
	DepositAddresses []string `json:"depositAddresses"`
}

type DelegateTransaction

type DelegateTransaction struct {
	ChainName   string  `json:"chainName"`
	ValidatorID string  `json:"validatorID"`
	DelegatorID string  `json:"delegatorID"`
	Amount      float64 `json:"amount"`
	// 交易中的operationType在数据库中存为数字,1为Delegate,2为Undelegate,3为Claim Reward,注意在任何场景中,给用户打钱的交易都记为Claim,即假如取款不分两部,则取款交易记为3
	OperationType       string `json:"operationType"`
	OperationTypeOrigin int    `json:"operationTypeOrigin"`
	Block               string `json:"block"` // 在aptos中block和txHash都是version
	TxHash              string `json:"txHash"`
	TxTime              int64  `json:"txTime"`
}

type DelegateTransactionList

type DelegateTransactionList []DelegateTransaction

type DelegatedValidator

type DelegatedValidator struct {
	ChainName       string `json:"chainName"`
	ValidatorID     string `json:"validatorID"`
	Commission      uint   `json:"commission"`
	Principal       string `json:"principal"`
	SelfPrincipal   string `json:"selfPrincipal"`
	Status          string `json:"status"`
	StatusOrigin    int    `json:"statusOrigin"`
	APR             int64  `json:"apr"`
	AppearTime      uint64 `json:"appearTime"`
	DelegatorNum    int64  `json:"delegatorNum"`
	MaxDelegatorNum int64  `json:"maxDelegatorNum"`
	Extra           string `json:"extra"`
}

type DelegatedValidatorList

type DelegatedValidatorList []DelegatedValidator

type DelegatedValidatorReward

type DelegatedValidatorReward struct {
	ChainName   string `json:"chainName"`
	ValidatorID string `json:"validatorID"`
	// Identifier为收益周期,即如果是每个Epoch统计收益即为Epoch,如果是某个BlockHeight分发收益则记录BlockHeight,如果是按时间周期,则记录时间或者日期。
	Identifier string `json:"identifier"`
	// 确定的Block Height或者收益周期的block起始值,用逗号分隔
	Block      string  `json:"block"`
	Amount     float64 `json:"amount"`
	RewardTime uint64  `json:"rewardTime"`
	Principal  float64 `json:"principal"`
	Commission uint    `json:"commission"` // Commission Rate, 统一为 百分比 * 100,例如: 12.34% 为 1234
}

type DelegatedValidatorRewardList

type DelegatedValidatorRewardList []DelegatedValidatorReward

type Delegator

type Delegator struct {
	ChainName   string `json:"chainName"`
	ValidatorID string `json:"validatorID"`
	DelegatorID string `json:"delegatorID"`
	Principal   string `json:"principal"`
	Extra       string `json:"extra"`
}

type DelegatorOverview

type DelegatorOverview struct {
	StakedAmount                  float64 `json:"stakedAmount"`
	UnlockAmount                  float64 `json:"unlockAmount"`
	PendingAmount                 float64 `json:"pendingAmount"`
	ReadyToClaim                  float64 `json:"readyToClaim"`
	HistoricalRewardsForDelegator float64 `json:"historicalRewardsForDelegator"`
	HistoricalClaimedRewards      float64 `json:"historicalClaimedRewards"`
	HistoricalRewardsForValidator float64 `json:"historicalRewardsForValidator"`
	HistoricalReferralCommission  float64 `json:"historicalReferralCommission"`
	SettledReferralCommission     float64 `json:"settledReferralCommission"`
	UnsettledReferralCommission   float64 `json:"unsettledReferralCommission"`
}

type DelegatorReward

type DelegatorReward struct {
	DelegatedValidatorReward
	DelegatorID string `json:"delegatorID"`
}

type DelegatorRewardList

type DelegatorRewardList []DelegatorReward

type Deposit

type Deposit struct {
	ID              uint64 `json:"id"`
	BrokerID        uint64 `json:"brokerId"`
	FromAddress     string `json:"fromAddress"`
	ContractAddress string `json:"contractAddress"`
	TxHash          string `json:"txHash"`
	ChainName       string `json:"chainName"`
	BlockHeight     uint64 `json:"blockHeight"`
	Slot            uint64 `json:"slot"`
	BlockTime       uint64 `json:"blockTime"`
}

type DepositDataInfo

type DepositDataInfo struct {
	DepositDataRoot      string `json:"depositDataRoot"`
	Pubkey               string `json:"pubkey"`
	Signature            string `json:"signature"`
	WithdrawalCredential string `json:"withdrawalCredential"`
}

type DepositDataRequestParams

type DepositDataRequestParams struct {
	Uid               string `json:"uid"`
	Quantity          int64  `json:"quantity"`
	WithdrawalAddress string `json:"withdrawalAddress"`
}

type DepositDataResponse

type DepositDataResponse struct {
	Network  string            `json:"network"`
	Protocol string            `json:"protocol"`
	Period   string            `json:"period"`
	Ethereum *EthereumResponse `json:"ethereum"`
}

type DepositDetails

type DepositDetails struct {
	Deposit
	Validators ValidatorDetailList `json:"validators"`
}

type EthereumResponse

type EthereumResponse struct {
	ContractAddress     string             `json:"contractAddress"`
	EstimatedGas        uint64             `json:"estimatedGas"`
	UnsignedTransaction string             `json:"unsignedTransaction"`
	DepositData         []*DepositDataInfo `json:"depositData"`
}

type GenerateBroadcastStakingRequestParams

type GenerateBroadcastStakingRequestParams struct {
	StakingTransactionHex string `json:"stakingTransactionHex"`
	RequestID             string `json:"requestId"`
}

type GenerateStakingRequestParams

type GenerateStakingRequestParams struct {
	StakerPublicKeyHex string `json:"stakerPublicKeyHex"`
	StakingAmount      int64  `json:"stakingAmount"`
	StakingTimeBlocks  int64  `json:"stakingTimeBlocks"`
	TxInclusionHeight  uint64 `json:"txInclusionHeight"`
}

type GenerateStakingRequestResp

type GenerateStakingRequestResp struct {
	StakingTxHex string `json:"staking_tx_hex"`
	RequestID    string `json:"request_id"`
}

type ListDelegatesParams

type ListDelegatesParams struct {
	PageParams
	OperationType int `json:"operationType"`
}

type PageParams

type PageParams struct {
	PageNum  int `json:"pageNum" form:"pageNum"`
	PageSize int `json:"pageSize" form:"pageSize"`
}

type PageResult

type PageResult[T any] struct {
	PageNum  int   `json:"pageNum"`
	PageSize int   `json:"pageSize"`
	Total    int64 `json:"total"`
	List     []T   `json:"list"`
}

type PoolRewardInfo

type PoolRewardInfo struct {
	AvgYearApr       string `json:"avg_year_apr"`
	BeginSlot        int    `json:"begin_slot"`
	CumulativeReward string `json:"cumulative_reward"`
	DailyReward      string `json:"daily_reward"`
	Date             string `json:"date"`
	EndSlot          int    `json:"end_slot"`
}

type PoolRewardInfoList

type PoolRewardInfoList []PoolRewardInfo

type PooledStakingInfo

type PooledStakingInfo struct {
	Amount           string `json:"amount"`
	CumulativeReward string `json:"cumulative_reward"`
	Point            string `json:"point"`
	UserAddress      string `json:"user_address"`
}

type PooledStakingInfoList

type PooledStakingInfoList []PooledStakingInfo

type PooledWithdrawRequestInfo

type PooledWithdrawRequestInfo struct {
	RequestID      int    `json:"request_id"`
	User           string `json:"user"`
	Point          string `json:"point"`
	Amount         string `json:"amount"`
	Principal      string `json:"principal"`
	WithdrawTxhash string `json:"withdraw_txhash"`
	Description    string `json:"description"`
}

type Response

type Response[T any] struct {
	Code uint   `json:"code"`
	Msg  string `json:"msg"`
	Data T      `json:"data"`
}

type Reward

type Reward struct {
	Date              string `json:"date"`
	TotalCount        int64  `json:"totalCount"`
	ActiveCount       int64  `json:"activeCount"`
	ExitCount         int64  `json:"exitCount"`
	Balance           string `json:"balance"`
	Principal         string `json:"principal"`
	Apr               string `json:"apr"`
	CumulativeRewards string `json:"cumulativeRewards"`
	CumulativeStaking string `json:"cumulativeStaking"`
	CumulativeGasFee  string `json:"cumulativeGasFee"`
	Rewards           string `json:"rewards"`
	Staking           string `json:"staking"`
	GasFee            string `json:"gasFee"`
	Withdrawal        string `json:"withdrawal"`
	Rate              string `json:"rate"`
}

type RewardList

type RewardList []Reward

type SendTransactionRequestParams

type SendTransactionRequestParams struct {
	SignedTransaction string `json:"signedTransaction"`
}

type SendTransactionResponse

type SendTransactionResponse struct {
	TxHash string `json:"txHash"`
}

type StakingService

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

func NewStakingService

func NewStakingService(baseURL, privateKey, address string) (*StakingService, error)

func (*StakingService) AddDepositAddress

func (stakingService *StakingService) AddDepositAddress(uid string, depositaddresses []string) (result *string, code uint, msg string, err error)

func (*StakingService) AnnuallyRewards

func (stakingService *StakingService) AnnuallyRewards(uid string, startTime int64, endTime int64) (result *RewardList, code uint, msg string, err error)

func (*StakingService) AssignDepositedValidators

func (stakingService *StakingService) AssignDepositedValidators(txHash string, validatorAssignmentParams ValidatorAssignmentParams) (result *[]UserValidators, code uint, msg string, err error)

func (*StakingService) BatchAssignDepositedValidators

func (stakingService *StakingService) BatchAssignDepositedValidators(batchValidatorAssignmentParams BatchValidatorAssignmentParams) (result *[]UserValidators, code uint, msg string, err error)

func (*StakingService) CreateUser

func (stakingService *StakingService) CreateUser(uid string, depositaddresses []string) (result *User, code uint, msg string, err error)

func (*StakingService) DailyRewards

func (stakingService *StakingService) DailyRewards(uid string, startTime int64, endTime int64) (result *RewardList, code uint, msg string, err error)

func (*StakingService) DeleteUser

func (stakingService *StakingService) DeleteUser(uid string) (result *string, code uint, msg string, err error)

func (*StakingService) DepositData

func (stakingService *StakingService) DepositData(depositDataRequestParams DepositDataRequestParams) (result *DepositDataResponse, code uint, msg string, err error)

func (*StakingService) GenerateBroadcastStakingRequest

func (stakingService *StakingService) GenerateBroadcastStakingRequest(params GenerateBroadcastStakingRequestParams) (result *BroadcastBabylonStakingTxResp, code uint, msg string, err error)

func (*StakingService) GenerateStakingRequest

func (stakingService *StakingService) GenerateStakingRequest(params GenerateStakingRequestParams) (result *GenerateStakingRequestResp, code uint, msg string, err error)

func (*StakingService) GetDelegatedValidatorInfo

func (stakingService *StakingService) GetDelegatedValidatorInfo(chainName, validatorID string) (result *DelegatedValidator, code uint, msg string, err error)

func (*StakingService) GetDelegatorInfo

func (stakingService *StakingService) GetDelegatorInfo(chainName, validatorID, delegatorID string) (result *Delegator, code uint, msg string, err error)

func (*StakingService) GetDelegatorOverview

func (stakingService *StakingService) GetDelegatorOverview(chainName, validatorID, delegatorID string) (result *DelegatorOverview, code uint, msg string, err error)

func (*StakingService) GetDepositDetails

func (stakingService *StakingService) GetDepositDetails(txHash string) (result *DepositDetails, code uint, msg string, err error)

func (*StakingService) GetPoolRewards

func (stakingService *StakingService) GetPoolRewards(date *string, limit *uint) (result *PoolRewardInfoList, code uint, msg string, err error)

func (*StakingService) GetPooledStakingInfo

func (stakingService *StakingService) GetPooledStakingInfo() (result *PooledStakingInfoList, code uint, msg string, err error)

func (*StakingService) GetTransactionHistory

func (stakingService *StakingService) GetTransactionHistory(userAddress string, txType, pageNum, pageSize int64) (result *PageResult[TransactionList], code uint, msg string, err error)

func (*StakingService) GetUnusedKeys

func (stakingService *StakingService) GetUnusedKeys() (result *uint64, code uint, msg string, err error)

func (*StakingService) GetUserDetails

func (stakingService *StakingService) GetUserDetails(uid string) (result *UserDetails, code uint, msg string, err error)

func (*StakingService) GetUserPooledStakingInfo

func (stakingService *StakingService) GetUserPooledStakingInfo(address string) (result *UserPooledStakingInfo, code uint, msg string, err error)

func (*StakingService) GetUserWithdrawPossible

func (stakingService *StakingService) GetUserWithdrawPossible(userAddress string) (result *WithdrawPossibleBlock, code uint, msg string, err error)

func (*StakingService) GetWithdrawRequestInfo

func (stakingService *StakingService) GetWithdrawRequestInfo(requestID uint64) (result *PooledWithdrawRequestInfo, code uint, msg string, err error)

func (*StakingService) ListDelegatedValidators

func (stakingService *StakingService) ListDelegatedValidators(chainName string) (result *DelegatedValidatorList, code uint, msg string, err error)

func (*StakingService) ListDelegatesForDelegator

func (stakingService *StakingService) ListDelegatesForDelegator(chainName, validatorID, delegatorID string, params ListDelegatesParams) (result *PageResult[DelegateTransaction], code uint, msg string, err error)

func (*StakingService) ListDelegatesForValidator

func (stakingService *StakingService) ListDelegatesForValidator(chainName, validatorID string, params ListDelegatesParams) (result *PageResult[DelegateTransaction], code uint, msg string, err error)

ListDelegatesForValidator 方法用于获取某个验证者的所有委托记录

func (*StakingService) ListDelegators

func (stakingService *StakingService) ListDelegators(chainName, validatorID string) (result *[]Delegator, code uint, msg string, err error)

func (*StakingService) ListDeposits

func (stakingService *StakingService) ListDeposits(pageNum, pageSize uint) (result *PageResult[Deposit], code uint, msg string, err error)

func (*StakingService) ListRewardsForDelegator

func (stakingService *StakingService) ListRewardsForDelegator(chainName, validatorID, delegatorID string, pageParams PageParams) (result *PageResult[DelegatorReward], code uint, msg string, err error)

func (*StakingService) ListRewardsForValidator

func (stakingService *StakingService) ListRewardsForValidator(chainName, validatorID string, pageParams PageParams) (result *PageResult[DelegatedValidatorReward], code uint, msg string, err error)

func (*StakingService) ListUsers

func (stakingService *StakingService) ListUsers(pageNum, pageSize uint) (result *PageResult[User], code uint, msg string, err error)

func (*StakingService) ManualDepositBroker

func (stakingService *StakingService) ManualDepositBroker(txHash string) (result *string, code uint, msg string, err error)

func (*StakingService) ManualDepositBrokerUser

func (stakingService *StakingService) ManualDepositBrokerUser(txHash string) (result *string, code uint, msg string, err error)

func (*StakingService) MonthlyRewards

func (stakingService *StakingService) MonthlyRewards(uid string, startTime int64, endTime int64) (result *RewardList, code uint, msg string, err error)

func (*StakingService) QuarterlyRewards

func (stakingService *StakingService) QuarterlyRewards(uid string, startTime int64, endTime int64) (result *RewardList, code uint, msg string, err error)

func (*StakingService) SendTransaction

func (stakingService *StakingService) SendTransaction(sendTransactionRequestParams SendTransactionRequestParams) (result *SendTransactionResponse, code uint, msg string, err error)

func (*StakingService) ValidatorExit

func (stakingService *StakingService) ValidatorExit(pubkey string, validatorExitParam ValidatorExitParam) (result *ValidatorExitRes, code uint, msg string, err error)

func (*StakingService) ValidatorList

func (stakingService *StakingService) ValidatorList(validatorListRequestParam ValidatorListRequestParam) (result *PageResult[ValidatorDetail], code uint, msg string, err error)

type TransactionInfo

type TransactionInfo struct {
	Amount         float32 `json:"amount"`
	Type           uint64  `json:"type"`
	TxTime         uint64  `json:"txTime"`
	Status         string  `json:"status"`
	TxHash         string  `json:"txHash"`
	WithdrawalHash string  `json:"withdrawalHash"`
}

type TransactionList

type TransactionList []*TransactionInfo

type User

type User struct {
	ID       uint64 `json:"id"`
	BrokerID uint64 `json:"brokerID"`
	UID      string `json:"uid"`
}

type UserDetails

type UserDetails struct {
	User
	DepositAddresses []string            `json:"depositAddresses"`
	Validators       ValidatorDetailList `json:"validators"`
}

type UserPooledStakingInfo

type UserPooledStakingInfo struct {
	DepositedEth string `json:"deposited_eth"`
	TotalEth     string `json:"total_eth"`
}

type UserValidators

type UserValidators struct {
	UID        string        `json:"uid"`
	Validators ValidatorList `json:"validators"`
}

type Validator

type Validator struct {
	UID            string `json:"uid"`
	ValidatorIndex uint64 `json:"validatorIndex"`
	Pubkey         string `json:"pubkey"`
}

type ValidatorAssignmentParams

type ValidatorAssignmentParams struct {
	Assignments []Assignment `json:"assignments"`
}

type ValidatorDetail

type ValidatorDetail struct {
	Validator
	Balance        string `json:"balance"`
	TotalRewards   string `json:"totalRewards"`
	Status         string `json:"status"`
	ActivationTime string `json:"ActivationTime"`
	ExitTime       string `json:"exitTime"`
	Principal      string `json:"principal"`
}

type ValidatorDetailList

type ValidatorDetailList []ValidatorDetail

type ValidatorExitParam

type ValidatorExitParam struct {
	Epoch     uint64 `json:"epoch"`
	Broadcast uint64 `json:"broadcast"`
}

type ValidatorExitRes

type ValidatorExitRes struct {
	Signature string `json:"signature"`
}

type ValidatorList

type ValidatorList []Validator

type ValidatorListRequestParam

type ValidatorListRequestParam struct {
	Uid string `form:"uid"`
	PageParams
}

type WithdrawPossibleBlock

type WithdrawPossibleBlock struct {
	CanWithdrawBlock string `json:"can_withdraw_block"`
}

Jump to

Keyboard shortcuts

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