multicall

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 7 Imported by: 0

README

multicall-go

The multi call of Golang

Usage

func GetPrice(ctx context.Context, pairAddress string) (*big.Int, error) {
	mc := multicall.NewMultiCall(multicall.ArbitrumTestnetRpc, 
		multicall.ArbitrumTestnetMultiCallAddress)
	
	calls := []*multicall.ViewCall{
		{"key-1", contract.PriceOracleMetaData.ABI,
			"0xe7F83e97BC5Fd77CCf4CD25c17Fcb566E7c62781",
			"getMarkPrice",
			[]interface{}{common.HexToAddress(pairAddress)}},
	}
	
	result, err := mc.CallTargets(ctx, calls)
	if err != nil {
		return nil, err
	}
	
	gotVal, ok := result["key-1"]
	if !ok {
		return nil, err
	} 
	
	price := gotVal[0].(*big.Int)
	return price, nil
}

Documentation

Index

Constants

View Source
const (
	EthMainnetRpc        = "https://rpc.ankr.com/eth"
	EthRopstenTestnetRPC = "https://ropsten.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
	EthRinkebyTestnetRPC = "https://rinkeby.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
	EthGoerliTestnetRPC  = "https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"
	EthKovanTestnetRPC   = "https://kovan.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161"

	EthMainnetMultiCallAddress        = "0x5BA1e12693Dc8F9c48aAD8770482f4739bEeD696"
	EthRopstenTestnetMultiCallAddress = "0x53c43764255c17bd724f74c4ef150724ac50a3ed"
	EthRinkebyTestnetMultiCallAddress = "0x42ad527de7d4e9d9d011ac45b31d8551f8fe9821"
	EthGoerliTestnetMultiCallAddress  = "0x77dca2c955b15e9de4dbbcf1246b4b85b651e50e"
	EthKovanTestnetMultiCallAddress   = "0x2cc8688c5f75e365aaeeb4ea8d6a480405a48d2a"
)

via: https://rpc.info/ and https://github.com/makerdao/multicall eth chain

View Source
const (
	BscMainnetRpc = "https://bsc-dataseed.binance.org/"
	BscTestnetRpc = "https://data-seed-prebsc-1-s1.binance.org:8545/"

	BscMainnetMultiCallAddress = "0x41263cba59eb80dc200f3e2544eda4ed6a90e76c"
	BscTestnetMultiCallAddress = "0xae11C5B5f29A6a25e955F0CB8ddCc416f522AF5C"
)

binance smart chain

View Source
const (
	MaticMainnetRpc = "https://polygon-rpc.com"
	MaticTestnetRpc = "https://rpc-mumbai.maticvigil.com"

	MaticMainnetMultiCallAddress = "0x275617327c958bD06b5D6b871E7f491D76113dd8"
	MaticTestnetMultiCallAddress = "0xe9939e7Ea7D7fb619Ac57f648Da7B1D425832631"
)

polygon matic chain

View Source
const (
	ArbitrumMainnetRpc = "https://arb1.arbitrum.io/rpc"
	ArbitrumTestnetRpc = "https://rinkeby.arbitrum.io/rpc"

	ArbitrumMainnetMultiCallAddress = "0x82D550B27bA4FD402aAD58ECe8C393FcEC6b4afa"
	ArbitrumTestnetMultiCallAddress = "0x96DB1F8055074aB62161B6Ad66Ab6B8679513DeF"
)

arbitrum One chain

Variables

This section is empty.

Functions

func NewMultiCall

func NewMultiCall(exploreRpc, multiAddress string) *multiCall

Types

type MultiCall

type MultiCall interface {
	CallTargets(ctx context.Context, calls []*ViewCall) (map[string][]interface{}, error)
}

type ViewCall

type ViewCall struct {
	Id        string
	TargetAbi string
	Target    string
	Method    string
	Arguments []interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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