@aceswap/ace-data 中文文档教程
ace-data
这是一组用于从以太坊查询 AceSwap 数据的实用程序。 这 数据已通过 AceSwap 团队维护的子图被 Graph 索引。
Supported Queries
以下所有返回一个 Promise ,该 Promise 以请求的结果解析。
ace.priceUSD({¹})
Gets USD price of Ace.ace.priceETH({¹})
Gets ETH price of Ace.blocks.latestBlock()
Gets the latest block.blocks.getBlock({¹})
Gets data for the specified block.charts.factory()
Gets data for the AceSwap 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 AceSwap factory.exchange.dayData({²})
Gets data for the AceSwap factory broken down by day.exchange.twentyFourHourData({¹})
Gets 24h data for the AceSwap factory.exchange_v1.userHistory({², user_address})
Gets LP history for specified user.exchange_v1.userPositions({¹, user_address})
Gets LP positions for specified user.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 AceBar contract info.bar.user({¹, user_address})
Gets AceBar data for specified user.maker.info({¹})
Gets AceMaker contract info.maker.servings({²})
Gets past servings to the bar.maker.servers({¹})
Gets servers that have served Ace to the bar.maker.pendingServings({¹})
Gets data on the servings ready to be served to the bar.timelock.queuedTxs({²})
Gets queued Timelock transactions.timelock.canceledTxs({²})
Gets canceled Timelock transactions.timelock.executedTxs({²})
Gets executed Timelock transactions.timelock.allTxs({²})
Gets all Timelock transactions.lockup.user({¹, user_address})
Gets lockup data for specified user.bentobox.clones({masterAddress, chainId})
Gets Clone contracts for specified master contract.
¹ {block, timestamp}
支持在特定块/UNIX 时间戳处获取。
² {minBlock, maxBlock, minTimestamp, maxTimestamp}
支持在特定时间范围内抓取。
Supported Subscriptions
以下所有返回一个 Observable,当订阅一个对象时。
ace.observePriceETH()
Gets an observable of the current ETH price of Ace.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 AceSwap factory.bar.observeInfo()
Gets an observable for AceBar contract info.maker.observePendingServings()
Gets an observable for pending servings.
Timeseries
aceData.timeseries({blocks = [], timestamps = [], target = targetFunction}, {targetArguments})
返回一个查询数组。 块/时间戳是要查询的块/时间戳的数组(选择一个)。 目标是目标函数,目标参数是目标的参数。 请参见下面的示例
Example
const aceData = require('@aceswap/ace-data'); // common js
// or
import aceData from '@aceswap/ace-data'; // es modules
// query and log resolved results
aceData.masterchef
.pools({block: 11223344})
.then(pools => console.log(pools))
aceData.timelock
.allTxs({minTimestamp: 1605239738, maxTimestamp: 1608239738})
.then(txs => console.log(txs))
aceData.bar
.user({user_address: '0x6684977bbed67e101bb80fc07fccfba655c0a64f'})
.then(user => console.log(user))
aceData.exchange
.observePairs()
.subscribe({next: (pairs) => console.log(pairs), error: (err) => console.log(err)})
aceData
.timeseries({blocks: [11407623, 11507623, 11607623], target: aceData.exchange.pair}, {pair_address: "0x795065dCc9f64b5614C407a6EFDC400DA6221FB0"})
ace-data
This is a collection of utilities to query AceSwap data from Ethereum. This data has been indexed by the Graph via the subgraph the AceSwap team maintains.
Supported Queries
The below all return a Promise that resolves with the requested results.
ace.priceUSD({¹})
Gets USD price of Ace.ace.priceETH({¹})
Gets ETH price of Ace.blocks.latestBlock()
Gets the latest block.blocks.getBlock({¹})
Gets data for the specified block.charts.factory()
Gets data for the AceSwap 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 AceSwap factory.exchange.dayData({²})
Gets data for the AceSwap factory broken down by day.exchange.twentyFourHourData({¹})
Gets 24h data for the AceSwap factory.exchange_v1.userHistory({², user_address})
Gets LP history for specified user.exchange_v1.userPositions({¹, user_address})
Gets LP positions for specified user.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 AceBar contract info.bar.user({¹, user_address})
Gets AceBar data for specified user.maker.info({¹})
Gets AceMaker contract info.maker.servings({²})
Gets past servings to the bar.maker.servers({¹})
Gets servers that have served Ace to the bar.maker.pendingServings({¹})
Gets data on the servings ready to be served to the bar.timelock.queuedTxs({²})
Gets queued Timelock transactions.timelock.canceledTxs({²})
Gets canceled Timelock transactions.timelock.executedTxs({²})
Gets executed Timelock transactions.timelock.allTxs({²})
Gets all Timelock transactions.lockup.user({¹, user_address})
Gets lockup data for specified user.bentobox.clones({masterAddress, chainId})
Gets Clone contracts for specified master contract.
¹ {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.
ace.observePriceETH()
Gets an observable of the current ETH price of Ace.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 AceSwap factory.bar.observeInfo()
Gets an observable for AceBar contract info.maker.observePendingServings()
Gets an observable for pending servings.
Timeseries
aceData.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 aceData = require('@aceswap/ace-data'); // common js
// or
import aceData from '@aceswap/ace-data'; // es modules
// query and log resolved results
aceData.masterchef
.pools({block: 11223344})
.then(pools => console.log(pools))
aceData.timelock
.allTxs({minTimestamp: 1605239738, maxTimestamp: 1608239738})
.then(txs => console.log(txs))
aceData.bar
.user({user_address: '0x6684977bbed67e101bb80fc07fccfba655c0a64f'})
.then(user => console.log(user))
aceData.exchange
.observePairs()
.subscribe({next: (pairs) => console.log(pairs), error: (err) => console.log(err)})
aceData
.timeseries({blocks: [11407623, 11507623, 11607623], target: aceData.exchange.pair}, {pair_address: "0x795065dCc9f64b5614C407a6EFDC400DA6221FB0"})