bclient

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 21 Imported by: 2

Documentation

Overview

Package bclient provides a blockchain client for indexed finance

Index

Constants

This section is empty.

Variables

View Source
var (
	Pending   = ProposalState("Pending")
	Active    = ProposalState("Active")
	Canceled  = ProposalState("Canceled")
	Defeated  = ProposalState("Defeated")
	Succeeded = ProposalState("Succeeded")
	Queued    = ProposalState("Queued")
	Expired   = ProposalState("Expired")
	Executed  = ProposalState("Executed")
)
View Source
var (

	// DEFI5TokenAddress is the address of the DEFI5 token/pool contract
	DEFI5TokenAddress = common.HexToAddress(defi5Addr)
	// DEFI5StakingAddress is the address of the DEFI5 staking contract
	DEFI5StakingAddress = common.HexToAddress(defi5StakeAddr)
	// CC10StakingAddress is the address of the CC10 staking contract
	CC10StakingAddress = common.HexToAddress(cc10StakeAddr)
	// DEFI5UNILPStakingAddress is the address of the ETH-DEFI5 Uniswap staking contract
	DEFI5UNILPStakingAddress = common.HexToAddress(defi5UNILPStakeAddr)
	// CC10UNILPStakingAddress is the address of the ETH-CC10 uniswap staking contract
	CC10UNILPStakingAddress = common.HexToAddress(cc10UNILPStakeAddr)
	// CC10TokenAddress is the address of the CC10 token/pool contract
	CC10TokenAddress = common.HexToAddress(cc10Addr)
	// ORCL5TokenAddress is the address of the ORCL5 token/pool contract
	ORCL5TokenAddress = common.HexToAddress(orcl5Addr)
	// DEGEN10TokenAddress is the address of the DEGEN10 token contract
	DEGEN10TokenAddress = common.HexToAddress(degen10Addr)
	// WETHTokenAddress is the address of the WETH token contract
	WETHTokenAddress = common.HexToAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")
	// DAITokenAddress is the address of the MCD (Multi Collateral DAI) contract
	DAITokenAddress = common.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f")
	// NDXTokenAddress is the address of the NDX contract
	NDXTokenAddress = common.HexToAddress("0x86772b1409b61c639eaac9ba0acfbb6e238e5f83")
	// GovernorAlpha is the address of the GovernorALpha governance contract
	GovernorAlpha = common.HexToAddress("0x95129751769f99CC39824a0793eF4933DD8Bb74B")
	// InfuraWSURL is the URL for INFURA websockets access
	InfuraWSURL = "wss://mainnet.infura.io/ws/v3/"
	// InfuraHTTPURL is the URL for INFURA HTTP access
	InfuraHTTPURL = "https://mainnet.infura.io/v3/"
	// IndexPools contains all current available idnex pools
	// note that it may not be truly up-to-date
	IndexPools = map[string]common.Address{"defi5": DEFI5TokenAddress, "cc10": CC10TokenAddress}
)

Functions

func BalanceOfDecimal

func BalanceOfDecimal(ip IndexPool, addr common.Address) (decimal.Decimal, error)

BalanceOfDecimal returns the IndexPool balance in decimal (non wei) format

func StakeBalanceOf

StakeBalanceOf returns the balance of staking tokens owned by account

func StakeEarned

StakeEarned returns the amount of staking tokens earned

Types

type Client

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

Client wraps ethclient and provides helper functions for interacting with the indexed finance smart contracts

func NewClient

func NewClient(url string) (*Client, error)

NewClient returns an eth client connected to an RPC

func NewInfuraClient

func NewInfuraClient(token string, websockets bool) (*Client, error)

NewInfuraClient returns an eth client connected to infura

func (*Client) CC10

func (c *Client) CC10() (IndexPool, error)

CC10 returns a CC10 contract binding

func (*Client) Cc10DaiPrice

func (c *Client) Cc10DaiPrice() (float64, error)

Cc10DaiPrice returns the price of CC10 in terms of DAI

func (*Client) Cc10EthPairAddress

func (c *Client) Cc10EthPairAddress() common.Address

Cc10EthPairAddress returns the UniswapV2 pair of CC10-ETH

func (*Client) Close

func (c *Client) Close()

Close terminates the blockchain connection

func (*Client) CurrentBlock

func (c *Client) CurrentBlock() (uint64, error)

CurrentBlock returns the current block known by the ethereum client

func (*Client) DEFI5

func (c *Client) DEFI5() (IndexPool, error)

DEFI5 returns a DEFI5 contract binding

func (*Client) DEGEN10 added in v0.0.23

func (c *Client) DEGEN10() (IndexPool, error)

DEGEN10 returns a DEGEN10 contract binding

func (*Client) Defi5DaiPrice

func (c *Client) Defi5DaiPrice() (float64, error)

Defi5DaiPrice returns the price of DEFI5 in terms of DAI

func (*Client) Defi5EthPairAddress

func (c *Client) Defi5EthPairAddress() common.Address

Defi5EthPairAddress returns the UniswapV2 pair of DEFI5-ETH

func (*Client) Degen10DaiPrice added in v0.0.23

func (c *Client) Degen10DaiPrice() (float64, error)

Degen10DaiPrice returns the price of DEGEN10 in terms of DAI

func (*Client) EthClient added in v0.0.21

func (c *Client) EthClient() *ethclient.Client

EthClient returns the underlying ethclient connection

func (*Client) EthDaiPrice

func (c *Client) EthDaiPrice() (*big.Int, error)

EthDaiPrice returns the price of ETH in terms of DAI

func (*Client) ExchangeAmount

func (c *Client) ExchangeAmount(amount *big.Int, pair string) (*big.Int, error)

ExchangeAmount returns the exchange amount for a variety of pairs

func (*Client) GetIndexPool added in v0.0.22

func (bc *Client) GetIndexPool(name string) (IndexPool, error)

GetIndexPool is a helper function returning the underlying index pool by name

func (*Client) GetPoolAddress added in v0.0.23

func (bc *Client) GetPoolAddress(name string) (common.Address, error)

GetPoolAddress returns the index pool address for a given pool

func (*Client) GetTotalValueLocked added in v0.0.15

func (c *Client) GetTotalValueLocked(ip IndexPool, mc *multicall.Multicall, logger *zap.Logger, poolAddress common.Address) (float64, error)

GetTotalValueLocked returns the total value locked into the contracts

func (*Client) GovernorAlpha added in v0.0.9

func (c *Client) GovernorAlpha() (*governoralpha.Governoralpha, error)

GovernorAlpha returns the GovernorAlpha contracts binding at the active governance address

func (*Client) MCAPControllerAt

func (c *Client) MCAPControllerAt(ip IndexPool) (*mcapscontroller.Mcapscontroller, error)

MCAPControllerAt returns the marketcap square root controller bindings for an IndexPool

func (*Client) MultiCall added in v0.0.23

func (c *Client) MultiCall(addr string) (*multicall.Multicall, error)

MultiCall returns the multicall contract

func (*Client) NDX added in v0.0.16

func (c *Client) NDX() (*erc20.Erc20, error)

NDX returns an NDX contract binding

func (*Client) NdxDaiPrice

func (c *Client) NdxDaiPrice() (float64, error)

NdxDaiPrice returns the price of NDX in terms of DAI

func (*Client) NdxEthPairAddress

func (c *Client) NdxEthPairAddress() common.Address

NdxEthPairAddress returns the UniswapV2 pair of NDX-ETH

func (*Client) ORCL5 added in v0.0.22

func (c *Client) ORCL5() (IndexPool, error)

ORCL5 returns a ORCL5 contract binding

func (*Client) OracleAt

OracleAt returns the uniswapv2 oracle contract binding that the current idnex pool is using

func (*Client) OracleFor

func (c *Client) OracleFor(ip IndexPool) (common.Address, error)

OracleFor returns the uniswap v2 oracle address for tne given index pool

func (*Client) Orcl5DaiPrice added in v0.0.22

func (c *Client) Orcl5DaiPrice() (float64, error)

Orcl5DaiPrice returns the price of ORCL5 in terms of DAI

func (*Client) PairDecimals

func (c *Client) PairDecimals(pair string) int

PairDecimals returns the decimals for the corresponding token pair

func (*Client) PoolTokensFor

func (c *Client) PoolTokensFor(ip IndexPool) (map[string]common.Address, error)

PoolTokensFor returns the pools tokens baseketed in the pool, and their ERC20 name

func (*Client) PoolTokensForMC added in v0.0.23

func (c *Client) PoolTokensForMC(mc *multicall.Multicall, poolAddress common.Address) (map[string]common.Address, error)

PoolTokensForMC is equivalent to PoolTokensFor but using the multicall contract

func (*Client) Reserves

func (c *Client) Reserves(pair string) (*uniswap.Reserve, error)

Reserves returns available reserves in the pair

func (*Client) StakingAt

func (c *Client) StakingAt(contractType string) (*stakingbindings.Stakingbindings, error)

StakingAt returns a staking rewards bindings at the given address

func (*Client) Uniswap

func (c *Client) Uniswap() *uniswap.Client

Uniswap returns a uniswap client helper

type DEFI5

type DEFI5 struct {
	*poolbindings.Poolbindings
}

DEFI5 is the DEFI Top 5 IndexPool

type ERC20I added in v0.0.23

type ERC20I interface {
	BalanceOf(opts *bind.CallOpts, whom common.Address) (*big.Int, error)
	Decimals(opts *bind.CallOpts) (uint8, error)
	TotalSupply(opts *bind.CallOpts) (*big.Int, error)
}

ERC20I denotes ERC20 interface functions

type IndexPool

type IndexPool interface {
	IndexPoolRead
}

IndexPool provides helper functions around the IndexPool contract

type IndexPoolRead

type IndexPoolRead interface {
	ERC20I
	IsPublicSwap(opts *bind.CallOpts) (bool, error)
	GetController(opts *bind.CallOpts) (common.Address, error)
	GetCurrentTokens(opts *bind.CallOpts) ([]common.Address, error)
	GetNumTokens(opts *bind.CallOpts) (*big.Int, error)
	GetMaxPoolTokens(opts *bind.CallOpts) (*big.Int, error)
	GetSpotPrice(opts *bind.CallOpts, tokenIn common.Address, tokenOut common.Address) (*big.Int, error)
	GetSwapFee(opts *bind.CallOpts) (*big.Int, error)
	GetCurrentDesiredTokens(opts *bind.CallOpts) ([]common.Address, error)
	GetDenormalizedWeight(opts *bind.CallOpts, token common.Address) (*big.Int, error)
	GetTotalDenormalizedWeight(opts *bind.CallOpts) (*big.Int, error)
	GetUsedBalance(opts *bind.CallOpts, token common.Address) (*big.Int, error)
	GetBalance(opts *bind.CallOpts, token common.Address) (*big.Int, error)
	ExtrapolatePoolValueFromToken(opts *bind.CallOpts) (common.Address, *big.Int, error)
}

IndexPoolRead are read-only IndexPool contract calls See https://docs.indexed.finance/indexed-finance-docs/smart-contracts/pool#indexpool for more information

type ProposalState added in v0.0.9

type ProposalState string

ProposalState indicates a state that a proposal may be in

func GetProposalState added in v0.0.9

func GetProposalState(
	gov *governoralpha.Governoralpha,
	number *big.Int,
) (ProposalState, error)

GetProposalState returns the state of the proposal

func ProposalFromUint added in v0.0.9

func ProposalFromUint(state uint8) ProposalState

ProposalFromUint returns a proposal

func (ProposalState) String added in v0.0.9

func (ps ProposalState) String() string

Jump to

Keyboard shortcuts

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