xoracle-go-sdk

command module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: GPL-3.0 Imports: 3 Imported by: 0

README

xOracle go sdk

The xoracle-go-sdk package provides a Go client for the xOracle API.

Installation

To install the package, you need to have Go installed on your system. You can download and install Go from the official website: https://golang.org/dl/

Once you have Go installed, you can install the package using the following command:

go get github.com/Crown-Labs/xoracle-go-sdk

This will download and install the package and its dependencies.

Available Functions

  • GetTokenIndexPrice()
  • GetTokenAddressPrice(networkId int)
  • GetTokenIndexInfo()
  • GetNodeInfo()

Usage

To use the package, you need to import it in your Go code:

package main

import (
	"fmt"

	"github.com/Crown-Labs/xoracle-go-sdk/api"
	"github.com/Crown-Labs/xoracle-go-sdk/common"
)

func main() {
	// Create new xoracle instance
	xOracle := api.NewApi([]int{
		common.TOKEN_INDEX.BTC,
		common.TOKEN_INDEX.ETH,
		common.TOKEN_INDEX.BNB,
		common.TOKEN_INDEX.BUSD,
		common.TOKEN_INDEX.USDC,
		common.TOKEN_INDEX.MATIC,
		common.TOKEN_INDEX.OP,
		common.TOKEN_INDEX.ARB,
	})

	// Get token prices
	networkId := common.NETWORK_ID.LINEA_TESTNET
	tokenAddressPrices, err := xOracle.GetTokenAddressPrice(networkId)
	if err != nil {
		fmt.Println(err)
	}

	// Logs token prices
	for _, price := range tokenAddressPrices {
		fmt.Printf("TokenAddress: %s, Price: %s, Price 30 Decimals: %s\n",
			price.TokenAddress,
			price.Price.String(),
			common.ConvertPriceDecimals(price.Price, 30).String(),
		)
	}
}

In this code, we import the xoracle-go-sdk package, create an instance of the xOracle Api using the NewApi function, and use its methods to interact with the xOracle API. We get the token index prices using the GetTokenIndexPrice method, the token address prices for a specific network using the GetTokenAddressPrice method, and the token index info using the GetTokenIndexInfo method.

Contributing

If you want to contribute to the project, you can fork the repository and create a pull request with your changes. Please make sure to follow the coding style and conventions used in the project.

License

This project is licensed under the GPL-3.0 license. See the LICENSE file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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