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

@rolla-finance/mm-api-client

v1.7.1

Published

Client library to interact with the Rolla ecosystem

Downloads

11

Readme

Rolla marker maker client

This package contains

  • TypeScript client for the Rolla REST api
  • WebSocket client for handling quote requests

The REST client is generated from the OpenAPI specification, is type-safe and easy to use.

Installation

npm install @rolla-finance/mm-api-client

Api client usage

Some of the calls that the client makes require jwt token authentication, generated using Sign-In with Ethereum. For that reason we require that you provide private key and chain id that we use to generate the authentication string, or provide a function that returns the authentication string. These credentials are used to generate the jwt token that is used for authentication. MM api client automatically refreshes the token when it expires.

The client uses Axios for http requests. You can pass in an existing Axios instance as well as other axios options in the second constructor argument.

Basic api client usage is as follows:

import { RollaApiClient } from '@rolla-finance/mm-api-client';

const client = new RollaApiClient({
  privateKey: 'private_key',
  chainId: 96,
});

// or construct with a function that returns the authentication string
const apiClient = new RollaApiClient(() =>
  someFunctionToGetAuthenticationString()
);

const assetsResponse = await client.getAllAssets();
await client.getMarketMakerActiveQuotes({
  optionAddress: '0x1',
  underlyingAddress: '0x2',
});
// etc.

WebSocket client usage

Websocket is used for receiving quote requests and metatransactions. The client is a wrapper around the ws package. As a market maker receiving data, you need to authenticate with the server. The authentication is done using a similar mechanism as the REST api, using ethereum private key and chain id.


import {
  MarketMakerQuoteRequestDto,
  MarketMakerQuoteResponseDto,
  RollaWS,
  RollaApiClient
} from "@rolla-finance/mm-api-client";

export const apiClient = new RollaApiClient({
  privateKey: 'private_key',
  chainId: 96,
});

const rollaWs = await apiClient.initRollaWS({
  // if set to true, this will generate additional logs
  debugMode: true,
  // how many times to retry connecting to the server until giving up
  retryCount: Infinity,
  // how long to wait between retries
  retryInterval: 1000,
});
// subscribe to quote requests, this will call the provided function when one or more quote requests are received
rollaWs.subscribeToQuoteRequests(listenAndRespondToQuotes);
// subscribe to meta transactions, this will call the provided function when one or more meta transactions are received
rollaWs.subscribeToMetaTxs(listenAndRespondToMetaTransactions);


const listenAndRespondToQuotes = async (requests: MarketMakerQuoteRequestDto[]) {
  const responses = await yourLogicForGeneratingQuotes(requests);
  if (responses.length) {
    await apiClient.postQuoteResponses({
      marketMakerQuoteResponseDto: responses,
    });
  }
}

const listenAndRespondToMetaTransactions = async (lastLookRequests: SignedMetaTransactionDto[]) {
  const signedResponses = await yourLogicForProcessingLastLookResponses(lastLookRequests);

  await apiClient.postMetaTransactionResponses({
    lastLookResponseWithOrderSignatureDto: signedResponses,
  });
}

License

BSL-1.0