tokenprice

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithThresholdPct

func WithThresholdPct(pct float64) func(*Opts)

func WithTicker

func WithTicker(t ticker.Ticker) func(*Opts)

Types

type Buffer

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

func NewBuffer

func NewBuffer(price tokens.Pricer, optOrTokens ...any) *Buffer

NewBuffer creates a new token price buffer.

A token price buffer maintains a buffered view of token prices for multiple tokens. Buffered token prices are not updated unless they are outside the threshold percentage. Start steaming token prices with Buffer.Stream(ctx).

func (*Buffer) Price

func (b *Buffer) Price(token tokens.Token) float64

Price returns the buffered price for the given token. If the price is not known, returns 0.

func (*Buffer) Stream

func (b *Buffer) Stream(ctx context.Context)

Stream starts streaming prices for all tokens into the buffer.

type Opts

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

Jump to

Keyboard shortcuts

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