npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hxronetwork/parimutuelsdk

v1.0.42

Published

## Available Scripts

Downloads

25

Readme

Parimutuel-web3

Available Scripts

yarn build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

Tech/Framework used

The project uses the React framework and type script

Functions/Variables

CryptoEnum

Defines constants for currencies

PositionSideEnum

Defines constants for side taken when entering ie SHORT and LONG

MarketPairEnum

Define variables for the index used to lock and expire the market

function getMarketPubkeys

Allows getting the market PublicKey and duration for each market available. The response is array of objects each holding two keys, pubkey and duration

Takes two params:

  • config as object: An object contains all PublicKey for each duration of crypto market
  • marketPair as string: was define in the MarketPairEnum

(PublicKey: https://solana-labs.github.io/solana-web3.js/classes/PublicKey.html)

*** Note: Both config and marketPair are mandatory ***

MIN_1, MIN_5, MIN_15, HR_1. and DAY_1

Define constants for the each duration

MarketStatusEnum

Defines variables for status of the contests ie: UPCOMING, LIVE and SETTLED

ConfigEnum

Defines constants for each enviroment ie: DEV, STAGING and CUSTOM

function decodeAccount

The function decode data account information.
The response is the data as AccountInfo (https://solana-labs.github.io/solana-program-library/token/js/interfaces/Account.html)

Have a param:

  • data as Buffer (https://nodejs.org/api/buffer.html)

*** Note: data is mandatory ***

function decodeMint

The function decode data mint information.
The response is the data as MintInfo (https://solana-labs.github.io/solana-program-library/token/js/interfaces/Mint.html)

Have a param:

  • data as Buffer (https://nodejs.org/api/buffer.html)

*** Note: data is mandatory ***

TokenAccount

Define interface

Have 3 keys:

  • pubkey as string

  • account as AccountInfo<Buffer> (AccountInfo: https://solana-labs.github.io/solana-program-library/token/js/interfaces/Account.html).
    (Buffer: https://nodejs.org/api/buffer.html)

  • info as AccountInfo

ParimutuelAccount

Define declare type

ParimutuelMarket

Define declare type

ParimutuelNetwork

Define declare type

ParimutuelPosition

Define declare type

ParimutuelTraderFeePayerAccount

Define declare type

function isParimutuelAccount

The function check the account is parimutuel account or not.
The response is true or false

Have a param:

  • account as AccountInfo<Buffer> (AccountInfo: https://solana-labs.github.io/solana-program-library/token/js/interfaces/Account.html).
    (Buffer: https://nodejs.org/api/buffer.html)

function getMarketStatus

The function check status of the market.
Response is one of three value:

  • MarketStatusEnum.UPCOMING
  • MarketStatusEnum.LIVE
  • MarketStatusEnum.SETTLED

Have 3 params:

  • timeWindowStart as string
  • marketClose as string
  • duration as number

class ParimutuelWeb3

Class ParimutuelWeb3 defines the various SDK functions available, corresponding to smart contract instructions

  • Constructors: Create a new ParimutuelWeb3 object.
    new ParimutuelWeb3(config: ParimutuelConfig, connection?: Connection).
    If the connection parameter is not provided a new connection is using clusterApiUrl('devnet') of web3 library (https://docs.solana.com/clusters)

    Parameters:

    • config: ParimutuelConfig.

    All public key for each constant in the environments

    • connection?: Connection.

    Connection define in (https://solana-labs.github.io/solana-web3.js/classes/Connection.html)

    Returns ParimutuelWeb3

  • Method:

    function updateNetwork (

      userWallet: WalletSigner | Keypair,
      protocolMintPubkey: PublicKey | unknown,
      settlementMintPubkey: PublicKey | unknown,
      protocolProductOraclePubkey: PublicKey | unknown,
      protocolPriceOraclePubkey: PublicKey | unknown,
      networkProtocolFeeCollectorPubkey: PublicKey | unknown,
      networkSettlementFeeCollectorPubkey: PublicKey | unknown,
      protocolTokenRequiredForMinFee: BN = new BN(1000000),
      minProtocolFeeBps: number = 10,
      maxProtocolFeeBps: number = 150,
      minSettlementFeeBps: number = 100,
      maxSettlementFeeBps: number = 300
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • protocolMintPubkey: PublicKey | unknown
    • settlementMintPubkey: PublicKey | unknown
    • protocolProductOraclePubkey: PublicKey | unknown
    • protocolPriceOraclePubkey: PublicKey | unknown
    • networkProtocolFeeCollectorPubkey: PublicKey | unknown
    • networkSettlementFeeCollectorPubkey: PublicKey | unknown
    • protocolTokenRequiredForMinFee: BN = new BN(1000000)
    • minProtocolFeeBps: number = 10
    • maxProtocolFeeBps: number = 150
    • minSettlementFeeBps: number = 100
    • maxSettlementFeeBps: number = 300

    Returns: string

    function createParimutuel (

      userWallet: WalletSigner | Keypair,
      marketPubkey: PublicKey,
      marketOpen: number,
      timeWindowStart: number,
      marketClose: number
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • marketPubkey: PublicKey
    • marketOpen: number
    • timeWindowStart: number
    • marketClose: number

    Returns: string

    function updatePrice (

      userWallet: WalletSigner | Keypair,
      parimutuelPubkey: PublicKey
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • parimutuelPubkey: PublicKey

    Returns: string

    function placePosition (

    userWallet: WalletSigner | Keypair, 
    parimutuelPubkey: PublicKey, 
    size: number, 
    side: PositionSideEnum,
    seq: number,
    )

    Parameters:

    • userWallet: WalletSigner | Keypair,
    • parimutuelPubkey: PublicKey,
    • size: number,
    • side: PositionSideEnum
    • seq: number,

    Returns: string

    function getPlacePositionInstruction (

    userWallet: WalletSigner | Keypair, 
    parimutuelPubkey: PublicKey, 
    size: number, 
    side: PositionSideEnum,
    seq: number,
    )

    Parameters:

    • userWallet: WalletSigner | Keypair,
    • parimutuelPubkey: PublicKey,
    • size: number,
    • side: PositionSideEnum
    • seq: number,

    Returns: TransactionInstruction[]

    function settlePosition (

      userWallet: WalletSigner | Keypair, 
      traderWalletPubkey: PublicKey, 
      parimutuelPubkey: PublicKey
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • traderWalletPubkey: PublicKey
    • parimutuelPubkey: PublicKey

    Returns: string

    function destroyParimutuel (

      userWallet: WalletSigner | Keypair, 
      parimutuelPubkey: PublicKey
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • parimutuelPubkey: PublicKey

    Returns: string

    function destroyPosition(

      userWallet: WalletSigner | Keypair, 
      traderWalletPubkey: PublicKey, 
      parimutuelPubkey: PublicKey
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • traderWalletPubkey: PublicKey
    • parimutuelPubkey: PublicKey

    Returns: string

    function destroyPositionEntry(

      userWallet: WalletSigner | Keypair, 
      traderWalletPubkey: PublicKey, 
      parimutuelPubkey: PublicKey, 
      sequenceNumber: number
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • traderWalletPubkey: PublicKey
    • parimutuelPubkey: PublicKey
    • sequenceNumber: number

    Returns: string

    function transferToken (

      walletPubkey: PublicKey, 
      mintPubkey: PublicKey, 
      authorityKeypair: Keypair, 
      amount: number
    )

    Parameters:

    • walletPubkey: PublicKey
    • mintPubkey: PublicKey
    • authorityKeypair: Keypair
    • amount: number

    function depositFee (

      userWallet: WalletSigner | Keypair, 
      marketPubkey: PublicKey, 
      mintPubkey: PublicKey, 
      amount: number
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • marketPubkey: PublicKey
    • mintPubkey: PublicKey
    • amount: number

    Returns: string

    function withdrawFee (

      userWallet: WalletSigner | Keypair, 
      amount: number
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • amount: number

    Returns: string

    function createStore (

      userWallet: WalletSigner | Keypair, 
      storeWalletPubkey: PublicKey, 
      marketPubkey: PublicKey, 
      protocolFeeBps: number, 
      settlementFeeBps: number
    )

    Parameters:

    • userWallet: WalletSigner | Keypair
    • storeWalletPubkey: PublicKey
    • marketPubkey: PublicKey
    • protocolFeeBps: number
    • settlementFeeBps: number

    Returns: string

    function attachCookie (

      userWallet: WalletSigner | Keypair, 
      storePubkey: PublicKey, 
      parimutuelPubkey: PublicKey
    ) 

    Parameters:

    • userWallet: WalletSigner | Keypair
    • storePubkey: PublicKey
    • parimutuelPubkey: PublicKey

    Returns: string

    function getFees (

      networkWalletPubkey: PublicKey, 
      marketWalletPubkey: PublicKey
    ): ParimutuelFees

    Fetch all the account info based on networkWalletPubkey and marketWalletPubkey parameter

    Parameters:

    • networkWalletPubkey: PublicKey
    • marketWalletPubkey: PublicKey

    Define PublicKey on https://solana-labs.github.io/solana-web3.js/classes/PublicKey.html

    Returns: An object has two values are network and market. Each value in the object has 4 values are protocolFeeAccountPubkey, protocolFeeAmount, settlementFeeAccountPubkey, and settlementFeeAmount

    function getMarkets (

      marketPair: MarketPairEnum
    ): ParimutuelMarket[]

    Filter all public keys on the config with marketPair parameter and then fetch all the account info for multiple accounts specified by an array of public keys

    Parameters:

    • marketPair: MarketPairEnum

    Returns: The array contains all object markets for the marketPair chosen. Each object has 3 values are pubkey, account, and info.info is an object has 2 values market and fixedFees

    function getNetwork (): ParimutuelNetwork

    Fetch all the account info by the PARIMUTUEL_PROGRAM_ID in the config

    Returns: An object has 3 values are pubkey, account, and info.info is an object has 2 values network and linearFees

    function getNetworkTraderAccount (

      userWalletPubkey: PublicKey, 
      networkPubkey: PublicKey
    ): ParimutuelTraderAccount

    Fetch all the account info based on userWalletPubkey and networkPubkey parameter

    Parameters:

    • userWalletPubkey: PublicKey
    • networkPubkey: PublicKey

    Returns: An object has 3 values are pubkey, account, and info.info is an object has a value traderAccount

    function getParimutuel (

      parimutuelPubkey: PublicKey
    ): ParimutuelAccount

    Fetch all the account info with parimutuelPubkey

    Parameters:

    • parimutuelPubkey: PublicKey

    Returns: An object has 3 values are pubkey, account, and info.info is an object has a value parimutuel

    function getParimutuels (

      markets: MarketPubkey[], 
      number?: number
    ): ParimutuelAccount[]

    Parameters:

    • markets: MarketPubkey[]
    • number?: number (default: 5)

    Returns: The array contains all object parimutuels filtered by the markets and number parameters. Each object has 3 values are pubkey, account, and info.The info is an object has a value parimutuel

    function getUserPositions (

      userWalletPubkey: PublicKey, 
      markets: ParimutuelMarket[]
    ): ParimutuelPosition[]

    Fetch all the accounts owned by the program id in the config and with the optional userWalletPubkey

    Parameters:

    • userWalletPubkey: PublicKey
    • markets: ParimutuelMarket[]

    Returns: The array contains all object positions filtered by the markets and userWalletPubkey parameters. Each object has 3 values are pubkey, account, and info. The info is an object has 4 values parimutuelPubkey, parimutuel, market, and position

    function getParimutuelPositions (

      parimutuelPubkey: PublicKey
    ): ParimutuelPosition[]

    Fetch all the accounts owned by the program id in the config and with the optional parimutuelPubkey

    Parameters:

    • parimutuelPubkey: PublicKey

    Returns: The array contains all object positions filtered by the parimutuelPubkey parameter. Each object has 3 values are pubkey, account, and info.The info is an object has 4 values parimutuelPubkey, parimutuel, market, and position:

    function getEntries (

      traderPositionPubkey: PublicKey
    ): ParimutuelEntry[]

    Fetch all the accounts owned by the program id in the config and with the optional traderPositionPubkey

    Parameters:

    • traderPositionPubkey: PublicKey

    Returns: The array contains all object entries filtered by the traderPositionPubkey parameter. Each object has 3 values are pubkey, account, and info.The info is an object has 2 values parimutuelPubkey, and entry:

    function getStore (

      storePubkey: PublicKey
    ): Store

    Fetch all the account info with storePubkey

    Parameters:

    • storePubkey: PublicKey

    Returns: The Store object which contains version, programId, bumpSeed, marketKey, wallet, protocolFeeCollector, settlementFeeCollector, and fee

    function getTraderFeePayerAccount (

      userWalletPubkey: PublicKey, 
      networkPubkey: PublicKey
    ): ParimutuelTraderFeePayerAccount

    Fetch all the account info based on userWalletPubkey and networkPubkey parameter

    Parameters:

    • userWalletPubkey: PublicKey
    • networkPubkey: PublicKey

    Returns: An object contains have 3 values are pubkey, account, and info.