client

package
v2.0.0-...-7e5f7d2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Mainnet
	// 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")
	CompoundUSDT = Address("0xf650c3d88d12db855b8bf7d11be6c55a4e07dcc9")

	// GOERLI
	CompoundUSDC_goerli = Address("0x73506770799Eb04befb5AaE4734e58C2C624F493")

	// Common
	USDC        = Address("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48")
	USDC_goerli = Address("0x07865c6e87b9f70255377e024ace6630c1eaa37f")
)
View Source
const (
	MATIC_polygon_mumbai       = Address("0x0000000000000000000000000000000000001010")
	WMATIC_polygon_mumbai      = Address("0x9c3c9283d3e44854697cd22d3faa240cfb032889")
	WMATIC_AAVE_polygon_mumbai = Address("0xf237dE5664D3c2D2545684E76fef02A3A58A364c")
	AaveLendingPoolV3Mumbai    = Address("0x4ff9EB4C5F5f790CE7bB51d4876481C2eefDE00F")
	USDT_polygon_mumbai        = Address("0xEF4aEDfD3552db80E8F5133ed5c27cebeD2fE015")
	USDC_polygon_mumbai        = Address("0xa45C8154149C3C383c226269add5ffB5cdA7ccb7")
)

Polygon mumbai

View Source
const (
	USDC_polygon  = Address("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174")
	USDT_polygon  = Address("0xc2132D05D31c914a87C6611C10748AEb04B58e8F")
	MATIC_polygon = Address("0x0000000000000000000000000000000000001010")
)

Polygon mainnet

View Source
const (
	AaveWMATICv3      = Address("0x6d80113e533a2C0fe82EaBD35f1875DcEA89Ea97")
	AaveUSDCv3        = Address("0x625E7708f30cA75bfd92586e17077590C60eb4cD")
	AaveUSDTv3        = Address("0x6ab707Aca953eDAeFBc4fD23bA73294241490620")
	AaveDAIv3         = Address("0x82E64f49Ed5EC1bC6e43DAD4FC8Af9bb3A2312EE")
	AaveLendingPoolV3 = Address("0x794a61358D6845594F94dc1DB02A252b5b4814aD")
	AaveLendingPoolV2 = Address("0x8dff5e27ea6b7ac08ebfdf9eb090f32ee9a30fcf")
	AaveUSDTv2        = Address("0x60D55F02A771d515e077c9C2403a1ef324885CeC")
	AaveUSDCv2        = Address("0x1a13F4Ca1d028320A707D99520AbFefca3998b7F")
	AaveDAIv2         = Address("0x27F8D03b3a2196956ED754baDc28D73be8830A6e")
)

Aave Mainnet

View Source
const (
	LendingPoolMumbai = Address("0x1758d4e6f68166C4B2d9d0F049F33dEB399Daa1F")
	AaveUSDTMumbai    = Address("0xEF4aEDfD3552db80E8F5133ed5c27cebeD2fE015")
	AaveUSDCMumbai    = Address("0xCdc2854e97798AfDC74BC420BD5060e022D14607")
	AaveDAIMumbai     = Address("0xDD4f3Ee61466C4158D394d57f3D4C397E91fBc51")
	AaveWMATICMumbai  = Address("0xC0e5f125D33732aDadb04134dB0d351E9bB5BCf6")
)

Aave mumbai

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,
		"сUSDT":        CompoundUSDT,
		"сUSDT_goerli": CompoundUSDC_goerli,
		"aUSDCv3":      AaveUSDCv3,
		"aUSDTv3":      AaveUSDTv3,
		"aUSDTv2":      AaveUSDTv2,
	}
)

Functions

func ConfigToOpts

func ConfigToOpts(cfg *config.Config) (*bind.TransactOpts, *ethclient.Client, error)

ConfigToOpts structs the optios needed for a bclient

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) Approve

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

func (*BClient) BalanceOf

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

func (*BClient) BalanceOfUnderlying

func (bc *BClient) BalanceOfUnderlying(ctx context.Context, address Address, owner Address) (*types.Transaction, error)

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) ExchangeRateCurrent

func (bc *BClient) ExchangeRateCurrent(ctx context.Context, address Address) (*types.Transaction, error)

func (*BClient) GetAccountSnapshot

func (bc *BClient) GetAccountSnapshot(ctx context.Context, address Address)

GetAccountSnapshot returns a snapshot of the account state

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

func (*BClient) GetPrice

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

GetPrice returns the price/exchange rate of the cToken (WIP)

func (*BClient) GetReserveDataAaveV3

func (bc *BClient) GetReserveDataAaveV3(ctx context.Context, address, owner, token Address) (int64, error)

func (*BClient) GetReserveNormilizedIncomeAaveV3

func (bc *BClient) GetReserveNormilizedIncomeAaveV3(ctx context.Context, address, token Address) (int64, error)

func (*BClient) GetUserAccountDataAaveV3

func (bc *BClient) GetUserAccountDataAaveV3(ctx context.Context, address, owner, token Address) (int64, error)

func (*BClient) Mint

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

func (*BClient) MintAaveV2

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

func (*BClient) MintAaveV3

func (bc *BClient) MintAaveV3(ctx context.Context, address, owner Address, mintAmount *big.Int, token common.Address) error

func (*BClient) SupplyRatePerBlock

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

func (*BClient) WithdrawAaveV3

func (bc *BClient) WithdrawAaveV3(ctx context.Context, address, owner Address, withdrawAmount *big.Int, token common.Address) error

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(pageSize, pageNum string) (*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(pageSize, pageNum string) (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