@mistswapdex/mist-data
v0.0.1
Published
This is a collection of utilities to query MistSwap data from smartBCH. This data has been indexed by the Graph via the subgraph the MistSwap team maintains.
Downloads
2
Readme
mist-data
This is a collection of utilities to query MistSwap data from smartBCH. This data has been indexed by the Graph via the subgraph the MistSwap team maintains.
Supported Queries
The below all return a Promise that resolves with the requested results.
sushi.priceUSD({¹})
Gets USD price of Mist.sushi.priceETH({¹})
Gets ETH price of Mist.blocks.latestBlock()
Gets the latest block.blocks.getBlock({¹})
Gets data for the specified block.charts.factory()
Gets data for the MistSwap factory broken down daily + weekly.charts.tokenHourly({token_address, startTime?})
Gets data for specified token broken down hourly.charts.tokenDaily({token_address})
Gets data for specified token broken down daily.charts.pairHourly({pair_address, startTime?})
Gets data for specified pair broken down hourly.charts.pairDaily({pair_address})
Gets data for specified pair broken down daily.exchange.token({¹, token_address})
Gets data for specified token.exchange.token24h({¹, token_address})
Gets 24h data for specified token.exchange.tokenHourData({², token_address})
Gets hourly data for specified token.exchange.tokenDayData({², token_address})
Gets daily data for specified token.exchange.tokens({¹})
Gets data for all tokens.exchange.tokens24h({¹})
Gets 24h data for all tokens.exchange.pair({¹, pair_address})
Gets data for specified pair.exchange.pair24h({¹, pair_address})
Gets 24h data for specified pair.exchange.pairHourData({², pair_address})
Gets hourly data for specified pair.exchange.pairDayData({{², pair_address})
Gets daily data for specified pair.exchange.pairs({¹, [pair_addresses]?})
Gets data for all / specified pairs.exchange.pairs24h({¹})
Gets 24h data for all pairs.exchange.ethPrice({¹})
Gets USD price of ETH.exchange.ethPriceHourly({²})
Gets USD price of ETH broken down hourly.exchange.factory({¹})
Gets all data for the MistSwap factory.exchange.dayData({²})
Gets data for the MistSwap factory broken down by day.exchange.twentyFourHourData({¹})
Gets 24h data for the MistSwap factory.
masterchef.info({¹})
Gets MasterChef contract info.masterchef.pool({¹, pool_id, pool_address})
Gets pool info, either by pool id or by pool address.masterchef.pools({¹})
Gets pool info for all pools in MasterChef.masterchef.user({¹, user_address})
Gets user's data for all of the user's pools.masterchef.users({¹})
Gets all users and data for all of the users' pools.masterchef.apys({¹})
Gets pool info for all pools in MasterChef including APYs.masterchef.apys24h({¹})
Gets 24h pool info for all pools in MasterChef including APYs.exchange.stakedValue({¹, token_address})
Get pricing info for MasterChef pool.bar.info({¹})
Gets MistBar contract info.bar.user({¹, user_address})
Gets MistBar data for specified user.
¹ {block, timestamp}
Supports fetching at a specific block / UNIX timestamp.
² {minBlock, maxBlock, minTimestamp, maxTimestamp}
Supports fetching in a specific timeframe.
Supported Subscriptions
The below all return an Observable that when subscribed to with an object.
sushi.observePriceETH()
Gets an observable of the current ETH price of Mist.blocks.observeLatestBlock()
Gets an observable of the latest block.exchange.observeToken({token_address})
Gets an observable for specified token.exchange.observeTokens()
Gets an observable for the top 1000 tokens (by volume in USD).exchange.observePair({pair_address})
Gets an observable for specified pair.exchange.observePairs()
Gets an observable for the top 1000 pairs (by liquidity in USD).exchange.observeEthPrice()
Gets an observable for the current USD price of ETH.exchange.observeFactory()
Gets an observable for the MistSwap factory.bar.observeInfo()
Gets an observable for MistBar contract info.
Timeseries
mistData.timeseries({blocks = [], timestamps = [], target = targetFunction}, {targetArguments})
Returns an array of queries. Blocks / timestamps are arrays of the blocks / timestamps to query (choose one). The target is the target function, the target arguments are the arguments for the target. See example below
Example
const mistData = require('@mistswapdex/mist-data'); // common js
// or
import mistData from '@mistswapdex/mist-data'; // es modules
// query and log resolved results
mistData.masterchef
.pools({block: 1782402})
.then(pools => console.log(pools))
mistData.bar
.user({user_address: '0xFDF3b46D029b61F4f257745DFdD99092e272Bf60'})
.then(user => console.log(user))
mistData.exchange
.observePairs()
.subscribe({next: (pairs) => console.log(pairs), error: (err) => console.log(err)})
mistData
.timeseries({blocks: [1762402, 1772402, 1782402], target: mistData.exchange.pair}, {pair_address: "0x674A71E69fe8D5cCff6fdcF9F1Fa4262Aa14b154"})