Documentation ¶
Index ¶
- Constants
- Variables
- func Approve(client *DefiClient, coin coinType, addr common.Address, size *big.Int) error
- type AaveClient
- func (c *AaveClient) Borrow(size *big.Int, coin coinType, interestRate rateModel) error
- func (c *AaveClient) FlashLoanActions(size *big.Int, coin coinType, actions *Actions) *Actions
- func (c *AaveClient) GetUserReserveData(addr common.Address, user common.Address) (ReserveData, error)
- func (c *AaveClient) Lend(size *big.Int, coin coinType) error
- type Actions
- type BalancerClient
- type Client
- type CompoundClient
- func (c *CompoundClient) BalanceOf(coin coinType) (*big.Int, error)
- func (c *CompoundClient) BalanceOfUnderlying(coin coinType) (*types.Transaction, error)
- func (c *CompoundClient) Redeem(amount int64, coin coinType) error
- func (c *CompoundClient) RedeemActions(size *big.Int, coin coinType) *Actions
- func (c *CompoundClient) Supply(amount int64, coin coinType) error
- func (c *CompoundClient) SupplyActions(size *big.Int, coin coinType) *Actions
- type CurveClient
- func (c *CurveClient) AddLiquidityActions(handler common.Address, pool common.Address, tokens []common.Address, ...) *Actions
- func (c *CurveClient) ExchangeActions(handler common.Address, token1Addr common.Address, token2Addr common.Address, ...) *Actions
- func (c *CurveClient) ExchangeUnderlyingActions(handler common.Address, token1Addr common.Address, token2Addr common.Address, ...) *Actions
- func (c *CurveClient) RemoveLiquidityActions(handler common.Address, pool common.Address, tokenI common.Address, ...) *Actions
- type DefiClient
- func (c *DefiClient) Aave() *AaveClient
- func (c *DefiClient) BalanceOf(coin coinType) (*big.Int, error)
- func (c *DefiClient) Balancer() *BalancerClient
- func (c *DefiClient) CombineActions(actions *Actions) ([]common.Address, [][]byte, *big.Int, error)
- func (c *DefiClient) Compound() *CompoundClient
- func (c *DefiClient) Curve() *CurveClient
- func (c *DefiClient) ExecuteActions(actions *Actions) error
- func (c *DefiClient) ExecuteActionsWithGasPrice(actions *Actions, gasPrice *big.Int) error
- func (c *DefiClient) Kyberswap() *KyberswapClient
- func (c *DefiClient) Maker() *MakerClient
- func (c *DefiClient) SuggestGasPrice(blockNum *big.Int) (*big.Int, error)
- func (c *DefiClient) SupplyFundActions(size *big.Int, coin coinType) *Actions
- func (c *DefiClient) Sushiswap() *SushiswapClient
- func (c *DefiClient) Uniswap() *UniswapClient
- func (c *DefiClient) Yearn() *YearnClient
- type KyberswapClient
- type MakerClient
- func (c *MakerClient) DepositCollateralActions(collateralAmount *big.Int, collateralType coinType, cdp *big.Int) *Actions
- func (c *MakerClient) GenerateDaiAction(collateralAmount *big.Int, daiAmount *big.Int, collateralType coinType) *Actions
- func (c *MakerClient) WipeAction(daiAmount *big.Int, cdp *big.Int) *Actions
- type ReserveData
- type SushiswapClient
- type TxHash
- type UniswapClient
- func (c *UniswapClient) FlashSwapActions(size *big.Int, coinBorrow coinType, coinRepay coinType, actions *Actions) *Actions
- func (c *UniswapClient) Swap(size int64, baseCurrency coinType, quoteCurrency coinType, ...) error
- func (c *UniswapClient) SwapActions(size *big.Int, baseCurrency coinType, quoteCurrency coinType) *Actions
- type YearnClient
Constants ¶
const ( // StableRate https://medium.com/aave/aave-borrowing-rates-upgraded-f6c8b27973a7 StableRate rateModel = 1 // VariableRate https://medium.com/aave/aave-borrowing-rates-upgraded-f6c8b27973a7 VariableRate rateModel = 2 )
const ( // ETH is ether. ETH coinType = iota // BAT is basic attention token. BAT coinType = iota // COMP is the governance token for Compound. COMP coinType = iota // DAI is the stable coin. DAI coinType = iota // REP is Augur reputation token. REP coinType = iota // SAI is Single Collateral DAI. SAI coinType = iota // UNI is the governance token for Uniswap. UNI coinType = iota // USDC is the stable coin by Circle. USDC coinType = iota // USDT is the stable coin. USDT coinType = iota // WBTC is wrapped BTC. WBTC coinType = iota // ZRX is the utility token for 0x. ZRX coinType = iota // BUSD is the Binance USD token. BUSD coinType = iota // YFI is the yearn governance token. YFI coinType = iota // AAVE is the Aave governance token. AAVE coinType = iota )
const ( FurucomboAddr string = "0xfFffFffF2ba8F66D4e51811C5190992176930278" // ProxyAddr is the address of the proxy contract. ProxyAddr string = "0x57805e5a227937bac2b0fdacaa30413ddac6b8e1" )
Variables ¶
var CoinToAddressMap = map[coinType]common.Address{ ETH: common.HexToAddress("0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"), BAT: common.HexToAddress("0x0d8775f648430679a709e98d2b0cb6250d2887ef"), COMP: common.HexToAddress("0xc00e94cb662c3520282e6f5717214004a7f26888"), DAI: common.HexToAddress("0x6b175474e89094c44da98b954eedeac495271d0f"), USDC: common.HexToAddress("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"), USDT: common.HexToAddress("0xdac17f958d2ee523a2206206994597c13d831ec7"), BUSD: common.HexToAddress("0x4Fabb145d64652a948d72533023f6E7A623C7C53"), // contains filtered or unexported fields }
CoinToAddressMap returns a mapping from coin to address
var CoinToCompoundMap = map[coinType]common.Address{ ETH: common.HexToAddress("0x4ddc2d193948926d02f9b1fe9e1daa0718270ed5"), DAI: common.HexToAddress("0x5d3a536e4d6dbd6114cc1ead35777bab948e3643"), USDC: common.HexToAddress("0x39aa39c021dfbae8fac545936693ac917d5e7563"), }
CoinToCompoundMap returns a mapping from coin to compound address
var CoinToIlkMap = map[coinType][32]byte{ ETH: byte32PutString("4554482d41000000000000000000000000000000000000000000000000000000"), YFI: byte32PutString("5946492d41000000000000000000000000000000000000000000000000000000"), USDC: byte32PutString("555344432d420000000000000000000000000000000000000000000000000000"), USDT: byte32PutString("555344542d410000000000000000000000000000000000000000000000000000"), UNI: byte32PutString("554e4956324441494554482d4100000000000000000000000000000000000000"), AAVE: byte32PutString("414156452d410000000000000000000000000000000000000000000000000000"), }
CoinToIlkMap maps the coin type to the corresponding Ilk as found in here: https://etherscan.io/address/0x8b4ce5DCbb01e0e1f0521cd8dCfb31B308E52c24 Ilk is a MakerDao collateral type, each Ilk correspond to a type of collateral and user can query it's name, symbol, dec, gem, pip, join and flip.
var CoinToJoinMap = map[coinType]common.Address{ DAI: common.HexToAddress("0x9759A6Ac90977b93B58547b4A71c78317f391A28"), ETH: common.HexToAddress("0x2F0b23f53734252Bda2277357e97e1517d6B042A"), USDC: common.HexToAddress("0x2600004fd1585f7270756DDc88aD9cfA10dD0428"), YFI: common.HexToAddress("0x3ff33d9162aD47660083D7DC4bC02Fb231c81677"), USDT: common.HexToAddress("0x0Ac6A1D74E84C2dF9063bDDc31699FF2a2BB22A2"), UNI: common.HexToAddress("0x2502F65D77cA13f183850b5f9272270454094A08"), AAVE: common.HexToAddress("0x24e459F61cEAa7b1cE70Dbaea938940A7c5aD46e"), }
CoinToJoinMap maps the coin type to its corresponding Join which is a MakerDao terminology meaning an adapter to deposit and withdraw unlocked collateral.
Functions ¶
Types ¶
type AaveClient ¶
type AaveClient struct {
// contains filtered or unexported fields
}
AaveClient is an instance of Aave protocol.
func (*AaveClient) Borrow ¶
func (c *AaveClient) Borrow(size *big.Int, coin coinType, interestRate rateModel) error
Borrow borrow money from lending pool.
func (*AaveClient) FlashLoanActions ¶
func (c *AaveClient) FlashLoanActions(size *big.Int, coin coinType, actions *Actions) *Actions
FlashLoanActions create an action to perform Uniswap flashloan.
func (*AaveClient) GetUserReserveData ¶
func (c *AaveClient) GetUserReserveData(addr common.Address, user common.Address) (ReserveData, error)
GetUserReserveData get the reserve data.
type BalancerClient ¶
type BalancerClient struct {
// contains filtered or unexported fields
}
BalancerClient is an instance of Balancer protocol.
type CompoundClient ¶
type CompoundClient struct {
// contains filtered or unexported fields
}
CompoundClient is an instance of Compound protocol.
func (*CompoundClient) BalanceOf ¶
func (c *CompoundClient) BalanceOf(coin coinType) (*big.Int, error)
BalanceOf return the balance of given cToken.
func (*CompoundClient) BalanceOfUnderlying ¶
func (c *CompoundClient) BalanceOfUnderlying(coin coinType) (*types.Transaction, error)
BalanceOfUnderlying return the balance of given cToken
func (*CompoundClient) Redeem ¶
func (c *CompoundClient) Redeem(amount int64, coin coinType) error
Redeem supplies token to compound.
func (*CompoundClient) RedeemActions ¶
func (c *CompoundClient) RedeemActions(size *big.Int, coin coinType) *Actions
RedeemActions create a Compound redeem action to be executed.
func (*CompoundClient) Supply ¶
func (c *CompoundClient) Supply(amount int64, coin coinType) error
Supply supplies token to compound.
func (*CompoundClient) SupplyActions ¶
func (c *CompoundClient) SupplyActions(size *big.Int, coin coinType) *Actions
SupplyActions create a supply action to supply asset to Compound.
type CurveClient ¶
type CurveClient struct {
// contains filtered or unexported fields
}
CurveClient struct
func (*CurveClient) AddLiquidityActions ¶
func (c *CurveClient) AddLiquidityActions( handler common.Address, pool common.Address, tokens []common.Address, amounts []*big.Int, minAmount *big.Int) *Actions
AddLiquidityActions adds liqudity to the given pool. `handler` is the address of the Curve pool. `pool` is the address of the pool token, e.g. bCRV token or 3CRV token. `tokens` is the addresses of the tokens that is in the pool. `amounts` is how much amount of each tokens you want to deposit. `minAmount` is the minimum amount of pool token that you want to get back as a result.
func (*CurveClient) ExchangeActions ¶
func (c *CurveClient) ExchangeActions( handler common.Address, token1Addr common.Address, token2Addr common.Address, i *big.Int, j *big.Int, dx *big.Int, minDy *big.Int) *Actions
ExchangeActions creates a Curve exchange action to swap from one stable coin to another.
func (*CurveClient) ExchangeUnderlyingActions ¶
func (c *CurveClient) ExchangeUnderlyingActions(handler common.Address, token1Addr common.Address, token2Addr common.Address, i *big.Int, j *big.Int, dx *big.Int, minDy *big.Int) *Actions
ExchangeUnderlyingActions creates a Curve exchangeUnderlying action. `handler` is the address of the Curve pool. `token1Addr` is the address of the input token. `token2Addr` is the address of the output token. `i` is the index of the input token in the pool. `j` is the index of the output token in the pool. `dx` is the amount of the input token that you want to swap `minDy` is the minimum amount of the output token that you want to receive.
func (*CurveClient) RemoveLiquidityActions ¶
func (c *CurveClient) RemoveLiquidityActions( handler common.Address, pool common.Address, tokenI common.Address, tokenAmount *big.Int, i *big.Int, minAmount *big.Int, ) *Actions
RemoveLiquidityActions creates remove liquidity action on Curve. `handler` is the address of the Curve pool. `pool` is the address of the pool token, e.g. bCRV token or 3CRV token. `tokenI` is the addresse of the tokens that you want to remove. `tokenAmount` is how much amount of token you want to deposit. `i` is the index of the token in the given pool. `minAmount` is the minimum amount of the underlying token that you want to get back as a result.
type DefiClient ¶
type DefiClient struct {
// contains filtered or unexported fields
}
DefiClient is the struct that stores the information.
func NewClient ¶
func NewClient(opts *bind.TransactOpts, ethClient *ethclient.Client) *DefiClient
NewClient Create a new client opts can be created using your private key ethclient can be created when you dial an ETH end point
func (*DefiClient) Aave ¶
func (c *DefiClient) Aave() *AaveClient
Aave returns an Aave client which contains functions that you can use to interact with Aave.
func (*DefiClient) BalanceOf ¶
func (c *DefiClient) BalanceOf(coin coinType) (*big.Int, error)
BalanceOf returns the balance of a given coin.
func (*DefiClient) Balancer ¶
func (c *DefiClient) Balancer() *BalancerClient
Balancer creates a new instance of BalancerClient
func (*DefiClient) CombineActions ¶
CombineActions takes in an `Actions` and returns a slice of handler address and a slice of call data if the combine is not successful, it will return the error.
func (*DefiClient) Compound ¶
func (c *DefiClient) Compound() *CompoundClient
Compound returns a compound client.
func (*DefiClient) ExecuteActions ¶
func (c *DefiClient) ExecuteActions(actions *Actions) error
ExecuteActions sends one transaction for all the Defi interactions.
func (*DefiClient) ExecuteActionsWithGasPrice ¶
func (c *DefiClient) ExecuteActionsWithGasPrice(actions *Actions, gasPrice *big.Int) error
ExecuteActionsWithGasPrice sends one transaction for all the Defi interactions with given gasPrice.
func (*DefiClient) Kyberswap ¶
func (c *DefiClient) Kyberswap() *KyberswapClient
Kyberswap returns a Kyberswap client.
func (*DefiClient) Maker ¶
func (c *DefiClient) Maker() *MakerClient
Maker creates a new instance of MakerClient
func (*DefiClient) SuggestGasPrice ¶
SuggestGasPrice provides an estimation of the gas price based on the `blockNum`. If the blockNum is `nil`, it will automatically use the latest block data. The user can also specify a specific `blockNum` so that block will be used for the prediction.
func (*DefiClient) SupplyFundActions ¶
func (c *DefiClient) SupplyFundActions(size *big.Int, coin coinType) *Actions
SupplyFundActions transfer a certain amount of fund to the proxy
func (*DefiClient) Sushiswap ¶
func (c *DefiClient) Sushiswap() *SushiswapClient
Sushiswap returns a Sushiswap client.
func (*DefiClient) Uniswap ¶
func (c *DefiClient) Uniswap() *UniswapClient
Uniswap returns a uniswap client.
type KyberswapClient ¶
type KyberswapClient struct {
// contains filtered or unexported fields
}
KyberswapClient struct
func (*KyberswapClient) SwapActions ¶
func (c *KyberswapClient) SwapActions(size *big.Int, baseCurrency coinType, quoteCurrency coinType) *Actions
SwapActions creates a swap action.
type MakerClient ¶
type MakerClient struct {
// contains filtered or unexported fields
}
MakerClient is an instance of Maker protocol.
func (*MakerClient) DepositCollateralActions ¶
func (c *MakerClient) DepositCollateralActions(collateralAmount *big.Int, collateralType coinType, cdp *big.Int) *Actions
DepositCollateralActions deposits additional collateral to the given vault.
func (*MakerClient) GenerateDaiAction ¶
func (c *MakerClient) GenerateDaiAction(collateralAmount *big.Int, daiAmount *big.Int, collateralType coinType) *Actions
GenerateDaiAction generate an action to create a vault and get some DAI
func (*MakerClient) WipeAction ¶
WipeAction creates a wipe action to decrease debt for th given cdp/vault.
type ReserveData ¶
type ReserveData struct { CurrentATokenBalance *big.Int CurrentBorrowBalance *big.Int PrincipalBorrowBalance *big.Int BorrowRateMode *big.Int BorrowRate *big.Int LiquidityRate *big.Int OriginationFee *big.Int VariableBorrowIndex *big.Int LastUpdateTimestamp *big.Int UsageAsCollateralEnabled bool }
ReserveData is a struct described the status of Aave lending pool.
type SushiswapClient ¶
type SushiswapClient struct {
// contains filtered or unexported fields
}
SushiswapClient struct
func (*SushiswapClient) SwapActions ¶
func (c *SushiswapClient) SwapActions(size *big.Int, baseCurrency coinType, quoteCurrency coinType) *Actions
SwapActions create a new swap action.
type UniswapClient ¶
type UniswapClient struct {
// contains filtered or unexported fields
}
UniswapClient struct
func (*UniswapClient) FlashSwapActions ¶
func (c *UniswapClient) FlashSwapActions(size *big.Int, coinBorrow coinType, coinRepay coinType, actions *Actions) *Actions
FlashSwapActions create an action to perform flash swap on Uniswap.
func (*UniswapClient) Swap ¶
func (c *UniswapClient) Swap(size int64, baseCurrency coinType, quoteCurrency coinType, receipient common.Address) error
Swap in the Uniswap Exchange.
func (*UniswapClient) SwapActions ¶
func (c *UniswapClient) SwapActions(size *big.Int, baseCurrency coinType, quoteCurrency coinType) *Actions
SwapActions create a new swap action.
type YearnClient ¶
type YearnClient struct {
// contains filtered or unexported fields
}
YearnClient is an instance of Compound protocol.
func (*YearnClient) AddLiquidityActions ¶
func (c *YearnClient) AddLiquidityActions(size *big.Int, coin coinType) *Actions
AddLiquidityActions creates an add liquidity action to Yearn.
func (*YearnClient) RemoveLiquidityActions ¶
func (c *YearnClient) RemoveLiquidityActions(size *big.Int, coin coinType) *Actions
RemoveLiquidityActions creates a remove liquidity action to Yearn.