This commit is contained in:
Laurent Le Houerou 2021-11-09 09:45:18 +04:00
parent 22b69e5bf5
commit 0da2e12fa2
10 changed files with 32 additions and 17 deletions

View File

@ -12,11 +12,11 @@ import (
type WBNB struct { type WBNB struct {
evm.Token evm.Token
client evm.Client client *Client
contract *contracts.WBnb contract *contracts.WBnb
} }
func NewWBNB(client evm.Client) (*WBNB, error) { func NewWBNB(client *Client) (*WBNB, error) {
address, err := client.TokenService().TokenAddressBySymbol("WBNB") address, err := client.TokenService().TokenAddressBySymbol("WBNB")
if err != nil { if err != nil {
return nil, errors.Wrap(err, "getting wbnb address") return nil, errors.Wrap(err, "getting wbnb address")

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"math/big" "math/big"
"git.lehouerou.net/laurent/evm/bsc"
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/pancakeswap/contracts" "git.lehouerou.net/laurent/evm/pancakeswap/contracts"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
@ -16,13 +18,13 @@ import (
const MasterChefAddress = "0x73feaa1eE314F8c655E354234017bE2193C9E24E" const MasterChefAddress = "0x73feaa1eE314F8c655E354234017bE2193C9E24E"
type MasterChef struct { type MasterChef struct {
client evm.Client client *bsc.Client
contract *contracts.MasterChef contract *contracts.MasterChef
cake evm.Token cake evm.Token
} }
func NewMasterChef(client evm.Client) (*MasterChef, error) { func NewMasterChef(client *bsc.Client) (*MasterChef, error) {
c, err := contracts.NewMasterChef(common.HexToAddress(MasterChefAddress), client) c, err := contracts.NewMasterChef(common.HexToAddress(MasterChefAddress), client)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"math/big" "math/big"
"git.lehouerou.net/laurent/evm/bsc"
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/pancakeswap/contracts" "git.lehouerou.net/laurent/evm/pancakeswap/contracts"
@ -19,12 +21,12 @@ const (
) )
type NftMarket struct { type NftMarket struct {
client evm.Client client *bsc.Client
contract *contracts.NftMarket contract *contracts.NftMarket
wbnb evm.Token wbnb evm.Token
} }
func NewNftMarket(client evm.Client) (*NftMarket, error) { func NewNftMarket(client *bsc.Client) (*NftMarket, error) {
contract, err := contracts.NewNftMarket(common.HexToAddress(MarketAddress), client) contract, err := contracts.NewNftMarket(common.HexToAddress(MarketAddress), client)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")

View File

@ -2,6 +2,7 @@ package pancakeswap
import ( import (
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/bsc"
"git.lehouerou.net/laurent/evm/pancakeswap/contracts" "git.lehouerou.net/laurent/evm/pancakeswap/contracts"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -11,7 +12,7 @@ const (
RouterAddress = "0x10ED43C718714eb63d5aA57B78B54704E256024E" RouterAddress = "0x10ED43C718714eb63d5aA57B78B54704E256024E"
) )
func NewRouter(client evm.Client) (*evm.UniswapRouter, error) { func NewRouter(client *bsc.Client) (*evm.UniswapRouter, error) {
contract, err := contracts.NewRouter(common.HexToAddress(RouterAddress), client) contract, err := contracts.NewRouter(common.HexToAddress(RouterAddress), client)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")

View File

@ -3,6 +3,7 @@ package polycat
import ( import (
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/polycat/contracts" "git.lehouerou.net/laurent/evm/polycat/contracts"
"git.lehouerou.net/laurent/evm/polygon"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -14,7 +15,7 @@ type CatPair struct {
paircontract *contracts.CatPair paircontract *contracts.CatPair
} }
func NewCatPair(client evm.Client, address common.Address) (*CatPair, error) { func NewCatPair(client *polygon.Client, address common.Address) (*CatPair, error) {
t, err := client.TokenService().TokenByAddress(address) t, err := client.TokenService().TokenByAddress(address)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")

View File

@ -3,13 +3,14 @@ package polycat
import ( import (
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/polycat/contracts" "git.lehouerou.net/laurent/evm/polycat/contracts"
"git.lehouerou.net/laurent/evm/polygon"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
const CatRouterAddress = "0x94930a328162957FF1dd48900aF67B5439336cBD" const CatRouterAddress = "0x94930a328162957FF1dd48900aF67B5439336cBD"
func NewCatRouterService(c evm.Client) (*evm.UniswapRouter, error) { func NewCatRouterService(c *polygon.Client) (*evm.UniswapRouter, error) {
contract, err := contracts.NewCatRouter(common.HexToAddress(CatRouterAddress), c) contract, err := contracts.NewCatRouter(common.HexToAddress(CatRouterAddress), c)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"math/big" "math/big"
"git.lehouerou.net/laurent/evm/polygon"
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/polycat/contracts" "git.lehouerou.net/laurent/evm/polycat/contracts"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -18,11 +20,11 @@ const (
) )
type MasterchefService struct { type MasterchefService struct {
client evm.Client client *polygon.Client
contract *contracts.Masterchef contract *contracts.Masterchef
} }
func NewMasterchefService(c evm.Client) (*MasterchefService, error) { func NewMasterchefService(c *polygon.Client) (*MasterchefService, error) {
contract, err := contracts.NewMasterchef(common.HexToAddress(MasterchefAddress), c) contract, err := contracts.NewMasterchef(common.HexToAddress(MasterchefAddress), c)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"math/big" "math/big"
"git.lehouerou.net/laurent/evm/polygon"
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/polycat/contracts" "git.lehouerou.net/laurent/evm/polycat/contracts"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
@ -18,11 +20,11 @@ const (
) )
type Masterchefv2Service struct { type Masterchefv2Service struct {
client evm.Client client *polygon.Client
contract *contracts.MasterChefv2 contract *contracts.MasterChefv2
} }
func NewMasterchefv2Service(c evm.Client) (*Masterchefv2Service, error) { func NewMasterchefv2Service(c *polygon.Client) (*Masterchefv2Service, error) {
contract, err := contracts.NewMasterChefv2(common.HexToAddress(Masterchefv2Address), c) contract, err := contracts.NewMasterChefv2(common.HexToAddress(Masterchefv2Address), c)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"math/big" "math/big"
"git.lehouerou.net/laurent/evm/polygon"
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/polycat/contracts" "git.lehouerou.net/laurent/evm/polycat/contracts"
"github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind"
@ -16,11 +18,11 @@ import (
const RewardLockerAddress = "0xE0e44d4E7e61f2f4f990f5F4e2408D2187315C94" const RewardLockerAddress = "0xE0e44d4E7e61f2f4f990f5F4e2408D2187315C94"
type RewardLockerService struct { type RewardLockerService struct {
client evm.Client client *polygon.Client
contract *contracts.RewardLocker contract *contracts.RewardLocker
} }
func NewRewardLockerService(c evm.Client) (*RewardLockerService, error) { func NewRewardLockerService(c *polygon.Client) (*RewardLockerService, error) {
contract, err := contracts.NewRewardLocker(common.HexToAddress(RewardLockerAddress), c) contract, err := contracts.NewRewardLocker(common.HexToAddress(RewardLockerAddress), c)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")

View File

@ -4,6 +4,8 @@ import (
"context" "context"
"math/big" "math/big"
"git.lehouerou.net/laurent/evm/polygon"
"git.lehouerou.net/laurent/evm" "git.lehouerou.net/laurent/evm"
"git.lehouerou.net/laurent/evm/polycat/contracts" "git.lehouerou.net/laurent/evm/polycat/contracts"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
@ -13,11 +15,11 @@ import (
) )
type TankChefService struct { type TankChefService struct {
client evm.Client client *polygon.Client
contract *contracts.TankChef contract *contracts.TankChef
} }
func NewTankChefService(c evm.Client, address string) (*TankChefService, error) { func NewTankChefService(c *polygon.Client, address string) (*TankChefService, error) {
contract, err := contracts.NewTankChef(common.HexToAddress(address), c) contract, err := contracts.NewTankChef(common.HexToAddress(address), c)
if err != nil { if err != nil {
return nil, errors.Wrap(err, "init contract") return nil, errors.Wrap(err, "init contract")