npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@phoenix-global/horizon-data

v2.1.40

Published

[![npm version](https://badge.fury.io/js/synthetix-data.svg)](https://badge.fury.io/js/synthetix-data) [![Discord](https://img.shields.io/discord/413890591840272394.svg?color=768AD4&label=discord&logo=https%3A%2F%2Fdiscordapp.com%2Fassets%2F8c9701b98ad437

Downloads

3

Readme

horizon-data

npm version Discord Twitter Follow

This is a collection of utilities to query Horizon data from Ethereum. This data has been indexed by The Graph via the various subgraphs the Horizon team maintains (the subgraph code repo).

Supported queries

The below all return a Promise that resolves with the requested results.

  1. depot.userActions({ user }) Get all depot deposit (sUSD) actions for the given user - deposit, withdrawl, unaccepted, removed.
  2. depot.clearedDeposits({ fromAddress, toAddress }) Get all cleared hasset deposits (payments of ETH for sUSD) either from a given fromAddress or (and as well as) to a given toAddress
  3. depot.exchanges({ from }) Get all depot exchanges (buying sUSD with ETH) for a given from address.
  4. exchanges.total() Get the total exchange volume, total fees and total number of unique exchange addresses.
  5. exchanges.rebates({ minTimestamp = 1 day ago }) Get the last N exchange rebates since the given minTimestamp in seconds. Ordered in reverse chronological order.
  6. exchanges.reclaims({ minTimestamp = 1 day ago }) Get the last N exchange reclaims since the given minTimestamp in seconds. Ordered in reverse chronological order.
  7. exchanges.since({ minTimestamp = 1 day ago }) Get the last N exchanges since the given minTimestamp (in seconds, so one hour ago is 3600). These are ordered in reverse chronological order.
  8. rate.updates Get all rate updates for hassets in reverse chronological order
  9. hassets.issuers Get all wallets that have invoked Issue on sUSD (other hassets to come)
  10. hassets.transfers Get hasset transfers in reverse chronological order
  11. hassets.holders Get all potential hasset holders
  12. hzn.holders Get the list of wallets that have ever sent or received HZN.
  13. hzn.rewards Get the list of reward escrow holders and their latest balance at vesting entry add or vest.
  14. hzn.total Get the total count of unique issuers and hznHolders
  15. hzn.transfers Get HZN transfers in reverse chronological order
  16. hzn.issued Get the Issued events in reverse chronological order.
  17. hzn.burned Get the Burned events in reverse chronological order.
  18. hzn.feesClaimed Get the FeesClaimed events in reverse chronological order, showing fees in sUSD and rewards in hzn.
  19. hzn.debtSnapshot Get the historical debt balance for any wallet address.
  20. binaryOptions.markets Get all the binary options markets created.
  21. binaryOptions.optionTransactions Get all the Bid and Refund transactions made to the binary options markets.
  22. binaryOptions.historicalOptionPrice Get historical records of every option price for every market.
  23. etherCollateral.loans Get the list of all EtherCollateral loans opened.
  24. exchanger.exchangeEntriesSettled({ max, from }) Get the list of all settled exchanges.
  25. exchanges.aggregate({ max, timeSeries }) Get the total amount of exchanges aggregated across various time series.
  26. rate.hznAggregate({ max, timeSeries }) Get the price of hzn aggregated across various time series.
  27. hzn.aggregateActiveStakers({ max, timeSeries }) Get the number of active stakers across various time series.
  28. hzn.totalActiveStakers() Get the current number of active stakers.
  29. rate.dailyRateChange({ hassets }) get the rate change over the past 24 hours for any hasset. Can pass in a list to retrieve multiple hassets.
  30. hzn.accountsRemovedFromLiquidation({ maxTime, minTime, account, max }) finds all the accounts that have fixed their c-ratio to avoid being at risk of liquidation after being flagged.
  31. hzn.accountsFlaggedForLiquidation({ minTime, maxTime, account, max }) finds all the accounts that have been flagged for liquidation.
  32. hzn.accountsLiquidated({ maxTime, minTime, account, max }) finds all the accounts that have been liquidated after being flagged for liquidation.
  33. hzn.getActiveLiquidations({ max, account, minTime, maxTime }) finds all the accounts that have been flagged and are still pending liquidation or in a waiting state. Can also just check for a specific account if desired.

Supported subscriptions

The below all return an Observable that when subscribed to with an object.

  1. exchanges.observe() Get an observable to subscribe to that will next the latest exchanges in real time (replays the most recent exchange immediately).
  2. rate.observe() Get an observable to subscribe to that will next the latest rates in real time (replays the most recent exchange immediately).

Use this as a node or webpack dependency

const hznData = require('horizon-data'); // common js
// or
import hznData from 'horizon-data'; // es modules

// query and log resolved results
hznData.exchanges
	.since({
		minTimestamp: Math.floor(Date.now() / 1e3) - 3600 * 24, // one day ago
	})
	.then(exchanges => console.log(exchanges));

// subscribe and log streaming results
hznData.exchanges.observe().subscribe({
	next(val) {
		console.log(val);
	},
	error: console.error,
	complete() {
		console.log('done');
	},
});

Use in a browser

<script src="//cdn.jsdelivr.net/npm/horizon-data/browser.js"></script>
<script>
	window.hznData.exchanges
		.since({
			minTimestamp: Math.floor(Date.now() / 1e3) - 3600 * 24, // one day ago
		})
		.then(console.log);

	window.hznData.exchanges.observe().subscribe({ next: console.log });
</script>

How to query via the npm library (CLI)

# get last 24 hours of exchange activity, ordered from latest to earliest
npx horizon-data exchanges.since

# get exchanges on horizon as they occur in real time (replays the last exchange first)
npx horizon-data exchanges.subscribe