invest_factory

package
v0.0.0-...-8b20efb Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// contract with only the Invest method
	UniswapInvestAddress = common.HexToAddress("0x73a6DbA24743Ce32f645FeeD8c95F9e0d7494eb9")
	// contract with only the MultiAssetInvest method
	UniswapMultiInvestAddress = common.HexToAddress("")

	BalancerInvestAddress      = common.HexToAddress("")
	BalancerMultiInvestAddress = common.HexToAddress("")

	SushiswapInvestAddress = common.HexToAddress("0xa43a0d62de25527eb66dd9f00886f2ab9d1bd31e")
)

Functions

func ETH2WETH

func ETH2WETH(token common.Address, tokenInfos daemons.TokenInfos) common.Address

Types

type Balancer

type Balancer struct {
	DexPool
}

func (*Balancer) Estimate

func (b *Balancer) Estimate(amount *big.Int, token string, pool common.Address) (tokensOut map[string]*big.Int, poolTokenOut *big.Int, err error)

func (*Balancer) MultiAssetsInvest

func (b *Balancer) MultiAssetsInvest(investments []Investment, userAddress common.Address, pool common.Address) (*MultiAssetsInvestResult, error)

func (*Balancer) Prepare

func (b *Balancer) Prepare(amount *big.Int, userAddr common.Address, inToken string, pool common.Address, slippage int64, estimateLP *big.Int) (*PrepareResult, error)

func (*Balancer) RemoveLiquidity

func (b *Balancer) RemoveLiquidity(amount *big.Int, account, pool common.Address) (*RemoveLiquidityResult, error)

type DexPool

type DexPool struct {
	Daemon daemons.Daemon
}

func (DexPool) GetPoolBoundTokens

func (dp DexPool) GetPoolBoundTokens(pool common.Address) ([]types.PoolToken, error)

func (DexPool) GetPools

func (dp DexPool) GetPools() (daemons.PoolInfos, error)

func (DexPool) PackNecessaryAllowances

func (dp DexPool) PackNecessaryAllowances(al *alchemy.Alchemy, user, pool common.Address, investments ...Investment) (map[string]PrependApprove, error)

func (DexPool) RequireTokenBound

func (dp DexPool) RequireTokenBound(token common.Address, pool common.Address) bool

type EstimateResult

type EstimateResult struct {
	LP           string              `json:"LP"`
	Tokens       map[string][]string `json:"tokens"`
	InvestAmount string              `json:"invest_amount"`
}

type HarvestReward

type HarvestReward struct {
	DexPool
}

func (*HarvestReward) Estimate

func (h *HarvestReward) Estimate(amount *big.Int, inToken string, pool common.Address) (tokensOut map[string]*big.Int, poolTokenOut *big.Int, err error)

func (*HarvestReward) MultiAssetsInvest

func (h *HarvestReward) MultiAssetsInvest(investments []Investment, userAddress common.Address, pool common.Address) (*MultiAssetsInvestResult, error)

func (*HarvestReward) Prepare

func (h *HarvestReward) Prepare(amount *big.Int, userAddr common.Address, inToken string, pool common.Address, slippage int64, estimateLP *big.Int) (*PrepareResult, error)

func (*HarvestReward) RemoveLiquidity

func (h *HarvestReward) RemoveLiquidity(amount *big.Int, account, pool common.Address) (*RemoveLiquidityResult, error)

type IPoolInvestAgent

type IPoolInvestAgent interface {
	Estimate(amount *big.Int, inToken string, pool common.Address) (tokensOut map[string]*big.Int, poolTokenOut *big.Int, err error)
	Prepare(amount *big.Int, userAddr common.Address, inToken string, pool common.Address, slippage int64, estimateLP *big.Int) (*PrepareResult, error)
	GetPools() (daemons.PoolInfos, error)
	GetPoolBoundTokens(pool common.Address) ([]types.PoolToken, error)
	RequireTokenBound(token common.Address, pool common.Address) bool
	MultiAssetsInvest(investments []Investment, userAddress common.Address, pool common.Address) (*MultiAssetsInvestResult, error)
	RemoveLiquidity(amount *big.Int, account, pool common.Address) (*RemoveLiquidityResult, error)
}

func New

func New(dex string) (IPoolInvestAgent, error)

type Investment

type Investment struct {
	Symbol            string
	Address           common.Address
	Amount            *big.Int
	InfiniteAllowance bool

	// this will let abi.Pack informed of original ETH transfer
	ETH2WETH bool
}

type MultiAssetsInvestResult

type MultiAssetsInvestResult struct {
	NecessaryApproves map[string]PrependApprove
	Tokens            []estimatedToken
	ContractAddress   common.Address
	CallData          []byte
}

type PrepareResult

type PrepareResult struct {
	Data               string `json:"data"`
	TxFee              string `json:"tx_fee"`
	ContractAddr       string `json:"contract_addr"`
	FromTokenAddr      string `json:"from_token_addr"`
	FromTokenAmount    string `json:"from_token_amount"`
	Allowance          string `json:"allowance"`
	AllowanceSatisfied bool   `json:"allowance_satisfied"`
	AllowanceData      string `json:"allowance_data"`
}

type PrependApprove

type PrependApprove struct {
	Allowance *big.Int
	CallData  []byte
}

type RemoveLiquidityResult

type RemoveLiquidityResult struct {
	Approve  *PrependApprove
	CallData []byte
	Contract common.Address
}

type Sushiswap

type Sushiswap struct {
	DexPool
}

func (*Sushiswap) Estimate

func (s *Sushiswap) Estimate(amount *big.Int, token string, pool common.Address) (tokensOut map[string]*big.Int, lp *big.Int, err error)

func (*Sushiswap) MultiAssetsInvest

func (s *Sushiswap) MultiAssetsInvest(investments []Investment, userAddress common.Address, pool common.Address) (*MultiAssetsInvestResult, error)

func (*Sushiswap) Prepare

func (s *Sushiswap) Prepare(amount *big.Int, userAddr common.Address, inToken string, pool common.Address, slippage int64, estimateLP *big.Int) (*PrepareResult, error)

func (*Sushiswap) RemoveLiquidity

func (s *Sushiswap) RemoveLiquidity(amount *big.Int, account, pool common.Address) (*RemoveLiquidityResult, error)

type UniswapV2

type UniswapV2 struct {
	DexPool
}

func (*UniswapV2) Estimate

func (u *UniswapV2) Estimate(amount *big.Int, token string, pool common.Address) (tokensOut map[string]*big.Int, lp *big.Int, err error)

func (*UniswapV2) EstimateByTokenSymbols

func (u *UniswapV2) EstimateByTokenSymbols(amount *big.Int, inToken, token0, token1 string) (tokensOut map[string]*big.Int, lp *big.Int, err error)

TODO: autopilot exchange path because we are doing estimation, so ETH can be seen directly as WETH, although an extra step will indeed take place when doing the real deal

func (*UniswapV2) MultiAssetsInvest

func (u *UniswapV2) MultiAssetsInvest(investments []Investment, userAddress common.Address, pool common.Address) (*MultiAssetsInvestResult, error)

MultiAssetsInvest allows investers using their already owned token pair to add liquidity

func (*UniswapV2) Prepare

func (u *UniswapV2) Prepare(amount *big.Int, userAddr common.Address, inToken string, pool common.Address, slippage int64, estimateLP *big.Int) (*PrepareResult, error)

func (*UniswapV2) RemoveLiquidity

func (u *UniswapV2) RemoveLiquidity(amount *big.Int, account, pool common.Address) (*RemoveLiquidityResult, error)

Jump to

Keyboard shortcuts

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