Git Product home page Git Product logo

synthetix-optimism-data's Introduction

synthetix-data

npm version Discord Twitter Follow

This is a collection of utilities to query Synthetix data from Ethereum. This data has been indexed by The Graph via the various subgraphs the Synthetix 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 synth deposits (payments of ETH for sUSD) either from a given fromAddress or (and as well as) to a given toAddress
  3. exchanges.total() Get the total exchange volume, total fees and total number of unique exchange addresses.
  4. exchanges.rebates({ minTimestamp = 1 day ago }) Get the last N exchange rebates since the given minTimestamp in seconds. Ordered in reverse chronological order.
  5. exchanges.reclaims({ minTimestamp = 1 day ago }) Get the last N exchange reclaims since the given minTimestamp in seconds. Ordered in reverse chronological order.
  6. 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.
  7. rate.updates Get all rate updates for synths in reverse chronological order
  8. synths.issuers Get all wallets that have invoked Issue on sUSD (other synths to come)
  9. synths.transfers Get synth transfers in reverse chronological order
  10. snx.holders Get the list of wallets that have ever sent or received SNX.
  11. snx.rewards Get the list of reward escrow holders and their latest balance at vesting entry add or vest.
  12. snx.total Get the total count of unique issuers and snxHolders
  13. snx.transfers Get SNX transfers in reverse chronological order

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 snxData = require('synthetix-data'); // common js
// or
import snxData from 'synthetix-data'; // es modules

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

// subscribe and log streaming results
snxData.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/synthetix-data/browser.js"></script>
<script>
	window.snxData.exchanges
		.since({
			minTimestamp: Math.floor(Date.now() / 1e3) - 3600 * 24, // one day ago
		})
		.then(console.log);

	window.snxData.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 synthetix-data exchanges.since

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

synthetix-optimism-data's People

Contributors

0xclem avatar evgenyboxer avatar jjgonecrypto avatar k-ho avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.