protocols

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

README

protocols repo

Keeps the logic to compute LP token prices / TVL for vaults and protocol types of interest to the infrared project.

See https://github.com/infrared-dao/infrared-default-list for a complete list.

Documentation

Overview

Package protocols provides standardized protocol implementations for computing LP data, e.g. LP token prices and TVL values

Index

Constants

View Source
const Version = "0.3.0"

Version information

Variables

This section is empty.

Functions

This section is empty.

Types

type KodiakConfig added in v0.1.4

type KodiakConfig struct {
	Token0      string `json:"token0"`
	Token1      string `json:"token1"`
	LPTDecimals uint   `json:"lpt_decimals"`
}

type KodiakLPPriceProvider

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

KodiakLPPriceProvider defines the provider for Kodiak LP price and TVL.

func NewKodiakLPPriceProvider

func NewKodiakLPPriceProvider(address common.Address, prices map[string]decimal.Decimal, logger zerolog.Logger, config []byte) *KodiakLPPriceProvider

NewKodiakLPPriceProvider creates a new instance of the KodiakLPPriceProvider.

func (*KodiakLPPriceProvider) GetConfig added in v0.1.4

func (k *KodiakLPPriceProvider) GetConfig(ctx context.Context, address string, client *ethclient.Client) ([]byte, error)

func (*KodiakLPPriceProvider) Initialize

func (k *KodiakLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize instantiates the KodiakV1 smart contract.

func (*KodiakLPPriceProvider) LPTokenPrice

func (k *KodiakLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

LPTokenPrice returns the current price of the protocol's LP token in USD cents (1 USD = 100 cents).

func (*KodiakLPPriceProvider) TVL

TVL returns the Total Value Locked in the protocol in USD cents (1 USD = 100 cents).

type Protocol

type Protocol interface {
	// GetConfig returns static configuration data needed for LP token price/TVL calculation.
	// Returns an error if the configuration cannot be prepared.
	GetConfig(ctx context.Context, address string, ethClient *ethclient.Client) ([]byte, error)

	// LPTokenPrice returns the current price of the protocol's LP token
	// in USD.
	// Returns an error if the price cannot be determined.
	LPTokenPrice(ctx context.Context) (string, error)

	// TVL returns the Total Value Locked in the protocol in USD.
	// Returns an error if the TVL cannot be determined.
	TVL(ctx context.Context) (string, error)
}

Protocol defines methods for querying DeFi protocol metrics. Implementations must be safe for concurrent use.

Directories

Path Synopsis
cmd
internal
sc

Jump to

Keyboard shortcuts

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