protocols

package module
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

README

Protocols Adapters Repo

This repo implements adapters to different berachain protocols needed to compute LP token prices / TVL for vaults of interest to the infrared project.

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

Inclusion as an Infrared Partner

In order for a partner project to be shown in the infrared frontend and attract the economic energy of infrared users, there are two needed steps:

  1. Add token, protocol, and gauge information to our default list
  2. Implement an adapter to compute the staking token price

All related tokens (tokens in the pool and reward tokens) must first be added to the default token lists, and the protocol and gauge information must be added to the default gauge list (see default list repo). Do not add the staking token to these lists unless it is a token commonly traded on DEXes.

Anyone can open a PR to add this data for their protocol, but it is advised to be in contact with the infrared business development team in advance for the PR to be merged quickly.

Additionally infrared needs a way to track the staking token price to estimate infrared vault TVL and APR.

If the staking token of the gauge is a token we already track in the default token list, then you do not need to implement any custom adapter in this repo. For example, BERPS bHONEY and Infrared iBGT vaults have staking tokens bHONEY and iBGT respectively which are in the tokens list because they commonly trade on DEXes

However, the more common case is that the staking token for the gauge is an LP "claim" token which is not traded commonly on any DEX and is only used to track positions in your protocol. In this case you will also need to create an adapter which computes the current staking token price before infrared will show your vault information to our users.

Implementing an Adapter

Please follow these best practices when implementing an adapter for your protocol.

When you have implemented your adapter, please write a simple test script which demonstrates the Config(), LPTokenPrice(), and TVL() functions in a file called main.go at /cmd/test/protoName/main.go

Golang Types and Stateful Structs

Use the golang big.Int type to represent token amounts, use the decimal.Decimal type to represent prices and rates. Do not hardcode any contract addresses but allow them to be passed in to a function which creates a new stateful data struct to store them.

If your protocol has multiple pools/vaults with infrared, then we will initialize and run separate instances of the adapter for each pool/vault with different initialization data. Please write your adapter and data structs to represent a single pool/vault in your protocol with all differentiation passed as inputs.

Add ABIs for any contracts you will make calls to under /assets/abis and update the makefile codegen command to generate their go bindings. Use the pkg and output location patterns which already exist.

New Struct and Initialize Functions

Create a function which returns a new data structure for any stateful information, but make sure that this 'New' function does not contain any code which has the potential to throw an error. Examples would be the NewKodiakLPPriceProvider or NewBexLPPriceProvider.

You can expect that this 'New' function will be given both a price map for all underlying tokens and the config data as a json encoded string in a byte array (discussed below). The price map will link all underlying token addresses as string keys to their corresponding Price struct, which contains token name, the number of decimals in amount representations of the token, and a decimal.Decimal price value in USD. Please include a blockNumber which these prices should correspond to and make all onchain function calls (except in the Config setup) use this blockNumber as a filter so that the token price and TVL can be queried at any time in the past.

In the Initialize() function on this type, you should perform any setup which has the potential to actually throw errors, and make sure that all potential errors are correctly handled and returned. Common examples are errors could be thrown when unmarshalling json config data, if needed token prices were not supplied, or if there are problems with the RPC node when initializing smart contract connections, etc.

Required Adapter Functions

The functions which you must implement for the adapter to be used in the infrared backend system are the LPTokenPrice() and TVL() functions which should return either a string representing the USD amount, or an error which happened during execution. The LPTokenPrice() should return the price of a single staking token (if it has 18 decimals then the price of 10^18 sub units) in USD. The TVL() should return the total amount in USD represented by the entire pool/vault in your protocol.

It is best practice to internally work with all price information in these functions as decimal.Decimal types until the final serialization to a string before output.

Config Function and Data

The Protocol interface exposes a Config function which is meant to collect any data which is unlikely to change between calls but would be needed input to all onchain function calls in the process of computing the LP token price. This will be custom to each adapter dependent on what data is needed to uniquely describe the pool/vault.

For example, with Kodiak, the order of the tokens in a pool matters, so the Config function performs an onchain query to the Kodiak vault to find which underlying token is token0 and which is token1. Another example is with BEX, where which token is the quote token and which is the base token is important information to store, as well as the IDX or pool type for the given pool.

If your specific protocol does not require any such config data to later compute the LP Token price or TVL then you can return an empty byte array or simply "" since it will not need to be parsed back into json.

This config information will only be generated once by the system by calling to Config() and storing its output, and then the output will be present to all future calls. It is recommended that you make a custom type to store your config data and annotate it with appropriate json serialization directives eg. the KodiakConfig and BexConfig type structs.

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 (
	One64x64                = "18446744073709551616" // 1 << 64
	Decimals18              = 1e18
	ShareTokenPriceDecimals = 18
)
View Source
const (
	V2PoolByteCodeSHA256   = "bffda5c9e111fa411890cc93d58cb5c58a14f97bcbfa642efe300c766c4397f6"
	V3IslandByteCodeSHA256 = "f1b68b8044f372c1831075be05a63c1757ef9c64cabd5dfbf9a749a93f25b1da"
)
View Source
const USDPriceDecimals uint = 18

The fetchPrice() onchain call always returns a USD price with 18 decimals

View Source
const Version = "0.4.0"

Version information

Variables

This section is empty.

Functions

func ABDKToDecimal added in v0.1.14

func ABDKToDecimal(xIn *big.Int) (decimal.Decimal, error)

ABDKToDecimal converts an ABDK fixed point 64.64 number to deicmal.Decimal

func NormalizeAmount added in v0.1.7

func NormalizeAmount(amount *big.Int, decimals uint) decimal.Decimal

Given a token amount as a big.Int and the number of decimals (uint) get a decimal.Decimal amount

Types

type AquaBeraConfig added in v0.1.12

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

type AquaBeraLPPriceProvider added in v0.1.12

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

AquaBeraLPPriceProvider defines the provider for AquaBera LP price and TVL.

func NewAquaBeraLPPriceProvider added in v0.1.12

func NewAquaBeraLPPriceProvider(
	address common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *AquaBeraLPPriceProvider

NewAquaBeraLPPriceProvider creates a new instance of the AquaBeraLPPriceProvider.

func (*AquaBeraLPPriceProvider) GetConfig added in v0.1.12

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

GetConfig fetches and returns the configuration for the AquaBera protocol.

func (*AquaBeraLPPriceProvider) Initialize added in v0.1.12

func (a *AquaBeraLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data provided and instantiates the AquaBera smart contract.

func (*AquaBeraLPPriceProvider) LPTokenPrice added in v0.1.12

func (a *AquaBeraLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

LPTokenPrice returns the current price of the protocol's LP token in USD.

func (*AquaBeraLPPriceProvider) TVL added in v0.1.12

TVL returns the Total Value Locked in the protocol in USD.

func (*AquaBeraLPPriceProvider) UpdateBlock added in v0.1.18

func (a *AquaBeraLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type Balances added in v0.1.18

type Balances struct {
	Amount0 *big.Int
	Amount1 *big.Int
}

type BeraBorrowCDPConfig added in v0.1.9

type BeraBorrowCDPConfig struct {
	ColVaultAddress string `json:"col_vault_address"`
	LPTDecimals     uint   `json:"lpt_decimals"`
	CDPDecimals     uint   `json:"cdp_decimals"`
}

LPTDecimals are the decimals of the InfraredWrapper token CDPDecimals are the decimals of the CompoundingInfraredCollateralVault token

type BeraBorrowLPPriceProvider added in v0.1.9

type BeraBorrowLPPriceProvider struct {
	LPTAddress common.Address
	// contains filtered or unexported fields
}

BeraBorrowLPPriceProvider defines the provider for BeraBorrow CDP price and CDP TVL.

func NewBeraBorrowLPPriceProvider added in v0.1.9

func NewBeraBorrowLPPriceProvider(
	LPTAddress common.Address,
	block *big.Int,
	logger zerolog.Logger,
	config []byte,
) *BeraBorrowLPPriceProvider

NewBeraBorrowLPPriceProvider creates a new instance of the BeraBorrowLPPriceProvider.

func (*BeraBorrowLPPriceProvider) GetConfig added in v0.1.9

func (b *BeraBorrowLPPriceProvider) GetConfig(ctx context.Context, lpAddress string, client *ethclient.Client) ([]byte, error)

func (*BeraBorrowLPPriceProvider) Initialize added in v0.1.9

func (b *BeraBorrowLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data and instantiates the CDP contract.

func (*BeraBorrowLPPriceProvider) LPTokenPrice added in v0.1.9

func (b *BeraBorrowLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

LPTokenPrice returns the current price of the protocol's LP token in USD

func (*BeraBorrowLPPriceProvider) TVL added in v0.1.9

TVL returns the Total Value Locked in the CDP in USD Actually gets the TVL of the CICV which is 1-1 with the TVL of the IW which is the LP token

func (*BeraBorrowLPPriceProvider) UpdateBlock added in v0.1.18

func (b *BeraBorrowLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type BexLPPriceProvider added in v0.1.6

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

BexLPPriceProvider defines the provider for BEX LP price and Pool TVL.

func NewBexLPPriceProvider added in v0.1.6

func NewBexLPPriceProvider(
	crocqueryAddress common.Address,
	lpTokenAddress common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *BexLPPriceProvider

NewBexLPPriceProvider creates a new instance of the BexLPPriceProvider.

func (*BexLPPriceProvider) GetConfig added in v0.1.6

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

func (*BexLPPriceProvider) Initialize added in v0.1.6

func (b *BexLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data and instantiates the CrocQuery and LP Token ERC20, CrocLPERC20 smart contracts.

func (*BexLPPriceProvider) LPTokenPrice added in v0.1.6

func (b *BexLPPriceProvider) 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 (*BexLPPriceProvider) TVL added in v0.1.6

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

func (*BexLPPriceProvider) UpdateBlock added in v0.1.18

func (b *BexLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type BexPoolConfig added in v0.1.6

type BexPoolConfig struct {
	Base        string `json:"base"`
	Quote       string `json:"quote"`
	IDX         string `json:"idx"`
	LPTDecimals uint   `json:"lpt_decimals"`
}

type BexV2LPPriceProvider added in v0.1.7

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

BexLPPriceProvider defines the provider for BEX LP price and Pool TVL.

func NewBexV2LPPriceProvider added in v0.1.7

func NewBexV2LPPriceProvider(
	vaultAddress common.Address,
	poolAddress common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *BexV2LPPriceProvider

NewBexLPPriceProvider creates a new instance of the BexLPPriceProvider.

func (*BexV2LPPriceProvider) GetConfig added in v0.1.7

func (b *BexV2LPPriceProvider) GetConfig(ctx context.Context, poolAddress string, client *ethclient.Client) ([]byte, error)

func (*BexV2LPPriceProvider) Initialize added in v0.1.7

func (b *BexV2LPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data and instantiates the Vault and Base Pool contracts.

func (*BexV2LPPriceProvider) LPTokenPrice added in v0.1.7

func (b *BexV2LPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

LPTokenPrice returns the current price of the protocol's LP token in USD

func (*BexV2LPPriceProvider) TVL added in v0.1.7

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

func (*BexV2LPPriceProvider) UpdateBlock added in v0.1.18

func (b *BexV2LPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type BexV2PoolConfig added in v0.1.7

type BexV2PoolConfig struct {
	PoolID      [32]byte `json:"poolid"`
	LPTDecimals uint     `json:"lpt_decimals"`
}

type BullaConfig added in v0.1.10

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

BullaConfig defines the configuration for Bulla Exchange adapter

type BullaLPPriceProvider added in v0.1.10

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

BullaLPPriceProvider defines the provider for Bulla Exchange LP price and TVL.

func NewBullaLPPriceProvider added in v0.1.10

func NewBullaLPPriceProvider(
	address common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *BullaLPPriceProvider

NewBullaLPPriceProvider creates a new instance of the BullaLPPriceProvider.

func (*BullaLPPriceProvider) GetConfig added in v0.1.10

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

GetConfig returns the configuration for the Bulla Exchange adapter.

func (*BullaLPPriceProvider) Initialize added in v0.1.10

func (b *BullaLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data provided and instantiates the Bulla smart contract.

func (*BullaLPPriceProvider) LPTokenPrice added in v0.1.10

func (b *BullaLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

LPTokenPrice returns the current price of the protocol's LP token in USD.

func (*BullaLPPriceProvider) TVL added in v0.1.10

TVL returns the Total Value Locked in the protocol in USD.

func (*BullaLPPriceProvider) UpdateBlock added in v0.1.18

func (b *BullaLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type BurrBearLPPriceProvider added in v0.1.11

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

BurrBearLPPriceProvider defines the provider for BEX LP price and Pool TVL.

func NewBurrBearLPPriceProvider added in v0.1.11

func NewBurrBearLPPriceProvider(
	poolAddress common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *BurrBearLPPriceProvider

NewBurrBearLPPriceProvider creates a new instance of the BurrBearLPPriceProvider.

func (*BurrBearLPPriceProvider) GetConfig added in v0.1.11

func (bb *BurrBearLPPriceProvider) GetConfig(ctx context.Context, poolAddress string, client *ethclient.Client) ([]byte, error)

func (*BurrBearLPPriceProvider) Initialize added in v0.1.11

func (bb *BurrBearLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data and instantiates the Vault and Base Pool contracts.

func (*BurrBearLPPriceProvider) LPTokenPrice added in v0.1.11

func (bb *BurrBearLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

LPTokenPrice returns the current price of the protocol's LP token in USD

func (*BurrBearLPPriceProvider) TVL added in v0.1.11

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

func (*BurrBearLPPriceProvider) UpdateBlock added in v0.1.18

func (bb *BurrBearLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type BurrBearPoolConfig added in v0.1.11

type BurrBearPoolConfig struct {
	VaultContract string   `json:"vault_contract"`
	PoolID        [32]byte `json:"poolid"`
	LPTDecimals   uint     `json:"lpt_decimals"`
}

type D8xConfig added in v0.1.14

type D8xConfig struct {
	PoolId         uint8          `json:"poolId"`
	PoolManager    common.Address `json:"pool_manager"`
	MarginToken    common.Address `json:"margin_token"`
	MarginDecimals uint8          `json:"margin_decimals"`
}

type D8xLPPriceProvider added in v0.1.14

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

func NewD8xLPPriceProvider added in v0.1.14

func NewD8xLPPriceProvider(
	address common.Address,
	block *big.Int,
	logger zerolog.Logger,
	config []byte,
) *D8xLPPriceProvider

NewD8xLPPriceProvider returns a new instance of D8XLPPriceProvider with the assigned config and the D8X contract address

func (*D8xLPPriceProvider) GetConfig added in v0.1.14

func (d8x *D8xLPPriceProvider) GetConfig(ctx context.Context, address string, ethClient *ethclient.Client) ([]byte, error)

func (*D8xLPPriceProvider) Initialize added in v0.1.14

func (d8x *D8xLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

func (*D8xLPPriceProvider) LPTokenPrice added in v0.1.14

func (d8x *D8xLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

LPTokenPrice returns the current price of the protocol's LP token in USD

func (*D8xLPPriceProvider) TVL added in v0.1.14

func (d8x *D8xLPPriceProvider) TVL(ctx context.Context) (string, error)

TVL returns the Total Value Locked in the pool in USD.

func (*D8xLPPriceProvider) UpdateBlock added in v0.1.18

func (d8x *D8xLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type DolomiteConfig added in v0.1.8

type DolomiteConfig struct {
	Token0      string `json:"token0"`
	LPTDecimals uint   `json:"lpt_decimals"`
}

type DolomiteLPPriceProvider added in v0.1.8

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

DolomiteLPPriceProvider defines the provider for Dolomite dToken price and TVL.

func NewDolomiteLPPriceProvider added in v0.1.8

func NewDolomiteLPPriceProvider(
	address common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *DolomiteLPPriceProvider

NewDolomiteLPPriceProvider creates a new instance of the DolomiteLPPriceProvider.

func (*DolomiteLPPriceProvider) GetConfig added in v0.1.8

func (d *DolomiteLPPriceProvider) GetConfig(ctx context.Context, address string, ethClient *ethclient.Client) ([]byte, error)

func (*DolomiteLPPriceProvider) Initialize added in v0.1.8

func (d *DolomiteLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data provided and instantiates the Dolomite smart contract.

func (*DolomiteLPPriceProvider) LPTokenPrice added in v0.1.8

func (d *DolomiteLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

func (*DolomiteLPPriceProvider) TVL added in v0.1.8

func (*DolomiteLPPriceProvider) UpdateBlock added in v0.1.18

func (d *DolomiteLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type KodiakConfig added in v0.1.4

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

type KodiakContract added in v0.1.18

type KodiakContract interface {
	Decimals(opts *bind.CallOpts) (uint8, error)
	Token0(opts *bind.CallOpts) (common.Address, error)
	Token1(opts *bind.CallOpts) (common.Address, error)
	TotalSupply(opts *bind.CallOpts) (*big.Int, error)
	GetBalances(opts *bind.CallOpts) (Balances, error)
}

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,
	block *big.Int,
	prices map[string]Price,
	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 checks the configuration/data provided and instantiates the KodiakV1 smart contract.

func (*KodiakLPPriceProvider) LPTokenPrice

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

LPTokenPrice returns the current price of LP token in USD

func (*KodiakLPPriceProvider) TVL

TVL returns the Total Value Locked in the pool/island as USD

func (*KodiakLPPriceProvider) UpdateBlock added in v0.1.18

func (k *KodiakLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type KodiakV2Pool added in v0.1.18

type KodiakV2Pool struct {
	*sc.UniswapV2
}

func (*KodiakV2Pool) GetBalances added in v0.1.18

func (v2 *KodiakV2Pool) GetBalances(opts *bind.CallOpts) (Balances, error)

type KodiakV3Island added in v0.1.18

type KodiakV3Island struct {
	*sc.KodiakIsland
}

Wrapper types which implement a common KodiakContract interface

func (*KodiakV3Island) GetBalances added in v0.1.18

func (v3 *KodiakV3Island) GetBalances(opts *bind.CallOpts) (Balances, error)

type Price added in v0.1.5

type Price struct {
	TokenName string
	Decimals  uint
	Price     decimal.Decimal
}

Type to track a token Price along with the number of decimals used representing token amounts

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)

	// Initialize performs any needed setup for the data structures to call other functions
	// Returns any error which occurs in setup
	Initialize(ctx context.Context, client *ethclient.Client) 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)

	// UpdateBlock sets the internal block and priceMap state to different time
	// If the protocol doesn't need a price map the second param can be nil
	UpdateBlock(block *big.Int, prices map[string]Price)
}

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

type WasabeeConfig added in v0.1.17

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

WasabeeConfig defines the configuration for Wasabee adapter

type WasabeeLPPriceProvider added in v0.1.17

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

WasabeeLPPriceProvider defines the provider for Wasabee LP price and TVL.

func NewWasabeeLPPriceProvider added in v0.1.17

func NewWasabeeLPPriceProvider(
	address common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *WasabeeLPPriceProvider

NewWasabeeLPPriceProvider creates a new instance of the WasabeeLPPriceProvider.

func (*WasabeeLPPriceProvider) GetConfig added in v0.1.17

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

GetConfig returns the configuration for the Wasabee adapter.

func (*WasabeeLPPriceProvider) Initialize added in v0.1.17

func (w *WasabeeLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data provided and instantiates the Wasabee smart contract.

func (*WasabeeLPPriceProvider) LPTokenPrice added in v0.1.17

func (w *WasabeeLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

LPTokenPrice returns the current price of the protocol's LP token in USD.

func (*WasabeeLPPriceProvider) TVL added in v0.1.17

TVL returns the Total Value Locked in the protocol in USD.

func (*WasabeeLPPriceProvider) UpdateBlock added in v0.1.18

func (w *WasabeeLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type WasabiConfig added in v0.1.14

type WasabiConfig struct {
	Token0      string `json:"token0"`
	LPTDecimals uint   `json:"lpt_decimals"`
}

type WasabiLPPriceProvider added in v0.1.14

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

WasabiLPPriceProvider defines the provider for Wasabi Token price and TVL.

func NewWasabiLPPriceProvider added in v0.1.14

func NewWasabiLPPriceProvider(
	address common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *WasabiLPPriceProvider

NewWasabiLPPriceProvider creates a new instance of the WasabiLPPriceProvider.

func (*WasabiLPPriceProvider) GetConfig added in v0.1.14

func (w *WasabiLPPriceProvider) GetConfig(ctx context.Context, address string, ethClient *ethclient.Client) ([]byte, error)

func (*WasabiLPPriceProvider) Initialize added in v0.1.14

func (w *WasabiLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data provided and instantiates the Wasabi smart contract.

func (*WasabiLPPriceProvider) LPTokenPrice added in v0.1.14

func (w *WasabiLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

func (*WasabiLPPriceProvider) TVL added in v0.1.14

func (*WasabiLPPriceProvider) UpdateBlock added in v0.1.18

func (w *WasabiLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

type WeberaConfig added in v0.1.19

type WeberaConfig struct {
	Asset       string `json:"token0"`
	LPTDecimals uint   `json:"lpt_decimals"`
}

type WeberaLPPriceProvider added in v0.1.19

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

WeberaLPPriceProvider defines the provider for Webera Token price and TVL.

func NewWeberaLPPriceProvider added in v0.1.19

func NewWeberaLPPriceProvider(
	address common.Address,
	block *big.Int,
	prices map[string]Price,
	logger zerolog.Logger,
	config []byte,
) *WeberaLPPriceProvider

NewWeberaLPPriceProvider creates a new instance of the WeberaLPPriceProvider.

func (*WeberaLPPriceProvider) GetConfig added in v0.1.19

func (w *WeberaLPPriceProvider) GetConfig(ctx context.Context, address string, ethClient *ethclient.Client) ([]byte, error)

func (*WeberaLPPriceProvider) Initialize added in v0.1.19

func (w *WeberaLPPriceProvider) Initialize(ctx context.Context, client *ethclient.Client) error

Initialize checks the configuration/data provided and instantiates the WeBera smart contract.

func (*WeberaLPPriceProvider) LPTokenPrice added in v0.1.19

func (w *WeberaLPPriceProvider) LPTokenPrice(ctx context.Context) (string, error)

func (*WeberaLPPriceProvider) TVL added in v0.1.19

func (*WeberaLPPriceProvider) UpdateBlock added in v0.1.19

func (w *WeberaLPPriceProvider) UpdateBlock(block *big.Int, prices map[string]Price)

Directories

Path Synopsis
cmd
test/aquabera command
test/beraborrow command
test/bex command
test/bexv2 command
test/bulla command
test/burrbear command
test/d8x command
test/dolomite command
test/kodiak command
test/wasabee command
test/wasabi command
test/webera command
internal
sc

Jump to

Keyboard shortcuts

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