client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CompoundBAT is the address of the cBAT contract
	CompoundBAT = Address("0x6c8c6b02e7b2be14d4fa6022dfd6d75921d90e4e")
	// CompoundDAI is the address of the cDAI contract
	CompoundDAI = Address("0x5d3a536e4d6dbd6114cc1ead35777bab948e3643")
	// CompoundSAI is the address of the cSAI contract
	CompoundSAI = Address("0xf5dce57282a584d2746faf1593d3121fcac444dc")
	// CompoundETH is the address of the cETH contract
	CompoundETH = Address("0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5")
	// CompoundREP is the address of the cREP contract
	CompoundREP = Address("0x158079ee67fce2f58472a96584a73c7ab9ac95c1")
	// CompoundUSDC is the address of the cUSDC contract
	CompoundUSDC = Address("0x39aa39c021dfbae8fac545936693ac917d5e7563")
	// CompoundWBTC is the address of the cWBTC contract
	CompoundWBTC = Address("0xc11b1268c1a384e55c48c2391d8d480264a3a7f4")
	// CompoundZRX is th eaddress of the cZRX contract
	CompoundZRX = Address("0xb3319f5d18bc0d84dd1b4825dcde5d5f7266d407")
	// Comptroller is th address of the comptroller contract
	Comptroller = Address("0x178053c06006e67e09879C09Ff012fF9d263dF29")
	// Unitroller is the address of the unitroller contract
	Unitroller = Address("0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b")
)

Variables

View Source
var (
	// CompoundTokens is map containing the name, and address of all compound tokens
	CompoundTokens = map[string]Address{
		"cBAT":  CompoundBAT,
		"cDAI":  CompoundDAI,
		"cSAI":  CompoundSAI,
		"cETH":  CompoundETH,
		"cREP":  CompoundREP,
		"cUSDC": CompoundUSDC,
		"cWBTC": CompoundWBTC,
		"cZRX":  CompoundZRX,
	}
)

Functions

This section is empty.

Types

type Address

type Address string

Address is a compound contract address type

func (Address) EthAddress

func (a Address) EthAddress() common.Address

EthAddress returns a typed ethereum address

func (Address) String

func (a Address) String() string

type BClient

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

BClient is an ethereum blockchain client

func NewBClient

func NewBClient(auth *bind.TransactOpts, client *ethclient.Client) *BClient

NewBClient registers a new blockchain client

func (*BClient) Borrow

func (bc *BClient) Borrow(ctx context.Context, address Address, borrowAmount *big.Int) error

Borrow is used to borrow a particular address

func (*BClient) CanLiquidate

func (bc *BClient) CanLiquidate(ctx context.Context, account common.Address) (bool, error)

CanLiquidate is used to check whether or not the given address can be liquidated

func (*BClient) GetBorrowRate

func (bc *BClient) GetBorrowRate(ctx context.Context, address Address) (*big.Int, error)

GetBorrowRate calls BorrowRatePerBlock to retrieve the current borrow interest rate

func (*BClient) GetLiqd

func (bc *BClient) GetLiqd(ctx context.Context, borrowToken Address, opts LiquidateOpts) error

GetLiqd is used to liquidate a borrower

type Client

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

Client is used to interact with the compound.finance api

func NewClient

func NewClient(url string) *Client

NewClient is used to instantiate a new go-compound client

func (*Client) GetAccount

func (c *Client) GetAccount(address string) (*models.AccountResponse, error)

GetAccount is used to retrieve information on a single account

func (*Client) GetAccounts

func (c *Client) GetAccounts() (*models.AccountResponse, error)

GetAccounts is used to retrieve information on many accounts

func (*Client) GetBorrowInterestedAccrued

func (c *Client) GetBorrowInterestedAccrued(token Address, resp *models.AccountResponse) (string, error)

GetBorrowInterestedAccrued is used to retrieve the interest you owe for borrowing

func (*Client) GetCToken

func (c *Client) GetCToken(address string) (*models.CTokenResponse, error)

GetCToken is used to get information on a particular ctoken

func (*Client) GetCTokens

func (c *Client) GetCTokens() (*models.CTokenResponse, error)

GetCTokens is used to retrieve information on many ctokens

func (*Client) GetLiquidatableAccounts

func (c *Client) GetLiquidatableAccounts() (map[string]float64, error)

GetLiquidatableAccounts is used to return all accounts with health below 1.0 indicating they can be liquidated. The keys of the map are the addresses and the values are their health

func (*Client) GetSupplyInterestEarned

func (c *Client) GetSupplyInterestEarned(token Address, resp *models.AccountResponse) (float64, error)

GetSupplyInterestEarned is used to retrieve the interest earned by supply a particular token

func (*Client) GetTotalBorrowValueInEth

func (c *Client) GetTotalBorrowValueInEth(address string) (float64, error)

GetTotalBorrowValueInEth is used to retrieve the total collateral value in eth that is owned by this account

func (*Client) GetTotalCollateralValueInEth

func (c *Client) GetTotalCollateralValueInEth(address string) (float64, error)

GetTotalCollateralValueInEth is used to retrieve the total collateral value in eth that is owned by this account

func (*Client) GetTotalSupplyInterestedEarned

func (c *Client) GetTotalSupplyInterestedEarned(resp *models.AccountResponse) (float64, error)

GetTotalSupplyInterestedEarned is used to return the total supply interest earned for a particular account

func (*Client) WatchHealth

func (c *Client) WatchHealth(ctx context.Context, address string, riskChan, warnChan chan float64) error

WatchHealth is a helper function used to watch account health and send signals on different states. the riskChan is a channel used to signal when an account health is at 1.0 or lower, which means it is at risk of liquidation warnChan is a channel used to signal when an account is nearing liquidation risk, and has a health of 1.2 or lower

type LiquidateOpts

type LiquidateOpts struct {
	Borrower         common.Address
	RepayAmount      *big.Int
	CTokenCollateral Address
}

LiquidateOpts is used to provide input parameters to LiquidateBorrow functinos

Jump to

Keyboard shortcuts

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