helper

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PolygonRPC = "https://polygon-rpc.com/"

	PolygonChainID = 137
	WMaticAddr     = "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270"
	WETHAddr       = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
	UsdcAddr       = "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"
	AmpAddr        = "0x0621d647cecbFb64b79E44302c1933cB4f27054d"
)
View Source
const (
	ContractV3Factory            = "0x1F98431c8aD98523631AE4a59f267346ea31F984"
	ContractV3SwapRouterV1       = "0xE592427A0AEce92De3Edee1F18E0157C05861564"
	ContractV3SwapRouterV2       = "0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45"
	ContractV3NFTPositionManager = "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"
	ContractV3Quoter             = "0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6"
)

Variables

View Source
var (
	WMATIC = coreEntities.NewToken(PolygonChainID, common.HexToAddress(WMaticAddr), 18, "Matic", "Matic Network(PolyGon)")
	AMP    = coreEntities.NewToken(PolygonChainID, common.HexToAddress(AmpAddr), 18, "AMP", "Amp")
	USDC   = coreEntities.NewToken(PolygonChainID, common.HexToAddress(UsdcAddr), 6, "USDC", "USD Coin")
)

Functions

func ConstructV3Pool

func ConstructV3Pool(client *ethclient.Client, token0, token1 *coreEntities.Token, poolFee uint64) (*entities.Pool, error)

func FloatStringToBigInt

func FloatStringToBigInt(amount string, decimals int) *big.Int

func GetPoolAddress

func GetPoolAddress(client *ethclient.Client, token0, token1 common.Address, fee *big.Int) (common.Address, error)

func IntDivDecimal

func IntDivDecimal(v *big.Int, decimal int) *big.Int

func IntWithDecimal

func IntWithDecimal(v uint64, decimal int) *big.Int

func SendTX

func SendTX(client *ethclient.Client, toAddress common.Address, value *big.Int,
	data []byte, w *Wallet) (*types.Transaction, error)

SendTx Send a real transaction to the blockchain.

func TryTX

func TryTX(client *ethclient.Client, toAddress common.Address, value *big.Int,
	data []byte, w *Wallet) (*types.Transaction, error)

Trytx Trying to send a transaction, it just return the transaction hash if success.

Types

type Wallet

type Wallet struct {
	PrivateKey *ecdsa.PrivateKey
	PublicKey  common.Address
}

func InitWallet

func InitWallet(privateHexKeys string) *Wallet

func (Wallet) PubkeyStr

func (w Wallet) PubkeyStr() string

Jump to

Keyboard shortcuts

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