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

@openpool/definitive

v1.0.1

Published

The OpenPool Reporting SDK is a Typescript SDK for retrieving detailed onchain reporting data.

Downloads

8

Readme

OpenPool Onchain Reporting SDK

The OpenPool Reporting SDK is a Typescript SDK for retrieving detailed onchain reporting data.

Processing and navigating blockchain transaction data is time-consuming, while creating accurate on-chain reporting demands precision and financial know-how. OpenPool's SDK allows you to build bespoke financial dashboards and internal reporting to support business operations and customer demands. The OpenPool SDK is powered by the OpenPool API and requires an API Key, which you can get by signing up for a Free account on the OpenPool Developer Portal.

The OpenPool SDK currently supports the following chains:

  • Ethereum
  • Polygon
  • Base
  • Optimism
  • Arbitrum
  • Gnosis
  • Avalanche
  • BNB

🌟 Features

  • 📈 Detailed Wallet Balances & Performance: Retrieve the real-time and historical enriched balances and performance (with unrealized + realized P&L) data of a given wallet or contract’s tokens (ERC-20’s), NFTs, and DeFi staked positions.
  • 📒 Flexible Wallet Accounting History: Query an enriched human-readable transaction history with accounting data for a given wallet or contract. For these requests, a custom cost-method and base-currency can be provided.
  • 🏷️ Customizable Address Labels: Create, update and manage custom smart contract names for counterparty addresses your wallet interacts with.
  • 📇 Detailed Metadata: Retrieve metadata for Smart Contracts, Assets, Blockchains, Protocols and Tokens.
  • 🔒 Typescript: Written in Typescript with full type-safety
  • ➕ ...and more!

📚 Table of Contents

🏁 Getting Started

In order to make requests with the OpenPool SDK you will need to first sign up for an API Key on the OpenPool Dev Portal (it’s Free to sign up).

Installation

npm install @openpool/definitive

🛠️ Usage

Initialization

Once you install the SDK, you can initialize it like so:

import { OpenPool } from "@openpool/definitive";

const config = {
  apiKey: 'whatILearnedInBoatingSchoolIs', // Replace with your OpenPool API key.
};

const openpool = new OpenPool(config);

Making requests

Every address that you will want to retrieve data for will need to be registered first. Once registered, an address will have an is_loaded field that will update upon the completion of its transactions being processed.

💡 How to register an address

import { OpenPool } from "@openpool/definitive";

const config = {
  apiKey: 'whatILearnedInBoatingSchoolIs', // Replace with your OpenPool API key.
};

const openpool = new OpenPool(config);

const registerAddress = async (address: string) => {
  try {
    const requestBody = {address}
    const response = await openpool.registerWallet(requestBody);
    return response
  }
  catch(e){
    // Handle Error
  }
  finally {
    // Do something...
  }
}

const registerWalletResponse = await registerAddress('0x123abc')

💡 How to look up the registration status of an address

import { OpenPool } from "@openpool/definitive";

const config = {
  apiKey: 'whatILearnedInBoatingSchoolIs', // Replace with your OpenPool API key.
};

const openpool = new OpenPool(config);

const lookupTheRegistrationStatusOfAnAddress = async (address: string) => {
  try {
    const requestBody = {address}
    const response = await openpool.getWalletRegistrations(requestBody);
    const registrationStatusResults = response.results
    const registrationStatus = response.results[0].is_loaded
    return registrationStatus
  }
  catch(e){
    // Handle Error
  }
  finally {
    // Do something...
  }
}

const walletRegistrationStatus = await lookupTheRegistrationStatusOfAnAddress('0x123abc')

Examples

Fetching the token balance and performance in USD of a given address

import { OpenPool } from "@openpool/definitive";

const config = {
  apiKey: 'whatILearnedInBoatingSchoolIs', // Replace with your OpenPool API key.
};

const openpool = new OpenPool(config);

const getTokenBalancesForAnAddress = async (address: string) => {
  try {
    const params = { wallet: address }
    const tokenBalanceResponse = await openpool.getTokenBalances(params);
    return tokenBalanceResponse.result;
  }
  catch(e){
    // Handle Error
  }
  finally {
    // Do something...
  }
}

Fetching the enriched transactions data for a set of addresses

import { OpenPool } from "@openpool/definitive";

const config = {
  apiKey: 'whatILearnedInBoatingSchoolIs', // Replace with your OpenPool API key.
};

const openpool = new OpenPool(config);

const getTransactionsForAddress = async (address: string) => {
  try {
    const params = { wallet: address }
    const transactionsResponse = await openpool.getTransactions(params);
    return transactionsResponse.result;
  }
  catch(e) {
    // Handle Error
  }
  finally {
    // Do something...
  }
}

const transactions = await getTransactionsForAddress("0x123abc, 0x456cdef, 0x789ghi")

Getting the total unrealized P&L of a given address

import { OpenPool } from "@openpool/definitive";

const config = {
  apiKey: 'whatILearnedInBoatingSchoolIs', // Replace with your OpenPool API key.
};

const openpool = new OpenPool(config);
    const params = { wallet: address }

const getTotalUnrealizedPnl = async (address: string) => {
  try {
    const params = { wallet: address }
    const transactionsResponse = await openpool.getTotalUnrealizedPnl(params);
    return transactionsResponse.value;
  }
  catch(e) {
    // Handle Error
  }
  finally {
    // Do something...
  }
}

const unrealizedPnl = await getTotalUnrealizedPnl('0x123abc')

📖 API Reference

Table of Contents

  1. Core SDK Methods
  2. Definitive Specific Methods

Core SDK Methods

The core methods for the SDK can be found in its Readme on its NPM page here.

Definitive Specific Methods

getDefinitiveNAV(query: PrivateDefinitiveNAVQuery)

Description

Get the NAV of a given Definitive vault address, in the time period specified.

  • OpenPool API Endpoint: GET:/private/definitive/nav/

Parameters

| Name | Type | Description | Optional | | ----- | ------------------------- | --------------------------------------------------------------------------------------------------------- | -------- | | query | PrivateDefinitiveNAVQuery | Requires a token_address, vault_address, and optionally a period ("Y", "3M", "D", "M", "MAX", "W", "YTD") | No |

PrivateDefinitiveNAVQuery Interface

 {
  token_address: string;
  vault_address: string;
  period?: "Y" | "3M" | "D" | "M" | "MAX" | "W" | "YTD"
}

getDefinitiveUserPerformance(query: PrivateDefinitiveUserPerformanceQuery)

Description

Get the performance of a specific Definitive user's address, in the specified time period

  • OpenPool API Endpoint: GET:/private/definitive/performance/

Parameters

| Name | Type | Description | Optional | | ----- | ------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | | query | PrivateDefinitiveUserPerformanceQuery | Requires a token_address, vault_address, user_address, type, and optionally a period ("Y", "3M", "D", "M", "MAX", "W", "YTD") | No |

PrivateDefinitiveUserPerformanceQuery Interface

 {
  token_address: string;
  user_address: string;
  vault_address: string;
  type?: "twr" | "notional"
  period?: "Y" | "3M" | "D" | "M" | "MAX" | "W" | "YTD"
}