Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@azuro-protocol/sdk

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@azuro-protocol/sdk

Azuro SDK

  • 0.4.13
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
2
Weekly downloads
 
Created
Source

@azuro-protocol/sdk

Is an SDK that will help you create better decentralized solutions in prediction markets.

Table of contents

Installation

  • Install NodeJS >= 14
  • Run npm install @azuro-protocol/sdk command to install

Usage

import { fetchGames } from '@azuro-protocol/sdk'
// Or if you're stuck with CommonJS
const azuro = require('@azuro-protocol/sdk')

An example of how to get started with the SDK

import {
  setContractAddresses,
  configure,
  setWalletProvider,
  setSelectedChainId
} from '@azuro-protocol/sdk'
import { Web3Provider } from '@ethersproject/providers'
import Web3 from 'web3'

const library = new Web3Provider(Web3.currentProvider)

setSelectedChainId(100)

setContractAddresses({
  core: '0x4fE6A9e47db94a9b2a4FfeDE8db1602FD1fdd37d',
  lp: '0xac004b512c33D029cf23ABf04513f1f380B3FD0a',
  bet: '0xFd9E5A2A1bfc8B57A288A3e12E2c601b0Cc7e476',
  token: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
})

configure({
  rpcUrl: 'https://rpc.xdaichain.com/',
  ipfsGateway: 'https://ipfs-gateway.azuro.org/ipfs/',
})

setWalletProvider(library)

API

fetchGames

This function synchronizes with the blockchain and gives you all the matches that are currently recorded in the blockchain.

You also have the option to filter out these matches if you don't want to receive past matches or cancelled matches.

You can specify the block number to start parsing games from. Better to parse only the latest games for performance reasons

Arguments:
ArgumentTypeDefaultDescription
filters.resolvedbooleantrueShould resolved games be present in the result list
filters.cancelledbooleantrueShould cancelled games be present in the result list
fromnumberNumber of transaction block to start parsing games from
Example:
import { fetchGames } from '@azuro-protocol/sdk'

await fetchGames({
  filters : {
    resolved: false,
    canceled: false,
  },
  from: 26746291,
})

An example of what you get when you use this function.

[
  {
    "country": "International Tournaments",
    "league": "Dota 2. DPC NA 2021/2022 Tour 3: Division I  - Group Stage",
    "participants": [
      {
        "name": "Wildcard Gaming",
        "image": "https://cdn.sfp.odds.ru/img/234655.png"
      },
      {
        "name": "Nouns",
        "image": "https://cdn.sfp.odds.ru/img/243075.png"
      }
    ],
    "scopeId": 1854,
    "leagueId": 700,
    "countryId": 258,
    "sportTypeId": 1000,
    "id": 1854,
    "state": 0,
    "startsAt": 1655841600000,
    "conditions": [
      {
        "paramId": null,
        "odds": [
          {
            "conditionId": 642,
            "outcomeId": 32,
            "outcomeRegistryId": 10009,
            "paramId": 1,
            "value": 2.9613596003664573
          },
          {
            "conditionId": 642,
            "outcomeId": 33,
            "outcomeRegistryId": 10010,
            "paramId": 1,
            "value": 1.3562682487845052
          }
        ]
      }
    ],
    "marketRegistryId": 19
  },
  ...]

To understand what identifiers to outcomeId and other parameters mean, see our IPFS list, where we store dictionary and descriptions.

Response object:
PropertyTypeDescription
idNumberGame ID
stateNumberGame status. 0 - Active. 1 - Resolved. 2 - Canceled
leagueStringContains info about league and round
countryStringLeague country
participantsArrayList of participants. Each participant has "name" and "image"
startsAtNumberTimestamp. Date when this game starts
marketRegistryIdNumberDictionary from this QmPWps8adamqZfnie6MutAsrYUQynQ8ckwFb3bggz2T4aU
conditionsArrayDictionary from OutcomeID QmQ34UYPPtpxJiWcVj4buh4HzFo4Z9gwGt5KRiprQN3fkT

setSelectedChainId

A function to set the chain id you will use for blockchain transactions.

import { setSelectedChainId } from '@azuro-protocol/sdk'
setSelectedChainId(100)

setContractAddresses

The function sets the contracts with which you will interact. These are the contracts of our protocol.

import { setContractAddresses } from '@azuro-protocol/sdk'

setContractAddresses({
    core: '0x4fE6A9e47db94a9b2a4FfeDE8db1602FD1fdd37d',
    lp: '0xac004b512c33D029cf23ABf04513f1f380B3FD0a',
    bet: '0xFd9E5A2A1bfc8B57A288A3e12E2c601b0Cc7e476',
    token: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d',
})

configure

The function sets the rpcUrl and ipfs that you will interact with.

import { configure } from '@azuro-protocol/sdk'

configure({
    rpcUrl: 'https://rpc.xdaichain.com/',
    ipfsGateway: 'https://ipfs-gateway.azuro.org/ipfs/',
})

setWalletProvider

The function allows you to set your wallet provider for further interaction.

import { setWalletProvider } from '@azuro-protocol/sdk'
import { JsonRpcProvider, Web3Provider } from '@ethersproject/providers'

//library: Web3Provider
setWalletProvider(library);

getLatestConditionsBlock

This method returns the number of latest block was fetched or null in case the games were never fetched yet

You can use this value as an argument from in the next invocation of method fetchGames to prevent fetching the same games twice

import { getLatestConditionsBlock } from '@azuro-protocol/sdk'

await fetchGames(/* ... */)

getLatestConditionsBlock() // number 

fetchAllowance

import { fetchAllowance } from '@azuro-protocol/sdk'

fetchAllowance(account) //account as string

calculateActualOdds

The odds of events change over time, so in order to always know the actual odds we have a method.

import { calculateActualOdds } from '@azuro-protocol/sdk'

await calculateActualOdds({
    conditionId,
    betAmount,
    outcomeId,
})

approve

This method allows you to set the amount you allow our smart contract to use.

import { approve } from '@azuro-protocol/sdk'
import { constants } from 'ethers'

approve(constants.MaxUint256)

placeBet

This method allows you to bet on an event.

import { placeBet } from '@azuro-protocol/sdk'

await placeBet({
    conditionId,
    outcomeId,
    betAmount,
    betRate,
    slippage,
})

fetchUserBets

This method gives a list of your bets.

import { fetchUserBets } from '@azuro-protocol/sdk'

await fetchUserBets(account)

An example of what you get when you use this function.

{
    "bets": [
        {
            "nftId": 145,
            "conditionId": 720,
            "paramId": 1,
            "marketRegistryId": 1,
            "outcomeRegistryId": 1,
            "rate": 2.062164217,
            "amount": 1,
            "result": -1,
            "createdAt": 1655913670000,
            "isRedeemed": false,
            "gameInfo": {
                "id": 1832,
                "country": "Brazil",
                "league": "Brasileiro Serie A - Round 14",
                "participants": [
                    {
                        "name": "Corinthians Paulista",
                        "image": "https://content.bookieratings.net/images/8e/o3/8eo376_20181001112205_100x100.png"
                    },
                    {
                        "name": "Santos",
                        "image": "https://content.bookieratings.net/images/et/z8/etz8q7_20181001112207_100x100.png"
                    }
                ],
                "scopeId": 1832,
                "leagueId": 329,
                "countryId": 31,
                "sportTypeId": 33,
                "startsAt": 1656194400000,
                "state": 1
            }
        },
    ]
}

redeemPrize

This method allows you to get your reward for a winning bet.

import { redeemPrize } from '@azuro-protocol/sdk'

redeemPrize(nftId)

Dictionary

This is a dictionary that allows you to understand the parameters we give in the fetchGames method and others.

  1. betTypeOdd.marketRegistry IPFS hash: QmPWps8adamqZfnie6MutAsrYUQynQ8ckwFb3bggz2T4aU

  2. betTypeOdd.gamePeriod IPFS hash: QmTPaf3Vu1wuVH3CNagHmmvj7A9x4A4YHtm5jDzomLD2XP

  3. betTypeOdd.gameType IPFS hash: QmcxH3srMCPmaqCnSEtTE8PfhF5ykjEgUVgg9vYehmUc8v

  4. betTypeOdd.gameVariety IPFS hash: QmUAPb5un7FCbXRJJLaSwGv8iH8yoEj4AQb1B8jbm1sAYg

  5. betTypeOdd.outcomeRegistry IPFS hash: QmQ34UYPPtpxJiWcVj4buh4HzFo4Z9gwGt5KRiprQN3fkT

  6. betTypeOdd.param IPFS hash: QmYsGGCbNrwcUpTCbVbKM7NrMZNg1coFpJDu9ZBrsVqL9H

  7. betTypeOdd.teamPlayer IPFS hash: QmUbip5C5XhyW7mwHkRcdUYFb5jGaD4K7AmmKUNLuaMDi7

  8. sportTypeId IPFS hash: QmZ3UGFQreUNNtnW2v5uoQZLKPv5kJxWvZhr87kDSm6vyJ

  9. betTypeOdd IPFS hash: QmZL7mcGKYnbhcWAxQShKtwn9nwZcimaeRFKgAnKm4mcsH

Keywords

FAQs

Package last updated on 11 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc