Skip to content

Commit

Permalink
(fix) Updated examples for oracle price requests
Browse files Browse the repository at this point in the history
  • Loading branch information
abel committed Jan 17, 2024
1 parent b0f68ed commit b88f684
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
12 changes: 8 additions & 4 deletions examples/exchange/oracle/1_StreamPrices/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@ import (
"context"
"encoding/json"
"fmt"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"

"github.com/InjectiveLabs/sdk-go/client/common"
exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange"
)

func main() {
network := common.LoadNetwork("mainnet", "lb")
network := common.LoadNetwork("testnet", "lb")
exchangeClient, err := exchangeclient.NewExchangeClient(network)
if err != nil {
panic(err)
}

ctx := context.Background()
baseSymbol := "BTC"
quoteSymbol := "USDT"
oracleType := "bandibc"
marketsAssistant, err := chainclient.NewMarketsAssistantInitializedFromChain(ctx, exchangeClient)
market := marketsAssistant.AllDerivativeMarkets()["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"]

baseSymbol := market.OracleBase
quoteSymbol := market.OracleQuote
oracleType := market.OracleType
stream, err := exchangeClient.StreamPrices(ctx, baseSymbol, quoteSymbol, oracleType)
if err != nil {
panic(err)
Expand Down
14 changes: 9 additions & 5 deletions examples/exchange/oracle/2_Price/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,27 @@ import (
"context"
"encoding/json"
"fmt"
chainclient "github.com/InjectiveLabs/sdk-go/client/chain"

"github.com/InjectiveLabs/sdk-go/client/common"
exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange"
)

func main() {
network := common.LoadNetwork("mainnet", "lb")
network := common.LoadNetwork("testnet", "lb")
exchangeClient, err := exchangeclient.NewExchangeClient(network)
if err != nil {
panic(err)
}

ctx := context.Background()
baseSymbol := "BTC"
quoteSymbol := "USDT"
oracleType := "BandIBC"
oracleScaleFactor := uint32(6)
marketsAssistant, err := chainclient.NewMarketsAssistantInitializedFromChain(ctx, exchangeClient)
market := marketsAssistant.AllDerivativeMarkets()["0x17ef48032cb24375ba7c2e39f384e56433bcab20cbee9a7357e4cba2eb00abe6"]

baseSymbol := market.OracleBase
quoteSymbol := market.OracleQuote
oracleType := market.OracleType
oracleScaleFactor := uint32(0)
res, err := exchangeClient.GetPrice(ctx, baseSymbol, quoteSymbol, oracleType, oracleScaleFactor)
if err != nil {
fmt.Println(err)
Expand Down

0 comments on commit b88f684

Please sign in to comment.