staking_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: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HarvestFarmInvestContract = "0x72c8757145bd5a39e4435461B8813d623EC1B5F4"
)

Variables

View Source
var APYOfPoolInfo = make(map[common.Address]*APYOfPool)
View Source
var (
	SushiswapStakingPool = common.HexToAddress("0xc2EdaD668740f1aA35E4D8f227fB8E17dcA888Cd")
)
View Source
var WETHAddr = common.HexToAddress("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2")

Functions

func CalcAPY

func CalcAPY(contractAddr common.Address) (*big.Int, error)

CalcAPY return APY * 10**18

func CalcCurrentPriceOfStaking

func CalcCurrentPriceOfStaking(poolAddr, userAddr common.Address) (*big.Int, *big.Float, error)

CalcCurrentPriceOfStaking return user stakedAmount & stakedValue

func CalcInitPriceOfStaking

func CalcInitPriceOfStaking(opsRecord []*StakingOps) (*big.Float, error)

func GetAPYOfPools

func GetAPYOfPools()

func GetTotalSupplyAtHeight

func GetTotalSupplyAtHeight(poolAddr *common.Address, height *big.Int) (*big.Int, error)

func UpdatePoolInfoDaemon

func UpdatePoolInfoDaemon(ctx context.Context)

func UpdatePoolInfoEveryDay

func UpdatePoolInfoEveryDay() error

Types

type APYOfPool

type APYOfPool struct {
	LPAddr     common.Address
	APY        *big.Int
	PoolID     *big.Int
	AllocPoint *big.Int
	Token0Name string
	Token1Name string
	Token0Addr common.Address
	Token1Addr common.Address
}

type HarvestFarmInvest

type HarvestFarmInvest struct{}

func (*HarvestFarmInvest) ClaimReward

func (h *HarvestFarmInvest) ClaimReward(userAddr common.Address, pool common.Address) (*claimRewardResult, error)

func (*HarvestFarmInvest) Exit

func (h *HarvestFarmInvest) Exit(user common.Address, pool common.Address) (*exitResult, error)

func (*HarvestFarmInvest) Stake

func (h *HarvestFarmInvest) Stake(value *big.Int, amount *big.Int, userAddr common.Address, vault common.Address) (*stakeResult, error)

Stake is Deposit indeed

func (*HarvestFarmInvest) Withdraw

func (h *HarvestFarmInvest) Withdraw(userAddr common.Address, pool common.Address, amount *big.Int) (*withdrawResult, error)

type HarvestFarmReward

type HarvestFarmReward struct{}

func (*HarvestFarmReward) ClaimReward

func (r *HarvestFarmReward) ClaimReward(user common.Address, pool common.Address) (*claimRewardResult, error)

func (*HarvestFarmReward) Exit

func (r *HarvestFarmReward) Exit(userAddr common.Address, pool common.Address) (*exitResult, error)

func (*HarvestFarmReward) Stake

func (r *HarvestFarmReward) Stake(value *big.Int, amount *big.Int, userAddr common.Address, pool common.Address) (*stakeResult, error)

func (*HarvestFarmReward) Withdraw

func (r *HarvestFarmReward) Withdraw(userAddr common.Address, pool common.Address, amount *big.Int) (*withdrawResult, error)

type IPoolStakingAgent

type IPoolStakingAgent interface {
	Stake(value *big.Int, amount *big.Int, userAddr common.Address, pool common.Address) (*stakeResult, error)
	ClaimReward(userAddr common.Address, pool common.Address) (*claimRewardResult, error)
	Withdraw(userAddr common.Address, pool common.Address, amount *big.Int) (*withdrawResult, error)
	Exit(userAddr common.Address, pool common.Address) (*exitResult, error)
}

func New

func New(dex string) (IPoolStakingAgent, error)

type InfoOfPool

type InfoOfPool struct {
	LPTotalSupply       *big.Int
	Reserve0            *big.Int
	Reserve1            *big.Int
	BalanceOfMasterChif *big.Int
	Token0Addr          common.Address
	Token1Addr          common.Address
}

func GetInfoFromLPPool

func GetInfoFromLPPool(lpContract common.Address) (*InfoOfPool, error)

type PoolInfoInMChif

type PoolInfoInMChif struct {
	PoolID          *big.Int
	PoolAddr        common.Address
	AllocPoint      *big.Int
	TotalAllocPoint *big.Int
}

type Reserves

type Reserves struct {
	Reserve0           *big.Int
	Reserve1           *big.Int
	BlockTimestampLast uint32
}

func GetReservesAtHeight

func GetReservesAtHeight(poolAddr *common.Address, height *big.Int) (*Reserves, error)

type StakingOps

type StakingOps struct {
	Platform    string
	Action      string // deposit || withdraw
	Amount      *big.Int
	Timestamp   int64
	BlockHeight string
	LPSymbol    string
	LPAddr      common.Address
}

func GetUserOpsInMasterChif

func GetUserOpsInMasterChif(userAddr common.Address) ([]*StakingOps, error)

get user deposit withdraw history in SushiMasterChif

type Sushiswap

type Sushiswap struct{}

func (*Sushiswap) ClaimReward

func (s *Sushiswap) ClaimReward(userAddr common.Address, pool common.Address) (*claimRewardResult, error)

func (*Sushiswap) Exit

func (s *Sushiswap) Exit(userAddr common.Address, pool common.Address) (*exitResult, error)

func (*Sushiswap) Stake

func (s *Sushiswap) Stake(value *big.Int, amount *big.Int, userAddr common.Address, pool common.Address) (*stakeResult, error)

Pool is LP token addr

func (*Sushiswap) Withdraw

func (s *Sushiswap) Withdraw(userAddr common.Address, pool common.Address, amount *big.Int) (*withdrawResult, error)

type UniswapV2

type UniswapV2 struct{}

func (*UniswapV2) ClaimReward

func (u *UniswapV2) ClaimReward(userAddr common.Address, pool common.Address) (*claimRewardResult, error)

func (*UniswapV2) Exit

func (u *UniswapV2) Exit(userAddr common.Address, pool common.Address) (*exitResult, error)

func (*UniswapV2) Stake

func (u *UniswapV2) Stake(value *big.Int, amount *big.Int, userAddr common.Address, pool common.Address) (*stakeResult, error)

func (*UniswapV2) Withdraw

func (u *UniswapV2) Withdraw(userAddr common.Address, pool common.Address, amount *big.Int) (*withdrawResult, error)

@param amount nil = withdraw all

Jump to

Keyboard shortcuts

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