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) Defi5DaiPrice() (float64, error)
- func (c *Client) Defi5EthPairAddress() common.Address
- func (c *Client) EthDaiPrice() (*big.Int, error)
- func (c *Client) ExchangeAmount(amount *big.Int, pair string) (*big.Int, error)
- func (c *Client) MCAPControllerAt(ip IndexPool) (*mcapscontroller.Mcapscontroller, error)
- func (c *Client) NdxDaiPrice() (float64, error)
- func (c *Client) NdxEthPairAddress() common.Address
- func (c *Client) OracleAt(ip IndexPool) (*uv2oraclebindings.Uv2oraclebindings, error)
- func (c *Client) OracleFor(ip IndexPool) (common.Address, error)
- func (c *Client) PairDecimals(pair string) int
- func (c *Client) PoolTokensFor(ip IndexPool) (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 IndexPool
- type IndexPoolRead
Constants ¶
This section is empty.
Variables ¶
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) // DEFI5UNILPStakingAddress is the address of the ETH-DEFI5 Uniswap staking contract DEFI5UNILPStakingAddress = common.HexToAddress(defi5UNILPStakeAddr) // CC10TokenAddress is the address of the CC10 token/pool contract CC10TokenAddress = common.HexToAddress(cc10Addr) // 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") // 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) 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) 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) 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) StakingAt ¶
func (c *Client) StakingAt(contractType string) (*stakingbindings.Stakingbindings, error)
StakingAt returns a staking rewards bindings at the given address
type IndexPool ¶
type IndexPool interface { IndexPoolRead }
IndexPool provides helper functions around the IndexPool contract
type IndexPoolRead ¶
type IndexPoolRead interface { 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) BalanceOf(opts *bind.CallOpts, whom common.Address) (*big.Int, error) Decimals(opts *bind.CallOpts) (uint8, error) }
IndexPoolRead are read-only IndexPool contract calls See https://docs.indexed.finance/indexed-finance-docs/smart-contracts/pool#indexpool for more information