@hxronetwork/parimutuelsdk
v1.0.42
Published
## Available Scripts
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:
configas object: An object contains allPublicKeyfor eachdurationof crypto marketmarketPairas string: was define in theMarketPairEnum
(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:
dataas 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:
dataas Buffer (https://nodejs.org/api/buffer.html)
*** Note: data is mandatory ***
TokenAccount
Define interface
Have 3 keys:
pubkeyas stringaccountasAccountInfo<Buffer>(AccountInfo: https://solana-labs.github.io/solana-program-library/token/js/interfaces/Account.html).
(Buffer: https://nodejs.org/api/buffer.html)infoas 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:
accountasAccountInfo<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.UPCOMINGMarketStatusEnum.LIVEMarketStatusEnum.SETTLED
Have 3 params:
timeWindowStartas stringmarketCloseas stringdurationas 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 usingclusterApiUrl('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
ParimutuelWeb3Method:
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:
stringfunction
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:
stringfunction
updatePrice(userWallet: WalletSigner | Keypair, parimutuelPubkey: PublicKey )Parameters:
- userWallet: WalletSigner | Keypair
- parimutuelPubkey: PublicKey
Returns:
stringfunction
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:
stringfunction
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:
stringfunction
destroyParimutuel(userWallet: WalletSigner | Keypair, parimutuelPubkey: PublicKey )Parameters:
- userWallet: WalletSigner | Keypair
- parimutuelPubkey: PublicKey
Returns:
stringfunction
destroyPosition(userWallet: WalletSigner | Keypair, traderWalletPubkey: PublicKey, parimutuelPubkey: PublicKey )Parameters:
- userWallet: WalletSigner | Keypair
- traderWalletPubkey: PublicKey
- parimutuelPubkey: PublicKey
Returns:
stringfunction
destroyPositionEntry(userWallet: WalletSigner | Keypair, traderWalletPubkey: PublicKey, parimutuelPubkey: PublicKey, sequenceNumber: number )Parameters:
- userWallet: WalletSigner | Keypair
- traderWalletPubkey: PublicKey
- parimutuelPubkey: PublicKey
- sequenceNumber: number
Returns:
stringfunction
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:
stringfunction
withdrawFee(userWallet: WalletSigner | Keypair, amount: number )Parameters:
- userWallet: WalletSigner | Keypair
- amount: number
Returns:
stringfunction
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:
stringfunction
attachCookie(userWallet: WalletSigner | Keypair, storePubkey: PublicKey, parimutuelPubkey: PublicKey )Parameters:
- userWallet: WalletSigner | Keypair
- storePubkey: PublicKey
- parimutuelPubkey: PublicKey
Returns:
stringfunction
getFees(networkWalletPubkey: PublicKey, marketWalletPubkey: PublicKey ): ParimutuelFeesFetch all the account info based on
networkWalletPubkeyandmarketWalletPubkeyparameterParameters:
- 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
networkandmarket. Each value in the object has 4 values areprotocolFeeAccountPubkey,protocolFeeAmount,settlementFeeAccountPubkey, andsettlementFeeAmountfunction
getMarkets(marketPair: MarketPairEnum ): ParimutuelMarket[]Filter all public keys on the config with
marketPairparameter and then fetch all the account info for multiple accounts specified by an array of public keysParameters:
- marketPair: MarketPairEnum
Returns: The array contains all object markets for the
marketPairchosen. Each object has 3 values arepubkey,account, andinfo.infois an object has 2 valuesmarketandfixedFeesfunction
getNetwork(): ParimutuelNetworkFetch all the account info by the
PARIMUTUEL_PROGRAM_IDin the configReturns: An object has 3 values are
pubkey,account, andinfo.infois an object has 2 valuesnetworkandlinearFeesfunction
getNetworkTraderAccount(userWalletPubkey: PublicKey, networkPubkey: PublicKey ): ParimutuelTraderAccountFetch all the account info based on
userWalletPubkeyandnetworkPubkeyparameterParameters:
- userWalletPubkey: PublicKey
- networkPubkey: PublicKey
Returns: An object has 3 values are
pubkey,account, andinfo.infois an object has a valuetraderAccountfunction
getParimutuel(parimutuelPubkey: PublicKey ): ParimutuelAccountFetch all the account info with
parimutuelPubkeyParameters:
- parimutuelPubkey: PublicKey
Returns: An object has 3 values are
pubkey,account, andinfo.infois an object has a valueparimutuelfunction
getParimutuels(markets: MarketPubkey[], number?: number ): ParimutuelAccount[]Parameters:
- markets: MarketPubkey[]
- number?: number (default: 5)
Returns: The array contains all object parimutuels filtered by the
marketsandnumberparameters. Each object has 3 values arepubkey,account, andinfo.Theinfois an object has a valueparimutuelfunction
getUserPositions(userWalletPubkey: PublicKey, markets: ParimutuelMarket[] ): ParimutuelPosition[]Fetch all the accounts owned by the program id in the config and with the optional
userWalletPubkeyParameters:
- userWalletPubkey: PublicKey
- markets: ParimutuelMarket[]
Returns: The array contains all object positions filtered by the
marketsanduserWalletPubkeyparameters. Each object has 3 values arepubkey,account, andinfo. Theinfois an object has 4 valuesparimutuelPubkey,parimutuel,market, andpositionfunction
getParimutuelPositions(parimutuelPubkey: PublicKey ): ParimutuelPosition[]Fetch all the accounts owned by the program id in the config and with the optional
parimutuelPubkeyParameters:
- parimutuelPubkey: PublicKey
Returns: The array contains all object positions filtered by the
parimutuelPubkeyparameter. Each object has 3 values arepubkey,account, andinfo.Theinfois an object has 4 valuesparimutuelPubkey,parimutuel,market, andposition:function
getEntries(traderPositionPubkey: PublicKey ): ParimutuelEntry[]Fetch all the accounts owned by the program id in the config and with the optional
traderPositionPubkeyParameters:
- traderPositionPubkey: PublicKey
Returns: The array contains all object entries filtered by the
traderPositionPubkeyparameter. Each object has 3 values arepubkey,account, andinfo.Theinfois an object has 2 valuesparimutuelPubkey, andentry:function
getStore(storePubkey: PublicKey ): StoreFetch all the account info with
storePubkeyParameters:
- storePubkey: PublicKey
Returns: The Store object which contains
version,programId,bumpSeed,marketKey,wallet,protocolFeeCollector,settlementFeeCollector, andfeefunction
getTraderFeePayerAccount(userWalletPubkey: PublicKey, networkPubkey: PublicKey ): ParimutuelTraderFeePayerAccountFetch all the account info based on
userWalletPubkeyandnetworkPubkeyparameterParameters:
- userWalletPubkey: PublicKey
- networkPubkey: PublicKey
Returns: An object contains have 3 values are
pubkey,account, andinfo.
