Skip to main content

Market

toJSONString

You can use this function to convert market object into string.

const sdk = await SDK.initialize(endpoint);

const res = await sdk.models.getAllMarkets();

res.forEach((market) => console.log(market.toJSONString()));

toFilteredJSONString

You can use this function to convert market object into string with filters.

const sdk = await SDK.initialize(endpoint);

const res = await sdk.models.getAllMarkets();

res.forEach((market) => console.log(market.toFilteredJSONString(filter)));

filterMarketData

Populate only selected attributes from the market data defined using filter. Populates marketId by default.

const res = filterMarketData(market, filter);

Code snippet

getEndTimestamp

You can use this function to get timestamp at the end of the market period.

const res = market.getEndTimestamp();

Code snippet

getPoolId

You can use this function to get pool id to be used for fetching data using sdk.models.market.getPool(). Returns null if no swap pool is available for the market.

const res = market.getPoolId();

Code snippet

getPool

You can use this function to recreate swap pool for this market using data fetched with poolId.

const res = market.getPool();

Code snippet

getDisputes

You can use this function to fetch disputes for this market using unique identifier marketId.

const res = market.getDisputes();

Code snippet

deploySwapPool

Creates swap pool for the market with specified liquidity.

const poolId = await market.deploySwapPool(signer, amount, wts, false);

Arguments

NameTypeDescription
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction
amountstringThe amount of each token to add to the pool
weightsstringThe relative denormalized weight of each asset
callbackOrPaymentInfobooleantrue to get txn fee estimation otherwise callback to capture transaction result.

Code snippet

assetSpotPricesInZtg

You can use this function to fetch spot prices of all assets in this market Can be used to find prices at a particular block using unique identifier.

const res = market.assetSpotPricesInZtg(blockHash);

Arguments

NameTypeIntroduction
blockHashanynot necessarily. The unique identifier for the block to fetch asset spot prices.

Code snippet

buyCompleteSet

You can use this function to buy a complete set of outcome shares for the market. Note: This is the only way to create new shares.

const res = market.buyCompleteSet(signer, Number(1000000000000));

Arguments

NameTypeIntroduction
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction.
amountnumberThe amount of each share.
callbackOrPaymentInfo"true" to get txn fee estimation otherwise callback to capture transaction result.

Code snippet

sellCompleteSet

You can use this function to sell/destroy a complete set of outcome shares for the market.

const res = market.sellCompleteSet(signer, Number(1000000000000));

Arguments

NameTypeIntroduction
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction.
amountnumberThe amount of each share.
callbackOrPaymentInfo"true" to get txn fee estimation otherwise callback to capture transaction result.

Code snippet

reportOutcome

You can use this function to report an outcome for the market.

const res = await market.reportOutcome(signer, outcomeReport, false);

Arguments

NameTypeIntroduction
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction.
outcomeOutcomeReportThe outcome of the market
callbackOrPaymentInfo"true" to get txn fee estimation otherwise callback to capture transaction result.

Code snippet

dispute

You can use this function to submit a disputed outcome for the market.

const res = await market.dispute(signer, outcomeReport, false);

Arguments

NameTypeIntroduction
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction.
outcomeOutcomeReportThe outcome of the market
callbackOrPaymentInfo"true" to get txn fee estimation otherwise callback to capture transaction result.

Code snippet

redeemShares

You can use this function to redeem the winning shares for the market.

const res = await market.redeemShares(signer, outcomeReport, false);

Arguments

NameTypeIntroduction
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction.
outcomeOutcomeReportThe outcome of the market
callbackOrPaymentInfo"true" to get txn fee estimation otherwise callback to capture transaction result.

Code snippet

approve

You can use this function to approve the Proposed market that is waiting for approval from the advisory committee.

const res = await market.approve(signer, false);

Arguments

NameTypeIntroduction
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction.
callbackOrPaymentInfo"true" to get txn fee estimation otherwise callback to capture transaction result.

Code snippet

reject

You can use this function to reject the Proposed market that is waiting for approval from the advisory committee.

const res = await market.reject(signer, false);

Arguments

NameTypeIntroduction
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction.
callbackOrPaymentInfo"true" to get txn fee estimation otherwise callback to capture transaction result.

Code snippet

cancelAdvised

You can use this function to allow the proposer of the market that is currently in a Proposed state to cancel the market proposal.

const res = await market.cancelAdvised(signer, false);

Arguments

NameTypeIntroduction
signerKeyringPairOrExtSignerThe actual signer provider to sign the transaction.
callbackOrPaymentInfo"true" to get txn fee estimation otherwise callback to capture transaction result.

Code snippet