Documentation
¶
Index ¶
- Constants
- type ExpectedRPC
- type Indexer
- func (d *Indexer) AverageBlockTime() time.Duration
- func (d *Indexer) BlockToTimestamp(height uint64) time.Time
- func (d *Indexer) CalculateVolumes(pools []types.PoolStatus) error
- func (d *Indexer) DenomTrace(ibc string) (ibctypes.DenomTrace, error)
- func (d *Indexer) GetStatus() map[string]string
- func (d *Indexer) PoolStatusAt(height, poolId uint64) (types.PoolStatus, uint64, error)
- func (d *Indexer) PoolStatusesAt(height uint64, poolId ...uint64) ([]types.PoolStatus, uint64, error)
- func (d *Indexer) SetLatestBlockHeight(height uint64, blockTime time.Time)
- func (d *Indexer) SetLatestPrice(token, base string, value float64, lastUpdated time.Time) error
- type PoolMap
- type PriceMap
- func (p *PriceMap) Estimate(lastUpdated time.Time, denom string) (float64, time.Duration)
- func (p *PriceMap) Nearest(timestamp time.Time, name string) []repository.TokenPrice
- func (p *PriceMap) Prune(minLastUpdated time.Time) int
- func (p *PriceMap) Set(price repository.TokenPrice) bool
- func (p *PriceMap) Sort()
- func (p *PriceMap) SortToken(denom string)
Constants ¶
View Source
const BaseVolumeDenom = "uosmo"
View Source
const (
DefaultBlocksPerHour = 720
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExpectedRPC ¶
type ExpectedRPC interface { DenomTrace(ibc string) (IBCTypes.DenomTrace, error) DenomTraces() ([]IBCTypes.DenomTrace, error) BlockAt(height int64) (*tmtypes.Block, error) ChainID() (string, error) Close() error Mempool() ([]*types.Transaction, error) PoolsAt(height int64, ids ...uint64) ([]*pmtypes.PoolI, error) PoolsTotalLiquidityAt(height int64, ids ...uint64) ([]types.PoolLiquidity, error) PoolsVolumeAt(height int64, ids ...uint64) ([]types.PoolVolume, error) Subscribe(eventName string, handle func(events <-chan ctypes.ResultEvent) error) error }
type Indexer ¶
type Indexer struct {
// contains filtered or unexported fields
}
func New ¶
func New(ctx context.Context, cancel context.CancelCauseFunc, group *errgroup.Group, logger *slog.Logger, repo repository.Repository, rpc ExpectedRPC, poolIds []uint64, blocks uint64, verbose bool) (*Indexer, error)
func (*Indexer) AverageBlockTime ¶
func (*Indexer) BlockToTimestamp ¶
Calculates block timestamp based on latest block height and latest block timestamp FIXME: This is approximation. Better way would be to record each block timestamp and find that block's timestamp and return it instead. If no block exists with that height, find a closest block and interpolate/extrapolate from that.
func (*Indexer) CalculateVolumes ¶
func (d *Indexer) CalculateVolumes(pools []types.PoolStatus) error
func (*Indexer) DenomTrace ¶
func (d *Indexer) DenomTrace(ibc string) (ibctypes.DenomTrace, error)
func (*Indexer) PoolStatusAt ¶
func (*Indexer) PoolStatusesAt ¶
func (*Indexer) SetLatestBlockHeight ¶
type PriceMap ¶
func (*PriceMap) Estimate ¶
Estimate will extrapolate or interpolate(depending on cache state and lastUpdated param) the price.
- If the price is outside of cache dates - final price will be the same as closest price available.
- If the price is inside cache dates - final price will be the average of two prices(unless exact match is found) Estimation time error will be returned.
func (*PriceMap) Nearest ¶
func (p *PriceMap) Nearest(timestamp time.Time, name string) []repository.TokenPrice
func (*PriceMap) Set ¶
func (p *PriceMap) Set(price repository.TokenPrice) bool
Set will add a token price if such does not exist (must not match LastUpdated). Will return true if it results in unsorted array.
Click to show internal directories.
Click to hide internal directories.