Documentation
¶
Index ¶
- Constants
- Variables
- func AddOneDay(day string) (string, error)
- func AddPrefix(value string) string
- func AppendToFile(filePath, content string) error
- func ContractStorageKey(name string) [32]byte
- func DistributeWithdrawalsProposalNodeKey(sender common.Address, ...) [32]byte
- func EpochAtTimestamp(config beacon.Eth2Config, time uint64) uint64
- func Err(c *gin.Context, status, msg string)
- func FloatToStr(f float64) string
- func GetApyFromStafiInfo(stafiInfoEndpoint string) (float64, error)
- func GetDropRate(startDayStr, nowDayStr string) (string, error)
- func GetDropRateFromTimestamp(startDay, stamp string) (string, error)
- func GetGaspriceFromEthgasstation() (base, priority uint64, err error)
- func GetNewDayUtc8Seconds() int64
- func GetNodeManagedEth(nodeDeposit, balance uint64, status uint8) uint64
- func GetNodeReward(balance, effectiveBalance, nodeDepositAmount uint64) 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 GetTotalReward(balance, withdrawal uint64) uint64
- func GetUserNodePlatformRewardV1(userDepositBalance uint64, rewardDeci decimal.Decimal) (decimal.Decimal, decimal.Decimal, decimal.Decimal)
- func GetUserNodePlatformRewardV2(nodeDepositAmount uint64, rewardDeci decimal.Decimal) (decimal.Decimal, decimal.Decimal, decimal.Decimal)
- func GetUserValPlatformDepositAndRewardV1(validatorBalance, nodeDepositAmount uint64, ...) (uint64, uint64, uint64, uint64, uint64)
- func GetYesterdayUTC8Date() string
- func IsImageExt(extName string) bool
- func MerkleTreeDealedEpochStorageKey() [32]byte
- 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 ProposalNokeKey(sender common.Address, proposalId [32]byte) [32]byte
- func ReadLastLine(filePath string) (string, error)
- func RemovePrefix(value string) string
- func SafeGo(x func())
- func SafeGoWithRestart(x func())
- func ShutdownListener() context.Context
- func Stack(skip int) []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 ToUpperList(list []string) []string
- func Uuid() string
- func VerifyProof(leafNode NodeHash, proof []NodeHash, root NodeHash) bool
- type CoinGeckeoPrice
- type MerkleTree
- type Node
- type NodeHash
- type NodeHashList
- type ResGasPrice
- type Rsp
- type RspApy
- type RspCoinGecko
- type RspCoinMarket
- type TokenInfo
Constants ¶
const ( ValidatorStatusDeposited = uint8(1) // lightnode + super node related ValidatorStatusWithdrawMatch = uint8(2) ValidatorStatusStaked = uint8(3) // lightnode related ValidatorStatusWithdrawUnmatch = uint8(4) 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 ( FeePool = uint8(1) SuperNodeFeePool = uint8(2) )
const ( V1 = "v1" V2 = "v2" Dev = "dev" )
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) SlashTypeSyncMiss = uint8(4) SlashTypeAttesterMiss = uint8(5) SlashTypeProposerMiss = uint8(6) )
const ( V1EndEpoch = uint64(148000) Eth1StartHeight = uint64(15572967) StandardEffectiveBalance = uint64(32e9) //gwei StandardSuperNodeFakeDepositBalance = uint64(1e9) //gwei StandardLightNodeDepositAmount = uint64(12e9) //gwei )
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 ( UnstakingStartTimestamp uint64 REthTotalApy float64 ValidatorAverageApr float64 )
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 ContractStorageKey ¶
func EpochAtTimestamp ¶
func EpochAtTimestamp(config beacon.Eth2Config, time uint64) uint64
Get an eth2 epoch number by time
func FloatToStr ¶
func GetApyFromStafiInfo ¶
func GetDropRate ¶
func GetNewDayUtc8Seconds ¶
func GetNewDayUtc8Seconds() int64
func GetNodeManagedEth ¶
func GetNodeReward ¶
func GetNowUTC8Date ¶
func GetNowUTC8Date() string
func GetSwapHash ¶
func GetTotalReward ¶
func GetUserNodePlatformRewardV1 ¶
func GetUserNodePlatformRewardV1(userDepositBalance uint64, rewardDeci decimal.Decimal) (decimal.Decimal, decimal.Decimal, decimal.Decimal)
return (user reward, node reward, paltform fee)
func GetUserNodePlatformRewardV2 ¶
func GetUserNodePlatformRewardV2(nodeDepositAmount uint64, rewardDeci decimal.Decimal) (decimal.Decimal, decimal.Decimal, decimal.Decimal)
todo split v1/v2 by height platform = 5% node = 5% + (90% * nodedeposit/32) rewardDeci decimals maybe 9/18, also the returns return (user reward, node reward, paltform fee)
func GetUserValPlatformDepositAndRewardV1 ¶
func GetUserValPlatformDepositAndRewardV1(validatorBalance, nodeDepositAmount uint64, platformFee, nodeFee decimal.Decimal) (uint64, uint64, uint64, uint64, uint64)
statistic use return (user deposit, user reward, val deposit, val reward, paltform fee)
func GetYesterdayUTC8Date ¶
func GetYesterdayUTC8Date() string
func IsImageExt ¶
func MerkleTreeDealedEpochStorageKey ¶
func MerkleTreeDealedEpochStorageKey() [32]byte
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 ToUpperList ¶
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 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 RspApy ¶
type RspApy struct {
Data struct {
TotalStakeValue float64 `json:"totalStakeValue"`
StakeValueList []struct {
StakeAmount string `json:"stakeAmount"`
StakeValue float64 `json:"stakeValue"`
StakeApy float64 `json:"stakeApy"`
MintApy float64 `json:"mintApy"`
TotalApy float64 `json:"totalApy"`
RTokenType int64 `json:"rTokenType"`
} `json:"stakeValueList"`
} `json:"data"`
Message string `json:"message"`
Status string `json:"status"`
}
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 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"`
}