Documentation ¶
Overview ¶
Package bclient provides a blockchain client for indexed finance
Index ¶
- Variables
- func BalanceOfDecimal(ip IndexPool, addr common.Address) (decimal.Decimal, error)
- func StakeBalanceOf(sp *stakingbindings.Stakingbindings, ip IndexPoolRead, addr common.Address) (decimal.Decimal, error)
- func StakeEarned(sp *stakingbindings.Stakingbindings, ip IndexPoolRead, addr common.Address) (decimal.Decimal, error)
- type Client
- func (c *Client) CC10() (IndexPool, error)
- func (c *Client) Cc10DaiPrice() (float64, error)
- func (c *Client) Cc10EthPairAddress() common.Address
- func (c *Client) Close()
- func (c *Client) CurrentBlock() (uint64, error)
- func (c *Client) DEFI5() (IndexPool, error)
- func (c *Client) DEGEN10() (IndexPool, error)
- func (c *Client) Defi5DaiPrice() (float64, error)
- func (c *Client) Defi5EthPairAddress() common.Address
- func (c *Client) Degen10DaiPrice() (float64, error)
- func (c *Client) EthClient() *ethclient.Client
- func (c *Client) EthDaiPrice() (*big.Int, error)
- func (c *Client) ExchangeAmount(amount *big.Int, pair string) (*big.Int, error)
- func (bc *Client) GetIndexPool(name string) (IndexPool, error)
- func (bc *Client) GetPoolAddress(name string) (common.Address, error)
- func (c *Client) GetTotalValueLocked(ip IndexPool, mc *multicall.Multicall, logger *zap.Logger, ...) (float64, error)
- func (c *Client) GovernorAlpha() (*governoralpha.Governoralpha, error)
- func (c *Client) MCAPControllerAt(ip IndexPool) (*mcapscontroller.Mcapscontroller, error)
- func (c *Client) MultiCall(addr string) (*multicall.Multicall, error)
- func (c *Client) NDX() (*erc20.Erc20, error)
- func (c *Client) NdxDaiPrice() (float64, error)
- func (c *Client) NdxEthPairAddress() common.Address
- func (c *Client) ORCL5() (IndexPool, error)
- func (c *Client) OracleAt(ip IndexPool) (*uv2oraclebindings.Uv2oraclebindings, error)
- func (c *Client) OracleFor(ip IndexPool) (common.Address, error)
- func (c *Client) Orcl5DaiPrice() (float64, error)
- func (c *Client) PairDecimals(pair string) int
- func (c *Client) PoolTokensFor(ip IndexPool) (map[string]common.Address, error)
- func (c *Client) PoolTokensForMC(mc *multicall.Multicall, poolAddress common.Address) (map[string]common.Address, error)
- func (c *Client) Reserves(pair string) (*uniswap.Reserve, error)
- func (c *Client) StakingAt(contractType string) (*stakingbindings.Stakingbindings, error)
- func (c *Client) Uniswap() *uniswap.Client
- type DEFI5
- type ERC20I
- type IndexPool
- type IndexPoolRead
- type ProposalState
Constants ¶
This section is empty.
Variables ¶
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") )
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 ¶
BalanceOfDecimal returns the IndexPool balance in decimal (non wei) format
func StakeBalanceOf ¶
func StakeBalanceOf( sp *stakingbindings.Stakingbindings, ip IndexPoolRead, addr common.Address) (decimal.Decimal, error)
StakeBalanceOf returns the balance of staking tokens owned by account
func StakeEarned ¶
func StakeEarned( sp *stakingbindings.Stakingbindings, ip IndexPoolRead, addr common.Address) (decimal.Decimal, error)
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 NewInfuraClient ¶
NewInfuraClient returns an eth client connected to infura
func (*Client) Cc10DaiPrice ¶
Cc10DaiPrice returns the price of CC10 in terms of DAI
func (*Client) Cc10EthPairAddress ¶
Cc10EthPairAddress returns the UniswapV2 pair of CC10-ETH
func (*Client) CurrentBlock ¶
CurrentBlock returns the current block known by the ethereum client
func (*Client) Defi5DaiPrice ¶
Defi5DaiPrice returns the price of DEFI5 in terms of DAI
func (*Client) Defi5EthPairAddress ¶
Defi5EthPairAddress returns the UniswapV2 pair of DEFI5-ETH
func (*Client) Degen10DaiPrice ¶ added in v0.0.23
Degen10DaiPrice returns the price of DEGEN10 in terms of DAI
func (*Client) EthDaiPrice ¶
EthDaiPrice returns the price of ETH in terms of DAI
func (*Client) ExchangeAmount ¶
ExchangeAmount returns the exchange amount for a variety of pairs
func (*Client) GetIndexPool ¶ added in v0.0.22
GetIndexPool is a helper function returning the underlying index pool by name
func (*Client) GetPoolAddress ¶ added in v0.0.23
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) NdxDaiPrice ¶
NdxDaiPrice returns the price of NDX in terms of DAI
func (*Client) NdxEthPairAddress ¶
NdxEthPairAddress returns the UniswapV2 pair of NDX-ETH
func (*Client) OracleAt ¶
func (c *Client) OracleAt(ip IndexPool) (*uv2oraclebindings.Uv2oraclebindings, error)
OracleAt returns the uniswapv2 oracle contract binding that the current idnex pool is using
func (*Client) Orcl5DaiPrice ¶ added in v0.0.22
Orcl5DaiPrice returns the price of ORCL5 in terms of DAI
func (*Client) PairDecimals ¶
PairDecimals returns the decimals for the corresponding token pair
func (*Client) PoolTokensFor ¶
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) StakingAt ¶
func (c *Client) StakingAt(contractType string) (*stakingbindings.Stakingbindings, error)
StakingAt returns a staking rewards bindings at the given address
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