add smartchef harvest method
This commit is contained in:
parent
005d54e57d
commit
ee4bb4c23d
1
pancakeswap/contracts/smartchef.abi
Normal file
1
pancakeswap/contracts/smartchef.abi
Normal file
File diff suppressed because one or more lines are too long
2171
pancakeswap/contracts/smartchef.go
Normal file
2171
pancakeswap/contracts/smartchef.go
Normal file
File diff suppressed because one or more lines are too long
35
pancakeswap/smartchef.go
Normal file
35
pancakeswap/smartchef.go
Normal file
@ -0,0 +1,35 @@
|
||||
package pancakeswap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math/big"
|
||||
|
||||
"git.lehouerou.net/laurent/evm"
|
||||
"git.lehouerou.net/laurent/evm/bsc"
|
||||
"git.lehouerou.net/laurent/evm/pancakeswap/contracts"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type SmartChef struct {
|
||||
client *bsc.Client
|
||||
contract *contracts.SmartChef
|
||||
}
|
||||
|
||||
func NewSmartChef(client *bsc.Client, address common.Address) (*SmartChef, error) {
|
||||
contract, err := contracts.NewSmartChef(address, client)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "init contract")
|
||||
}
|
||||
return &SmartChef{
|
||||
client: client,
|
||||
contract: contract,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *SmartChef) Harvest(ctx context.Context) (evm.Transaction, error) {
|
||||
return s.client.Execute(ctx, func(ctx context.Context, opts *evm.TransactOpts) (*types.Transaction, error) {
|
||||
return s.contract.Deposit(opts.TransactOpts, big.NewInt(0))
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user