Zeitgeist SDK Documentation
The Zeitgeist SDK is written in Typescript
and can be found here:
@zeitgeistpm/sdk.
You can do the following to install it directly into your javascript based
project: npm i @zeitgeistpm/sdk
or yarn add @zeitgeistpm/sdk
.
tip
All amount
parameters are in Pennock, so need to be multiplied by 10^10, which
means if you want to transfer 1 ZTG, you should fill in 10000000000
Get Markets Datas
Function Name | Description |
---|---|
getAllMarketIds | get all market IDs in the Zeitgeiest. |
getAllMarkets | get all market in the Zeitgeiest. |
getMarketCount | get market counts in the Zeitgeiest. |
fetchMarketData | fetch specify market's infomation by id in the Zeitgeiest. |
queryMarket | query market by GraphQL in the Zeitgeiest. |
queryMarketsCount | query counts of markets for specified filter options by GraphQL in the Zeitgeiest. |
filterMarkets | get all market in the Zeitgeiest. |
filterMarketData | Populate only selected attributes from the market data defined using filter. |
indexTransferRecipients | query subsquid indexer for market data with pagination in the Zeitgeiest. |
getMarketDataForPoolsList | get market datas by using pool's data |
getEndTimestamp | get timestamp at the end of the market period. |
fetchDisputes | get all market IDs in the Zeitgeiest. |
getDisputes | fetch disputes for this market using unique identifier marketId . |
Get Pools && Assets Datas
Function Name | Description |
---|---|
getPoolId | get pool id to be used for fetching data using sdk.models.market.getPool() . |
getPool | recreate swap pool for this market using data fetched with poolId . |
fetchPoolData | get specify pool infomation in the Zeitgeiest. |
filterPools | filter some pools from Zeitgeist |
queryAllActiveAssets | query all active assets from subsquid indexer in the Zeitgeiest. |
getAssetsForPoolsList | get assets datas by using pool's data |
getAssetPriceHistory | get assets' historic prices |
assetSpotPricesInZtg | find prices at a particular block in the Zeitgeiest. |
assetSpotPricesInZtg | find prices at a particular block using unique identifier. |
getSpotPrice | get spot price in the specified block. |
fetchPoolSpotPrices | fetch spot prices of specified blocks. |
sharesId | fetch all shares' ids. |
Get Accounts Datas
Function Name | Description |
---|---|
getAccountBalances | get balance of specific account. |
getAccountHistoricalValues | get accounts' historic datas |
accountId | fetch account id in this pool. |
Create Markets Transactions
Function Name | Description |
---|---|
createCategoricalMarket | create a categorical market in the Zeitgeiest. |
createCpmmMarketAndDeployAssets | Create a market using CPMM scoring rule, buy a complete set of the assets used and deploy within and deploy an arbitrary amount of those that's greater than the minimum amount. |
createScalarMarket | create a scalar market in the Zeitgeiest. |
deploySwapPool | create swap pool for this market via api.tx.predictionMarkets.deploySwapPoolForMarket(marketId, weights) . |
assetSpotPricesInZtg | find prices at a particular block using unique identifier. |
buyCompleteSet | buy a complete set of outcome shares for the market. |
sellCompleteSet | sell/destroy a complete set of outcome shares for the market. |
reportOutcome | report an outcome for the market. |
dispute | submit a disputed outcome for the market. |
redeemShares | redeem the winning shares for the market. |
approve | approve the Proposed market that is waiting for approval from the advisory committee. |
reject | reject the Proposed market that is waiting for approval from the advisory committee. |
cancelAdvised | allow the proposer of the market that is currently in a Proposed state to cancel the market proposal. |
joinPool | join pool. |
poolJoinWithExactAssetAmount | join exact asset amount to the pool. |
joinPoolMultifunc | join pool. Three substrate join_pool_xxx functions in one |
exitPool | retrieve a given set of assets from pool to the signer. |
swapExactAmountIn | swap a given assetAmountIn of the assetIn/assetOut pair to pool. |
swapExactAmountOut | swap a given assetAmountOut of the assetIn/assetOut pair to pool. |
Utils
Function Name | Description |
---|---|
getBlockInfo | get block info in Zeitgeist. |
getChainInfo | get chain info about Zeitgeiest. |
getBlockData | get block infomation by blockhash in the Zeitgeiest. |
currencyTransfer | transfer specified asset from self to any account in the Zeitgeiest. |
toJSONString | convert market object into string. |
toFilteredJSONString | convert market object into string with filters. |