Documentation ¶
Index ¶
- Constants
- Variables
- func AddOneDay(day string) (string, error)
- func AddPrefix(value string) string
- func AppendToFile(filePath, content string) error
- func BatchGetOperatorsOnChain(multicaller *multicall.Caller, ssvNetworkViewsContractAddress common.Address, ...) (map[uint64]*OperatorInfoOnChain, error)
- func Bytes1(val uint64) []byte
- func Bytes16(x uint64) []byte
- func Bytes2(val uint64) []byte
- func Bytes32(x uint64) []byte
- func Bytes4(x uint64) []byte
- func Bytes64(x uint64) []byte
- func Bytes8(x uint64) []byte
- func ContractStorageKey(name string) [32]byte
- func DistributeFeeProposalNodeKey(sender common.Address, ...) [32]byte
- func DistributeSuperNodeFeeProposalNodeKey(sender common.Address, ...) [32]byte
- func DistributeWithdrawalsProposalNodeKey(sender common.Address, ...) [32]byte
- func EndSlotOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
- func EpochAtTimestamp(config beacon.Eth2Config, time uint64) uint64
- func Err(c *gin.Context, status, msg string)
- func EventTopics(a abi.ABI, names ...string) ([]common.Hash, error)
- func FloatToStr(f float64) string
- func FromHexString(data string) ([]byte, error)
- func GetContractAddress(storage *storage.Storage, name string) (common.Address, error)
- func GetDropRate(startDayStr, nowDayStr string) (string, error)
- func GetDropRateFromTimestamp(startDay, stamp string) (string, error)
- func GetGaspriceFromBeacon() (base uint64, err error)
- func GetGaspriceFromEthgasstation() (base, priority uint64, err error)
- func GetNewDayUtc8Seconds() int64
- func GetNodeManagedEth(nodeDeposit, balance uint64, status uint8) uint64
- func GetNowUTC8Date() string
- func GetPriceFromCoinGecko(url string) (map[string]float64, error)
- func GetPriceFromCoinMarket(url string) (map[string]float64, error)
- func GetSwapHash(swapType, sender string, created int64) string
- func GetYesterdayUTC8Date() string
- func IsImageExt(extName string) bool
- func NodeSubmissionKey(sender common.Address, _block *big.Int, _totalEth *big.Int, ...) [32]byte
- func Ok(c *gin.Context, msg string, data interface{})
- func PriceSymbolValid(symbol string) bool
- func ReadLastLine(filePath string) (string, error)
- func RemovePrefix(value string) string
- func ReserveEthForWithdrawProposalId(cycle *big.Int) [32]byte
- func SafeGo(x func())
- func SafeGoWithRestart(x func())
- func ShutdownListener() context.Context
- func Stack(skip int) []byte
- func StafiDistributorProposalNodeKey(sender common.Address, proposalId [32]byte) [32]byte
- func StafiWithdrawProposalNodeKey(sender common.Address, proposalId [32]byte) [32]byte
- func StartSlotOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
- func StartTimestampOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
- func StrToFloat(str string) float64
- func StrToInt64(str string) (int64, error)
- func SubOneDay(day string) (string, error)
- func SymbolValid(symbol string) bool
- func TimestampOfSlot(config beacon.Eth2Config, slot uint64) uint64
- func ToBytes16(val []byte) [16]byte
- func ToBytes32(val []byte) [32]byte
- func ToBytes48(val []byte) [48]byte
- func ToBytes64(val []byte) [64]byte
- func ToBytes8(val []byte) [8]byte
- func ToBytes96(val []byte) [96]byte
- func ToUpperList(list []string) []string
- func UnpackEvent(a abi.ABI, v interface{}, name string, data []byte, topics []common.Hash) error
- func Uuid() string
- func VerifyProof(leafNode NodeHash, proof []NodeHash, root NodeHash) bool
- func WaitTxOkCommon(client *ethclient.Client, txHash common.Hash) (blockNumber uint64, err error)
- func XOR(data []byte) []byte
- type CoinGeckeoPrice
- type MerkleTree
- type Node
- type NodeHash
- type NodeHashList
- type OperatorFromApi
- type OperatorInfoOnChain
- type ResGasPrice
- type ResGasPriceFromBeacon
- type Rsp
- type RspCoinGecko
- type RspCoinMarket
- type RspError
- type RspSsvOperator
- type RspSsvOperators
- type TokenInfo
Constants ¶
const ( ValidatorStatusUnInitial = uint8(0) ValidatorStatusDeposited = uint8(1) // lightnode + super node related ValidatorStatusWithdrawMatch = uint8(2) ValidatorStatusStaked = uint8(3) ValidatorStatusWithdrawUnmatch = uint8(4) // lightnode related ValidatorStatusOffBoard = uint8(5) ValidatorStatusOffBoardCanWithdraw = uint8(6) ValidatorStatusOffBoardWithdrawed = uint8(7) // status on beacon chain ValidatorStatusWaiting = uint8(8) ValidatorStatusActive = uint8(9) ValidatorStatusExited = uint8(10) ValidatorStatusWithdrawable = uint8(11) ValidatorStatusWithdrawDone = uint8(12) // after distribute reward ValidatorStatusDistributed = uint8(13) // distribute full withdrawal // after slash ValidatorStatusActiveSlash = uint8(51) ValidatorStatusExitedSlash = uint8(52) ValidatorStatusWithdrawableSlash = uint8(53) ValidatorStatusWithdrawDoneSlash = uint8(54) ValidatorStatusDistributedSlash = uint8(55) // distribute full withdrawal )
1 deposited { 2 withdrawl match 3 staked 4 withdrawl unmatch } { 5 offboard 6 OffBoard can withdraw 7 OffBoard withdrawed } 8 waiting 9 active 10 exited 11 withdrawable 12 withdrawdone { 13 distributed } 51 active+slash 52 exit+slash 53 withdrawable+slash 54 withdrawdone+slash 55 distributed+slash
const ( NodeTypeCommon = uint8(1) NodeTypeTrust = uint8(2) NodeTypeLight = uint8(3) NodeTypeSuper = uint8(4) )
1 common node 2 trust node 3 light node 4 super node
const ( ValidatorEverSlashedFalse = uint8(0) ValidatorEverSlashedTrue = uint8(1) )
const ( FeePool = uint8(1) SuperNodeFeePool = uint8(2) )
const ( MetaTypeEth1BlockSyncer = uint8(1) // dealed block height MetaTypeEth2ValidatorInfoSyncer = uint8(2) // dealed epoch MetaTypeEth2ValidatorBalanceSyncer = uint8(3) // dealed epoch MetaTypeV1ValidatorSyncer = uint8(4) // dealed block height MetaTypeEth2BlockSyncer = uint8(5) // dealed epoch MetaTypeEth2NodeBalanceCollector = uint8(6) // dealed epoch )
const ( SlashTypeFeeRecipient = uint8(1) SlashTypeProposerSlash = uint8(2) SlashTypeAttesterSlash = uint8(3) SlashTypeNotExitSlash = uint8(7) // not show in front end SlashTypeSyncMiss = uint8(4) SlashTypeAttesterMiss = uint8(5) SlashTypeProposerMiss = uint8(6) )
const ( TheMergeEpoch = uint64(148000) TheMergeSlot = uint64(4736000) TheMergeBlockNumber = uint64(15572967) RewardV1EndEpoch = uint64(195975) //todo mainnet RewardEpochInterval = uint64(75) SlashStartEpoch = uint64(180000) //dev DevTheMergeEpoch = uint64(4400) DevTheMergeBlockNumber = uint64(133654) DevRewardV1EndEpoch = uint64(75) StandardEffectiveBalance = uint64(32e9) //gwei StandardSuperNodeFakeDepositBalance = uint64(1e9) //gwei OfficialSlashAmount = uint64(1e9) //gwei MaxPartialWithdrawalAmount = uint64(8e9) //gwei // node deposit amount(gwei) NodeDepositAmount0 = uint64(0) //gwei super NodeDepositAmount4 = uint64(4e9) //gwei solo 4 NodeDepositAmount8 = uint64(8e9) //gwei solo 8 NodeDepositAmount12 = uint64(12e9) //gwei solo 12 )
const ( NodeClaimTypeNone = uint8(0) NodeClaimTypeClaimReward = uint8(1) NodeClaimTypeClaimDeposit = uint8(2) NodeClaimTypeClaimTotal = uint8(3) )
enum ClaimType { None, CLAIMREWARD, CLAIMDEPOSIT, CLAIMTOTAL }
const ( StakerWithdrawalClaimableTimestamp = uint64(1) MinValidatorWithdrawabilityDelay = uint64(256 + 5) MaxDistributeWaitSeconds = uint64(8 * 60 * 60) MaxDistributeWaitEpoch = uint64(75) EjectorUptimeInterval = uint64(10 * 60) )
const ( MaxPageSize = 50 DefaultPageSize = 10 )
const ( CodeParamParseErr = "80001" CodeSymbolErr = "80002" CodeInternalErr = "80003" CodeParamErr = "80004" CodePriceEmptyErr = "80005" CodeAddressNotExist = "80005" CodeValidatorNotExist = "80006" CodeStakerUnstakingPlanExist = "80007" )
const ( RetryLimit = 200 RetryInterval = 6 * time.Second )
const ( SymbolDot = "DOT" SymbolKsm = "KSM" SymbolAtom = "ATOM" SymbolEth = "ETH" SymbolFis = "FIS" )
const DropRate10 = "10000000000000000000"
const DropRate4 = "4000000000000000000"
const DropRate7 = "7000000000000000000"
Variables ¶
var (
// dev use
OldRethSupply, _ = new(big.Int).SetString("25642334000000000000", 10)
GweiDeci = decimal.NewFromInt(1e9)
PlatformFeeV1Deci = decimal.NewFromFloat(0.1)
NodeFeeV1Deci = decimal.NewFromFloat(0.1)
Percent5Deci = decimal.NewFromFloat(0.05)
Percent90Deci = decimal.NewFromFloat(0.9)
)
var OneWeekSeconds = 7 * 24 * 60 * 60
var ShutdownRequestChannel = make(chan struct{})
shutdownRequestChannel is used to initiate shutdown from one of the subsystems using the same code paths as when an interrupt signal is received.
Functions ¶
func AppendToFile ¶
func BatchGetOperatorsOnChain ¶ added in v0.4.2
func Bytes1 ¶
Bytes1 returns the first byte of the little-endian representation of the supplied value.
func Bytes16 ¶
Bytes16 returns the first sixteen bytes of the little-endian representation of the supplied value.
func Bytes2 ¶
Bytes2 returns the first two bytes of the little-endian representation of the supplied value.
func Bytes32 ¶
Bytes32 returns the first thirty-two bytes of the little-endian representation of the supplied value.
func Bytes4 ¶
Bytes4 returns the first four bytes of the little-endian representation of the supplied value.
func Bytes64 ¶
Bytes64 returns the first thirty-two bytes of the little-endian representation of the supplied value.
func Bytes8 ¶
Bytes8 returns the first eight bytes of the little-endian representation of the supplied value.
func ContractStorageKey ¶
keccak256(abi.encodePacked("contract.address", _contractName))
func EndSlotOfEpoch ¶
func EndSlotOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
func EpochAtTimestamp ¶
func EpochAtTimestamp(config beacon.Eth2Config, time uint64) uint64
Get an eth2 epoch number by time
func EventTopics ¶ added in v0.2.0
func FloatToStr ¶
func FromHexString ¶
FromHexString returns a byte array given a hex string
func GetContractAddress ¶
func GetDropRate ¶
func GetGaspriceFromBeacon ¶
func GetNewDayUtc8Seconds ¶
func GetNewDayUtc8Seconds() int64
func GetNodeManagedEth ¶
func GetNowUTC8Date ¶
func GetNowUTC8Date() string
func GetSwapHash ¶
func GetYesterdayUTC8Date ¶
func GetYesterdayUTC8Date() string
func IsImageExt ¶
func NodeSubmissionKey ¶
func PriceSymbolValid ¶
func ReadLastLine ¶
func RemovePrefix ¶
Remove a prefix from a hex string if present
func SafeGoWithRestart ¶
func SafeGoWithRestart(x func())
func ShutdownListener ¶
shutdowntListener listens for OS Signals such as SIGINT (Ctrl+C) and shutdown requests from shutdownRequestChannel. It returns a context that is canceled when either signal is received.
func StartSlotOfEpoch ¶
func StartSlotOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
Get an eth2 first slot number by epoch
func StartTimestampOfEpoch ¶
func StartTimestampOfEpoch(config beacon.Eth2Config, epoch uint64) uint64
func StrToFloat ¶
func StrToInt64 ¶
func SymbolValid ¶
func TimestampOfSlot ¶
func TimestampOfSlot(config beacon.Eth2Config, slot uint64) uint64
func ToBytes16 ¶
ToBytes16 returns a 16-byte array with the supplied value placed in the low-order indices.
func ToBytes32 ¶
ToBytes32 returns a 32-byte array with the supplied value placed in the low-order indices.
func ToBytes48 ¶
ToBytes48 returns a 48-byte array with the supplied value placed in the low-order indices.
func ToBytes64 ¶
ToBytes64 returns a 64-byte array with the supplied value placed in the low-order indices.
func ToBytes8 ¶
ToBytes8 returns an 8-byte array with the supplied value placed in the low-order indices.
func ToBytes96 ¶
ToBytes96 returns a 96-byte array with the supplied value placed in the low-order indices.
func ToUpperList ¶
func UnpackEvent ¶ added in v0.2.0
func WaitTxOkCommon ¶
Types ¶
type CoinGeckeoPrice ¶
type CoinGeckeoPrice struct {
Usd float64 `json:"usd"`
}
type MerkleTree ¶
type MerkleTree struct {
// contains filtered or unexported fields
}
leafNodes on layers[0], rootNode on layers[len(layers)-1]
func NewMerkleTree ¶
func NewMerkleTree(nodeHashList NodeHashList) *MerkleTree
func (*MerkleTree) GetLayers ¶
func (m *MerkleTree) GetLayers() [][]*Node
func (*MerkleTree) GetProof ¶
func (m *MerkleTree) GetProof(leafNodeHash NodeHash) ([]NodeHash, error)
func (*MerkleTree) GetRootHash ¶
func (m *MerkleTree) GetRootHash() (hash NodeHash, err error)
type NodeHash ¶
type NodeHash []byte
func ConbinedHash ¶
func GetNodeHash ¶
func NodeHashFromHexString ¶
type NodeHashList ¶
type NodeHashList []NodeHash
func (NodeHashList) Len ¶
func (nodeHashList NodeHashList) Len() int
func (NodeHashList) Less ¶
func (nodeHashList NodeHashList) Less(i, j int) bool
func (NodeHashList) Swap ¶
func (nodeHashList NodeHashList) Swap(i, j int)
type OperatorFromApi ¶ added in v0.4.2
type OperatorFromApi struct { ID int `json:"id"` IDStr string `json:"id_str"` DeclaredFee string `json:"declared_fee"` PreviousFee string `json:"previous_fee"` Fee string `json:"fee"` PublicKey string `json:"public_key"` OwnerAddress string `json:"owner_address"` Location string `json:"location"` SetupProvider string `json:"setup_provider"` Eth1NodeClient string `json:"eth1_node_client"` Eth2NodeClient string `json:"eth2_node_client"` Description string `json:"description"` WebsiteURL string `json:"website_url"` TwitterURL string `json:"twitter_url"` LinkedinURL string `json:"linkedin_url"` Logo string `json:"logo"` Type string `json:"type"` Name string `json:"name"` Performance struct { Two4H float64 `json:"24h"` Three0D float64 `json:"30d"` } `json:"performance"` IsValid bool `json:"is_valid"` IsDeleted bool `json:"is_deleted"` IsActive int `json:"is_active"` Status string `json:"status"` ValidatorsCount int `json:"validators_count"` Version string `json:"version"` Network string `json:"network"` MevRelays string `json:"mev_relays,omitempty"` DkgAddress string `json:"dkg_address,omitempty"` AddressWhitelist string `json:"address_whitelist,omitempty"` }
func GetAllSsvOperatorsFromApi ¶ added in v0.4.2
func GetAllSsvOperatorsFromApi(network string) ([]OperatorFromApi, error)
func GetOperatorFromApi ¶ added in v0.4.2
func GetOperatorFromApi(network string, id uint64) (*OperatorFromApi, error)
func MustGetOperatorDetail ¶ added in v0.4.3
func MustGetOperatorDetail(network string, id uint64) (*OperatorFromApi, error)
type OperatorInfoOnChain ¶ added in v0.4.2
type ResGasPrice ¶
type ResGasPrice struct { BaseFee int `json:"baseFee"` BlockNumber int `json:"blockNumber"` BlockTime float64 `json:"blockTime"` GasPrice struct { Fast int `json:"fast"` Instant int `json:"instant"` Standard int `json:"standard"` } `json:"gasPrice"` NextBaseFee int `json:"nextBaseFee"` PriorityFee struct { Fast int `json:"fast"` Instant int `json:"instant"` Standard int `json:"standard"` } `json:"priorityFee"` }
type ResGasPriceFromBeacon ¶
type RspCoinGecko ¶
type RspCoinGecko map[string]CoinGeckeoPrice
type RspCoinMarket ¶
type RspCoinMarket struct { Status struct { Timestamp time.Time `json:"timestamp"` ErrorCode int `json:"error_code"` ErrorMessage interface{} `json:"error_message"` Elapsed int `json:"elapsed"` CreditCount int `json:"credit_count"` Notice interface{} `json:"notice"` } `json:"status"` Data map[string]TokenInfo `json:"data"` }
type RspSsvOperator ¶ added in v0.4.2
type RspSsvOperator struct { OperatorFromApi Error RspError `json:"error"` }
type RspSsvOperators ¶ added in v0.4.2
type TokenInfo ¶
type TokenInfo struct { ID int `json:"id"` Name string `json:"name"` Symbol string `json:"symbol"` Slug string `json:"slug"` NumMarketPairs int `json:"num_market_pairs"` DateAdded time.Time `json:"date_added"` Tags []string `json:"tags"` MaxSupply interface{} `json:"max_supply"` CirculatingSupply float64 `json:"circulating_supply"` TotalSupply float64 `json:"total_supply"` IsActive int `json:"is_active"` IsMarketCapIncludedInCalc int `json:"is_market_cap_included_in_calc"` Platform interface{} `json:"platform"` CmcRank int `json:"cmc_rank"` IsFiat int `json:"is_fiat"` LastUpdated time.Time `json:"last_updated"` Quote struct { USD struct { Price float64 `json:"price"` Volume24H float64 `json:"volume_24h"` PercentChange1H float64 `json:"percent_change_1h"` PercentChange24H float64 `json:"percent_change_24h"` PercentChange7D float64 `json:"percent_change_7d"` PercentChange30D float64 `json:"percent_change_30d"` PercentChange60D float64 `json:"percent_change_60d"` PercentChange90D float64 `json:"percent_change_90d"` MarketCap float64 `json:"market_cap"` LastUpdated time.Time `json:"last_updated"` } `json:"USD"` } `json:"quote"` }