Documentation ¶
Index ¶
- Constants
- Variables
- func ConfigToOpts(cfg *config.Config) (*bind.TransactOpts, *ethclient.Client, error)
- type Address
- type BClient
- func (bc *BClient) Approve(ctx context.Context, address, spender Address, amount *big.Int) error
- func (bc *BClient) BalanceOf(ctx context.Context, address Address, owner Address) (*big.Int, error)
- func (bc *BClient) BalanceOfUnderlying(ctx context.Context, address Address, owner Address) (*types.Transaction, error)
- func (bc *BClient) Borrow(ctx context.Context, address Address, borrowAmount *big.Int) error
- func (bc *BClient) CanLiquidate(ctx context.Context, account common.Address) (bool, error)
- func (bc *BClient) ExchangeRateCurrent(ctx context.Context, address Address) (*types.Transaction, error)
- func (bc *BClient) GetAccountSnapshot(ctx context.Context, address Address)
- func (bc *BClient) GetBorrowRate(ctx context.Context, address Address) (*big.Int, error)
- func (bc *BClient) GetLiqd(ctx context.Context, borrowToken Address, opts LiquidateOpts) error
- func (bc *BClient) GetPrice(ctx context.Context, address Address) (*big.Int, error)
- func (bc *BClient) GetReserveDataAaveV3(ctx context.Context, address, owner, token Address) (int64, error)
- func (bc *BClient) GetReserveNormilizedIncomeAaveV3(ctx context.Context, address, token Address) (int64, error)
- func (bc *BClient) GetUserAccountDataAaveV3(ctx context.Context, address, owner, token Address) (int64, error)
- func (bc *BClient) Mint(ctx context.Context, address Address, mintAmount *big.Int) error
- func (bc *BClient) MintAaveV2(ctx context.Context, address, owner Address, mintAmount *big.Int) error
- func (bc *BClient) MintAaveV3(ctx context.Context, address, owner Address, mintAmount *big.Int, ...) error
- func (bc *BClient) SupplyRatePerBlock(ctx context.Context, address Address) (*big.Int, error)
- func (bc *BClient) WithdrawAaveV3(ctx context.Context, address, owner Address, withdrawAmount *big.Int, ...) error
- type Client
- func (c *Client) GetAccount(address string) (*models.AccountResponse, error)
- func (c *Client) GetAccounts(pageSize, pageNum string) (*models.AccountResponse, error)
- func (c *Client) GetBorrowInterestedAccrued(token Address, resp *models.AccountResponse) (string, error)
- func (c *Client) GetCToken(address string) (*models.CTokenResponse, error)
- func (c *Client) GetCTokens() (*models.CTokenResponse, error)
- func (c *Client) GetLiquidatableAccounts(pageSize, pageNum string) (map[string]float64, error)
- func (c *Client) GetSupplyInterestEarned(token Address, resp *models.AccountResponse) (float64, error)
- func (c *Client) GetTotalBorrowValueInEth(address string) (float64, error)
- func (c *Client) GetTotalCollateralValueInEth(address string) (float64, error)
- func (c *Client) GetTotalSupplyInterestedEarned(resp *models.AccountResponse) (float64, error)
- func (c *Client) WatchHealth(ctx context.Context, address string, riskChan, warnChan chan float64) error
- type LiquidateOpts
Constants ¶
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") )
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
const ( USDC_polygon = Address("0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174") USDT_polygon = Address("0xc2132D05D31c914a87C6611C10748AEb04B58e8F") MATIC_polygon = Address("0x0000000000000000000000000000000000001010") )
Polygon mainnet
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
const ( LendingPoolMumbai = Address("0x1758d4e6f68166C4B2d9d0F049F33dEB399Daa1F") AaveUSDTMumbai = Address("0xEF4aEDfD3552db80E8F5133ed5c27cebeD2fE015") AaveUSDCMumbai = Address("0xCdc2854e97798AfDC74BC420BD5060e022D14607") AaveDAIMumbai = Address("0xDD4f3Ee61466C4158D394d57f3D4C397E91fBc51") AaveWMATICMumbai = Address("0xC0e5f125D33732aDadb04134dB0d351E9bB5BCf6") )
Aave mumbai
Variables ¶
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 ¶
ConfigToOpts structs the optios needed for a bclient
Types ¶
type Address ¶
type Address string
Address is a compound contract address type
func (Address) EthAddress ¶
EthAddress returns a typed ethereum address
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) BalanceOfUnderlying ¶
func (*BClient) CanLiquidate ¶
CanLiquidate is used to check whether or not the given address can be liquidated
func (*BClient) ExchangeRateCurrent ¶
func (*BClient) GetAccountSnapshot ¶
GetAccountSnapshot returns a snapshot of the account state
func (*BClient) GetBorrowRate ¶
GetBorrowRate calls BorrowRatePerBlock to retrieve the current borrow interest rate
func (*BClient) GetReserveDataAaveV3 ¶
func (*BClient) GetReserveNormilizedIncomeAaveV3 ¶
func (*BClient) GetUserAccountDataAaveV3 ¶
func (*BClient) MintAaveV2 ¶
func (*BClient) MintAaveV3 ¶
func (*BClient) SupplyRatePerBlock ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to interact with the compound.finance api
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 ¶
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 ¶
GetTotalBorrowValueInEth is used to retrieve the total collateral value in eth that is owned by this account
func (*Client) GetTotalCollateralValueInEth ¶
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