sushi-data
This is a collection of utilities to query SushiSwap data from Ethereum. This data has been indexed by the Graph via the subgraph the SushiSwap team maintains.
Supported Queries
The below all return a Promise that resolves with the requested results.
Sushi
-
sushi.priceUSD({¹})
Gets USD price of Sushi. -
sushi.priceETH({¹})
Gets ETH price of Sushi. -
blocks.latestBlock()
Gets the latest block. -
blocks.getBlock({¹})
Gets data for the specified block. -
charts.factory()
Gets data for the SushiSwap factory broken down daily + weekly. -
charts.tokenHourly({address, startTime?})
Gets data for specified token broken down hourly. -
charts.tokenDaily({address})
Gets data for specified token broken down daily. -
charts.pairHourly({address, startTime?})
Gets data for specified pair broken down hourly. -
charts.pairDaily({address})
Gets data for specified pair broken down daily. -
exchange.token({¹, address})
Gets data for specified token. -
exchange.token24h({¹, address})
Gets 24h data for specified token. -
exchange.tokenHourData({², address})
Gets hourly data for specified token. -
exchange.tokenDayData({², address})
Gets daily data for specified token. -
exchange.tokens({¹})
Gets data for all tokens. -
exchange.tokens24h({¹})
Gets 24h data for all tokens. -
exchange.pair({¹, address})
Gets data for specified pair. -
exchange.pair24h({¹, address})
Gets 24h data for specified pair. -
exchange.pairHourData({², address})
Gets hourly data for specified pair. -
exchange.pairDayData({{², address})
Gets daily data for specified pair. -
exchange.pairs({¹, [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 SushiSwap factory. -
exchange.dayData({²})
Gets data for the SushiSwap factory broken down by day. -
exchange.twentyFourHourData({¹})
Gets 24h data for the SushiSwap factory. -
exchange_v1.userHistory({², address})
Gets LP history for specified user. -
exchange_v1.userPositions({¹, address})
Gets LP positions for specified user. -
masterchef.info({¹})
Gets MasterChef contract info. -
masterchef.pool({¹, poolId, address})
Gets pool info, either by pool id or by pool address. -
masterchef.pools({¹})
Gets pool info for all pools in MasterChef. -
masterchef.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. -
masterchef.stakedValue({¹, address})
Get pricing info for MasterChef pool. -
bar.info({¹})
Gets SushiBar contract info. -
bar.user({¹, address})
Gets SushiBar data for specified user. -
maker.info({¹})
Gets SushiMaker contract info. -
maker.servings({²})
Gets past servings to the bar. -
maker.servers({¹})
Gets servers that have served Sushi 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.
Bento
-
kashi.pair({¹, address})
Gets data for specified pair. -
kashi.pairChange({¹, spacing, address})
Gets change data for specified pair with the specified spacing. -
kashi.pairChart({³, spacing, address})
Gets data for specified pair with the specified spacing. -
kashi.pairs({², [addresses]?})
Gets data for all / specified pairs. -
kashi.pairsChange({¹, spacing, [addresses]?})
Gets change data for all / specified pairs with the specified spacing.
Argument legend
¹ {block, timestamp}
Supports fetching at a specific block / UNIX timestamp.
² {block, timestamp, max}
Supports fetching at a specific block / UNIX timestamp with a maximum amount of results.
³ {minBlock, maxBlock, minTimestamp, maxTimestamp}
Supports fetching in a specific timeframe.
⁴ {minBlock, maxBlock, minTimestamp, maxTimestamp, max}
Supports fetching in a specific timeframe with a maximum amount of results.
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 Sushi. -
blocks.observeLatestBlock()
Gets an observable of the latest block. -
exchange.observeToken({address})
Gets an observable for specified token. -
exchange.observeTokens()
Gets an observable for the top 1000 tokens (by volume in USD). -
exchange.observePair({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 SushiSwap factory. -
bar.observeInfo()
Gets an observable for SushiBar contract info.
Example
const sushiData = require('@sushiswap/sushi-data'); // common js
// or
import { sushi } from '@sushiswap/sushi-data'; // es modules
import { bento } from '@sushiswap/sushi-data';
// query and log resolved results
sushi.masterchef
.pools({block: 11223344})
.then(pools => console.log(pools))
sushi.timelock
.allTxs({minTimestamp: 1605239738, maxTimestamp: 1608239738})
.then(txs => console.log(txs))
sushi.bar
.user({address: '0x6684977bbed67e101bb80fc07fccfba655c0a64f'})
.then(user => console.log(user))
sushi.exchange
.observePairs()
.subscribe({next: (pairs) => console.log(pairs), error: (err) => console.log(err)})
bento.kashi
.pairs()
.then(pairs => console.log(pairs))