Documentation ¶
Overview ¶
Depth recorder fills keeps track of historical depth values and inserts changes in the block_pool_depths table.
Index ¶
- Constants
- Variables
- func ActiveAndStandbyBondMetrics(active, standby sortedBonds, minimumEligibleBond int64) *bondMetricsInts
- func ActiveNetworkVersion(ctx context.Context) (string, error)
- func ActiveNodeCount(ctx context.Context, moment db.Nano) (int64, error)
- func AssetAndRuneDepths() (assetE8PerPool, runeE8PerPool map[string]int64, timestamp time.Time)
- func AssetPrice(assetDepth, runeDepth int64) float64
- func CalculateAPYInterest(periodicRate float64, periodsPerYear float64) float64
- func CalculateSynthUnits(assetDepth, synthDepth, liquidityUnits int64) int64
- func GetActions(ctx context.Context, moment time.Time, params ActionsParams) (oapigen.ActionsResponse, error)
- func GetAllLastConstantValue(ctx context.Context) (map[string]int64, error)
- func GetBalances(ctx context.Context, address string, height string, timestamp string) (oapigen.BalanceResponse, miderr.Err)
- func GetBorrowerIds(ctx context.Context, asset *string) (addrs []string, err error)
- func GetChurnsData(ctx context.Context) (oapigen.Churns, error)
- func GetLastConstantValue(ctx context.Context, key string) (int64, error)
- func GetLendingData(ctx context.Context) (map[string]LendingInfo, error)
- func GetMemberIds(ctx context.Context, pool *string) (addrs []string, err error)
- func GetNetworkData(ctx context.Context) (oapigen.Network, error)
- func GetPoolsStatuses(ctx context.Context, moment db.Nano) (map[string]string, error)
- func GetTHORNamesByAddress(ctx context.Context, addr string) (names []string, err error)
- func GetTHORNamesByOwnerAddress(ctx context.Context, addr string) (names []string, err error)
- func GetTopSwaps(ctx context.Context) (oapigen.ActionsResponse, error)
- func LastBlock() (height int64, timestamp time.Time, hash []byte)
- func LastChurnHeight(ctx context.Context) (int64, error)
- func NodesSecpAndEd(ctx context.Context, t time.Time) (secp256k1Addrs, ed25519Addrs map[string]string, err error)
- func PoolBasedOfType(poolName string, poolType MemberPoolType) bool
- func PoolExists(pool string) bool
- func PoolExistsNow(pool string) bool
- func PoolStatus(ctx context.Context, pool string) (string, error)
- func PoolsWithDeposit(ctx context.Context) ([]string, error)
- func ProcessBlock(block *chain.Block, commit bool) (err error)
- func QueryOneValue(dest interface{}, ctx context.Context, query string, args ...interface{}) error
- func ResetDepthManagerForTest()
- func ResetLatestStateForTest()
- func SetDepthsForTest(depths []Depth)
- func SetLastHeightForTest(height int64)
- func SetLastTimeForTest(timestamp db.Second)
- func Setup() error
- func StatusPerNode(ctx context.Context, moment time.Time) (map[string]string, error)
- func TotalLiquidityFeesRune(ctx context.Context, from time.Time, to time.Time) (int64, error)
- func TotalLiquidityFeesRuneAtBlock(ctx context.Context, timestamp time.Time) (int64, error)
- type ActionsParams
- type BlockState
- type Borrower
- type Borrowers
- type Depth
- type DepthMap
- type LatestState
- type LendingInfo
- type MemberPool
- type MemberPoolType
- type MemberPools
- type PoolDepths
- type THORName
- type THORNameEntry
Constants ¶
const DefaultLimit = 50
const DefaultPoolStatus = "staged"
const OutboundTimeout = time.Hour * 48
OutboundTimeout is an upperboundary for the amount of time for a followup on outbound events.
const WeeksInYear = 52
Variables ¶
var NetworkNilNode = metrics.MustCounter(
"midgard_network_nil_node",
"Number of times thornode returned nil node in thorchain/nodes.")
var RewardEntriesAggregate = db.RegisterAggregate( db.NewAggregate("rewards_event_entries", "rewards_event_entries"). AddGroupColumn("pool"). AddBigintSumColumn("rune_e8"). AddBigintSumColumn("saver_e8"))
Functions ¶
func ActiveAndStandbyBondMetrics ¶
func ActiveAndStandbyBondMetrics(active, standby sortedBonds, minimumEligibleBond int64) *bondMetricsInts
func ActiveNodeCount ¶
Returns Active node count for a given Unix Nano timestamp
func AssetAndRuneDepths ¶
Deprecated, use timeseries.Latest.GetState().PoolInfo(poolname) instead
func AssetPrice ¶
func CalculateAPYInterest ¶
func CalculateSynthUnits ¶
CalculateSynthUnits calculate dynamic synth units (L*S)/(2*A-S) L = LP units S = synth balance A = asset balance
func GetActions ¶
func GetActions(ctx context.Context, moment time.Time, params ActionsParams) ( oapigen.ActionsResponse, error)
Gets a list of actions generated by external transactions and return its associated data
func GetAllLastConstantValue ¶
func GetBalances ¶
func GetBorrowerIds ¶
func GetLastConstantValue ¶
Get value from Mimir overrides or from the Thorchain constants.
func GetLendingData ¶
func GetLendingData(ctx context.Context) (map[string]LendingInfo, error)
func GetMemberIds ¶
GetMemberIds returns the ids of all known members.
The id of a member is defined as their rune address if they are participating with their rune address, or as their asset address otherwise (for members with asset address only.)
Member ids present in multiple pools will be only returned once.
func GetPoolsStatuses ¶
Returns last status change for pool for a given point in time (UnixNano timestamp) If a pool with assets has no status change, it means it is in "staged" status status is lowercase
func GetTHORNamesByAddress ¶
NOTE: there is probably a pure-postrgres means of doing this, which would be more performant. If we find that the performance of this query to be too slow, can try that. I don't imagine it being much of a problem since people aren't going to associate their address with 100's of thornames
func GetTopSwaps ¶
func GetTopSwaps(ctx context.Context) (oapigen.ActionsResponse, error)
func LastChurnHeight ¶
LastChurnHeight gets the latest block where a vault was activated
func NodesSecpAndEd ¶
func NodesSecpAndEd(ctx context.Context, t time.Time) (secp256k1Addrs, ed25519Addrs map[string]string, err error)
NodesSecpAndEd returs the public keys mapped to their respective addresses.
func PoolBasedOfType ¶
func PoolBasedOfType(poolName string, poolType MemberPoolType) bool
func PoolExists ¶
func PoolExistsNow ¶
func PoolsWithDeposit ¶
PoolsWithDeposit gets all asset identifiers that have at least one stake
func QueryOneValue ¶
QueryOneValue is a helper to make store single value queries result into dest Also, if there is no row to be shown it will return the empty interface{} instead of making error
func ResetDepthManagerForTest ¶
func ResetDepthManagerForTest()
func ResetLatestStateForTest ¶
func ResetLatestStateForTest()
func SetDepthsForTest ¶
func SetDepthsForTest(depths []Depth)
func SetLastHeightForTest ¶
func SetLastHeightForTest(height int64)
func SetLastTimeForTest ¶
Often current height or timestamp is read from the last track, this function helps to set them for tests.
func Setup ¶
func Setup() error
Setup initializes the package. The previous state is restored (if there was any).
func StatusPerNode ¶
StatusPerNode gets the labels for a given point in time. New nodes have the empty string (for no confirmed status). A zero moment defaults to the latest available. Requests beyond the last block cause an error.
func TotalLiquidityFeesRune ¶
TotalLiquidityFeesRune gets sum of liquidity fees in Rune for a given time interval
Types ¶
type ActionsParams ¶
type BlockState ¶
func (BlockState) NextSecond ¶
func (s BlockState) NextSecond() db.Second
func (BlockState) PoolExists ¶
func (s BlockState) PoolExists(pool string) bool
func (BlockState) PoolInfo ¶
func (s BlockState) PoolInfo(pool string) *PoolDepths
Returns nil if pool doesn't exist
type Borrowers ¶
type Borrowers []Borrower
func (Borrowers) ToOapigen ¶
func (borrowers Borrowers) ToOapigen() []oapigen.BorrowerPool
type DepthMap ¶
type DepthMap map[string]PoolDepths
type LatestState ¶
var Latest LatestState
func (*LatestState) GetState ¶
func (latest *LatestState) GetState() BlockState
type LendingInfo ¶
type MemberPool ¶
type MemberPool struct { Pool string RuneAddress string AssetAddress string LiquidityUnits int64 AssetDeposit int64 RuneDeposit int64 RuneAdded int64 AssetAdded int64 RunePending int64 AssetPending int64 DateFirstAdded int64 DateLastAdded int64 RuneWithdrawn int64 AssetWithdrawn int64 }
TODO(HooriRn): this struct might not be needed since the graphql depracation. (delete-graphql) Info of a member in a specific pool.
type MemberPoolType ¶
type MemberPoolType int
const ( RegularAndSaverPools MemberPoolType = iota // regular and synth pools too RegularPools // regular (non-synth) pools e.g. 'BTC.BTC' SaverPools // LPs of synth pools e.g. 'BTC/BTC' )
type MemberPools ¶
type MemberPools []MemberPool
Pools data associated with a single member
func GetMemberPools ¶
func GetMemberPools(ctx context.Context, address []string, poolType MemberPoolType) (MemberPools, error)
func GetRUNEPoolProvider ¶
func GetRUNEPoolProvider(ctx context.Context, address []string, poolType MemberPoolType) (MemberPools, error)
func (MemberPools) ToOapigen ¶
func (memberPools MemberPools) ToOapigen() []oapigen.MemberPool
func (MemberPools) ToRUNEPool ¶
func (memberPools MemberPools) ToRUNEPool() []oapigen.RUNEPoolProvider
type PoolDepths ¶
func (PoolDepths) AssetPrice ¶
func (p PoolDepths) AssetPrice() float64
func (PoolDepths) ExistsNow ¶
func (p PoolDepths) ExistsNow() bool
When a pool becomes suspended all the funds are burned. We use this as a detection of pools which no longer exist.
type THORName ¶
type THORName struct { Owner string Expire int64 Entries []THORNameEntry }