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

@valorem-labs-inc/sdk

v0.0.12

Published

> This TypeScript SDK provides a streamlined interface for interacting with Valorem's smart > contracts and Trade API, enabling developers to build applications on top of Valorem's > infrastructure with ease. Please note that this SDK is a work in progres

Downloads

10

Readme

Valorem TypeScript SDK

This TypeScript SDK provides a streamlined interface for interacting with Valorem's smart contracts and Trade API, enabling developers to build applications on top of Valorem's infrastructure with ease. Please note that this SDK is a work in progress, and the API is subject to change, including potential breaking changes.

Table of Contents

Installation

To install the Valorem TypeScript SDK, choose your package manager and run the appropriate command:

Using npm:

npm i @valorem-labs-inc/sdk

Using pnpm:

pnpm i @valorem-labs-inc/sdk

Using yarn:

yarn add @valorem-labs-inc/sdk

Getting Started

To get started with the SDK, you'll need to set up the necessary clients from Viem and initialize the ValoremSDK. Here's a quick start guide:

import { createPublicClient, createWalletClient, http } from 'viem';
import { privateKeyToAccount } from 'viem/accounts';
import { arbitrumSepolia } from 'viem/chains';
import { ValoremSDK } from '@valorem-labs-inc/sdk';

// Replace YOUR_PRIVATE_KEY with your Ethereum private key.
const account = privateKeyToAccount(YOUR_PRIVATE_KEY);

// Set up Viem clients for the Arbitrum Sepolia test network.
const publicClient = createPublicClient({
  chain: arbitrumSepolia,
  transport: http(),
});

const walletClient = createWalletClient({
  account,
  chain: arbitrumSepolia,
  transport: http(),
});

// Initialize the Valorem SDK with the created clients.
const valoremSDK = new ValoremSDK({
  publicClient,
  walletClient,
});

Usage

Here's how you can sign in and send requests to the Trade API using the SDK:

import {
  ValoremSDK,
  OptionType,
  get24HrTimestamps,
  SupportedAsset,
  type ParsedQuoteResponse,
} from '@valorem-labs-inc/sdk';

// ... continuing from `Getting Started` section above
const webTaker = valoremSDK.webTaker;
const clearinghouse = valoremSDK.clearinghouse;

// Sign in to the Trade API.
await webTaker.signIn();

// Now you can send requests to the Trade API! Let's walkthrough setting up a basic quote request.
// First we need to get the option ID for the option we want to buy, so let's define the parameters.
// We'll use WETH as the underlying asset, and USDC as the exercise.
// For the exercise window we will use the next 24 hours.

// Our mock tokens on Arbitrum Sepolia
const USDC = SupportedAsset.fromSymbolAndChainId('USDC', 421614);
const WETH = SupportedAsset.fromSymbolAndChainId('WETH', 421614);

const underlyingAsset = WETH.address;
const exerciseAsset = USDC.address;
const underlyingAmount = 1000000000000n; // 1 WETH, divided by 1e6
const exerciseAmount = 2500n; // 2500 USDC, divided by 1e6
const { exerciseTimestamp, expiryTimestamp } = get24HrTimestamps();

// Now we have all the information we need to create an OptionType.
const optionType = await OptionType.fromInfo({
  optionInfo: {
    underlyingAsset,
    underlyingAmount,
    exerciseAsset,
    exerciseAmount,
    exerciseTimestamp,
    expiryTimestamp,
  },
  clearinghouse,
});

// And with the OptionType's id, we can initialize a quote request.
const quoteRequest = webTaker.createQuoteRequest({
  optionId,
  quantityToBuy: 1,
});

// Before we start sending requests, let's define a callback to handle responses from Market Makers.
// This one will automatically accept any quotes we receive.
async function onQuoteResponse(quote: ParsedQuoteResponse) {
  await webTaker.acceptQuote({ quote });
}

// Continuously send requests and handle responses...
await webTaker.sendRFQ({
  quoteRequest,
  onQuoteResponse,
});

For a more comprehensive example using the Valorem TypeScript SDK to create options, request quotes, and fulfill trade orders, check out the example script in trade-interfaces.

It covers token approvals, option type creation, and error handling in-depth.

Documentation

Documentation for the Valorem TypeScript SDK is available here.

Contributing

We welcome contributions to the Valorem TypeScript SDK! If you have suggestions, bug reports, or contributions, please submit them as issues or pull requests in the repository.

To update the version of a package:

  1. Make sure @changesets/cli is installed locally
  2. Then run pnpm changeset in your terminal to write a changelog update
  3. Then pnpm changeset version to to compile changes into changelog.md and bump version
  4. Finally run pnpm build && pnpm publish --no-git-checks --tag alpha to publish

License

The Valorem TypeScript SDK is licensed under the MIT License. See the LICENSE file for more details.